BOSS 6.6.4.p01
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 15 of file inclkstar.h.

Constructor & Destructor Documentation

◆ inclkstar()

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

Definition at line 61 of file inclkstar.cxx.

61 :
62 Algorithm(name, pSvcLocator) {
63
64 m_tuple2 = 0;
65 for(int i = 0; i < 10; i++) m_pass[i] = 0;
66
67//Declare the properties
68 //Declare the properties
69 declareProperty("Vr0cut", m_vr0cut=5.0);
70 declareProperty("Vz0cut", m_vz0cut=10.0);
71 declareProperty("CheckDedx", m_checkDedx = 1);
72 declareProperty("CheckTof", m_checkTof = 1);
73}

Member Function Documentation

◆ execute()

StatusCode inclkstar::execute ( )

Definition at line 129 of file inclkstar.cxx.

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

◆ finalize()

StatusCode inclkstar::finalize ( )

Definition at line 352 of file inclkstar.cxx.

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

◆ initialize()

StatusCode inclkstar::initialize ( )

Definition at line 76 of file inclkstar.cxx.

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

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