BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
misc/Pi0EtaToGGRecAlg.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/SmartDataPtr.h"
3
9
11
12const double xmpi0 = 0.13497;
13
14//*******************************************************************************************
15Pi0EtaToGGRecAlg::Pi0EtaToGGRecAlg(const std::string& name, ISvcLocator* pSvcLocator) :
16 Algorithm(name, pSvcLocator)
17{
18 //Declare the properties
19 declareProperty("Pi0MinMass", m_minmass_cut = 0.07);
20 declareProperty("Pi0MaxMass", m_maxmass_cut = 0.18);
21 declareProperty("Pi0ChisqCut", m_chisq_cut = 20.0);
22
23 /// Individual photons
24 declareProperty("PhotonUseBarrelEmc", m_useBarrel = true);
25 declareProperty("PhotonUseEndcapEmc", m_useEndcap = true);
26 declareProperty("PhotonMinEnergy", m_minEnergy = 0.02);
27 declareProperty("PhotonDeltaAngleCut", m_angled_cut = 20.0);
28 declareProperty("PhotonDeltaThetaCut", m_thed_cut = 20.0);
29 declareProperty("PhotonDeltaPhiCut", m_phid_cut = 20.0);
30
31}
32
33//******************************************************************************************
35
36 MsgStream log(msgSvc(), name());
37 log << MSG::INFO << "in initialize()" <<endreq;
38
39 return StatusCode::SUCCESS;
40}
41
42
43//*********************************************************************************************
45
46 MsgStream log(msgSvc(), name());
47 log << MSG::INFO << "in execute()" <<endreq;
48
49 // get event header, eventlist and tracklist from TDS
50 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
51 SmartDataPtr<EvtRecEvent> recEvt(eventSvc(), EventModel::EvtRec::EvtRecEvent);
52 SmartDataPtr<EvtRecTrackCol> recTrkCol(eventSvc(), EventModel::EvtRec::EvtRecTrackCol);
53
54 bool save2TDS = false;
55 SmartDataPtr<EvtRecPi0Col> recPi0Col(eventSvc(), EventModel::EvtRec::EvtRecPi0Col);
56 if ( !recPi0Col ) {
57 recPi0Col = new EvtRecPi0Col;
58 save2TDS = true;
59 }
60
62
63 //
64 // Set up the pi0's list
65 //
66 for(int i1 = recEvt->totalCharged(); i1 < (recEvt->totalTracks()-1); i1++) {
67 EvtRecTrack* g1Trk = *(recTrkCol->begin() + i1);
68 if ( !validPhoton(g1Trk,recEvt,recTrkCol) ) continue;
69 RecEmcShower* g1Shower = g1Trk->emcShower();
70 HepLorentzVector g1P4 = getP4(g1Shower);
71
72 for(int i2 = i1+1; i2 < recEvt->totalTracks(); i2++) {
73 EvtRecTrack* g2Trk = *(recTrkCol->begin() + i2);
74 if ( !validPhoton(g2Trk,recEvt,recTrkCol) ) continue;
75 RecEmcShower* g2Shower = g2Trk->emcShower();
76 HepLorentzVector g2P4 = getP4(g2Shower);
77
78 HepLorentzVector p2g = g1P4 + g2P4;
79 if ( p2g.m() < m_minmass_cut ) continue;
80 if ( p2g.m() > m_maxmass_cut ) continue;
81
82 /// Perform pi0 1C kinfit
83 kmfit->init();
84 kmfit->setIterNumber(1);
85 kmfit->AddTrack(0, 0.0, g1Shower);
86 kmfit->AddTrack(1, 0.0, g2Shower);
87 kmfit->AddResonance(0, xmpi0, 0, 1);
88 if ( !kmfit->Fit(0) ) continue;
89 kmfit->BuildVirtualParticle(0);
90
91 double pi0_chisq = kmfit->chisq(0);
92 if ( pi0_chisq > m_chisq_cut ) continue;
93
94 double e1 = (kmfit->pfit(0)).e();
95 double e2 = (kmfit->pfit(1)).e();
96 HepLorentzVector ppi0 = kmfit->pfit(0) + kmfit->pfit(1);
97
98 EvtRecPi0* recPi0 = new EvtRecPi0();
99 recPi0->setRawMass(p2g.restMass());
100 recPi0->setChisq(pi0_chisq);
101 recPi0->setFcos((e1-e2)/ppi0.rho());
102
103 if ( g1P4.e() >= g2P4.e() ) {
104 recPi0->setHiPfit(kmfit->pfit(0));
105 recPi0->setLoPfit(kmfit->pfit(1));
106 recPi0->setHiEnGamma(g1Trk);
107 recPi0->setLoEnGamma(g2Trk);
108 }
109 else {
110 recPi0->setHiPfit(kmfit->pfit(1));
111 recPi0->setLoPfit(kmfit->pfit(0));
112 recPi0->setHiEnGamma(g2Trk);
113 recPi0->setLoEnGamma(g1Trk);
114 }
115
116 std::cout << "p(g1) = " << g1P4 << std::endl;
117 std::cout << "p(g2) = " << g2P4 << std::endl;
118 std::cout << "chi2(pi0) = " << pi0_chisq << std::endl;
119 std::cout << "m(gg) before fill = " << p2g.restMass() << std::endl << std::endl;
120
121 recPi0Col->push_back(recPi0);
122 }
123 }
124
125 /// Fill number of pi0s in EvtRecEvent
126 recEvt->setNumberOfPi0(recPi0Col->size());
127
128 if ( save2TDS ) {
129 StatusCode sc = eventSvc()->registerObject(EventModel::EvtRec::EvtRecPi0Col, recPi0Col);
130 if ( sc.isFailure() ) {
131 log << MSG::ERROR << "could not register EvtRecPi0Col in TDS" <<endreq;
132 return StatusCode::FAILURE;
133 }
134 }
135
136 return StatusCode::SUCCESS;
137}
138
139
140//********************************************************************************************
142
143 MsgStream log(msgSvc(), name());
144 log << MSG::INFO << "in finalize()" << endreq;
145
146 return StatusCode::SUCCESS;
147}
148
149HepLorentzVector Pi0EtaToGGRecAlg::getP4(RecEmcShower* gTrk){
150
151 double eraw = gTrk->energy();
152 double phi = gTrk->phi();
153 double the = gTrk->theta();
154
155 return HepLorentzVector( eraw * sin(the) * cos(phi),
156 eraw * sin(the) * sin(phi),
157 eraw * cos(the),
158 eraw );
159}
160
161
162bool Pi0EtaToGGRecAlg::validPhoton(EvtRecTrack* recTrk,
163 SmartDataPtr<EvtRecEvent> recEvt,
164 SmartDataPtr<EvtRecTrackCol> recTrkCol)
165{
166
167 if ( !recTrk->isEmcShowerValid() ) return( false );
168
169 RecEmcShower *emcTrk = recTrk->emcShower();
170
171
172 // flag = 1: Barrel = 0,2 : Endcap
173 int flag =(emcTrk->cellId() & 0x000F0000) >> 16;
174 if ((flag == 1) && !m_useBarrel) return( false );
175 if ((flag == 0 || flag == 2) && !m_useEndcap) return( false );
176
177 if ( emcTrk->energy() < m_minEnergy ) return( false );
178
179 /// find the nearest charged track
180 Hep3Vector emcpos(emcTrk->x(), emcTrk->y(), emcTrk->z());
181 if (recEvt->totalCharged() > 0)
182 {
183 double dthe = 200.;
184 double dphi = 200.;
185 double dang1 = 200.;
186 for (int j = 0; j < recEvt->totalCharged(); j++) {
187 EvtRecTrackIterator jtTrk = recTrkCol->begin() + j;
188 if ( !(*jtTrk)->isExtTrackValid() ) continue;
189 RecExtTrack* extTrk = (*jtTrk)->extTrack();
190 if ( extTrk->emcVolumeNumber() == -1 ) continue;
191 Hep3Vector extpos = extTrk->emcPosition();
192 double angd1 = extpos.angle(emcpos);
193 double thed = extpos.theta() - emcpos.theta();
194 double phid = extpos.deltaPhi(emcpos);
195 thed = fmod(thed+CLHEP::twopi+CLHEP::twopi+CLHEP::pi, CLHEP::twopi) - CLHEP::pi;
196 phid = fmod(phid+CLHEP::twopi+CLHEP::twopi+CLHEP::pi, CLHEP::twopi) - CLHEP::pi;
197
198 if ( fabs(thed) < fabs(dthe) ) dthe = thed;
199 if ( fabs(phid) < fabs(dphi) ) dphi = phid;
200 if ( angd1 < dang1 ) dang1 = angd1;
201 }
202 if ( dang1 < 200 ) {
203 dthe = dthe * 180 / (CLHEP::pi);
204 dphi = dphi * 180 / (CLHEP::pi);
205 dang1 = dang1 * 180 / (CLHEP::pi);
206 if ( m_angled_cut > 0 ) {
207 if ( dang1 < m_angled_cut ) return( false );
208 } else {
209 if ( (fabs(dthe) < m_thed_cut) && (fabs(dphi)<m_phid_cut) ) return( false );
210 }
211 } // End of "dang1 < 200" IF
212
213 } // End of "recEvt->totalCharged() > 0" IF
214
215 return true;
216}
double sin(const BesAngle a)
Definition BesAngle.h:210
double cos(const BesAngle a)
Definition BesAngle.h:213
Double_t e1
Double_t e2
ObjectVector< EvtRecPi0 > EvtRecPi0Col
Definition EvtRecPi0.h:58
EvtRecTrackCol::iterator EvtRecTrackIterator
***************************************************************************************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()
int cellId() const
double theta() const
double phi() const
double x() const
double z() const
double energy() const
double y() const
const Hep3Vector emcPosition() const
const int emcVolumeNumber() const
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 setHiEnGamma(const EvtRecTrack *trk)
Definition EvtRecPi0.h:40
RecEmcShower * emcShower()
Definition EvtRecTrack.h:58
bool isEmcShowerValid()
Definition EvtRecTrack.h:47
static KinematicFit * instance()
void BuildVirtualParticle(int number)
void AddResonance(int number, double mres, std::vector< int > tlis)
void setIterNumber(const int niter=5)
double chisq() const
HepLorentzVector pfit(int n) const
Pi0EtaToGGRecAlg(const std::string &name, ISvcLocator *pSvcLocator)
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
Definition TrackPool.cxx:22
const double xmpi0
_EXTERN_ std::string EvtRecPi0Col
Definition EventModel.h:123
_EXTERN_ std::string EvtRecEvent
Definition EventModel.h:116
_EXTERN_ std::string EvtRecTrackCol
Definition EventModel.h:117