Belle II Software  release-06-02-00
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 <TVector3.h>
12 #include <framework/gearbox/Const.h>
13 #include <top/reconstruction_cpp/HelixSwimmer.h>
14 #include <top/reconstruction_cpp/RaytracerBase.h>
15 #include <framework/database/DBObjPtr.h>
16 #include <top/dbobjects/TOPCalModuleAlignment.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 
25 namespace Belle2 {
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;
57  {}
58 
63  explicit TrackAngles(const TVector3& direction);
64 
69  TVector3 getDirection() const {return TVector3(cosFi * sinTh, sinFi * sinTh, cosTh);}
70  };
71 
75  struct AssumedEmission {
76  TVector3 position;
78  bool isSet = false;
79  };
80 
84  struct SelectedHit {
85  int pixelID = 0;
86  double time = 0;
87  double timeErr = 0;
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 
129  bool overrideTransformation(const TRotation& rotation, const TVector3& translation)
130  {
131  m_valid = setHelix(rotation, translation);
132  return m_valid;
133  }
134 
139  bool isValid() const {return m_valid;}
140 
145  int getModuleID() const {return m_moduleID;}
146 
151  double getMomentumMag() const {return m_momentum;}
152 
157  double getTransverseMomentum() const {return m_pT;}
158 
163  double getCharge() const {return m_charge;}
164 
169  double getTrackLength() const {return m_trackLength;}
170 
175  double getLengthInQuartz() const {return m_length;}
176 
183  double getBeta(const Const::ChargedStable& particle, double overrideMass = 0) const;
184 
190  const TOPTrack::AssumedEmission& getEmissionPoint(double dL = 0) const;
191 
199  double getTOF(const Const::ChargedStable& particle, double dL = 0, double overrideMass = 0) const;
200 
206  const TOP::HelixSwimmer& getHelix() const {return m_helix;}
207 
212  const Track* getTrack() const {return m_track;}
213 
218  const ExtHit* getExtHit() const {return m_extHit;}
219 
224  const MCParticle* getMCParticle() const {return m_mcParticle;}
225 
230  int getPDGCode() const
231  {
232  if (m_mcParticle) return m_mcParticle->getPDG();
233  return 0;
234  }
235 
240  const TOPBarHit* getBarHit() const {return m_barHit;}
241 
246  const std::vector<SelectedHit>& getSelectedHits() const {return m_selectedHits;}
247 
252  double getBkgRate() const {return m_bkgRate;}
253 
261  bool isScanRequired(unsigned col, double time, double wid) const;
262 
263  private:
264 
271  void set(const Track& track, const std::string& digitsName, const Const::ChargedStable& chargedStable);
272 
279  bool setHelix(const TRotation& rotation, const TVector3& translation);
280 
290  bool xsecPrism(std::vector<double>& lengths, std::vector<TVector3>& positions,
291  const RaytracerBase::Prism& prism, const TRotation& rotation, const TVector3& translation);
292 
293  int m_moduleID = 0;
294  double m_momentum = 0;
295  double m_pT = 0;
296  double m_charge = 0;
297  double m_TOFLength = 0;
298  double m_trackLength = 0;
299  double m_length = 0;
304  const Track* m_track = 0;
305  const ExtHit* m_extHit = 0;
307  const TOPBarHit* m_barHit = 0;
308  bool m_valid = false;
310  std::vector<SelectedHit> m_selectedHits;
311  double m_bkgRate = 0;
312  std::unordered_multimap<unsigned, const SelectedHit*> m_columnHits;
315  mutable std::map<double, TOPTrack::AssumedEmission> m_emissionPoints;
316 
317  };
318 
319 
320  inline double TOPTrack::getBeta(const Const::ChargedStable& chargedStable, double overrideMass) const
321  {
322  double mass = chargedStable.getMass();
323  if (overrideMass > 0)
324  mass = overrideMass;
325  return m_momentum / sqrt(m_momentum * m_momentum + mass * mass);
326  }
327 
328  inline double TOPTrack::getTOF(const Const::ChargedStable& chargedStable, double dL, double overrideMass) const
329  {
330  return (m_trackLength + dL) / getBeta(chargedStable, overrideMass) / Const::speedOfLight;
331  }
332 
333 
334  } // end TOP namespace
336 } // end Belle2 namespace
337 
338 
Provides a type-safe way to pass members of the chargedStableSet set.
Definition: Const.h:470
double getMass() const
Particle mass.
Definition: UnitConst.cc:323
static const ChargedStable pion
charged pion particle
Definition: Const.h:542
static const double speedOfLight
[cm/ns]
Definition: Const.h:575
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
Store one Ext hit as a ROOT object.
Definition: ExtHit.h:30
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:26
Utility for propagation of a particle along helix.
Definition: HelixSwimmer.h:29
Reconstructed track at TOP.
Definition: TOPTrack.h:40
int getPDGCode() const
Returns PDG code of associated MCParticle (returns 0 if none)
Definition: TOPTrack.h:230
bool setHelix(const TRotation &rotation, const TVector3 &translation)
Sets helix (helix is given in nominal frame)
Definition: TOPTrack.cc:167
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:206
double m_bkgRate
estimated background hit rate
Definition: TOPTrack.h:311
double getLengthInQuartz() const
Returns track length within quartz.
Definition: TOPTrack.h:175
DBObjPtr< TOPFrontEndSetting > m_feSetting
front-end settings
Definition: TOPTrack.h:302
DBObjPtr< TOPCalModuleAlignment > m_alignment
module alignment constants
Definition: TOPTrack.h:301
double getBkgRate() const
Returns estimated background hit rate.
Definition: TOPTrack.h:252
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:368
const TOPTrack::AssumedEmission & getEmissionPoint(double dL=0) const
Returns assumed photon emission position and track direction.
Definition: TOPTrack.cc:355
std::unordered_multimap< unsigned, const SelectedHit * > m_columnHits
selected hits mapped to pixel columns
Definition: TOPTrack.h:312
double getCharge() const
Returns charge.
Definition: TOPTrack.h:163
bool isValid() const
Checks if track is successfully constructed.
Definition: TOPTrack.h:139
const ExtHit * getExtHit() const
Returns extrapolated hit (track entrance to the bar)
Definition: TOPTrack.h:218
TOPTrack()
Default constructor.
Definition: TOPTrack.h:103
const TOPBarHit * getBarHit() const
Returns bar hit of MC particle assigned to this track (if any)
Definition: TOPTrack.h:240
int m_moduleID
slot ID
Definition: TOPTrack.h:293
const Track * getTrack() const
Returns mdst track.
Definition: TOPTrack.h:212
double m_momentum
track momentum magnitude at TOP
Definition: TOPTrack.h:294
int getModuleID() const
Returns slot ID.
Definition: TOPTrack.h:145
const MCParticle * getMCParticle() const
Returns MC particle assigned to this track (if any)
Definition: TOPTrack.h:224
std::map< double, TOPTrack::AssumedEmission > m_emissionPoints
assumed emission points in module local frame
Definition: TOPTrack.h:315
bool m_valid
true for properly defined track
Definition: TOPTrack.h:308
double m_pT
transverse momentum at POCA
Definition: TOPTrack.h:295
double getTransverseMomentum() const
Returns transverse momentum (at POCA)
Definition: TOPTrack.h:157
const std::vector< SelectedHit > & getSelectedHits() const
Returns selected photon hits from TOPDigits belonging to the slot ID.
Definition: TOPTrack.h:246
double m_trackLength
trajectory length from IP to average photon emission point
Definition: TOPTrack.h:298
double getMomentumMag() const
Returns momentum magnitude (extrapolated to TOP)
Definition: TOPTrack.h:151
double m_charge
track charge in units of elementary charge
Definition: TOPTrack.h:296
std::vector< SelectedHit > m_selectedHits
selected photon hits from TOPDigits belonging to this slot ID
Definition: TOPTrack.h:310
const MCParticle * m_mcParticle
MC particle.
Definition: TOPTrack.h:306
bool xsecPrism(std::vector< double > &lengths, std::vector< TVector3 > &positions, const RaytracerBase::Prism &prism, const TRotation &rotation, const TVector3 &translation)
Calculates intersection of trajectory with prism.
Definition: TOPTrack.cc:270
TOP::HelixSwimmer m_helix
trajectory helix in nominal slot frame
Definition: TOPTrack.h:300
double m_length
trajectory length within quartz
Definition: TOPTrack.h:299
double getTrackLength() const
Returns track length from IP to the average position of photon emission within quartz.
Definition: TOPTrack.h:169
void set(const Track &track, const std::string &digitsName, const Const::ChargedStable &chargedStable)
Sets the object (called by constructors)
Definition: TOPTrack.cc:88
const ExtHit * m_extHit
extrapolated hit
Definition: TOPTrack.h:305
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:328
bool overrideTransformation(const TRotation &rotation, const TVector3 &translation)
Overrides transformation from local to nominal frame, which is by default obtained from DB.
Definition: TOPTrack.h:129
const Track * m_track
mdst track
Definition: TOPTrack.h:304
double getBeta(const Const::ChargedStable &particle, double overrideMass=0) const
Returns particle beta.
Definition: TOPTrack.h:320
double m_TOFLength
trajectory length corresponding to TOF of extrapolated hit
Definition: TOPTrack.h:297
const TOPBarHit * m_barHit
bar hit
Definition: TOPTrack.h:307
Class that bundles various TrackFitResults.
Definition: Track.h:25
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
TrackAngles trackAngles
sine and cosine of track polar and azimuthal angles
Definition: TOPTrack.h:77
selected photon hit from TOPDigits
Definition: TOPTrack.h:84
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
double sinTh
sine of polar angle
Definition: TOPTrack.h:49
TVector3 getDirection() const
Returns direction vector.
Definition: TOPTrack.h:69