26 #include <TLorentzVector.h>
28 #include <TDatabasePDG.h>
36 using namespace MbdDefs;
47 _savefname(
"bbcstudy.root" ),
61 _tree =
new TTree(
"t",
"BBC Study");
62 _tree->Branch(
"evt",&
f_evt,
"evt/I");
63 _tree->Branch(
"bimp",&
f_bimp,
"bimp/F");
64 _tree->Branch(
"ncoll",&
f_ncoll,
"ncoll/I");
65 _tree->Branch(
"npart",&
f_npart,
"npart/I");
66 _tree->Branch(
"vx",&
f_vx,
"vx/F");
67 _tree->Branch(
"vy",&
f_vy,
"vy/F");
68 _tree->Branch(
"vz",&
f_vz,
"vz/F");
69 _tree->Branch(
"bns",&
f_bbcn[0],
"bns/S");
70 _tree->Branch(
"bnn",&
f_bbcn[1],
"bnn/S");
71 _tree->Branch(
"bqs",&
f_bbcq[0],
"bqs/F");
72 _tree->Branch(
"bqn",&
f_bbcq[1],
"bqn/F");
73 _tree->Branch(
"bts",&
f_bbct[0],
"bts/F");
74 _tree->Branch(
"btn",&
f_bbct[1],
"btn/F");
75 _tree->Branch(
"btes",&
f_bbcte[0],
"btes/F");
76 _tree->Branch(
"bten",&
f_bbcte[1],
"bten/F");
77 _tree->Branch(
"bz",&
f_bbcz,
"bz/F");
78 _tree->Branch(
"bt0",&
f_bbct0,
"bt0/F");
80 _pdg = TDatabasePDG::Instance();
81 _rndm =
new TRandom3(0);
86 name =
"h_bbcq"; name += ipmt;
87 title =
"bbc charge, ch "; title += ipmt;
88 h_bbcq[ipmt] =
new TH1F(name,title,1200,0,120*90);
97 for (
int iarm=0; iarm<2; iarm++)
99 name =
"h_bbcqtot"; name += iarm;
100 title =
"bbc charge, arm "; title += iarm;
101 h_bbcqtot[iarm] =
new TH1F(name,title,1200,0,120*60);
104 name =
"hevt_bbct"; name += iarm;
105 title =
"bbc times, arm "; title += iarm;
106 hevt_bbct[iarm] =
new TH1F(name,title,200,7.5,11.5);
109 h2_bbcqtot =
new TH2F(
"h2_bbcqtot",
"north BBCQ vs South BBCQ",300,0,120*900,300,0,120*900);
111 h_ztrue =
new TH1F(
"h_ztrue",
"true z-vtx",600,-30,30);
112 h_tdiff =
new TH1F(
"h_tdiff",
"dt (measured - true_time)",6000,-3,3);
115 gaussian =
new TF1(
"gaussian",
"gaus",0,20);
118 c_bbct =
new TCanvas(
"c_bbct",
"BBC Times",1200,800);
201 cout <<
"VTXP " <<
"\t" <<
f_vx <<
"\t" <<
f_vy <<
"\t" <<
f_vz <<
"\t" <<
f_vt << endl;
211 unsigned int nvtx = 0;
246 unsigned int nhits = 0;
252 for (
auto hit_iter = bbc_hit_range.first; hit_iter != bbc_hit_range.second; hit_iter++)
254 PHG4Hit *this_hit = hit_iter->second;
256 unsigned int ipmt = this_hit->
get_layer();
260 if ( trkid>0 &&
f_evt<20 ) cout <<
"TRKID " << trkid << endl;
266 TParticlePDG *partinfo =
_pdg->GetParticle( pid );
270 charge = partinfo->Charge()/3;
272 else if ( part->
isIon() )
277 Double_t beta = v4.Beta();
292 float tube_z = zsign*253.;
293 float flight_z = fabs(tube_z - vtxp->
get_z());
295 float flight_time = sqrt( tube_x*tube_x + tube_y*tube_y + flight_z*flight_z )/
C;
296 float tdiff = this_hit->
get_t(1) - ( vtxp->
get_t() + flight_time );
299 if ( this_hit->
get_t(1) < first_time[ipmt] )
301 if ( fabs( this_hit->
get_t(1) ) < 106.5 )
303 first_time[ipmt] = this_hit->
get_t(1) - vtxp->
get_t();
304 Float_t dt =
static_cast<float>(
_rndm->Gaus( 0,
_tres ) );
305 first_time[ipmt] += dt;
309 cout <<
"BAD " << ipmt <<
"\t" << this_hit->
get_t(1) << endl;
315 cout <<
"hit " << ipmt <<
"\t" << trkid <<
"\t" << pid
323 <<
"\t" << this_hit->
get_x(1)
324 <<
"\t" << this_hit->
get_y(1)
325 <<
"\t" << this_hit->
get_z(1)
326 <<
"\t" << this_hit->
get_t(1)
353 cout <<
"ERROR " << endl;
361 cout <<
"******** " <<
f_evt <<
" **************" << endl;
366 for (
int iarm=0; iarm<2; iarm++)
371 vector<float> hit_times[2];
384 cout <<
"ipmt " << ipmt <<
"\t" << len[ipmt] <<
"\t" << edep[ipmt] << endl;
388 float npe = len[ipmt]*(120/3.0);
389 float dnpe =
static_cast<float>(
_rndm->Gaus( 0, sqrt(npe) ) );
395 h_bbcq[ipmt]->Fill( npe );
399 if ( first_time[ipmt] < 9999. )
402 hevt_bbct[arm]->Fill( first_time[ipmt] );
403 hit_times[arm].push_back( first_time[ipmt] );
405 f_bbct[arm] += first_time[ipmt];
411 cout <<
"ERROR, have hit but no time" << endl;
422 for (
int iarm=0; iarm<2; iarm++)
427 float earliest = hit_times[iarm][0];
430 gaussian->SetParameter(1, earliest);
431 gaussian->SetRange(6, earliest+ 5*0.05);
458 cout <<
"Event " <<
f_evt <<
" ? ";
461 TString
name =
"evt_"; name +=
f_evt; name +=
".png";
480 _truth_container = findNode::getClass<PHG4TruthInfoContainer>(topNode,
"G4TruthInfo");
484 _bbchits = findNode::getClass<PHG4HitContainer> (topNode,
"G4HIT_BBC");
487 _evtheader = findNode::getClass<EventHeaderv1>(topNode,
"EventHeader");
500 cout <<
"PIDs of Particles that hit BBC" << endl;
501 unsigned int ipid = 0;
507 for (
auto &
pid : _pids)
509 cout <<
pid.first <<
"\t" <<
pid.second <<
"\t" <<
pid.second/npart << endl;
512 cout <<
"There were " << ipid <<
" different particle types" << endl;
520 _bbcout = findNode::getClass<MbdOut>(topNode,
"MbdOut");
524 _bbcpmts = findNode::getClass<MbdPmtContainer>(topNode,
"MbdPmtContainer");
525 if(!
_bbcpmts &&
f_evt<4) cout <<
PHWHERE <<
" MbdPmtContainer node not found on node tree" << endl;
530 cout <<
"ERROR, f_bbcz != bbcz, " <<
f_bbcz <<
"\t" << bbcz << endl;
533 for (
int iarm=0; iarm<2; iarm++)
537 cout <<
"ERROR, f_bbcq != bbcq, arm " << iarm <<
"\t" <<
f_bbcq[iarm] <<
"\t" <<
_bbcout->
get_q(iarm) << endl;