BOSS 8.0.0
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 20 of file EvtSelExample.h.

Constructor & Destructor Documentation

◆ EvtSelExample()

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

Definition at line 45 of file EvtSelExample.cxx.

46 : Algorithm( name, pSvcLocator ) {
47
48 // Declare the properties
49 declareProperty( "Vr0cut", m_vr0cut = 5.0 );
50 declareProperty( "Vz0cut", m_vz0cut = 20.0 );
51 declareProperty( "Vr1cut", m_vr1cut = 1.0 );
52 declareProperty( "Vz1cut", m_vz1cut = 5.0 );
53 declareProperty( "Vctcut", m_cthcut = 0.93 );
54 declareProperty( "EnergyThreshold", m_energyThreshold = 0.04 );
55 declareProperty( "GammaAngCut", m_gammaAngCut = 20.0 );
56}

Referenced by EvtSelExample().

Member Function Documentation

◆ execute()

StatusCode EvtSelExample::execute ( )

Definition at line 86 of file EvtSelExample.cxx.

86 {
87
88 MsgStream log( msgSvc(), name() );
89 log << MSG::INFO << "in execute()" << endmsg;
90
91 // DQA
92 // Add the line below at the beginning of execute()
93 //
94 setFilterPassed( false );
95
96 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
97 m_runNo = eventHeader->runNumber();
98 m_event = eventHeader->eventNumber();
99 log << MSG::DEBUG << "run, evtnum = " << m_runNo << " , " << m_event << endmsg;
100
101 SmartDataPtr<EvtRecEvent> evtRecEvent( eventSvc(), EventModel::EvtRec::EvtRecEvent );
102 log << MSG::DEBUG << "ncharg, nneu, tottks = " << evtRecEvent->totalCharged() << " , "
103 << evtRecEvent->totalNeutral() << " , " << evtRecEvent->totalTracks() << endmsg;
104
105 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol( eventSvc(), EventModel::EvtRec::EvtRecTrackCol );
106
107 if ( evtRecEvent->totalNeutral() > 100 ) { return StatusCode::SUCCESS; }
108
109 Vint iGood, ipip, ipim;
110 iGood.clear();
111 ipip.clear();
112 ipim.clear();
113 Vp4 ppip, ppim;
114 ppip.clear();
115 ppim.clear();
116
117 Hep3Vector xorigin( 0, 0, 0 );
118
119 IVertexDbSvc* vtxsvc;
120 Gaudi::svcLocator()->service( "VertexDbSvc", vtxsvc ).ignore();
121 if ( vtxsvc->isVertexValid() )
122 {
123 double* dbv = vtxsvc->PrimaryVertex();
124 double* vv = vtxsvc->SigmaPrimaryVertex();
125 xorigin.setX( dbv[0] );
126 xorigin.setY( dbv[1] );
127 xorigin.setZ( dbv[2] );
128 }
129
130 int nCharge = 0;
131 for ( int i = 0; i < evtRecEvent->totalCharged(); i++ )
132 {
133 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
134 if ( !( *itTrk )->isMdcTrackValid() ) continue;
135 if ( !( *itTrk )->isMdcKalTrackValid() ) continue;
136 RecMdcTrack* mdcTrk = ( *itTrk )->mdcTrack();
137
138 double pch = mdcTrk->p();
139 double x0 = mdcTrk->x();
140 double y0 = mdcTrk->y();
141 double z0 = mdcTrk->z();
142 double phi0 = mdcTrk->helix( 1 );
143 double xv = xorigin.x();
144 double yv = xorigin.y();
145 double Rxy = fabs( ( x0 - xv ) * cos( phi0 ) + ( y0 - yv ) * sin( phi0 ) );
146
147 if ( fabs( z0 ) >= m_vz0cut ) continue;
148 if ( Rxy >= m_vr0cut ) continue;
149 // if(fabs(m_Vct)>=m_cthcut) continue;
150 iGood.push_back( ( *itTrk )->trackId() );
151 nCharge += mdcTrk->charge();
152 if ( mdcTrk->charge() > 0 ) { ipip.push_back( ( *itTrk )->trackId() ); }
153 else { ipim.push_back( ( *itTrk )->trackId() ); }
154 }
155
156 //
157 // Finish Good Charged Track Selection
158 //
159 int nGood = iGood.size();
160 log << MSG::DEBUG << "ngood, totcharge = " << nGood << " , " << nCharge << endmsg;
161 if ( ( nGood != 2 ) || ( nCharge != 0 ) ) { return StatusCode::SUCCESS; }
162
163 Vint iGam;
164 iGam.clear();
165 for ( int i = evtRecEvent->totalCharged(); i < evtRecEvent->totalTracks(); i++ )
166 {
167 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
168 if ( !( *itTrk )->isEmcShowerValid() ) continue;
169 RecEmcShower* emcTrk = ( *itTrk )->emcShower();
170 Hep3Vector emcpos( emcTrk->x(), emcTrk->y(), emcTrk->z() );
171 // find the nearest charged track
172 double dthe = 200.;
173 double dphi = 200.;
174 double dang = 200.;
175 for ( int j = 0; j < evtRecEvent->totalCharged(); j++ )
176 {
177 EvtRecTrackIterator jtTrk = evtRecTrkCol->begin() + j;
178 if ( !( *jtTrk )->isExtTrackValid() ) continue;
179 RecExtTrack* extTrk = ( *jtTrk )->extTrack();
180 if ( extTrk->emcVolumeNumber() == -1 ) continue;
181 Hep3Vector extpos = extTrk->emcPosition();
182 // double ctht = extpos.cosTheta(emcpos);
183 double angd = extpos.angle( emcpos );
184 double thed = extpos.theta() - emcpos.theta();
185 double phid = extpos.deltaPhi( emcpos );
186 thed = fmod( thed + CLHEP::twopi + CLHEP::twopi + pi, CLHEP::twopi ) - CLHEP::pi;
187 phid = fmod( phid + CLHEP::twopi + CLHEP::twopi + pi, CLHEP::twopi ) - CLHEP::pi;
188
189 // if(fabs(thed) < fabs(dthe)) dthe = thed;
190 // if(fabs(phid) < fabs(dphi)) dphi = phid;
191 if ( angd < dang )
192 {
193 dang = angd;
194 dthe = thed;
195 dphi = phid;
196 }
197 }
198 if ( dang >= 200 ) continue;
199 double eraw = emcTrk->energy();
200 dthe = dthe * 180 / ( CLHEP::pi );
201 dphi = dphi * 180 / ( CLHEP::pi );
202 dang = dang * 180 / ( CLHEP::pi );
203 if ( eraw < m_energyThreshold ) continue;
204 if ( dang < m_gammaAngCut ) continue;
205 // if((fabs(dthe) < m_gammaThetaCut) && (fabs(dphi)<m_gammaPhiCut) ) continue;
206 //
207 // good photon cut will be set here
208 //
209 iGam.push_back( ( *itTrk )->trackId() );
210 }
211
212 //
213 // Finish Good Photon Selection
214 //
215 int nGam = iGam.size();
216
217 log << MSG::DEBUG << "num Good Photon " << nGam << " , " << evtRecEvent->totalNeutral()
218 << endmsg;
219 if ( nGam < 2 ) { return StatusCode::SUCCESS; }
220
221 // Vertex Fit
222
223 // Kinamatic Fit
224
225 // finale selection
226
227 m_tuple->write().ignore();
228
229 ////////////////////////////////////////////////////////////
230 // DQA
231 // set tag and quality
232
233 // Pid: 1 - electron, 2 - muon, 3 - pion, 4 - kaon, 5 - proton
234
235 ( *( evtRecTrkCol->begin() + ipip[0] ) )->setPartId( 2 );
236 ( *( evtRecTrkCol->begin() + ipim[0] ) )->setPartId( 2 );
237 // Quality: defined by whether dE/dx or TOF is used to identify particle
238 // 0 - no dE/dx, no TOF (can be used for dE/dx and TOF calibration)
239 // 1 - only dE/dx (can be used for TOF calibration)
240 // 2 - only TOF (can be used for dE/dx calibration)
241 // 3 - Both dE/dx and TOF
242 ( *( evtRecTrkCol->begin() + ipip[0] ) )->setQuality( 0 );
243 ( *( evtRecTrkCol->begin() + ipim[0] ) )->setQuality( 0 );
244
245 // DQA
246 // Add the line below at the end of execute(), (before return)
247 //
248 setFilterPassed( true );
249 ////////////////////////////////////////////////////////////
250
251 return StatusCode::SUCCESS;
252}
EvtRecTrackCol::iterator EvtRecTrackIterator
double pi
std::vector< HepLorentzVector > Vp4
Definition Gam4pikp.cxx:38
std::vector< int > Vint
Definition Gam4pikp.cxx:37
IMessageSvc * msgSvc()
const HepVector helix() const
......
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0

