14 #include <JANA/JApplication.h>
41 vector<const DBCALGeometry *> BCALGeomVec;
42 eventLoop->Get(BCALGeomVec);
43 if(BCALGeomVec.size() == 0)
44 throw JException(
"Could not load DBCALGeometry object!");
50 unattenuate_to_center = exp(+L_over_2/Xo);
52 USE_OLD_BCAL_HITS = 0;
53 gPARMS->SetDefaultParameter(
"TRIGGER:USE_OLD_BCAL_HITS", USE_OLD_BCAL_HITS,
54 "Use old DBCALHit calculation for BCAL energy sum.");
63 BCAL_CHANNEL_THRESHOLD = 455.;
64 FCAL_CHANNEL_THRESHOLD = 0.130;
65 gPARMS->SetDefaultParameter(
"TRIGGER:BCAL_CHANNEL_THRESHOLD", BCAL_CHANNEL_THRESHOLD,
66 "Threshold for BCAL energy sum (units of adc counts)");
67 gPARMS->SetDefaultParameter(
"TRIGGER:FCAL_CHANNEL_THRESHOLD", FCAL_CHANNEL_THRESHOLD,
68 "Threshold for FCAL energy sum (units of MeV)");
81 vector<const DBCALHit*> bcalhits;
82 vector<const DFCALHit*> fcalhits;
83 vector<const DSCHit*> schits;
84 vector<const DTOFHit*> tofhits;
91 double Ebcal_all = 0.0;
93 double Efcal_all = 0.0;
94 double BCAL_Eupstream = 0.0;
95 double BCAL_Edownstream = 0.0;
98 if(USE_OLD_BCAL_HITS) {
126 for(
unsigned int i=0; i< bcalhits.size(); i++){
127 const DBCALHit* bcalhit = bcalhits[i];
130 Ebcal_all += bcalhit->
E;
132 BCAL_Eupstream += bcalhit->
E;
134 Ebcal_all += bcalhit->
E;
136 BCAL_Edownstream += bcalhit->
E;
141 Ebcal = unattenuate_to_center * (BCAL_Eupstream + BCAL_Edownstream)/2.0;
144 for(
unsigned int i=0; i< fcalhits.size(); i++){
145 const DFCALHit* fcalhit = fcalhits[i];
147 Efcal_all += fcalhit->
E;
148 if(fcalhit->
E > FCAL_CHANNEL_THRESHOLD)
153 for(
unsigned int i=0; i< bcalhits.size(); i++){
154 const DBCALHit* bcalhit = bcalhits[i];
156 bcalhit->GetSingle(bcaldigihit);
157 if(bcaldigihit == NULL)
160 Ebcal_all += bcalhit->
E;
166 for(
unsigned int i=0; i< fcalhits.size(); i++){
167 const DFCALHit* fcalhit = fcalhits[i];
169 Efcal_all += fcalhit->
E;
170 if(fcalhit->
E > FCAL_CHANNEL_THRESHOLD)
176 unsigned int Nschits = schits.size();
179 unsigned int Ntofhits = tofhits.size();
184 bool sum_cut = (Ebcal + 4.0*Efcal)>=2.0;
185 trig->
L1a_fired = sum_cut && Ebcal>0.200 && Efcal>0.030;
186 trig->
L1b_fired = sum_cut && Ebcal>0.030 && Efcal>0.030 && Nschits>0;
196 _data.push_back(trig);
jerror_t init(void)
Called once at program start.
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
float GetBCAL_attenutation_length() const
float GetBCAL_length() const
uint32_t pulse_integral
identified pulse integral as returned by FPGA algorithm
jerror_t fini(void)
Called after last event of last event source has been processed.
static double BCAL_MEV_PER_ADC_COUNT
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.