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 <top/dbobjects/TOPNominalTTS.h>
19#include <mdst/dataobjects/MCParticle.h>
20
21#include <vector>
22#include <map>
23#include <unordered_map>
24#include <string>
25
26namespace Belle2 {
31
32 class Track;
33 class ExtHit;
34 class TOPBarHit;
35
36 namespace TOP {
37
41 class TOPTrack {
42
43 public:
44
48 struct TrackAngles {
49 double cosTh = 0;
50 double sinTh = 0;
51 double cosFi = 0;
52 double sinFi = 0;
53
58 {}
59
64 explicit TrackAngles(const ROOT::Math::XYZVector& direction);
65
70 ROOT::Math::XYZVector getDirection() const {return ROOT::Math::XYZVector(cosFi * sinTh, sinFi * sinTh, cosTh);}
71 };
72
77 ROOT::Math::XYZPoint position;
79 bool isSet = false;
80 };
81
85 struct SelectedHit {
86 int pixelID = 0;
87 double time = 0;
88 double timeErr = 0;
89
96 SelectedHit(int pix, double t, double terr):
97 pixelID(pix), time(t), timeErr(terr)
98 {}
99 };
100
105 {}
106
113 explicit TOPTrack(const Track& track, const std::string& digitsName = "",
114 const Const::ChargedStable& chargedStable = Const::pion);
115
121 explicit TOPTrack(const ExtHit* extHit, const std::string& digitsName = "");
122
129 bool overrideTransformation(const ROOT::Math::Transform3D& transform)
130 {
131 m_valid = setHelix(transform);
132 return m_valid;
133 }
134
139 void setTOFCorrection(const DBObjPtr<TOPCalTOFCorrection>& tofCorrections);
140
145 bool isValid() const {return m_valid;}
146
151 int getModuleID() const {return m_moduleID;}
152
157 double getMomentumMag() const {return m_momentum;}
158
163 double getTransverseMomentum() const {return m_pT;}
164
169 double getCharge() const {return m_charge;}
170
175 double getTrackLength() const {return m_trackLength;}
176
181 double getLengthInQuartz() const {return m_length;}
182
189 double getBeta(const Const::ChargedStable& particle, double overrideMass = 0) const;
190
196 const TOPTrack::AssumedEmission& getEmissionPoint(double dL = 0) const;
197
205 double getTOF(const Const::ChargedStable& particle, double dL = 0, double overrideMass = 0) const;
206
212 const TOP::HelixSwimmer& getHelix() const {return m_helix;}
213
218 const Track* getTrack() const {return m_track;}
219
224 const ExtHit* getExtHit() const {return m_extHit;}
225
230 const MCParticle* getMCParticle() const {return m_mcParticle;}
231
236 int getPDGCode() const
237 {
238 if (m_mcParticle) return m_mcParticle->getPDG();
239 return 0;
240 }
241
246 const TOPBarHit* getBarHit() const {return m_barHit;}
247
252 const std::vector<SelectedHit>& getSelectedHits() const {return m_selectedHits;}
253
258 double getBkgRate() const {return m_bkgRate;}
259
267 bool isScanRequired(unsigned col, double time, double wid) const;
268
269 private:
270
277 void set(const Track& track, const std::string& digitsName, const Const::ChargedStable& chargedStable);
278
284 bool setHelix(const ROOT::Math::Transform3D& transform);
285
294 bool xsecPrism(std::vector<double>& lengths, std::vector<ROOT::Math::XYZPoint>& positions,
295 const RaytracerBase::Prism& prism, const ROOT::Math::Transform3D& transform);
296
297 int m_moduleID = 0;
298 double m_momentum = 0;
299 double m_pT = 0;
300 double m_charge = 0;
301 double m_TOFLength = 0;
302 double m_TOFCorrection = 0;
303 double m_trackLength = 0;
304 double m_length = 0;
308
309 const Track* m_track = 0;
310 const ExtHit* m_extHit = 0;
312 const TOPBarHit* m_barHit = 0;
313 bool m_valid = false;
314
315 std::vector<SelectedHit> m_selectedHits;
316 double m_bkgRate = 0;
317 const TOPNominalTTS* m_tts = nullptr;
318 std::unordered_multimap<unsigned, const SelectedHit*> m_columnHits;
319
321 mutable std::map<double, TOPTrack::AssumedEmission> m_emissionPoints;
322
325
326 };
327
328
329 inline double TOPTrack::getBeta(const Const::ChargedStable& chargedStable, double overrideMass) const
330 {
331 double mass = chargedStable.getMass();
332 if (overrideMass > 0)
333 mass = overrideMass;
334 return m_momentum / sqrt(m_momentum * m_momentum + mass * mass);
335 }
336
337 inline double TOPTrack::getTOF(const Const::ChargedStable& chargedStable, double dL, double overrideMass) const
338 {
339 return (m_trackLength + dL) / getBeta(chargedStable, overrideMass) / Const::speedOfLight + m_TOFCorrection;
340 }
341
342
343 } // end TOP namespace
345} // end Belle2 namespace
346
347
Provides a type-safe way to pass members of the chargedStableSet set.
Definition Const.h:590
double getMass() const
Particle mass.
Definition UnitConst.cc:353
static const ChargedStable pion
charged pion particle
Definition Const.h:662
static const double speedOfLight
[cm/ns]
Definition Const.h:696
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
Nominal time transition spread of PMT.
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:129
int getPDGCode() const
Returns PDG code of associated MCParticle (returns 0 if none)
Definition TOPTrack.h:236
void setTOFCorrection(const DBObjPtr< TOPCalTOFCorrection > &tofCorrections)
Sets time-of-flight correction value.
Definition TOPTrack.cc:389
const Track * getTrack() const
Returns mdst track.
Definition TOPTrack.h:218
double m_bkgRate
estimated background hit rate
Definition TOPTrack.h:316
double getLengthInQuartz() const
Returns track length within quartz.
Definition TOPTrack.h:181
const MCParticle * getMCParticle() const
Returns MC particle assigned to this track (if any)
Definition TOPTrack.h:230
DBObjPtr< TOPFrontEndSetting > m_feSetting
front-end settings
Definition TOPTrack.h:307
DBObjPtr< TOPCalModuleAlignment > m_alignment
module alignment constants
Definition TOPTrack.h:306
double getBkgRate() const
Returns estimated background hit rate.
Definition TOPTrack.h:258
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:373
const TOPTrack::AssumedEmission & getEmissionPoint(double dL=0) const
Returns assumed photon emission position and track direction.
Definition TOPTrack.cc:359
std::unordered_multimap< unsigned, const SelectedHit * > m_columnHits
selected hits mapped to pixel columns
Definition TOPTrack.h:318
const TOPNominalTTS * m_tts
PMT independent TTS, used by isScanRequired.
Definition TOPTrack.h:317
double getCharge() const
Returns charge.
Definition TOPTrack.h:169
bool isValid() const
Checks if track is successfully constructed.
Definition TOPTrack.h:145
TOPTrack()
Default constructor.
Definition TOPTrack.h:104
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:275
const ExtHit * getExtHit() const
Returns extrapolated hit (track entrance to the bar)
Definition TOPTrack.h:224
int m_moduleID
slot ID
Definition TOPTrack.h:297
double m_TOFCorrection
time-of-flight correction
Definition TOPTrack.h:302
double m_momentum
track momentum magnitude at TOP
Definition TOPTrack.h:298
int getModuleID() const
Returns slot ID.
Definition TOPTrack.h:151
std::map< double, TOPTrack::AssumedEmission > m_emissionPoints
assumed emission points in module local frame, for dL != 0
Definition TOPTrack.h:321
bool m_valid
true for properly defined track
Definition TOPTrack.h:313
double m_pT
transverse momentum at POCA
Definition TOPTrack.h:299
double getTransverseMomentum() const
Returns transverse momentum (at POCA)
Definition TOPTrack.h:163
bool setHelix(const ROOT::Math::Transform3D &transform)
Sets helix (helix is given in nominal frame)
Definition TOPTrack.cc:171
const std::vector< SelectedHit > & getSelectedHits() const
Returns selected photon hits from TOPDigits belonging to the slot ID.
Definition TOPTrack.h:252
double m_trackLength
trajectory length from IP to average photon emission point
Definition TOPTrack.h:303
double getMomentumMag() const
Returns momentum magnitude (extrapolated to TOP)
Definition TOPTrack.h:157
double m_charge
track charge in units of elementary charge
Definition TOPTrack.h:300
std::vector< SelectedHit > m_selectedHits
selected photon hits from TOPDigits belonging to this slot ID
Definition TOPTrack.h:315
const MCParticle * m_mcParticle
MC particle.
Definition TOPTrack.h:311
TOP::HelixSwimmer m_helix
trajectory helix in nominal slot frame
Definition TOPTrack.h:305
double m_length
trajectory length within quartz
Definition TOPTrack.h:304
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:212
double getTrackLength() const
Returns track length from IP to the average position of photon emission within quartz.
Definition TOPTrack.h:175
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:246
const ExtHit * m_extHit
extrapolated hit
Definition TOPTrack.h:310
TOPTrack::AssumedEmission m_emissionPoint0
assumed emission point in module local frame, at dL = 0
Definition TOPTrack.h:324
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:337
const Track * m_track
mdst track
Definition TOPTrack.h:309
double getBeta(const Const::ChargedStable &particle, double overrideMass=0) const
Returns particle beta.
Definition TOPTrack.h:329
double m_TOFLength
trajectory length corresponding to TOF of extrapolated hit
Definition TOPTrack.h:301
const TOPBarHit * m_barHit
bar hit
Definition TOPTrack.h:312
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:76
ROOT::Math::XYZPoint position
position
Definition TOPTrack.h:77
TrackAngles trackAngles
sine and cosine of track polar and azimuthal angles
Definition TOPTrack.h:78
SelectedHit(int pix, double t, double terr)
Constructor.
Definition TOPTrack.h:96
double timeErr
time uncertainty
Definition TOPTrack.h:88
Sine and cosine of track polar and azimuthal angles at assumed photon emission.
Definition TOPTrack.h:48
double sinFi
sine of azimuthal angle
Definition TOPTrack.h:52
TrackAngles()
Default constructor.
Definition TOPTrack.h:57
double cosFi
cosine of azimuthal angle
Definition TOPTrack.h:51
double cosTh
cosine of polar angle
Definition TOPTrack.h:49
ROOT::Math::XYZVector getDirection() const
Returns direction vector.
Definition TOPTrack.h:70
double sinTh
sine of polar angle
Definition TOPTrack.h:50