6 #include <Event/Event.h>
37 for (
int ich=0; ich<nch; ich++)
40 bbcsig.push_back(
OnlBbcSig(ich,nsamples) );
43 bbcsig[ich].SetEventPed0Range(0,1);
47 for (
int iarm = 0; iarm < 2; iarm++)
52 title =
"bbc times, arm ";
54 hevt_bbct[iarm] =
new TH1F(name, title, 2000, -50., 50.);
55 hevt_bbct[iarm]->SetLineColor(4);
57 h2_tmax[0] =
new TH2F(
"h2_ttmax",
"time tmax vs ch",
NSAMPLES,-0.5,
NSAMPLES-0.5,128,0,128);
58 h2_tmax[0]->SetXTitle(
"sample");
59 h2_tmax[0]->SetYTitle(
"ch");
60 h2_tmax[1] =
new TH2F(
"h2_qtmax",
"chg tmax vs ch",
NSAMPLES,-0.5,
NSAMPLES-0.5,128,0,128);
61 h2_tmax[1]->SetXTitle(
"sample");
62 h2_tmax[1]->SetYTitle(
"ch");
64 for (
int iboard=0; iboard<16; iboard++)
66 TRIG_SAMP[iboard] = -1;
72 const char *bbccalib = getenv(
"BBCCALIB");
75 std::cout <<
"BBCCALIB environment variable not set" << std::endl;
79 Read_Charge_Calib( gainfile.c_str() );
82 Read_TQ_T0_Offsets( tq_t0_offsetfile.c_str() );
85 ifstream mondatafile( mondata_fname );
87 mondatafile >> label >> bz_offset;
88 std::cout << label <<
"\t" << bz_offset << std::endl;
98 for (
int iarm=0; iarm<2; iarm++)
124 for (
int ipmt = 0; ipmt <
BBC_N_PMT; ipmt++ )
135 for (
int iarm = 0; iarm < 2; iarm++ )
164 std::fill_n(
f_pmtt0, 128, 1e12);
165 std::fill_n(
f_pmtt1, 128, 1e12);
166 std::fill_n(
f_pmtq, 128, 0.);
175 for (
int ipkt=0; ipkt<2; ipkt++)
177 int pktid = 1001 + ipkt;
178 p[ipkt] =
event->getPacket( pktid );
185 int feech = ipkt*NCHPERPKT + ich;
187 for (
int isamp=0; isamp<
NSAMPLES; isamp++)
192 if (
f_adc[feech][isamp] <= 100 )
209 for (
int ipkt=0; ipkt<2; ipkt++)
211 if (
p[ipkt]!=0 )
delete p[ipkt];
226 gaussian =
new TF1(
"gaussian",
"gaus", 0, 20);
230 for (
int ich=0; ich<256; ich++)
236 int pmtch = (ich/16)*8 + ich%8;
243 if (
h2_tmax[1]->GetEntries() == 128*100 )
246 TH1 *h_trigsamp[16]{};
247 for (
int iboard=0; iboard<16; iboard++)
249 name =
"h_trigsamp"; name += iboard;
250 h_trigsamp[iboard] =
h2_tmax[1]->ProjectionX( name, iboard*8 + 1, (iboard+1)*8 );
251 int maxbin = h_trigsamp[iboard]->GetMaximumBin();
252 TRIG_SAMP[iboard] = h_trigsamp[iboard]->GetBinCenter( maxbin );
254 cout <<
"TRIG_SAMP" << iboard <<
"\t" <<
TRIG_SAMP[iboard] << endl;
264 std::vector<float> hit_times[2];
267 for (
int ich=0; ich<256; ich++)
271 int pmtch = (ich/16)*8 + ich%8;
278 bbcsig[ich].GetSplineAmpl();
279 Double_t threshold = 0.5;
324 f_pmtt0[pmtch] = 12.5 - tdc*0.00189;
342 if ( fabs(
f_pmtt1[ipmt]) < 25. )
344 hit_times[arm].push_back(
f_pmtt1[ipmt] );
355 for (
int iarm = 0; iarm < 2; iarm++)
357 if ( hit_times[iarm].empty() )
367 float earliest = hit_times[iarm].at(0);
381 ac =
new TCanvas(
"ac",
"ac",550*1.5,425*1.5);
428 std::ifstream gainfile( gainfname );
430 cout <<
"Reading gains from " << gainfname << endl;
432 float integ, integerr;
434 float width, widtherr;
436 while ( gainfile >> ch >> integ >> peak >> width >> integerr >> peakerr >> widtherr >> chi2ndf )
451 ifstream tcalibfile( t0cal_fname );
453 cout <<
"Reading tq_t0 offset calibrations from " << t0cal_fname << endl;
461 tcalibfile >> pmtnum >>
tq_t0_offsets[ipmt] >> meanerr >> sigma >> sigmaerr;
462 if ( pmtnum != ipmt )
464 cerr <<
"ERROR, pmtnum != ipmt, " << pmtnum <<
"\t" << ipmt << endl;