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/TOPCalTOFCorrection.h>
17#include <top/dbobjects/TOPFrontEndSetting.h>
18#include <mdst/dataobjects/MCParticle.h>
19
20#include <vector>
21#include <map>
22#include <unordered_map>
23#include <string>
24
25namespace Belle2 {
30
31 class Track;
32 class ExtHit;
33 class TOPBarHit;
34
35 namespace TOP {
36
40 class TOPTrack {
41
42 public:
43
47 struct TrackAngles {
48 double cosTh = 0;
49 double sinTh = 0;
50 double cosFi = 0;
51 double sinFi = 0;
52
57 {}
58
63 explicit TrackAngles(const ROOT::Math::XYZVector& direction);
64
69 ROOT::Math::XYZVector getDirection() const {return ROOT::Math::XYZVector(cosFi * sinTh, sinFi * sinTh, cosTh);}
70 };
71
76 ROOT::Math::XYZPoint position;
78 bool isSet = false;
79 };
80
84 struct SelectedHit {
85 int pixelID = 0;
86 double time = 0;
87 double timeErr = 0;
88
95 SelectedHit(int pix, double t, double terr):
96 pixelID(pix), time(t), timeErr(terr)
97 {}
98 };
99
104 {}
105
112 explicit TOPTrack(const Track& track, const std::string& digitsName = "",
113 const Const::ChargedStable& chargedStable = Const::pion);
114
120 explicit TOPTrack(const ExtHit* extHit, const std::string& digitsName = "");
121
128 bool overrideTransformation(const ROOT::Math::Transform3D& transform)
129 {
130 m_valid = setHelix(transform);
131 return m_valid;
132 }
133
138 void setTOFCorrection(const DBObjPtr<TOPCalTOFCorrection>& tofCorrections);
139
144 bool isValid() const {return m_valid;}
145
150 int getModuleID() const {return m_moduleID;}
151
156 double getMomentumMag() const {return m_momentum;}
157
162 double getTransverseMomentum() const {return m_pT;}
163
168 double getCharge() const {return m_charge;}
169
174 double getTrackLength() const {return m_trackLength;}
175
180 double getLengthInQuartz() const {return m_length;}
181
188 double getBeta(const Const::ChargedStable& particle, double overrideMass = 0) const;
189
195 const TOPTrack::AssumedEmission& getEmissionPoint(double dL = 0) const;
196
204 double getTOF(const Const::ChargedStable& particle, double dL = 0, double overrideMass = 0) const;
205
211 const TOP::HelixSwimmer& getHelix() const {return m_helix;}
212
217 const Track* getTrack() const {return m_track;}
218
223 const ExtHit* getExtHit() const {return m_extHit;}
224
229 const MCParticle* getMCParticle() const {return m_mcParticle;}
230
235 int getPDGCode() const
236 {
237 if (m_mcParticle) return m_mcParticle->getPDG();
238 return 0;
239 }
240
245 const TOPBarHit* getBarHit() const {return m_barHit;}
246
251 const std::vector<SelectedHit>& getSelectedHits() const {return m_selectedHits;}
252
257 double getBkgRate() const {return m_bkgRate;}
258
266 bool isScanRequired(unsigned col, double time, double wid) const;
267
268 private:
269
276 void set(const Track& track, const std::string& digitsName, const Const::ChargedStable& chargedStable);
277
283 bool setHelix(const ROOT::Math::Transform3D& transform);
284
293 bool xsecPrism(std::vector<double>& lengths, std::vector<ROOT::Math::XYZPoint>& positions,
294 const RaytracerBase::Prism& prism, const ROOT::Math::Transform3D& transform);
295
296 int m_moduleID = 0;
297 double m_momentum = 0;
298 double m_pT = 0;
299 double m_charge = 0;
300 double m_TOFLength = 0;
301 double m_TOFCorrection = 0;
302 double m_trackLength = 0;
303 double m_length = 0;
307
308 const Track* m_track = 0;
309 const ExtHit* m_extHit = 0;
311 const TOPBarHit* m_barHit = 0;
312 bool m_valid = false;
313
314 std::vector<SelectedHit> m_selectedHits;
315 double m_bkgRate = 0;
316 std::unordered_multimap<unsigned, const SelectedHit*> m_columnHits;
317
319 mutable std::map<double, TOPTrack::AssumedEmission> m_emissionPoints;
320
321 };
322
323
324 inline double TOPTrack::getBeta(const Const::ChargedStable& chargedStable, double overrideMass) const
325 {
326 double mass = chargedStable.getMass();
327 if (overrideMass > 0)
328 mass = overrideMass;
329 return m_momentum / sqrt(m_momentum * m_momentum + mass * mass);
330 }
331
332 inline double TOPTrack::getTOF(const Const::ChargedStable& chargedStable, double dL, double overrideMass) const
333 {
334 return (m_trackLength + dL) / getBeta(chargedStable, overrideMass) / Const::speedOfLight + m_TOFCorrection;
335 }
336
337
338 } // end TOP namespace
340} // end Belle2 namespace
341
342
Provides a type-safe way to pass members of the chargedStableSet set.
Definition Const.h:589
double getMass() const
Particle mass.
Definition UnitConst.cc:353
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
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.
bool overrideTransformation(const ROOT::Math::Transform3D &transform)
Overrides transformation from local to nominal frame, which is by default obtained from DB.
Definition TOPTrack.h:128
int getPDGCode() const
Returns PDG code of associated MCParticle (returns 0 if none)
Definition TOPTrack.h:235
void setTOFCorrection(const DBObjPtr< TOPCalTOFCorrection > &tofCorrections)
Sets time-of-flight correction value.
Definition TOPTrack.cc:386
const Track * getTrack() const
Returns mdst track.
Definition TOPTrack.h:217
double m_bkgRate
estimated background hit rate
Definition TOPTrack.h:315
double getLengthInQuartz() const
Returns track length within quartz.
Definition TOPTrack.h:180
const MCParticle * getMCParticle() const
Returns MC particle assigned to this track (if any)
Definition TOPTrack.h:229
DBObjPtr< TOPFrontEndSetting > m_feSetting
front-end settings
Definition TOPTrack.h:306
DBObjPtr< TOPCalModuleAlignment > m_alignment
module alignment constants
Definition TOPTrack.h:305
double getBkgRate() const
Returns estimated background hit rate.
Definition TOPTrack.h:257
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:316
double getCharge() const
Returns charge.
Definition TOPTrack.h:168
bool isValid() const
Checks if track is successfully constructed.
Definition TOPTrack.h:144
TOPTrack()
Default constructor.
Definition TOPTrack.h:103
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:223
int m_moduleID
slot ID
Definition TOPTrack.h:296
double m_TOFCorrection
time-of-flight correction
Definition TOPTrack.h:301
double m_momentum
track momentum magnitude at TOP
Definition TOPTrack.h:297
int getModuleID() const
Returns slot ID.
Definition TOPTrack.h:150
std::map< double, TOPTrack::AssumedEmission > m_emissionPoints
assumed emission points in module local frame
Definition TOPTrack.h:319
bool m_valid
true for properly defined track
Definition TOPTrack.h:312
double m_pT
transverse momentum at POCA
Definition TOPTrack.h:298
double getTransverseMomentum() const
Returns transverse momentum (at POCA)
Definition TOPTrack.h:162
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:251
double m_trackLength
trajectory length from IP to average photon emission point
Definition TOPTrack.h:302
double getMomentumMag() const
Returns momentum magnitude (extrapolated to TOP)
Definition TOPTrack.h:156
double m_charge
track charge in units of elementary charge
Definition TOPTrack.h:299
std::vector< SelectedHit > m_selectedHits
selected photon hits from TOPDigits belonging to this slot ID
Definition TOPTrack.h:314
const MCParticle * m_mcParticle
MC particle.
Definition TOPTrack.h:310
TOP::HelixSwimmer m_helix
trajectory helix in nominal slot frame
Definition TOPTrack.h:304
double m_length
trajectory length within quartz
Definition TOPTrack.h:303
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:211
double getTrackLength() const
Returns track length from IP to the average position of photon emission within quartz.
Definition TOPTrack.h:174
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:245
const ExtHit * m_extHit
extrapolated hit
Definition TOPTrack.h:309
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:332
const Track * m_track
mdst track
Definition TOPTrack.h:308
double getBeta(const Const::ChargedStable &particle, double overrideMass=0) const
Returns particle beta.
Definition TOPTrack.h:324
double m_TOFLength
trajectory length corresponding to TOF of extrapolated hit
Definition TOPTrack.h:300
const TOPBarHit * m_barHit
bar hit
Definition TOPTrack.h:311
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:75
ROOT::Math::XYZPoint position
position
Definition TOPTrack.h:76
TrackAngles trackAngles
sine and cosine of track polar and azimuthal angles
Definition TOPTrack.h:77
SelectedHit(int pix, double t, double terr)
Constructor.
Definition TOPTrack.h:95
double timeErr
time uncertainty
Definition TOPTrack.h:87
Sine and cosine of track polar and azimuthal angles at assumed photon emission.
Definition TOPTrack.h:47
double sinFi
sine of azimuthal angle
Definition TOPTrack.h:51
TrackAngles()
Default constructor.
Definition TOPTrack.h:56
double cosFi
cosine of azimuthal angle
Definition TOPTrack.h:50
double cosTh
cosine of polar angle
Definition TOPTrack.h:48
ROOT::Math::XYZVector getDirection() const
Returns direction vector.
Definition TOPTrack.h:69
double sinTh
sine of polar angle
Definition TOPTrack.h:49