Belle II Software development
TrackBase.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9//-----------------------------------------------------------------------------
10// Description : A class to represent a track object in TRGCDC.
11//-----------------------------------------------------------------------------
12
13#define TRGCDC_SHORT_NAMES
14
15#include "trg/trg/Debug.h"
16#include "trg/cdc/TRGCDC.h"
17#include "trg/cdc/TrackBase.h"
18#include "trg/cdc/Wire.h"
19#include "trg/cdc/Link.h"
20#include "trg/cdc/Fitter.h"
21#include "trg/cdc/Relation.h"
22
23using namespace std;
24
25namespace Belle2 {
32 : _name("CopyOf" + t._name),
33 _status(t._status),
34 _charge(t._charge),
35 _ts(0),
36 _tsAll(t._tsAll),
37 _nTs(t._nTs),
38 _fitter(t._fitter),
39 _fitted(t._fitted),
40 m_trackID(t.m_trackID)
41 {
42 _ts = new vector<TCLink*>[_nTs];
43 for (unsigned i = 0; i < _nTs; i++)
44 _ts[i].assign(t._ts[i].begin(), t._ts[i].end());
45 }
46
47 TRGCDCTrackBase::TRGCDCTrackBase(const string& name, double charge)
48 : _name(name),
49 _status(0),
50 _charge(charge),
51 _ts(0),
52 _nTs(TRGCDC::getTRGCDC()->nSuperLayers()),
53 _fitter(0),
54 _fitted(false),
55 m_trackID(9999)
56 {
57 _ts = new vector<TCLink*>[_nTs];
58 }
59
61 {
62 }
63
64 void
65 TRGCDCTrackBase::dump(const string&, const string& pre) const
66 {
67// bool detail = (cmd.find("detail") != string::npos);
68
69 string tab = TRGDebug::tab() + pre;
70 cout << tab << "Dump of " << name() << endl;
71 tab += " ";
72
73 cout << tab << "status=" << status() << ":p=" << p() << ":x=" << x()
74 << endl;
75 cout << tab;
76 for (unsigned i = 0; i < _nTs; i++) {
77 cout << i << ":" << _ts[i].size();
78 for (unsigned j = 0; j < _ts[i].size(); j++) {
79 if (j == 0)
80 cout << "(";
81 else
82 cout << ",";
83 const TCLink& l = * _ts[i][j];
84 cout << l.cell()->name();
85 }
86 if (_ts[i].size())
87 cout << "),";
88 }
89// if (detail) {
90
91// }
92 cout << endl;
93 }
94
95
96 int
98 {
99 if (_fitter) {
100 return _fitter->fit(* this);
101 } else {
102 cout << "TRGCDCTrackBase !!! no fitter available" << endl;
103 return -1;
104 }
105 }
106
107 void
109 {
110 _ts[a->cell()->superLayerId()].push_back(a);
111 _tsAll.push_back(a);
112 }
113
114 void
115 TRGCDCTrackBase::append(const vector<TRGCDCLink*>& links)
116 {
117 for (unsigned i = 0; i < links.size(); i++) {
118 append(links[i]);
119 }
120 }
121
122 const std::vector<TCLink*>&
124 {
125 return _tsAll;
126 }
127
128 const std::vector<TCLink*>&
129 TRGCDCTrackBase::links(unsigned layerId) const
130 {
131 return _ts[layerId];
132 }
133
134 int
136 {
137 cout << "TRGCDCTrackBase::approach2D !!! not implemented" << endl;
138 return -1;
139 }
140
141 const TRGCDCRelation
143 {
144
145 TRGDebug::enterStage("MCInfo");
146
147 map<unsigned, unsigned> relations;
148 for (unsigned i = 0; i < _tsAll.size(); i++) {
149
150 const TCCell& cell = * _tsAll[i]->cell();
151 const TCCHit& hit = * cell.hit();
152 const unsigned iMCParticle = hit.iMCParticle();
153
154 map<unsigned, unsigned>::iterator it = relations.find(iMCParticle);
155 if (it != relations.end())
156 ++it->second;
157 else
158 relations[iMCParticle] = 1;
159
160 if (TRGDebug::level()) {
161 cout << TRGDebug::tab() << cell.name() << ",MCParticle="
162 << iMCParticle << endl;
163 }
164 }
165
166 if (TRGDebug::level()) {
167 map<unsigned, unsigned>::const_iterator it = relations.begin();
168 while (it != relations.end()) {
169 cout << TRGDebug::tab()
170 << it->first << ","
171 << it->second << endl;
172 ++it;
173 }
174 }
175
176 TRGDebug::leaveStage("MCInfo");
177
178 return TCRelation(* this, relations);
179 }
180
181 const TRGCDCRelation
183 {
184
185 TRGDebug::enterStage("MCInfo");
186
187 map<unsigned, unsigned> relations;
188 for (unsigned i = 0; i < _tsAll.size(); i++) {
189
190
191 const TCCell& cell = * _tsAll[i]->cell();
192
193 // Ignore stereo layers
194 if (cell.superLayerId() % 2 == 1) continue;
195
196 const TCCHit& hit = * cell.hit();
197 const unsigned iMCParticle = hit.iMCParticle();
198
199 map<unsigned, unsigned>::iterator it = relations.find(iMCParticle);
200 if (it != relations.end())
201 ++it->second;
202 else
203 relations[iMCParticle] = 1;
204
205 if (TRGDebug::level()) {
206 cout << TRGDebug::tab() << cell.name() << ",MCParticle="
207 << iMCParticle << endl;
208 }
209 }
210
211 if (TRGDebug::level()) {
212 map<unsigned, unsigned>::const_iterator it = relations.begin();
213 while (it != relations.end()) {
214 cout << TRGDebug::tab()
215 << it->first << ","
216 << it->second << endl;
217 ++it;
218 }
219 }
220
221 TRGDebug::leaveStage("MCInfo");
222
223 return TCRelation(* this, relations);
224 }
225
226
227
228
229
230
231 const TRGCDCRelation
233 {
234
235 TRGDebug::enterStage("MCInfo");
236
237 map<unsigned, unsigned> relations;
238 for (unsigned i = 0; i < _tsAll.size(); i++) {
239
240 const TCCell& cell = * _tsAll[i]->cell();
241
242 // Ignore axial layers
243 if (cell.superLayerId() % 2 == 0) continue;
244
245 const TCCHit& hit = * cell.hit();
246 const unsigned iMCParticle = hit.iMCParticle();
247
248 map<unsigned, unsigned>::iterator it = relations.find(iMCParticle);
249 if (it != relations.end())
250 ++it->second;
251 else
252 relations[iMCParticle] = 1;
253
254 if (TRGDebug::level()) {
255 cout << TRGDebug::tab() << cell.name() << ",MCParticle="
256 << iMCParticle << endl;
257 }
258 }
259
260 if (TRGDebug::level()) {
261 map<unsigned, unsigned>::const_iterator it = relations.begin();
262 while (it != relations.end()) {
263 cout << TRGDebug::tab()
264 << it->first << ","
265 << it->second << endl;
266 ++it;
267 }
268 }
269
270 TRGDebug::leaveStage("MCInfo");
271
272 return TCRelation(* this, relations);
273 }
274
276} // namespace Belle2
virtual int fit(TRGCDCTrackBase &) const =0
Fit functions.
A class to represent a wire in CDC.
Definition: Relation.h:35
A class to represent a track object in TRGCDC.
Definition: TrackBase.h:40
std::vector< TRGCDCLink * > _tsAll
Links for all super layers.
Definition: TrackBase.h:160
const unsigned _nTs
Size of _ts.
Definition: TrackBase.h:163
std::vector< TRGCDCLink * > * _ts
Links for each super layer.
Definition: TrackBase.h:157
const TRGCDCFitter * _fitter
Fitter.
Definition: TrackBase.h:166
The instance of TRGCDC is a singleton.
Definition: TRGCDC.h:69
const TRGCDCRelation relation(void) const
returns MC information.
Definition: TrackBase.cc:142
static std::string tab(void)
returns tab spaces.
Definition: Debug.cc:47
virtual void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: TrackBase.cc:65
const TRGCDCRelation relation3D(void) const
returns MC information for only stereo layers.
Definition: TrackBase.cc:232
static void enterStage(const std::string &stageName)
Declare that you enter new stage.
Definition: Debug.cc:24
int status(void) const
returns status.
Definition: TrackBase.h:199
const TRGCDCRelation relation2D(void) const
returns MC information for only axial layers.
Definition: TrackBase.cc:182
virtual int fit(void)
fits itself by a default fitter. Error was happened if return value is not zero.
Definition: TrackBase.cc:97
TRGCDCTrackBase(const TRGCDCTrackBase &)
Copy constructor.
Definition: TrackBase.cc:31
std::string name(void) const
returns name.
Definition: TrackBase.h:185
static int level(void)
returns the debug level.
Definition: Debug.cc:67
static void leaveStage(const std::string &stageName)
Declare that you leave a stage.
Definition: Debug.cc:34
virtual int approach2D(TRGCDCLink &) const
calculate closest approach. Error was happened if return value is not zero.
Definition: TrackBase.cc:135
virtual const CLHEP::Hep3Vector & p(void) const
returns momentum vector.
Definition: TrackBase.h:206
const std::vector< TRGCDCLink * > & links(void) const
returns a vector to track segments.
Definition: TrackBase.cc:123
virtual const CLHEP::Hep3Vector & x(void) const
returns position vector.
Definition: TrackBase.h:213
virtual ~TRGCDCTrackBase()
Destructor.
Definition: TrackBase.cc:60
void append(TRGCDCLink *)
appends a link.
Definition: TrackBase.cc:108
Abstract base class for different kinds of events.
STL namespace.