Belle II Software  release-08-01-10
TrackMC.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 GEN_HEPEVT particle in tracking.
11 //-----------------------------------------------------------------------------
12 
13 #include "trg/cdc/TRGCDC.h"
14 #include "trg/cdc/TrackMC.h"
15 
16 namespace Belle2 {
22  TRGCDCTrackMC*
23  TRGCDCTrackMC::_undefined = new TRGCDCTrackMC();
24 
25  std::vector<const TRGCDCTrackMC*>
26  TRGCDCTrackMC::_list = std::vector<const TRGCDCTrackMC*>();
27 
28  void
30  {
31  if (_list.size()) {
32  for (unsigned i = 0; i < _list.size(); i++)
33  delete _list[i];
34  _list.clear();
35  }
36 
37 // unsigned n = 0;
38 
39 // for (unsigned i = 0; i < n; i++) {
40 // struct gen_hepevt * h = 0;
41 // if (! h) {
42 // std::cout << "TRGCDCTrackMC::update !!! can not access to GEN_HEPEVT";
43 // std::cout << std::endl;
44 // break;
45 // }
46 // // if (h->m_P[3] != 0.0 && (h->m_P[0] * h->m_P[0] + h->m_P[1] * h->m_P[1]
47 // // + h->m_P[2] * h->m_P[2]) != 0.0) {
48 // _list.push_back(new TRGCDCTrackMC(h));
49 // // } else {
50 // // std::cout << "TRGCDCTrackMC::update !!! momentum/energy is zero";
51 // // std::cout << std::endl;
52 // // }
53 // }
54  }
55 
56 // TRGCDCTrackMC::TRGCDCTrackMC(const struct gen_hepevt * h)
57 // : _hep(h),
58 // _mother(0),
59 // _p(h->m_P[0], h->m_P[1], h->m_P[2], h->m_P[3]),
60 // _v(h->m_V[0], h->m_V[1], h->m_V[2]) {
61 // if (_hep->m_mother != 0) {
62 // _mother = _list[_hep->m_mother - 1];
63 // _mother->_children.push_back(this);
64 // }
65 // }
66 
68  {
69  }
70 
72  {
73  if (_list.size()) {
74  for (unsigned i = 0; i < _list.size(); i++)
75  delete _list[i];
76  _list.clear();
77  }
78  }
79 
80  void
81  TRGCDCTrackMC::dump(const std::string&, const std::string& pre) const
82  {
83  std::cout << pre;
84  std::cout << id() << ":";
85  std::cout << pType() << ":";
86  if (_mother) std::cout << _mother->id();
87  else std::cout << "-";
88  std::cout << ":";
89  std::cout << _p << ":" << _v;
90  std::cout << std::endl;
91  }
92 
93  std::vector<const TRGCDCTrackMC*>
95  {
96  std::vector<const TRGCDCTrackMC*> t;
97  t.assign(_list.begin(), _list.end());
98  return t;
99  }
100 
101  std::vector<const TRGCDCWireHitMC*>
103  {
104  std::vector<const TRGCDCWireHitMC*> t;
105  t.assign(_hits.begin(), _hits.end());
106  return t;
107  }
108 
110 } // namespace Belle2
std::vector< TRGCDCWireHitMC * > _hits
vector of pointers to TRGCDCWireHitMC
Definition: TrackMC.h:101
TRGCDCTrackMC * _mother
pointer to mother TRGCDCTrackMC
Definition: TrackMC.h:93
const CLHEP::HepLorentzVector _p
momentum
Definition: TrackMC.h:97
const CLHEP::Hep3Vector _v
vertex
Definition: TrackMC.h:99
static std::vector< const TRGCDCTrackMC * > _list
vector of pointers to TRGCDCTrackMC
Definition: TrackMC.h:105
std::vector< const TRGCDCWireHitMC * > hits(void) const
returns a list of TRGCDCWireHitMC.
Definition: TrackMC.cc:102
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: TrackMC.cc:81
unsigned id(void) const
returns an id started from 0.
Definition: TrackMC.h:114
virtual ~TRGCDCTrackMC()
Destructor.
Definition: TrackMC.cc:71
static void update(void)
updates information.
Definition: TrackMC.cc:29
static TRGCDCTrackMC * _undefined
returns a pointer to gen_hepevt.
Definition: TrackMC.h:88
TRGCDCTrackMC()
Constructor.
Definition: TrackMC.cc:67
int pType(void) const
returns particle type.
Definition: TrackMC.h:130
static std::vector< const TRGCDCTrackMC * > list(void)
returns a list of TRGCDCTrackMC's.
Definition: TrackMC.cc:94
Abstract base class for different kinds of events.