BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
inclkstar Class Reference

#include <inclkstar.h>

Inheritance diagram for inclkstar:

Public Member Functions

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

Detailed Description

Definition at line 9 of file inclkstar.h.

Constructor & Destructor Documentation

◆ inclkstar()

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

Definition at line 45 of file inclkstar.cxx.

46 : Algorithm( name, pSvcLocator ) {
47
48 m_tuple2 = 0;
49 for ( int i = 0; i < 10; i++ ) m_pass[i] = 0;
50
51 // Declare the properties
52 // Declare the properties
53 declareProperty( "Vr0cut", m_vr0cut = 5.0 );
54 declareProperty( "Vz0cut", m_vz0cut = 10.0 );
55 declareProperty( "CheckDedx", m_checkDedx = 1 );
56 declareProperty( "CheckTof", m_checkTof = 1 );
57}

Referenced by inclkstar().

Member Function Documentation

◆ execute()

StatusCode inclkstar::execute ( )

Definition at line 116 of file inclkstar.cxx.

116 {
117 StatusCode sc = StatusCode::SUCCESS;
118
119 MsgStream log( msgSvc(), name() );
120 log << MSG::INFO << "in execute()" << endmsg;
121
122 // DQA
123 // Add the line below at the beginning of execute()
124 //
125 setFilterPassed( false );
126
127 m_pass[0] += 1;
128
129 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
130 SmartDataPtr<EvtRecEvent> evtRecEvent( eventSvc(), EventModel::EvtRec::EvtRecEvent );
131 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol( eventSvc(), EventModel::EvtRec::EvtRecTrackCol );
132
133 Vint iGood, ikm, ikp, ipip, ipim, iGam;
134 iGood.clear();
135 ikm.clear();
136 ikp.clear();
137 ipip.clear();
138 ipim.clear();
139 iGam.clear();
140
141 Vp4 ppip, ppim, pkm, pkp;
142 ppip.clear();
143 ppim.clear();
144 pkm.clear();
145 pkp.clear();
146
147 int TotCharge = 0;
148 for ( int i = 0; i < evtRecEvent->totalCharged(); i++ )
149 {
150 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
151 if ( !( *itTrk )->isMdcTrackValid() ) continue;
152 RecMdcTrack* mdcTrk = ( *itTrk )->mdcTrack();
153 if ( fabs( mdcTrk->z() ) >= m_vz0cut ) continue;
154 if ( mdcTrk->r() >= m_vr0cut ) continue;
155 iGood.push_back( i );
156 TotCharge += mdcTrk->charge();
157 }
158 //
159 // Finish Good Charged Track Selection
160 //
161 int nGood = iGood.size();
162
163 //
164 // Charge track number cut
165 //
166
167 if ( ( nGood < 2 ) || ( TotCharge != 0 ) ) return sc;
168
169 m_pass[1] += 1;
170
171 //
172 // Assign 4-momentum to each charged track
173 //
174 ParticleID* pid = ParticleID::instance();
175 for ( int i = 0; i < nGood; i++ )
176 {
177 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + iGood[i];
178 // if(pid) delete pid;
179 pid->init();
180 pid->setMethod( pid->methodProbability() );
181 pid->setChiMinCut( 4 );
182 pid->setRecTrack( *itTrk );
183 pid->usePidSys( pid->useDedx() | pid->useTof1() | pid->useTof2() ); // use PID sub-system
184 pid->identify( pid->onlyPion() | pid->onlyKaon() ); // seperater Pion/Kaon
185 // pid->identify(pid->onlyPion());
186 // pid->identify(pid->onlyKaon());
187 pid->calculate();
188 if ( !( pid->IsPidInfoValid() ) ) continue;
189 // RecMdcTrack* mdcTrk = (*itTrk)->mdcTrack();
190 if ( !( *itTrk )->isMdcKalTrackValid() ) continue;
191 RecMdcKalTrack* mdcKalTrk = ( *itTrk )->mdcKalTrack();
192 if ( pid->probKaon() > 0.001 && ( pid->probKaon() > pid->probPion() ) )
193 {
194 mdcKalTrk->setPidType( RecMdcKalTrack::kaon );
195 HepLorentzVector ptrk;
196 ptrk.setPx( mdcKalTrk->px() );
197 ptrk.setPy( mdcKalTrk->py() );
198 ptrk.setPz( mdcKalTrk->pz() );
199 double p3 = ptrk.mag();
200 ptrk.setE( sqrt( p3 * p3 + mk * mk ) );
201 if ( mdcKalTrk->charge() > 0 )
202 {
203 ikp.push_back( iGood[i] );
204 pkp.push_back( ptrk );
205 }
206 else
207 {
208 ikm.push_back( iGood[i] );
209 pkm.push_back( ptrk );
210 }
211 }
212
213 if ( pid->probPion() > 0.001 && ( pid->probPion() > pid->probKaon() ) )
214 {
215 mdcKalTrk->setPidType( RecMdcKalTrack::pion );
216 HepLorentzVector ptrk;
217 ptrk.setPx( mdcKalTrk->px() );
218 ptrk.setPy( mdcKalTrk->py() );
219 ptrk.setPz( mdcKalTrk->pz() );
220 double p3 = ptrk.mag();
221 ptrk.setE( sqrt( p3 * p3 + mpi * mpi ) );
222 if ( mdcKalTrk->charge() > 0 )
223 {
224 ipip.push_back( iGood[i] );
225 ppip.push_back( ptrk );
226 }
227 else
228 {
229 ipim.push_back( iGood[i] );
230 ppim.push_back( ptrk );
231 }
232 }
233 }
234 int npip = ipip.size();
235 int npim = ipim.size();
236 int nkm = ikm.size();
237 int nkp = ikp.size();
238
239 m_nkm = nkm;
240 m_nkp = nkp;
241 m_npip = npip;
242 m_npim = npim;
243 m_ncharge = nGood;
244 m_pass[3] += 1;
245
246 if ( npip < 1 && npim < 1 ) return sc;
247 if ( nkp < 1 && nkm < 1 ) return sc;
248
249 m_pass[4] += 1;
250
251 //
252 //**************** Kstar Finding ************
253 //
254 //
255 HepLorentzVector pkstar, pkstar1, ppi1, ppi2, pTot;
256 Vint ikstar;
257 ikstar.clear();
258
259 double difchi0 = 99999.0;
260 int ixpim = -1;
261 int ixkp = -1;
262
263 for ( int i = 0; i < npim; i++ )
264 {
265 for ( int j = 0; j < nkp; j++ )
266 {
267 pkstar = ppim[i] + pkp[j];
268 double difchi = fabs( pkstar.m() - mkstar0 );
269 if ( difchi < difchi0 )
270 {
271 difchi0 = difchi;
272 ixpim = i;
273 ixkp = j;
274 } // good kstar
275 } // K+
276 } // pi-
277
278 m_difchikp = difchi0;
279
280 if ( ixpim != -1 ) m_kstarkp = ( ppim[ixpim] + pkp[ixkp] ).m();
281
282 double difchi1 = 99999.0;
283 int ixpip = -1;
284 int ixkm = -1;
285
286 for ( int ii = 0; ii < npip; ii++ )
287 {
288 for ( int jj = 0; jj < nkm; jj++ )
289 {
290 pkstar1 = ppip[ii] + pkm[jj];
291 double difchi2 = fabs( pkstar1.m() - mkstar0 );
292 if ( difchi2 < difchi1 )
293 {
294 difchi1 = difchi2;
295 ixpip = ii;
296 ixkm = jj;
297 } // good kstar
298 } // K-
299 } // pi+
300
301 m_difchikm = difchi1;
302
303 if ( ixpip != -1 ) m_kstarkm = ( ppip[ixpip] + pkm[ixkm] ).m();
304
305 // cout << "m_kstarkm==========" << m_kstarkm <<endl;
306 if ( ixpip == -1 && ixpim == -1 ) return sc;
307
308 if ( difchi0 < difchi1 ) { pTot = ppim[ixpim] + pkp[ixkp]; }
309 else { pTot = ppip[ixpip] + pkm[ixkm]; }
310 m_mkstar = pTot.m();
311 m_pkstar = pTot.rho();
312
313 // DQA
314 TH1* h( 0 );
315 if ( m_thsvc->getHist( "/DQAHist/InclKstar/InclKstar_mass", h ).isSuccess() )
316 { h->Fill( m_mkstar ); }
317 else { log << MSG::ERROR << "Couldn't retrieve InclKstar_mass" << endmsg; }
318
319 m_tuple2->write().ignore();
320 ////////////////////////////////////
321 // DQA
322
323 if ( ixpim != -1 )
324 {
325 // (*(evtRecTrkCol->begin()+ipim[ixpim]))->setPartId(3);
326 // (*(evtRecTrkCol->begin()+ikp[ixkp]))->setPartId(4);
327 ( *( evtRecTrkCol->begin() + ipim[ixpim] ) )->tagPion();
328 ( *( evtRecTrkCol->begin() + ikp[ixkp] ) )->tagKaon();
329 ( *( evtRecTrkCol->begin() + ipim[ixpim] ) )->setQuality( 3 );
330 ( *( evtRecTrkCol->begin() + ikp[ixkp] ) )->setQuality( 3 );
331 }
332 else
333 {
334 // (*(evtRecTrkCol->begin()+ipip[ixpip]))->setPartId(3);
335 // (*(evtRecTrkCol->begin()+ikm[ixkm]))->setPartId(4);
336 ( *( evtRecTrkCol->begin() + ipip[ixpip] ) )->tagPion();
337 ( *( evtRecTrkCol->begin() + ikm[ixkm] ) )->tagKaon();
338 ( *( evtRecTrkCol->begin() + ipip[ixpip] ) )->setQuality( 3 );
339 ( *( evtRecTrkCol->begin() + ikm[ixkm] ) )->setQuality( 3 );
340 }
341 //--------------------------------------------------
342 // Add the line below at the end of execute(), (before return)
343 //
344 setFilterPassed( true );
345
346 return StatusCode::SUCCESS;
347}
EvtRecTrackCol::iterator EvtRecTrackIterator
double mpi
std::vector< HepLorentzVector > Vp4
Definition Gam4pikp.cxx:38
const double mk
Definition Gam4pikp.cxx:33
std::vector< int > Vint
Definition Gam4pikp.cxx:37
IMessageSvc * msgSvc()
static ParticleID * instance()
bool IsPidInfoValid() const
void calculate()
void init()
const double mkstar0
Definition inclkstar.cxx:29

