Belle II Software development
TOPTrack.h
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#pragma once
10
11#include <framework/gearbox/Const.h>
12#include <top/reconstruction_cpp/HelixSwimmer.h>
13#include <top/reconstruction_cpp/RaytracerBase.h>
14#include <framework/database/DBObjPtr.h>
15#include <top/dbobjects/TOPCalModuleAlignment.h>
16#include <top/dbobjects/TOPFrontEndSetting.h>
17#include <mdst/dataobjects/MCParticle.h>
18
19#include <vector>
20#include <map>
21#include <unordered_map>
22#include <string>
23
24namespace Belle2 {
30 class Track;
31 class ExtHit;
32 class TOPBarHit;
33
34 namespace TOP {
35
39 class TOPTrack {
40
41 public:
42
46 struct TrackAngles {
47 double cosTh = 0;
48 double sinTh = 0;
49 double cosFi = 0;
50 double sinFi = 0;
56 {}
57
62 explicit TrackAngles(const ROOT::Math::XYZVector& direction);
63
68 ROOT::Math::XYZVector getDirection() const {return ROOT::Math::XYZVector(cosFi * sinTh, sinFi * sinTh, cosTh);}
69 };
70
75 ROOT::Math::XYZPoint position;
77 bool isSet = false;
78 };
79
83 struct SelectedHit {
84 int pixelID = 0;
85 double time = 0;
86 double timeErr = 0;
94 SelectedHit(int pix, double t, double terr):
95 pixelID(pix), time(t), timeErr(terr)
96 {}
97 };
98
103 {}
104
111 explicit TOPTrack(const Track& track, const std::string& digitsName = "",
112 const Const::ChargedStable& chargedStable = Const::pion);
113
119 explicit TOPTrack(const ExtHit* extHit, const std::string& digitsName = "");
120
127 bool overrideTransformation(const ROOT::Math::Transform3D& transform)
128 {
129 m_valid = setHelix(transform);
130 return m_valid;
131 }
132
137 bool isValid() const {return m_valid;}
138
143 int getModuleID() const {return m_moduleID;}
144
149 double getMomentumMag() const {return m_momentum;}
150
155 double getTransverseMomentum() const {return m_pT;}
156
161 double getCharge() const {return m_charge;}
162
167 double getTrackLength() const {return m_trackLength;}
168
173 double getLengthInQuartz() const {return m_length;}
174
181 double getBeta(const Const::ChargedStable& particle, double overrideMass = 0) const;
182
188 const TOPTrack::AssumedEmission& getEmissionPoint(double dL = 0) const;
189
197 double getTOF(const Const::ChargedStable& particle, double dL = 0, double overrideMass = 0) const;
198
204 const TOP::HelixSwimmer& getHelix() const {return m_helix;}
205
210 const Track* getTrack() const {return m_track;}
211
216 const ExtHit* getExtHit() const {return m_extHit;}
217
222 const MCParticle* getMCParticle() const {return m_mcParticle;}
223
228 int getPDGCode() const
229 {
230 if (m_mcParticle) return m_mcParticle->getPDG();
231 return 0;
232 }
233
238 const TOPBarHit* getBarHit() const {return m_barHit;}
239
244 const std::vector<SelectedHit>& getSelectedHits() const {return m_selectedHits;}
245
250 double getBkgRate() const {return m_bkgRate;}
251
259 bool isScanRequired(unsigned col, double time, double wid) const;
260
261 private:
262
269 void set(const Track& track, const std::string& digitsName, const Const::ChargedStable& chargedStable);
270
276 bool setHelix(const ROOT::Math::Transform3D& transform);
277
286 bool xsecPrism(std::vector<double>& lengths, std::vector<ROOT::Math::XYZPoint>& positions,
287 const RaytracerBase::Prism& prism, const ROOT::Math::Transform3D& transform);
288
289 int m_moduleID = 0;
290 double m_momentum = 0;
291 double m_pT = 0;
292 double m_charge = 0;
293 double m_TOFLength = 0;
294 double m_trackLength = 0;
295 double m_length = 0;
300 const Track* m_track = 0;
301 const ExtHit* m_extHit = 0;
303 const TOPBarHit* m_barHit = 0;
304 bool m_valid = false;
306 std::vector<SelectedHit> m_selectedHits;
307 double m_bkgRate = 0;
308 std::unordered_multimap<unsigned, const SelectedHit*> m_columnHits;
311 mutable std::map<double, TOPTrack::AssumedEmission> m_emissionPoints;
312
313 };
314
315
316 inline double TOPTrack::getBeta(const Const::ChargedStable& chargedStable, double overrideMass) const
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 }
323
324 inline double TOPTrack::getTOF(const Const::ChargedStable& chargedStable, double dL, double overrideMass) const
325 {
326 return (m_trackLength + dL) / getBeta(chargedStable, overrideMass) / Const::speedOfLight;
327 }
328
329
330 } // end TOP namespace
332} // end Belle2 namespace
333
334
Provides a type-safe way to pass members of the chargedStableSet set.
Definition: Const.h:589
double getMass() const
Particle mass.
Definition: UnitConst.cc:356
static const ChargedStable pion
charged pion particle
Definition: Const.h:661
static const double speedOfLight
[cm/ns]
Definition: Const.h:695
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
Store one Ext hit as a ROOT object.
Definition: ExtHit.h:31
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
int getPDG() const
Return PDG code of particle.
Definition: MCParticle.h:112
Class to store track parameters of incoming MC particles relation to MCParticle filled in top/simulat...
Definition: TOPBarHit.h:27
Utility for propagation of a particle along helix.
Definition: HelixSwimmer.h:30
Reconstructed track at TOP.
Definition: TOPTrack.h:39
bool overrideTransformation(const ROOT::Math::Transform3D &transform)
Overrides transformation from local to nominal frame, which is by default obtained from DB.
Definition: TOPTrack.h:127
int getPDGCode() const
Returns PDG code of associated MCParticle (returns 0 if none)
Definition: TOPTrack.h:228
const Track * getTrack() const
Returns mdst track.
Definition: TOPTrack.h:210
double m_bkgRate
estimated background hit rate
Definition: TOPTrack.h:307
double getLengthInQuartz() const
Returns track length within quartz.
Definition: TOPTrack.h:173
const MCParticle * getMCParticle() const
Returns MC particle assigned to this track (if any)
Definition: TOPTrack.h:222
DBObjPtr< TOPFrontEndSetting > m_feSetting
front-end settings
Definition: TOPTrack.h:298
DBObjPtr< TOPCalModuleAlignment > m_alignment
module alignment constants
Definition: TOPTrack.h:297
double getBkgRate() const
Returns estimated background hit rate.
Definition: TOPTrack.h:250
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.
Definition: TOPTrack.cc:370
const TOPTrack::AssumedEmission & getEmissionPoint(double dL=0) const
Returns assumed photon emission position and track direction.
Definition: TOPTrack.cc:357
std::unordered_multimap< unsigned, const SelectedHit * > m_columnHits
selected hits mapped to pixel columns
Definition: TOPTrack.h:308
double getCharge() const
Returns charge.
Definition: TOPTrack.h:161
bool isValid() const
Checks if track is successfully constructed.
Definition: TOPTrack.h:137
TOPTrack()
Default constructor.
Definition: TOPTrack.h:102
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
const ExtHit * getExtHit() const
Returns extrapolated hit (track entrance to the bar)
Definition: TOPTrack.h:216
int m_moduleID
slot ID
Definition: TOPTrack.h:289
double m_momentum
track momentum magnitude at TOP
Definition: TOPTrack.h:290
int getModuleID() const
Returns slot ID.
Definition: TOPTrack.h:143
std::map< double, TOPTrack::AssumedEmission > m_emissionPoints
assumed emission points in module local frame
Definition: TOPTrack.h:311
bool m_valid
true for properly defined track
Definition: TOPTrack.h:304
double m_pT
transverse momentum at POCA
Definition: TOPTrack.h:291
double getTransverseMomentum() const
Returns transverse momentum (at POCA)
Definition: TOPTrack.h:155
bool setHelix(const ROOT::Math::Transform3D &transform)
Sets helix (helix is given in nominal frame)
Definition: TOPTrack.cc:170
const std::vector< SelectedHit > & getSelectedHits() const
Returns selected photon hits from TOPDigits belonging to the slot ID.
Definition: TOPTrack.h:244
double m_trackLength
trajectory length from IP to average photon emission point
Definition: TOPTrack.h:294
double getMomentumMag() const
Returns momentum magnitude (extrapolated to TOP)
Definition: TOPTrack.h:149
double m_charge
track charge in units of elementary charge
Definition: TOPTrack.h:292
std::vector< SelectedHit > m_selectedHits
selected photon hits from TOPDigits belonging to this slot ID
Definition: TOPTrack.h:306
const MCParticle * m_mcParticle
MC particle.
Definition: TOPTrack.h:302
TOP::HelixSwimmer m_helix
trajectory helix in nominal slot frame
Definition: TOPTrack.h:296
double m_length
trajectory length within quartz
Definition: TOPTrack.h:295
const TOP::HelixSwimmer & getHelix() const
Returns helix Helix is given in nominal slot frame and with reference position at average photon emis...
Definition: TOPTrack.h:204
double getTrackLength() const
Returns track length from IP to the average position of photon emission within quartz.
Definition: TOPTrack.h:167
void set(const Track &track, const std::string &digitsName, const Const::ChargedStable &chargedStable)
Sets the object (called by constructors)
Definition: TOPTrack.cc:91
const TOPBarHit * getBarHit() const
Returns bar hit of MC particle assigned to this track (if any)
Definition: TOPTrack.h:238
const ExtHit * m_extHit
extrapolated hit
Definition: TOPTrack.h:301
double getTOF(const Const::ChargedStable &particle, double dL=0, double overrideMass=0) const
Returns time-of-flight from IP to photon emission position.
Definition: TOPTrack.h:324
const Track * m_track
mdst track
Definition: TOPTrack.h:300
double getBeta(const Const::ChargedStable &particle, double overrideMass=0) const
Returns particle beta.
Definition: TOPTrack.h:316
double m_TOFLength
trajectory length corresponding to TOF of extrapolated hit
Definition: TOPTrack.h:293
const TOPBarHit * m_barHit
bar hit
Definition: TOPTrack.h:303
Class that bundles various TrackFitResults.
Definition: Track.h:25
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
Abstract base class for different kinds of events.
prism data in module local frame.
assumed photon emission point in local frame
Definition: TOPTrack.h:74
ROOT::Math::XYZPoint position
position
Definition: TOPTrack.h:75
TrackAngles trackAngles
sine and cosine of track polar and azimuthal angles
Definition: TOPTrack.h:76
selected photon hit from TOPDigits
Definition: TOPTrack.h:83
SelectedHit(int pix, double t, double terr)
Constructor.
Definition: TOPTrack.h:94
double timeErr
time uncertainty
Definition: TOPTrack.h:86
Sine and cosine of track polar and azimuthal angles at assumed photon emission.
Definition: TOPTrack.h:46
double sinFi
sine of azimuthal angle
Definition: TOPTrack.h:50
TrackAngles()
Default constructor.
Definition: TOPTrack.h:55
double cosFi
cosine of azimuthal angle
Definition: TOPTrack.h:49
double cosTh
cosine of polar angle
Definition: TOPTrack.h:47
ROOT::Math::XYZVector getDirection() const
Returns direction vector.
Definition: TOPTrack.h:68
double sinTh
sine of polar angle
Definition: TOPTrack.h:48