1#include "GaudiKernel/SmartIF.h"
2#include "GaudiKernel/MsgStream.h"
3#include "GaudiKernel/SmartDataPtr.h"
4#include "GaudiKernel/IDataManagerSvc.h"
20 Algorithm(name, pSvcLocator)
24 declareProperty(
"RejectBothInEndcap", m_rejectEndEnd =
false);
27 declareProperty(
"Pi0MinMass", m_pi0minmass_cut = 0.08);
28 declareProperty(
"Pi0MaxMass", m_pi0maxmass_cut = 0.18);
29 declareProperty(
"Pi0ChisqCut", m_pi0chisq_cut = 2500);
32 declareProperty(
"EtaMinMass", m_etaminmass_cut = 0.4);
33 declareProperty(
"EtaMaxMass", m_etamaxmass_cut = 0.7);
34 declareProperty(
"EtaChisqCut", m_etachisq_cut = 2500);
38 declareProperty(
"PhotonMinEnergy", m_minEnergy = 0.025);
40 declareProperty(
"PhotonInBarrelOrEndcap", m_useBarrelEndcap =
true);
41 declareProperty(
"PhotonMaxCosThetaBarrel", m_maxCosThetaBarrel = 0.8);
42 declareProperty(
"PhotonMinCosThetaEndcap", m_minCosThetaEndcap = 0.86);
43 declareProperty(
"PhotonMaxCosThetaEndcap", m_maxCosThetaEndcap = 0.92);
44 declareProperty(
"PhotonMinEndcapEnergy", m_minEndcapEnergy = 0.050);
46 declareProperty(
"PhotonApplyTimeCut", m_applyTimeCut =
true);
47 declareProperty(
"PhotonMinTime", m_minTime = 0.);
48 declareProperty(
"PhotonMaxTime", m_maxTime = 14.);
49 declareProperty(
"PhotonDeltaTime", m_deltaTime = 10.);
51 declareProperty(
"PhotonApplyDangCut", m_applyDangCut =
false);
52 declareProperty(
"PhotonMinDang", m_minDang = 20.0);
55 declareProperty(
"MaxNGoodPhoton", m_maxNGoodPhoton = 50);
56 declareProperty(
"MaxNPi0", m_maxNPi0 = 100);
59 declareProperty(
"DoClear", m_doClear =
false);
65 MsgStream log(
msgSvc(), name());
66 log << MSG::INFO <<
"in initialize()" <<endreq;
68 return StatusCode::SUCCESS;
75 MsgStream log(
msgSvc(), name());
76 log << MSG::INFO <<
"in execute()" <<endreq;
79 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
87 if ( sc.isFailure() ) {
88 log << MSG::ERROR <<
"could not register EvtRecPi0Col in TDS" <<endreq;
89 return StatusCode::FAILURE;
94 if ( !recEtaToGGCol ) {
97 if ( sc.isFailure() ) {
98 log << MSG::ERROR <<
"could not register EvtRecEtaToGGCol in TDS" <<endreq;
99 return StatusCode::FAILURE;
104 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
110 std::vector<EvtRecTrack*> vGoodPhotons;
111 for (
int i = recEvt->totalCharged(); i < recEvt->totalTracks(); i++ ) {
113 if ( !validPhoton(gTrk,recEvt,recTrkCol) )
continue;
114 vGoodPhotons.push_back(gTrk);
117 int nGoodPhoton = vGoodPhotons.size();
118 if ( nGoodPhoton > m_maxNGoodPhoton )
return StatusCode::SUCCESS;
126 for(
int i1 = 0; i1 < (nGoodPhoton-1); i1++) {
129 HepLorentzVector g1P4 = getP4(g1Shower);
131 for(
int i2 = i1+1; i2 < nGoodPhoton; i2++) {
134 HepLorentzVector g2P4 = getP4(g2Shower);
136 HepLorentzVector p2g = g1P4 + g2P4;
139 if(m_rejectEndEnd&&bothInEndcap(g1P4,g2P4))
continue;
142 if ((p2g.m() > m_pi0minmass_cut) && (p2g.m() < m_pi0maxmass_cut ))
155 double pi0_chisq = kmfit->
chisq(0);
156 if ( pi0_chisq >= m_pi0chisq_cut )
continue;
164 if ( g1P4.e() >= g2P4.e() ) {
176 recPi0Col->push_back(recPi0);
182 if ((p2g.m() > m_etaminmass_cut) && (p2g.m() < m_etamaxmass_cut ))
195 double eta_chisq = kmfit->
chisq(0);
196 if ( eta_chisq >= m_etachisq_cut )
continue;
204 if ( g1P4.e() >= g2P4.e() ) {
216 recEtaToGGCol->push_back(recEtaToGG);
224 if ( recPi0Col->size() > m_maxNPi0 ) {
228 return StatusCode::SUCCESS;
235 MsgStream log(
msgSvc(), name());
236 log << MSG::INFO <<
"in finalize()" << endreq;
238 return StatusCode::SUCCESS;
244HepLorentzVector Pi0EtaToGGRecAlg::getP4(
RecEmcShower* gTrk){
246 double eraw = gTrk->
energy();
247 double phi = gTrk->
phi();
248 double the = gTrk->
theta();
250 return HepLorentzVector( eraw *
sin(the) *
cos(phi),
251 eraw *
sin(the) *
sin(phi),
257bool Pi0EtaToGGRecAlg::validPhoton(
EvtRecTrack* recTrk,
258 SmartDataPtr<EvtRecEvent> recEvt,
259 SmartDataPtr<EvtRecTrackCol> recTrkCol)
265 HepLorentzVector shP4 = getP4(emcTrk);
266 double cosThetaSh = shP4.vect().cosTheta();
270 if (shP4.e() <= m_minEnergy)
return false;
274 if ( m_useBarrelEndcap ) {
275 bool inBarrelEndcap =
false;
277 if(fabs(cosThetaSh) < m_maxCosThetaBarrel) inBarrelEndcap =
true;
279 if((fabs(cosThetaSh) > m_minCosThetaEndcap)
280 &&(fabs(cosThetaSh) < m_maxCosThetaEndcap)
281 &&(shP4.e() > m_minEndcapEnergy)) inBarrelEndcap =
true;
283 if ( !inBarrelEndcap )
return false;
288 if ( m_applyTimeCut ) {
289 double time = emcTrk->
time();
290 if ( recEvt->totalCharged() > 0 ) {
291 if ( time < m_minTime || time > m_maxTime )
return false;
294 RecEmcShower* firstG = (*(recTrkCol->begin()))->emcShower();
295 double deltaTime = fabs(time - firstG->
time());
296 if ( deltaTime > 10 )
return false;
302 if (m_applyDangCut && recEvt->totalCharged() > 0)
304 Hep3Vector emcpos(emcTrk->
x(), emcTrk->
y(), emcTrk->
z());
307 for (
int j = 0; j < recEvt->totalCharged(); j++) {
309 if ( !(*jtTrk)->isExtTrackValid() )
continue;
313 double angd1 = extpos.angle(emcpos);
314 if ( angd1 < dang ) dang = angd1;
318 dang = dang * 180 / (CLHEP::pi);
319 if ( dang <= m_minDang )
return false;
327bool Pi0EtaToGGRecAlg::bothInEndcap(HepLorentzVector g1_P4, HepLorentzVector g2_P4){
329 double g1_CosTheta = g1_P4.vect().cosTheta();
330 double g2_CosTheta = g2_P4.vect().cosTheta();
332 bool g1InEndcap =
false;
333 bool g2InEndcap =
false;
335 if((fabs(g1_CosTheta) > m_minCosThetaEndcap)
336 &&(fabs(g1_CosTheta) < m_maxCosThetaEndcap)) g1InEndcap =
true;
338 if((fabs(g2_CosTheta) > m_minCosThetaEndcap)
339 &&(fabs(g2_CosTheta) < m_maxCosThetaEndcap)) g2InEndcap =
true;
341 if(g1InEndcap&&g2InEndcap)
return(
true );
double sin(const BesAngle a)
double cos(const BesAngle a)
ObjectVector< EvtRecEtaToGG > EvtRecEtaToGGCol
ObjectVector< EvtRecPi0 > EvtRecPi0Col
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
const Hep3Vector emcPosition() const
const int emcVolumeNumber() const
void setLoEnGamma(const EvtRecTrack *trk)
void setHiEnGamma(const EvtRecTrack *trk)
void setUnconMass(const double unconMass)
void setChisq(const double chisq)
void setHiPfit(const HepLorentzVector &hiPfit)
void setLoPfit(const HepLorentzVector &loPfit)
void setChisq(const double chisq)
void setLoPfit(const HepLorentzVector &loPfit)
void setLoEnGamma(const EvtRecTrack *trk)
void setHiPfit(const HepLorentzVector &hiPfit)
void setUnconMass(const double unconMass)
void setHiEnGamma(const EvtRecTrack *trk)
RecEmcShower * emcShower()
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)
_EXTERN_ std::string EvtRecPi0Col
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecEtaToGGCol
_EXTERN_ std::string EvtRecTrackCol