◆ finalize()

StatusCode inclkstar::finalize ( )

Definition at line 350 of file inclkstar.cxx.

350 {
351
352 MsgStream log( msgSvc(), name() );
353 log << MSG::INFO << "in finalize()" << endmsg;
354 log << MSG::INFO << "Total Entries : " << m_pass[0] << endmsg;
355 log << MSG::INFO << "TOF,dEdx: " << m_pass[1] << endmsg;
356 log << MSG::INFO << "Ncharge Cut : " << m_pass[2] << endmsg;
357 log << MSG::INFO << "PID : " << m_pass[3] << endmsg;
358 log << MSG::INFO << "Npi and Nk Cut : " << m_pass[4] << endmsg;
359 return StatusCode::SUCCESS;
360}

◆ initialize()

StatusCode inclkstar::initialize ( )

Definition at line 60 of file inclkstar.cxx.

60 {
61 MsgStream log( msgSvc(), name() );
62
63 log << MSG::INFO << "in initialize()" << endmsg;
64
65 StatusCode status;
66
67 if ( service( "THistSvc", m_thsvc ).isFailure() )
68 {
69 log << MSG::ERROR << "Couldn't get THistSvc" << endmsg;
70 return StatusCode::FAILURE;
71 }
72 // "DQAHist" is fixed
73 TH1F* inclkstar_mass = new TH1F( "InclKstar_mass", "INCLUSIVE_Kstar_MASS", 65, 0.65, 1.3 );
74 inclkstar_mass->GetXaxis()->SetTitle( "M_{K#pi} (GeV)" );
75 inclkstar_mass->GetYaxis()->SetTitle( "Nentries/10MeV/c^{2}" );
76
77 if ( m_thsvc->regHist( "/DQAHist/InclKstar/InclKstar_mass", inclkstar_mass ).isFailure() )
78 { log << MSG::ERROR << "Couldn't register InclKstar_mass" << endmsg; }
79
80 //*****************************************
81 NTuplePtr nt2( ntupleSvc(), "DQAFILE/InclKstar" );
82 if ( nt2 ) m_tuple2 = nt2;
83 else
84 {
85 m_tuple2 =
86 ntupleSvc()->book( "DQAFILE/InclKstar", CLID_ColumnWiseTuple, "inclkstar Ntuple" );
87 if ( m_tuple2 )
88 {
89 status = m_tuple2->addItem( "nkaonm", m_nkm );
90 status = m_tuple2->addItem( "nkaonp", m_nkp );
91 status = m_tuple2->addItem( "npionp", m_npip );
92 status = m_tuple2->addItem( "npionm", m_npim );
93 status = m_tuple2->addItem( "ncharge", m_ncharge );
94 status = m_tuple2->addItem( "difchikp", m_difchikp );
95 status = m_tuple2->addItem( "difchikm", m_difchikm );
96 status = m_tuple2->addItem( "mkstarkp", m_kstarkp );
97 status = m_tuple2->addItem( "mkstarkm", m_kstarkm );
98 status = m_tuple2->addItem( "mkstar", m_mkstar );
99 status = m_tuple2->addItem( "pkstar", m_pkstar );
100 }
101 else
102 {
103 log << MSG::ERROR << " Cannot book N-tuple:" << long( m_tuple2 ) << endmsg;
104 return StatusCode::FAILURE;
105 }
106 }
107 //
108 //--------end of book--------
109 //
110
111 log << MSG::INFO << "successfully return from initialize()" << endmsg;
112 return StatusCode::SUCCESS;
113}
INTupleSvc * ntupleSvc()

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