CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
Pi0RecAlg.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/SmartDataPtr.h"
3
11const double xmpi0 = 0.13497;
12
13//*******************************************************************************************
14Pi0RecAlg::Pi0RecAlg(const std::string& name, ISvcLocator* pSvcLocator) :
15 Algorithm(name, pSvcLocator)
16{
17 //Declare the properties
18 declareProperty("EMinOfBarrel", _pi0_cut.MinEnergyOfBarrelPhoton = 0.025);
19 declareProperty("EMinOfEndcap", _pi0_cut.MinEnergyOfEndcapPhoton = 0.045);
20 declareProperty("Angle", _pi0_cut.MinAngle = 20);
21 declareProperty("TimeLimit", _pi0_cut.TimeLimit = 20);
22
23 declareProperty("Pi0MinMass", _pi0_cut.MinMass = 0.10);
24 declareProperty("Pi0MaxMass", _pi0_cut.MaxMass = 0.18);
25 declareProperty("ChisqCut", _pi0_cut.Chisq = 50.0);
26}
27
28//******************************************************************************************
30
31 MsgStream log(msgSvc(), name());
32 log << MSG::INFO << "in initialize()" <<endreq;
33
34 return StatusCode::SUCCESS;
35}
36
37
38//*********************************************************************************************
39StatusCode Pi0RecAlg::execute() {
40
41 MsgStream log(msgSvc(), name());
42 log << MSG::INFO << "in execute()" <<endreq;
43
44 // get event header, eventlist and tracklist from TDS
45 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
46 SmartDataPtr<EvtRecEvent> recEvt(eventSvc(), EventModel::EvtRec::EvtRecEvent);
47 SmartDataPtr<EvtRecTrackCol> recTrkCol(eventSvc(), EventModel::EvtRec::EvtRecTrackCol);
48
49 bool save2TDS = false;
50 SmartDataPtr<EvtRecPi0Col> recPi0Col(eventSvc(), EventModel::EvtRec::EvtRecPi0Col);
51 if ( !recPi0Col ) {
52 recPi0Col = new EvtRecPi0Col;
53 save2TDS = true;
54 }
55 using namespace Pi0;
56 // std::cout<<"**********************************************"<<std::endl;
57 static Criteria cri_inv(_pi0_cut.MinMass, _pi0_cut.MaxMass);
58
59 //static KFitCriteria cri_kfit;
60
61 UserPi0Cut::SetForTrack(recEvt, recTrkCol);
62
63// Pi0::make_gamma_list(recEvt, recTrkCol);
64 Pi0::make_gamma_list(_pi0_cut);
66 // Pi0::print_gamma_list(Pi0::GetDefaultGammaList());
67 Pi0::apply_criteria(cri_inv);
69 // Pi0::print_pi0_list(Pi0::GetCandidatePi0List());
71 // std::cout<<"**********************************************"<<std::endl;
72 if ( save2TDS ) {
73 StatusCode sc = eventSvc()->registerObject(EventModel::EvtRec::EvtRecPi0Col, recPi0Col);
74 if ( sc.isFailure() ) {
75 log << MSG::ERROR << "could not register EvtRecPi0Col in TDS" <<endreq;
76 return StatusCode::FAILURE;
77 }
78 }
79 return StatusCode::SUCCESS;
80}
81
82
83//********************************************************************************************
84StatusCode Pi0RecAlg::finalize() {
85
86 MsgStream log(msgSvc(), name());
87 log << MSG::INFO << "in finalize()" << endreq;
88
89 return StatusCode::SUCCESS;
90}
91
92HepLorentzVector Pi0RecAlg::getP4(RecEmcShower* gTrk) {
93
94 double eraw = gTrk->energy();
95 double phi = gTrk->phi();
96 double the = gTrk->theta();
97
98 return HepLorentzVector( eraw * sin(the) * cos(phi),
99 eraw * sin(the) * sin(phi),
100 eraw * cos(the),
101 eraw );
102}
103
104// KinematicFit * kmfit = KinematicFit::instance();
105
106//
107// Set up the pi0's list
108//
109/* for(int i1 = recEvt->totalCharged(); i1 < (recEvt->totalTracks()-1); i1++) {
110 EvtRecTrack* g1Trk = *(recTrkCol->begin() + i1);
111 if ( !g1Trk->isPhoton() ) continue;
112 RecEmcShower* g1Shower = g1Trk->emcShower();
113 HepLorentzVector g1P4 = getP4(g1Shower);
114
115 for(int i2 = i1+1; i2 < recEvt->totalTracks(); i2++) {
116 EvtRecTrack* g2Trk = *(recTrkCol->begin() + i2);
117 if ( !g2Trk->isPhoton() ) continue;
118 RecEmcShower* g2Shower = g2Trk->emcShower();
119 HepLorentzVector g2P4 = getP4(g2Shower);
120
121 HepLorentzVector p2g = g1P4 + g2P4;
122 if ( p2g.m() < m_minmass_cut ) continue;
123 if ( p2g.m() > m_maxmass_cut ) continue;
124
125 kmfit->init();
126 kmfit->setIterNumber(1);
127 kmfit->AddTrack(0, 0.0, g1Shower);
128 kmfit->AddTrack(1, 0.0, g2Shower);
129 kmfit->AddResonance(0, xmpi0, 0, 1);
130 if ( !kmfit->Fit(0) ) continue;
131 kmfit->BuildVirtualParticle(0);
132 if ( kmfit->chisq(0) > m_chisq_cut ) continue;
133
134 double e1 = (kmfit->pfit(0)).e();
135 double e2 = (kmfit->pfit(1)).e();
136 HepLorentzVector ppi0 = kmfit->pfit(0) + kmfit->pfit(1);
137 double f = (e1-e2)/ppi0.rho();
138 if ( fabs(f) > m_costheta_cut ) continue;
139
140 EvtRecPi0* recPi0 = new EvtRecPi0();
141 recPi0->setRawMass(p2g.restMass());
142 recPi0->setChisq(kmfit->chisq(0));
143 recPi0->setFcos(f);
144 if ( g1P4.e() >= g2P4.e() ) {
145 recPi0->setHiPfit(kmfit->pfit(0));
146 recPi0->setLoPfit(kmfit->pfit(1));
147 recPi0->setHiEnGamma(g1Trk);
148 recPi0->setLoEnGamma(g2Trk);
149 }
150 else {
151 recPi0->setHiPfit(kmfit->pfit(1));
152 recPi0->setLoPfit(kmfit->pfit(0));
153 recPi0->setHiEnGamma(g2Trk);
154 recPi0->setLoEnGamma(g1Trk);
155 }
156
157 recPi0Col->push_back(recPi0);
158 }
159 }*/
160
161// std::cout<<"**********************************************"<<std::endl;
162/* std::cout<<"A(";
163 for(int i1 = 0; i1 < (recEvt->totalTracks()); i1++)
164 {
165 EvtRecTrack* g1Trk = *(recTrkCol->begin() + i1);
166 std::cout<<g1Trk->trackId()<<", ";
167 }
168 std::cout<<")"<<std::endl;
169 std::cout<<"N(";
170 for(int i1 = recEvt->totalCharged(); i1 < (recEvt->totalTracks()); i1++)
171 {
172 EvtRecTrack* g1Trk = *(recTrkCol->begin() + i1);
173 std::cout<<g1Trk->trackId()<<", ";
174 }
175 std::cout<<")"<<std::endl;
176 std::cout<<"C(";
177 for(int i1 = 0; i1 < recEvt->totalCharged(); i1++)
178 {
179 EvtRecTrack* g1Trk = *(recTrkCol->begin() + i1);
180 std::cout<<g1Trk->trackId()<<", ";
181 }
182 std::cout<<")"<<std::endl;*/
double sin(const BesAngle a)
Definition BesAngle.h:210
double cos(const BesAngle a)
Definition BesAngle.h:213
ObjectVector< EvtRecPi0 > EvtRecPi0Col
Definition EvtRecPi0.h:58
const double xmpi0
Definition Pi0RecAlg.cxx:11
IMessageSvc * msgSvc()
double theta() const
double phi() const
double energy() const
StatusCode execute()
Definition Pi0RecAlg.cxx:39
Pi0RecAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition Pi0RecAlg.cxx:14
StatusCode finalize()
Definition Pi0RecAlg.cxx:84
StatusCode initialize()
Definition Pi0RecAlg.cxx:29
_EXTERN_ std::string EvtRecPi0Col
Definition EventModel.h:141
_EXTERN_ std::string EvtRecEvent
Definition EventModel.h:134
_EXTERN_ std::string EvtRecTrackCol
Definition EventModel.h:135
Pi0List & make_pi0_list(const GammaList &gamma_list)
GammaList & make_gamma_list(UserPi0Cut &cut)
void Pi0ListToTDS(const Pi0List &pi0list, EvtRecPi0Col *recPi0Col)
GammaList & GetDefaultGammaList()
Pi0List & GetCandidatePi0List()
Pi0List & apply_criteria(const Criteria &cri)
double MinAngle
Definition Pi0Cut.h:26
double MinEnergyOfEndcapPhoton
Definition Pi0Cut.h:25
double MinMass
Definition Pi0Cut.h:28
double MaxMass
Definition Pi0Cut.h:29
double TimeLimit
Definition Pi0Cut.h:27
double MinEnergyOfBarrelPhoton
Definition Pi0Cut.h:24
static void SetForTrack(EvtRecEvent *_recEvt, EvtRecTrackCol *_recTrkCol)
Definition Pi0Cut.h:90
double Chisq
Definition Pi0Cut.h:30