Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JEventProcessor_BCAL_online.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: JEventProcessor_FCAL_online.cc
4 // Created: Fri Nov 9 11:58:09 EST 2012
5 // Creator: wolin (on Linux stan.jlab.org 2.6.32-279.11.1.el6.x86_64 x86_64)
6 //
7 
8 #include <stdint.h>
9 #include <vector>
10 
12 #include <JANA/JApplication.h>
13 
14 using namespace std;
15 using namespace jana;
16 
17 #include "BCAL/DBCALDigiHit.h"
18 #include "BCAL/DBCALTDCDigiHit.h"
19 #include "BCAL/DBCALHit.h"
20 #include "BCAL/DBCALTDCHit.h"
21 #include "BCAL/DBCALPoint.h"
22 #include "BCAL/DBCALCluster.h"
23 #include "BCAL/DBCALShower.h"
24 #include "BCAL/DBCALGeometry.h"
25 #include "DANA/DStatusBits.h"
26 #include "DAQ/DEPICSvalue.h"
27 #include "DAQ/DF1TDCHit.h"
28 #include "DAQ/Df250PulseData.h"
29 #include "DAQ/Df250PulseIntegral.h"
30 #include "DAQ/Df250WindowRawData.h"
31 #include "TRIGGER/DL1Trigger.h"
32 
33 #include <TDirectory.h>
34 #include <TH2.h>
35 #include <TH1.h>
36 #include <TProfile2D.h>
37 #include <TStyle.h>
38 
39 
40 // root hist pointers
41 static TH1I *bcal_fadc_digi_integral = NULL;
42 static TH1I *bcal_fadc_digi_pedestal = NULL;
43 static TH1I *bcal_fadc_digi_good_pedestal = NULL;
44 static TH1I *bcal_fadc_digi_QF = NULL;
45 static TH1I *bcal_fadc_digi_time = NULL;
46 static TH2I *bcal_fadc_digi_occ = NULL;
47 static TProfile2D *bcal_fadc_digi_pedestal_ave = NULL;
50 static TH1I *bcal_fadc_digi_occ_layer1 = NULL;
51 static TH1I *bcal_fadc_digi_occ_layer2 = NULL;
52 static TH1I *bcal_fadc_digi_occ_layer3 = NULL;
53 static TH1I *bcal_fadc_digi_occ_layer4 = NULL;
54 // static TH1I *bcal_fadc_digi_nhits_chan = NULL;
55 static TH1I *bcal_fadc_digi_nhits_evnt = NULL;
56 static TProfile *bcal_fadc_digi_pedestal_vtime = NULL;
57 static TProfile *bcal_fadc_digi_pedestal_vevent = NULL;
58 
59 static TH1I *bcal_tdc_digi_time = NULL;
60 static TH2I *bcal_tdc_digi_reltime = NULL;
61 static TH2I *bcal_tdc_digi_occ = NULL;
62 static TH1I *bcal_tdc_digi_occ_layer1 = NULL;
63 static TH1I *bcal_tdc_digi_occ_layer2 = NULL;
64 static TH1I *bcal_tdc_digi_occ_layer3 = NULL;
65 // static TH1I *bcal_tdc_digi_nhits_chan = NULL;
66 static TH1I *bcal_tdc_digi_nhits_evnt = NULL;
67 
68 static TH1I *bcal_fadc_E = NULL;
69 static TH1I *bcal_fadc_t = NULL;
70 static TH2I *bcal_fadc_occ = NULL;
71 // keep track of the integrated energy in each channel so that
72 // we can calculate the average energy per hit
73 static TH2D *bcal_fadc_avgE = NULL;
74 static TH2I *bcal_fadc_saturated = NULL;
75 
76 static TH1I *bcal_tdc_t = NULL;
77 static TH2I *bcal_tdc_occ = NULL;
78 
79 static TH1I *bcal_num_hits = NULL;
80 static TH1I *bcal_Uhit_E = NULL;
81 static TH1I *bcal_Uhit_t = NULL;
82 static TH1I *bcal_Uhit_t_ADC = NULL;
83 static TH1I *bcal_Uhit_t_TDC = NULL;
84 static TH1I *bcal_Uhit_tdiff = NULL;
85 static TH1I *bcal_Uhit_tTDC_twalk = NULL;
86 static TH1I *bcal_Uhit_noTDC_E = NULL;
87 static TH2I *bcal_Uhit_tTDC_tADC = NULL;
88 static TH2I *bcal_Uhit_tTDC_E = NULL;
89 static TH2I *bcal_Uhit_tADC_E = NULL;
90 static TProfile2D *bcal_Uhit_tdiff_ave = NULL;
91 static TProfile2D *bcal_hit_tdiff_raw_ave = NULL;
92 static TProfile2D *bcal_hit_tdiff_ave = NULL;
93 
94 static TH1I *bcal_num_points = NULL;
95 static TH1I *bcal_point_E = NULL;
96 static TH1I *bcal_point_t = NULL;
97 static TH1I *bcal_point_rho = NULL;
98 static TH1I *bcal_point_sigRho = NULL;
99 static TH1I *bcal_point_theta = NULL;
100 static TH1I *bcal_point_sigTheta = NULL;
101 static TH1I *bcal_point_phi = NULL;
102 static TH1I *bcal_point_sigPhi = NULL;
103 static TH1I *bcal_point_z = NULL;
104 static TH1I *bcal_point_sigZ = NULL;
105 static TProfile2D *bcal_point_z_dist = NULL;
106 static TH2I *bcal_point_z_sector = NULL;
107 static TH2I *bcal_point_E_sector = NULL;
108 static TH1I *bcal_point_E_layer1 = NULL;
109 static TH1I *bcal_point_E_layer2 = NULL;
110 static TH1I *bcal_point_E_layer3 = NULL;
111 static TH1I *bcal_point_E_layer4 = NULL;
112 static TProfile *bcal_point_aveE_sector_layer1 = NULL;
113 static TProfile *bcal_point_aveE_sector_layer2 = NULL;
114 static TProfile *bcal_point_aveE_sector_layer3 = NULL;
115 static TProfile *bcal_point_aveE_sector_layer4 = NULL;
116 
117 
118 static TH1I *bcal_cluster_nCells = NULL;
119 static TH1I *bcal_cluster_E = NULL;
120 static TH1I *bcal_cluster_t = NULL;
121 static TH1I *bcal_cluster_sigT = NULL;
122 static TH1I *bcal_cluster_t0 = NULL;
123 static TH1I *bcal_cluster_rho = NULL;
124 static TH1I *bcal_cluster_sigRho = NULL;
125 static TH1I *bcal_cluster_theta = NULL;
126 static TH1I *bcal_cluster_sigTheta = NULL;
127 static TH1I *bcal_cluster_phi = NULL;
128 static TH1I *bcal_cluster_sigPhi = NULL;
129 static TH2I *bcal_cluster_rho_theta = NULL;
130 
131 static TH1I *bcal_num_showers = NULL;
132 static TH1I *bcal_shower_N_cell = NULL;
133 static TH1I *bcal_shower_E = NULL;
134 static TH1I *bcal_shower_E_raw = NULL;
135 static TH1I *bcal_shower_x = NULL;
136 static TH1I *bcal_shower_y = NULL;
137 static TH1I *bcal_shower_z = NULL;
138 static TH1I *bcal_shower_t = NULL;
139 static TH1I *bcal_shower_xErr = NULL;
140 static TH1I *bcal_shower_yErr = NULL;
141 static TH1I *bcal_shower_zErr = NULL;
142 static TH1I *bcal_shower_tErr = NULL;
143 static TH1I *bcal_shower_EErr = NULL;
144 static TH2I *bcal_shower_plane = NULL;
145 
146 static TH1I *bcal_num_events;
147 
148 //----------------------------------------------------------------------------------
149 
150 
151 // Routine used to create our JEventProcessor
152 extern "C"{
153  void InitPlugin(JApplication *app){
154  InitJANAPlugin(app);
155  app->AddProcessor(new JEventProcessor_BCAL_online());
156  }
157 }
158 
159 
160 //----------------------------------------------------------------------------------
161 
162 
164 }
165 
166 
167 //----------------------------------------------------------------------------------
168 
169 
171 }
172 
173 
174 //----------------------------------------------------------------------------------
175 
177 
178  // First thread to get here makes all histograms. If one pointer is
179  // already not NULL, assume all histograms are defined and return now
180  if(bcal_fadc_digi_integral != NULL){
181  return NOERROR;
182  }
183 
184  recentwalltime = 0;
185 
186  // create root folder for bcal and cd to it, store main dir
187  TDirectory *main = gDirectory;
188  gDirectory->mkdir("bcal")->cd();
189  //gStyle->SetOptStat(111110);
190 
191  // book hists
192  int timemin_ns = -200;
193  int timemax_ns = 400;
194  int timeminTDC_ns = -300;
195  int timemaxTDC_ns = 900;
196  float Ehit_min = -0.2;
197  float Ehit_max = 2.0;
198  float Eclust_min = -0.2;
199  float Eclust_max = 6.0;
200 
201  gStyle->SetTitleOffset(1, "Y");
202  gStyle->SetTitleSize(0.05,"xyz");
203  gStyle->SetTitleSize(0.08,"h");
204  gStyle->SetLabelSize(0.05,"xyz");
205  gStyle->SetTitleX(0);
206  gStyle->SetTitleAlign(13);
207  gStyle->SetNdivisions(505,"xy");
208 
209  bcal_num_events = new TH1I("bcal_num_events","BCAL Number of events",1, 0.5, 1.5);
210 
211  bcal_fadc_digi_integral = new TH1I("bcal_fadc_digi_integral","BCAL Integral (DBCALDigiHit);Integral (fADC counts)", 500, 0, 40000);
212  bcal_fadc_digi_pedestal = new TH1I("bcal_fadc_digi_pedestal","BCAL Pedestal (DBCALDigiHit);Pedestal (fADC counts)", 400, 200, 600);
213  bcal_fadc_digi_good_pedestal = new TH1I("bcal_fadc_digi_good_pedestal","BCAL Good Pedestal (DBCALDigiHit);Pedestal (fADC counts)", 40, 380, 420);
214 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0)
215  bcal_fadc_digi_pedestal->SetCanExtend(TH1::kXaxis);
216  bcal_fadc_digi_good_pedestal->SetCanExtend(TH1::kXaxis);
217 #else
218  bcal_fadc_digi_pedestal->SetBit(TH1::kCanRebin);
219  bcal_fadc_digi_good_pedestal->SetBit(TH1::kCanRebin);
220 #endif
221  bcal_fadc_digi_QF = new TH1I("bcal_fadc_digi_QF","Qualtiy Factor (DBCALDigiHit);Qualtiy Factor", 128, -0.5, 127.5);
222  bcal_fadc_digi_time = new TH1I("bcal_fadc_digi_time","ADC Time (DBCALDigiHit);Time (fADC time/62.5 ps)", 550, -600, 6000);
223  bcal_fadc_digi_occ = new TH2I("bcal_fadc_digi_occ","ADC occupancy (DBCALDigiHit);Module", 48, 0.5, 48.5, 33, 0.5, 33.5);
224  bcal_fadc_digi_pedestal_ave = new TProfile2D("bcal_fadc_digi_pedestal_ave",
225  "Mean pedestal per cell (DBCALDigiHit);Module",
226  48, 0.5, 48.5, 33, 0.5, 33.5);
227  bcal_fadc_digi_nsamples_integral = new TH1I("bcal_fadc_digi_nsamples_integral","Number of samples: Integral (DBCALDigiHit);Number of samples",
228  100, 0, 100);
229  bcal_fadc_digi_nsamples_pedestal = new TH1I("bcal_fadc_digi_nsamples_pedestal","Number of samples: Pedestal (DBCALDigiHit);Number of samples",
230  10, 0, 10);
231  bcal_fadc_digi_occ_layer1 = new TH1I("bcal_fadc_digi_occ_layer1","Occupancy in layer 1 (DBCALDigiHit);global sector (4 x module + sector)",192, 0.5, 192.5);
232  bcal_fadc_digi_occ_layer2 = new TH1I("bcal_fadc_digi_occ_layer2","Occupancy in layer 2 (DBCALDigiHit);global sector (4 x module + sector)",192, 0.5, 192.5);
233  bcal_fadc_digi_occ_layer3 = new TH1I("bcal_fadc_digi_occ_layer3","Occupancy in layer 3 (DBCALDigiHit);global sector (4 x module + sector)",192, 0.5, 192.5);
234  bcal_fadc_digi_occ_layer4 = new TH1I("bcal_fadc_digi_occ_layer4","Occupancy in layer 4 (DBCALDigiHit);global sector (4 x module + sector)",192, 0.5, 192.5);
235  // bcal_fadc_digi_nhits_chan = new TH1I("bcal_fadc_digi_nhits_chan","ADC hits per channel;hits per channel",5,-0.5,4.5);
236  bcal_fadc_digi_nhits_evnt = new TH1I("bcal_fadc_digi_nhits_evnt","ADC hits per event;hits per event",125,-0.5,124.5);
237 
238  bcal_fadc_digi_pedestal_vtime = new TProfile("bcal_fadc_digi_pedestal_vtime","Avg BCAL pedestal vs time;time;pedestal (all chan avg)",200,0.0,0.0);
239  bcal_fadc_digi_pedestal_vtime->GetXaxis()->SetTimeDisplay(1);
240  bcal_fadc_digi_pedestal_vtime->GetXaxis()->SetTimeFormat("%m/%d %H:%M %F 1970-01-01 00:00:00");
241  bcal_fadc_digi_pedestal_vevent = new TProfile("bcal_fadc_digi_pedestal_vevent","Avg BCAL pedestal vs event;event num;pedestal (all chan avg)",200,0.,0.);
242 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0)
243  bcal_fadc_digi_pedestal_vtime->SetCanExtend(TH1::kXaxis);
244  bcal_fadc_digi_pedestal_vevent->SetCanExtend(TH1::kXaxis);
245 #else
246  bcal_fadc_digi_pedestal_vtime->SetBit(TH1::kCanRebin);
247  bcal_fadc_digi_pedestal_vevent->SetBit(TH1::kCanRebin);
248 #endif
249 
250  bcal_tdc_digi_time = new TH1I("bcal_tdc_digi_time","TDC Time (DBCALDigiTDCHit);Time (F1TDC counts)", 500, 0, 66000);
251  bcal_tdc_digi_reltime = new TH2I("bcal_tdc_digi_reltime","Relative TDC Time (DBCALDigiTDCHit);Time (F1TDC counts); TDC trig time",
252  100, 0, 70000, 100, 0, 600);
253  bcal_tdc_digi_occ = new TH2I("bcal_tdc_digi_occ","TDC occupancy (DBCALDigiTDCHit);Module", 48, 0.5, 48.5, 25, 0.5, 25.5);
254 
255  bcal_tdc_digi_occ_layer1 = new TH1I("bcal_tdc_digi_occ_layer1","Occupancy in layer 1 (DBCALDigiTDCHit);global sector (4 x module + sector)",192, 0.5, 192.5);
256  bcal_tdc_digi_occ_layer2 = new TH1I("bcal_tdc_digi_occ_layer2","Occupancy in layer 2 (DBCALDigiTDCHit);global sector (4 x module + sector)",192, 0.5, 192.5);
257  bcal_tdc_digi_occ_layer3 = new TH1I("bcal_tdc_digi_occ_layer3","Occupancy in layer 3 (DBCALDigiTDCHit);global sector (4 x module + sector)",192, 0.5, 192.5);
258  // bcal_tdc_digi_nhits_chan = new TH1I("bcal_tdc_digi_nhits_chan","TDC hits per channel;hits per channel",5,-0.5,4.5);
259  bcal_tdc_digi_nhits_evnt = new TH1I("bcal_tdc_digi_nhits_evnt","TDC hits per event;hits per event",125,-0.5,124.5);
260 
261  bcal_fadc_E = new TH1I("bcal_fadc_E","Uncorrected Energy (DBCALHit);Energy, not atten. corr. (GeV)", 500, Ehit_min, Ehit_max);
262  bcal_fadc_t = new TH1I("bcal_fadc_t","ADC Time (DBCALHit);Time (ns)", 1200, timemin_ns, timemax_ns);
263  bcal_fadc_occ = new TH2I("bcal_fadc_occ","ADC occupancy (DBCALHit);Module", 48, 0.5, 48.5, 33, 0.5, 33.5);
264  bcal_fadc_avgE = new TH2D("bcal_fadc_avgE","Average Energy x Occupancy (DBCALHit);Module", 48, 0.5, 48.5, 33, 0.5, 33.5);
265  bcal_fadc_saturated = new TH2I("bcal_fadc_saturated","Saturated Occupancy (DBCALHit);Module", 48, 0.5, 48.5, 33, 0.5, 33.5);
266 
267  bcal_tdc_t = new TH1I("bcal_tdc_t","TDC Time (DBCALTDCHit);Time (ns)", 1200, timeminTDC_ns, timemaxTDC_ns);
268  bcal_tdc_occ = new TH2I("bcal_tdc_occ","TDC occupancy (DBCALTDCHit);Module", 48, 0.5, 48.5, 25, 0.5, 25.5);
269 
270  bcal_num_hits = new TH1I("bcal_num_hits","Number of BCAL hits;Number of hits per event", 250, 0, 250);
271  bcal_Uhit_E = new TH1I("bcal_Uhit_E","Uncorrected Energy (DBCALUnifiedHit);Energy, not atten. corr. (GeV)", 500, Ehit_min, Ehit_max);
272  bcal_Uhit_t = new TH1I("bcal_Uhit_t","Unified time (DBCALUnifiedHit);time (ns)", 1200, timeminTDC_ns, timemaxTDC_ns);
273  bcal_Uhit_t_TDC = new TH1I("bcal_Uhit_t_TDC","TDC time (DBCALUnifiedHit);Timewalk corrected TDC time (ns)", 1200, timeminTDC_ns, timemaxTDC_ns);
274  bcal_Uhit_t_ADC = new TH1I("bcal_Uhit_t_ADC","ADC time (DBCALUnifiedHit);ADC time (ns)", 1000, timemin_ns, timemax_ns);
275  bcal_Uhit_noTDC_E = new TH1I("bcal_Uhit_noTDC_E","Energy for no TDC (DBCALUnifiedHit);Energy", 500, Ehit_min, Ehit_max);
276  bcal_Uhit_tTDC_tADC = new TH2I("bcal_Uhit_tTDC_tADC","ADC vs TDC time (DBCALUnifiedHit);TDC time;ADC time (ns)",
277  100, timemin_ns, timemax_ns, 100, timemin_ns, timemax_ns);
278  bcal_Uhit_tdiff = new TH1I("bcal_Uhit_tdiff","time diff. (ADC-TDC) (DBCALUnifiedHit);(TDC - ADC) time (ns)",
279  200, -300, 300);
280  bcal_Uhit_tTDC_E = new TH2I("bcal_Uhit_tTDC_E","TDC time vs Energy (DBCALUnifiedHit);Energy, not atten. corr. (GeV);Timewalk corrected TDC time",
281  100, Ehit_min, Ehit_max, 100, timeminTDC_ns, timemaxTDC_ns);
282  bcal_Uhit_tADC_E = new TH2I("bcal_Uhit_tADC_E","ADC time vs Energy (DBCALUnifiedHit);Energy, not atten. corr. (GeV);ADC time (ns)",
283  100, Ehit_min, Ehit_max, 100, timemin_ns, timemax_ns);
284  bcal_Uhit_tTDC_twalk = new TH1I("bcal_Uhit_tTDC_twalk","TDC timewalk correction (DBCALUnifiedHit);Timewalk correction (ns)",
285  150, -140, 10);
286  bcal_Uhit_tdiff_ave = new TProfile2D("bcal_Uhit_tdiff_ave", "Mean time diff. (TDC-ADC) (UnifiedHit);Module",
287  48, 0.5, 48.5, 33, 0.5, 33.5);
288  bcal_hit_tdiff_raw_ave = new TProfile2D("bcal_hit_tdiff_raw_ave", "Mean time diff. uncalib. (TDC-ADC) (Hit);Module",
289  48, 0.5, 48.5, 33, 0.5, 33.5);
290  bcal_hit_tdiff_ave = new TProfile2D("bcal_hit_tdiff_ave", "Mean time diff. (TDC-ADC) (Hit);Module",
291  48, 0.5, 48.5, 33, 0.5, 33.5);
292 
293  bcal_num_points = new TH1I("bcal_num_points","Number of BCAL points;Number of points per event", 100, 0, 100);
294  bcal_point_E = new TH1I("bcal_point_E","Energy (DBCALPoint);Energy (GeV)", 500, Ehit_min, Ehit_max);
295  bcal_point_t = new TH1I("bcal_point_t","time (DBCALPoint);Time (ns)", 500, timemin_ns, timemax_ns);
296  bcal_point_rho = new TH1I("bcal_point_rho","rho (DBCALPoint);rho", 450, 0, 450);
297  bcal_point_sigRho = new TH1I("bcal_point_sigRho","sigRho (DBCALPoint)", 100, 0, 30);
298  bcal_point_theta = new TH1I("bcal_point_theta","theta (DBCALPoint)", 500, 0, 3);
299  bcal_point_sigTheta = new TH1I("bcal_point_sigTheta","sigTheta (DBCALPoint)", 100, 0, 1);
300  bcal_point_phi = new TH1I("bcal_point_phi","phi (DBCALPoint)",200, -0.1309, 6.4141);
301  bcal_point_sigPhi = new TH1I("bcal_point_sigPhi","sigPhi (DBCALPoint)", 100, 0, 0.1);
302  bcal_point_z = new TH1I("bcal_point_z","Z wrt target center (DBCALPoint);Z wrt target center (cm)", 600, -100, 500);
303  bcal_point_sigZ = new TH1I("bcal_point_sigZ","sigZ (DBCALPoint)", 100, 0, 35);
304  bcal_point_z_dist = new TProfile2D("bcal_point_z_dist","Mean Z positions per cell (DBCALPoint);Module;Sector, Layer",
305  48, 0.5, 48.5, 16, 0.5, 16.5);
306  bcal_point_z_sector = new TH2I("bcal_point_z_sector","Z vs global sector (DBCALPoint);global sector (4 x module + sector);Z wrt target center (cm)",
307  192, 0.5, 192.5, 300, -100, 500);
308  bcal_point_E_sector = new TH2I("bcal_point_E_sector","Energy vs global sector (DBCALPoint);global sector (4 x module + sector);Energy (GeV)",
309  192, 0.5, 192.5, 200, Ehit_min, Ehit_max);
310  bcal_point_E_layer1 = new TH1I("bcal_point_E_layer1","Energy in layer 1 (DBCALPoint);Energy (GeV)", 225, Ehit_min, Ehit_max);
311  bcal_point_E_layer2 = new TH1I("bcal_point_E_layer2","Energy in layer 2 (DBCALPoint);Energy (GeV)", 225, Ehit_min, Ehit_max);
312  bcal_point_E_layer3 = new TH1I("bcal_point_E_layer3","Energy in layer 3 (DBCALPoint);Energy (GeV)", 225, Ehit_min, Ehit_max);
313  bcal_point_E_layer4 = new TH1I("bcal_point_E_layer4","Energy in layer 4 (DBCALPoint);Energy (GeV)", 225, Ehit_min, Ehit_max);
314  bcal_point_aveE_sector_layer1 = new TProfile("bcal_point_aveE_sector_layer1",
315  "Mean energy in layer 1 (DBCALPoint);global sector (4 x module + sector);Energy (GeV)",
316  192, 0.5, 192.5);
317  bcal_point_aveE_sector_layer2 = new TProfile("bcal_point_aveE_sector_layer2",
318  "Mean energy in layer 2 (DBCALPoint);global sector (4 x module + sector);Energy (GeV)",
319  192, 0.5, 192.5);
320  bcal_point_aveE_sector_layer3 = new TProfile("bcal_point_aveE_sector_layer3",
321  "Mean energy in layer 3 (DBCALPoint);global sector (4 x module + sector);Energy (GeV)",
322  192, 0.5, 192.5);
323  bcal_point_aveE_sector_layer4 = new TProfile("bcal_point_aveE_sector_layer4",
324  "Mean energy in layer 4 (DBCALPoint);global sector (4 x module + sector);Energy (GeV)",
325  192, 0.5, 192.5);
326 
327  bcal_cluster_nCells = new TH1I("bcal_cluster_nCells","Number of Cells (DBCALCluster)", 50, 0, 50);
328  bcal_cluster_E = new TH1I("bcal_cluster_E","Energy (DBCALCluster);Energy (GeV)", 450, Eclust_min, Eclust_max);
329  bcal_cluster_t = new TH1I("bcal_cluster_t","time (DBCALCluster);Time (ns)", 500, timemin_ns, timemax_ns);
330  bcal_cluster_sigT = new TH1I("bcal_cluster_sigT","sigT (DBCALCluster)", 100, 0, 50);
331  bcal_cluster_t0 = new TH1I("bcal_cluster_t0","t0 (DBCALCluster);Inner raduis time (ns)", 500, timemin_ns, timemax_ns);
332  bcal_cluster_rho = new TH1I("bcal_cluster_rho","rho (DBCALCluster)", 450, 0, 450);
333  bcal_cluster_sigRho = new TH1I("bcal_cluster_sigRho","sigRho (DBCALCluster)", 100, 0, 50);
334  bcal_cluster_theta = new TH1I("bcal_cluster_theta","theta (DBCALCluster)", 500, 0, 3);
335  bcal_cluster_sigTheta = new TH1I("bcal_cluster_sigTheta","sigTheta (DBCALCluster)", 100, 0, 0.5);
336  bcal_cluster_phi = new TH1I("bcal_cluster_phi","phi (DBCALCluster)", 200, -0.1309, 6.4141);
337  bcal_cluster_sigPhi = new TH1I("bcal_cluster_sigPhi","sigPhi (DBCALCluster)", 100, 0, 0.1);
338  bcal_cluster_rho_theta = new TH2I("bcal_cluster_rho_theta","theta vs rho (DBCALCluster);rho;theta", 100, 0, 360, 100, 0, 2.2);
339 
340  bcal_num_showers = new TH1I("bcal_num_showers","Number of BCAL showers;Number of showers per event", 20, 0, 20);
341  bcal_shower_N_cell = new TH1I("bcal_shower_N_cell","Number of Cells (DBCALShower)", 50, 0, 50);
342  bcal_shower_E = new TH1I("bcal_shower_E","Energy (DBCALShower);Energy (GeV)", 500, Eclust_min, Eclust_max);
343  bcal_shower_E_raw = new TH1I("bcal_shower_E_raw","Raw Energy (DBCALShower)", 500, Eclust_min, Eclust_max);
344  bcal_shower_x = new TH1I("bcal_shower_x","x (DBCALShower);X position (cm)", 500, -100, 100);
345  bcal_shower_y = new TH1I("bcal_shower_y","y (DBCALShower);Y position (cm)", 500, -100, 100);
346  bcal_shower_z = new TH1I("bcal_shower_z","z (DBCALShower);Z position (cm)", 600, -100, 500);
347  bcal_shower_t = new TH1I("bcal_shower_t","Time (DBCALShower);Time (ns)", 500, timemin_ns, timemax_ns);
348  bcal_shower_xErr = new TH1I("bcal_shower_xErr","xErr (DBCALShower)", 100, 0, 10);
349  bcal_shower_yErr = new TH1I("bcal_shower_yErr","yErr (DBCALShower)", 100, 0, 10);
350  bcal_shower_zErr = new TH1I("bcal_shower_zErr","zErr (DBCALShower)", 100, 0, 20);
351  bcal_shower_tErr = new TH1I("bcal_shower_tErr","tErr (DBCALShower)", 100, 0, 2);
352  bcal_shower_EErr = new TH1I("bcal_shower_EErr","EErr (DBCALShower);#sigma_E/E", 100, 0, 0.2);
353  bcal_shower_plane = new TH2I("bcal_shower_plane","Shower position (DBCALShower);X position (cm);Y position (cm)", 100, -100, 100, 100, -100, 100);
354 
355  // Turn off stats window for occupancy plots
356  bcal_fadc_digi_occ->SetStats(0);
357  bcal_tdc_digi_occ->SetStats(0);
358  bcal_tdc_digi_reltime->SetStats(0);
359  bcal_fadc_occ->SetStats(0);
360  bcal_fadc_avgE->SetStats(0);
361  bcal_fadc_saturated->SetStats(0);
362  bcal_fadc_digi_pedestal_vtime->SetStats(0);
363  bcal_fadc_digi_pedestal_vevent->SetStats(0);
364  bcal_tdc_occ->SetStats(0);
365  bcal_Uhit_tTDC_tADC->SetStats(0);
366  bcal_Uhit_tTDC_E->SetStats(0);
367  bcal_Uhit_tADC_E->SetStats(0);
368  bcal_Uhit_tTDC_twalk->SetStats(0);
369  bcal_point_z_dist->SetStats(0);
370  bcal_point_z_sector->SetStats(0);
371  bcal_fadc_digi_pedestal_ave->SetStats(0);
372  bcal_Uhit_tdiff_ave->SetStats(0);
373  bcal_hit_tdiff_raw_ave->SetStats(0);
374  bcal_hit_tdiff_ave->SetStats(0);
375  bcal_shower_plane->SetStats(0);
376  bcal_cluster_rho_theta->SetStats(0);
377 
378  // Set y-axis labels for occupancy plots
379  for(int ibin=1; ibin<=16; ibin++){
380  int idy = ibin-1; // convenient to use index that starts from zero!
381 
382  int layer = 1 + (idy%4);
383  int sector = 1 + idy/4;
384 
385  stringstream ss;
386  ss<<"D ";
387  ss << "S"<<sector<<" L"<<layer;
388  bcal_fadc_digi_occ->GetYaxis()->SetBinLabel(ibin, ss.str().c_str());
389  bcal_fadc_occ->GetYaxis()->SetBinLabel(ibin, ss.str().c_str());
390  bcal_fadc_avgE->GetYaxis()->SetBinLabel(ibin, ss.str().c_str());
391  bcal_fadc_saturated->GetYaxis()->SetBinLabel(ibin, ss.str().c_str());
392  bcal_fadc_digi_pedestal_ave->GetYaxis()->SetBinLabel(ibin, ss.str().c_str());
393  bcal_Uhit_tdiff_ave->GetYaxis()->SetBinLabel(ibin, ss.str().c_str());
394  bcal_hit_tdiff_raw_ave->GetYaxis()->SetBinLabel(ibin, ss.str().c_str());
395  bcal_hit_tdiff_ave->GetYaxis()->SetBinLabel(ibin, ss.str().c_str());
396 
397  ss.str("");
398  ss.clear();
399  ss<<"U ";
400  ss << "S"<<sector<<" L"<<layer;
401  bcal_fadc_digi_occ->GetYaxis()->SetBinLabel(ibin+17, ss.str().c_str());
402  bcal_fadc_occ->GetYaxis()->SetBinLabel(ibin+17, ss.str().c_str());
403  bcal_fadc_avgE->GetYaxis()->SetBinLabel(ibin+17, ss.str().c_str());
404  bcal_fadc_saturated->GetYaxis()->SetBinLabel(ibin+17, ss.str().c_str());
405  bcal_fadc_digi_pedestal_ave->GetYaxis()->SetBinLabel(ibin+17, ss.str().c_str());
406  bcal_Uhit_tdiff_ave->GetYaxis()->SetBinLabel(ibin+17, ss.str().c_str());
407  bcal_hit_tdiff_raw_ave->GetYaxis()->SetBinLabel(ibin+17, ss.str().c_str());
408  bcal_hit_tdiff_ave->GetYaxis()->SetBinLabel(ibin+17, ss.str().c_str());
409  }
410 
411  // Occupancy plots for TDC (without layer 4)
412  // Set y-axis labels for occupancy plots
413  for(int ibin=1; ibin<=12; ibin++){
414  int idy = ibin-1; // convenient to use index that starts from zero!
415 
416  int layer = 1 + (idy%3);
417  int sector = 1 + idy/3;
418 
419  stringstream ss;
420  ss<<"D ";
421  ss << "S"<<sector<<" L"<<layer;
422  bcal_tdc_digi_occ->GetYaxis()->SetBinLabel(ibin, ss.str().c_str());
423  bcal_tdc_occ->GetYaxis()->SetBinLabel(ibin, ss.str().c_str());
424 
425  ss.str("");
426  ss.clear();
427  ss<<"U ";
428  ss << "S"<<sector<<" L"<<layer;
429  bcal_tdc_digi_occ->GetYaxis()->SetBinLabel(ibin+13, ss.str().c_str());
430  bcal_tdc_occ->GetYaxis()->SetBinLabel(ibin+13, ss.str().c_str());
431  }
432 
433  // Occupancy plots WITHOUT 2 ends
434  // Set y-axis labels for occupancy plots
435  for(int ibin=1; ibin<=16; ibin++){
436  int idy = ibin-1; // convenient to use index that starts from zero!
437 
438  int layer = 1 + (idy%4);
439  int sector = 1 + idy/4;
440 
441  stringstream ss;
442  ss<<" ";
443  ss << "S"<<sector<<" L"<<layer;
444  bcal_point_z_dist->GetYaxis()->SetBinLabel(ibin, ss.str().c_str());
445  bcal_point_z_dist->GetYaxis()->SetTitleOffset(1.4);
446  }
447 
448 
449  // back to main dir
450  main->cd();
451 
452  return NOERROR;
453 }
454 
455 
456 //----------------------------------------------------------------------------------
457 
458 
459 jerror_t JEventProcessor_BCAL_online::brun(JEventLoop *eventLoop, int32_t runnumber) {
460  // This is called whenever the run number changes
461 
462  return NOERROR;
463 }
464 
465 
466 //----------------------------------------------------------------------------------
467 
468 
469 jerror_t JEventProcessor_BCAL_online::evnt(JEventLoop *loop, uint64_t eventnumber) {
470  // This is called for every event. Use of common resources like writing
471  // to a file or filling a histogram should be mutex protected. Using
472  // loop-Get(...) to get reconstructed objects (and thereby activating the
473  // reconstruction algorithm) should be done outside of any mutex lock
474  // since multiple threads may call this method at the same time.
475 
476  // load BCAL geometry
477  vector<const DBCALGeometry *> BCALGeomVec;
478  loop->Get(BCALGeomVec);
479  if(BCALGeomVec.size() == 0)
480  throw JException("Could not load locBCALGeometry object!");
481  const DBCALGeometry *locBCALGeom = BCALGeomVec[0];
482 
483  vector<const DEPICSvalue*> depicsvalue;
484  loop->Get(depicsvalue);
485  if (depicsvalue.size()>0) {
486  recentwalltime = depicsvalue[0]->timestamp;
487  return NOERROR;
488  }
489 
490  vector<const DBCALDigiHit*> dbcaldigihits;
491  vector<const DBCALTDCDigiHit*> dbcaltdcdigihits;
492  vector<const DBCALHit*> dbcalhits;
493  vector<const DBCALTDCHit*> dbcaltdchits;
494  vector<const DBCALUnifiedHit*> dbcaluhits;
495  vector<const DBCALPoint*> dbcalpoints;
496  vector<const DBCALCluster*> dbcalclusters;
497  vector<const DBCALShower*> dbcalshowers;
498 
499  // First check that this is not a font panel trigger or no trigger
500  bool goodtrigger=1;
501 
502  const DL1Trigger *trig = NULL;
503  try {
504  loop->GetSingle(trig);
505  } catch (...) {}
506  if (trig) {
507  if (trig->fp_trig_mask){
508  goodtrigger=0;
509  }
510  } else {
511  // HDDM files are from simulation, so keep them even though they have no trigger
512  bool locIsHDDMEvent = loop->GetJEvent().GetStatusBit(kSTATUS_HDDM);
513  if (!locIsHDDMEvent) goodtrigger=0;
514  }
515  // calculate total BCAL energy in order to catch BCAL LED events
516  loop->Get(dbcalhits);
517  double total_bcal_energy = 0.;
518  for(unsigned int i=0; i<dbcalhits.size(); i++) {
519  total_bcal_energy += dbcalhits[i]->E;
520  }
521  if (total_bcal_energy > 12.) goodtrigger=0;
522 
523  if (!goodtrigger) {
524  return NOERROR;
525  }
526 
527  loop->Get(dbcaldigihits);
528  loop->Get(dbcaltdcdigihits);
529  loop->Get(dbcaltdchits);
530  loop->Get(dbcaluhits);
531  loop->Get(dbcalpoints);
532  loop->Get(dbcalclusters);
533  loop->Get(dbcalshowers);
534 
535  // FILL HISTOGRAMS
536  // Since we are filling histograms local to this plugin, it will not interfere with other ROOT operations: can use plugin-wide ROOT fill lock
537  japp->RootFillLock(this); //ACQUIRE ROOT FILL LOCK
538 
539  if( (dbcaldigihits.size() > 0) || (dbcaltdcdigihits.size() > 0) )
540  bcal_num_events->Fill(1);
541 
542  bcal_fadc_digi_nhits_evnt->Fill(dbcaldigihits.size());
543  bcal_tdc_digi_nhits_evnt->Fill(dbcaltdcdigihits.size());
544 
545  // The map is created to get the nunmber of hits per cell
546  // map<readout_channel, cellHits> cellHitMap;
547  // for( vector<const DBCALDigiHit*>::const_iterator hitPtr = dbcaldigihits.begin();
548  // hitPtr != dbcaldigihits.end();
549  // ++hitPtr ){
550 
551  // const DBCALDigiHit& hit = (**hitPtr);
552 
553  // int id = DBCALGeometry::cellId( hit.module, hit.layer, hit.sector );
554  // readout_channel chan(id, hit.end);
555 
556  // //this will create cellHitMap[chan] if it doesn't already exist
557  // cellHitMap[chan].hits.push_back(*hitPtr);
558  // }
559 
560 
561  // Digitized fADC hits for bcal
562  for(unsigned int i=0; i<dbcaldigihits.size(); i++) {
563  const DBCALDigiHit *hit = dbcaldigihits[i];
564 
566  bcal_fadc_digi_pedestal->Fill(hit->pedestal);
567  if (hit->pedestal > 0) bcal_fadc_digi_good_pedestal->Fill(hit->pedestal);
568  bcal_fadc_digi_QF->Fill(hit->QF);
569  bcal_fadc_digi_time->Fill(hit->pulse_time);
572  int layer = hit->layer;
573  int glosect = locBCALGeom->getglobalsector(hit->module, hit->sector);
574  if (layer==1) bcal_fadc_digi_occ_layer1->Fill(glosect);
575  if (layer==2) bcal_fadc_digi_occ_layer2->Fill(glosect);
576  if (layer==3) bcal_fadc_digi_occ_layer3->Fill(glosect);
577  if (layer==4) bcal_fadc_digi_occ_layer4->Fill(glosect);
578 
579  if ( hit->pedestal > 0 ) {
580  if (recentwalltime>0) {
582  }
583  bcal_fadc_digi_pedestal_vevent->Fill(eventnumber,hit->pedestal);
584  }
585 
586  // Occupancy histogram defined to give better aspect ratio
587  int ix = hit->module;
588  int iy = (hit->sector-1)*4 + hit->layer;
589  if(hit->end == DBCALGeometry::kUpstream) {
590  bcal_fadc_digi_occ->Fill(ix, iy+17);
591  if ( hit->pedestal > 0 ) {
592  bcal_fadc_digi_pedestal_ave->Fill(ix, iy+17, hit->pedestal);
593  }
594  }
595  if(hit->end == DBCALGeometry::kDownstream) {
596  bcal_fadc_digi_occ->Fill(ix, iy);
597  if ( hit->pedestal > 0 ) {
598  bcal_fadc_digi_pedestal_ave->Fill(ix, iy, hit->pedestal);
599  }
600  }
601  }
602 
603  // Digitized TDC hits for bcal
604  for(unsigned int i=0; i<dbcaltdcdigihits.size(); i++) {
605  const DBCALTDCDigiHit *hit = dbcaltdcdigihits[i];
606 
607  bcal_tdc_digi_time->Fill(hit->time);
608  vector<const DF1TDCHit*> f1tdchits;
609  hit->Get(f1tdchits);
610  if(f1tdchits.size() > 0)
611  bcal_tdc_digi_reltime->Fill(f1tdchits[0]->time,f1tdchits[0]->trig_time);
612 
613  int layer = hit->layer;
614  int glosect = locBCALGeom->getglobalsector(hit->module, hit->sector);
615  if (layer==1) bcal_tdc_digi_occ_layer1->Fill(glosect);
616  if (layer==2) bcal_tdc_digi_occ_layer2->Fill(glosect);
617  if (layer==3) bcal_tdc_digi_occ_layer3->Fill(glosect);
618 
619  // Occupancy histogram defined to give better aspect ratio
620  int ix = hit->module;
621  int iy = (hit->sector-1)*3 + hit->layer; // TDC has 3 layers per sector
622  if(hit->end == DBCALGeometry::kUpstream) bcal_tdc_digi_occ->Fill(ix, iy+13);
623  if(hit->end == DBCALGeometry::kDownstream) bcal_tdc_digi_occ->Fill(ix, iy);
624  }
625 
626  // Calibrated fADC hits for bcal
627  for(unsigned int i=0; i<dbcalhits.size(); i++) {
628  const DBCALHit *hit = dbcalhits[i];
629 
630  bool saturated=0;
631  vector<const DBCALDigiHit*> assoc_BCALDigiHit;
632  hit->Get(assoc_BCALDigiHit);
633  if (assoc_BCALDigiHit.size()>0) {
634  // pre-Fall 2016 firmware
635  vector<const Df250PulseIntegral*> f250PulseIntegral;
636  assoc_BCALDigiHit[0]->Get(f250PulseIntegral);
637  //printf("got %i DBCALDigiHit %i f250PulseIntegral\n", assoc_BCALDigiHit.size(),f250PulseIntegral.size());
638  if (f250PulseIntegral.size()>0) {
639  vector<const Df250WindowRawData*> f250WindowRawData;
640  f250PulseIntegral[0]->Get(f250WindowRawData);
641  if (f250WindowRawData.size()>0) {
642  //printf("got Df250WindowRawData\n");
643  if (f250WindowRawData[0]->overflow==1) {
644  saturated=1;
645  }
646  }
647  }
648 
649  // post-Fall 2016 firmware
650  vector<const Df250PulseData*> f250PulseData;
651  assoc_BCALDigiHit[0]->Get(f250PulseData);
652  //printf("got %i DBCALDigiHit %i f250PulseData\n", assoc_BCALDigiHit.size(),f250PulseData.size());
653  if (f250PulseData.size()>0) {
654  vector<const Df250WindowRawData*> f250WindowRawData;
655  f250PulseData[0]->Get(f250WindowRawData);
656  if (f250WindowRawData.size()>0) {
657  //printf("got Df250WindowRawData\n");
658  if (f250WindowRawData[0]->overflow==1) {
659  saturated=1;
660  }
661  }
662  }
663  }
664 
665  // Occupancy histogram defined to give better aspect ratio
666  int ix = hit->module;
667  int iy = (hit->sector-1)*4 + hit->layer;
668  if (!saturated) {
669  bcal_fadc_E->Fill(hit->E);
670  bcal_fadc_t->Fill(hit->t);
671  if(hit->end == DBCALGeometry::kUpstream) {
672  bcal_fadc_occ->Fill(ix, iy+17);
673  bcal_fadc_avgE->Fill(ix, iy+17, hit->E);
674  }
675  if(hit->end == DBCALGeometry::kDownstream) {
676  bcal_fadc_occ->Fill(ix, iy);
677  bcal_fadc_avgE->Fill(ix, iy, hit->E);
678  }
679  } else {
680  if(hit->end == DBCALGeometry::kUpstream) {
681  bcal_fadc_saturated->Fill(ix, iy+17);
682  }
683  if(hit->end == DBCALGeometry::kDownstream) {
684  bcal_fadc_saturated->Fill(ix, iy);
685  }
686  }
687  }
688 
689  // Calibrated TDC hits for bcal
690  for(unsigned int i=0; i<dbcaltdchits.size(); i++) {
691  const DBCALTDCHit *hit = dbcaltdchits[i];
692 
693  bcal_tdc_t->Fill(hit->t);
694 
695  // Occupancy histogram defined to give better aspect ratio
696  int ix = hit->module;
697  int iy = (hit->sector-1)*3 + hit->layer; // TDC has 3 layers per sector
698  if(hit->end == DBCALGeometry::kUpstream) bcal_tdc_occ->Fill(ix, iy+13);
699  if(hit->end == DBCALGeometry::kDownstream) bcal_tdc_occ->Fill(ix, iy);
700  }
701 
702  // BCAL Unified Hit (combined ADC and TDC info)
703  bcal_num_hits->Fill(dbcaluhits.size());
704  for(unsigned int i=0; i<dbcaluhits.size(); i++) {
705  const DBCALUnifiedHit *Uhit = dbcaluhits[i];
706  bcal_Uhit_E->Fill(Uhit->E);
707  bcal_Uhit_t->Fill(Uhit->t);
708  bcal_Uhit_t_ADC->Fill(Uhit->t_ADC);
709  bcal_Uhit_tADC_E->Fill(Uhit->E,Uhit->t_ADC);
710  if (Uhit->t_TDC != 0) {
711  bcal_Uhit_t_TDC->Fill(Uhit->t_TDC);
712  float t_diff = Uhit->t_TDC - Uhit->t_ADC;
713  bcal_Uhit_tdiff->Fill(t_diff);
714  bcal_Uhit_tTDC_E->Fill(Uhit->E,Uhit->t_TDC);
715  bcal_Uhit_tTDC_tADC->Fill(Uhit->t_TDC,Uhit->t_ADC);
716  const DBCALTDCHit* tdchit = NULL;
717  Uhit->GetSingle(tdchit);
718  const DBCALHit* adchit = NULL;
719  Uhit->GetSingle(adchit);
720  float t_diff_hit = tdchit->t - adchit->t;
721  float t_diff_hit_raw = tdchit->t_raw - adchit->t_raw;
722  //vector<const DBCALTDCHit*> tdchits;
723  //Uhit->Get(tdchits);
724  //bcal_Uhit_tTDC_twalk->Fill(Uhit->t_TDC - tdchits[0]->t);
725  bcal_Uhit_tTDC_twalk->Fill(Uhit->t_TDC - tdchit->t);
726  int ix = Uhit->module;
727  int iy = (Uhit->sector-1)*4 + Uhit->layer;
728  if (adchit->pulse_peak>=120) { // Only compare TDC and ADC where pulse is big enough that time-walk is small.
729  if(Uhit->end == DBCALGeometry::kUpstream) {
730  bcal_Uhit_tdiff_ave->Fill(ix, iy+17, t_diff);
731  bcal_hit_tdiff_raw_ave->Fill(ix, iy+17, t_diff_hit_raw);
732  bcal_hit_tdiff_ave->Fill(ix, iy+17, t_diff_hit);
733  }
734  if(Uhit->end == DBCALGeometry::kDownstream) {
735  bcal_Uhit_tdiff_ave->Fill(ix, iy, t_diff);
736  bcal_hit_tdiff_raw_ave->Fill(ix, iy, t_diff_hit_raw);
737  bcal_hit_tdiff_ave->Fill(ix, iy, t_diff_hit);
738  }
739  }
740  } else {
741  bcal_Uhit_noTDC_E->Fill(Uhit->E);
742  }
743  }
744 
745  // BCAL Points (combined hits from each end)
746  bcal_num_points->Fill(dbcalpoints.size());
747  for(unsigned int i=0; i<dbcalpoints.size(); i++) {
748  const DBCALPoint *point = dbcalpoints[i];
749  bcal_point_E->Fill(point->E());
750  bcal_point_t->Fill(point->t());
751  bcal_point_rho->Fill(point->rho());
752  bcal_point_sigRho->Fill(point->sigRho());
753  bcal_point_theta->Fill(point->theta());
754  bcal_point_sigTheta->Fill(point->sigTheta());
755  bcal_point_phi->Fill(point->phi());
756  bcal_point_sigPhi->Fill(point->sigPhi());
757  bcal_point_z->Fill(point->z());
758  bcal_point_sigZ->Fill(point->sigZ());
759 
760  int layer = point->layer();
761  if (layer==1) bcal_point_E_layer1->Fill(point->E());
762  if (layer==2) bcal_point_E_layer2->Fill(point->E());
763  if (layer==3) bcal_point_E_layer3->Fill(point->E());
764  if (layer==4) bcal_point_E_layer4->Fill(point->E());
765 
766  vector<const DBCALUnifiedHit*> endhits;
767  point->Get(endhits);
768 
769  int glosect = locBCALGeom->getglobalsector(endhits[0]->module, endhits[0]->sector);
770  bcal_point_z_sector->Fill(glosect,point->z());
771  bcal_point_E_sector->Fill(glosect,point->E());
772  if (layer==1) bcal_point_aveE_sector_layer1->Fill(glosect,point->E());
773  if (layer==2) bcal_point_aveE_sector_layer2->Fill(glosect,point->E());
774  if (layer==3) bcal_point_aveE_sector_layer3->Fill(glosect,point->E());
775  if (layer==4) bcal_point_aveE_sector_layer4->Fill(glosect,point->E());
776 
777  int ix = endhits[0]->module;
778  int iy = (endhits[0]->sector-1)*4 + endhits[0]->layer;
779  bcal_point_z_dist->Fill(ix, iy, point->z());
780  }
781 
782  // BCAL Clusters (combined neighboring points)
783  for(unsigned int i=0; i<dbcalclusters.size(); i++) {
784  const DBCALCluster *cluster = dbcalclusters[i];
785  bcal_cluster_nCells->Fill(cluster->nCells());
786  bcal_cluster_E->Fill(cluster->E());
787  bcal_cluster_t->Fill(cluster->t());
788  bcal_cluster_sigT->Fill(cluster->sigT());
789  bcal_cluster_t0->Fill(cluster->t0());
790  bcal_cluster_rho->Fill(cluster->rho());
791  bcal_cluster_sigRho->Fill(cluster->sigRho());
792  bcal_cluster_theta->Fill(cluster->theta());
793  bcal_cluster_sigTheta->Fill(cluster->sigTheta());
794  bcal_cluster_phi->Fill(cluster->phi());
795  bcal_cluster_sigPhi->Fill(cluster->sigPhi());
796  bcal_cluster_rho_theta->Fill(cluster->rho(),cluster->theta());
797  }
798 
799  // BCAL Showers (combined cluster with track)
800  bcal_num_showers->Fill(dbcalshowers.size());
801  for(unsigned int i=0; i<dbcalshowers.size(); i++) {
802  const DBCALShower *shower = dbcalshowers[i];
803  bcal_shower_N_cell->Fill(shower->N_cell);
804  bcal_shower_E->Fill(shower->E);
805  bcal_shower_E_raw->Fill(shower->E_raw);
806  bcal_shower_x->Fill(shower->x);
807  bcal_shower_y->Fill(shower->y);
808  bcal_shower_z->Fill(shower->z);
809  bcal_shower_t->Fill(shower->t);
810  bcal_shower_xErr->Fill(shower->xErr());
811  bcal_shower_yErr->Fill(shower->yErr());
812  bcal_shower_zErr->Fill(shower->zErr());
813  bcal_shower_tErr->Fill(shower->tErr());
814  bcal_shower_EErr->Fill(shower->EErr()/shower->E);
815  bcal_shower_plane->Fill(shower->x,shower->y);
816  }
817 
818  japp->RootFillUnLock(this); //RELEASE ROOT FILL LOCK
819 
820  return NOERROR;
821 }
822 
823 
824 //----------------------------------------------------------------------------------
825 
826 
828  // This is called whenever the run number changes, before it is
829  // changed to give you a chance to clean up before processing
830  // events from the next run number.
831 
832  bcal_fadc_digi_pedestal_vtime->SetMinimum(bcal_fadc_digi_pedestal_vtime->GetMinimum(0.1));
834 
835  return NOERROR;
836 }
837 
838 
839 //----------------------------------------------------------------------------------
840 
841 
843  // Called before program exit after event processing is finished.
844  return NOERROR;
845 }
846 
847 
848 //----------------------------------------------------------------------------------
849 //----------------------------------------------------------------------------------
static TH1I * bcal_tdc_digi_occ_layer2
static TH1I * bcal_cluster_sigRho
float E
Definition: DBCALHit.h:30
static TH1I * bcal_shower_E
float rho() const
Definition: DBCALPoint.h:50
float const EErr() const
Definition: DBCALShower.h:36
static TH1I * bcal_shower_y
static TH1I * bcal_shower_x
static TH1I * bcal_cluster_t0
static TH1I * bcal_fadc_t
static TH1I * bcal_num_showers
if(locHist_BCALShowerPhiVsZ!=NULL)
static TH1I * bcal_point_E_layer4
float t_TDC
Time of TDC hit that is closes t to the ADC time.
static TH2I * bcal_tdc_digi_reltime
static TH1I * bcal_shower_yErr
float t0() const
Definition: DBCALCluster.cc:28
static TH2I * bcal_Uhit_tTDC_tADC
static TH1I * bcal_shower_tErr
Int_t layer
static TH1I * bcal_num_hits
static TProfile * bcal_point_aveE_sector_layer1
static TH2I * bcal_shower_plane
long int recentwalltime
float rho() const
Definition: DBCALCluster.h:59
static TH1I * bcal_fadc_digi_occ_layer3
int module
Definition: DBCALHit.h:25
static TH1I * bcal_cluster_sigT
uint32_t fp_trig_mask
Definition: DL1Trigger.h:19
static TH1I * bcal_point_sigTheta
static TH1I * bcal_point_theta
static TH1I * bcal_fadc_digi_time
static TH1I * bcal_tdc_digi_nhits_evnt
float phi() const
Definition: DBCALPoint.h:56
static TH2I * bcal_cluster_rho_theta
static TH1I * bcal_fadc_digi_integral
static TH1I * bcal_shower_t
float const tErr() const
Definition: DBCALShower.h:40
static TH1I * bcal_point_E_layer3
static TH1I * bcal_fadc_digi_occ_layer1
float const xErr() const
Definition: DBCALShower.h:37
static TH1I * bcal_point_E_layer1
static TProfile2D * bcal_point_z_dist
uint32_t nsamples_integral
number of samples used in integral
Definition: DBCALDigiHit.h:34
int layer
Definition: DBCALHit.h:26
float t() const
Definition: DBCALCluster.h:49
static TH2I * bcal_fadc_digi_occ
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
float sigPhi() const
Definition: DBCALPoint.h:57
trig[33-1]
static TH2I * bcal_tdc_occ
static TH1I * bcal_num_events
static TH2I * bcal_tdc_digi_occ
int layer() const
Definition: DBCALPoint.h:65
static TH1I * bcal_num_points
float sigRho() const
Definition: DBCALPoint.h:51
JApplication * japp
static TH2I * bcal_point_E_sector
static TH1I * bcal_cluster_t
static TH1I * bcal_shower_xErr
DBCALGeometry::End end
Definition: DBCALDigiHit.h:28
DBCALGeometry::End end
Definition: DBCALHit.h:28
static TH1I * bcal_cluster_theta
jerror_t fini(void)
Called after last event of last event source has been processed.
float theta() const
Definition: DBCALPoint.h:53
static TH1I * bcal_point_sigPhi
uint32_t pulse_integral
identified pulse integral as returned by FPGA algorithm
Definition: DBCALDigiHit.h:29
static TProfile * bcal_point_aveE_sector_layer4
static TH1I * bcal_shower_N_cell
float E() const
Definition: DBCALPoint.h:38
static TProfile * bcal_point_aveE_sector_layer2
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
static TH1I * bcal_Uhit_t_ADC
static TH1I * bcal_tdc_digi_occ_layer3
float sigT() const
Definition: DBCALCluster.h:50
static TProfile2D * bcal_hit_tdiff_ave
InitPlugin_t InitPlugin
static TH1I * bcal_Uhit_tTDC_twalk
static TH1I * bcal_fadc_digi_pedestal
uint32_t nsamples_pedestal
number of samples used in pedestal
Definition: DBCALDigiHit.h:35
static TH2D * bcal_fadc_avgE
static TH1I * bcal_point_t
static TH1I * bcal_shower_zErr
float sigPhi() const
Definition: DBCALCluster.h:66
float sigTheta() const
Definition: DBCALCluster.h:63
float t_ADC
Time from fADC.
DBCALGeometry::End end
static TH1I * bcal_tdc_t
DBCALGeometry::End end
static TH1I * bcal_shower_E_raw
float z() const
Definition: DBCALPoint.h:60
static TH1I * bcal_fadc_digi_nsamples_integral
uint32_t QF
Quality Factor from FPGA algorithms.
Definition: DBCALDigiHit.h:33
float t
Definition: DBCALHit.h:31
static TH1I * bcal_point_E_layer2
static TH2I * bcal_Uhit_tADC_E
int sector
Definition: DBCALHit.h:27
float const zErr() const
Definition: DBCALShower.h:39
static TProfile * bcal_fadc_digi_pedestal_vtime
int getglobalsector(int module, int sector) const
static TH1I * bcal_point_z
static TH1I * bcal_fadc_E
static TH1I * bcal_cluster_rho
static TH1I * bcal_fadc_digi_occ_layer4
float phi() const
Definition: DBCALCluster.h:65
static TH1I * bcal_cluster_sigTheta
float sigRho() const
Definition: DBCALCluster.h:60
static TH1I * bcal_point_sigZ
uint32_t pedestal
pedestal info used by FPGA (if any)
Definition: DBCALDigiHit.h:32
float theta() const
Definition: DBCALCluster.h:62
static TH1I * bcal_cluster_nCells
static TH1I * bcal_shower_EErr
float sigZ() const
Definition: DBCALPoint.h:61
static TH1I * bcal_shower_z
static TH1I * bcal_fadc_digi_nhits_evnt
static TH1I * bcal_cluster_phi
float t_raw
Uncalibrated time in ns.
Definition: DBCALTDCHit.h:27
static TH1I * bcal_Uhit_noTDC_E
static TH1I * bcal_tdc_digi_time
static TH2I * bcal_fadc_occ
int pulse_peak
Definition: DBCALHit.h:29
static TH1I * bcal_point_sigRho
static TH1I * bcal_fadc_digi_nsamples_pedestal
static TH1I * bcal_point_rho
uint32_t pulse_time
identified pulse time as returned by FPGA algorithm
Definition: DBCALDigiHit.h:31
static TH2I * bcal_fadc_saturated
float t() const
Definition: DBCALPoint.h:41
static TH1I * bcal_cluster_E
static TH1I * bcal_cluster_sigPhi
DBCALGeometry::End end
Definition: DBCALTDCHit.h:25
static TProfile2D * bcal_hit_tdiff_raw_ave
static TH1I * bcal_Uhit_tdiff
static TH2I * bcal_Uhit_tTDC_E
static TProfile * bcal_fadc_digi_pedestal_vevent
static TH1I * bcal_point_E
static TH1I * bcal_Uhit_t
static TProfile * bcal_point_aveE_sector_layer3
float sigTheta() const
Definition: DBCALPoint.h:54
static TH1I * bcal_tdc_digi_occ_layer1
float const yErr() const
Definition: DBCALShower.h:38
static TH1I * bcal_fadc_digi_good_pedestal
static TH1I * bcal_fadc_digi_QF
static TProfile2D * bcal_Uhit_tdiff_ave
int nCells() const
Definition: DBCALCluster.h:37
static TH1I * bcal_fadc_digi_occ_layer2
static TH1I * bcal_point_phi
static TH1I * bcal_Uhit_t_TDC
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
int main(int argc, char *argv[])
Definition: gendoc.cc:6
jerror_t init(void)
Called once at program start.
float E_raw
Definition: DBCALShower.h:18
static TProfile2D * bcal_fadc_digi_pedestal_ave
static TH1I * bcal_Uhit_E
float t_raw
Uncalibrated time in ns.
Definition: DBCALHit.h:32
static TH2I * bcal_point_z_sector
float t
Unified time, obtained from ADC and/or TDC and used for further analysis.
float E() const
Definition: DBCALCluster.h:41