Belle II Software development
TOPTrack Class Reference

Reconstructed track at TOP. More...

#include <TOPTrack.h>

Classes

struct  AssumedEmission
 assumed photon emission point in local frame More...
 
struct  SelectedHit
 selected photon hit from TOPDigits More...
 
struct  TrackAngles
 Sine and cosine of track polar and azimuthal angles at assumed photon emission. More...
 

Public Member Functions

 TOPTrack ()
 Default constructor.
 
 TOPTrack (const Track &track, const std::string &digitsName="", const Const::ChargedStable &chargedStable=Const::pion)
 Constructor from mdst track - isValid() must be checked before using the object.
 
 TOPTrack (const ExtHit *extHit, const std::string &digitsName="")
 Constructor from extrapolated track hit - isValid() must be checked before using the object.
 
bool overrideTransformation (const ROOT::Math::Transform3D &transform)
 Overrides transformation from local to nominal frame, which is by default obtained from DB.
 
bool isValid () const
 Checks if track is successfully constructed.
 
int getModuleID () const
 Returns slot ID.
 
double getMomentumMag () const
 Returns momentum magnitude (extrapolated to TOP)
 
double getTransverseMomentum () const
 Returns transverse momentum (at POCA)
 
double getCharge () const
 Returns charge.
 
double getTrackLength () const
 Returns track length from IP to the average position of photon emission within quartz.
 
double getLengthInQuartz () const
 Returns track length within quartz.
 
double getBeta (const Const::ChargedStable &particle, double overrideMass=0) const
 Returns particle beta.
 
const TOPTrack::AssumedEmissiongetEmissionPoint (double dL=0) const
 Returns assumed photon emission position and track direction.
 
double getTOF (const Const::ChargedStable &particle, double dL=0, double overrideMass=0) const
 Returns time-of-flight from IP to photon emission position.
 
const TOP::HelixSwimmergetHelix () const
 Returns helix Helix is given in nominal slot frame and with reference position at average photon emission.
 
const TrackgetTrack () const
 Returns mdst track.
 
const ExtHitgetExtHit () const
 Returns extrapolated hit (track entrance to the bar)
 
const MCParticlegetMCParticle () const
 Returns MC particle assigned to this track (if any)
 
int getPDGCode () const
 Returns PDG code of associated MCParticle (returns 0 if none)
 
const TOPBarHitgetBarHit () const
 Returns bar hit of MC particle assigned to this track (if any)
 
const std::vector< SelectedHit > & getSelectedHits () const
 Returns selected photon hits from TOPDigits belonging to the slot ID.
 
double getBkgRate () const
 Returns estimated background hit rate.
 
bool isScanRequired (unsigned col, double time, double wid) const
 Checks if scan method of YScanner is needed to construct PDF for a given pixel column.
 

Private Member Functions

void set (const Track &track, const std::string &digitsName, const Const::ChargedStable &chargedStable)
 Sets the object (called by constructors)
 
bool setHelix (const ROOT::Math::Transform3D &transform)
 Sets helix (helix is given in nominal frame)
 
bool xsecPrism (std::vector< double > &lengths, std::vector< ROOT::Math::XYZPoint > &positions, const RaytracerBase::Prism &prism, const ROOT::Math::Transform3D &transform)
 Calculates intersection of trajectory with prism.
 

Private Attributes

int m_moduleID = 0
 slot ID
 
double m_momentum = 0
 track momentum magnitude at TOP
 
double m_pT = 0
 transverse momentum at POCA
 
double m_charge = 0
 track charge in units of elementary charge
 
double m_TOFLength = 0
 trajectory length corresponding to TOF of extrapolated hit
 
double m_trackLength = 0
 trajectory length from IP to average photon emission point
 
double m_length = 0
 trajectory length within quartz
 
TOP::HelixSwimmer m_helix
 trajectory helix in nominal slot frame
 
DBObjPtr< TOPCalModuleAlignmentm_alignment
 module alignment constants
 
DBObjPtr< TOPFrontEndSettingm_feSetting
 front-end settings
 
const Trackm_track = 0
 mdst track
 
const ExtHitm_extHit = 0
 extrapolated hit
 
const MCParticlem_mcParticle = 0
 MC particle.
 
const TOPBarHitm_barHit = 0
 bar hit
 
bool m_valid = false
 true for properly defined track
 
