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