12 #include <JANA/JApplication.h>
26 #include <TDirectory.h>
139 TDirectory *
mainDir = gDirectory;
140 TDirectory *taghDir = gDirectory->mkdir(
"TAGH");
144 tagh_num_events =
new TH1I(
"tagh_num_events",
"TAGH number of events",1,0.5,1.5);
145 hBeamCurrent =
new TH1I(
"BeamCurrent",
"Beam current;beam current [nA]",600,0.0,300.0);
147 gDirectory->mkdir(
"Hit")->cd();
148 hHit_HasTDCvsHasADC =
new TH2F(
"Hit_HasTDCvsHasADC",
"TAGH has TDC? vs. has ADC?;fADC status;TDC status",2,-0.5,1.5,2,-0.5,1.5);
156 hHit_Energy =
new TH1F(
"Hit_Energy",
"TAGH energy;photon energy [GeV];hits / counter",120,0.0,12.0);
157 hHit_EnergyVsSlotID =
new TH2I(
"Hit_EnergyVsSlotID",
"TAGH energy vs. counter ID;counter (slot) ID;photon energy [GeV]",
Nslots,0.5,0.5+
Nslots,120,0.0,12.0);
158 hHit_Integral =
new TH1I(
"Hit_Integral",
"TAGH fADC pulse integral;pulse integral;hits",1000,0.0,30000.0);
159 hHit_IntegralVsSlotID =
new TH2I(
"Hit_IntegralVsSlotID",
"TAGH fADC pulse integral vs. counter ID;counter (slot) ID;pulse integral",
Nslots,0.5,0.5+
Nslots,1000,0.0,30000.0);
161 hHit_fadcTime =
new TH1I(
"Hit_fadcTime",
"TAGH fADC time;time [ns];hits / 400 ps",2000,-400.0,400.0);
163 hHit_Time =
new TH1I(
"Hit_Time",
"TAGH time;time [ns];hits / 400 ps",2000,-400.0,400.0);
164 hHit_TimeVsSlotID =
new TH2F(
"Hit_TimeVsSlotID",
"TAGH time vs. counter ID;counter (slot) ID;time [ns]",
Nslots,0.5,0.5+
Nslots,2000,-400.0,400.0);
165 hHit_TimeVsEnergy =
new TH2F(
"Hit_TimeVsEnergy",
"TAGH time vs. energy;energy [GeV];time [ns]",120,0.0,12.0,2000,-400.0,400.0);
166 hHit_TimeVsIntegral =
new TH2I(
"Hit_TimeVsIntegral",
"TAGH time vs. integral;pulse integral;time [ns]",500,0.0,15000.0,2000,-400.0,400.0);
167 hHit_tdcTime =
new TH1I(
"Hit_tdcTime",
"TAGH TDC time;time [ns];hits / 400 ps",2000,-400.0,400.0);
169 hHit_tdcadcTimeDiffVsSlotID =
new TH2I(
"Hit_tdcadcTimeDiffVsSlotID",
"TAGH TDC/ADC time difference vs. counter ID;counter (slot) ID;time(TDC) - time(ADC) [ns]",
Nslots,0.5,0.5+
Nslots,200,-40.0,40.0);
170 hHit_tdcadcTimeDiffVsIntegral =
new TH2I(
"Hit_tdcadcTimeDiffVsIntegral",
"TAGH TDC/ADC time difference vs. integral;pulse integral;time(TDC) - time(ADC) [ns]",500,0.0,15000.0,200,-40.0,40.0);
173 gDirectory->mkdir(
"DigiHit")->cd();
175 hDigiHit_NSamplesPedestal =
new TH1I(
"DigiHit_NSamplesPedestal",
"TAGH fADC pedestal samples;pedestal samples;raw hits",50,-0.5,49.5);
176 hDigiHit_Pedestal =
new TH1I(
"DigiHit_Pedestal",
"TAGH fADC pedestals;pedestal [fADC counts];raw hits",200,0.0,200.0);
178 hDigiHit_QualityFactor =
new TH1I(
"DigiHit_QualityFactor",
"TAGH fADC quality factor;quality factor;raw hits",4,-0.5,3.5);
179 hDigiHit_PulseNumber =
new TH1I(
"DigiHit_PulseNumber",
"TAGH fADC pulse number;pulse number;raw hits",4,-0.5,3.5);
182 hDigiHit_RawPeak =
new TH1I(
"DigiHit_RawPeak",
"TAGH fADC pulse peak (raw);pulse peak (raw);raw hits",410,0.0,4100.0);
183 hDigiHit_RawPeakVsSlotID =
new TH2I(
"DigiHit_RawPeakVsSlotID",
"TAGH fADC pulse peak (raw) vs. counter ID;counter (slot) ID;pulse peak (raw)",
Nslots,0.5,0.5+
Nslots,410,0.0,4100.0);
184 hDigiHit_RawIntegral =
new TH1I(
"DigiHit_RawIntegral",
"TAGH fADC pulse integral (raw);pulse integral (raw);raw hits",1000,0.0,30000.0);
185 hDigiHit_RawIntegralVsSlotID =
new TH2I(
"DigiHit_RawIntegralVsSlotID",
"TAGH fADC pulse integral (raw) vs. counter ID;counter (slot) ID;pulse integral (raw)",
Nslots,0.5,0.5+
Nslots,1000,0.0,30000.0);
186 hDigiHit_NSamplesIntegral =
new TH1I(
"DigiHit_NSamplesIntegral",
"TAGH fADC integral samples;integral samples;raw hits",60,-0.5,59.5);
187 hDigiHit_PeakVsSlotID =
new TH2I(
"DigiHit_PeakVsSlotID",
"TAGH fADC pulse peak vs. counter ID;counter (slot) ID;pulse peak",
Nslots,0.5,0.5+
Nslots,410,0.0,4100.0);
188 hDigiHit_IntegralVsPeak =
new TH2I(
"DigiHit_IntegralVsPeak",
"TAGH fADC pulse integral vs. peak;pulse peak;pulse integral",410,0.0,4100.0,1000,0.0,30000.0);
190 hDigiHit_PulseTime =
new TH1I(
"DigiHit_PulseTime",
"TAGH fADC pulse time;pulse time [62.5 ps];raw hits",1000,0.0,6500.0);
191 hDigiHit_fadcTime =
new TH1I(
"DigiHit_fadcTime",
"TAGH fADC pulse time;pulse time [ns];raw hits / 400 ps",1000,0.0,400.0);
193 hDigiHit_fadcTimeVsIntegral =
new TH2I(
"DigiHit_fadcTimeVsIntegral",
"TAGH fADC pulse time vs. integral;pulse integral;pulse time [ns]",500,0.0,15000.0,1000,0.0,400.0);
197 hDigiHit_tdcRawTime =
new TH1I(
"DigiHit_tdcRawTime",
"TAGH TDC raw time;time [60 ps];raw hits",1000,0.0,65500.0);
198 hDigiHit_tdcTime =
new TH1I(
"DigiHit_tdcTime",
"TAGH TDC time;time [ns];raw hits / 400 ps",2000,0.0,800.0);
200 hDigiHit_tdcTimeVsfadcTime =
new TH2I(
"DigiHit_tdcTimeVsfadcTime",
"TAGH TDC time vs. ADC time;fADC time [ns];TDC time [ns]",400,0.0,400.0,800,0.0,800.0);
201 hDigiHit_tdcadcTimeDiff =
new TH1I(
"DigiHit_tdcadcTimeDiff",
"TAGH TDC/ADC time difference;time(TDC) - time(ADC) [ns];raw hits / 400 ps",1000,0.0,400.0);
203 hDigiHit_tdcadcTimeDiffVsIntegral =
new TH2I(
"DigiHit_tdcadcTimeDiffVsIntegral",
"TAGH TDC/ADC time difference vs. pulse integral;pulse integral;time(TDC) - time(ADC) [ns]",500,0.0,15000.0,1000,0.0,400.0);
210 hDigiHit_fadcTime_cut =
new TH1I(
"DigiHit_fadcTime_cut",
"TAGH fADC pulse time (> 1k ADC integral counts);pulse time [ns];raw hits / 400 ps",1000,0.0,400.0);
211 hDigiHit_fadcTimeVsSlotID_cut =
new TH2I(
"DigiHit_fadcTimeVsSlotID_cut",
"TAGH fADC pulse time vs. counter ID (> 1k ADC integral counts);counter (slot) ID;pulse time [ns]",
Nslots,0.5,0.5+
Nslots,1000,0.0,400.0);
212 hDigiHit_fadcTimeVsQF_cut =
new TH2I(
"DigiHit_fadcTimeVsQF_cut",
"TAGH fADC pulse time vs. quality factor (> 1k ADC integral counts);fADC quality factor;pulse time [ns]",4,-0.5,3.5,1000,0.0,400.0);
226 vector<const DTAGHGeometry*> taghGeomVect;
227 eventLoop->Get(taghGeomVect);
228 if (taghGeomVect.size() == 0)
return OBJECT_NOT_AVAILABLE;
233 for (
int i = 0; i <
Nslots; i++) {
234 Elows[i] = taghGeom.
getElow(Nslots - i);
241 const int Ntime = 2000;
242 double Tlows[Ntime + 1];
243 for (
int i = 0; i <= Ntime; i++) {
244 Tlows[i] = -400.0 + i*0.4;
249 japp->RootFillLock(
this);
255 japp->RootFillUnLock(
this);
272 vector<const DTAGHHit*> hits;
273 eventLoop->Get(hits,
"Calib");
274 vector<const DTAGHDigiHit*> digihits;
275 eventLoop->Get(digihits);
276 vector<const DTAGHTDCDigiHit*> tdcdigihits;
277 eventLoop->Get(tdcdigihits);
280 eventLoop->GetSingle(ttabUtilities);
283 map< const DTAGHDigiHit*, pair<const Df250PulseData*, const Df250WindowRawData*> > pd_wrd_cache;
284 for (
const auto& hit : digihits) {
288 if (pd !=
nullptr) pd->GetSingle(wrd);
289 pd_wrd_cache[hit] = pair<const Df250PulseData*, const Df250WindowRawData*>(pd, wrd);
293 vector<const DEPICSvalue*> epicsVals;
294 eventLoop->Get(epicsVals);
295 for (
const auto& ev : epicsVals) {
296 if (ev->name ==
"IBCAD00CRCUR6") {
304 japp->RootFillLock(
this);
307 if (digihits.size() > 0 || tdcdigihits.size() > 0)
313 int NfadcHits_cut = 0;
314 int NHits_hasADC = 0;
int NHits_hasADC_us = 0;
int NHits_hasADC_ds = 0;
316 for (
int i = 0; i <
Nslots; i++) Nadc[i] = 0;
317 for (
const auto& hit : digihits) {
318 double ped = (double)hit->pedestal/hit->nsamples_pedestal;
322 if (ped == 0.0 || hit->pulse_peak == 0)
continue;
329 double pI = hit->pulse_integral-hit->nsamples_integral*ped;
334 double t_ns = 0.0625*hit->pulse_time;
351 size_t threshold = 400;
352 if (wrd !=
nullptr) {
353 size_t prevSample = 100;
356 for (
size_t sample : wrd->
samples) {
357 if (sample > threshold && prevSample < threshold) {
363 Nadc[hit->counter_id-1] = Ncrosses;
366 if (hit->pulse_peak > threshold) Nadc[hit->counter_id-1]++;
371 if (digihits.size() > 0) {
372 for (
int i = 0; i <
Nslots; i++) {
373 NmultiPeak += Nadc[i];
379 for (
const auto& hit : digihits) {
380 double ped = (double)hit->pedestal/hit->nsamples_pedestal;
381 double pI = hit->pulse_integral-ped*hit->nsamples_integral;
384 for (
const auto& tdchit : tdcdigihits) {
385 if (hit->counter_id == tdchit->counter_id) {
388 double T_adc = 0.0625*hit->pulse_time;
400 for (
int i = 0; i <
Nslots; i++) Ntdc[i] = 0;
401 for (
const auto& hit : tdcdigihits) {
402 Ntdc[hit->counter_id-1]++;
409 if (tdcdigihits.size() > 0) {
410 for (
int i = 0; i <
Nslots; i++) {
416 for (
const auto& hit : hits) {
421 else NHits_hasADC_ds++;
448 japp->RootFillUnLock(
this);
static TH1I * hHit_NHits_us
double Convert_DigiTimeToNs_F1TDC(const JObject *locTDCDigiHit) const
double getElow(unsigned int counter) const
static TH1I * hDigiHit_NSamplesIntegral
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
static TH1I * hDigiHit_NSamplesPedestal
static TH1I * hDigiHit_NfadcHits
if(locHist_BCALShowerPhiVsZ!=NULL)
static TH2I * hDigiHit_adctdcMatchesVsSlotID_cut
static TH2I * hDigiHit_IntegralVsSlotID
static TH1I * hHit_Integral
static TH2I * hDigiHit_RawIntegralVsSlotID
static TH2I * hDigiHit_tdcadcTimeDiffVsSlotID
static TH2F * hHit_TimeVsEnergy
static TH2I * hDigiHit_NtdcHitsVsSlotID
static TH1I * tagh_num_events
JEventProcessor_TAGH_online()
vector< uint16_t > samples
static TH1I * hDigiHit_fadcOccupancy
static TH2I * hHit_IntegralVsSlotID
static TH2I * hDigiHit_fadcTimeVsSlotID_cut
static TH1I * hDigiHit_NtdcHits
static TH1I * hBeamCurrent
static TH2I * hDigiHit_fadcTimeVsIntegral
static TH2I * hDigiHit_tdcadcTimeDiffVsIntegral
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
static TH1F * hHit_Occupancy
static TH1I * hDigiHit_fadcTime_cut
static TH1I * hDigiHit_fadcOccupancy_cut
static TH1I * hHit_tdcTime
static TH2I * hHit_EnergyVsSlotID
static TH1I * hDigiHit_tdcOccupancy
static TH2I * hDigiHit_IntegralVsPeak
static TH2I * hDigiHit_PeakVsSlotID
static TH1F * hHit_Energy
static TH1I * hHit_fadcTime
static TH2I * hHit_TimeVsIntegral
static TH2I * hHit_tdcadcTimeDiffVsSlotID
static TH2I * hDigiHit_RawPeakVsSlotID
jerror_t init(void)
Called once at program start.
static TH1I * hDigiHit_Pedestal
jerror_t fini(void)
Called after last event of last event source has been processed.
static TH1I * hDigiHit_PulseTime
static TH2F * hHit_TimeVsSlotID
static TH2F * hHit_HasTDCvsHasADC
static TH1I * hDigiHit_tdcadcTimeDiff
~JEventProcessor_TAGH_online()
double getEhigh(unsigned int counter) const
static TH2I * hDigiHit_tdcTimeVsfadcTime
static int matches(char *d, char *c, t_iostream *fp)
static TH1I * hHit_RawNHits
static TH1I * hDigiHit_tdcRawTime
static TH2I * hDigiHit_fadcTimeVsSlotID
static TH2I * hHit_tdcadcTimeDiffVsIntegral
static TH2I * hHit_HVidVsSlotID
static TH1I * hDigiHit_RawPeak
static TH1I * hDigiHit_NfadcHits_cut
static TProfile * hDigiHit_PedestalVsSlotID
static TH1I * hHit_NHits_ds
static TH1I * hDigiHit_fadcTime
static TH1I * hDigiHit_PulseNumber
static TH2I * hHit_tdcTimeVsSlotID
static TH2I * hDigiHit_NfadcHitsVsSlotID
static TH1I * hDigiHit_RawIntegral
static TH1I * hDigiHit_NfadcHits_multiPeak
static const unsigned int kCounterCount
static TH2I * hDigiHit_PulseNumberVsSlotID
const int NupstreamCounters
static TH2I * hDigiHit_tdcTimeVsSlotID
static TH2I * hDigiHit_fadcTimeVsQF_cut
static TH1I * hDigiHit_tdcTime
static TH1I * hDigiHit_QualityFactor
uint32_t pulse_number
pulse number for this channel, this event starting from 0
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
static TH2I * hHit_fadcTimeVsSlotID