BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
Pi0EtaToGGRecAlg.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/SmartDataPtr.h"
3
10
12
13const double xmpi0 = 0.134976; // BOSS 6.4.1 pdt.table value
14const double xmeta = 0.54784; // PDG08 = 0.547853, BOSS 6.4.1 pdt.table = 0.54784
15
16//*************************************************************************************
17Pi0EtaToGGRecAlg::Pi0EtaToGGRecAlg(const std::string& name, ISvcLocator* pSvcLocator) :
18 Algorithm(name, pSvcLocator)
19{
20 //Declare the properties
21
22 declareProperty("RejectBothInEndcap", m_rejectEndEnd = false);
23
24 /// pi0 properties
25 declareProperty("Pi0MinMass", m_pi0minmass_cut = 0.08);
26 declareProperty("Pi0MaxMass", m_pi0maxmass_cut = 0.18);
27 declareProperty("Pi0ChisqCut", m_pi0chisq_cut = 2500);
28
29 /// eta properties
30 declareProperty("EtaMinMass", m_etaminmass_cut = 0.4);
31 declareProperty("EtaMaxMass", m_etamaxmass_cut = 0.7);
32 declareProperty("EtaChisqCut", m_etachisq_cut = 2500);
33
34
35 /// Individual photons properties
36 declareProperty("PhotonMinEnergy", m_minEnergy = 0.025);
37
38 declareProperty("PhotonInBarrelOrEndcap", m_useBarrelEndcap = true);
39 declareProperty("PhotonMaxCosThetaBarrel", m_maxCosThetaBarrel = 0.8);
40 declareProperty("PhotonMinCosThetaEndcap", m_minCosThetaEndcap = 0.84);
41 declareProperty("PhotonMaxCosThetaEndcap", m_maxCosThetaEndcap = 0.92);
42 declareProperty("PhotonMinEndcapEnergy", m_minEndcapEnergy = 0.050);
43
44 declareProperty("PhotonApplyTimeCut", m_applyTimeCut = true);
45 declareProperty("PhotonMinTime", m_minTime = 0.);
46 declareProperty("PhotonMaxTime", m_maxTime = 14.);
47 declareProperty("PhotonDeltaTime", m_deltaTime = 10.);
48
49 declareProperty("PhotonApplyDangCut", m_applyDangCut = false);
50 declareProperty("PhotonMinDang", m_minDang = 20.0);
51
52 /// Limits for number of photons, pi0s and etas
53 declareProperty("MaxNGoodPhoton", m_maxNGoodPhoton = 50);
54 declareProperty("MaxNPi0", m_maxNPi0 = 100);
55 //declareProperty("MaxNEta", m_maxNEta = 100);
56}
57
58//******************************************************************************************
60
61 MsgStream log(msgSvc(), name());
62 log << MSG::INFO << "in initialize()" <<endreq;
63
64 return StatusCode::SUCCESS;
65}
66
67
68//*********************************************************************************************
69StatusCode Pi0EtaToGGRecAlg::execute() {
70
71 MsgStream log(msgSvc(), name());
72 log << MSG::INFO << "in execute()" <<endreq;
73
74 // get event header, eventlist and tracklist from TDS
75 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
76 SmartDataPtr<EvtRecEvent> recEvt(eventSvc(), EventModel::EvtRec::EvtRecEvent);
77 SmartDataPtr<EvtRecTrackCol> recTrkCol(eventSvc(), EventModel::EvtRec::EvtRecTrackCol);
78
79 SmartDataPtr<EvtRecPi0Col> recPi0Col(eventSvc(), EventModel::EvtRec::EvtRecPi0Col);
80 if ( !recPi0Col ) {
81 recPi0Col = new EvtRecPi0Col;
82 StatusCode sc = eventSvc()->registerObject(EventModel::EvtRec::EvtRecPi0Col, recPi0Col);
83 if ( sc.isFailure() ) {
84 log << MSG::ERROR << "could not register EvtRecPi0Col in TDS" <<endreq;
85 return StatusCode::FAILURE;
86 }
87 }
88
89 SmartDataPtr<EvtRecEtaToGGCol> recEtaToGGCol(eventSvc(), EventModel::EvtRec::EvtRecEtaToGGCol);
90 if ( !recEtaToGGCol ) {
91 recEtaToGGCol = new EvtRecEtaToGGCol;
92 StatusCode sc = eventSvc()->registerObject(EventModel::EvtRec::EvtRecEtaToGGCol, recEtaToGGCol);
93 if ( sc.isFailure() ) {
94 log << MSG::ERROR << "could not register EvtRecEtaToGGCol in TDS" <<endreq;
95 return StatusCode::FAILURE;
96 }
97 }
98
99 // select good photons
100 std::vector<EvtRecTrack*> vGoodPhotons;
101 for ( int i = recEvt->totalCharged(); i < recEvt->totalTracks(); i++ ) {
102 EvtRecTrack* gTrk = *(recTrkCol->begin() + i);
103 if ( !validPhoton(gTrk,recEvt,recTrkCol) ) continue;
104 vGoodPhotons.push_back(gTrk);
105 }
106
107 int nGoodPhoton = vGoodPhotons.size();
108 if ( nGoodPhoton > m_maxNGoodPhoton ) return StatusCode::SUCCESS;
109
110 /// Needed for 1C mass fits for pi0 and eta
112
113 //
114 // Form two-photon combinations
115 //
116 for(int i1 = 0; i1 < (nGoodPhoton-1); i1++) {
117 EvtRecTrack* g1Trk = vGoodPhotons[i1];
118 RecEmcShower* g1Shower = g1Trk->emcShower();
119 HepLorentzVector g1P4 = getP4(g1Shower);
120
121 for(int i2 = i1+1; i2 < nGoodPhoton; i2++) {
122 EvtRecTrack* g2Trk = vGoodPhotons[i2];
123 RecEmcShower* g2Shower = g2Trk->emcShower();
124 HepLorentzVector g2P4 = getP4(g2Shower);
125
126 HepLorentzVector p2g = g1P4 + g2P4;
127
128 /// If RejectBothInEndcap=true, reject candidate if both photons are in endcaps
129 if(m_rejectEndEnd&&bothInEndcap(g1P4,g2P4)) continue;
130
131 /// Select pi0 candidates
132 if ((p2g.m() > m_pi0minmass_cut) && (p2g.m() < m_pi0maxmass_cut ))
133 {
134
135 /// Perform pi0 1C KinematicFit
136 kmfit->init();
137 kmfit->setIterNumber(5);
138 kmfit->AddTrack(0, 0.0, g1Shower);
139 kmfit->AddTrack(1, 0.0, g2Shower);
140 kmfit->AddResonance(0, xmpi0, 0, 1);
141
142 kmfit->Fit(0); // Perform fit
143 kmfit->BuildVirtualParticle(0);
144
145 double pi0_chisq = kmfit->chisq(0);
146 if ( pi0_chisq >= m_pi0chisq_cut ) continue;
147
148
149 /// Fill EvtRecPi0
150 EvtRecPi0* recPi0 = new EvtRecPi0();
151 recPi0->setUnconMass(p2g.restMass());
152 recPi0->setChisq(pi0_chisq);
153
154 if ( g1P4.e() >= g2P4.e() ) {
155 recPi0->setHiPfit(kmfit->pfit(0));
156 recPi0->setLoPfit(kmfit->pfit(1));
157 recPi0->setHiEnGamma(g1Trk);
158 recPi0->setLoEnGamma(g2Trk);
159 }
160 else {
161 recPi0->setHiPfit(kmfit->pfit(1));
162 recPi0->setLoPfit(kmfit->pfit(0));
163 recPi0->setHiEnGamma(g2Trk);
164 recPi0->setLoEnGamma(g1Trk);
165 }
166 recPi0Col->push_back(recPi0);
167
168 } // End of pi0 mass window IF
169
170
171 /// Select eta candidates
172 if ((p2g.m() > m_etaminmass_cut) && (p2g.m() < m_etamaxmass_cut ))
173 {
174
175 /// Perform eta 1C KinematicFit
176 kmfit->init();
177 kmfit->setIterNumber(5);
178 kmfit->AddTrack(0, 0.0, g1Shower);
179 kmfit->AddTrack(1, 0.0, g2Shower);
180 kmfit->AddResonance(0, xmeta, 0, 1);
181
182 kmfit->Fit(0); // Perform fit
183 kmfit->BuildVirtualParticle(0);
184
185 double eta_chisq = kmfit->chisq(0);
186 if ( eta_chisq >= m_etachisq_cut ) continue;
187
188
189 /// Fill EvtRecEtaToGG
190 EvtRecEtaToGG* recEtaToGG = new EvtRecEtaToGG();
191 recEtaToGG->setUnconMass(p2g.restMass());
192 recEtaToGG->setChisq(eta_chisq);
193
194 if ( g1P4.e() >= g2P4.e() ) {
195 recEtaToGG->setHiPfit(kmfit->pfit(0));
196 recEtaToGG->setLoPfit(kmfit->pfit(1));
197 recEtaToGG->setHiEnGamma(g1Trk);
198 recEtaToGG->setLoEnGamma(g2Trk);
199 }
200 else {
201 recEtaToGG->setHiPfit(kmfit->pfit(1));
202 recEtaToGG->setLoPfit(kmfit->pfit(0));
203 recEtaToGG->setHiEnGamma(g2Trk);
204 recEtaToGG->setLoEnGamma(g1Trk);
205 }
206 recEtaToGGCol->push_back(recEtaToGG);
207
208 } // End of etaToGG mass window IF
209
210 } // End of g2Trk evtRec FOR
211 } // End of g1Trk evtRec FOR
212
213 // If there are too many pi0s, it's possibly a bad event and all pi0s are abandoned
214 if ( recPi0Col->size() > m_maxNPi0 ) {
215 recPi0Col->clear();
216 }
217
218 return StatusCode::SUCCESS;
219}
220
221
222//********************************************************************************************
223StatusCode Pi0EtaToGGRecAlg::finalize() {
224
225 MsgStream log(msgSvc(), name());
226 log << MSG::INFO << "in finalize()" << endreq;
227
228 return StatusCode::SUCCESS;
229}
230
231
232
233/// ************************** FUNCTIONS *****************************************************
234HepLorentzVector Pi0EtaToGGRecAlg::getP4(RecEmcShower* gTrk){
235
236 double eraw = gTrk->energy();
237 double phi = gTrk->phi();
238 double the = gTrk->theta();
239
240 return HepLorentzVector( eraw * sin(the) * cos(phi),
241 eraw * sin(the) * sin(phi),
242 eraw * cos(the),
243 eraw );
244}
245
246
247bool Pi0EtaToGGRecAlg::validPhoton(EvtRecTrack* recTrk,
248 SmartDataPtr<EvtRecEvent> recEvt,
249 SmartDataPtr<EvtRecTrackCol> recTrkCol)
250{
251 if ( !recTrk->isEmcShowerValid() ) return false;
252
253 RecEmcShower *emcTrk = recTrk->emcShower();
254
255 HepLorentzVector shP4 = getP4(emcTrk);
256 double cosThetaSh = shP4.vect().cosTheta();
257
258
259 /// Minimum energy
260 if (shP4.e() <= m_minEnergy) return false;
261
262
263 /// Barrel/Endcap
264 if ( m_useBarrelEndcap ) {
265 bool inBarrelEndcap = false;
266
267 if(fabs(cosThetaSh) < m_maxCosThetaBarrel) inBarrelEndcap = true;
268
269 if((fabs(cosThetaSh) > m_minCosThetaEndcap)
270 &&(fabs(cosThetaSh) < m_maxCosThetaEndcap)
271 &&(shP4.e() > m_minEndcapEnergy)) inBarrelEndcap = true;
272
273 if ( !inBarrelEndcap ) return false;
274 }
275
276
277 /// Time, only apply timing cuts if "recEvt->totalCharged() > 0"
278 if ( m_applyTimeCut ) {
279 double time = emcTrk->time();
280 if ( recEvt->totalCharged() > 0 ) {
281 if ( time < m_minTime || time > m_maxTime ) return false;
282 }
283 else {
284 RecEmcShower* firstG = (*(recTrkCol->begin()))->emcShower();
285 double deltaTime = fabs(time - firstG->time());
286 if ( deltaTime > 10 ) return false;
287 }
288 }
289
290
291 /// Dang
292 if (m_applyDangCut && recEvt->totalCharged() > 0)
293 {
294 Hep3Vector emcpos(emcTrk->x(), emcTrk->y(), emcTrk->z());
295 double dang = 200.;
296
297 for (int j = 0; j < recEvt->totalCharged(); j++) {
298 EvtRecTrackIterator jtTrk = recTrkCol->begin() + j;
299 if ( !(*jtTrk)->isExtTrackValid() ) continue;
300 RecExtTrack* extTrk = (*jtTrk)->extTrack();
301 if ( extTrk->emcVolumeNumber() == -1 ) continue;
302 Hep3Vector extpos = extTrk->emcPosition();
303 double angd1 = extpos.angle(emcpos);
304 if ( angd1 < dang ) dang = angd1;
305 }
306
307 if ( dang < 200 ) {
308 dang = dang * 180 / (CLHEP::pi);
309 if ( dang <= m_minDang ) return false;
310 }
311 } // End of "recEvt->totalCharged() > 0" IF
312
313 return true;
314}
315
316
317bool Pi0EtaToGGRecAlg::bothInEndcap(HepLorentzVector g1_P4, HepLorentzVector g2_P4){
318
319 double g1_CosTheta = g1_P4.vect().cosTheta();
320 double g2_CosTheta = g2_P4.vect().cosTheta();
321
322 bool g1InEndcap = false;
323 bool g2InEndcap = false;
324
325 if((fabs(g1_CosTheta) > m_minCosThetaEndcap)
326 &&(fabs(g1_CosTheta) < m_maxCosThetaEndcap)) g1InEndcap = true;
327
328 if((fabs(g2_CosTheta) > m_minCosThetaEndcap)
329 &&(fabs(g2_CosTheta) < m_maxCosThetaEndcap)) g2InEndcap = true;
330
331 if(g1InEndcap&&g2InEndcap) return( true );
332
333 return( false );
334}
double sin(const BesAngle a)
Definition: BesAngle.h:210
double cos(const BesAngle a)
Definition: BesAngle.h:213
Double_t time
ObjectVector< EvtRecEtaToGG > EvtRecEtaToGGCol
Definition: EvtRecEtaToGG.h:58
ObjectVector< EvtRecPi0 > EvtRecPi0Col
Definition: EvtRecPi0.h:58
EvtRecTrackCol::iterator EvtRecTrackIterator
Definition: EvtRecTrack.h:111
const double xmeta
const double xmpi0
***************************************************************************************Pseudo Class RRes *****************************************************************************************Parameters and physical constants **Maarten sept ************************************************************************DOUBLE PRECISION xsmu **************************************************************************PARTICLE DATA all others are from PDG *Only resonances with known widths into electron pairs are sept ************************************************************************C Declarations xmb DOUBLE PRECISION xcb DOUBLE PRECISION xmpi0
Definition: RRes.h:32
IMessageSvc * msgSvc()
double theta() const
Definition: DstEmcShower.h:38
double phi() const
Definition: DstEmcShower.h:39
double x() const
Definition: DstEmcShower.h:35
double time() const
Definition: DstEmcShower.h:50
double z() const
Definition: DstEmcShower.h:37
double energy() const
Definition: DstEmcShower.h:45
double y() const
Definition: DstEmcShower.h:36
const Hep3Vector emcPosition() const
Definition: DstExtTrack.h:126
const int emcVolumeNumber() const
Definition: DstExtTrack.h:132
void setLoEnGamma(const EvtRecTrack *trk)
Definition: EvtRecEtaToGG.h:41
void setHiEnGamma(const EvtRecTrack *trk)
Definition: EvtRecEtaToGG.h:40
void setUnconMass(const double unconMass)
Definition: EvtRecEtaToGG.h:34
void setChisq(const double chisq)
Definition: EvtRecEtaToGG.h:35
void setHiPfit(const HepLorentzVector &hiPfit)
Definition: EvtRecEtaToGG.h:37
void setLoPfit(const HepLorentzVector &loPfit)
Definition: EvtRecEtaToGG.h:38
void setChisq(const double chisq)
Definition: EvtRecPi0.h:35
void setLoPfit(const HepLorentzVector &loPfit)
Definition: EvtRecPi0.h:38
void setLoEnGamma(const EvtRecTrack *trk)
Definition: EvtRecPi0.h:41
void setHiPfit(const HepLorentzVector &hiPfit)
Definition: EvtRecPi0.h:37
void setUnconMass(const double unconMass)
Definition: EvtRecPi0.h:34
void setHiEnGamma(const EvtRecTrack *trk)
Definition: EvtRecPi0.h:40
RecEmcShower * emcShower()
Definition: EvtRecTrack.h:58
bool isEmcShowerValid()
Definition: EvtRecTrack.h:47
void setIterNumber(const int niter=5)
HepLorentzVector pfit(int n) const
void BuildVirtualParticle(int number)
void AddResonance(int number, double mres, std::vector< int > tlis)
static KalmanKinematicFit * instance()
Pi0EtaToGGRecAlg(const std::string &name, ISvcLocator *pSvcLocator)
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
Definition: TrackPool.cxx:22
_EXTERN_ std::string EvtRecPi0Col
Definition: EventModel.h:118
_EXTERN_ std::string EvtRecEvent
Definition: EventModel.h:111
_EXTERN_ std::string EvtRecEtaToGGCol
Definition: EventModel.h:119
_EXTERN_ std::string EvtRecTrackCol
Definition: EventModel.h:112