BOSS 7.0.8
BESIII Offline Software System
Loading...
Searching...
No Matches
inclphi Class Reference

#include <inclphi.h>

+ Inheritance diagram for inclphi:

Public Member Functions

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

Detailed Description

Definition at line 15 of file inclphi.h.

Constructor & Destructor Documentation

◆ inclphi()

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

Definition at line 59 of file inclphi.cxx.

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

Member Function Documentation

◆ execute()

StatusCode inclphi::execute ( )

Definition at line 136 of file inclphi.cxx.

136 {
137 StatusCode sc = StatusCode::SUCCESS;
138
139 MsgStream log(msgSvc(), name());
140 log << MSG::INFO << "in execute()" << endreq;
141
142 // DQA
143 // Add the line below at the beginning of execute()
144 //
145 setFilterPassed(false);
146
147 m_pass[0] += 1;
148
149 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
150 int run=eventHeader->runNumber();
151 int event=eventHeader->eventNumber();
152
153 SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc(), EventModel::EvtRec::EvtRecEvent);
154 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol(eventSvc(), EventModel::EvtRec::EvtRecTrackCol);
155
156 m_pass[1] += 1;
157
158 Vint ikp, ikm, iGood;
159 iGood.clear();
160 ikp.clear();
161 ikm.clear();
162
163 Vp4 pkp, pkm;
164 pkp.clear();
165 pkm.clear();
166
167 int TotCharge = 0;
168 for(int i = 0; i < evtRecEvent->totalCharged(); i++){
169 EvtRecTrackIterator itTrk=evtRecTrkCol->begin() + i;
170 if(!(*itTrk)->isMdcTrackValid()) continue;
171 RecMdcTrack *mdcTrk = (*itTrk)->mdcTrack();
172 if(fabs(mdcTrk->z()) >= m_vz0cut) continue;
173 if(mdcTrk->r() >= m_vr0cut) continue;
174 iGood.push_back(i);
175 TotCharge += mdcTrk->charge();
176 }
177 //
178 // Finish Good Charged Track Selection
179 //
180 int nGood = iGood.size();
181
182 //
183 // Charge track number cut
184 //
185
186 if((nGood < 2) || (TotCharge!=0)) return sc;
187
188 m_pass[2] += 1;
189
190 //
191 // Assign 4-momentum to each charged track
192 //
194 for(int i = 0; i < nGood; i++) {
195 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + iGood[i];
196 // if(pid) delete pid;
197 pid->init();
198 pid->setMethod(pid->methodProbability());
199 pid->setChiMinCut(4);
200 pid->setRecTrack(*itTrk);
201 pid->usePidSys(pid->useDedx() | pid->useTof1() | pid->useTof2()); // use PID sub-system
202 pid->identify(pid->onlyPion() | pid->onlyKaon()); // seperater Pion/Kaon
203 pid->calculate();
204 if(!(pid->IsPidInfoValid())) continue;
205 if(!(*itTrk)->isMdcKalTrackValid()) continue ;
206 RecMdcKalTrack* mdcKalTrk = (*itTrk)->mdcKalTrack();
207// RecMdcTrack* mdcTrk = (*itTrk)->mdcTrack();
208
209 if(pid->probKaon() < 0.001 || (pid->probKaon() < pid->probPion())) continue;
210// if(pid->probPion() < 0.001) continue;
212 HepLorentzVector ptrk;
213 ptrk.setPx(mdcKalTrk->px());
214 ptrk.setPy(mdcKalTrk->py());
215 ptrk.setPz(mdcKalTrk->pz());
216 double p3 = ptrk.mag();
217 ptrk.setE(sqrt(p3*p3+mk*mk));
218 if(mdcKalTrk->charge() >0) {
219 ikp.push_back(iGood[i]);
220 pkp.push_back(ptrk);
221 } else {
222 ikm.push_back(iGood[i]);
223 pkm.push_back(ptrk);
224 }
225 }
226
227 m_pass[4] += 1;
228 int nkp = ikp.size();
229 int nkm = ikm.size();
230
231 m_nkp=nkp;
232 m_nkm=nkm;
233 m_ncharge=nGood;
234
235
236 if(nkp < 1 || nkm <1) return sc;
237
238 m_pass[5] += 1;
239
240//
241//**************** Phi Finding ************
242//
243//
244
245 HepLorentzVector pphi, pTot;
246 Vint iphi;
247 iphi.clear();
248
249 double difchi0=99999.0;
250 int ixk1 = -1;
251 int ixk2 = -1;
252
253 for (int i = 0; i < nkm; i++) {
254 for (int j = 0; j < nkp; j++) {
255
256 pphi = pkm[i] + pkp[j];
257 m_mphiall = pphi.m();
258 m_pphiall = pphi.rho();
259 m_tuple1->write();
260
261 double difchi =fabs(pphi.m()-mphi);
262 if(difchi < difchi0){
263 difchi0 = difchi;
264 ixk1 = i;
265 ixk2 = j;
266 } //good phi
267 } //K+
268 } //K-
269
270 m_difchi = difchi0;
271
272 if (ixk1 == -1) return sc;
273
274 m_pass[6] += 1;
275
276 pTot = pkm[ixk1] + pkp[ixk2];
277
278 m_pk1 = pkm[ixk1].m();
279 m_mphi = pTot.m();
280 m_pphi = pTot.rho();
281
282 TH1 *h(0);
283 if (m_thsvc->getHist("/DQAHist/InclPhi/InclPhi_mass", h).isSuccess()) {
284 h->Fill(pTot.m());
285 } else {
286 log << MSG::ERROR << "Couldn't retrieve inclphi_mass" << endreq;
287 }
288 m_tuple2->write();
289////////////////////////////////////
290//DQA
291// set tag and quality
292 // Pid: 1 - electron, 2 - muon, 3 - pion, 4 - kaon, 5 - proton
293// (*(evtRecTrkCol->begin()+ikm[ixk1]))->setPartId(4);
294// (*(evtRecTrkCol->begin()+ikp[ixk2]))->setPartId(4);
295 (*(evtRecTrkCol->begin()+ikm[ixk1]))->tagKaon();
296 (*(evtRecTrkCol->begin()+ikp[ixk2]))->tagKaon();
297 // Quality: defined by whether dE/dx or TOF is used to identify particle
298 // 0 - no dE/dx, no TOF (can be used for dE/dx and TOF calibration)
299 // 1 - only dE/dx (can be used for TOF calibration)
300 // 2 - only TOF (can be used for dE/dx calibration)
301 // 3 - Both dE/dx and TOF
302 (*(evtRecTrkCol->begin()+ikm[ixk1]))->setQuality(3);
303 (*(evtRecTrkCol->begin()+ikp[ixk2]))->setQuality(3);
304//--------------------------------------------------
305 // Add the line below at the end of execute(), (before return)
306 //
307 setFilterPassed(true);
308
309 return StatusCode::SUCCESS;
310}
EvtRecTrackCol::iterator EvtRecTrackIterator
Definition: EvtRecTrack.h:111
std::vector< HepLorentzVector > Vp4
Definition: Gam4pikp.cxx:53
const double mk
Definition: Gam4pikp.cxx:48
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:97
void init()
Definition: ParticleID.cxx:27
const double mphi
Definition: inclphi.cxx:44
_EXTERN_ std::string EvtRecEvent
Definition: EventModel.h:116
_EXTERN_ std::string EvtRecTrackCol
Definition: EventModel.h:117
float ptrk

