13 #include <JANA/JApplication.h>
25 #include <TDirectory.h>
29 #include <TPolyLine.h>
98 TDirectory *
main = gDirectory;
99 gDirectory->mkdir(
"tof")->cd();
103 tof_num_events =
new TH1I(
"tof_num_events",
"TOF Number of events",1, 0.5, 1.5);
105 tofe =
new TH1I(
"tofe",
"TOF energy in keV",100,0,15000);
106 toft =
new TH1I(
"toft",
"TOF time in ns",200,0,200);
107 tofo1 =
new TH2I(
"tofo1",
"TOF occupancy plane 1 by bar,top/bottom",50,0,50,2,0,2);
108 tofo2 =
new TH2I(
"tofo2",
"TOF occupancy plane 2 by left/right,bar",2,0,2,50,0,50);
110 tdcOccS =
new TH1I(
"tdcOccS",
"TOF, TDC Occupancy",86,1,44);
111 tdcOccN =
new TH1I(
"tdcOccN",
"TOF, TDC Occupancy",86,1,44);
112 tdcOccU =
new TH1I(
"tdcOccU",
"TOF, TDC Occupancy",86,1,44);
113 tdcOccD =
new TH1I(
"tdcOccD",
"TOF, TDC Occupancy",86,1,44);
115 adcOccS =
new TH1I(
"adcOccS",
"TOF, fADC Occupancy",86,1,44);
116 adcOccN =
new TH1I(
"adcOccN",
"TOF, fADC Occupancy",86,1,44);
117 adcOccU =
new TH1I(
"adcOccU",
"TOF, fADC Occupancy",86,1,44);
118 adcOccD =
new TH1I(
"adcOccD",
"TOF, fADC Occupancy",86,1,44);
120 histPed =
new TH1I(
"histPed",
"TOF, Pedestals",100, 0, 500);
122 hTimeAdc =
new TH1I(
"hTimeAdc",
"TOF, fADC time",100,0,400);
123 hTimeTdc =
new TH1I(
"hTimeTdc",
"TOF, TDC time",100,0,750);
125 planeHor =
new TH2I(
"planeHor",
"TOF Upstream, Hit position, Horizontal Plane",84,-126,126,84,-126,126);
126 planeVer =
new TH2I(
"planeVer",
"TOF Upstream, Hit position, Vertical Plane",84,-126,126,84,-126,126);
130 100,0.,500., 88, 0., 88.);
132 100,0.,500., 88, 0., 88.);
134 300,0.,10000., 88, 0., 88.);
136 300,0.,10000., 88, 0., 88.);
138 TOFTimesPlane0 =
new TH2F(
"TOFTimesPlane0",
"TOF TDC times Plane 0 all PMTs",
139 800,0.,1000., 88, 0., 88.);
140 TOFTimesPlane1 =
new TH2F(
"TOFTimesPlane1",
"TOF TDC times Plane 1 all PMTs",
141 800,0.,1000., 88, 0., 88.);
143 TOFWalkExample =
new TH2F(
"TOFWalkEXample",
"TOF T-vs-E walk correction example", 200, 10., 24000., 500, 200.,350.);
158 map<string,double> tdcshift;
159 if (!eventLoop->GetCalib(
"/TOF/tdc_shift", tdcshift)){
160 TOF_TDC_SHIFT = tdcshift[
"TOF_TDC_SHIFT"];
182 double tdc_time,pulse_time;
184 int ExamplePlane = 0;
192 double hit_north[45];
193 double hit_south[45];
196 double position, time, width;
199 Float_t distY_Horz = -126;
200 Float_t distX_Vert = -126;
202 memset(hit_north,0,
sizeof(hit_north));
203 memset(hit_south,0,
sizeof(hit_south));
204 memset(hit_up,0,
sizeof(hit_up));
205 memset(hit_down,0,
sizeof(hit_down));
217 vector< const DCAEN1290TDCHit*> CAENHits;
218 eventLoop->Get(CAENHits);
219 if (CAENHits.size()<=0){
222 uint32_t locROCID = CAENHits[0]->rocid;
224 vector <const DCODAROCInfo*> ROCS;
225 eventLoop->Get(ROCS);
226 for (
unsigned int n=0; n<ROCS.size(); n++) {
227 if (locROCID == ROCS[n]->rocid){
236 uint64_t TriggerTime = ROCS[indx]->timestamp;
237 int TriggerBIT = TriggerTime%6;
238 float TimingShift = TOF_TDC_SHIFT - (float)TriggerBIT;
241 if(TimingShift <= 0) {
247 vector<const DTOFHit*> dtofhits;
248 eventLoop->Get(dtofhits);
252 japp->RootFillLock(
this);
254 if(dtofhits.size() > 0)
257 for(
unsigned int i=0; i<dtofhits.size(); i++) {
258 const DTOFHit *dtofhit = dtofhits[i];
260 plane = dtofhit->
plane;
263 E = dtofhit->
dE*1000000.;
270 dtofhit->GetSingle(tdig);
271 tdc_time = std::numeric_limits<double>::quiet_NaN();
272 pulse_time = std::numeric_limits<double>::quiet_NaN();
274 const uint32_t &Rtdc_time = tdig->
time;
275 if(Rtdc_time!=0xFFFF){
276 tdc_time = 0.025*(double)Rtdc_time;
284 if ( (plane == ExamplePlane) &&
285 (bar == ExampleBar) &&
286 (end == ExampleEnd)){
287 tTDC = (float)tdig->
time * 0.0234375;
293 dtofhit->GetSingle(digi);
296 const uint32_t &Rpedestal = digi->
pedestal;
297 const uint32_t &Rpulse_time = digi->
pulse_time;
298 if(Rpedestal!=0xFFFF && Rpulse_time!=0xFFFF){
299 pedestal = Rpedestal;
300 pulse_time = 0.0625*(double)Rpulse_time;
314 if ( (plane == ExamplePlane) &&
315 (bar == ExampleBar) &&
316 (end == ExampleEnd)){
325 if(dtofhits[i]->dE>0.0) {
333 tofo1->Fill(bar,end);
335 tofo2->Fill(end,bar);
349 if (pedestal!=0xFFFF)
histPed->Fill(pedestal);
356 if ( ( (hit_down[bar]<=0) || (t < hit_down[bar]) ) && (bar!=22 || bar!=23) ){
357 hit_down[bar] = time;
364 if (pedestal!=0xFFFF)
histPed->Fill(pedestal);
371 if ( ( (hit_up[bar]<=0) || (t < hit_up[bar]) ) && (bar!=22 || bar!=23) ){
381 if (pedestal!=0xFFFF)
histPed->Fill(pedestal);
388 if ( ( (hit_north[bar]<=0) || (t < hit_north[bar]) ) && (bar!=22 || bar!=23) ){
389 hit_north[bar] = time;
396 if (pedestal!=0xFFFF)
histPed->Fill(pedestal);
403 if ( ( (hit_south[bar]<=0) || (t < hit_south[bar]) ) && (bar!=22 || bar!=23) ){
404 hit_south[bar] = time;
418 for (
int i=1; i<45; i++)
421 if ( i == 20 || i == 21 || i == 24 || i == 25 ){
422 distY_Horz = distY_Horz + 1.5;
423 distX_Vert = distX_Vert + 1.5;
427 distY_Horz = distY_Horz + 3;
428 distX_Vert = distX_Vert + 3;
432 if( hit_south[i]>0 && hit_north[i]>0 )
434 position = (15.2*(Float_t(hit_south[i] - hit_north[i])/2) );
435 distY_Horz = distY_Horz + (drand48()-0.5)*width;
436 if (position )
planeHor->Fill(position,distY_Horz);
439 if( hit_up[i]>0 && hit_down[i]>0 )
441 position = (15.2*(Float_t(hit_up[i] - hit_down[i])/2) );
442 distX_Vert = distX_Vert + (drand48()-0.5)*width;
443 planeVer->Fill(distX_Vert,position);
446 if ( i == 20 || i == 21 || i == 24 || i == 25 ){
447 distY_Horz = distY_Horz + 1.5;
448 distX_Vert = distX_Vert + 1.5;
451 distY_Horz = distY_Horz + 3;
452 distX_Vert = distX_Vert + 3;
457 japp->RootFillUnLock(
this);
static TH2F * TOFSignalsRawPlane0
static TH2F * TOFTimesPlane0
if(locHist_BCALShowerPhiVsZ!=NULL)
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
uint32_t pedestal
pedestal info used by FPGA (if any)
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
static TH2F * TOFWalkExample
static TH2F * TOFSignalsRawPlane1
JEventProcessor_TOF_online()
uint32_t nsamples_integral
number of samples used in integral
static TH1I * tof_num_events
static TH2F * TOFPedestalsPlane1
~JEventProcessor_TOF_online()
uint32_t nsamples_pedestal
number of samples used in pedestal
static TH2F * TOFTimesPlane1
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
static TH1I * pedestal[nChan]
uint32_t pulse_time
identified pulse time as returned by FPGA algorithm
File: DTOFHit.h Created: Tue Jan 18 16:15:26 EST 2011 Creator: B. Zihlmann Purpose: Container class t...
jerror_t fini(void)
Called after last event of last event source has been processed.
jerror_t init(void)
Called once at program start.
static TH2F * TOFPedestalsPlane0
int main(int argc, char *argv[])
uint32_t pulse_integral
identified pulse integral as returned by FPGA algorithm