std::vector< SelectedHitm_selectedHits
 selected photon hits from TOPDigits belonging to this slot ID
 
double m_bkgRate = 0
 estimated background hit rate
 
std::unordered_multimap< unsigned, const SelectedHit * > m_columnHits
 selected hits mapped to pixel columns
 
std::map< double, TOPTrack::AssumedEmissionm_emissionPoints
 assumed emission points in module local frame
 

Detailed Description

Reconstructed track at TOP.

Definition at line 39 of file TOPTrack.h.

Constructor & Destructor Documentation

◆ TOPTrack() [1/3]

TOPTrack ( )
inline

Default constructor.

Definition at line 102 of file TOPTrack.h.

103 {}

◆ TOPTrack() [2/3]

TOPTrack ( const Track track,
const std::string &  digitsName = "",
const Const::ChargedStable chargedStable = Const::pion 
)
explicit

Constructor from mdst track - isValid() must be checked before using the object.

Parameters
trackmdst track
digitsNamename of TOPDigits collection
chargedStablehypothesis used in mdst track extrapolation

Definition at line 40 of file TOPTrack.cc.

41 {
42 // find extrapolated track hit at TOP
43
44 Const::EDetector myDetID = Const::EDetector::TOP;
45 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
46 int numModules = geo->getNumModules();
47 int pdgCode = std::abs(chargedStable.getPDGCode());
48
49 RelationVector<ExtHit> extHits = track.getRelationsWith<ExtHit>();
50 double tmin = 1e10; // some large time
51 for (const auto& extHit : extHits) {
52 if (std::abs(extHit.getPdgCode()) != pdgCode) continue;
53 if (extHit.getDetectorID() != myDetID) continue;
54 if (extHit.getCopyID() < 1 or extHit.getCopyID() > numModules) continue;
55 if (extHit.getTOF() < tmin) {
56 tmin = extHit.getTOF();
57 m_extHit = &extHit;
58 }
59 }
60 if (not m_extHit) return;
61
62 // set the object
63
64 set(track, digitsName, chargedStable);
65 }
EDetector
Enum for identifying the detector components (detector and subdetector).
Definition: Const.h:42
unsigned getNumModules() const
Returns number of modules.
Definition: TOPGeometry.h:136
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using basf2 units.
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
void set(const Track &track, const std::string &digitsName, const Const::ChargedStable &chargedStable)
Sets the object (called by constructors)
Definition: TOPTrack.cc:91
const ExtHit * m_extHit
extrapolated hit
Definition: TOPTrack.h:301

◆ TOPTrack() [3/3]

TOPTrack ( const ExtHit extHit,
const std::string &  digitsName = "" 
)
explicit

Constructor from extrapolated track hit - isValid() must be checked before using the object.

Parameters
extHitextrapolated track hit
digitsNamename of TOPDigits collection

Definition at line 68 of file TOPTrack.cc.

69 {
70 if (not extHit) return;
71 m_extHit = extHit;
72
73 const auto* track = extHit->getRelated<Track>();
74 if (not track) {
75 B2ERROR("TOPTrack: no related Track found for valid ExtHit");
76 return;
77 }
78
79 auto chargedStable = Const::chargedStableSet.find(std::abs(extHit->getPdgCode()));
80 if (chargedStable == Const::invalidParticle) {
81 B2ERROR("TOPTrack: extrapolation hypothesis of ExtHit is not ChargedStable");
82 return;
83 }
84
85 // set the object
86
87 set(*track, digitsName, chargedStable);
88 }
const ParticleType & find(int pdg) const
Returns particle in set with given PDG code, or invalidParticle if not found.
Definition: Const.h:571
static const ParticleSet chargedStableSet
set of charged stable particles
Definition: Const.h:618
static const ParticleType invalidParticle
Invalid particle, used internally.
Definition: Const.h:681

Member Function Documentation

◆ getBarHit()

const TOPBarHit * getBarHit ( ) const
inline

Returns bar hit of MC particle assigned to this track (if any)

Returns
bar hit or NULL pointer

Definition at line 238 of file TOPTrack.h.

238{return m_barHit;}
const TOPBarHit * m_barHit
bar hit
Definition: TOPTrack.h:303

◆ getBeta()

double getBeta ( const Const::ChargedStable particle,
double  overrideMass = 0 
) const
inline

Returns particle beta.

Parameters
particleparticle mass hypothesis
overrideMassalternative mass value to be used to calculate beta. Ignored if <= 0.
Returns
particle beta

