Belle II Software  release-05-01-25
CellHit.cc
1 //-----------------------------------------------------------------------------
2 // $Id$
3 //-----------------------------------------------------------------------------
4 // Filename : CellHit.cc
5 // Section : TRG CDC
6 // Owner : Yoshihito Iwasaki
7 // Email : yoshihito.iwasaki@kek.jp
8 //-----------------------------------------------------------------------------
9 // Description : A class to represent a cell hit in CDC.
10 //-----------------------------------------------------------------------------
11 // $Log$
12 //-----------------------------------------------------------------------------
13 
14 #define TRG_SHORT_NAMES
15 #define TRGCDC_SHORT_NAMES
16 
17 #include "framework/datastore/StoreArray.h"
18 #include "mdst/dataobjects/MCParticle.h"
19 #include "cdc/dataobjects/CDCSimHit.h"
20 #include "cdc/dataobjects/CDCHit.h"
21 #include "trg/trg/Utilities.h"
22 #include "trg/cdc/Wire.h"
23 #include "trg/cdc/CellHit.h"
24 #include "trg/cdc/TrackMC.h"
25 #include "trg/cdc/WireHitMC.h" // to be removed
26 
27 using namespace std;
28 
29 namespace Belle2 {
35  TRGCDCCellHit::TRGCDCCellHit(const TRGCDCCell& w,
36  unsigned indexCDCHit,
37  unsigned indexCDCSimHit,
38  unsigned indexMCParticle,
39  float driftLeft,
40  float driftLeftError,
41  float driftRight,
42  float driftRightError,
43  int mcLRflag,
44  float fudgeFactor)
45  : _state(0),
46  _cell(w),
47  _xyPosition(w.xyPosition()),
48  _track(0),
49  _sequentialLength(0), //2019/07/31 by ytlai
50  _iCDCHit(indexCDCHit),
51  _iCDCSimHit(indexCDCSimHit),
52  _iMCParticle(indexMCParticle)
53  {
54 // w.hit(this); // set by TRGCDC
55  _mcLR = mcLRflag;
56  _drift[0] = driftLeft;
57  _drift[1] = driftRight;
58  _driftError[0] = driftLeftError * fudgeFactor;
59  _driftError[1] = driftRightError * fudgeFactor;
60  if (w.axial()) _state |= CellHitAxial;
61  else _state |= CellHitStereo;
62  }
63 
65  {
66  }
67 
68 // [FIXME] Crashes when there is no MC information
69  void
70  TRGCDCCellHit::dump(const std::string& msg,
71  const std::string& pre) const
72  {
73  std::cout << pre;
74  std::cout << _cell.name();
75  if (msg.find("state") != std::string::npos ||
76  msg.find("detail") != std::string::npos) {
77  std::cout << ",state";
78  TRGUtil::bitDisplay(_state);
79  if (track()) std::cout << ",trk ";
80  }
81  if (msg.find("position") != std::string::npos ||
82  msg.find("detail") != std::string::npos) {
83  cout << ",xy=" << _xyPosition;
84  }
85  if (msg.find("drift") != std::string::npos ||
86  msg.find("detail") != std::string::npos) {
87  if (_state & CellHitLeftMask) std::cout << ", L";
88  if (_state & CellHitRightMask) std::cout << ", R";
89  std::cout << ",dl " << _drift[0] << "+-" << _driftError[0];
90  std::cout << ",dr " << _drift[1] << "+-" << _driftError[1];
91  }
92  if (msg.find("mc") != std::string::npos ||
93  msg.find("detail") != std::string::npos) {
94  cout << ",mcpart=" << iMCParticle();
95  cout << ",flightTime=" << simHit()->getFlightTime();
96  cout << ",driftLength=" << simHit()->getDriftLength() << endl;
97  _cell.signal().dump("detail", pre + " ");
98  }
99  std::cout << std::endl;
100  }
101 
102  Point3D
103  TRGCDCCellHit::position(unsigned lr) const
104  {
105  static const HepGeom::Vector3D<double> HepXHat(1.0, 0.0, 0.0);
106  static const HepGeom::Vector3D<double> HepYHat(0.0, 1.0, 0.0);
107  static const HepGeom::Vector3D<double> HepZHat(0.0, 0.0, 1.0);
108 
109  //...Left...
110  if (lr == CellHitLeft) {
111  return _xyPosition
112  - _drift[CellHitLeft] * HepZHat.cross(_xyPosition.unit());
113  }
114 
115  //...Right case...
116  else {
117  return _xyPosition
118  + _drift[CellHitRight] * HepZHat.cross(_xyPosition.unit());
119  }
120  }
121 
122  int
124  {
125  if ((* a)->_cell.id() > (* b)->_cell.id())
126  return 1;
127  else if ((* a)->_cell.id() == (* b)->_cell.id())
128  return 0;
129  else
130  return -1;
131  }
132 
133  const CDCHit*
134  TRGCDCCellHit::hit(void) const
135  {
136  StoreArray<CDCHit> CDCHits("CDCHits");
137  return CDCHits[_iCDCHit];
138  }
139 
140  const CDCSimHit*
142  {
143  StoreArray<CDCSimHit> CDCHits("CDCSimHits");
144  return CDCHits[_iCDCSimHit];
145  }
146 
147  const MCParticle*
149  {
150  StoreArray<MCParticle> mcParticles("MCParticles");
151  return mcParticles[_iMCParticle];
152  }
153 
155 } // namespace Belle2
Belle2::CDCSimHit::getFlightTime
double getFlightTime() const
The method to get flight time.
Definition: CDCSimHit.h:201
Belle2::TRGCDCCellHit::dump
virtual void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: CellHit.cc:70
Belle2::TRGCDCCellHit::hit
const CDCHit * hit(void) const
Access to CDCHit.
Definition: CellHit.cc:134
Belle2::TRGCDCCellHit::iMCParticle
unsigned iMCParticle(void) const
returns an index to MCParticle.
Definition: CellHit.h:375
Belle2::CDCHit
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:51
Belle2::TRGCDCCellHit::_iCDCSimHit
unsigned _iCDCSimHit
Index to CDCSimHit array.
Definition: CellHit.h:200
Belle2::TRGCDCCell::signal
virtual const TRGSignal & signal(void) const =0
returns trigger output. Null will returned if no signal.
Belle2::CDCSimHit
Example Detector.
Definition: CDCSimHit.h:33
Belle2::TRGCDCCellHit::_xyPosition
const HepGeom::Point3D< double > & _xyPosition
position in the middle of wire. z is always zero, however.
Definition: CellHit.h:190
Belle2::TRGCDCCellHit::_drift
float _drift[2]
drift distance
Definition: CellHit.h:184
Belle2::TRGCDCCellHit::_mcLR
int _mcLR
mc left/right information
Definition: CellHit.h:179
Belle2::TRGCDCCellHit::_state
unsigned _state
state, defined above
Definition: CellHit.h:182
Belle2::TRGCDCCellHit::simHit
const CDCSimHit * simHit(void) const
Access to CDCSimHit.
Definition: CellHit.cc:141
Belle2::TRGCDCCellHit::_cell
const TRGCDCCell & _cell
a pointer to a TRGCDCWire
Definition: CellHit.h:188
Belle2::TRGCDCCellHit::~TRGCDCCellHit
virtual ~TRGCDCCellHit()
Destructor.
Definition: CellHit.cc:64
Belle2::TRGSignal::dump
void dump(const std::string &message="", const std::string &pre="") const
dumps contents.
Definition: Signal.cc:144
Belle2::TRGCDCCell
A class to represent a wire in CDC.
Definition: Cell.h:41
Belle2::TRGCDCCellHit
A class to represent a wire hit in CDC.
Definition: CellHit.h:75
Belle2::TRGCDCCellHit::sortById
static int sortById(const TRGCDCCellHit **a, const TRGCDCCellHit **b)
Sort function.
Definition: CellHit.cc:123
Belle2::TRGCDCCellHit::position
HepGeom::Point3D< double > position(unsigned) const
returns left position. z is always zero.
Definition: CellHit.cc:103
Belle2::TRGCDCCellHit::_driftError
float _driftError[2]
drift distance error
Definition: CellHit.h:186
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TRGCDCCell::name
virtual std::string name(void) const =0
returns name.
Belle2::CDCSimHit::getDriftLength
double getDriftLength() const
The method to get drift length.
Definition: CDCSimHit.h:198
Belle2::TRGCDCCellHit::_iCDCHit
unsigned _iCDCHit
Index to CDCHit array.
Definition: CellHit.h:197
Belle2::TRGCDCCellHit::_iMCParticle
unsigned _iMCParticle
Index to MCParticle array.
Definition: CellHit.h:203
HepGeom::Point3D< double >
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:43
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::TRGCDCCellHit::track
const void * track(void) const
assigns a pointer to a TTrack.
Definition: CellHit.h:318
Belle2::TRGCDCCellHit::mcParticle
const MCParticle * mcParticle(void) const
Access to MCParticle.
Definition: CellHit.cc:148