12 #include <JANA/JApplication.h>
26 #include <TDirectory.h>
29 #include <TProfile2D.h>
84 TDirectory *
main = gDirectory;
85 gDirectory->mkdir(
"bcal_saturation")->cd();
87 gStyle->SetTitleOffset(1,
"Y");
88 gStyle->SetTitleSize(0.05,
"xyz");
89 gStyle->SetTitleSize(0.08,
"h");
90 gStyle->SetLabelSize(0.05,
"xyz");
92 gStyle->SetTitleAlign(13);
93 gStyle->SetNdivisions(505,
"xy");
95 bcal_num_events =
new TH1I(
"bcal_num_events",
"BCAL Number of events",1, 0.5, 1.5);
97 bcal_saturated_counter =
new TH1I(
"bcal_saturated_counter",
"BCAL # saturated fADCs per event; # saturated fADCs", 10, 0, 10);
99 TString locSaturateName[2] = {
"saturate",
"noSaturate"};
100 for(
int locSaturate = 0; locSaturate<2; locSaturate++){
101 for(
int locLayer=0; locLayer<4; locLayer++){
103 bcalUS_waveform[locSaturate][locLayer] =
new TH2F(Form(
"bcalUS_waveform_%s_layer%d", locSaturateName[locSaturate].Data(), locLayer+1),
"Upstream BCAL Waveforms; DigiHit Number; Samples", 10000, 0, 10000, 100, 0, 100);
104 bcalDS_waveform[locSaturate][locLayer] =
new TH2F(Form(
"bcalDS_waveform_%s_layer%d", locSaturateName[locSaturate].Data(), locLayer+1),
"Downstream BCAL Waveforms; DigiHit Number; Samples", 10000, 0, 10000, 100, 0, 100);
108 bcal_fadc_digi_integral =
new TH1I(
"bcal_fadc_digi_integral",
"BCAL Integral (DBCALDigiHit);Integral (fADC counts)", 600, 0, 120000);
109 bcal_fadc_digi_peak =
new TH1I(
"bcal_fadc_digi_peak",
"BCAL Peak (DBCALDigiHit);Peak (fADC counts)", 1000, 0, 5000);
110 bcal_fadc_digi_integral_peak =
new TH2I(
"bcal_fadc_digi_integral_peak",
"BCAL Integral vs Peak (DBCALDigiHit);Peak (fADC counts);Integral (fADC counts)", 1000, 0, 5000, 600, 0, 120000);
111 bcal_fadc_digi_QF =
new TH1I(
"bcal_fadc_digi_QF",
"Qualtiy Factor (DBCALDigiHit);Qualtiy Factor", 20, 0, 20);
112 bcal_fadc_digi_time =
new TH1I(
"bcal_fadc_digi_time",
"ADC Time (DBCALDigiHit);Time (fADC time/62.5 ps)", 550, -600, 6000);
113 bcal_fadc_digi_time_saturate =
new TH1I(
"bcal_fadc_digi_time_saturate",
"Saturated pulse ADC Time (DBCALDigiHit);Time (fADC time/62.5 ps)", 550, -600, 6000);
118 for(
int locSaturate = 0; locSaturate<2; locSaturate++){
119 for(
int locLayer=0; locLayer<4; locLayer++){
120 waveformCounterUS[locSaturate][locLayer] = 0;
121 waveformCounterDS[locSaturate][locLayer] = 0;
148 vector<const DBCALDigiHit*> dbcaldigihits;
155 loop->GetSingle(trig);
163 bool locIsHDDMEvent = loop->GetJEvent().GetStatusBit(
kSTATUS_HDDM);
164 if (!locIsHDDMEvent) goodtrigger=0;
171 loop->Get(dbcaldigihits);
173 int locSaturatedCounter = 0;
177 japp->RootFillLock(
this);
179 if( (dbcaldigihits.size() > 0) )
183 for(
unsigned int i=0; i<dbcaldigihits.size(); i++) {
185 int locLayer = hit->
layer-1;
192 vector<const Df250WindowRawData*> f250WindowRawData;
193 hit->Get(f250WindowRawData);
194 if(hit->
pulse_peak > 3000 && f250WindowRawData.size() > 0) {
196 const vector<uint16_t> &samples = f250WindowRawData[0]->samples;
197 uint nsamples=samples.size();
198 for(uint isample=0; isample<nsamples; isample++) {
201 bcalUS_waveform[0][locLayer]->Fill(waveformCounterUS[0][locLayer], isample, samples[isample]);
203 bcalDS_waveform[0][locLayer]->Fill(waveformCounterDS[0][locLayer], isample, samples[isample]);
206 bcalUS_waveform[1][locLayer]->Fill(waveformCounterUS[1][locLayer], isample, samples[isample]);
208 bcalDS_waveform[1][locLayer]->Fill(waveformCounterDS[1][locLayer], isample, samples[isample]);
212 waveformCounterUS[0][locLayer]++;
214 waveformCounterDS[0][locLayer]++;
217 waveformCounterUS[1][locLayer]++;
219 waveformCounterDS[1][locLayer]++;
225 locSaturatedCounter++;
230 japp->RootFillUnLock(
this);
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
static TH2F * bcalDS_waveform[2][4]
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
static TH1I * bcal_saturated_counter
static TH1I * bcal_fadc_digi_time
~JEventProcessor_BCAL_saturation()
JEventProcessor_BCAL_saturation()
uint32_t pulse_peak
identified pulse height as returned by FPGA algorithm
static TH1I * bcal_fadc_digi_QF
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
uint32_t pulse_integral
identified pulse integral as returned by FPGA algorithm
jerror_t init(void)
Called once at program start.
static TH2I * bcal_fadc_digi_integral_peak
static TH2F * bcalUS_waveform[2][4]
static TH1I * bcal_num_events
static TH1I * bcal_fadc_digi_time_saturate
uint32_t pulse_time
identified pulse time as returned by FPGA algorithm
static TH1I * bcal_fadc_digi_peak
jerror_t fini(void)
Called after last event of last event source has been processed.
static TH1I * bcal_fadc_digi_integral
int main(int argc, char *argv[])