BOSS 7.0.7
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtSelExample Class Reference

#include <EvtSelExample.h>

+ Inheritance diagram for EvtSelExample:

Public Member Functions

 EvtSelExample (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 

Detailed Description

Definition at line 22 of file EvtSelExample.h.

Constructor & Destructor Documentation

◆ EvtSelExample()

EvtSelExample::EvtSelExample ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 56 of file EvtSelExample.cxx.

56 :
57 Algorithm(name, pSvcLocator) {
58
59 //Declare the properties
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);
67}

Member Function Documentation

◆ execute()

StatusCode EvtSelExample::execute ( )

Definition at line 99 of file EvtSelExample.cxx.

99 {
100
101 MsgStream log(msgSvc(), name());
102 log << MSG::INFO << "in execute()" << endreq;
103
104 // DQA
105 // Add the line below at the beginning of execute()
106 //
107 setFilterPassed(false);
108
109 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
110 m_runNo=eventHeader->runNumber();
111 m_event=eventHeader->eventNumber();
112 log << MSG::DEBUG <<"run, evtnum = "
113 << m_runNo << " , "
114 << m_event <<endreq;
115
116
117 SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc(), EventModel::EvtRec::EvtRecEvent);
118 log << MSG::DEBUG <<"ncharg, nneu, tottks = "
119 << evtRecEvent->totalCharged() << " , "
120 << evtRecEvent->totalNeutral() << " , "
121 << evtRecEvent->totalTracks() <<endreq;
122
123 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol(eventSvc(), EventModel::EvtRec::EvtRecTrackCol);
124
125 if(evtRecEvent->totalNeutral()>100) {
126 return StatusCode::SUCCESS;
127 }
128
129 Vint iGood, ipip, ipim;
130 iGood.clear();
131 ipip.clear();
132 ipim.clear();
133 Vp4 ppip, ppim;
134 ppip.clear();
135 ppim.clear();
136
137 Hep3Vector xorigin(0,0,0);
138
139 IVertexDbSvc* vtxsvc;
140 Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
141 if(vtxsvc->isVertexValid()){
142 double* dbv = vtxsvc->PrimaryVertex();
143 double* vv = vtxsvc->SigmaPrimaryVertex();
144 xorigin.setX(dbv[0]);
145 xorigin.setY(dbv[1]);
146 xorigin.setZ(dbv[2]);
147 }
148
149 int nCharge = 0;
150 for(int i = 0; i < evtRecEvent->totalCharged(); i++){
151 EvtRecTrackIterator itTrk=evtRecTrkCol->begin() + i;
152 if(!(*itTrk)->isMdcTrackValid()) continue;
153 if (!(*itTrk)->isMdcKalTrackValid()) continue;
154 RecMdcTrack *mdcTrk = (*itTrk)->mdcTrack();
155
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));
164
165 if(fabs(z0) >= m_vz0cut) continue;
166 if(Rxy >= m_vr0cut) continue;
167// if(fabs(m_Vct)>=m_cthcut) continue;
168 iGood.push_back((*itTrk)->trackId());
169 nCharge += mdcTrk->charge();
170 if (mdcTrk->charge() > 0) {
171 ipip.push_back((*itTrk)->trackId());
172 } else {
173 ipim.push_back((*itTrk)->trackId());
174 }
175 }
176
177 //
178 // Finish Good Charged Track Selection
179 //
180 int nGood = iGood.size();
181 log << MSG::DEBUG << "ngood, totcharge = " << nGood << " , " << nCharge << endreq;
182 if((nGood != 2)||(nCharge!=0)){
183 return StatusCode::SUCCESS;
184 }
185
186 Vint iGam;
187 iGam.clear();
188 for(int i = evtRecEvent->totalCharged(); i< evtRecEvent->totalTracks(); i++) {
189 EvtRecTrackIterator itTrk=evtRecTrkCol->begin() + i;
190 if(!(*itTrk)->isEmcShowerValid()) continue;
191 RecEmcShower *emcTrk = (*itTrk)->emcShower();
192 Hep3Vector emcpos(emcTrk->x(), emcTrk->y(), emcTrk->z());
193 // find the nearest charged track
194 double dthe = 200.;
195 double dphi = 200.;
196 double dang = 200.;
197 for(int j = 0; j < evtRecEvent->totalCharged(); j++) {
198 EvtRecTrackIterator jtTrk = evtRecTrkCol->begin() + j;
199 if(!(*jtTrk)->isExtTrackValid()) continue;
200 RecExtTrack *extTrk = (*jtTrk)->extTrack();
201 if(extTrk->emcVolumeNumber() == -1) continue;
202 Hep3Vector extpos = extTrk->emcPosition();
203 // double ctht = extpos.cosTheta(emcpos);
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;
209
210// if(fabs(thed) < fabs(dthe)) dthe = thed;
211// if(fabs(phid) < fabs(dphi)) dphi = phid;
212 if(angd < dang) {
213 dang = angd;
214 dthe = thed;
215 dphi = phid;
216 }
217 }
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;
225// if((fabs(dthe) < m_gammaThetaCut) && (fabs(dphi)<m_gammaPhiCut) ) continue;
226 //
227 // good photon cut will be set here
228 //
229 iGam.push_back((*itTrk)->trackId());
230 }
231
232 //
233 // Finish Good Photon Selection
234 //
235 int nGam = iGam.size();
236
237 log << MSG::DEBUG << "num Good Photon " << nGam << " , " <<evtRecEvent->totalNeutral()<<endreq;
238 if(nGam<2){
239 return StatusCode::SUCCESS;
240 }
241
242 // Vertex Fit
243
244 // Kinamatic Fit
245
246 // finale selection
247
248 m_tuple->write();
249
250 ////////////////////////////////////////////////////////////
251 // DQA
252 // set tag and quality
253
254 // Pid: 1 - electron, 2 - muon, 3 - pion, 4 - kaon, 5 - proton
255
256 (*(evtRecTrkCol->begin()+ipip[0]))->setPartId(2);
257 (*(evtRecTrkCol->begin()+ipim[0]))->setPartId(2);
258 // Quality: defined by whether dE/dx or TOF is used to identify particle
259 // 0 - no dE/dx, no TOF (can be used for dE/dx and TOF calibration)
260 // 1 - only dE/dx (can be used for TOF calibration)
261 // 2 - only TOF (can be used for dE/dx calibration)
262 // 3 - Both dE/dx and TOF
263 (*(evtRecTrkCol->begin()+ipip[0]))->setQuality(0);
264 (*(evtRecTrkCol->begin()+ipim[0]))->setQuality(0);
265
266 // DQA
267 // Add the line below at the end of execute(), (before return)
268 //
269 setFilterPassed(true);
270 ////////////////////////////////////////////////////////////
271
272 return StatusCode::SUCCESS;
273
274}
double sin(const BesAngle a)
Definition: BesAngle.h:210
double cos(const BesAngle a)
Definition: BesAngle.h:213
EvtRecTrackCol::iterator EvtRecTrackIterator
Definition: EvtRecTrack.h:111
std::vector< HepLorentzVector > Vp4
Definition: Gam4pikp.cxx:53
std::vector< int > Vint
Definition: Gam4pikp.cxx:52
IMessageSvc * msgSvc()
double x() const
Definition: DstEmcShower.h:35
double z() const
Definition: DstEmcShower.h:37
double energy() const
Definition: DstEmcShower.h:45
double y() const
Definition: DstEmcShower.h:36
const Hep3Vector emcPosition() const
Definition: DstExtTrack.h:126
const int emcVolumeNumber() const
Definition: DstExtTrack.h:132
const int charge() const
Definition: DstMdcTrack.h:53
const HepVector helix() const
......
const double z() const
Definition: DstMdcTrack.h:63
const double p() const
Definition: DstMdcTrack.h:58
const double y() const
Definition: DstMdcTrack.h:62
const double x() const
Definition: DstMdcTrack.h:61
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0
_EXTERN_ std::string EvtRecEvent
Definition: EventModel.h:116
_EXTERN_ std::string EvtRecTrackCol
Definition: EventModel.h:117
const float pi
Definition: vector3.h:133

