10 #include <JANA/JApplication.h>
24 #include <TDirectory.h>
104 TDirectory *
mainDir = gDirectory;
105 TDirectory *dircDir = gDirectory->mkdir(
"DIRC_online");
108 hLEDRefAdcTime =
new TH1I(
"LEDRefAdcTime",
"LED ADC reference SiPM time; time (ns)", 100, -20, 20);
109 hLEDRefTdcTime =
new TH1I(
"LEDRefTdcTime",
"LED TDC reference SiPM time; time (ns)", 100, -20, 20);
110 hLEDRefIntegral =
new TH1I(
"LEDRefIntegral",
"LED reference SiPM integral; integral (ADC)", 100, 1000, 1500);
111 hLEDRefAdcVsTdcTime =
new TH2I(
"LEDRefAdcVsTdcTime",
"LED ADC vs TDC reference SiPM time; TDC time (ns); ADC time (ns)", 100, -20, 20, 100, -20, 20);
112 hLEDRefTdcChannelTimeDiff =
new TH1I(
"LEDRefTdcChannelTimeDiff",
"PMT pixel hit - LED TDC reference SiPM time; PMT Channel - SiPM TDC time (ns)", 400, 110, 150);
113 hLEDRefTdcVsChannelTime =
new TH2I(
"LEDRefTdcVsChannelTime",
"LED TDC reference SiPM time vs PMT pixel hit time; PMT Channel time (ns); TDC time (ns)", 40, 110, 150, 100, -20, 20);
114 hLEDRefAdcVsChannelTime =
new TH2I(
"LEDRefAdcVsChannelTime",
"LED ADC reference SiPM time vs PMT pixel hit time; PMT Channel time (ns); ADC time (ns)", 40, 110, 150, 100, -20, 20);
115 hLEDRefIntegralVsTdcTime =
new TH2I(
"LEDRefIntegralVsTdcTime",
"LED TDC reference SiPM time; TDC time (ns); Pulse Integral", 100, -20, 20, 100, 1000, 1500);
116 hRefTime =
new TH1I(
"RefTime",
"Reference time from mean hit time; time (ns)", 500, 0, 100);
119 dirc_num_events =
new TH1I(
"dirc_num_events",
"DIRC Number of events",1,0.5,1.5);
120 TDirectory *hitDir = gDirectory->mkdir(
"Hit"); hitDir->cd();
122 TString trig_str[] = {
"LED",
"NonLED"};
123 for (
int j = 0; j < 2; j++) {
124 hHit_NHits[j] =
new TH1I(
"Hit_NHits_"+trig_str[j],
"DIRCPmtHit multiplicity " + trig_str[j] +
"; hits; events",
NmultBins,0.5,0.5+
Nmult);
125 hHit_Box[j] =
new TH1I(
"Hit_Box_"+trig_str[j],
"DIRCPmtHit box" + trig_str[j] +
"; box; hits",2,-0.5,-0.5+2);
126 hHit_NHitsVsBox[j] =
new TH2I(
"Hit_NHitsVsBox_"+trig_str[j],
"DIRCPmtHit multiplicity vs. box" + trig_str[j] +
"; box; hits",2,-0.5,-0.5+2,
NmultBins,0.5,0.5+
Nmult);
129 TString box_str[] = {
"NorthUpper",
"SouthLower"};
130 for (
int i = 0; i <
Nboxes; i++) {
131 gDirectory->mkdir(box_str[i]+
"Box")->cd();
132 for (
int j = 0; j < 2; j++) {
133 TString strN =
"_" + trig_str[j];
134 TString strT =
", " + box_str[i] +
" box " + trig_str[j] +
" trigger";
136 hHit_TimeOverThreshold[i][j] =
new TH1I(
"Hit_TimeOverThreshold"+strN,
"DIRCPmtHit time-over-threshold "+strT+
"; time-over-threshold (ns); hits",100,0.0,100.);
138 hHit_tdcTime[i][j] =
new TH1I(
"Hit_Time"+strN,
"DIRCPmtHit time "+strT+
";time [ns]; hits",500,0.0,500.0);
139 hHit_tdcTimeVsEvent[i][j] =
new TH2I(
"Hit_TimeVsEvent"+strN,
"DIRCPmtHit time "+strT+
"; event #; time [ns]; hits",1000,0,100e6,500,0.0,500.0);
145 hHit_tdcTimeDiffEvent[i] =
new TH1I(
"Hit_LEDTimeDiffEvent",
"LED DIRCPmtHit time diff in event; #Delta t [ns]",200,-50,50);
147 hHit_TimeEventMeanVsLEDRef[i] =
new TH2I(
"Hit_TimeEventMeanVsLEDRef",
"LED Time Event Mean DIRCPmtHit time vs. LED Reference time; LED reference time [ns] ; LED pixel event mean time [ns]", 100, 100, 150, 400, -10, 30);
148 hHit_TimeDiffEventMeanLEDRefVsTimestamp[i] =
new TH2I(
"Hit_TimeDiffeventMeanLEDRefVsTimestamp",
"LED Time Event Mean DIRCPmtHit time - LED reference time vs. event timestamp; event timestamp [ns?] ; time difference [ns]", 1000, 0, 1e10, 400, 100, 140);
151 gDirectory->mkdir(
"Timewalk")->cd();
153 hHit_Timewalk[i][j] =
new TH2I(Form(
"Hit_Timewalk_%d",j),Form(
"DIRCPmtHit channel %d: #Delta t vs time-over-threshold; time-over-threshold [ns]; #Delta t [ns]",j),100,0,100,100,-50.,50.);
162 TDirectory *digihitDir = gDirectory->mkdir(
"DigiHit"); digihitDir->cd();
164 for (
int j = 0; j < 2; j++) {
166 hDigiHit_Box[j] =
new TH1I(
"DigiHit_Box_"+trig_str[j],
"DIRCTDCDigiHit box" + trig_str[j] +
";box;hits",Nboxes,-0.5,-0.5+Nboxes);
170 for (
int i = 0; i <
Nboxes; i++) {
171 gDirectory->mkdir(box_str[i]+
"Box")->cd();
172 for (
int j = 0; j < 2; j++) {
173 TString strN =
"_" + trig_str[j];
174 TString strT =
", " + box_str[i] +
" box " + trig_str[j] +
" trigger";
176 hDigiHit_tdcTime[i][j] =
new TH1I(
"TDCDigiHit_Time"+strN,
"DIRCTDCDigiHit time"+strT+
";time [ns]; hits",500,0.0,500.0);
209 vector<const DDIRCGeometry*> locDIRCGeometryVec;
210 eventLoop->Get(locDIRCGeometryVec);
211 auto locDIRCGeometry = locDIRCGeometryVec[0];
214 vector<const DDIRCTDCDigiHit*> digihits;
215 eventLoop->Get(digihits);
216 vector<const DDIRCPmtHit*> hits;
217 eventLoop->Get(hits);
218 vector<const DDIRCTriggerTime*> timestamps;
219 eventLoop->Get(timestamps);
222 eventLoop->GetSingle(locTTabUtilities);
225 vector<const DCODAROCInfo*> locCODAROCInfos;
226 eventLoop->Get(locCODAROCInfos);
227 uint64_t locReferenceClockTime = 0;
228 for (
const auto& locCODAROCInfo : locCODAROCInfos) {
229 if(locCODAROCInfo->rocid == 92) {
230 locReferenceClockTime = locCODAROCInfo->timestamp;
237 bool locDIRCLEDTrig =
false;
238 bool locPhysicsTrig =
false;
239 vector<const DL1Trigger*>
trig;
240 eventLoop->Get(trig);
241 if (trig.size() > 0) {
243 if (trig[0]->fp_trig_mask & 0x4000){
244 locDIRCLEDTrig =
true;
247 if (trig[0]->trig_mask & 0x1){
248 locPhysicsTrig =
true;
252 if(locDIRCLEDTrig) loc_itrig = 0;
253 else if(locPhysicsTrig) loc_itrig = 1;
257 double locLEDRefTime = 0;
258 double locLEDRefAdcTime = 0;
259 double locLEDRefTdcTime = 0;
268 vector<const DDIRCLEDRef*> dircLEDRefs;
269 eventLoop->Get(dircLEDRefs);
270 for(uint i=0; i<dircLEDRefs.size(); i++) {
272 locLEDRefAdcTime = dircLEDRef->
t_fADC;
273 locLEDRefTdcTime = dircLEDRef->
t_TDC;
274 locLEDRefTime = dircLEDRef->
t_TDC;
276 japp->RootFillLock(
this);
282 japp->RootFillUnLock(
this);
315 japp->RootFillLock(
this);
320 int NDigiHits[] = {0,0};
322 for (
const auto& hit : digihits) {
323 int box = (hit->channel <
Nchannels) ? 1 : 0;
327 hDigiHit_pixelOccupancy[box][loc_itrig]->Fill(locDIRCGeometry->GetPixelRow(hit->channel), locDIRCGeometry->GetPixelColumn(hit->channel));
334 double locRefTime = 0;
336 double locFirstFiberTime = 128.1;
337 for (
const auto& hit : hits) {
339 int pmtrow = locDIRCGeometry->GetPmtRow(channel);
340 if(pmtrow < 6 && fabs(hit->t-locFirstFiberTime) < 5.) {
342 locRefTime += hit->t;
345 else if(pmtrow > 5 && pmtrow < 12 && fabs(hit->t-locFirstFiberTime-10) < 5.) {
347 locRefTime += (hit->t - 10);
350 else if(pmtrow > 11 && pmtrow < 18 && fabs(hit->t-locFirstFiberTime-20) < 5.) {
352 locRefTime += (hit->t - 20);
357 locRefTime /= locNHits;
364 bool ledFiber[3] = {
false,
false,
false};
365 for (
const auto& hit : hits) {
368 int pmtrow = locDIRCGeometry->GetPmtRow(channel);
369 if(pmtrow < 6) ledFiber[0] =
true;
370 else if(pmtrow < 12) ledFiber[1] =
true;
371 else ledFiber[2] =
true;
374 hHit_pixelOccupancy[box][loc_itrig]->Fill(locDIRCGeometry->GetPixelRow(hit->ch), locDIRCGeometry->GetPixelColumn(hit->ch));
386 if(locLEDRefTdcTime > 0) {
391 if(box==1 && channel==2490) {
397 double locDeltaT = hit->t - locRefTime;
398 if(ledFiber[1]) locDeltaT -= 10.;
399 if(ledFiber[2]) locDeltaT -= 20.;
404 hHit_NHits[loc_itrig]->Fill(NHits[0]+NHits[1]);
407 japp->RootFillUnLock(
this);
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
static TH1I * hLEDRefIntegral
static TH2I * hHit_tdcTimeVsChannel[Nboxes][2]
static TH2I * hHit_tdcTimeVsEvent[Nboxes][2]
static TH1I * hHit_tdcTimeDiffEvent[Nboxes]
static TH2I * hLEDRefIntegralVsTdcTime
static TH1I * hDigiHit_tdcTime[Nboxes][2]
static TH2I * hHit_TimeEventMeanVsLEDRef[Nboxes]
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
static TH2I * hHit_TimeOverThresholdVsChannel[Nboxes][2]
static TH2I * hLEDRefTdcVsChannelTime
static TH1I * hLEDRefTdcChannelTimeDiff
~JEventProcessor_DIRC_online()
static TH2I * hHit_Timewalk[Nboxes][Nchannels]
jerror_t fini(void)
Called after last event of last event source has been processed.
static TH1I * hLEDRefAdcTime
static TH2I * hHit_NHitsVsBox[2]
static TH1I * dirc_num_events
static TH1I * hHit_NHits[2]
static TH2I * hDigiHit_tdcTimeVsChannel[Nboxes][2]
jerror_t init(void)
Called once at program start.
static TH2I * hHit_TimeDiffEventMeanLEDRefVsTimestamp[Nboxes]
static TH1I * hDigiHit_NtdcHits[2]
JEventProcessor_DIRC_online()
static TH1I * hHit_tdcTime[Nboxes][2]
static TH2I * hDigiHit_NtdcHitsVsBox[2]
static TH1I * hDigiHit_Box[2]
static TH1I * hHit_TimeOverThreshold[Nboxes][2]
static TH2I * hDigiHit_pixelOccupancy[Nboxes][2]
static TH2I * hLEDRefAdcVsChannelTime
static TH1I * hLEDRefTdcTime
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
static TH2I * hHit_tdcTimeDiffVsChannel[Nboxes]
static TH2I * hHit_pixelOccupancy[Nboxes][2]
static TH1I * hHit_Box[2]
static TH2I * hLEDRefAdcVsTdcTime