Definition at line 316 of file TOPTrack.h.

317 {
318 double mass = chargedStable.getMass();
319 if (overrideMass > 0)
320 mass = overrideMass;
321 return m_momentum / sqrt(m_momentum * m_momentum + mass * mass);
322 }
double m_momentum
track momentum magnitude at TOP
Definition: TOPTrack.h:290
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28

◆ getBkgRate()

double getBkgRate ( ) const
inline

Returns estimated background hit rate.

Returns
background hit rate per module

Definition at line 250 of file TOPTrack.h.

250{return m_bkgRate;}
double m_bkgRate
estimated background hit rate
Definition: TOPTrack.h:307

◆ getCharge()

double getCharge ( ) const
inline

Returns charge.

Returns
charge in units of elementary charge

Definition at line 161 of file TOPTrack.h.

161{return m_charge;}
double m_charge
track charge in units of elementary charge
Definition: TOPTrack.h:292

◆ getEmissionPoint()

const TOPTrack::AssumedEmission & getEmissionPoint ( double  dL = 0) const

Returns assumed photon emission position and track direction.

Parameters
dLlength difference to the average emission position
Returns
assumed photon emission position and track direction in local frame

Definition at line 357 of file TOPTrack.cc.

358 {
359 if (m_emissionPoints.size() > 1000) m_emissionPoints.clear(); // prevent blow-up
360
361 auto& emissionPoint = m_emissionPoints[dL];
362 if (not emissionPoint.isSet) {
363 emissionPoint.position = m_helix.getPosition(dL);
364 emissionPoint.trackAngles = TrackAngles(m_helix.getDirection(dL));
365 emissionPoint.isSet = true;
366 }
367 return emissionPoint;
368 }
ROOT::Math::XYZPoint getPosition(double length) const
Returns particle position at given length.
Definition: HelixSwimmer.cc:63
ROOT::Math::XYZVector getDirection(double length) const
Returns particle direction at given length.
Definition: HelixSwimmer.cc:75
std::map< double, TOPTrack::AssumedEmission > m_emissionPoints
assumed emission points in module local frame
Definition: TOPTrack.h:311
TOP::HelixSwimmer m_helix
trajectory helix in nominal slot frame
Definition: TOPTrack.h:296

◆ getExtHit()

const ExtHit * getExtHit ( ) const
inline

Returns extrapolated hit (track entrance to the bar)

Returns
extrapolated hit

Definition at line 216 of file TOPTrack.h.

216{return m_extHit;}

◆ getHelix()

const TOP::HelixSwimmer & getHelix ( ) const
inline

Returns helix Helix is given in nominal slot frame and with reference position at average photon emission.

Returns
helix

Definition at line 204 of file TOPTrack.h.

204{return m_helix;}

◆ getLengthInQuartz()

double getLengthInQuartz ( ) const
inline

Returns track length within quartz.

Returns
track length within quartz

Definition at line 173 of file TOPTrack.h.

173{return m_length;}
double m_length
trajectory length within quartz
Definition: TOPTrack.h:295

◆ getMCParticle()

const MCParticle * getMCParticle ( ) const
inline

Returns MC particle assigned to this track (if any)

Returns
MC particle or NULL pointer

Definition at line 222 of file TOPTrack.h.

222{return m_mcParticle;}
const MCParticle * m_mcParticle
MC particle.
Definition: TOPTrack.h:302

◆ getModuleID()

int getModuleID ( ) const
inline

Returns slot ID.

Returns
slot ID

Definition at line 143 of file TOPTrack.h.

143{return m_moduleID;}
int m_moduleID
slot ID
Definition: TOPTrack.h:289

◆ getMomentumMag()

double getMomentumMag ( ) const
inline

Returns momentum magnitude (extrapolated to TOP)

Returns
momentum magnitude

Definition at line 149 of file TOPTrack.h.

149{return m_momentum;}

◆ getPDGCode()

int getPDGCode ( ) const
inline

Returns PDG code of associated MCParticle (returns 0 if none)

Returns
PDG code or 0

Definition at line 228 of file TOPTrack.h.

229 {
230 if (m_mcParticle) return m_mcParticle->getPDG();
231 return 0;
232 }
int getPDG() const
Return PDG code of particle.
Definition: MCParticle.h:112

◆ getSelectedHits()

const std::vector< SelectedHit > & getSelectedHits ( ) const
inline

