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