◆ finalize()

StatusCode inclphi::finalize ( )

Definition at line 313 of file inclphi.cxx.

313 {
314
315 MsgStream log(msgSvc(), name());
316 log << MSG::INFO << "in finalize()" << endmsg;
317 log << MSG::INFO << "Total Entries : " << m_pass[0] << endreq;
318 log << MSG::INFO << "dstCol, trkCol: " << m_pass[1] << endreq;
319 log << MSG::INFO << "Ncharge Cut : " << m_pass[2] << endreq;
320 log << MSG::INFO << "TOF dEdx : " << m_pass[3] << endreq;
321 log << MSG::INFO << "PID : " << m_pass[4] << endreq;
322 log << MSG::INFO << "NK Cut : " << m_pass[5] << endreq;
323 log << MSG::INFO << "Nphi select : " << m_pass[6] << endreq;
324 return StatusCode::SUCCESS;
325}

◆ initialize()

StatusCode inclphi::initialize ( )

Definition at line 74 of file inclphi.cxx.

74 {
75 MsgStream log(msgSvc(), name());
76
77 log << MSG::INFO << "in initialize()" << endmsg;
78
79 StatusCode status;
80
81 if(service("THistSvc", m_thsvc).isFailure()) {
82 log << MSG::ERROR << "Couldn't get THistSvc" << endreq;
83 return StatusCode::FAILURE;
84 }
85 // "DQAHist" is fixed
86 TH1F* inclphi_mass = new TH1F("InclPhi_mass","INCLUSIVE_PHI_MASS",80,1.01,1.05);
87 inclphi_mass->GetXaxis()->SetTitle("M_{KK} (GeV)");
88 inclphi_mass->GetYaxis()->SetTitle("Nentries/0.5MeV/c^{2}");
89 if(m_thsvc->regHist("/DQAHist/InclPhi/InclPhi_mass", inclphi_mass).isFailure()) {
90 log << MSG::ERROR << "Couldn't register inclphi_mass" << endreq;
91 }
92
93//*****************************************
94
95 NTuplePtr nt1(ntupleSvc(), "DQAFILE/InclPhi");
96 if ( nt1 ) m_tuple1 = nt1;
97 else {
98 m_tuple1 = ntupleSvc()->book ("DQAFILE/InclPhi1", CLID_ColumnWiseTuple, "inclphi Ntuple");
99 if ( m_tuple1 ) {
100 status = m_tuple1->addItem ("mphiall", m_mphiall);
101 status = m_tuple1->addItem ("mpphiall", m_pphiall);
102 }
103 else {
104 log << MSG::ERROR << " Cannot book N-tuple:" << long(m_tuple1) << endmsg;
105 return StatusCode::FAILURE;
106 }
107 }
108 NTuplePtr nt2(ntupleSvc(), "DQAFILE/InclPhi2");
109 if ( nt2 ) m_tuple2 = nt2;
110 else {
111 m_tuple2 = ntupleSvc()->book ("DQAFILE/InclPhi2", CLID_ColumnWiseTuple, "inclphi Ntuple");
112 if ( m_tuple2 ) {
113 status = m_tuple2->addItem ("nkp", m_nkp);
114 status = m_tuple2->addItem ("nkm", m_nkm);
115 status = m_tuple2->addItem ("ncharge", m_ncharge);
116 status = m_tuple2->addItem ("difchi0", m_difchi);
117 status = m_tuple2->addItem ("mmphi", m_mphi);
118 status = m_tuple2->addItem ("pphi", m_pphi);
119 status = m_tuple2->addItem ("pk1", m_pk1);
120 }
121 else {
122 log << MSG::ERROR << " Cannot book N-tuple:" << long(m_tuple2) << endmsg;
123 return StatusCode::FAILURE;
124 }
125 }
126 //
127 //--------end of book--------
128 //
129
130 log << MSG::INFO << "successfully return from initialize()" <<endmsg;
131 return StatusCode::SUCCESS;
132
133}
INTupleSvc * ntupleSvc()

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