Returns selected photon hits from TOPDigits belonging to the slot ID.

Returns
selected photon hits

Definition at line 244 of file TOPTrack.h.

244{return m_selectedHits;}
std::vector< SelectedHit > m_selectedHits
selected photon hits from TOPDigits belonging to this slot ID
Definition: TOPTrack.h:306

◆ getTOF()

double getTOF ( const Const::ChargedStable particle,
double  dL = 0,
double  overrideMass = 0 
) const
inline

Returns time-of-flight from IP to photon emission position.

Parameters
particleparticle mass hypothesis
dLlength difference to the average emission position
overrideMassalternative mass value to be used to calculate beta. Ignored if <= 0.
Returns
time-of-flight

Definition at line 324 of file TOPTrack.h.

325 {
326 return (m_trackLength + dL) / getBeta(chargedStable, overrideMass) / Const::speedOfLight;
327 }
static const double speedOfLight
[cm/ns]
Definition: Const.h:695
double m_trackLength
trajectory length from IP to average photon emission point
Definition: TOPTrack.h:294
double getBeta(const Const::ChargedStable &particle, double overrideMass=0) const
Returns particle beta.
Definition: TOPTrack.h:316

◆ getTrack()

const Track * getTrack ( ) const
inline

Returns mdst track.

Returns
mdst track

Definition at line 210 of file TOPTrack.h.

210{return m_track;}
const Track * m_track
mdst track
Definition: TOPTrack.h:300

◆ getTrackLength()

double getTrackLength ( ) const
inline

Returns track length from IP to the average position of photon emission within quartz.

Returns
track length from IP

Definition at line 167 of file TOPTrack.h.

167{return m_trackLength;}

◆ getTransverseMomentum()

double getTransverseMomentum ( ) const
inline

Returns transverse momentum (at POCA)

Returns
transverse momentum

Definition at line 155 of file TOPTrack.h.

155{return m_pT;}
double m_pT
transverse momentum at POCA
Definition: TOPTrack.h:291

◆ isScanRequired()

bool isScanRequired ( unsigned  col,
double  time,
double  wid 
) const

Checks if scan method of YScanner is needed to construct PDF for a given pixel column.

Parameters
colpixel column (0-based)
timePDF peak time
widPDF peak width squared
Returns
true if at least one of the detected photons is within the PDF peak convoluted with TTS.

Definition at line 370 of file TOPTrack.cc.

371 {
372 const auto& tts = TOPGeometryPar::Instance()->getGeometry()->getTTS(0); // PMT independent TTS should be fine here
373 const auto& range = m_columnHits.equal_range(col);
374 for (auto it = range.first; it != range.second; ++it) {
375 const auto hit = it->second;
376 for (const auto& gaus : tts.getTTS()) {
377 double sigsq = wid + pow(gaus.sigma, 2) + pow(hit->timeErr, 2);
378 double x = pow(hit->time - time - gaus.position, 2) / sigsq;
379 if (x < 10) return true;
380 }
381 }
382
383 return false;
384 }
std::unordered_multimap< unsigned, const SelectedHit * > m_columnHits
selected hits mapped to pixel columns
Definition: TOPTrack.h:308
const TOPNominalTTS & getTTS(unsigned type) const
Returns time transition spread of a given PMT type.
Definition: TOPGeometry.cc:50

◆ isValid()

bool isValid ( ) const
inline

Checks if track is successfully constructed.

Returns
true if successful

Definition at line 137 of file TOPTrack.h.

137{return m_valid;}
bool m_valid
true for properly defined track
Definition: TOPTrack.h:304

◆ overrideTransformation()

bool overrideTransformation ( const ROOT::Math::Transform3D &  transform)
inline

Overrides transformation from local to nominal frame, which is by default obtained from DB.

Needed for module alignment.

Parameters
transformtransformation from local to nominal frame
Returns
true if quartz bar intersection still exists

Definition at line 127 of file TOPTrack.h.

128 {
129 m_valid = setHelix(transform);
130 return m_valid;
131 }
bool setHelix(const ROOT::Math::Transform3D &transform)
Sets helix (helix is given in nominal frame)
Definition: TOPTrack.cc:170

◆ set()

void set ( const Track track,
const std::string &  digitsName,
const Const::ChargedStable chargedStable 
)
private

Sets the object (called by constructors)

