Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DL1MCTrigger_factory.h
Go to the documentation of this file.
1 #ifndef _DL1MCTrigger_factory_
2 #define _DL1MCTrigger_factory_
3 
4 #include <JANA/JFactory.h>
5 
6 #include "DL1MCTrigger.h"
7 
8 
10 
11 #include "FCAL/DFCALGeometry.h"
12 #include <FCAL/DFCALHit.h>
13 
14 #include <BCAL/DBCALHit.h>
15 
16 #include <DRandom2.h>
17 
18 #include <TH1.h>
19 #include <TH2.h>
20 
21 typedef vector< vector<double> > fcal_constants_t;
22 
23 class DL1MCTrigger_factory:public jana::JFactory<DL1MCTrigger>{
24  public:
27 
28  static const int sample = 125;
29  static const int time_stamp = 4.;
30  static const int max_adc_bins = 4096; /* number of FADC bins */
31 
32  static const int FCAL_MAX_CHANNELS = 2800;
33 
34  static const int TRIG_BASELINE = 100;
35 
36  fcal_constants_t fcal_gains;
37  fcal_constants_t fcal_pedestals;
38 
41 
44 
45  typedef struct {
46  int row;
47  int column;
48 
49  double energy;
50  double time;
51 
52  double adc_en[sample];
53  int adc_amp[sample];
54 
55  int merged;
56  } fcal_signal;
57 
58 
59  typedef struct {
60  int module;
61  int layer;
62  int sector;
63  int end;
64 
65  double time; /* Pulse time in ns */
66  double energy; /* Pulse energy in MeV */
67 
68  double adc_en[sample];
69  int adc_amp[sample];
70 
71  int merged;
72  } bcal_signal;
73 
74  typedef struct {
75 
76  int fcal;
77  int bcal;
78  int en_thr;
79 
80  int fcal_min;
81  int fcal_max;
82  int bcal_min;
83  int bcal_max;
84 
85  int st_nhit;
86  int tagh_nhit;
87  int tof_nhit;
88  int ps_nhit;
89 
90  unsigned int st_pattern;
91  unsigned int tagh_pattern;
92  unsigned int tof_pattern;
93  unsigned int ps_pattern;
94  } gtp_par;
95 
96 
97  typedef struct {
98 
99  int status;
100 
101  int bit;
102  int type; // Bit pattern: bit 1: FCAL
103  // bit 2: BCAL
104  // bit 3: ST
105  // bit 4: PS
106  // bit 5: TAGH
107  // bit 6: TOF
108 
110 
111  float fcal_en;
112  float bcal_en;
113  float en_thr;
114 
115  float fcal_min_en;
116  float fcal_max_en;
117  float bcal_min_en;
118  float bcal_max_en;
119  } trigger_conf;
120 
121  typedef struct{
122  int roc;
123  int slot;
124  int ch;
125 
126  int col;
127  int row;
128  } fcal_mod;
129 
130  typedef struct{
131  int roc;
132  int slot;
133  int ch;
134 
135  int module;
136  int layer;
137  int sector;
138  int end;
139  } bcal_mod;
140 
141  vector<trigger_conf> triggers_enabled;
142 
143  vector<fcal_mod> fcal_trig_mask;
144  vector<bcal_mod> bcal_trig_mask;
145 
146  vector<fcal_signal> fcal_signal_hits;
147  vector<bcal_signal> bcal_signal_hits;
148 
149  vector<fcal_signal> fcal_merged_hits;
150  vector<bcal_signal> bcal_merged_hits;
151 
152  int BYPASS;
156  int FCAL_NSA;
157  int FCAL_NSB;
159 
163  int BCAL_NSA;
164  int BCAL_NSB;
166 
168 
171  int ST_NSA;
172  int ST_NSB;
174  int ST_NHIT;
175 
177 
180 
181 
182  double time_shift;
183  double time_min;
184  double time_max;
185 
189 
192 
193 
194  int Read_RCDB(int32_t runnumber);
195  int SignalPulse(double en, double time, double amp_array[sample], int type);
196 
197  void AddBaseline(double adc_amp[sample], double pedestal, DRandom2 &gDRandom);
198 
199  void Digitize(double adc_amp[sample], int adc_count[sample]);
200 
201  template <typename T> int FADC_SSP(vector<T> merged_hits,
202  int detector);
203  int GTP(int detector);
204  int FindTriggers(DL1MCTrigger *trigger);
205  void PrintTriggers();
206 
208 
209  private:
210  jerror_t init(void); ///< Called once at program start.
211  jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber); ///< Called everytime a new run number is detected.
212  jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber); ///< Called every event.
213  jerror_t erun(void); ///< Called everytime run number changes, provided brun has been called.
214  jerror_t fini(void); ///< Called after last event of last event source has been processed.
215 
216 
217  void LoadFCALConst( fcal_constants_t &table,
218  const vector<double> &fcal_const_ch,
219  const DFCALGeometry &fcalGeom);
220 
221 
222  void GetSeeds(JEventLoop *loop, uint64_t eventnumber, UInt_t &seed1, UInt_t &seed2, UInt_t &seed3);
223 
224  TH1F *hfcal_gains;
226  TH1F *hfcal_ped;
227 
228  int debug;
229 
230 };
231 
232 #endif // _DL1MCTrigger_factory_
233 
static const int max_adc_bins
vector< bcal_signal > bcal_merged_hits
jerror_t init(void)
Called once at program start.
DRandom2 gDRandom
int SignalPulse(double en, double time, double amp_array[sample], int type)
static const int FCAL_MAX_CHANNELS
void LoadFCALConst(fcal_constants_t &table, const vector< double > &fcal_const_ch, const DFCALGeometry &fcalGeom)
vector< bcal_signal > bcal_signal_hits
fcal_constants_t fcal_pedestals
vector< trigger_conf > triggers_enabled
void AddBaseline(double adc_amp[sample], double pedestal, DRandom2 &gDRandom)
vector< bcal_mod > bcal_trig_mask
fcal_constants_t fcal_gains
vector< fcal_signal > fcal_merged_hits
static const int TRIG_BASELINE
static const int time_stamp
int FADC_SSP(vector< T > merged_hits, int detector)
void Digitize(double adc_amp[sample], int adc_count[sample])
void GetSeeds(JEventLoop *loop, uint64_t eventnumber, UInt_t &seed1, UInt_t &seed2, UInt_t &seed3)
jerror_t fini(void)
Called after last event of last event source has been processed.
int FindTriggers(DL1MCTrigger *trigger)
vector< fcal_signal > fcal_signal_hits
static TH1I * pedestal[nChan]
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
vector< vector< double > > fcal_constants_t
vector< fcal_mod > fcal_trig_mask
int Read_RCDB(int32_t runnumber)
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.