1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/SmartDataPtr.h"
16 Algorithm(name, pSvcLocator)
19 declareProperty(
"Pi0MinMass", m_minmass_cut = 0.07);
20 declareProperty(
"Pi0MaxMass", m_maxmass_cut = 0.18);
21 declareProperty(
"Pi0ChisqCut", m_chisq_cut = 20.0);
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);
36 MsgStream log(
msgSvc(), name());
37 log << MSG::INFO <<
"in initialize()" <<endreq;
39 return StatusCode::SUCCESS;
46 MsgStream log(
msgSvc(), name());
47 log << MSG::INFO <<
"in execute()" <<endreq;
50 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
54 bool save2TDS =
false;
66 for(
int i1 = recEvt->totalCharged(); i1 < (recEvt->totalTracks()-1); i1++) {
68 if ( !validPhoton(g1Trk,recEvt,recTrkCol) )
continue;
70 HepLorentzVector g1P4 = getP4(g1Shower);
72 for(
int i2 = i1+1; i2 < recEvt->totalTracks(); i2++) {
74 if ( !validPhoton(g2Trk,recEvt,recTrkCol) )
continue;
76 HepLorentzVector g2P4 = getP4(g2Shower);
78 HepLorentzVector p2g = g1P4 + g2P4;
79 if ( p2g.m() < m_minmass_cut )
continue;
80 if ( p2g.m() > m_maxmass_cut )
continue;
88 if ( !kmfit->
Fit(0) )
continue;
91 double pi0_chisq = kmfit->
chisq(0);
92 if ( pi0_chisq > m_chisq_cut )
continue;
94 double e1 = (kmfit->
pfit(0)).e();
95 double e2 = (kmfit->
pfit(1)).e();
96 HepLorentzVector ppi0 = kmfit->
pfit(0) + kmfit->
pfit(1);
99 recPi0->setRawMass(p2g.restMass());
101 recPi0->setFcos((
e1-
e2)/ppi0.rho());
103 if ( g1P4.e() >= g2P4.e() ) {
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;
121 recPi0Col->push_back(recPi0);
126 recEvt->setNumberOfPi0(recPi0Col->size());
130 if ( sc.isFailure() ) {
131 log << MSG::ERROR <<
"could not register EvtRecPi0Col in TDS" <<endreq;
132 return StatusCode::FAILURE;
136 return StatusCode::SUCCESS;
143 MsgStream log(
msgSvc(), name());
144 log << MSG::INFO <<
"in finalize()" << endreq;
146 return StatusCode::SUCCESS;
149HepLorentzVector Pi0EtaToGGRecAlg::getP4(
RecEmcShower* gTrk){
151 double eraw = gTrk->
energy();
152 double phi = gTrk->
phi();
153 double the = gTrk->
theta();
155 return HepLorentzVector( eraw *
sin(the) *
cos(phi),
156 eraw *
sin(the) *
sin(phi),
162bool Pi0EtaToGGRecAlg::validPhoton(
EvtRecTrack* recTrk,
163 SmartDataPtr<EvtRecEvent> recEvt,
164 SmartDataPtr<EvtRecTrackCol> recTrkCol)
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 );
177 if ( emcTrk->
energy() < m_minEnergy )
return(
false );
180 Hep3Vector emcpos(emcTrk->
x(), emcTrk->
y(), emcTrk->
z());
181 if (recEvt->totalCharged() > 0)
186 for (
int j = 0; j < recEvt->totalCharged(); j++) {
188 if ( !(*jtTrk)->isExtTrackValid() )
continue;
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;
198 if ( fabs(thed) < fabs(dthe) ) dthe = thed;
199 if ( fabs(phid) < fabs(dphi) ) dphi = phid;
200 if ( angd1 < dang1 ) dang1 = angd1;
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 );
209 if ( (fabs(dthe) < m_thed_cut) && (fabs(dphi)<m_phid_cut) )
return(
false );
double sin(const BesAngle a)
double cos(const BesAngle a)
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 setChisq(const double chisq)
void setLoPfit(const HepLorentzVector &loPfit)
void setLoEnGamma(const EvtRecTrack *trk)
void setHiPfit(const HepLorentzVector &hiPfit)
void setHiEnGamma(const EvtRecTrack *trk)
RecEmcShower * emcShower()
static KinematicFit * instance()
void BuildVirtualParticle(int number)
void AddResonance(int number, double mres, std::vector< int > tlis)
void setIterNumber(const int niter=5)
HepLorentzVector pfit(int n) const
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 EvtRecTrackCol