Parameters
trackmdst track
digitsNamename of TOPDigits collection
chargedStablehypothesis used in mdst track extrapolation

Definition at line 91 of file TOPTrack.cc.

92 {
93 // require fitResult
94
95 const auto* fitResult = track.getTrackFitResultWithClosestMass(chargedStable);
96 if (not fitResult) {
97 B2ERROR("TOPTrack: no TrackFitResult available for PDGCode = " << chargedStable.getPDGCode());
98 return;
99 }
100 m_pT = fitResult->getTransverseMomentum();
101
102 // require hits in CDC
103
104 if (fitResult->getHitPatternCDC().getNHits() == 0) return;
105
106 // set pointers
107
108 m_track = &track;
109 m_mcParticle = track.getRelated<MCParticle>();
110 if (m_mcParticle) {
111 const auto barHits = m_mcParticle->getRelationsWith<TOPBarHit>();
112 for (const auto& barHit : barHits) {
113 if (barHit.getModuleID() == m_extHit->getCopyID()) m_barHit = &barHit;
114 }
115 }
116
117 // set track parameters and helix
118
121 m_charge = fitResult->getChargeSign();
122 m_TOFLength = m_extHit->getTOF() * Const::speedOfLight * getBeta(chargedStable);
123 m_valid = setHelix(m_alignment->getTransformation(m_moduleID));
124 if (not m_valid) return;
125
126 // selection of photon hits belonging to this track
127
128 unsigned numHitsOtherSlots = 0;
129 StoreArray<TOPDigit> digits(digitsName);
130 for (const auto& digit : digits) {
131 if (digit.getHitQuality() != TOPDigit::c_Good) continue;
132 if (digit.getModuleID() == m_moduleID) {
133 m_selectedHits.push_back(SelectedHit(digit.getPixelID(), digit.getTime(), digit.getTimeError()));
134 } else {
135 numHitsOtherSlots++;
136 }
137 }
138
139 // background rate estimation (TODO to be improved ...)
140
141 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
142 const auto& tdc = geo->getNominalTDC();
143 double timeWindow = m_feSetting->getReadoutWindows() * tdc.getSyncTimeBase() / static_cast<double>(TOPNominalTDC::c_syncWindows);
144
145 const auto& backgroundPDFs = TOPRecoManager::getBackgroundPDFs();
146 unsigned k = m_moduleID - 1;
147 double effi = (k < backgroundPDFs.size()) ? backgroundPDFs[k].getEfficiency() : 0;
148 double effiSum = 0;
149 for (const auto& bkg : backgroundPDFs) effiSum += bkg.getEfficiency();
150 m_bkgRate = (effiSum > effi) ? numHitsOtherSlots * effi / (effiSum - effi) / timeWindow : 0;
151
152 // selected photon hits mapped to pixel columns
153
154 const auto* yScanner = TOPRecoManager::getYScanner(m_moduleID);
155 if (not yScanner) {
156 B2ERROR("TOPTrack: YScanner for given module not found (must be a bug!)" << LogVar("slot", m_moduleID));
157 m_valid = false;
158 return;
159 }
160 unsigned numCols = yScanner->getPixelPositions().getNumPixelColumns();
161 for (const auto& hit : m_selectedHits) {
162 unsigned col = (hit.pixelID - 1) % numCols;
163 m_columnHits.emplace(col, &hit);
164 }
165
166 m_valid = effi > 0; // no sense to provide PID for the track if the module is fully inefficient
167 }
int getCopyID() const
Get detector-element ID of sensitive element within detector.
Definition: ExtHit.h:125
ROOT::Math::XYZVector getMomentum() const
Get momentum at this extrapolation hit.
Definition: ExtHit.h:151
double getTOF() const
Get time of flight from the point of closest approach near the origin to this hit.
Definition: ExtHit.h:136
RelationVector< T > getRelationsWith(const std::string &name="", const std::string &namedRelation="") const
Get the relations between this object and another store array.
const TOPNominalTDC & getNominalTDC() const
Returns nominal time-to-digit conversion parameters.
Definition: TOPGeometry.h:218
@ c_syncWindows
number of windows corresponding to syncTimeBase
Definition: TOPNominalTDC.h:29
static const std::vector< BackgroundPDF > & getBackgroundPDFs()
Returns background PDF's of all modules.
static const YScanner * getYScanner(int moduleID)
Returns y-scanner of a given module.
DBObjPtr< TOPFrontEndSetting > m_feSetting
front-end settings
Definition: TOPTrack.h:298
DBObjPtr< TOPCalModuleAlignment > m_alignment
module alignment constants
Definition: TOPTrack.h:297
double m_TOFLength
trajectory length corresponding to TOF of extrapolated hit
Definition: TOPTrack.h:293
Class to store variables with their name which were sent to the logging service.

