Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DBCALUnifiedHit_factory.h
Go to the documentation of this file.
1 #ifndef _DBCALUnifiedHit_factory_
2 #define _DBCALUnifiedHit_factory_
3 
4 #include <JANA/JFactory.h>
5 #include <JANA/JEventLoop.h>
6 
7 using namespace jana;
8 
9 #include "BCAL/DBCALUnifiedHit.h"
10 #include "BCAL/DBCALTDCHit.h"
11 #include "BCAL/DBCALHit.h"
12 #include "BCAL/DBCALGeometry.h"
13 
14 #include <TTree.h>
15 
16 class DBCALUnifiedHit_factory : public JFactory<DBCALUnifiedHit> {
17 
18  public:
19 
20  int VERBOSE;
22  VERBOSE = 0;
23  if(gPARMS){
24  gPARMS->SetDefaultParameter("BCALUNIFIEDHIT:VERBOSE", VERBOSE, "Set level of verbosity.");
25  }
26  }
28 
30 
31  private:
32 
33  class cellHits{
34  public:
35  vector<const DBCALHit*> hits;
36  vector<const DBCALTDCHit*> tdc_hits;
37  };
38 
39  jerror_t init(void);
40  jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber); ///< Called everytime a new run number is detected.
41  jerror_t evnt(JEventLoop *loop, uint64_t eventnumber);
42 
43  // Use TDC Times"
44  bool USE_TDC;
45 
46  float E_tree;
47  float t_tdc_tree;
48  float t_adc_tree;
52  bool end_tree;
53 
54  //Used as a key for maps
56  public:
58  cellId(cellId), end(end) {}
59 
60  int cellId;
62 
63  bool operator<(const readout_channel &c) const {
64  if (cellId<c.cellId) return true;
65  if (cellId>c.cellId) return false;
66  if (end==DBCALGeometry::kUpstream && c.end==DBCALGeometry::kDownstream) return true;
67  return false;
68  }
69  };
70 
71  //For now timewalk corrections are of the form f(ADC) = c0 + c1/(ADC-c3)^c2
72  //Store all coefficients in one structure
73  /* class timewalk_coefficients { */
74  /* public: */
75  /* timewalk_coefficients() : */
76  /* a_thresh(0), c0(0), c1(0), c2(0) {} */
77  /* timewalk_coefficients(float c0, float c1, float c2, float a_thresh) : */
78  /* a_thresh(a_thresh), c0(c0), c1(c1), c2(c2) {} */
79  /* float a_thresh,c0,c1,c2; */
80  /* }; */
81 
82  /* map<readout_channel,timewalk_coefficients> tdc_timewalk_map; */
83 
84  // structure to store a 4 parameter fit with a threshold
86  public:
88  thresh(0), c0(0), c1(0), c2(0), c3(0) {}
89  timewalk_coefficients_c4(float c0, float c1, float c2, float c3, float thresh) :
90  thresh(thresh), c0(c0), c1(c1), c2(c2), c3(c3) {}
91  float thresh,c0,c1,c2,c3;
92  };
93 
94  map<readout_channel,timewalk_coefficients_c4> tdc_timewalk_map_c4;
95 
97 
98  //write out tree with hit info?
99  static const int enable_debug_output = 0;
100 };
101 
102 #endif //_DBCALUnifiedHit_factory_
Double_t c0[2][NMODULES]
Definition: tw_corr.C:67
const DBCALGeometry * dBCALGeom
#define c
map< readout_channel, timewalk_coefficients_c4 > tdc_timewalk_map_c4
bool operator<(const readout_channel &c) const
Double_t c1[2][NMODULES]
Definition: tw_corr.C:68
Double_t c2[2][NMODULES]
Definition: tw_corr.C:69
timewalk_coefficients_c4(float c0, float c1, float c2, float c3, float thresh)
const bool VERBOSE
readout_channel(int cellId, DBCALGeometry::End end)
TCanvas * c3
vector< const DBCALTDCHit * > tdc_hits