File: | /volatile/halld/gluex/nightly/2024-03-30/Linux_CentOS7.7-x86_64-gcc4.8.5/halld_recon/src/plugins/monitoring/BEAM_online/JEventProcessor_BEAM_online.cc |
Location: | line 239, column 5 |
Description: | Value stored to 'epair' is never read |
1 | // $Id$ |
2 | // |
3 | // File: JEventProcessor_BEAM_online.cc |
4 | // Created: Thu Jan 9 11:26:05 EST 2020 |
5 | // Creator: zihlmann (on Linux ifarm1901.jlab.org 3.10.0-1062.4.1.el7.x86_64 x86_64) |
6 | // |
7 | |
8 | #include "JEventProcessor_BEAM_online.h" |
9 | using namespace jana; |
10 | |
11 | |
12 | // Routine used to create our JEventProcessor |
13 | #include <JANA/JApplication.h> |
14 | #include <JANA/JFactory.h> |
15 | extern "C"{ |
16 | void InitPlugin(JApplication *app){ |
17 | InitJANAPlugin(app); |
18 | app->AddProcessor(new JEventProcessor_BEAM_online()); |
19 | } |
20 | } // "C" |
21 | |
22 | |
23 | //------------------ |
24 | // JEventProcessor_BEAM_online (Constructor) |
25 | //------------------ |
26 | JEventProcessor_BEAM_online::JEventProcessor_BEAM_online() |
27 | { |
28 | |
29 | } |
30 | |
31 | //------------------ |
32 | // ~JEventProcessor_BEAM_online (Destructor) |
33 | //------------------ |
34 | JEventProcessor_BEAM_online::~JEventProcessor_BEAM_online() |
35 | { |
36 | |
37 | } |
38 | |
39 | //------------------ |
40 | // init |
41 | //------------------ |
42 | jerror_t JEventProcessor_BEAM_online::init(void) |
43 | { |
44 | // This is called once at program startup. |
45 | // create root folder for BEAM histograms |
46 | TDirectory *main = gDirectory(ROOT::Internal::TDirectoryAtomicAdapter(TDirectory::CurrentDirectory ())); |
47 | gDirectory(ROOT::Internal::TDirectoryAtomicAdapter(TDirectory::CurrentDirectory ()))->mkdir("BEAM")->cd(); |
48 | |
49 | TriggerTime = new TH1D("TriggerTime", "Time difference of consecuitive triggers [ns]", 10000, 0., 200e3); |
50 | TriggerTime->SetTitle("Time difference between two consecutive physics triggers"); |
51 | TriggerTime->GetXaxis()->SetTitle("#Deltat [ns]"); |
52 | |
53 | PStagm = new TH1D("PStagm", "PStime minus tagm time", 5000, -120., 100.); |
54 | PStagh = new TH1D("PStagh", "PStime minus tagh time", 5000, -120., 100.); |
55 | |
56 | PStagm2d = new TH2D("PStagm2d", "Microscope Counter ID vs. tagm time - PStime", 1000, -120., 100., 120, 0., 120.); |
57 | PStagh2d = new TH2D("PStagh2d", "Hodoscope Counter ID vs. tagh time - PStime", 1000, -120., 100., 350, 0., 350.); |
58 | |
59 | PStagmEnergyInTime = new TH1D("PStagmEnergyInTime", "PSEnergy - TaggerEnergy in time photons microscope", 2000, -4., 4.); |
60 | PStagmEnergyOutOfTime = new TH1D("PStagmEnergyOutOfTime", "PSEnergy - TaggerEnergy out of time photons microscope", 2000, -4., 4.); |
61 | PStaghEnergyInTime = new TH1D("PStaghEnergyInTime", "PSEnergy - TaggerEnergy in time photons hodoscope", 2000, -4., 4.); |
62 | PStaghEnergyOutOfTime = new TH1D("PStaghEnergyOutOfTime", "PSEnergy - TaggerEnergy outo of time photons hodoscope", 2000, -4., 4.); |
63 | |
64 | PStagmEIT = new TH2D("PStagmEIT", "TAGM ID vs (PSEnergy - TaggerEnergy) in time photons", 2000, -4., 4., 120, 0, 120); |
65 | PStagmEOOT = new TH2D("PStagmEOOT", "TAGM ID vs PSEnergy - (TaggerEnergy) out of time photons", 2000, -4., 4., 120, 0, 120); |
66 | |
67 | PStaghEIT = new TH2D("PStaghEIT", "TAGH ID vs (PSEnergy - TaggerEnergy) in time photons", 2000, -4., 4., 350, 0, 350); |
68 | PStaghEOOT = new TH2D("PStaghEOOT", "TAGH ID vs PSEnergy - (TaggerEnergy) out of time photons", 2000, -4., 4., 350, 0, 350); |
69 | |
70 | outoftimeH = new TH1D("outoftimeH", "outoftime deltat tagger hits H", 10000, -100., 100.); |
71 | outoftimeM = new TH1D("outoftimeM", "outoftime deltat tagger hits M ", 5000, -100., 100.); |
72 | outoftimeMIX = new TH1D("outoftimeMIX", "outoftime deltat tagger hits MIX", 5000, -100., 100.); |
73 | outoftimeHij = new TH1D("outoftimeHij", "outoftime deltat tagger hits Hij i=220 j=100", 5000, -100., 100.); |
74 | |
75 | correlationC = new TH2D("correlationC", "Tagger Counter correlations when in time", 350, 0, 350., 350, 0., 350.); |
76 | correlationE = new TH1D("correlationE", "Tagger Counter Energy Sum when in time", 1000, 4., 13.); |
77 | |
78 | |
79 | acc = new TH2D("acc", "Microscope Counter ID vs. acc time difference with bunch -11", 1000, -120., 100., 120, 0., 120.); |
80 | fencePS = new TH1D("fencePS", "tagm time minus PS_time", 6000, -120., 120.); |
81 | fenceRF = new TH1D("fenceRF", "tagm time minus RF_time", 6000, -120., 120.); |
82 | |
83 | deltaT =new TH2D("deltaT", "Microscope counter time differences", 8000, -200., 200., 130, 0., 130); |
84 | deltaTall =new TH2D("deltaTall", "ALL Microscope counter time differences", 8000, -200., 200., 130, 0., 130.); |
85 | deltaTs =new TH2D("deltaTs", "Microscope counter time differences with itself", 80, -2., 2., 130, 0., 130.); |
86 | deltaTsa =new TH2D("deltaTsa", "Microscope counter time differences with itself all", 80, -2., 2., 130, 0., 130.); |
87 | |
88 | MICdeltaT = new TH2D("MICdeltaT", "dT = Tmic-Tref vs Microscope counter for random triggers", 130, 0., 130., 8000, -200., 200. ); |
89 | |
90 | main->cd(); |
91 | return NOERROR; |
92 | } |
93 | |
94 | //------------------ |
95 | // brun |
96 | //------------------ |
97 | jerror_t JEventProcessor_BEAM_online::brun(JEventLoop *eventLoop, int32_t runnumber) |
98 | { |
99 | // This is called whenever the run number changes |
100 | BlockStart = 1; |
101 | RFWidth = 4.008; // 249.5MHz correspondes to 4.008ns |
102 | |
103 | return NOERROR; |
104 | } |
105 | |
106 | //------------------ |
107 | // evnt |
108 | //------------------ |
109 | jerror_t JEventProcessor_BEAM_online::evnt(JEventLoop *loop, uint64_t eventnumber) |
110 | { |
111 | // This is called for every event. Use of common resources like writing |
112 | // to a file or filling a histogram should be mutex protected. Using |
113 | // loop->Get(...) to get reconstructed objects (and thereby activating the |
114 | // reconstruction algorithm) should be done outside of any mutex lock |
115 | // since multiple threads may call this method at the same time. |
116 | // Here's an example: |
117 | // |
118 | // vector<const MyDataClass*> mydataclasses; |
119 | // loop->Get(mydataclasses); |
120 | // |
121 | // japp->RootFillLock(this); |
122 | // ... fill historgrams or trees ... |
123 | // japp->RootFillUnLock(this); |
124 | |
125 | |
126 | vector <const DL1Trigger*> trig; |
127 | loop->Get(trig); |
128 | |
129 | if (trig.size() == 0){ |
130 | //cout<<"no trigger found"<<endl; |
131 | return NOERROR; |
132 | } |
133 | |
134 | if (!eventnumber%40){ |
135 | // this is the first event in the block |
136 | BlockStart = 1; |
137 | } |
138 | |
139 | if (!BlockStart && (trig[0]->trig_mask & 0x3)){ |
140 | double dt = (double)(trig[0]->timestamp - LastTime)*4.; // units are in ns |
141 | TriggerTime->Fill(dt); |
142 | LastTime = trig[0]->timestamp; |
143 | } |
144 | |
145 | if (BlockStart && (trig[0]->trig_mask > 0)){ |
146 | // this is the first physics trigger in the block |
147 | BlockStart = 0; |
148 | LastTime = trig[0]->timestamp; |
149 | } |
150 | |
151 | |
152 | // This of for PS-Triggers Bit 4 |
153 | if (trig[0]->trig_mask & 0x8){ |
154 | |
155 | vector <const DBeamPhoton*> Beam; |
156 | loop->Get(Beam); |
157 | int NBeamPhotons = Beam.size(); |
158 | vector <const DPSPair*> PSPairs; |
159 | loop->Get(PSPairs); |
160 | |
161 | if (PSPairs.size() < 1){ |
162 | return NOERROR; |
163 | } |
164 | |
165 | vector <const DPSPair*> OutOfTimePairsM; |
166 | vector <const DPSPair*> OutOfTimePairsH; |
167 | vector <const DBeamPhoton*> OutOfTimeBeamM; |
168 | vector <const DBeamPhoton*> OutOfTimeBeamH; |
169 | vector <const DBeamPhoton*> OutOfTimeBeamPhotons; |
170 | |
171 | double Width = RFWidth; // 249.5MHz correspondes to 4.008ns |
172 | double tpair = (PSPairs[0]->ee.first->t + PSPairs[0]->ee.second->t) / 2.; |
173 | double epair = (PSPairs[0]->ee.first->E + PSPairs[0]->ee.second->E); |
174 | |
175 | // loop over beam photons |
176 | for (int k=0; k<NBeamPhotons; k++){ |
177 | float dt = Beam[k]->time() - tpair; |
178 | |
179 | // Beam photon is out of time with PS-event |
180 | if (TMath::Abs(dt) > Width*3./2.) { |
181 | OutOfTimeBeamPhotons.push_back(Beam[k]); |
182 | if (Beam[k]->dSystem == SYS_TAGM){ |
183 | OutOfTimeBeamM.push_back(Beam[k]); |
184 | }else { |
185 | OutOfTimeBeamH.push_back(Beam[k]); |
186 | } |
187 | } |
188 | |
189 | if (Beam[k]->dSystem == SYS_TAGM){ |
190 | |
191 | for (int n=0; n<(int)PSPairs.size(); n++){ |
192 | const DPSPair *pair = PSPairs[n]; |
193 | tpair = (PSPairs[n]->ee.first->t + PSPairs[n]->ee.second->t) / 2.; |
194 | epair = (PSPairs[n]->ee.first->E + PSPairs[n]->ee.second->E); |
195 | double delta = Beam[k]->time() - tpair; |
196 | PStagm->Fill(delta); |
197 | PStagm2d->Fill(delta, Beam[k]->dCounter); |
198 | |
199 | if (TMath::Abs(delta)<Width/2.){ |
200 | double DeltaE = Beam[k]->momentum().Mag() - epair; |
201 | PStagmEnergyInTime->Fill(-DeltaE); |
202 | PStagmEIT->Fill(-DeltaE, Beam[k]->dCounter); |
203 | |
204 | } else if ( ( TMath::Abs(delta) > Width*3./2.) && |
205 | ( TMath::Abs(delta) < Width*3./2.+ 10.*Width)) { // +/- 10 beam bunches! |
206 | double DeltaE = Beam[k]->momentum().Mag() - epair; |
207 | PStagmEnergyOutOfTime->Fill(-DeltaE); |
208 | PStagmEOOT->Fill(-DeltaE, Beam[k]->dCounter); |
209 | OutOfTimePairsM.push_back(pair); |
210 | } |
211 | } |
212 | |
213 | } else { |
214 | |
215 | for (int n=0; n<(int)PSPairs.size(); n++){ |
216 | const DPSPair *pair = PSPairs[n]; |
217 | tpair = (PSPairs[n]->ee.first->t + PSPairs[n]->ee.second->t) / 2.; |
218 | epair = (PSPairs[n]->ee.first->E + PSPairs[n]->ee.second->E); |
219 | double delta = Beam[k]->time() - tpair; |
220 | PStagh->Fill(delta); |
221 | PStagh2d->Fill(delta, Beam[k]->dCounter); |
222 | if (TMath::Abs(delta)<Width/2.){ |
223 | double DeltaE = Beam[k]->momentum().Mag() - epair; |
224 | PStaghEnergyInTime->Fill(-DeltaE); |
225 | PStaghEIT->Fill(-DeltaE, Beam[k]->dCounter); |
226 | |
227 | } else if( ( TMath::Abs(delta) > Width*3./2.) && |
228 | ( TMath::Abs(delta) < Width*3./2.+10.*Width)) { // +/- 20 beam bunches! |
229 | double DeltaE = Beam[k]->momentum().Mag() - epair; |
230 | PStaghEnergyOutOfTime->Fill(-DeltaE); |
231 | PStaghEOOT->Fill(-DeltaE, Beam[k]->dCounter); |
232 | OutOfTimePairsH.push_back(pair); |
233 | } |
234 | } |
235 | } |
236 | } |
237 | |
238 | tpair = (PSPairs[0]->ee.first->t + PSPairs[0]->ee.second->t) / 2.; |
239 | epair = (PSPairs[0]->ee.first->E + PSPairs[0]->ee.second->E); |
Value stored to 'epair' is never read | |
240 | |
241 | //loop over hoddoscope out of time hits |
242 | for ( int n=0; n < ((int)OutOfTimeBeamH.size()-1); n++){ |
243 | const DBeamPhoton* b1 = OutOfTimeBeamH[n]; |
244 | |
245 | if (TMath::Abs( b1->time() - tpair - Width*12.) > Width*4.+Width/2.){ |
246 | continue; |
247 | } |
248 | |
249 | // match with other hodoscope hits |
250 | for ( int j=0; j<(int)OutOfTimeBeamH.size(); j++){ |
251 | if (j==n){ |
252 | continue; |
253 | } |
254 | |
255 | const DBeamPhoton* b2 = OutOfTimeBeamH[j]; |
256 | |
257 | if (TMath::Abs(b1->momentum().Mag() + b2->momentum().Mag() - 11.6)<0.2){ |
258 | continue; // get rid of mollers |
259 | } |
260 | if (TMath::Abs((int)b1->dCounter - (int)b2->dCounter)<8){ |
261 | continue; // get rid of neibouring hits. |
262 | } |
263 | |
264 | double deltat = b1->time() - b2->time(); |
265 | outoftimeH->Fill(deltat); |
266 | } |
267 | } |
268 | |
269 | //loop over hoddoscope out of time hits |
270 | for (unsigned int n=0; n<OutOfTimeBeamH.size(); n++){ |
271 | const DBeamPhoton* b1 = OutOfTimeBeamH[n]; |
272 | if (TMath::Abs( b1->time() - tpair - Width*12.) > Width*4+Width/2.){ |
273 | continue; |
274 | } |
275 | |
276 | // match with microscope hits |
277 | for (unsigned int j=0; j<OutOfTimeBeamM.size(); j++){ |
278 | const DBeamPhoton* b2 = OutOfTimeBeamM[j]; |
279 | if (TMath::Abs(b1->momentum().Mag() + b2->momentum().Mag() - 11.6)>0.2){ |
280 | double deltat = b1->time() - b2->time(); |
281 | outoftimeMIX->Fill(deltat); |
282 | } |
283 | } |
284 | } |
285 | |
286 | // loop over microscope out of time hits |
287 | for (int n=0; n<((int)OutOfTimeBeamM.size()-1); n++){ |
288 | const DBeamPhoton* b1 = OutOfTimeBeamM[n]; |
289 | if (TMath::Abs( b1->time() - tpair - Width*12.) > Width*4+Width/2.){ |
290 | continue; |
291 | } |
292 | |
293 | //match with other microscope out of time hits |
294 | for (int j=0; j<(int)OutOfTimeBeamM.size(); j++){ |
295 | if (j==n){ |
296 | continue; |
297 | } |
298 | const DBeamPhoton* b2 = OutOfTimeBeamM[j]; |
299 | |
300 | if (TMath::Abs(b1->momentum().Mag() + b2->momentum().Mag() - 11.6) < 0.2){ |
301 | continue; // get rid of potential mollers |
302 | } |
303 | if (TMath::Abs((int)b1->dCounter - (int)b2->dCounter)<8){ |
304 | continue; // get rid of neibouring hits. |
305 | } |
306 | |
307 | double deltat = b1->time() - b2->time(); |
308 | outoftimeM->Fill(deltat); |
309 | |
310 | } |
311 | } |
312 | |
313 | // look for potential Moller pairs |
314 | for (int n=0; n<((int)OutOfTimeBeamPhotons.size()-1); n++){ |
315 | const DBeamPhoton* b1 = OutOfTimeBeamPhotons[n]; |
316 | for (int j=n+1; j<(int)OutOfTimeBeamPhotons.size(); j++){ |
317 | const DBeamPhoton* b2 = OutOfTimeBeamPhotons[j]; |
318 | if (TMath::Abs(b1->time()-b2->time()) < Width/2.){ |
319 | int idx1 = b1->dCounter; |
320 | int idx2 = b2->dCounter; |
321 | if (b1->dSystem == SYS_TAGM){ |
322 | idx1+=130; |
323 | } else { |
324 | if (idx1>130){ |
325 | idx1 += 70; |
326 | } |
327 | } |
328 | if (b2->dSystem == SYS_TAGM){ |
329 | idx2+=130; |
330 | } else { |
331 | if (idx2>130){ |
332 | idx2 += 70; |
333 | } |
334 | } |
335 | |
336 | correlationC->Fill(idx1, idx2); |
337 | double E = (11.6-b1->momentum().Mag()) + (11.6-b2->momentum().Mag()); |
338 | correlationE->Fill(E); |
339 | } |
340 | } |
341 | } |
342 | |
343 | for (int k=0; k<NBeamPhotons; k++){ |
344 | const DBeamPhoton* b1 = Beam[k]; |
345 | |
346 | if (b1->dSystem != SYS_TAGM){ // look only at microscope |
347 | continue; |
348 | } |
349 | if (PSPairs.size()>0){ |
350 | float dt1 = b1->time() - tpair; |
351 | fencePS->Fill(dt1); |
352 | } |
353 | float dt1 = b1->time() - tpair; |
354 | fenceRF->Fill(b1->time() - tpair); |
355 | |
356 | if (TMath::Abs(dt1 - (15.*Width))> 6*Width+Width/2.){ // look only at accidentals in bunch +12 pm 7 bunches. |
357 | continue; |
358 | } |
359 | |
360 | for (int n=0; n<NBeamPhotons; n++){ |
361 | if (n == k){ |
362 | continue; |
363 | } |
364 | |
365 | const DBeamPhoton* b2 = Beam[n]; |
366 | |
367 | float dt2 = b2->time() - tpair; |
368 | if (b2->dSystem != SYS_TAGM){ // look only at microscope |
369 | continue; |
370 | } |
371 | if (TMath::Abs(dt2)<Width/2.){ // look only at accidentals |
372 | continue; |
373 | } |
374 | if (TMath::Abs((int)b1->dCounter - (int)b2->dCounter) < 10 ){ |
375 | continue; |
376 | } |
377 | if (TMath::Abs((int)b1->momentum().Mag() + (int)b2->momentum().Mag() - 11.6) < 0.2 ){ |
378 | continue; |
379 | } |
380 | |
381 | float DT = dt1-dt2; |
382 | acc->Fill(DT, b1->dCounter); |
383 | |
384 | } |
385 | } |
386 | } |
387 | |
388 | |
389 | // Any front pannel trigger is random like LED, clock, etc. |
390 | if (trig[0]->fp_trig_mask > 1){ |
391 | vector <const DBeamPhoton*> Beam; |
392 | loop->Get(Beam); |
393 | int NBeamPhotons = Beam.size(); |
394 | |
395 | for (int j=0; j<50; j++) { |
396 | |
397 | double TIME = -16.*RFWidth + j*RFWidth; |
398 | int REF_IDg = -1; |
399 | //cout<<NBeamPhotons<<endl; |
400 | for (int k=0 ;k<NBeamPhotons; k++){ |
401 | const DBeamPhoton* g = Beam[k]; |
402 | if (g->dSystem == SYS_TAGH){ |
403 | //cout<<g->time()<<endl; |
404 | if ((TMath::Abs(g->time()-TIME)<2.) && (g->dCounter<120)){ |
405 | REF_IDg = k; |
406 | break; |
407 | } |
408 | } |
409 | } |
410 | if (REF_IDg>-1){ |
411 | |
412 | double REFTIME = Beam[REF_IDg]->time(); |
413 | |
414 | double Ncnts = 0; |
415 | double NcntsA = 0; |
416 | |
417 | for (int k=0 ;k<NBeamPhotons; k++){ |
418 | const DBeamPhoton* g = Beam[k]; |
419 | if (g->dSystem == SYS_TAGM){ |
420 | double dt = g->time()-REFTIME; |
421 | deltaTall->Fill(dt, j); |
422 | NcntsA += 1.; |
423 | int dc = (int)Beam[REF_IDg]->dCounter; |
424 | //cout<<dc<<endl; |
425 | if ((dc<100) || (dc>190)){ |
426 | deltaT->Fill(dt, j); |
427 | Ncnts += 1.; |
428 | } |
429 | MICdeltaT->Fill(g->dCounter, dt); |
430 | } |
431 | } |
432 | |
433 | if (NcntsA>0){ |
434 | deltaTsa->Fill(0., j, 1./(double)NcntsA); |
435 | } |
436 | if (Ncnts>0){ |
437 | deltaTs->Fill(0., j, 1./(double)Ncnts); |
438 | } |
439 | } |
440 | } |
441 | } |
442 | |
443 | return NOERROR; |
444 | } |
445 | |
446 | //------------------ |
447 | // erun |
448 | //------------------ |
449 | jerror_t JEventProcessor_BEAM_online::erun(void) |
450 | { |
451 | // This is called whenever the run number changes, before it is |
452 | // changed to give you a chance to clean up before processing |
453 | // events from the next run number. |
454 | return NOERROR; |
455 | } |
456 | |
457 | //------------------ |
458 | // fini |
459 | //------------------ |
460 | jerror_t JEventProcessor_BEAM_online::fini(void) |
461 | { |
462 | // Called before program exit after event processing is finished. |
463 | return NOERROR; |
464 | } |
465 |