◆ setHelix()

bool setHelix ( const ROOT::Math::Transform3D &  transform)
private

Sets helix (helix is given in nominal frame)

Parameters
transformtransformation from local to nominal frame
Returns
true if quartz bar intersection exists

Definition at line 170 of file TOPTrack.cc.

171 {
172 m_emissionPoints.clear();
173
174 // helix in module nominal frame (z-axis still parallel to magnetic field)
175
176 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
177 const auto& module = geo->getModule(m_moduleID);
178 auto globalPosition = m_extHit->getPosition();
179 auto position = module.pointGlobalToNominal(static_cast<XYZPoint>(globalPosition));
180 auto momentum = module.momentumGlobalToNominal(m_extHit->getMomentum());
181 double Bz = BFieldManager::getField(globalPosition).Z();
182 m_helix.set(position, momentum, m_charge, Bz);
183 m_helix.setTransformation(transform);
184
185 // geometry data
186
187 const RaytracerBase::BarSegment bar(module);
188 const RaytracerBase::Mirror mirror(module);
189
190 // bar surfaces in module nominal frame
191
192 std::vector<XYZPoint> points;
193 std::vector<XYZVector> normals;
194 points.push_back(transform * XYZPoint(0, -bar.B / 2, 0)); // lower
195 normals.push_back(transform * XYZVector(0, -1, 0));
196
197 points.push_back(transform * XYZPoint(0, bar.B / 2, 0)); // upper
198 normals.push_back(transform * XYZVector(0, 1, 0));
199
200 points.push_back(transform * XYZPoint(-bar.A / 2, 0, 0)); // left side
201 normals.push_back(transform * XYZVector(-1, 0, 0));
202
203 points.push_back(transform * XYZPoint(bar.A / 2, 0, 0)); // right side
204 normals.push_back(transform * XYZVector(1, 0, 0));
205
206 // intersection with quartz bar
207
208 std::vector<double> lengths; // w.r.t extHit position
209 std::vector<XYZPoint> positions; // in module local frame
210 for (size_t i = 0; i < 2; i++) {
211 double t = m_helix.getDistanceToPlane(points[i], normals[i]);
212 if (isnan(t)) return false;
213 auto r = m_helix.getPosition(t);
214 if (std::abs(r.X()) > bar.A / 2) {
215 auto k = (r.X() > 0) ? 3 : 2;
216 t = m_helix.getDistanceToPlane(points[k], normals[k]);
217 if (isnan(t)) return false;
218 r = m_helix.getPosition(t);
219 if (r.Z() >= bar.zL and std::abs(r.Y()) > bar.B / 2) return false;
220 }
221 lengths.push_back(t);
222 positions.push_back(r);
223 }
224
225 // crossing prism?
226
227 if (positions[0].Z() < bar.zL or positions[1].Z() < bar.zL) {
228 const RaytracerBase::Prism prism(module);
229 bool ok = xsecPrism(lengths, positions, prism, transform);
230 if (not ok) return false;
231 }
232
233 // crossing mirror surface?
234
235 std::vector<bool> outOfBar;
236 XYZPoint rc(mirror.xc, mirror.yc, mirror.zc);
237 double Rsq = mirror.R * mirror.R;
238 for (const auto& r : positions) {
239 outOfBar.push_back((r - rc).Mag2() > Rsq);
240 }
241 if (outOfBar[0] and outOfBar[1]) return false;
242
243 if (outOfBar[0] or outOfBar[1]) { // track crosses mirror surface, where?
244 if (outOfBar[0]) std::reverse(lengths.begin(), lengths.end());
245 double t1 = lengths[0];
246 double t2 = lengths[1];
247 for (int i = 0; i < 20; i++) {
248 double t = (t1 + t2) / 2;
249 auto r = m_helix.getPosition(t);
250 if ((r - rc).Mag2() > Rsq) {
251 t2 = t;
252 } else {
253 t1 = t;
254 }
255 }
256 lengths[1] = (t1 + t2) / 2;
257 }
258
259 // set track length in quartz and full length from IP to the average emission point
260
261 m_length = std::abs(lengths[1] - lengths[0]);
262 double length = (lengths[0] + lengths[1]) / 2;
263 m_trackLength = m_TOFLength + length;
264
265 // finally move reference position to average emission point
266
268
269 return m_length > bar.B / 2; // require minimal track lenght inside quartz (more than half of bar thickness)
270 }
ROOT::Math::XYZVector getPosition() const
Get position of this extrapolation hit.
Definition: ExtHit.h:144
void moveReferencePosition(double length)
Moves reference position along helix by length.
Definition: HelixSwimmer.cc:51
double getDistanceToPlane(const ROOT::Math::XYZPoint &point, const ROOT::Math::XYZVector &normal) const
Returns the distance along helix to the nearest intersection with the plane nearly parallel to z axis...
Definition: HelixSwimmer.cc:88
void setTransformation(const ROOT::Math::Transform3D &transform)
Sets transformation from the frame in which helix is constructed (nominal frame) to module local fram...
Definition: HelixSwimmer.h:53
void set(const ROOT::Math::XYZPoint &position, const ROOT::Math::XYZVector &momentum, double charge, double Bz)
Sets the helix.
Definition: HelixSwimmer.cc:26
bool xsecPrism(std::vector< double > &lengths, std::vector< ROOT::Math::XYZPoint > &positions, const RaytracerBase::Prism &prism, const ROOT::Math::Transform3D &transform)
Calculates intersection of trajectory with prism.
Definition: TOPTrack.cc:273
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
Definition: BFieldManager.h:91

