BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
KShortReconstruction.cxx
Go to the documentation of this file.
1//
2// KShortReconstruction -> pi+ pi- Reconstruction
3//
4
5#include "GaudiKernel/MsgStream.h"
6#include "GaudiKernel/AlgFactory.h"
7#include "GaudiKernel/ISvcLocator.h"
8#include "GaudiKernel/SmartDataPtr.h"
9#include "GaudiKernel/IDataProviderSvc.h"
10#include "GaudiKernel/PropertyMgr.h"
11
12#include "EventModel/Event.h"
17#include "EventModel/Event.h"
19#include "McTruth/McParticle.h"
21#include "VertexFit/VertexFit.h"
25#include <vector>
26
27typedef std::vector<int> Vint;
28const double mpi = 0.13957;
29//*******************************************************************************************
30DECLARE_COMPONENT(KShortReconstruction)
31KShortReconstruction::KShortReconstruction(const std::string& name, ISvcLocator* pSvcLocator):
32Algorithm(name, pSvcLocator) {
33 //Declare the properties
34
35 declareProperty("Vz0Cut", m_vzCut = 20.0);
36 declareProperty("CosThetaCut", m_cosThetaCut=0.93);
37 declareProperty("ChisqCut", m_chisqCut = 100.0);
38 declareProperty("UseVFRefine", m_useVFrefine = false); //Use VertexfitRefine or not
39 /*
40 declareProperty("PidUseDedx", m_useDedx = true);
41 declareProperty("PidUseTof1", m_useTof1 = true);
42 declareProperty("PidUseTof2", m_useTof2 = true);
43 declareProperty("PidUseTofE", m_useTofE = false);
44 declareProperty("PidUseTofQ", m_useTofQ = false);
45 declareProperty("PidUseEmc", m_useEmc = false);
46 declareProperty("PidProbCut", m_PidProbCut= 0.001);
47 declareProperty("MassRangeLower", m_massRangeLower = 0.45);
48 declareProperty("MassRangeHigher", m_massRangeHigher = 0.55);
49 */
50}
51
52//******************************************************************************************
54 MsgStream log(msgSvc(), name());
55 log << MSG::INFO << "in initialize()" <<endreq;
56
57 return StatusCode::SUCCESS;
58}
59
60//********************************************************************************************
62 MsgStream log(msgSvc(), name());
63 log << MSG::INFO << "in finalize()" << endreq;
64
65 return StatusCode::SUCCESS;
66}
67
68StatusCode KShortReconstruction::registerEvtRecVeeVertexCol(
69 EvtRecVeeVertexCol* aNewEvtRecVeeVertexCol, MsgStream& log) {
70 StatusCode sc = eventSvc()->registerObject("/Event/EvtRec/EvtRecVeeVertexCol",
71 aNewEvtRecVeeVertexCol);
72 if (sc != StatusCode::SUCCESS) {
73 log << MSG::FATAL << "Could not register EvtRecVeeVertexCol in TDS!" << endreq;
74 }
75 return sc;
76}
77
78//*********************************************************************************************
80 MsgStream log(msgSvc(), name());
81 log << MSG::INFO << "in execute()" << endreq;
82
83 StatusCode sc;
84
85 //////////////////
86 // Read REC data
87 /////////////////
88 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
89 SmartDataPtr<EvtRecEvent> recEvent(eventSvc(), EventModel::EvtRec::EvtRecEvent);
90 SmartDataPtr<EvtRecTrackCol> recTrackCol(eventSvc(), EventModel::EvtRec::EvtRecTrackCol);
91 log << MSG::DEBUG << "run and event = " << eventHeader->runNumber()
92 << " " << eventHeader->eventNumber() << endreq;
93 log << MSG::DEBUG <<"ncharg, nneu, tottks = "
94 << recEvent->totalCharged() << " , "
95 << recEvent->totalNeutral() << " , "
96 << recEvent->totalTracks() <<endreq;
97 int evtNo = eventHeader->eventNumber();
98 //if (eventHeader->eventNumber() % 1000 == 0) {
99 // cout << "Event number = " << evtNo << endl;
100 //}
101
102 SmartDataPtr<EvtRecVeeVertexCol> veeVertexCol(eventSvc(),
104 if (!veeVertexCol) {
105 veeVertexCol = new EvtRecVeeVertexCol;
106 sc = registerEvtRecVeeVertexCol(veeVertexCol, log);
107 if (sc != StatusCode::SUCCESS) {
108 return sc;
109 }
110 }
111
112 //////////////////////////////////////////////
113 // No PID : identify positive and negative
114 ///////////////////////////////////////////////
115 Vint ipip, ipim, iGood;
116 for (unsigned int i = 0; i < recEvent->totalCharged(); i++) {
117 EvtRecTrackIterator itTrk = recTrackCol->begin() + i;
118// EvtRecTrack* track = *itTrk;
119 if(!(*itTrk)->isMdcTrackValid()) continue;
120 if(!(*itTrk)->isMdcKalTrackValid()) continue;
121 RecMdcTrack* mdcTrk = (*itTrk)->mdcTrack();
122 if (fabs(cos(mdcTrk->theta())) >= m_cosThetaCut) continue;
123 if (fabs(mdcTrk->z()) >= m_vzCut) continue;
124 iGood.push_back(i);
125 if (mdcTrk->charge() > 0) ipip.push_back(i);
126 if (mdcTrk->charge() < 0) ipim.push_back(i);
127 }
128 // Cut on good charged tracks
129 //if (iGood.size() < 2) return StatusCode::SUCCESS;
130 if (ipip.size() < 1 || ipim.size() < 1) return StatusCode::SUCCESS;
131
132 ///////////////////////////////////
133 // Vertex Fit
134 //////////////////////////////////
135 HepPoint3D vx(0., 0., 0.);
136 HepSymMatrix Evx(3, 0);
137 double bx = 1E+6;
138 double by = 1E+6;
139 double bz = 1E+6;
140 Evx[0][0] = bx*bx;
141 Evx[1][1] = by*by;
142 Evx[2][2] = bz*bz;
143
144 //VertexFit *vtxfit0 = VertexFit::instance();
145
146 for(unsigned int i1 = 0; i1 < ipip.size(); i1++) {
147 int ip1 = ipip[i1];
148 RecMdcKalTrack *pipKalTrk = (*(recTrackCol->begin()+ip1))->mdcKalTrack();
150 WTrackParameter wpiptrk(mpi, pipKalTrk->helix(), pipKalTrk->err());
151
152 for(unsigned int i2 = 0; i2 < ipim.size(); i2++) {
153 int ip2 = ipim[i2];
154 RecMdcKalTrack *pimKalTrk = (*(recTrackCol->begin()+ip2))->mdcKalTrack();
156 WTrackParameter wpimtrk(mpi, pimKalTrk->helix(), pimKalTrk->err());
157
158 if(m_useVFrefine){
159 VertexParameter vxpar;
160 vxpar.setVx(vx);
161 vxpar.setEvx(Evx);
162
164 vtxfit0->init();
165 //vtxfit0->AddTrack(0, wpiptrk);
166 //vtxfit0->AddTrack(1, wpimtrk);
167 vtxfit0->AddTrack(0, pipKalTrk, RecMdcKalTrack::pion);
168 vtxfit0->AddTrack(1, pimKalTrk, RecMdcKalTrack::pion);
169 vtxfit0->AddVertex(0, vxpar, 0, 1);
170
171 bool fitok = vtxfit0->Fit();
172 if(!fitok) continue;
173
174 //if(!(vtxfit0->Fit(0))) continue;
175 //vtxfit0->BuildVirtualParticle(0);
176
177 if(vtxfit0->chisq(0) > m_chisqCut) continue;
178 WTrackParameter wKshort = vtxfit0->wVirtualTrack(0); //FIXME
179 std::pair<int, int> pair;
180 pair.first = 3;
181 pair.second = 3;
182
183 EvtRecTrack* track0 = *(recTrackCol->begin() + ip1);
184 EvtRecTrack* track1 = *(recTrackCol->begin() + ip2);
185
186 EvtRecVeeVertex* KsVertex = new EvtRecVeeVertex;
187 KsVertex->setVertexId(310);
188 KsVertex->setVertexType(0);
189 KsVertex->setChi2(vtxfit0->chisq(0));
190 KsVertex->setNdof(1);
191 KsVertex->setMass(wKshort.p().m());
192 KsVertex->setW(wKshort.w());
193 KsVertex->setEw(wKshort.Ew());
194 KsVertex->setPair(pair);
195 KsVertex->setNCharge(0);
196 KsVertex->setNTracks(2);
197 KsVertex->addDaughter(track0, 0);
198 KsVertex->addDaughter(track1, 1);
199 veeVertexCol->push_back(KsVertex);
200 /*
201 cout << "============= After Vertex fitting ===========" << endl;
202 cout << "Event number = " << evtNo << endl;
203 cout << "chi2 = " << vtxfit0->chisq(0) << endl;
204 cout << "mass = " << wKshort.p().m() << endl;
205 cout << "w = " << wKshort.w() << endl;
206 cout << "Ew = " << wKshort.Ew() << endl;
207 cout << "track 0 : Z : " << track0->mdcTrack()->z() << endl;
208 cout << "track 1 : Z : " << track1->mdcTrack()->z() << endl; */
209
210 }else{
211 VertexParameter vxpar;
212 vxpar.setVx(vx);
213 vxpar.setEvx(Evx);
214
215 VertexFit *vtxfit0 = VertexFit::instance();
216 vtxfit0->init();
217 vtxfit0->AddTrack(0, wpiptrk);
218 vtxfit0->AddTrack(1, wpimtrk);
219 vtxfit0->AddVertex(0, vxpar, 0, 1);
220 if(!(vtxfit0->Fit(0))) continue;
221 vtxfit0->BuildVirtualParticle(0);
222 if(vtxfit0->chisq(0) > m_chisqCut) continue;
223 WTrackParameter wKshort = vtxfit0->wVirtualTrack(0); //FIXME
224 std::pair<int, int> pair;
225 pair.first = 3;
226 pair.second = 3;
227
228 EvtRecTrack* track0 = *(recTrackCol->begin() + ip1);
229 EvtRecTrack* track1 = *(recTrackCol->begin() + ip2);
230
231 EvtRecVeeVertex* KsVertex = new EvtRecVeeVertex;
232 KsVertex->setVertexId(310);
233 KsVertex->setVertexType(0);
234 KsVertex->setChi2(vtxfit0->chisq(0));
235 KsVertex->setNdof(1);
236 KsVertex->setMass(wKshort.p().m());
237 KsVertex->setW(wKshort.w());
238 KsVertex->setEw(wKshort.Ew());
239 KsVertex->setPair(pair);
240 KsVertex->setNCharge(0);
241 KsVertex->setNTracks(2);
242 KsVertex->addDaughter(track0, 0);
243 KsVertex->addDaughter(track1, 1);
244 veeVertexCol->push_back(KsVertex);
245
246 /*
247 cout << "============= After Vertex fitting ===========" << endl;
248 cout << "Event number = " << evtNo << endl;
249 cout << "chi2 = " << vtxfit0->chisq(0) << endl;
250 cout << "mass = " << wKshort.p().m() << endl;
251 cout << "w = " << wKshort.w() << endl;
252 cout << "Ew = " << wKshort.Ew() << endl;
253 cout << "track 0 : Z : " << track0->mdcTrack()->z() << endl;
254 cout << "track 1 : Z : " << track1->mdcTrack()->z() << endl; */
255
256 }
257
258
259 }
260 }
261
262 return StatusCode::SUCCESS;
263}
double cos(const BesAngle a)
Definition: BesAngle.h:213
EvtRecTrackCol::iterator EvtRecTrackIterator
Definition: EvtRecTrack.h:111
ObjectVector< EvtRecVeeVertex > EvtRecVeeVertexCol
const double mpi
Definition: Gam4pikp.cxx:47
std::vector< int > Vint
Definition: Gam4pikp.cxx:52
const double mpi
std::vector< int > Vint
IMessageSvc * msgSvc()
const HepVector & helix() const
static void setPidType(PidType pidType)
const HepSymMatrix & err() const
const double theta() const
Definition: DstMdcTrack.h:59
const int charge() const
Definition: DstMdcTrack.h:53
const double z() const
Definition: DstMdcTrack.h:63
void setVertexType(int vtxType)
void setChi2(double chi2)
void addDaughter(const SmartRef< EvtRecTrack > &track, int i)
void setEw(const HepSymMatrix &Ew)
void setMass(double mass)
void setNdof(int ndof)
void setNTracks(int nTracks)
void setVertexId(int vtxId)
void setPair(const std::pair< int, int > &pair)
void setW(const HepVector &w)
void setNCharge(int nCharge)
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
Definition: TrackPool.cxx:22
WTrackParameter wVirtualTrack(int n) const
double chisq() const
void AddTrack(const int index, RecMdcKalTrack *p, const RecMdcKalTrack::PidType pid)
static VertexFitRefine * instance()
void AddVertex(int number, VertexParameter vpar, std::vector< int > lis)
double chisq() const
Definition: VertexFit.h:66
WTrackParameter wVirtualTrack(int n) const
Definition: VertexFit.h:92
void init()
Definition: VertexFit.cxx:29
void AddVertex(int number, VertexParameter vpar, std::vector< int > lis)
Definition: VertexFit.cxx:89
static VertexFit * instance()
Definition: VertexFit.cxx:15
void BuildVirtualParticle(int number)
Definition: VertexFit.cxx:619
bool Fit()
Definition: VertexFit.cxx:301
void setEvx(const HepSymMatrix &eVx)
void setVx(const HepPoint3D &vx)
HepLorentzVector p() const
HepVector w() const
HepSymMatrix Ew() const
_EXTERN_ std::string EvtRecEvent
Definition: EventModel.h:116
_EXTERN_ std::string EvtRecVeeVertexCol
Definition: EventModel.h:121
_EXTERN_ std::string EvtRecTrackCol
Definition: EventModel.h:117