1#include "GaudiKernel/IDataManagerSvc.h"
2#include "GaudiKernel/MsgStream.h"
3#include "GaudiKernel/SmartDataPtr.h"
4#include "GaudiKernel/SmartIF.h"
6#include "EventModel/EventHeader.h"
7#include "EvtRecEvent/EvtRecEtaToGG.h"
8#include "EvtRecEvent/EvtRecEvent.h"
9#include "EvtRecEvent/EvtRecPi0.h"
10#include "EvtRecEvent/EvtRecTrack.h"
11#include "VertexFit/KalmanKinematicFit.h"
20 : Algorithm( name, pSvcLocator ) {
23 declareProperty(
"RejectBothInEndcap", m_rejectEndEnd =
false );
26 declareProperty(
"Pi0MinMass", m_pi0minmass_cut = 0.08 );
27 declareProperty(
"Pi0MaxMass", m_pi0maxmass_cut = 0.18 );
28 declareProperty(
"Pi0ChisqCut", m_pi0chisq_cut = 2500 );
31 declareProperty(
"EtaMinMass", m_etaminmass_cut = 0.4 );
32 declareProperty(
"EtaMaxMass", m_etamaxmass_cut = 0.7 );
33 declareProperty(
"EtaChisqCut", m_etachisq_cut = 2500 );
36 declareProperty(
"PhotonMinEnergy", m_minEnergy = 0.025 );
38 declareProperty(
"PhotonInBarrelOrEndcap", m_useBarrelEndcap =
true );
39 declareProperty(
"PhotonMaxCosThetaBarrel", m_maxCosThetaBarrel = 0.8 );
40 declareProperty(
"PhotonMinCosThetaEndcap", m_minCosThetaEndcap = 0.86 );
41 declareProperty(
"PhotonMaxCosThetaEndcap", m_maxCosThetaEndcap = 0.92 );
42 declareProperty(
"PhotonMinEndcapEnergy", m_minEndcapEnergy = 0.050 );
44 declareProperty(
"PhotonApplyTimeCut", m_applyTimeCut =
true );
45 declareProperty(
"PhotonMinTime", m_minTime = 0. );
46 declareProperty(
"PhotonMaxTime", m_maxTime = 14. );
47 declareProperty(
"PhotonDeltaTime", m_deltaTime = 10. );
49 declareProperty(
"PhotonApplyDangCut", m_applyDangCut =
false );
50 declareProperty(
"PhotonMinDang", m_minDang = 20.0 );
53 declareProperty(
"MaxNGoodPhoton", m_maxNGoodPhoton = 50 );
54 declareProperty(
"MaxNPi0", m_maxNPi0 = 100 );
57 declareProperty(
"DoClear", m_doClear =
false );
63 MsgStream log(
msgSvc(), name() );
64 log << MSG::INFO <<
"in initialize()" << endmsg;
66 return StatusCode::SUCCESS;
72 MsgStream log(
msgSvc(), name() );
73 log << MSG::INFO <<
"in execute()" << endmsg;
76 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(),
"/Event/EventHeader" );
87 log << MSG::ERROR <<
"could not register EvtRecPi0Col in TDS" << endmsg;
88 return StatusCode::FAILURE;
92 SmartDataPtr<EvtRecEtaToGGCol> recEtaToGGCol( eventSvc(),
101 log << MSG::ERROR <<
"could not register EvtRecEtaToGGCol in TDS" << endmsg;
102 return StatusCode::FAILURE;
108 SmartIF<IDataManagerSvc> dataManSvc( eventSvc() );
114 std::vector<EvtRecTrack*> vGoodPhotons;
115 for (
int i = recEvt->totalCharged(); i < recEvt->totalTracks(); i++ )
117 EvtRecTrack* gTrk = *( recTrkCol->begin() + i );
118 if ( !validPhoton( gTrk, recEvt, recTrkCol ) )
continue;
119 vGoodPhotons.push_back( gTrk );
122 int nGoodPhoton = vGoodPhotons.size();
123 if ( nGoodPhoton > m_maxNGoodPhoton )
return StatusCode::SUCCESS;
131 for (
int i1 = 0; i1 < ( nGoodPhoton - 1 ); i1++ )
133 EvtRecTrack* g1Trk = vGoodPhotons[i1];
134 RecEmcShower* g1Shower = g1Trk->
emcShower();
135 HepLorentzVector g1P4 = getP4( g1Shower );
137 for (
int i2 = i1 + 1; i2 < nGoodPhoton; i2++ )
139 EvtRecTrack* g2Trk = vGoodPhotons[i2];
140 RecEmcShower* g2Shower = g2Trk->
emcShower();
141 HepLorentzVector g2P4 = getP4( g2Shower );
143 HepLorentzVector p2g = g1P4 + g2P4;
146 if ( m_rejectEndEnd && bothInEndcap( g1P4, g2P4 ) )
continue;
149 if ( ( p2g.m() > m_pi0minmass_cut ) && ( p2g.m() < m_pi0maxmass_cut ) )
155 kmfit->
AddTrack( 0, 0.0, g1Shower );
156 kmfit->
AddTrack( 1, 0.0, g2Shower );
162 double pi0_chisq = kmfit->
chisq( 0 );
163 if ( pi0_chisq >= m_pi0chisq_cut )
continue;
166 EvtRecPi0* recPi0 =
new EvtRecPi0();
170 if ( g1P4.e() >= g2P4.e() )
184 recPi0Col->push_back( recPi0 );
189 if ( ( p2g.m() > m_etaminmass_cut ) && ( p2g.m() < m_etamaxmass_cut ) )
195 kmfit->
AddTrack( 0, 0.0, g1Shower );
196 kmfit->
AddTrack( 1, 0.0, g2Shower );
202 double eta_chisq = kmfit->
chisq( 0 );
203 if ( eta_chisq >= m_etachisq_cut )
continue;
206 EvtRecEtaToGG* recEtaToGG =
new EvtRecEtaToGG();
210 if ( g1P4.e() >= g2P4.e() )
224 recEtaToGGCol->push_back( recEtaToGG );
232 if ( recPi0Col->size() > m_maxNPi0 ) { recPi0Col->clear(); }
234 return StatusCode::SUCCESS;
240 MsgStream log(
msgSvc(), name() );
241 log << MSG::INFO <<
"in finalize()" << endmsg;
243 return StatusCode::SUCCESS;
247HepLorentzVector Pi0EtaToGGRecAlg::getP4(
RecEmcShower* gTrk ) {
249 double eraw = gTrk->
energy();
250 double phi = gTrk->
phi();
251 double the = gTrk->
theta();
253 return HepLorentzVector( eraw *
sin( the ) *
cos( phi ), eraw *
sin( the ) *
sin( phi ),
254 eraw *
cos( the ), eraw );
257bool Pi0EtaToGGRecAlg::validPhoton(
EvtRecTrack* recTrk, SmartDataPtr<EvtRecEvent> recEvt,
258 SmartDataPtr<EvtRecTrackCol> recTrkCol ) {
261 RecEmcShower* emcTrk = recTrk->
emcShower();
263 HepLorentzVector shP4 = getP4( emcTrk );
264 double cosThetaSh = shP4.vect().cosTheta();
267 if ( shP4.e() <= m_minEnergy )
return false;
270 if ( m_useBarrelEndcap )
272 bool inBarrelEndcap =
false;
274 if ( fabs( cosThetaSh ) < m_maxCosThetaBarrel ) inBarrelEndcap =
true;
276 if ( ( fabs( cosThetaSh ) > m_minCosThetaEndcap ) &&
277 ( fabs( cosThetaSh ) < m_maxCosThetaEndcap ) && ( shP4.e() > m_minEndcapEnergy ) )
278 inBarrelEndcap =
true;
280 if ( !inBarrelEndcap )
return false;
284 if ( m_applyTimeCut )
287 if ( recEvt->totalCharged() > 0 )
293 RecEmcShower* firstG = ( *( recTrkCol->begin() ) )->emcShower();
294 double deltaTime = fabs(
time - firstG->
time() );
295 if ( deltaTime > 10 )
return false;
300 if ( m_applyDangCut && recEvt->totalCharged() > 0 )
302 Hep3Vector emcpos( emcTrk->
x(), emcTrk->
y(), emcTrk->
z() );
305 for (
int j = 0; j < recEvt->totalCharged(); j++ )
308 if ( !( *jtTrk )->isExtTrackValid() )
continue;
309 RecExtTrack* extTrk = ( *jtTrk )->extTrack();
312 double angd1 = extpos.angle( emcpos );
313 if ( angd1 < dang ) dang = angd1;
318 dang = dang * 180 / ( CLHEP::pi );
319 if ( dang <= m_minDang )
return false;
326bool Pi0EtaToGGRecAlg::bothInEndcap( HepLorentzVector g1_P4, HepLorentzVector g2_P4 ) {
328 double g1_CosTheta = g1_P4.vect().cosTheta();
329 double g2_CosTheta = g2_P4.vect().cosTheta();
331 bool g1InEndcap =
false;
332 bool g2InEndcap =
false;
334 if ( ( fabs( g1_CosTheta ) > m_minCosThetaEndcap ) &&
335 ( fabs( g1_CosTheta ) < m_maxCosThetaEndcap ) )
338 if ( ( fabs( g2_CosTheta ) > m_minCosThetaEndcap ) &&
339 ( fabs( g2_CosTheta ) < m_maxCosThetaEndcap ) )
342 if ( g1InEndcap && g2InEndcap )
return (
true );
DECLARE_COMPONENT(BesBdkRc)
ObjectVector< EvtRecEtaToGG > EvtRecEtaToGGCol
ObjectVector< EvtRecPi0 > EvtRecPi0Col
EvtRecTrackCol::iterator EvtRecTrackIterator
double sin(const BesAngle a)
double cos(const BesAngle a)
***************************************************************************************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