15 #include "TLorentzVector.h"
20 #include <trackbase_historic/SvtxVertex.h>
21 #include <trackbase_historic/SvtxVertexMap.h>
31 #include <g4vertex/GlobalVertexMap.h>
32 #include <g4vertex/GlobalVertex.h>
34 #include <calobase/RawClusterContainer.h>
35 #include <calobase/RawCluster.h>
36 #include <calobase/RawClusterv1.h>
37 #include <calobase/RawTowerv2.h>
38 #include <calobase/RawTowerGeom.h>
39 #include <calobase/RawTowerContainer.h>
40 #include <calobase/RawTowerGeomContainer_Cylinderv1.h>
41 #include <calobase/RawTowerGeomContainer.h>
48 #include <HepMC/GenVertex.h>
49 #include <HepMC/IteratorRange.h>
50 #include <HepMC/SimpleVector.h>
63 #include <gsl/gsl_rng.h>
65 #include "/gpfs/mnt/gpfs02/sphenix/user/lebedev/mdc/analysis/install/include/eventmix/sPHElectron.h"
66 #include "/gpfs/mnt/gpfs02/sphenix/user/lebedev/mdc/analysis/install/include/eventmix/sPHElectronv1.h"
67 #include "/gpfs/mnt/gpfs02/sphenix/user/lebedev/mdc/analysis/install/include/eventmix/sPHElectronPair.h"
68 #include "/gpfs/mnt/gpfs02/sphenix/user/lebedev/mdc/analysis/install/include/eventmix/sPHElectronPairv1.h"
69 #include "/gpfs/mnt/gpfs02/sphenix/user/lebedev/mdc/analysis/install/include/eventmix/sPHElectronPairContainer.h"
70 #include "/gpfs/mnt/gpfs02/sphenix/user/lebedev/mdc/analysis/install/include/eventmix/sPHElectronPairContainerv1.h"
113 std::cout <<
"sPHAnalysis::Init started..." << endl;
115 std::cout <<
"sPHAnalysis::Init: output file " <<
OutputFileName.c_str() <<
" opened." << endl;
117 ntppid =
new TNtuple(
"ntppid",
"",
"charge:pt:eta:mom:nmvtx:ntpc:chi2:ndf:cemc_ecore:cemc_e3x3:cemc_prob:cemc_chi2:cemc_dphi:cemc_deta:quality:dca2d:hcalin_e3x3:hcalout_e3x3:gdist:cemc-dphi_3x3:cemc_deta_3x3:hcalin_dphi:hcalin_deta:hcalout_dphi:hcalout_deta:hcalin_clusdphi:hcalin_clusdeta:hcalin_cluse:hcalout_clusdphi:hcalout_clusdeta:hcalout_cluse");
119 ntp1 =
new TNtuple(
"ntp1",
"",
"type:mass:pt:eta:pt1:pt2:e3x31:e3x32:emce1:emce2:p1:p2:chisq1:chisq2:dca2d1:dca2d2:dca3dxy1:dca3dxy2:dca3dz1:dcz3dz2:mult:rap:nmvtx1:nmvtx2:ntpc1:ntpc2");
121 ntpmc1 =
new TNtuple(
"ntpmc1",
"",
"charge:pt:eta");
122 ntpmc2 =
new TNtuple(
"ntpmc2",
"",
"type:mass:pt:eta:rap:pt1:pt2:eta1:eta2");
124 ntp2 =
new TNtuple(
"ntp2",
"",
"type:mass:pt:eta:rap:pt1:pt2:eta1:eta2:mult:emult:pmult:chisq1:chisq2:dca2d1:dca2d2:eop3x3_1:eop3x3_2:dretaphi:nmvtx1:nmvtx2:nintt1:nintt2:ntpc1:ntpc2:b");
126 ntpb =
new TNtuple(
"ntpb",
"",
"bimp:mult:truemult:cemcmult:evtno:evtno5:ginacc:ngood");
128 ntp_notracking =
new TNtuple(
"ntp_notracking",
"",
"mass:pt:pt1:pt2:hoe1:hoe2");
137 hmult =
new TH1D(
"hmult",
"",100,0.,2000.);
138 hmass =
new TH1D(
"hmass",
"",160,4.,12.);
139 hgmass =
new TH1D(
"hgmass",
"",160,4.,12.);
140 hgmass0 =
new TH1D(
"hgmass0",
"",160,4.,12.);
141 hgmass09 =
new TH1D(
"hgmass09",
"",160,4.,12.);
142 heop3x3 =
new TH1D(
"heop3x3",
"",180,0.,1.8);
143 heop5x5 =
new TH1D(
"heop5x5",
"",180,0.,1.8);
144 heop =
new TH1D(
"heop",
"",180,0.,1.8);
145 hdphi =
new TH1D(
"hdphi",
"",200,0.25,0.25);
146 hdeta =
new TH1D(
"hdeta",
"",200,0.25,0.25);
148 hdca2d =
new TH1D(
"hdca2d",
"",1000,-0.1,0.1);
149 hdca3dxy =
new TH1D(
"hdca3dxy",
"",1000,-0.1,0.1);
150 hdca3dz =
new TH1D(
"hdca3dz",
"",1000,-0.1,0.1);
151 hchi2 =
new TH1D(
"hchi2",
"",1000,0.,50.);
152 hndf =
new TH1D(
"hndf",
"",1000,0.,50.);
153 hquality =
new TH1D(
"hquality",
"",1000,0.,50.);
155 test =
new TH1D(
"test",
"",1000,0.,50.);
159 _rng =
new TRandom2();
164 std::cout <<
"sPHAnalysis::Init ended." << endl;
172 std::cout <<
"sPHAnalysis::InitRun started..." << std::endl;
173 std::cout <<
"sPHAnalysis::InitRun ended." << std::endl;
206 cout<<
"--------------------------- EventNumber = " <<
EventNumber-1 << endl;
209 PHHepMCGenEventMap *genevtmap = findNode::getClass<PHHepMCGenEventMap>(topNode,
"PHHepMCGenEventMap");
214 genevt = iter->second;
216 cout <<
"got PHHepMCGenEvent... " << genevt << endl;
219 HepMC::GenEvent *
event = genevt->getEvent();
221 int npart =
event->particles_size();
222 int nvert =
event->vertices_size();
223 cout <<
"Number of particles = " << npart <<
" " << nvert << endl;
239 double pt =
_rng->Uniform() * 10.;
240 double y = (
_rng->Uniform()*2.) - 1.;
241 double phi = (2.0 * M_PI) *
_rng->Uniform();
242 double mass = 9.3987;
243 double mt = sqrt(mass * mass + pt * pt);
244 double eta = asinh(sinh(y) * mt / pt);
246 vm.SetPtEtaPhiM(pt, eta, phi, mass);
250 double m1 = 0.000511;
251 double m2 = 0.000511;
254 double E1 = (mass * mass - m2 * m2 + m1 * m1) / (2.0 * mass);
255 double p1 = sqrt((mass * mass - (m1 + m2) * (m1 + m2)) * (mass * mass - (m1 - m2) * (m1 - m2))) / (2.0 *
mass);
256 double phi1 =
_rng->Uniform() * 2. * M_PI;
257 double th1 =
fsin->GetRandom();
258 double px1 = p1 * sin(th1) * cos(phi1);
259 double py1 = p1 * sin(th1) * sin(phi1);
260 double pz1 = p1 * cos(th1);
262 v1.SetPxPyPzE(px1, py1, pz1, E1);
265 double betax = vm.Px() / vm.E();
266 double betay = vm.Py() / vm.E();
267 double betaz = vm.Pz() / vm.E();
268 v1.Boost(betax, betay, betaz);
271 TLorentzVector
v2 = vm -
v1;
272 cout <<
"decay electrons: " << v1.Pt() <<
" " << v2.Pt() << endl;
274 HepMC::FourVector fv1 = HepMC::FourVector(v1.Px(),v1.Py(),v1.Pz());
275 HepMC::GenParticle gp1 = HepMC::GenParticle(fv1,-11);
276 HepMC::FourVector fv2 = HepMC::FourVector(v2.Px(),v2.Py(),v2.Pz());
277 HepMC::GenParticle gp2 = HepMC::GenParticle(fv2,11);
279 HepMC::GenEvent* newevent =
new HepMC::GenEvent(*
event);
281 for (HepMC::GenEvent::vertex_iterator
v = newevent->vertices_begin();
v != newevent->vertices_end(); ++
v)
283 int npin = (*v)->particles_in_size();
284 int npout = (*v)->particles_out_size();
285 HepMC::ThreeVector pnt = (*v)->point3d();
286 cout <<
"event vertex: " << npin <<
" " << npout <<
" " << pnt.x() <<
" " << pnt.y() <<
" " << pnt.z() << endl;
287 cout <<
"adding particle with id " << gp1.pdg_id() << endl;
288 (*v)->add_particle_out(&gp1);
289 cout <<
" after adding electron1: " << (*v)->particles_out_size() << endl;
290 (*v)->add_particle_out(&gp2);
291 cout <<
" after adding electron2: " << (*v)->particles_out_size() << endl;
300 cout <<
"inserted event " << tmpptr << endl;
302 cout <<
"procedd_event_hepmc() ended." << endl;
311 cout<<
"--------------------------- EventNumber = " <<
EventNumber-1 << endl;
315 cout << eePairs << endl;
316 if(!eePairs) { cout <<
"ERROR: ElectronPairs node not found!" << endl; }
317 else { cout <<
"Found ElectronPairs node." << endl; }
319 float mult = eePairs->
size();
320 cout <<
"Number of pairs = " << eePairs->
size() << endl;
331 double px1 = electron->
get_px();
332 double py1 = electron->
get_py();
333 double pz1 = electron->
get_pz();
334 double px2 = positron->
get_px();
335 double py2 = positron->
get_py();
336 double pz2 = positron->
get_pz();
337 tmp[4] = sqrt(px1*px1+py1*py1);
338 tmp[5] = sqrt(px2*px2+py2*py2);
343 tmp[10] = sqrt(px1*px1+py1*py1+pz1*pz1);
344 tmp[11] = sqrt(px2*px2+py2*py2+pz2*pz2);
345 double chisq1 = electron->
get_chi2();
347 if(ndf1!=0.) { chisq1 = chisq1/ndf1;}
else {chisq1 = 99999.;}
348 double chisq2 = positron->
get_chi2();
350 if(ndf2!=0.) { chisq2 = chisq2/ndf2;}
else {chisq2 = 99999.;}
370 cout <<
"process_event_pairs() ended." << endl;
381 PHHepMCGenEventMap *genevtmap = findNode::getClass<PHHepMCGenEventMap>(topNode,
"PHHepMCGenEventMap");
386 genevt = iter->second;
390 HepMC::GenEvent *
event = genevt->getEvent();
393 HepMC::HeavyIon* hi =
event->heavy_ion();
394 float impact_parameter = hi->impact_parameter();
397 tmp[0] = impact_parameter;
408 HepMC::GenParticle* parent = NULL;
411 for ( HepMC::GenVertex::particle_iterator mother = p->production_vertex()-> particles_begin(HepMC::ancestors);
412 mother != p->production_vertex()-> particles_end(HepMC::ancestors);
417 if(abs((*mother)->pdg_id()) == 553)
422 if(parent != NULL)
break;
437 PHHepMCGenEventMap *genevtmap = findNode::getClass<PHHepMCGenEventMap>(topNode,
"PHHepMCGenEventMap");
442 genevt = iter->second;
447 HepMC::GenEvent *
event = genevt->getEvent();
450 int npart =
event->particles_size();
451 int nvert =
event->vertices_size();
452 cout <<
"HepMC::GenEvent: Number of particles, vertuces = " << npart <<
" " << nvert << endl;
457 bool einacc2 =
false;
458 bool pinacc2 =
false;
467 HepMC::GenVertex* jpsidecay_vtx = NULL;
470 for (HepMC::GenEvent::particle_const_iterator
p =
event->particles_begin();
p !=
event->particles_end(); ++
p)
472 int pid = (*p)->pdg_id();
473 int status = (*p)->status();
474 double pt = ((*p)->momentum()).
perp();
475 double pz = ((*p)->momentum()).pz();
476 double mass = ((*p)->momentum()).
m();
477 double eta = ((*p)->momentum()).
eta();
478 double ee = ((*p)->momentum()).
e();
481 if(abs(pid)==553 && status==2) {
482 cout <<
"Upsilon: " << pid <<
" " << status <<
" " << pt <<
" " << mass <<
" " << eta << endl;
483 HepMC::GenVertex* upsvtx = (*p)->production_vertex();
484 cout <<
" Upsilon production Z vertex = " << upsvtx->point3d().z() << endl;
487 if(abs(pid)==443 && status==2) {
488 cout <<
"J/psi: " << pid <<
" " << status <<
" " << pt <<
" " << mass <<
" " << eta << endl;
489 jpsidecay_vtx = (*p)->end_vertex();
498 for (HepMC::GenEvent::particle_const_iterator
p =
event->particles_begin();
p !=
event->particles_end(); ++
p)
500 int pid = (*p)->pdg_id();
501 int status = (*p)->status();
502 double pt = ((*p)->momentum()).
perp();
504 double mass = ((*p)->momentum()).
m();
505 double eta = ((*p)->momentum()).
eta();
509 if(pid==-11 && status==1 && pt>0.0) {
513 HepMC::GenVertex* elevtx = (*p)->production_vertex();
514 if(elevtx == jpsidecay_vtx) {
515 cout <<
"electron from J/psi: " << pid <<
" " << status <<
" " << pt <<
" " << mass <<
" " << eta << endl;
516 if(fabs(eta)<1.0) einacc =
true;
517 if(fabs(eta)<1.0 && pt>2.0) einacc2 =
true;
522 if(pid==11 && status==1 && pt>0.0) {
523 HepMC::GenVertex* posvtx = (*p)->production_vertex();
524 if(posvtx == jpsidecay_vtx) {
525 cout <<
"positroni form J/psi: " << pid <<
" " << status <<
" " << pt <<
" " << mass <<
" " << eta << endl;
526 if(fabs(eta)<1.0) pinacc =
true;
527 if(fabs(eta)<1.0 && pt>2.0) pinacc2 =
true;
535 if(einacc && pinacc) { type = 1.; }
536 if(einacc2 && pinacc2) { type = 2.; }
562 cout<<
"--------------------------- EventNumber = " <<
EventNumber-1 << endl;
566 GlobalVertexMap *global_vtxmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
575 cout <<
"Global vertex Z = " << Zvtx << endl;
577 RawClusterContainer* cemc_clusters = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_CEMC");
579 cerr <<
PHWHERE <<
" ERROR: Can not find CLUSTER_CEMC node." << endl;
582 cout <<
" Number of CEMC clusters = " << cemc_clusters->
size() << endl;
584 RawTowerGeomContainer* _geomEM = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_CEMC");
585 if(!_geomEM) std::cerr<<
"No TOWERGEOM_CEMC"<<std::endl;
586 RawTowerGeomContainer* _geomIH = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_HCALIN");
587 if(!_geomIH) std::cerr<<
"No TOWERGEOM_HCALIN"<<std::endl;
588 RawTowerGeomContainer* _geomOH = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_HCALOUT");
589 if(!_geomIH) std::cerr<<
"No TOWERGEOM_HCALIN"<<std::endl;
591 RawTowerContainer* _towersRawEM = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_CEMC");
592 if (!_towersRawEM) std::cerr<<
"No TOWER_CALIB_CEMC Node"<<std::endl;
593 RawTowerContainer* _towersRawIH = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_HCALIN");
594 if (!_towersRawIH) std::cerr<<
"No TOWER_CALIB_HCALIN Node"<<std::endl;
595 RawTowerContainer* _towersRawOH = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_HCALOUT");
596 if (!_towersRawOH) std::cerr<<
"No TOWER_CALIB_HCALOUT Node"<<std::endl;
598 vector<TLorentzVector> electrons;
604 for (iter = begin_end.first; iter != begin_end.second; ++iter)
609 double cemc_ecore = cluster->
get_ecore();
610 if(cemc_ecore<2.0)
continue;
611 double cemc_x = cluster->
get_x();
612 double cemc_y = cluster->
get_y();
613 double cemc_z = cluster->
get_z() - Zvtx;
615 double cemc_r = sqrt(pow(cemc_x,2)+pow(cemc_y,2));
616 double cemc_rr = sqrt(pow(cemc_r,2)+pow(cemc_z,2));
617 double cemc_eta = asinh( cemc_z / cemc_r );
618 double cemc_phi = atan2( cemc_y, cemc_x );
619 double cemc_px = cemc_ecore * (cemc_x/cemc_rr);
620 double cemc_py = cemc_ecore * (cemc_y/cemc_rr);
621 double cemc_pz = cemc_ecore * (cemc_z/cemc_rr);
625 double distem = 99999.;
631 double cemc_tower_phi = tower_geom->
get_phi();
634 double cemc_tower_z = tower_geom->
get_center_z() - Zvtx;
635 double cemc_tower_r = sqrt(pow(cemc_tower_x,2)+pow(cemc_tower_y,2));
636 double cemc_tower_eta = asinh( cemc_tower_z / cemc_tower_r );
637 double tmpdist = sqrt(pow(cemc_eta-cemc_tower_eta,2)+pow(cemc_phi-cemc_tower_phi,2));
638 if(tmpdist<distem) { distem = tmpdist; thetowerem = tower; }
641 unsigned int ietaem = thetower_geom_em->
get_bineta();
642 unsigned int jphiem = thetower_geom_em->
get_binphi();
649 double distin = 99999.;
655 double hcalin_tower_phi = tower_geom->
get_phi();
658 double hcalin_tower_z = tower_geom->
get_center_z() - Zvtx;
659 double hcalin_tower_r = sqrt(pow(hcalin_tower_x,2)+pow(hcalin_tower_y,2));
660 double hcalin_tower_eta = asinh( hcalin_tower_z / hcalin_tower_r );
661 double tmpdist = sqrt(pow(cemc_eta-hcalin_tower_eta,2)+pow(cemc_phi-hcalin_tower_phi,2));
662 if(tmpdist<distin) { distin = tmpdist; thetowerin = tower; }
665 unsigned int ieta = thetower_geom->
get_bineta();
666 unsigned int jphi = thetower_geom->
get_binphi();
672 if(ieta<1 || ieta>22)
continue;
673 for(
unsigned int i=0;
i<=2;
i++) {
674 for(
unsigned int j=0;
j<=2;
j++) {
675 unsigned int itmp = ieta-1+
i;
676 unsigned int jtmp = 0;
677 if(jphi==0 &&
j==0) { jtmp = 63; }
678 else if(jphi==63 &&
j==2) { jtmp = 0; }
679 else { jtmp = jphi-1+
j; }
681 if(tmptower) { e3x3in += tmptower->
get_energy(); }
687 double distout = 99999.;
693 double hcalout_tower_phi = tower_geom->
get_phi();
696 double hcalout_tower_z = tower_geom->
get_center_z() - Zvtx;
697 double hcalout_tower_r = sqrt(pow(hcalout_tower_x,2)+pow(hcalout_tower_y,2));
698 double hcalout_tower_eta = asinh( hcalout_tower_z / hcalout_tower_r );
699 double tmpdist = sqrt(pow(cemc_eta-hcalout_tower_eta,2)+pow(cemc_phi-hcalout_tower_phi,2));
700 if(tmpdist<distout) { distout = tmpdist; thetowerout = tower; }
703 unsigned int ietaout = thetower_geomout->
get_bineta();
704 unsigned int jphiout = thetower_geomout->
get_binphi();
709 if(ietaout<1 || ietaout>22)
continue;
710 for(
unsigned int i=0;
i<=2;
i++) {
711 for(
unsigned int j=0;
j<=2;
j++) {
712 unsigned int itmp = ietaout-1+
i;
713 unsigned int jtmp = 0;
714 if(jphiout==0 &&
j==0) { jtmp = 63; }
715 else if(jphiout==63 &&
j==2) { jtmp = 0; }
716 else { jtmp = jphiout-1+
j; }
718 if(tmptower) { e3x3out += tmptower->
get_energy(); }
723 if(e3x3in/cemc_ecore>0.06)
continue;
725 TLorentzVector
tmp = TLorentzVector(cemc_px,cemc_py,cemc_pz,cemc_ecore);
726 electrons.push_back(tmp);
727 vhoe.push_back(e3x3in/cemc_ecore);
731 cout <<
"number of selected electrons = " << electrons.size() <<
" " << vhoe.size() << endl;
735 if(electrons.size()>=2) {
736 for(
long unsigned int i=0;
i<electrons.size()-1;
i++) {
737 for(
long unsigned int j=
i+1;
j<electrons.size();
j++) {
738 TLorentzVector pair = electrons[
i]+electrons[
j];
739 cout <<
i <<
" " <<
j << endl;
742 cout << pair.M() <<
" " << pair.Pt() << endl;
743 tmp1[2] = (electrons[
i]).
Pt();
744 tmp1[3] = (electrons[
j]).
Pt();
745 cout << vhoe[
i] <<
" " << vhoe[
j] << endl;
748 cout <<
"filling..." << endl;
750 cout <<
"done." << endl;
755 cout <<
"returning..." << endl;
765 double pathlength = 999.;
772 if(what==0) { pathlength = proj[proj.size()-3]; }
773 else if(what==1) { pathlength = proj[proj.size()-2]; }
774 else if(what==2) { pathlength = proj[proj.size()-1]; }
775 else { dphi = 9999.; deta = 9999.;
return e3x3;}
777 double track_eta = 999.;
778 double track_phi = 999.;
781 double track_x = trackstate->
get_x();
782 double track_y = trackstate->
get_y();
783 double track_z = trackstate->
get_z() - Zvtx;
784 double track_r = sqrt(track_x*track_x+track_y*track_y);
785 track_eta = asinh( track_z / track_r );
786 track_phi = atan2( track_y, track_x );
787 }
else { cout <<
"track state not found!" << endl; dphi = 9999.; deta = 9999.;
return e3x3; }
799 double tower_r = sqrt(pow(tower_x,2)+pow(tower_y,2));
800 double tower_eta = asinh( tower_z / tower_r );
801 double tower_phi = atan2( tower_y , tower_x );
802 double tmpdist = sqrt(pow(track_eta-tower_eta,2)+pow(track_phi-tower_phi,2));
803 if(tmpdist<dist) { dist = tmpdist; thetower = tower; deta = fabs(track_eta-tower_eta); dphi = fabs(track_phi-tower_phi); }
805 cout <<
"dist: " << dist <<
" " << deta <<
" " << dphi << endl;
807 if(!thetower) { dphi = 9999.; deta = 9999.;
return e3x3; }
809 unsigned int ieta = thetower_geom->
get_bineta();
810 unsigned int jphi = thetower_geom->
get_binphi();
812 unsigned int maxbinphi = 63;
if(what==0) maxbinphi = 255;
813 unsigned int maxbineta = 23;
if(what==0) maxbineta = 93;
815 for(
unsigned int i=0;
i<=2;
i++) {
816 for(
unsigned int j=0;
j<=2;
j++) {
817 unsigned int itmp = ieta-1+
i;
818 unsigned int jtmp = 0;
819 if(jphi==0 &&
j==0) { jtmp = maxbinphi; }
820 else if(jphi==maxbinphi &&
j==2) { jtmp = 0; }
821 else { jtmp = jphi-1+
j; }
822 if(itmp>=0 && itmp<=maxbineta) {
824 if(tmptower) { e3x3 += tmptower->
get_energy(); }
846 _trackmap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
848 cout <<
" Number of tracks = " << _trackmap->
size() << endl;
850 _trkrclusters = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
852 cout <<
" Number of TRKR clusters = " << _trkrclusters->
size() << endl;
854 _trackseedcontainer_svtx = findNode::getClass<TrackSeedContainer>(topNode,
"SvtxTrackSeedContainer");
857 _trackseedcontainer_silicon = findNode::getClass<TrackSeedContainer>(topNode,
"SiliconTrackSeedContainer");
860 _trackseedcontainer_tpc = findNode::getClass<TrackSeedContainer>(topNode,
"TpcTrackSeedContainer");
863 _cemc_clusters = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_CEMC");
865 cout <<
" Number of CEMC clusters = " << _cemc_clusters->
size() << endl;
877 int evtno5 = evtno%5;
882 cout<<
"--------------------------- EventNumber = " <<
EventNumber-1 << endl;
888 GlobalVertexMap *global_vtxmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
897 cout <<
"Global BBC vertex Z = " << Zvtx << endl;
900 float impact_parameter = 999.;
983 SvtxTrackMap *trackmap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
985 cerr <<
PHWHERE <<
" ERROR: Can not find SvtxTrackMap node." << endl;
988 cout <<
" Number of tracks = " << trackmap->
size() << endl;
989 double mult = trackmap->
size();
992 RawClusterContainer* cemc_clusters = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_CEMC");
994 cerr <<
PHWHERE <<
" ERROR: Can not find CLUSTER_CEMC node." << endl;
997 cout <<
" Number of CEMC clusters = " << cemc_clusters->
size() << endl;
998 int cemcmult = cemc_clusters->
size();
1000 RawClusterContainer* hcalin_clusters = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_HCALIN");
1001 if(!hcalin_clusters) {
1002 cerr <<
PHWHERE <<
" ERROR: Can not find CLUSTER_HCALIN node." << endl;
1005 RawClusterContainer* hcalout_clusters = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_HCALOUT");
1006 if(!hcalout_clusters) {
1007 cerr <<
PHWHERE <<
" ERROR: Can not find CLUSTER_HCALOUT node." << endl;
1011 RawTowerGeomContainer* _geomEM = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_CEMC");
1012 if(!_geomEM) std::cerr<<
"No TOWERGEOM_CEMC"<<std::endl;
1013 RawTowerGeomContainer* _geomIH = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_HCALIN");
1014 if(!_geomIH) std::cerr<<
"No TOWERGEOM_HCALIN"<<std::endl;
1015 RawTowerGeomContainer* _geomOH = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_HCALOUT");
1016 if(!_geomOH) std::cerr<<
"No TOWERGEOM_HCALIN"<<std::endl;
1018 RawTowerContainer* _towersEM = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_CEMC");
1019 if (!_towersEM) std::cerr<<
"No TOWER_CALIB_CEMC Node"<<std::endl;
1020 RawTowerContainer* _towersIH = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_HCALIN");
1021 if (!_towersIH) std::cerr<<
"No TOWER_CALIB_HCALIN Node"<<std::endl;
1022 RawTowerContainer* _towersOH = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_HCALOUT");
1023 if (!_towersOH) std::cerr<<
"No TOWER_CALIB_HCALOUT Node"<<std::endl;
1050 cout <<
"starting loop over tracks..." << endl;
1054 if(!track) { cout <<
"ERROR: bad track pointer = " << track << endl;
continue; }
1057 double px = track->
get_px();
1058 double py = track->
get_py();
1059 double pz = track->
get_pz();
1060 double pt = sqrt(px * px + py * py);
1061 double mom = sqrt(px * px + py * py + pz * pz);
1065 double ndf = track->
get_ndf();
1067 if(ndf!=0.) chi2 = chisq/ndf;
1069 if(pt>0.5 && chi2<5.) { ngood++; }
1070 if(pt<2.0)
continue;
1076 double cemc_ecore = 0.;
1077 double cemc_prob = 0.;
1078 double cemc_chi2 = 0.;
1085 double cemc_deta2 = 9999.;
1086 double cemc_dphi2 = 9999.;
1087 double cemc_e3x3 =
Get_CAL_e3x3(track, _towersEM, _geomEM, 0, Zvtx, cemc_dphi2, cemc_deta2);
1088 double hcalin_deta = 9999.;
1089 double hcalin_dphi = 9999.;
1090 double hcalin_e3x3 =
Get_CAL_e3x3(track, _towersIH, _geomIH, 1, Zvtx, hcalin_dphi, hcalin_deta);
1091 double hcalout_deta = 9999.;
1092 double hcalout_dphi = 9999.;
1093 double hcalout_e3x3 =
Get_CAL_e3x3(track, _towersOH, _geomOH, 2, Zvtx, hcalout_dphi, hcalout_deta);
1095 double hcalin_clusdphi = 9999.;
1096 double hcalin_clusdeta = 9999.;
1097 double hcalout_clusdphi = 9999.;
1098 double hcalout_clusdeta = 9999.;
1101 double hcalin_cluse = clus_hcalin->
get_energy();
1102 double hcalout_cluse = clus_hcalout->
get_energy();
1104 cout <<
"track: " << charge <<
" " << pt <<
" " << cemc_ecore <<
" " << cemc_e3x3 <<
" " << hcalin_e3x3 <<
" " << hcalout_e3x3 << endl;
1107 int nmvtx = 0;
int nintt = 0;
int ntpc = 0;
1110 for (
auto iter = siseed->begin_cluster_keys(); iter != siseed->end_cluster_keys(); ++iter) {
1122 for (
auto iter = tpcseed->begin_cluster_keys(); iter != tpcseed->end_cluster_keys(); ++iter) {
1128 cout <<
" ntpc, nmvtx, nitt= " << ntpc <<
" " << nmvtx <<
" " << nintt << endl;
1143 double gdist = 999.;
1163 tmp1[8] = cemc_ecore;
1164 tmp1[9] = cemc_e3x3;
1165 tmp1[10] = cemc_prob;
1166 tmp1[11] = cemc_chi2;
1170 tmp1[15] = dca3d_xy;
1171 tmp1[16] = hcalin_e3x3;
1172 tmp1[17] = hcalout_e3x3;
1174 tmp1[19] = cemc_dphi2;
1175 tmp1[20] = cemc_dphi2;
1176 tmp1[21] = hcalin_dphi;
1177 tmp1[22] = hcalin_deta;
1178 tmp1[23] = hcalout_deta;
1179 tmp1[24] = hcalout_deta;
1180 tmp1[25] = hcalin_clusdphi;
1181 tmp1[26] = hcalin_clusdeta;
1182 tmp1[27] = hcalin_cluse;
1183 tmp1[28] = hcalout_clusdphi;
1184 tmp1[29] = hcalout_clusdeta;
1185 tmp1[30] = hcalout_cluse;
1191 tmpb[0] = impact_parameter;
1195 tmpb[4] = float(evtno);
1196 tmpb[5] = float(evtno5);
1197 tmpb[6] = float(ginacc);
1198 tmpb[7] = float(ngood);
1210 TVector3 projection;
1212 vector<double>
proj;
1218 double pathlength = proj[proj.size()+4-what];
1222 double track_x = trackstate->
get_x();
1223 double track_y = trackstate->
get_y();
1224 double track_z = trackstate->
get_z();
1225 projection.SetX(track_x);
1226 projection.SetY(track_y);
1227 projection.SetZ(track_z);
1238 double track_eta = 99999.;
1239 double track_phi = 99999.;
1243 vector<double>
proj;
1249 double pathlength = 0.;
1251 pathlength = proj[proj.size()-3];
1252 }
else if(what==2) {
1253 pathlength = proj[proj.size()-2];
1254 }
else if(what==3) {
1255 pathlength = proj[proj.size()-1];
1256 }
else {
return returnCluster; }
1260 double track_x = trackstate->
get_x();
1261 double track_y = trackstate->
get_y();
1262 double track_z = trackstate->
get_z() - Zvtx;
1263 double track_r = sqrt(track_x*track_x+track_y*track_y);
1264 track_eta = asinh( track_z / track_r );
1265 track_phi = atan2( track_y, track_x );
1266 }
else {
return returnCluster; }
1268 if(track_eta == 99999. || track_phi == 99999.) {
return returnCluster; }
1269 double dist = 99999.;
1273 for (iter = begin_end.first; iter != begin_end.second; ++iter)
1276 if(!cluster)
continue;
1278 double cemc_ecore = cluster->
get_ecore();
1279 if(cemc_ecore<0.0)
continue;
1280 double cemc_x = cluster->
get_x();
1281 double cemc_y = cluster->
get_y();
1282 double cemc_z = cluster->
get_z() - Zvtx;
1283 double cemc_r = cluster->
get_r();
1284 double cemc_eta = asinh( cemc_z / cemc_r );
1285 double cemc_phi = atan2( cemc_y, cemc_x );
1286 double tmpdist = sqrt(pow((cemc_eta-track_eta),2)+pow((cemc_phi-track_phi),2));
1288 dist = tmpdist; returnCluster = cluster; dphi = fabs(cemc_phi-track_phi); deta = fabs(cemc_eta-track_eta);
1293 return returnCluster;
1303 cout<<
"--------------------------- EventNumber = " <<
EventNumber-1 << endl;
1308 SvtxTrackMap *trackmap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
1310 cerr <<
PHWHERE <<
" ERROR: Can not find SvtxTrackMap node." << endl;
1313 cout <<
" Number of tracks = " << trackmap->
size() << endl;
1315 SvtxVertexMap *vtxmap = findNode::getClass<SvtxVertexMap>(topNode,
"SvtxVertexMap");
1317 cout <<
"SvtxVertexMap node not found!" << endl;
1320 cout <<
"Number of SvtxVertexMap entries = " << vtxmap->
size() << endl;
1323 GlobalVertexMap *global_vtxmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
1324 if(!global_vtxmap) {
1325 cerr <<
PHWHERE <<
" ERROR: Can not find GlobalVertexMap node." << endl;
1330 cout <<
"Global BBC vertex Z = " << Zvtx << endl;
1332 RawClusterContainer* cemc_clusters = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_CEMC");
1333 if(!cemc_clusters) {
1334 cerr <<
PHWHERE <<
" ERROR: Can not find CLUSTER_CEMC node." << endl;
1337 else { cout <<
"FOUND CLUSTER_CEMC node." << endl; }
1339 vector<TLorentzVector> electrons;
1340 vector<TLorentzVector> positrons;
1341 vector<double> vpchi2;
1342 vector<double> vmchi2;
1343 vector<double> vpdca;
1344 vector<double> vmdca;
1345 vector<double> vpeop3x3;
1346 vector<double> vmeop3x3;
1347 vector<int> vpnmvtx;
1348 vector<int> vpnintt;
1350 vector<int> vmnmvtx;
1351 vector<int> vmnintt;
1358 cout <<
"ERROR: bad track pointer = " << track << endl;
1363 double px = track->
get_px();
1364 double py = track->
get_py();
1365 double pz = track->
get_pz();
1366 double pt = sqrt(px * px + py * py);
1367 double mom = sqrt(pt*pt+pz*pz);
1368 double ee = sqrt(mom*mom+0.000511*0.000511);
1370 if(pt<2.0)
continue;
1374 double ndf = track->
get_ndf();
1376 double dca3d_xy = track->
get_dca3d_xy();
if(ndf!=0.) chi2 = chisq/ndf;
1381 double cemc_ecore = 0.;
1382 if(clus) cemc_ecore = clus->
get_ecore();
1383 if(cemc_ecore/mom<0.7)
continue;
1384 double trk_x = track->
get_x();
1385 double trk_y = track->
get_y();
1386 double trk_z = track->
get_z();
1387 cout <<
"track: " << charge <<
" " << pt <<
" " << cemc_ecore/mom <<
" " << trk_x <<
" " << trk_y <<
" " << trk_z << endl;
1389 int nmvtx = 0;
int nintt = 0;
int ntpc = 0;
1391 for (
auto iter = siseed->begin_cluster_keys(); iter != siseed->end_cluster_keys(); ++iter) {
1401 for (
auto iter = tpcseed->begin_cluster_keys(); iter != tpcseed->end_cluster_keys(); ++iter) {
1407 if(charge<0) std::cout <<
"electron: " << pt <<
" " << eta <<
" " << nmvtx <<
" " << ntpc <<
" " << charge <<
" " << cemc_ecore << std::endl;
1408 if(charge>0) std::cout <<
"positron: " << pt <<
" " << eta <<
" " << nmvtx <<
" " << ntpc <<
" " << charge <<
" " << cemc_ecore << std::endl;
1409 TLorentzVector
tmp = TLorentzVector(px,py,pz,ee);
1411 positrons.push_back(tmp);
1412 vpeop3x3.push_back(cemc_ecore); vpchi2.push_back(chi2); vpdca.push_back(dca3d_xy);
1413 vpnmvtx.push_back(nmvtx); vpnintt.push_back(nintt); vpntpc.push_back(ntpc);
1416 electrons.push_back(tmp);
1417 vmeop3x3.push_back(cemc_ecore); vmchi2.push_back(chi2); vmdca.push_back(dca3d_xy);
1418 vmnmvtx.push_back(nmvtx); vmnintt.push_back(nintt); vmntpc.push_back(ntpc);
1423 double emult = electrons.size();
1424 double pmult = positrons.size();
1429 for(
long unsigned int i=0;
i<electrons.size();
i++) {
1430 for(
long unsigned int j=0;
j<positrons.size();
j++) {
1431 TLorentzVector pair = electrons[
i]+positrons[
j];
1432 double mass = pair.M();
1434 cout <<
"Upsilon mass = " << pair.M() << endl;
1438 tmp1[2] = pair.Pt();
1439 tmp1[3] = pair.Eta();
1440 tmp1[4] = pair.Rapidity();
1441 tmp1[5] = positrons[
j].Pt();
1442 tmp1[6] = electrons[
i].Pt();
1443 tmp1[7] = positrons[
j].Eta();
1444 tmp1[8] = electrons[
i].Eta();
1445 tmp1[9] = trackmap->
size();
1448 tmp1[12] = vpchi2[
j];
1449 tmp1[13] = vmchi2[
i];
1450 tmp1[14] = vpdca[
j];
1451 tmp1[15] = vmdca[
i];
1452 tmp1[16] = vpeop3x3[
j];
1453 tmp1[17] = vmeop3x3[
i];
1454 tmp1[18] = electrons[
i].DrEtaPhi(positrons[
j]);
1455 tmp1[19] = vpnmvtx[
j];
1456 tmp1[20] = vmnmvtx[
i];
1457 tmp1[21] = vpnintt[
j];
1458 tmp1[22] = vmnintt[
i];
1459 tmp1[23] = vpntpc[
j];
1460 tmp1[24] = vmntpc[
i];
1465 if(electrons.size()>1) {
1466 for(
long unsigned int i=0;
i<electrons.size()-1;
i++) {
1467 for(
long unsigned int j=
i+1;
j<electrons.size();
j++) {
1468 TLorentzVector pair = electrons[
i]+electrons[
j];
1469 double mass = pair.M();
1474 tmp1[2] = pair.Pt();
1475 tmp1[3] = pair.Eta();
1476 tmp1[4] = pair.Rapidity();
1477 tmp1[5] = electrons[
j].Pt();
1478 tmp1[6] = electrons[
i].Pt();
1479 tmp1[7] = electrons[
j].Eta();
1480 tmp1[8] = electrons[
i].Eta();
1481 tmp1[9] = trackmap->
size();
1484 tmp1[12] = vmchi2[
j];
1485 tmp1[13] = vmchi2[
i];
1486 tmp1[14] = vmdca[
j];
1487 tmp1[15] = vmdca[
i];
1488 tmp1[16] = vmeop3x3[
j];
1489 tmp1[17] = vmeop3x3[
i];
1490 tmp1[18] = electrons[
i].DrEtaPhi(electrons[
j]);
1491 tmp1[19] = vmnmvtx[
j];
1492 tmp1[20] = vmnmvtx[
i];
1493 tmp1[21] = vmnintt[
j];
1494 tmp1[22] = vmnintt[
i];
1495 tmp1[23] = vmntpc[
j];
1496 tmp1[24] = vmntpc[
i];
1501 if(positrons.size()>1) {
1502 for(
long unsigned int i=0;
i<positrons.size()-1;
i++) {
1503 for(
long unsigned int j=
i+1;
j<positrons.size();
j++) {
1504 TLorentzVector pair = positrons[
i]+positrons[
j];
1505 double mass = pair.M();
1510 tmp1[2] = pair.Pt();
1511 tmp1[3] = pair.Eta();
1512 tmp1[4] = pair.Rapidity();
1513 tmp1[5] = positrons[
j].Pt();
1514 tmp1[6] = positrons[
i].Pt();
1515 tmp1[7] = positrons[
j].Eta();
1516 tmp1[8] = positrons[
i].Eta();
1517 tmp1[9] = trackmap->
size();
1520 tmp1[12] = vpchi2[
j];
1521 tmp1[13] = vpchi2[
i];
1522 tmp1[14] = vpdca[
j];
1523 tmp1[15] = vpdca[
i];
1524 tmp1[16] = vpeop3x3[
j];
1525 tmp1[17] = vpeop3x3[
i];
1526 tmp1[18] = positrons[
i].DrEtaPhi(positrons[
j]);
1527 tmp1[19] = vpnmvtx[
j];
1528 tmp1[20] = vpnmvtx[
i];
1529 tmp1[21] = vpnintt[
j];
1530 tmp1[22] = vpnintt[
i];
1531 tmp1[23] = vpntpc[
j];
1532 tmp1[24] = vpntpc[
i];
1544 double px = trk->
get_px();
1545 double py = trk->
get_py();
1546 double pz = trk->
get_pz();
1547 double pt = sqrt(px*px+py*py);
1548 double pp = sqrt(pt*pt+pz*pz);
1551 if(pp==0.)
return false;
1553 if(pt<0.1)
return false;
1555 if(isnan(e3x3))
return false;
1557 if(e3x3/pp<0.1)
return false;
1565 std::cout <<
"sPHAnalysis::End() started, Number of processed events = " <<
EventNumber << endl;
1567 std::cout <<
"Writing out..." << endl;
1569 std::cout <<
"Closing output file..." << endl;