◆ xsecPrism()

bool xsecPrism ( std::vector< double > &  lengths,
std::vector< ROOT::Math::XYZPoint > &  positions,
const RaytracerBase::Prism prism,
const ROOT::Math::Transform3D &  transform 
)
private

Calculates intersection of trajectory with prism.

Parameters
lengthstrajectory lengths relative to extHit position of intersection points [in/out]
positionspositions of intersection points in module local frame [in/out]
prismprism geometry data
transformtransformation from local to nominal frame
Returns
true if intersection exists

Definition at line 273 of file TOPTrack.cc.

275 {
276 std::vector<XYZPoint> points;
277 std::vector<XYZVector> normals;
278
279 points.push_back(transform * XYZPoint(0, prism.yDown, 0)); // lower-most surface
280 normals.push_back(transform * XYZVector(0, -1, 0));
281
282 points.push_back(transform * XYZPoint(0, prism.yUp, 0)); // upper surface
283 normals.push_back(transform * XYZVector(0, 1, 0));
284
285 points.push_back(transform * XYZPoint(-prism.A / 2, 0, 0)); // left-side surface
286 normals.push_back(transform * XYZVector(-1, 0, 0));
287
288 points.push_back(transform * XYZPoint(prism.A / 2, 0, 0)); // right-side surface
289 normals.push_back(transform * XYZVector(1, 0, 0));
290
291 for (size_t i = 0; i < 2; i++) {
292 if (positions[i].Z() < prism.zR) {
293 double t = m_helix.getDistanceToPlane(points[i], normals[i]);
294 if (isnan(t)) return false;
295 auto r = m_helix.getPosition(t);
296 if (i == 0 and r.Z() > prism.zFlat) { // intersection with slanted surface -> find it using bisection
297 auto point = transform * XYZPoint(0, -prism.B / 2, 0);
298 double t1 = m_helix.getDistanceToPlane(point, normals[0]);
299 if (isnan(t1)) return false;
300 double t2 = t;
301 for (int iter = 0; iter < 20; iter++) {
302 t = (t1 + t2) / 2;
303 r = m_helix.getPosition(t);
304 double ySlanted = prism.yDown + prism.slope * (r.Z() - prism.zFlat);
305 if (r.Y() < ySlanted) t2 = t;
306 else t1 = t;
307 }
308 t = (t1 + t2) / 2;
309 }
310 if (std::abs(r.X()) > prism.A / 2) { // intersection on the side surface
311 auto k = (r.X() > 0) ? 3 : 2;
312 t = m_helix.getDistanceToPlane(points[k], normals[k]);
313 if (isnan(t)) return false;
314 r = m_helix.getPosition(t);
315 if (r.Z() < prism.zR) { // yes, it's on the prism side
316 if (r.Y() > prism.yUp or r.Y() < prism.yDown) return false;
317 double ySlanted = prism.yDown + prism.slope * (r.Z() - prism.zFlat);
318 if (r.Y() < ySlanted) return false;
319 } else { // no, it's on the prism entrance but outside the bar exit window -> find it using bisection
320 double t1 = lengths[i];
321 double t2 = t;
322 for (int iter = 0; iter < 20; iter++) {
323 t = (t1 + t2) / 2;
324 r = m_helix.getPosition(t);
325 if (r.Z() < prism.zR) t1 = t;
326 else t2 = t;
327 }
328 t = (t1 + t2) / 2;
329 }
330 }
331 lengths[i] = t;
332 positions[i] = m_helix.getPosition(t);
333 }
334 }
335
336 if (positions[0].Z() < prism.zL and positions[1].Z() < prism.zL) return false;
337
338 if (positions[0].Z() < prism.zL or positions[1].Z() < prism.zL) { // intersection is on exit window
339 int i0 = (positions[0].Z() < prism.zL) ? 0 : 1;
340 double t1 = lengths[i0];
341 double t2 = lengths[(i0 + 1) % 2];
342 for (int iter = 0; iter < 20; iter++) {
343 double t = (t1 + t2) / 2;
344 auto r = m_helix.getPosition(t);
345 if (r.Z() < prism.zL) t1 = t;
346 else t2 = t;
347 }
348 double t = (t1 + t2) / 2;
349 lengths[i0] = t;
350 positions[i0] = m_helix.getPosition(t);
351 }
352
353 return true;
354 }

