12 #include <JANA/JApplication.h>
13 #include <JANA/JFactory.h>
25 #include <TDirectory.h>
29 #include <TProfile2D.h>
78 gPARMS->SetDefaultParameter(
"BCAL_point_time:VERBOSE",
VERBOSE,
"BCAL_point_time verbosity level");
95 if (
VERBOSE>=1)
printf(
"JEventProcessor_pedestal_online::init()\n");
98 japp->RootWriteLock();
100 gStyle->SetTitleSize(0.06,
"xyz");
101 gStyle->SetTitleSize(0.07,
"h");
102 gStyle->SetLabelSize(0.06,
"xyz");
106 maindir = gDirectory;
107 peddir = maindir->mkdir(
"bcalpointime");
120 float maxtheta = 130;
122 int timediffbins = 150;
123 float mintimediff = -30;
124 float maxtimediff = 30;
126 int timesumbins = 150;
127 float mintimesum = 20;
128 float maxtimesum = 60;
130 test_coords =
new TH2I(
"test_coords",
"test_coords",thetabins,mintheta,maxtheta,zbins,minz,maxz);
132 char histname[255], histtitle[255];
135 sprintf(histname,
"hitus_TimeVsZ_layer%i_prof",j+1);
136 sprintf(histtitle,
"arrival time;Z (cm);time (ns)");
145 sprintf(histname,
"hitds_TimeVsZ_layer%i_prof",j+1);
146 sprintf(histtitle,
"arrival time;Z (cm);time (ns)");
154 sprintf(histname,
"hit_TimediffVsZ_layer%i_prof",j+1);
155 sprintf(histtitle,
"end time difference;Z (cm);#Delta t (ns)");
163 sprintf(histname,
"hit_TimesumVsZ_layer%i_prof",j+1);
164 sprintf(histtitle,
"end time sum;Z (cm);#Sigma t (ns)");
172 sprintf(histname,
"point_TimeVsZ_layer%i_prof",j+1);
173 sprintf(histtitle,
"calculated point time;Z (cm);time (ns)");
182 sprintf(histname,
"hitus_TimeVsZ_layer%i",j+1);
183 sprintf(histtitle,
"arrival time upstream [layer %i];Z (cm);time (ns)",j+1);
184 hitus_TimeVsZ_layer[j] =
new TH2I(histname,histtitle,260,-120,400,timebins,mintime,maxtime);
189 sprintf(histname,
"hitds_TimeVsZ_layer%i",j+1);
190 sprintf(histtitle,
"arrival time downstream [layer %i];Z (cm);time (ns)",j+1);
191 hitds_TimeVsZ_layer[j] =
new TH2I(histname,histtitle,260,-120,400,timebins,mintime,maxtime);
196 sprintf(histname,
"hit_TimediffVsZ_layer%i",j+1);
197 sprintf(histtitle,
"end time difference [layer %i];Z (cm);#Delta t (ns)",j+1);
198 hit_TimediffVsZ_layer[j] =
new TH2I(histname,histtitle,260,-120,400,timediffbins,mintimediff,maxtimediff);
203 sprintf(histname,
"hit_TimesumVsZ_layer%i",j+1);
204 sprintf(histtitle,
"end time sum [layer %i];Z (cm);#Delta t (ns)",j+1);
205 hit_TimesumVsZ_layer[j] =
new TH2I(histname,histtitle,260,-120,400,timesumbins,mintimesum,maxtimesum);
210 sprintf(histname,
"point_TimeVsZ_layer%i",j+1);
211 sprintf(histtitle,
"calculated point time [layer %i];Z (cm);time (ns)",j+1);
212 point_TimeVsZ_layer[j] =
new TH2I(histname,histtitle,260,-120,400,timebins,mintime,maxtime);
215 sprintf(histname,
"thrown_NVsZ");
216 sprintf(histtitle,
"number of points;Z (cm)");
217 thrown_NVsZ =
new TH1I(histname,histtitle,zbins,minz,maxz);
218 sprintf(histname,
"thrown_NVsTheta");
219 sprintf(histtitle,
"number of points;#theta_{p} (deg)");
220 thrown_NVsTheta =
new TH1I(histname,histtitle,thetabins,mintheta,maxtheta);
224 sprintf(histname,
"point_NormVsZ_layer%i",j+1);
225 sprintf(histtitle,
"number of points per thrown particle;Z (cm);points/thrown");
232 sprintf(histname,
"point_NormVsTheta_layer%i",j+1);
233 sprintf(histtitle,
"number of points per thrown particle;#theta_{p} (cm);points/thrown");
240 sprintf(histname,
"point_NVsZ_layer%i",j+1);
241 sprintf(histtitle,
"number of points;Z (cm)");
248 sprintf(histname,
"point_NVsTheta_layer%i",j+1);
249 sprintf(histtitle,
"number of points;#theta_{p} (deg)");
259 sprintf(histname,
"point_TimeVsZ_chan_%02i%02i%02i",i,j,k);
260 sprintf(histtitle,
"points [%2i,%2i,%2i];Z (cm);time (ns)",i,j,k);
261 point_TimeVsZ_chan[i][j][k] =
new TH2I(histname,histtitle,130,-120,400,timebins/2,mintime,maxtime);
291 vector<const DBCALPoint*> points;
292 vector<const DBCALHit*> hits;
293 vector<const DMCThrown*> thrown;
299 vector<const DBCALGeometry *> BCALGeomVec;
300 loop->Get(BCALGeomVec);
301 if(BCALGeomVec.size() == 0)
302 throw JException(
"Could not load DBCALGeometry object!");
303 auto locBCALGeom = BCALGeomVec[0];
308 japp->RootFillLock(
this);
310 if (peddir!=NULL) peddir->cd();
313 float theta_thrown = 0;
314 unsigned int numthrown = thrown.size();
315 if (
VERBOSE>=2)
printf(
"event %i, thrown %i\n",(
int)eventnumber,numthrown);
317 float pz = thrown[0]->pz();
318 float pt =
sqrt(thrown[0]->px()*thrown[0]->px() + thrown[0]->
py()*thrown[0]->
py());
319 float z_p = pz/pt * locBCALGeom->GetBCAL_radii()[0];
328 if (
VERBOSE>=1)
printf(
"Event %6lu numthrown %2i \n",eventnumber,numthrown);
329 japp->RootFillUnLock(
this);
333 unsigned int numpoints = points.size();
334 if (
VERBOSE>=2)
printf(
"event %i, points %i\n",(
int)eventnumber,numpoints);
336 for(
unsigned int pointn=0; pointn<numpoints; pointn++){
338 int module = point->
module();
340 int sector = point->
sector();
341 float time = point->
t();
343 float zpos = z_coord;
346 printf (
"(%i,%i,%i) is greater than (%i,%i,%i)\n",module,layer,sector,
nummodule,
numlayer,
numsector);
349 if (
VERBOSE>=3)
printf (
" point %2i (%i,%i,%i) %8.2f %8.3f\n",pointn,module,layer,sector,zpos,time);
357 unsigned int numhits = hits.size();
358 if (
VERBOSE>=2)
printf(
"event %i, hits %i\n",(
int)eventnumber,numhits);
363 for(
unsigned int hitn=0; hitn<numhits; hitn++){
366 int layer = hit->
layer;
369 float hittime = hit->
t;
372 printf (
"(%i,%i,%i) is greater than (%i,%i,%i)\n",module,layer,sector,
nummodule,
numlayer,
numsector);
375 if (
VERBOSE>=3)
printf (
" hit %2i (%i,%i,%i,%i) %8.3f\n",hitn,module,layer,sector,end,hittime);
386 if (ustime!=0 && dstime!=0) {
387 float timediff = ustime - dstime;
388 float timesum = ustime + dstime;
401 japp->RootFillUnLock(
this);
417 japp->RootFillLock(
this);
421 for (
int i=1; i<=nbins; i++) {
431 for (
int i=1; i<=nbins; i++) {
438 japp->RootFillUnLock(
this);
static TH1I * thrown_NVsZ
static TH1F * point_NormVsTheta_layer[numlayer]
static TH2I * hit_TimediffVsZ_layer[numlayer]
sprintf(text,"Post KinFit Cut")
static TProfile * hit_TimesumVsZ_layer_prof[numlayer]
static TProfile * point_TimeVsZ_layer_prof[numlayer]
jerror_t fini(void)
Called after last event of last event source has been processed.
static const int numsector
static const int numlayer
static TH1I * point_NVsTheta_layer[numlayer]
static TH2I * hitds_TimeVsZ_layer[numlayer]
static TH2I * hit_TimesumVsZ_layer[numlayer]
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
static TProfile * hitds_TimeVsZ_layer_prof[numlayer]
~JEventProcessor_BCAL_point_time()
static const double degperrad
static TH1I * thrown_NVsTheta
static TProfile * hitus_TimeVsZ_layer_prof[numlayer]
static TH2I * point_TimeVsZ_chan[nummodule][numlayer][numsector]
static TH1I * point_NVsZ_layer[numlayer]
static TH2I * test_coords
static TH2I * hitus_TimeVsZ_layer[numlayer]
JEventProcessor_BCAL_point_time()
jerror_t init(void)
Called once at program start.
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
static const int nummodule
static TH1F * point_NormVsZ_layer[numlayer]
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
static TH2I * point_TimeVsZ_layer[numlayer]
printf("string=%s", string)
static TProfile * hit_TimediffVsZ_layer_prof[numlayer]