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