3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/AlgFactory.h"
5#include "GaudiKernel/ISvcLocator.h"
6#include "GaudiKernel/SmartDataPtr.h"
7#include "GaudiKernel/IDataProviderSvc.h"
8#include "GaudiKernel/PropertyMgr.h"
10#include "GaudiKernel/Bootstrap.h"
11#include "GaudiKernel/ISvcLocator.h"
22#include "GaudiKernel/INTupleSvc.h"
23#include "GaudiKernel/NTuple.h"
24#include "GaudiKernel/Bootstrap.h"
25#include "GaudiKernel/IHistogramSvc.h"
26#include "CLHEP/Vector/ThreeVector.h"
27#include "CLHEP/Vector/LorentzVector.h"
28#include "CLHEP/Vector/TwoVector.h"
30using CLHEP::Hep3Vector;
31using CLHEP::Hep2Vector;
32using CLHEP::HepLorentzVector;
33#include "CLHEP/Geometry/Point3D.h"
42#ifndef ENABLE_BACKWARDS_COMPATIBILITY
45using CLHEP::HepLorentzVector;
47const double mpi = 0.13957;
48const double mk = 0.493677;
49const double xmass[5] = {0.000511, 0.105658, 0.139570,0.493677, 0.938272};
50const double velc = 299.792458;
51typedef std::vector<int>
Vint;
52typedef std::vector<HepLorentzVector>
Vp4;
57 Algorithm(name, pSvcLocator) {
60 declareProperty(
"Vr0cut", m_vr0cut=5.0);
61 declareProperty(
"Vz0cut", m_vz0cut=20.0);
62 declareProperty(
"Vr1cut", m_vr1cut=1.0);
63 declareProperty(
"Vz1cut", m_vz1cut=5.0);
64 declareProperty(
"Vctcut", m_cthcut=0.93);
65 declareProperty(
"EnergyThreshold", m_energyThreshold=0.04);
66 declareProperty(
"GammaAngCut", m_gammaAngCut=20.0);
72 MsgStream log(
msgSvc(), name());
74 log << MSG::INFO <<
"in initialize()" << endmsg;
80 NTuplePtr nt(
ntupleSvc(),
"DQAFILE/Rhopi");
81 if ( nt ) m_tuple = nt;
83 m_tuple =
ntupleSvc()->book(
"DQAFILE/Rhopi", CLID_ColumnWiseTuple,
"Rhopi ntuple");
85 status = m_tuple->addItem(
"runNo", m_runNo);
86 status = m_tuple->addItem(
"event", m_event);
88 log << MSG::ERROR <<
"Can not book N-tuple:" << long(m_tuple) << endreq;
92 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
93 return StatusCode::SUCCESS;
101 MsgStream log(
msgSvc(), name());
102 log << MSG::INFO <<
"in execute()" << endreq;
107 setFilterPassed(
false);
109 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
110 m_runNo=eventHeader->runNumber();
111 m_event=eventHeader->eventNumber();
112 log << MSG::DEBUG <<
"run, evtnum = "
118 log << MSG::DEBUG <<
"ncharg, nneu, tottks = "
119 << evtRecEvent->totalCharged() <<
" , "
120 << evtRecEvent->totalNeutral() <<
" , "
121 << evtRecEvent->totalTracks() <<endreq;
125 if(evtRecEvent->totalNeutral()>100) {
126 return StatusCode::SUCCESS;
129 Vint iGood, ipip, ipim;
137 Hep3Vector xorigin(0,0,0);
140 Gaudi::svcLocator()->service(
"VertexDbSvc", vtxsvc);
144 xorigin.setX(dbv[0]);
145 xorigin.setY(dbv[1]);
146 xorigin.setZ(dbv[2]);
150 for(
int i = 0; i < evtRecEvent->totalCharged(); i++){
152 if(!(*itTrk)->isMdcTrackValid())
continue;
153 if (!(*itTrk)->isMdcKalTrackValid())
continue;
156 double pch =mdcTrk->
p();
157 double x0 =mdcTrk->
x();
158 double y0 =mdcTrk->
y();
159 double z0 =mdcTrk->
z();
160 double phi0=mdcTrk->
helix(1);
161 double xv=xorigin.x();
162 double yv=xorigin.y();
163 double Rxy=fabs((x0-xv)*
cos(phi0)+(y0-yv)*
sin(phi0));
165 if(fabs(z0) >= m_vz0cut)
continue;
166 if(Rxy >= m_vr0cut)
continue;
168 iGood.push_back((*itTrk)->trackId());
169 nCharge += mdcTrk->
charge();
170 if (mdcTrk->
charge() > 0) {
171 ipip.push_back((*itTrk)->trackId());
173 ipim.push_back((*itTrk)->trackId());
180 int nGood = iGood.size();
181 log << MSG::DEBUG <<
"ngood, totcharge = " << nGood <<
" , " << nCharge << endreq;
182 if((nGood != 2)||(nCharge!=0)){
183 return StatusCode::SUCCESS;
188 for(
int i = evtRecEvent->totalCharged(); i< evtRecEvent->totalTracks(); i++) {
190 if(!(*itTrk)->isEmcShowerValid())
continue;
192 Hep3Vector emcpos(emcTrk->
x(), emcTrk->
y(), emcTrk->
z());
197 for(
int j = 0; j < evtRecEvent->totalCharged(); j++) {
199 if(!(*jtTrk)->isExtTrackValid())
continue;
204 double angd = extpos.angle(emcpos);
205 double thed = extpos.theta() - emcpos.theta();
206 double phid = extpos.deltaPhi(emcpos);
207 thed = fmod(thed+CLHEP::twopi+CLHEP::twopi+
pi, CLHEP::twopi) - CLHEP::pi;
208 phid = fmod(phid+CLHEP::twopi+CLHEP::twopi+
pi, CLHEP::twopi) - CLHEP::pi;
218 if(dang>=200)
continue;
219 double eraw = emcTrk->
energy();
220 dthe = dthe * 180 / (CLHEP::pi);
221 dphi = dphi * 180 / (CLHEP::pi);
222 dang = dang * 180 / (CLHEP::pi);
223 if(eraw < m_energyThreshold)
continue;
224 if(dang < m_gammaAngCut)
continue;
229 iGam.push_back((*itTrk)->trackId());
235 int nGam = iGam.size();
237 log << MSG::DEBUG <<
"num Good Photon " << nGam <<
" , " <<evtRecEvent->totalNeutral()<<endreq;
239 return StatusCode::SUCCESS;
256 (*(evtRecTrkCol->begin()+ipip[0]))->setPartId(2);
257 (*(evtRecTrkCol->begin()+ipim[0]))->setPartId(2);
263 (*(evtRecTrkCol->begin()+ipip[0]))->setQuality(0);
264 (*(evtRecTrkCol->begin()+ipim[0]))->setQuality(0);
269 setFilterPassed(
true);
272 return StatusCode::SUCCESS;
279 MsgStream log(
msgSvc(), name());
280 log << MSG::INFO <<
"in finalize()" << endmsg;
281 return StatusCode::SUCCESS;
double sin(const BesAngle a)
double cos(const BesAngle a)
EvtRecTrackCol::iterator EvtRecTrackIterator
HepGeom::Point3D< double > HepPoint3D
std::vector< HepLorentzVector > Vp4
std::vector< HepLorentzVector > Vp4
const Hep3Vector emcPosition() const
const int emcVolumeNumber() const
const HepVector helix() const
......
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecTrackCol