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