BOSS 7.0.3
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"
13#include "EvtRecEvent/EvtRecEvent.h"
14#include "EvtRecEvent/EvtRecTrack.h"
15#include "EvtRecEvent/EvtRecVeeVertex.h"
16#include "EventModel/EventHeader.h"
17#include "EventModel/Event.h"
18#include "EventModel/EventModel.h"
19#include "McTruth/McParticle.h"
20#include "ParticleID/ParticleID.h"
21#include "VertexFit/VertexFit.h"
22#include "VertexFit/SecondVertexFit.h"
23#include "VeeVertexAlg/KShortReconstruction.h"
24#include <vector>
25
26typedef std::vector<int> Vint;
27const double mpi = 0.13957;
28//*******************************************************************************************
29KShortReconstruction::KShortReconstruction(const std::string& name, ISvcLocator* pSvcLocator):
30Algorithm(name, pSvcLocator) {
31 //Declare the properties
32
33 declareProperty("Vz0Cut", m_vzCut = 20.0);
34 declareProperty("CosThetaCut", m_cosThetaCut=0.93);
35 declareProperty("ChisqCut", m_chisqCut = 100.0);
36 /*
37 declareProperty("PidUseDedx", m_useDedx = true);
38 declareProperty("PidUseTof1", m_useTof1 = true);
39 declareProperty("PidUseTof2", m_useTof2 = true);
40 declareProperty("PidUseTofE", m_useTofE = false);
41 declareProperty("PidUseTofQ", m_useTofQ = false);
42 declareProperty("PidUseEmc", m_useEmc = false);
43 declareProperty("PidProbCut", m_PidProbCut= 0.001);
44 declareProperty("MassRangeLower", m_massRangeLower = 0.45);
45 declareProperty("MassRangeHigher", m_massRangeHigher = 0.55);
46 */
47}
48
49//******************************************************************************************
51 MsgStream log(msgSvc(), name());
52 log << MSG::INFO << "in initialize()" <<endreq;
53
54 return StatusCode::SUCCESS;
55}
56
57//********************************************************************************************
59 MsgStream log(msgSvc(), name());
60 log << MSG::INFO << "in finalize()" << endreq;
61
62 return StatusCode::SUCCESS;
63}
64
65StatusCode KShortReconstruction::registerEvtRecVeeVertexCol(
66 EvtRecVeeVertexCol* aNewEvtRecVeeVertexCol, MsgStream& log) {
67 StatusCode sc = eventSvc()->registerObject("/Event/EvtRec/EvtRecVeeVertexCol",
68 aNewEvtRecVeeVertexCol);
69 if (sc != StatusCode::SUCCESS) {
70 log << MSG::FATAL << "Could not register EvtRecVeeVertexCol in TDS!" << endreq;
71 }
72 return sc;
73}
74
75//*********************************************************************************************
77 MsgStream log(msgSvc(), name());
78 log << MSG::INFO << "in execute()" << endreq;
79
80 StatusCode sc;
81
82 //////////////////
83 // Read REC data
84 /////////////////
85 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
86 SmartDataPtr<EvtRecEvent> recEvent(eventSvc(), EventModel::EvtRec::EvtRecEvent);
87 SmartDataPtr<EvtRecTrackCol> recTrackCol(eventSvc(), EventModel::EvtRec::EvtRecTrackCol);
88 log << MSG::DEBUG << "run and event = " << eventHeader->runNumber()
89 << " " << eventHeader->eventNumber() << endreq;
90 log << MSG::DEBUG <<"ncharg, nneu, tottks = "
91 << recEvent->totalCharged() << " , "
92 << recEvent->totalNeutral() << " , "
93 << recEvent->totalTracks() <<endreq;
94 int evtNo = eventHeader->eventNumber();
95 //if (eventHeader->eventNumber() % 1000 == 0) {
96 // cout << "Event number = " << evtNo << endl;
97 //}
98
99 SmartDataPtr<EvtRecVeeVertexCol> veeVertexCol(eventSvc(),
101 if (!veeVertexCol) {
102 veeVertexCol = new EvtRecVeeVertexCol;
103 sc = registerEvtRecVeeVertexCol(veeVertexCol, log);
104 if (sc != StatusCode::SUCCESS) {
105 return sc;
106 }
107 }
108
109 //////////////////////////////////////////////
110 // No PID : identify positive and negative
111 ///////////////////////////////////////////////
112 Vint ipip, ipim, iGood;
113 for (unsigned int i = 0; i < recEvent->totalCharged(); i++) {
114 EvtRecTrackIterator itTrk = recTrackCol->begin() + i;
115// EvtRecTrack* track = *itTrk;
116 if(!(*itTrk)->isMdcTrackValid()) continue;
117 if(!(*itTrk)->isMdcKalTrackValid()) continue;
118 RecMdcTrack* mdcTrk = (*itTrk)->mdcTrack();
119 if (fabs(cos(mdcTrk->theta())) >= m_cosThetaCut) continue;
120 if (fabs(mdcTrk->z()) >= m_vzCut) continue;
121 iGood.push_back(i);
122 if (mdcTrk->charge() > 0) ipip.push_back(i);
123 if (mdcTrk->charge() < 0) ipim.push_back(i);
124 }
125 // Cut on good charged tracks
126 //if (iGood.size() < 2) return StatusCode::SUCCESS;
127 if (ipip.size() < 1 || ipim.size() < 1) return StatusCode::SUCCESS;
128
129 ///////////////////////////////////
130 // Vertex Fit
131 //////////////////////////////////
132 HepPoint3D vx(0., 0., 0.);
133 HepSymMatrix Evx(3, 0);
134 double bx = 1E+6;
135 double by = 1E+6;
136 double bz = 1E+6;
137 Evx[0][0] = bx*bx;
138 Evx[1][1] = by*by;
139 Evx[2][2] = bz*bz;
140 VertexParameter vxpar;
141 vxpar.setVx(vx);
142 vxpar.setEvx(Evx);
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 vtxfit0->init();
159 vtxfit0->AddTrack(0, wpiptrk);
160 vtxfit0->AddTrack(1, wpimtrk);
161 vtxfit0->AddVertex(0, vxpar, 0, 1);
162 if(!(vtxfit0->Fit(0))) continue;
163 vtxfit0->BuildVirtualParticle(0);
164 if(vtxfit0->chisq(0) > m_chisqCut) continue;
165 WTrackParameter wKshort = vtxfit0->wVirtualTrack(0); //FIXME
166 std::pair<int, int> pair;
167 pair.first = 3;
168 pair.second = 3;
169
170 EvtRecTrack* track0 = *(recTrackCol->begin() + ip1);
171 EvtRecTrack* track1 = *(recTrackCol->begin() + ip2);
172
173 EvtRecVeeVertex* KsVertex = new EvtRecVeeVertex;
174 KsVertex->setVertexId(310);
175 KsVertex->setVertexType(0);
176 KsVertex->setChi2(vtxfit0->chisq(0));
177 KsVertex->setNdof(1);
178 KsVertex->setMass(wKshort.p().m());
179 KsVertex->setW(wKshort.w());
180 KsVertex->setEw(wKshort.Ew());
181 KsVertex->setPair(pair);
182 KsVertex->setNCharge(0);
183 KsVertex->setNTracks(2);
184 KsVertex->addDaughter(track0, 0);
185 KsVertex->addDaughter(track1, 1);
186 veeVertexCol->push_back(KsVertex);
187 /*
188 cout << "============= After Vertex fitting ===========" << endl;
189 cout << "Event number = " << evtNo << endl;
190 cout << "chi2 = " << vtxfit0->chisq(0) << endl;
191 cout << "mass = " << wKshort.p().m() << endl;
192 cout << "w = " << wKshort.w() << endl;
193 cout << "Ew = " << wKshort.Ew() << endl;
194 cout << "track 0 : Z : " << track0->mdcTrack()->z() << endl;
195 cout << "track 1 : Z : " << track1->mdcTrack()->z() << endl; */
196 }
197 }
198
199 return StatusCode::SUCCESS;
200}
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 mpi
std::vector< int > Vint
void addDaughter(const SmartRef< EvtRecTrack > &track, int i)
KShortReconstruction(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