◆ finalize()

StatusCode EvtSelExample::finalize ( )

Definition at line 255 of file EvtSelExample.cxx.

255 {
256
257 MsgStream log( msgSvc(), name() );
258 log << MSG::INFO << "in finalize()" << endmsg;
259 return StatusCode::SUCCESS;
260}

◆ initialize()

StatusCode EvtSelExample::initialize ( )

Definition at line 59 of file EvtSelExample.cxx.

59 {
60 MsgStream log( msgSvc(), name() );
61
62 log << MSG::INFO << "in initialize()" << endmsg;
63 StatusCode status;
64
65 // DQA
66 // The first directory specifier must be "DQAFILE"
67 // The second is the control sample name, the first letter is in upper format. eg. "Rhopi"
68 NTuplePtr nt( ntupleSvc(), "DQAFILE/Rhopi" );
69 if ( nt ) m_tuple = nt;
70 else
71 {
72 m_tuple = ntupleSvc()->book( "DQAFILE/Rhopi", CLID_ColumnWiseTuple, "Rhopi ntuple" );
73 if ( m_tuple )
74 {
75 status = m_tuple->addItem( "runNo", m_runNo );
76 status = m_tuple->addItem( "event", m_event );
77 }
78 else { log << MSG::ERROR << "Can not book N-tuple:" << long( m_tuple ) << endmsg; }
79 }
80
81 log << MSG::INFO << "successfully return from initialize()" << endmsg;
82 return StatusCode::SUCCESS;
83}
INTupleSvc * ntupleSvc()

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