1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/SmartDataPtr.h"
18 Algorithm(name, pSvcLocator)
22 declareProperty(
"RejectBothInEndcap", m_rejectEndEnd =
false);
25 declareProperty(
"Pi0MinMass", m_pi0minmass_cut = 0.08);
26 declareProperty(
"Pi0MaxMass", m_pi0maxmass_cut = 0.18);
27 declareProperty(
"Pi0ChisqCut", m_pi0chisq_cut = 2500);
30 declareProperty(
"EtaMinMass", m_etaminmass_cut = 0.4);
31 declareProperty(
"EtaMaxMass", m_etamaxmass_cut = 0.7);
32 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);
61 MsgStream log(
msgSvc(), name());
62 log << MSG::INFO <<
"in initialize()" <<endreq;
64 return StatusCode::SUCCESS;
71 MsgStream log(
msgSvc(), name());
72 log << MSG::INFO <<
"in execute()" <<endreq;
75 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
83 if ( sc.isFailure() ) {
84 log << MSG::ERROR <<
"could not register EvtRecPi0Col in TDS" <<endreq;
85 return StatusCode::FAILURE;
90 if ( !recEtaToGGCol ) {
93 if ( sc.isFailure() ) {
94 log << MSG::ERROR <<
"could not register EvtRecEtaToGGCol in TDS" <<endreq;
95 return StatusCode::FAILURE;
100 std::vector<EvtRecTrack*> vGoodPhotons;
101 for (
int i = recEvt->totalCharged(); i < recEvt->totalTracks(); i++ ) {
103 if ( !validPhoton(gTrk,recEvt,recTrkCol) )
continue;
104 vGoodPhotons.push_back(gTrk);
107 int nGoodPhoton = vGoodPhotons.size();
108 if ( nGoodPhoton > m_maxNGoodPhoton )
return StatusCode::SUCCESS;
116 for(
int i1 = 0; i1 < (nGoodPhoton-1); i1++) {
119 HepLorentzVector g1P4 = getP4(g1Shower);
121 for(
int i2 = i1+1; i2 < nGoodPhoton; i2++) {
124 HepLorentzVector g2P4 = getP4(g2Shower);
126 HepLorentzVector p2g = g1P4 + g2P4;
129 if(m_rejectEndEnd&&bothInEndcap(g1P4,g2P4))
continue;
132 if ((p2g.m() > m_pi0minmass_cut) && (p2g.m() < m_pi0maxmass_cut ))
145 double pi0_chisq = kmfit->
chisq(0);
146 if ( pi0_chisq >= m_pi0chisq_cut )
continue;
154 if ( g1P4.e() >= g2P4.e() ) {
166 recPi0Col->push_back(recPi0);
172 if ((p2g.m() > m_etaminmass_cut) && (p2g.m() < m_etamaxmass_cut ))
185 double eta_chisq = kmfit->
chisq(0);
186 if ( eta_chisq >= m_etachisq_cut )
continue;
194 if ( g1P4.e() >= g2P4.e() ) {
206 recEtaToGGCol->push_back(recEtaToGG);
214 if ( recPi0Col->size() > m_maxNPi0 ) {
218 return StatusCode::SUCCESS;
225 MsgStream log(
msgSvc(), name());
226 log << MSG::INFO <<
"in finalize()" << endreq;
228 return StatusCode::SUCCESS;
234HepLorentzVector Pi0EtaToGGRecAlg::getP4(
RecEmcShower* gTrk){
236 double eraw = gTrk->
energy();
237 double phi = gTrk->
phi();
238 double the = gTrk->
theta();
240 return HepLorentzVector( eraw *
sin(the) *
cos(phi),
241 eraw *
sin(the) *
sin(phi),
247bool Pi0EtaToGGRecAlg::validPhoton(
EvtRecTrack* recTrk,
248 SmartDataPtr<EvtRecEvent> recEvt,
249 SmartDataPtr<EvtRecTrackCol> recTrkCol)
255 HepLorentzVector shP4 = getP4(emcTrk);
256 double cosThetaSh = shP4.vect().cosTheta();
260 if (shP4.e() <= m_minEnergy)
return false;
264 if ( m_useBarrelEndcap ) {
265 bool inBarrelEndcap =
false;
267 if(fabs(cosThetaSh) < m_maxCosThetaBarrel) inBarrelEndcap =
true;
269 if((fabs(cosThetaSh) > m_minCosThetaEndcap)
270 &&(fabs(cosThetaSh) < m_maxCosThetaEndcap)
271 &&(shP4.e() > m_minEndcapEnergy)) inBarrelEndcap =
true;
273 if ( !inBarrelEndcap )
return false;
278 if ( m_applyTimeCut ) {
280 if ( recEvt->totalCharged() > 0 ) {
284 RecEmcShower* firstG = (*(recTrkCol->begin()))->emcShower();
285 double deltaTime = fabs(
time - firstG->
time());
286 if ( deltaTime > 10 )
return false;
292 if (m_applyDangCut && recEvt->totalCharged() > 0)
294 Hep3Vector emcpos(emcTrk->
x(), emcTrk->
y(), emcTrk->
z());
297 for (
int j = 0; j < recEvt->totalCharged(); j++) {
299 if ( !(*jtTrk)->isExtTrackValid() )
continue;
303 double angd1 = extpos.angle(emcpos);
304 if ( angd1 < dang ) dang = angd1;
308 dang = dang * 180 / (CLHEP::pi);
309 if ( dang <= m_minDang )
return false;
317bool Pi0EtaToGGRecAlg::bothInEndcap(HepLorentzVector g1_P4, HepLorentzVector g2_P4){
319 double g1_CosTheta = g1_P4.vect().cosTheta();
320 double g2_CosTheta = g2_P4.vect().cosTheta();
322 bool g1InEndcap =
false;
323 bool g2InEndcap =
false;
325 if((fabs(g1_CosTheta) > m_minCosThetaEndcap)
326 &&(fabs(g1_CosTheta) < m_maxCosThetaEndcap)) g1InEndcap =
true;
328 if((fabs(g2_CosTheta) > m_minCosThetaEndcap)
329 &&(fabs(g2_CosTheta) < m_maxCosThetaEndcap)) g2InEndcap =
true;
331 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