◆ finalize()

StatusCode EvtSelExample::finalize ( )

Definition at line 277 of file EvtSelExample.cxx.

277 {
278
279 MsgStream log(msgSvc(), name());
280 log << MSG::INFO << "in finalize()" << endmsg;
281 return StatusCode::SUCCESS;
282}

◆ initialize()

StatusCode EvtSelExample::initialize ( )

Definition at line 71 of file EvtSelExample.cxx.

71 {
72 MsgStream log(msgSvc(), name());
73
74 log << MSG::INFO << "in initialize()" << endmsg;
75 StatusCode status;
76
77 // DQA
78 // The first directory specifier must be "DQAFILE"
79 // The second is the control sample name, the first letter is in upper format. eg. "Rhopi"
80 NTuplePtr nt(ntupleSvc(), "DQAFILE/Rhopi");
81 if ( nt ) m_tuple = nt;
82 else {
83 m_tuple = ntupleSvc()->book("DQAFILE/Rhopi", CLID_ColumnWiseTuple, "Rhopi ntuple");
84 if( m_tuple ) {
85 status = m_tuple->addItem("runNo", m_runNo);
86 status = m_tuple->addItem("event", m_event);
87 } else {
88 log << MSG::ERROR << "Can not book N-tuple:" << long(m_tuple) << endreq;
89 }
90 }
91
92 log << MSG::INFO << "successfully return from initialize()" <<endmsg;
93 return StatusCode::SUCCESS;
94
95
96}
INTupleSvc * ntupleSvc()

The documentation for this class was generated from the following files: