Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JEventProcessor_occupancy_online.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: JEventProcessor_occupancy_online.cc
4 // Created: Tue Apr 12 09:43:54 EDT 2016
5 // Creator: zihlmann (on Linux gluon47.jlab.org 2.6.32-358.23.2.el6.x86_64 x86_64)
6 //
7 
8 #include <TMath.h>
9 
11 using namespace jana;
12 
13 #include <BCAL/DBCALHit.h>
14 #include <BCAL/DBCALDigiHit.h>
15 #include <BCAL/DBCALTDCDigiHit.h>
16 #include <CCAL/DCCALDigiHit.h>
17 #include <CDC/DCDCDigiHit.h>
18 #include <FDC/DFDCCathodeDigiHit.h>
19 #include <FDC/DFDCWireDigiHit.h>
20 #include <FCAL/DFCALDigiHit.h>
25 #include <TAGGER/DTAGHTDCDigiHit.h>
26 #include <TAGGER/DTAGHDigiHit.h>
27 #include <TAGGER/DTAGHHit.h>
28 #include <TAGGER/DTAGHGeometry.h>
29 #include <TOF/DTOFDigiHit.h>
30 #include <TOF/DTOFTDCDigiHit.h>
32 #include <TPOL/DTPOLHit_factory.h>
33 #include <RF/DRFTDCDigiTime.h>
36 #include <TAGGER/DTAGMDigiHit.h>
37 #include <TAGGER/DTAGMTDCDigiHit.h>
38 #include <TRIGGER/DL1Trigger.h>
39 #include <DIRC/DDIRCTDCDigiHit.h>
40 
41 // Script-fu for handling digihit type enmasse
42 #define DigiHitTypes(X) \
43  X(DBCALDigiHit) \
44  X(DBCALTDCDigiHit) \
45  X(DCCALDigiHit) \
46  X(DCDCDigiHit) \
47  X(DFDCCathodeDigiHit) \
48  X(DFDCWireDigiHit) \
49  X(DFCALDigiHit) \
50  X(DPSCDigiHit) \
51  X(DPSCTDCDigiHit) \
52  X(DPSDigiHit) \
53  X(DTOFDigiHit) \
54  X(DTOFTDCDigiHit) \
55  X(DSCDigiHit) \
56  X(DSCTDCDigiHit) \
57  X(DRFTDCDigiTime) \
58  X(DTAGMDigiHit) \
59  X(DTAGMTDCDigiHit) \
60  X(DTAGHDigiHit) \
61  X(DTAGHTDCDigiHit) \
62  X(DTPOLSectorDigiHit)\
63  X(DDIRCTDCDigiHit) \
64 
65 // Routine used to create our JEventProcessor
66 #include <JANA/JApplication.h>
67 #include <JANA/JFactory.h>
68 extern "C"{
69  void InitPlugin(JApplication *app){
70  InitJANAPlugin(app);
71  app->AddProcessor(new JEventProcessor_occupancy_online());
72  }
73 } // "C"
74 
75 
76 //------------------
77 // JEventProcessor_occupancy_online (Constructor)
78 //------------------
80 {
81 
82 }
83 
84 //------------------
85 // ~JEventProcessor_occupancy_online (Destructor)
86 //------------------
88 {
89 
90 }
91 
92 //------------------
93 // init
94 //------------------
96 {
97  japp->RootWriteLock();
98 
99  // All histograms go in the "occupancy" directory
100  TDirectory *main = gDirectory;
101  gDirectory->mkdir("occupancy")->cd();
102 // TDirectory *occ_dir = gDirectory;
103 
104 
105 
106  //------------------------ BCAL -----------------------
107  //FADC
108  bcal_adc_occ = new TH2I("bcal_adc_occ","ADC occupancy (DBCALDigiHit);Module", 48, 0.5, 48.5, 33, 0.5, 33.5);
109  // Set y-axis labels for occupancy plots
110  for(int ibin = 1; ibin <= 16; ibin++)
111  {
112  int idy = ibin-1; // convenient to use index that starts from zero!
113  int layer = 1 + (idy%4);
114  int sector = 1 + idy/4;
115 
116  ostringstream ss;
117  ss << "D S" << sector << " L" << layer;
118  bcal_adc_occ->GetYaxis()->SetBinLabel(ibin, ss.str().c_str());
119 
120  ss.str("");
121  ss << "U S" << sector << " L" << layer;
122  bcal_adc_occ->GetYaxis()->SetBinLabel(ibin + 17, ss.str().c_str());
123  }
124 
125  // TDC
126  bcal_tdc_occ = new TH2I("bcal_tdc_occ","TDC occupancy (DBCALDigiTDCHit);Module", 48, 0.5, 48.5, 25, 0.5, 25.5);
127  // Set y-axis labels for occupancy plots (without layer 4)
128  for(int ibin = 1; ibin <= 12; ibin++)
129  {
130  int idy = ibin-1; // convenient to use index that starts from zero!
131 
132  int layer = 1 + (idy%3);
133  int sector = 1 + idy/3;
134 
135  ostringstream ss;
136  ss << "D S" << sector << " L" << layer;
137  bcal_tdc_occ->GetYaxis()->SetBinLabel(ibin, ss.str().c_str());
138 
139  ss.str("");
140  ss << "U S" << sector << " L" << layer;
141  bcal_tdc_occ->GetYaxis()->SetBinLabel(ibin + 13, ss.str().c_str());
142  }
143  bcal_num_events = new TH1I("bcal_num_events", "BCAL number of events", 1, 0.0, 1.0);
144 
145  //------------------------ CCAL -----------------------
146  ccal_occ = new TH2F("ccal_occ", "CCAL Occupancy; column; row", 14, -1.5, 12.5, 14, -1.5, 12.5);
147  ccal_num_events = new TH1I("ccal_num_events", "CCAL number of events", 1, 0.0, 1.0);
148 
149  //------------------------ CDC ------------------------
150  int Nstraws[28] = {42, 42, 54, 54, 66, 66, 80, 80, 93, 93, 106, 106, 123, 123,
151  135, 135, 146, 146, 158, 158, 170, 170, 182, 182, 197, 197, 209, 209};
152  double radius[28] = {10.72134, 12.08024, 13.7795, 15.14602, 18.71726, 20.2438, 22.01672,
153  23.50008, 25.15616, 26.61158, 28.33624, 29.77388, 31.3817, 32.75838,
154  34.43478, 35.81146, 38.28542, 39.7002, 41.31564, 42.73042, 44.34078,
155  45.75302, 47.36084, 48.77054, 50.37582, 51.76012, 53.36286, 54.74716};
156  double phi[28] = {0, 0.074707844, 0.038166294, 0.096247609, 0.05966371, 0.012001551, 0.040721951,
157  0.001334527, 0.014963808, 0.048683644, 0.002092645, 0.031681749, 0.040719354,
158  0.015197341, 0.006786058, 0.030005892, 0.019704045, -0.001782064, -0.001306618,
159  0.018592421, 0.003686784, 0.022132975, 0.019600866, 0.002343723, 0.021301449,
160  0.005348855, 0.005997358, 0.021018761};
161 
162  // Define a different 2D histogram for each ring.
163  // X-axis is phi, Y-axis is radius (to plot correctly with "pol" option)
164  for(int iring=0; iring<28; iring++){
165  double r_start = radius[iring] - 0.8;
166  double r_end = radius[iring] + 0.8;
167  double phi_start = phi[iring]; // this is for center of straw. Need additional calculation for phi at end plate
168  double phi_end = phi_start + TMath::TwoPi();
169 
170  char hname[256];
171  sprintf(hname, "cdc_occ_ring_%02d", iring+1);
172  cdc_occ_ring[iring] = new TH2F(hname, "", Nstraws[iring], phi_start, phi_end, 1, r_start, r_end);
173  }
174  cdc_num_events = new TH1I("cdc_num_events", "CDC number of events", 1, 0.0, 1.0);
175  new TH2D("cdc_axes", "CDC Occupancy", 100, -57.0*4.0/3.0, 57.0*4.0/3.0, 100, -57.0, 57.0);
176 
177  //------------------------ FCAL -----------------------
178  fcal_occ = new TH2F("fcal_occ", "FCAL Occupancy; column; row", 61, -1.5, 59.5, 61, -1.5, 59.5);
179  fcal_num_events = new TH1I("fcal_num_events", "FCAL number of events", 1, 0.0, 1.0);
180 
181  //------------------------ FDC ------------------------
182  fdc_cathode_occ = new TH2F("fdc_cathode_occ","FDC Cathode Occupancy; Channel;", 48, 0.5, 48.5, 216, 0.5, 216.5);
183  fdc_wire_occ = new TH2F("fdc_wire_occ", "FDC Wire Occupancy; Channel;", 24, 0.5, 24.5, 96, 0.5, 96.5);
184  fdc_num_events = new TH1I("fdc_num_events", "FDC number of events", 1, 0.0, 1.0);
185 
186  //------------------------ PS/PSC ---------------------
187  psc_adc_left_occ = new TH1I("psc_adc_left_occ", "PSC fADC hit occupancy Left", 8, 0.5, 8.5);
188  psc_adc_right_occ = new TH1I("psc_adc_right_occ", "PSC fADC hit occupancy Right", 8, 0.5, 8.5);
189  psc_tdc_left_occ = new TH1I("psc_tdc_left_occ", "PSC TDC hit occupancy Left", 8, 0.5, 8.5);
190  psc_tdc_right_occ = new TH1I("psc_tdc_right_occ", "PSC TDC hit occupancy Right", 8, 0.5, 8.5);
191  ps_left_occ = new TH1I("ps_left_occ", "PS fADC hit occupancy Left", 145, 0.5, 145.5);
192  ps_right_occ = new TH1I("ps_right_occ", "PS fADC hit occupancy Right", 145, 0.5, 145.5);
193  ps_num_events = new TH1I("ps_num_events", "PS number of events", 1, 0.0, 1.0);
194 
195  //------------------------ RF -------------------------
196  rf_occ = new TH1D("rf_occ", "RF TDC Occupancy", 4, 0.5, 4.5);
197  rf_occ->GetXaxis()->SetBinLabel(1, "FDC");
198  rf_occ->GetXaxis()->SetBinLabel(2, "PSC");
199  rf_occ->GetXaxis()->SetBinLabel(3, "TAGH");
200  rf_occ->GetXaxis()->SetBinLabel(4, "TOF");
201  rf_num_events = new TH1I("rf_num_events", "RF number of events", 1, 0.0, 1.0);
202  dRFBinValueMap[SYS_FDC] = 1.0;
203  dRFBinValueMap[SYS_PSC] = 2.0;
204  dRFBinValueMap[SYS_TAGH] = 3.0;
205  dRFBinValueMap[SYS_TOF] = 4.0;
206 
207  //------------------------ Trigger -------------------------
208  L1GTPRate = new TH2F("L1GTPRate","L1 GTP Rate by bit;Trigger Bit;L1 GTP Rate (kHz)", 8, 0.5, 8.5, 1000, 0.0, 100.0);
209  L1livetime = new TH1F("L1livetime","L1 instantaneous livetime from TS scalers", 200, 0.0, 100.0);
210 
211  //------------------------ ST -------------------------
212  st_adc_occ = new TH1I("st_adc_occ", "ST fADC250 DigiHit Occupancy; Channel Number; fADC250 Counts", 30, 0.5, 30 + 0.5);
213  st_tdc_occ = new TH1I("st_tdc_occ", "ST TDC DigiHit Occupancy; Channel Number; TDC Counts", 30, 0.5, 30 + 0.5);
214  st_num_events = new TH1I("st_num_events", "Start Counter number of events", 1, 0.0, 1.0);
215 
216  //------------------------ TAGH -----------------------
218  tagh_adc_occ = new TH1I("tagh_adc_occ","TAGH fADC hit occupancy;counter (slot) ID;raw hits / counter",Nslots,0.5,0.5+Nslots);
219  tagh_tdc_occ = new TH1I("tagh_tdc_occ","TAGH TDC hit occupancy;counter (slot) ID;raw hits / counter",Nslots,0.5,0.5+Nslots);
220  tag_num_events = new TH1I("tag_num_events", "TAGGER number of events", 1, 0.0, 1.0);
221 
222  //------------------------ TAGM -----------------------
223  const uint32_t NCOLUMNS = 102;
224  tagm_adc_occ = new TH1I("tagm_adc_occ", "TAGM FADC250 column occupancy", NCOLUMNS, 0., NCOLUMNS + 1.);
225  tagm_tdc_occ = new TH1I("tagm_tdc_occ", "TAGM F1TDC column occupancy", NCOLUMNS, 0., NCOLUMNS + 1.);
226 
227  //------------------------ TPOL -----------------------
229  tpol_occ = new TH1I("tpol_occ","TPOL fADC hit occupancy;sector;raw hits / counter",Nsectors,0.5,0.5+Nsectors);
230 
231  //------------------------ TOF ------------------------
232  tof_num_events = new TH1I("tof_num_events", "TOF number of events", 1, 0.0, 1.0);
233  tof_tdc_S_occ = new TH1I("tof_tdc_S_occ","TOF, TDC Occupancy",86,1,44);
234  tof_tdc_N_occ = new TH1I("tof_tdc_N_occ","TOF, TDC Occupancy",86,1,44);
235  tof_tdc_U_occ = new TH1I("tof_tdc_U_occ","TOF, TDC Occupancy",86,1,44);
236  tof_tdc_D_occ = new TH1I("tof_tdc_D_occ","TOF, TDC Occupancy",86,1,44);
237 
238  tof_adc_S_occ = new TH1I("tof_adc_S_occ","TOF, fADC Occupancy",86,1,44);
239  tof_adc_N_occ = new TH1I("tof_adc_N_occ","TOF, fADC Occupancy",86,1,44);
240  tof_adc_U_occ = new TH1I("tof_adc_U_occ","TOF, fADC Occupancy",86,1,44);
241  tof_adc_D_occ = new TH1I("tof_adc_D_occ","TOF, fADC Occupancy",86,1,44);
242 
243  //------------------------ DIRC ------------------------
244  dirc_num_events = new TH1I("dirc_num_events", "DIRC number of events", 1, 0.0, 1.0);
245  dirc_tdc_pixel_N_occ_led = new TH2I("dirc_tdc_pixel_N_occ_led","DIRC, TDC North (Upper) Pixel Occupancy: LED trigger; pixel rows; pixel columns",144,-0.5,143.5,48,-0.5,47.5);
246  dirc_tdc_pixel_S_occ_led = new TH2I("dirc_tdc_pixel_S_occ_led","DIRC, TDC South (Lower) Pixel Occupancy: LED trigger; pixel rows; pixel columns",144,-0.5,143.5,48,-0.5,47.5);
247  dirc_tdc_pixel_N_occ = new TH2I("dirc_tdc_pixel_N_occ","DIRC, TDC North (Upper) Pixel Occupancy: Non-LED triggers; pixel rows; pixel columns",144,-0.5,143.5,48,-0.5,47.5);
248  dirc_tdc_pixel_S_occ = new TH2I("dirc_tdc_pixel_S_occ","DIRC, TDC South (Lower) Pixel Occupancy; Non-LED triggers; pixel rows; pixel columns",144,-0.5,143.5,48,-0.5,47.5);
249 
250  //------------------------ DigiHits ------------------------
251  #define FillDigiHitMap(A) digihitbinmap[#A]=(double)(digihitbinmap.size());
252  DigiHitTypes(FillDigiHitMap) // Initialize digihitbinmap with values from DigiHitTypes
253 
254  digihits_trig1 = new TH2I("digihits_trig1", "Digihits", digihitbinmap.size(), 0.5, 0.5+(double)digihitbinmap.size(), 151, 0.0, 151.0);
255  digihits_trig1->SetYTitle("Nhits/event");
256  digihits_scale_factors = new TH1F("digihits_scale_factors", "Digihits scale factors", digihitbinmap.size()+1, 0.5, 0.5+(double)digihitbinmap.size()+1.0);
257  for(auto p : digihitbinmap){
258  digihits_trig1->GetXaxis()->SetBinLabel(p.second, p.first.c_str());
259  digihits_scale_factors->GetXaxis()->SetBinLabel(p.second, p.first.c_str());
260  }
261  digihits_trig3 = (TH2I*)digihits_trig1->Clone("digihits_trig3");
262  digihits_trig4 = (TH2I*)digihits_trig1->Clone("digihits_trig4");
263 
264  // Some detectors have a much higher or lower rates so we scale the number of hits to
265  // fit them on the same histogram. We pass this to the RootSpy GUI in the form of a
266  // histogram with one extra bin. The extra (last) bin will have its content set to
267  // 1 so when RootSpy adds up N histograms, the last bin will keep track of how many
268  // histos where added. This can then be divided out of the other values to get back
269  // the original scale factors.
270  digihitsclmap["DFDCCathodeDigiHit"] = 3000.0/150.0;
271  digihitsclmap["DFDCWireDigiHit"] = 1500.0/150.0;
272  digihitsclmap["DCDCDigiHit"] = 900.0/150.0;
273  digihitsclmap["DBCALDigiHit"] = 300.0/150.0;
274  digihitsclmap["DBCALTDCDigiHit"] = 300.0/150.0;
275  digihitsclmap["DPSCDigiHit"] = 1.0/10.0;
276  digihitsclmap["DPSCTDCDigiHit"] = 1.0/10.0;
277  for(auto p : digihitsclmap) digihits_scale_factors->Fill(digihitbinmap[p.first], p.second);
278  digihits_scale_factors->Fill((double)digihitbinmap.size()+1.0, 1.0); // set last bin content to 1.0
279 
280  // back to main dir
281  main->cd();
282 
283  japp->RootUnLock();
284 
285  return NOERROR;
286 }
287 
288 //------------------
289 // brun
290 //------------------
291 jerror_t JEventProcessor_occupancy_online::brun(JEventLoop *eventLoop, int32_t runnumber)
292 {
293  // This is called whenever the run number changes
294 
295  vector<const DDIRCGeometry*> locDIRCGeometry;
296  eventLoop->Get(locDIRCGeometry);
297  dDIRCGeometry = locDIRCGeometry[0];
298 
299  return NOERROR;
300 }
301 
302 //------------------
303 // evnt
304 //------------------
305 jerror_t JEventProcessor_occupancy_online::evnt(JEventLoop *loop, uint64_t eventnumber)
306 {
307  // The following 2 lines will do the following for each DigiHitTypes type:
308  // vector<const A*> vDBCALDigiHit;
309  // loop->Get(vDBCALDigiHit);
310  #define GetDigihits(A) vector<const A*> v##A; loop->Get(v##A);
312 
313  // L1 triggers
314  vector<const DL1Trigger*> l1triggers;
315  loop->Get(l1triggers);
316  const DL1Trigger* l1trigger = l1triggers.empty() ? NULL : l1triggers[0];
317 
318  // trig[idx[ where idx=0-31 corresponds to "trig bit 1-32"
319  vector<bool> trig(32, 0);
320  vector<bool> fp_trig(32, 0);
321  if(l1trigger){
322  for(int itrig=0; itrig<32; itrig++) trig[itrig] = (l1trigger->trig_mask >> itrig)&0x01;
323  for(int itrig=0; itrig<32; itrig++) fp_trig[itrig] = (l1trigger->fp_trig_mask >> itrig)&0x01;
324  }
325  else // not a triggered event
326  return NOERROR;
327 
328  // calculate total BCAL energy in order to catch BCAL LED events
329  vector<const DBCALHit *> bcal_hits;
330  loop->Get(bcal_hits);
331  double total_bcal_energy = 0.;
332  for(unsigned int i=0; i<bcal_hits.size(); i++) {
333  total_bcal_energy += bcal_hits[i]->E;
334  }
335 
336 
337  japp->RootFillLock(this); //ACQUIRE ROOT FILL LOCK
338 
339  //------------------------ BCAL -----------------------
340 
341  // don't fill occupancy plots for BCAL LED events
342  if( !((l1trigger->fp_trig_mask & 0x100) || (l1trigger->fp_trig_mask & 0x200))
343  && (total_bcal_energy < 20.) ) {
344 
345  bcal_num_events->Fill(0.5);
346  //ADC
347  for(unsigned int i = 0; i < vDBCALDigiHit.size(); i++){
348  const DBCALDigiHit *hit = vDBCALDigiHit[i];
349 
350  int ix = hit->module;
351  int iy = (hit->sector-1)*4 + hit->layer;
352 
353  if(hit->end == DBCALGeometry::kUpstream)
354  bcal_adc_occ->Fill(ix, iy+17);
355  else if(hit->end == DBCALGeometry::kDownstream)
356  bcal_adc_occ->Fill(ix, iy);
357  }
358 
359  //TDC
360  for(unsigned int i = 0; i < vDBCALTDCDigiHit.size(); i++){
361  const DBCALTDCDigiHit *hit = vDBCALTDCDigiHit[i];
362 
363  int ix = hit->module;
364  int iy = (hit->sector-1)*3 + hit->layer; // TDC has 3 layers per sector
365 
366  if(hit->end == DBCALGeometry::kUpstream)
367  bcal_tdc_occ->Fill(ix, iy+13);
368  else if(hit->end == DBCALGeometry::kDownstream)
369  bcal_tdc_occ->Fill(ix, iy);
370  }
371  }
372 
373  //------------------------ CCAL -----------------------
374  ccal_num_events->Fill(0.5);
375  for(size_t loc_i = 0; loc_i < vDCCALDigiHit.size(); ++loc_i){
376  ccal_occ->Fill(vDCCALDigiHit[loc_i]->column, vDCCALDigiHit[loc_i]->row);
377  }
378 
379  //------------------------ CDC ------------------------
380  cdc_num_events->Fill(0.5);
381  for(uint32_t i=0; i<vDCDCDigiHit.size(); i++) {
382 
383  const DCDCDigiHit *digihit = vDCDCDigiHit[i];
384  int ring = digihit->ring-1; // start counting from zero!
385  int straw = digihit->straw; // first bin is one
386 
387  Double_t w = cdc_occ_ring[ring]->GetBinContent(straw, 1) + 1.0;
388  cdc_occ_ring[ring]->SetBinContent(straw, 1, w);
389  }
390 
391  //------------------------ FCAL -----------------------
392  fcal_num_events->Fill(0.5);
393  for(size_t loc_i = 0; loc_i < vDFCALDigiHit.size(); ++loc_i){
394  fcal_occ->Fill(vDFCALDigiHit[loc_i]->column, vDFCALDigiHit[loc_i]->row);
395  }
396 
397  //------------------------ FDC ------------------------
398  fdc_num_events->Fill(0.5);
399  for(unsigned int i = 0; i < vDFDCCathodeDigiHit.size(); i++){
400  uint32_t strip = vDFDCCathodeDigiHit[i]->strip;
401  if(vDFDCCathodeDigiHit[i]->strip_type == 3) strip += 9*12;
402  int ud = -1;
403  if (vDFDCCathodeDigiHit[i]->view == 3) ud = 0;
404  fdc_cathode_occ->Fill((vDFDCCathodeDigiHit[i]->package - 1)*12 + vDFDCCathodeDigiHit[i]->chamber*2 + ud, strip);
405  }
406  for(unsigned int i = 0; i < vDFDCWireDigiHit.size(); i++){
407  fdc_wire_occ->Fill((vDFDCWireDigiHit[i]->package - 1)*6 + vDFDCWireDigiHit[i]->chamber, vDFDCWireDigiHit[i]->wire);
408  }
409 
410  //------------------------ PS/PSC ---------------------
411  ps_num_events->Fill(0.5);
412  const int Nmods = 8;
413  for(unsigned int i=0; i < vDPSCDigiHit.size(); i++) {
414  const DPSCDigiHit *hit = vDPSCDigiHit[i];
415  if( hit->counter_id <= Nmods )
416  psc_adc_left_occ->Fill(hit->counter_id);
417  else
418  psc_adc_right_occ->Fill(hit->counter_id - Nmods);
419  }
420  for(unsigned int i=0; i < vDPSCTDCDigiHit.size(); i++) {
421  const DPSCTDCDigiHit *hit = vDPSCTDCDigiHit[i];
422  if( hit->counter_id <= Nmods )
423  psc_tdc_left_occ->Fill(hit->counter_id);
424  else
425  psc_tdc_right_occ->Fill(hit->counter_id - Nmods);
426  }
427  for(unsigned int i=0; i < vDPSDigiHit.size(); i++) {
428  const DPSDigiHit *hit = vDPSDigiHit[i];
429  if( hit->arm == 0 )
430  ps_left_occ->Fill(hit->column);
431  else
432  ps_right_occ->Fill(hit->column);
433  }
434 
435  //------------------------ RF -------------------------
436  rf_num_events->Fill(0.5);
437  for(size_t loc_i = 0; loc_i < vDRFTDCDigiTime.size(); ++loc_i){
438  DetectorSystem_t locSystem = vDRFTDCDigiTime[loc_i]->dSystem;
439  rf_occ->Fill(dRFBinValueMap[locSystem]);
440  }
441 
442  //------------------------ Trigger -------------------------
443  if(l1trigger){
444  if(!l1trigger->gtp_rate.empty())
445  {
446  // Sync Events
447  for(unsigned int ii = 0; ii < 8; ++ii) L1GTPRate->Fill(ii + 1, Float_t(l1trigger->gtp_rate[ii])/1000.0);
448  L1livetime->Fill((double)l1trigger->live_inst/10.0);
449  }
450  }
451 
452  //------------------------ ST -------------------------
453  st_num_events->Fill(0.5);
454  for(uint32_t i = 0; i < vDSCDigiHit.size(); i++) st_adc_occ->Fill(vDSCDigiHit[i]->sector);
455  for(uint32_t i = 0; i < vDSCTDCDigiHit.size(); i++) st_tdc_occ->Fill(vDSCTDCDigiHit[i]->sector);
456 
457  //------------------------ TAGH -----------------------
458  tag_num_events->Fill(0.5);
459  for(unsigned int i=0; i < vDTAGHDigiHit.size(); i++) tagh_adc_occ->Fill(vDTAGHDigiHit[i]->counter_id);
460  for(unsigned int i=0; i < vDTAGHTDCDigiHit.size(); i++) tagh_tdc_occ->Fill(vDTAGHTDCDigiHit[i]->counter_id);
461 
462  //------------------------ TAGM -----------------------
463  for(uint32_t i=0; i< vDTAGMDigiHit.size(); i++) {
464  const DTAGMDigiHit *hit = vDTAGMDigiHit[i];
465  if (hit->row == 0) tagm_adc_occ->Fill(hit->column);
466  }
467  for(uint32_t i=0; i< vDTAGMTDCDigiHit.size(); i++) {
468  const DTAGMTDCDigiHit *hit = vDTAGMTDCDigiHit[i];
469  if (hit->row == 0) tagm_tdc_occ->Fill(hit->column);
470  }
471 
472  //------------------------ TPOL -----------------------
473  for(unsigned int i=0; i < vDTPOLSectorDigiHit.size(); i++) tpol_occ->Fill(vDTPOLSectorDigiHit[i]->sector);
474 
475  //------------------------ TOF ------------------------
476  tof_num_events->Fill(0.5);
477  // fADC Hits
478  for(uint32_t i=0; i<vDTOFDigiHit.size(); i++){
479 
480  const DTOFDigiHit *hit = vDTOFDigiHit[i];
481  int plane = hit->plane;
482  int bar = hit->bar;
483  int end = hit->end;
484 
485  if( plane==0 && end==0 ) tof_adc_U_occ->Fill(bar);
486  if( plane==0 && end==1 ) tof_adc_D_occ->Fill(bar);
487  if( plane==1 && end==0 ) tof_adc_N_occ->Fill(bar);
488  if( plane==1 && end==1 ) tof_adc_S_occ->Fill(bar);
489  }
490 
491  // TDC Hits
492  for(uint32_t i=0; i<vDTOFTDCDigiHit.size(); i++){
493 
494  const DTOFTDCDigiHit *hit = vDTOFTDCDigiHit[i];
495  int plane = hit->plane;
496  int bar = hit->bar;
497  int end = hit->end;
498 
499  if( plane==0 && end==0 ) tof_tdc_U_occ->Fill(bar);
500  if( plane==0 && end==1 ) tof_tdc_D_occ->Fill(bar);
501  if( plane==1 && end==0 ) tof_tdc_N_occ->Fill(bar);
502  if( plane==1 && end==1 ) tof_tdc_S_occ->Fill(bar);
503  }
504 
505  //------------------------ DIRC ------------------------
506  dirc_num_events->Fill(0.5);
507  for(uint32_t i=0; i<vDDIRCTDCDigiHit.size(); i++){
508 
509  const DDIRCTDCDigiHit *hit = vDDIRCTDCDigiHit[i];
510  int ch = hit->channel;
511 
512  if(ch >= 108*64) {
513  if(fp_trig[14]) dirc_tdc_pixel_N_occ_led->Fill(dDIRCGeometry->GetPixelRow(ch), dDIRCGeometry->GetPixelColumn(ch));
514  else dirc_tdc_pixel_N_occ->Fill(dDIRCGeometry->GetPixelRow(ch), dDIRCGeometry->GetPixelColumn(ch));
515  }
516  else {
517  if(fp_trig[14]) dirc_tdc_pixel_S_occ_led->Fill(dDIRCGeometry->GetPixelRow(ch), dDIRCGeometry->GetPixelColumn(ch));
518  else dirc_tdc_pixel_S_occ->Fill(dDIRCGeometry->GetPixelRow(ch), dDIRCGeometry->GetPixelColumn(ch));
519  }
520  }
521 
522  //------------------------ DigiHits ------------------------
523  #define FillDigiHitHist(A) \
524  scale = digihitsclmap[#A]; \
525  if(scale==0.0) scale = digihitsclmap[#A] = 1.0; \
526  digihits_trigX->Fill(digihitbinmap[#A], v##A.size()/scale);
527  //digihits_hi_occ_trigX->Fill(digihitbinmap[#A], v##A.size());
528  double scale;
529  if(trig[0]){ // FCAL+BCAL
530  TH2I *digihits_trigX = digihits_trig1;
532  }
533  if(trig[2]){ // BCAL
534  TH2I *digihits_trigX = digihits_trig3;
536  }
537  if(trig[3]){ // PS
538  TH2I *digihits_trigX = digihits_trig4;
540  }
541 
542  japp->RootFillUnLock(this); //RELEASE ROOT FILL LOCK
543 
544 
545  return NOERROR;
546 }
547 
548 //------------------
549 // erun
550 //------------------
552 {
553  // This is called whenever the run number changes, before it is
554  // changed to give you a chance to clean up before processing
555  // events from the next run number.
556  return NOERROR;
557 }
558 
559 //------------------
560 // fini
561 //------------------
563 {
564  // Called before program exit after event processing is finished.
565  return NOERROR;
566 }
567 
static TH1I * ps_num_events
vector< uint32_t > gtp_rate
Definition: DL1Trigger.h:31
TH1I * fdc_num_events
Definition: FDC_occupancy.C:30
const int Nmods
int column
column number 1-102
Int_t layer
uint32_t trig_mask
Definition: DL1Trigger.h:18
uint32_t fp_trig_mask
Definition: DL1Trigger.h:19
sprintf(text,"Post KinFit Cut")
Definition: GlueX.h:29
#define FillDigiHitHist(A)
map< string, double > digihitsclmap
#define FillDigiHitMap(A)
uint32_t live_inst
Definition: DL1Trigger.h:26
static TH2I * bcal_tdc_occ
static TH1I * tof_num_events
const int Nsectors
DetectorSystem_t
Definition: GlueX.h:15
int bar
bar number
trig[33-1]
JApplication * japp
TH2I * fdc_cathode_occ
Definition: FDC_occupancy.C:26
DBCALGeometry::End end
Definition: DBCALDigiHit.h:28
static TH1I * dirc_num_events
InitPlugin_t InitPlugin
Definition: GlueX.h:20
Definition: GlueX.h:18
DPSGeometry::Arm arm
Definition: DPSDigiHit.h:19
static TH1I * bcal_num_events
DBCALGeometry::End end
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
const uint32_t NCOLUMNS
TH2I * fdc_wire_occ
Definition: FDC_occupancy.C:27
static TH1I * st_num_events
static TH1I * cdc_num_events
const int Nslots
int end
left/right 0/1 or North/South 0/1
int column
Definition: DPSDigiHit.h:20
#define GetDigihits(A)
static TH2D * cdc_occ_ring[29]
int counter_id
Definition: DPSCDigiHit.h:18
int plane
plane (0: vertical, 1: horizontal)
static const unsigned int kCounterCount
Definition: DTAGHGeometry.h:28
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
int row
row number 1-5
#define DigiHitTypes(X)
Definition: GlueX.h:32
map< string, double > digihitbinmap
int main(int argc, char *argv[])
Definition: gendoc.cc:6
static const int NSECTORS