15 #include <JANA/JApplication.h>
31 #include <TDirectory.h>
80 initialized_histograms =
false;
100 TDirectory *
main = gDirectory;
101 gDirectory->mkdir(
"CDC")->cd();
104 cdc_num_events =
new TH1I(
"cdc_num_events",
"CDC number of events",1, 0.5, 1.5);
106 cdc_o =
new TH2I(
"cdc_o",
"CDC occupancy by straw, ring;straw;ring",209,0.5,209.5,28,0.5,28.5);
109 gDirectory->mkdir(
"rings_occupancy",
"CDC rings: occupancy")->cd();
113 int Nstraws[28] = {42, 42, 54, 54, 66, 66, 80, 80, 93, 93, 106, 106, 123, 123, 135, 135, 146, 146, 158, 158, 170, 170, 182, 182, 197, 197, 209, 209};
114 double radius[28] = {10.72134, 12.08024, 13.7795, 15.14602, 18.71726, 20.2438, 22.01672, 23.50008, 25.15616, 26.61158, 28.33624, 29.77388, 31.3817, 32.75838, 34.43478, 35.81146, 38.28542, 39.7002, 41.31564, 42.73042, 44.34078, 45.75302, 47.36084, 48.77054, 50.37582, 51.76012, 53.36286, 54.74716};
115 double phi[28] = {0, 0.074707844, 0.038166294, 0.096247609, 0.05966371, 0.012001551, 0.040721951, 0.001334527, 0.014963808, 0.048683644, 0.002092645, 0.031681749, 0.040719354, 0.015197341, 0.006786058, 0.030005892, 0.019704045, -0.001782064, -0.001306618, 0.018592421, 0.003686784, 0.022132975, 0.019600866, 0.002343723, 0.021301449, 0.005348855, 0.005997358, 0.021018761};
118 for(
int iring=0; iring<28; iring++){
119 double r_start = radius[iring] - 0.8;
120 double r_end = radius[iring] + 0.8;
121 double phi_start = phi[iring];
122 double phi_end = phi_start + TMath::TwoPi();
125 sprintf(hname,
"cdc_occ_ring[%d]", iring+1);
126 cdc_occ_ring[iring+1] =
new TH2D(hname,
"", Nstraws[iring], phi_start, phi_end, 1, r_start, r_end);
156 Char_t rtunits[8] =
"0.125ns";
160 if (runnumber > 3675) {
183 const Int_t NSTRAWS = 3522;
184 const Float_t HALF = 0.5;
185 const Float_t NSTRAWSPH = 3522.5;
187 japp->RootWriteLock();
189 if(initialized_histograms)
195 gDirectory->cd(
"CDC");
199 cdc_raw_amp =
new TH1I(
"cdc_raw_amp",
"CDC amplitude (ADC units, scaled); ADC units",AMAX,0,AMAX);
201 cdc_raw_amp_vs_n =
new TH2I(
"cdc_raw_amp_vs_n",
"CDC amplitude (ADC units, scaled) vs straw number;straw;ADC units",NSTRAWS,HALF,NSTRAWSPH,128,0,AMAX);
203 cdc_raw_t =
new TH1I(
"cdc_raw_t",Form(
"CDC raw time (units of %s); raw time (%s)",rtunits,rtunits),200,0,RTMAX);
205 cdc_raw_t_vs_n =
new TH2I(
"cdc_raw_t_vs_n",Form(
"CDC raw time (units of %s) vs straw number;straw;time (%s)",rtunits,rtunits),NSTRAWS,HALF,NSTRAWSPH,100,0,RTMAX);
207 cdc_raw_int =
new TH1I(
"cdc_raw_int",
"CDC integral (ADC units, scaled), pedestal subtracted; ADC units",200,0,IMAX);
209 cdc_raw_int_vs_n =
new TH2I(
"cdc_raw_int_vs_n",
"CDC integral (ADC units,scaled), pedestal subtracted, vs straw number;straw;ADC units",NSTRAWS,HALF,NSTRAWSPH,100,0,IMAX);
211 cdc_raw_intpp =
new TH1I(
"cdc_raw_intpp",
"CDC integral (ADC units, scaled), includes pedestal; ADC units",200,0,IMAX);
213 cdc_raw_intpp_vs_n =
new TH2I(
"cdc_raw_intpp_vs_n",
"CDC integral (ADC units, scaled), including pedestal, vs straw number;straw;ADC units",NSTRAWS,HALF,NSTRAWSPH,100,0,IMAX);
215 cdc_ped =
new TH1I(
"cdc_ped",
"CDC pedestal (ADC units);pedestal (ADC units)",(Int_t)(PMAX/2),0,PMAX);
217 cdc_ped_vs_n =
new TH2I(
"cdc_ped_vs_n",
"CDC pedestal (ADC units) vs straw number;straw;pedestal (ADC units)",NSTRAWS,HALF,NSTRAWSPH,(Int_t)(PMAX/4),0,PMAX);
219 cdc_windata_ped =
new TH1I(
"cdc_windata_ped",
"CDC pedestal (ADC units) from raw window data;pedestal (ADC units)",(Int_t)(PMAX/2),0,PMAX);
221 cdc_windata_ped_vs_n =
new TH2I(
"cdc_windata_ped_vs_n",
"CDC pedestal (ADC units) from raw window data vs straw number;straw;pedestal (ADC units)",NSTRAWS,HALF,NSTRAWSPH,(Int_t)(PMAX/4),0,PMAX);
223 gDirectory->cd(
"..");
225 initialized_histograms =
true;
257 uint32_t nsamples_integral=0;
258 uint32_t nsamples_pedestal=0;
260 const uint16_t NPEDSAMPLES=16;
265 int straw_offset[29] = {0,0,42,84,138,192,258,324,404,484,577,670,776,882,1005,1128,1263,1398,1544,1690,1848,2006,2176,2346,2528,2710,2907,3104,3313};
269 eventLoop->GetSingle(locTrigger);
278 vector<const DCDCDigiHit*> digihits;
279 eventLoop->Get(digihits);
282 vector<const Df125WindowRawData*> wrdvector;
283 eventLoop->Get(wrdvector);
289 japp->RootFillLock(
this);
291 if(digihits.size() > 0)
294 for(uint32_t i=0; i<digihits.size(); i++) {
305 vector<uint16_t> samples;
315 digihit->GetSingle(pi);
317 pi->GetSingle(windat);
322 if ((nsamples_integral > 0) && (nsamples_pedestal > 0)) PED_SUB = kTRUE;
324 }
else if (i < (uint32_t)wrdvector.size()) {
325 windat = wrdvector[i];
329 digihit->GetSingle(pp);
333 digihit->GetSingle(cp);
337 digihit->GetSingle(cf);
338 if (cf) nsamples_integral = cf->
IE - (int)(0.1*digihit->
pulse_time);
341 ring = digihit->
ring;
342 straw = digihit->
straw;
343 n = straw_offset[ring] + straw;
352 cdc_o->Fill(straw,ring);
354 Double_t w =
cdc_occ_ring[ring]->GetBinContent(straw, 1) + 1.0;
363 total_ped = p*nsamples_integral/nsamples_pedestal;
364 integ = integral - total_ped;
373 if (PED_SUB && (integ>0)) {
401 if (windat->
samples.size()>=NPEDSAMPLES) {
407 for (uint16_t i=0; i<NPEDSAMPLES; i++) winped += (uint32_t)windat->
samples[i];
409 winped = (uint32_t)winped/16.0;
421 japp->RootFillUnLock(
this);
uint32_t first_max_amp
from second word
uint32_t nsamples_integral
number of samples used in integral
jerror_t init(void)
Called once at program start.
uint32_t nsamples_pedestal
number of samples used in pedestal
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
JEventProcessor_CDC_online()
uint32_t pulse_peak
from Pulse Pedestal Data word
sprintf(text,"Post KinFit Cut")
static TH1I * cdc_raw_amp
uint32_t Get_L1FrontPanelTriggerBits(void) const
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
static TH2I * cdc_raw_int_vs_n
uint32_t pulse_time
identified pulse time as returned by FPGA algorithm
bool Get_IsPhysicsEvent(void) const
~JEventProcessor_CDC_online()
static TH1I * cdc_raw_int
uint32_t pulse_integral
identified pulse integral as returned by FPGA algorithm
vector< uint16_t > samples
jerror_t fini(void)
Called after last event of last event source has been processed.
TH2I * cdc_windata_ped_vs_n
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
static TH1I * cdc_num_events
static TH2I * cdc_raw_amp_vs_n
static TH2D * cdc_occ_ring[29]
uint32_t pedestal
pedestal info used by FPGA (if any)
TH2D * cdc_raw_intpp_vs_n
int main(int argc, char *argv[])