Member Data Documentation

◆ m_alignment

DBObjPtr<TOPCalModuleAlignment> m_alignment
private

module alignment constants

Definition at line 297 of file TOPTrack.h.

◆ m_barHit

const TOPBarHit* m_barHit = 0
private

bar hit

Definition at line 303 of file TOPTrack.h.

◆ m_bkgRate

double m_bkgRate = 0
private

estimated background hit rate

Definition at line 307 of file TOPTrack.h.

◆ m_charge

double m_charge = 0
private

track charge in units of elementary charge

Definition at line 292 of file TOPTrack.h.

◆ m_columnHits

std::unordered_multimap<unsigned, const SelectedHit*> m_columnHits
private

selected hits mapped to pixel columns

Definition at line 308 of file TOPTrack.h.

◆ m_emissionPoints

std::map<double, TOPTrack::AssumedEmission> m_emissionPoints
mutableprivate

assumed emission points in module local frame

Definition at line 311 of file TOPTrack.h.

◆ m_extHit

const ExtHit* m_extHit = 0
private

extrapolated hit

Definition at line 301 of file TOPTrack.h.

◆ m_feSetting

DBObjPtr<TOPFrontEndSetting> m_feSetting
private

front-end settings

Definition at line 298 of file TOPTrack.h.

◆ m_helix

TOP::HelixSwimmer m_helix
private

trajectory helix in nominal slot frame

Definition at line 296 of file TOPTrack.h.

◆ m_length

double m_length = 0
private

trajectory length within quartz

Definition at line 295 of file TOPTrack.h.

◆ m_mcParticle

const MCParticle* m_mcParticle = 0
private

MC particle.

Definition at line 302 of file TOPTrack.h.

◆ m_moduleID

int m_moduleID = 0
private

slot ID

Definition at line 289 of file TOPTrack.h.

◆ m_momentum

double m_momentum = 0
private

track momentum magnitude at TOP

Definition at line 290 of file TOPTrack.h.

◆ m_pT

double m_pT = 0
private

transverse momentum at POCA

Definition at line 291 of file TOPTrack.h.

◆ m_selectedHits

std::vector<SelectedHit> m_selectedHits
private

selected photon hits from TOPDigits belonging to this slot ID

Definition at line 306 of file TOPTrack.h.

◆ m_TOFLength

double m_TOFLength = 0
private

trajectory length corresponding to TOF of extrapolated hit

Definition at line 293 of file TOPTrack.h.

◆ m_track

const Track* m_track = 0
private

mdst track

Definition at line 300 of file TOPTrack.h.

◆ m_trackLength

double m_trackLength = 0
private

trajectory length from IP to average photon emission point

Definition at line 294 of file TOPTrack.h.

◆ m_valid

bool m_valid = false
private

true for properly defined track

Definition at line 304 of file TOPTrack.h.


The documentation for this class was generated from the following files: