CMS 3D CMS Logo

TICLCandidate.h
Go to the documentation of this file.
1 #ifndef DataFormats_HGCalReco_TICLCandidate_h
2 #define DataFormats_HGCalReco_TICLCandidate_h
3 
10 #include "Common.h"
11 
13 
14 // A TICLCandidate is a lightweight physics object made from one or multiple Tracksters.
15 
17 public:
19 
22 
24 
26  : LeafCandidate(),
27  tracksters_({trackster}),
29  time_(trackster->time()),
30  timeError_(trackster->timeError()),
31  MTDtime_{0.f},
32  MTDtimeError_{-1.f},
33  rawEnergy_(0.f) {}
34 
37  if (trackPtr_.isNull() and tracksterPtr.isNull())
38  throw cms::Exception("NullPointerError")
39  << "TICLCandidate constructor: at least one between track and trackster must be valid";
40 
41  if (tracksterPtr.isNonnull()) {
42  tracksters_.push_back(tracksterPtr);
43  auto const& trackster = tracksters_[0].get();
44  idProbabilities_ = trackster->id_probabilities();
45  if (trackPtr_.isNonnull()) {
46  auto pdgId = trackster->isHadronic() ? 211 : 11;
47  auto const& tk = trackPtr_.get();
48  setPdgId(pdgId * tk->charge());
49  setCharge(tk->charge());
50  rawEnergy_ = trackster->raw_energy();
51  auto const& regrE = trackster->regressed_energy();
52  math::XYZTLorentzVector p4(regrE * tk->momentum().unit().x(),
53  regrE * tk->momentum().unit().y(),
54  regrE * tk->momentum().unit().z(),
55  regrE);
56  setP4(p4);
57 
58  } else {
59  auto pdgId = trackster->isHadronic() ? 130 : 22;
60  setPdgId(pdgId);
61  setCharge(0);
62  rawEnergy_ = trackster->raw_energy();
63  const float& regrE = trackster->regressed_energy();
64  math::XYZTLorentzVector p4(regrE * trackster->barycenter().unit().x(),
65  regrE * trackster->barycenter().unit().y(),
66  regrE * trackster->barycenter().unit().z(),
67  regrE);
68  setP4(p4);
69  }
70  } else {
71  //candidate from track only
72  auto const& tk = trackPtr_.get();
73  setPdgId(211 * tk->charge());
74  setCharge(tk->charge());
75  const float energy = std::sqrt(tk->p() * tk->p() + ticl::mpion2);
77  math::PtEtaPhiMLorentzVector p4Polar(tk->pt(), tk->eta(), tk->phi(), ticl::mpion);
78  setP4(p4Polar);
79  }
80  }
81 
82  inline float time() const { return time_; }
83  inline float timeError() const { return timeError_; }
84 
85  void setTime(float time, float timeError) {
86  time_ = time;
88  };
89 
90  inline float MTDtime() const { return MTDtime_; }
91  inline float MTDtimeError() const { return MTDtimeError_; }
92 
93  void setMTDTime(float time, float timeError) {
94  MTDtime_ = time;
96  };
97 
98  inline const edm::Ptr<reco::Track> trackPtr() const { return trackPtr_; }
100 
101  inline float rawEnergy() const { return rawEnergy_; }
103 
104  inline const std::vector<edm::Ptr<ticl::Trackster> > tracksters() const { return tracksters_; };
105 
107  void addTrackster(const edm::Ptr<ticl::Trackster>& trackster) {
108  tracksters_.push_back(trackster);
109  time_ = trackster->time();
110  timeError_ = trackster->timeError();
111  }
112  // convenience method to return the ID probability for a certain particle type
113  inline float id_probability(ParticleType type) const {
114  // probabilities are stored in the same order as defined in the ParticleType enum
115  return idProbabilities_[(int)type];
116  }
117 
118  inline const std::array<float, 8>& idProbabilities() const { return idProbabilities_; }
119 
121  for (auto& p : idProbabilities_) {
122  p = 0.f;
123  }
124  }
125 
126  void setIdProbabilities(const std::array<float, 8>& idProbs) { idProbabilities_ = idProbs; }
128 
129 private:
130  // vector of Ptr so Tracksters can come from different collections
131  // and there can be derived classes
132  std::vector<edm::Ptr<ticl::Trackster> > tracksters_;
134  // Since it contains multiple tracksters, duplicate the probability interface
135  std::array<float, 8> idProbabilities_;
136 
137  float time_;
138  float timeError_;
139  float MTDtime_;
141  float rawEnergy_;
142 };
143 #endif
const edm::Ptr< reco::Track > trackPtr() const
Definition: TICLCandidate.h:98
TICLCandidate(const edm::Ptr< reco::Track > trackPtr, const edm::Ptr< ticl::Trackster > &tracksterPtr)
Definition: TICLCandidate.h:35
void setIdProbabilities(const std::array< float, 8 > &idProbs)
constexpr double mpion
Definition: Common.h:40
int Charge
electric charge type
Definition: Candidate.h:34
float MTDtimeError() const
Definition: TICLCandidate.h:91
void setTracksters(const std::vector< edm::Ptr< ticl::Trackster > > &tracksters)
std::vector< edm::Ptr< ticl::Trackster > > tracksters_
const std::array< float, 8 > & idProbabilities() const
void zeroProbabilities()
void setTime(float time, float timeError)
Definition: TICLCandidate.h:85
edm::Ptr< reco::Track > trackPtr_
const LorentzVector & p4() const final
four-momentum Lorentz vector
const float timeError() const
Definition: Trackster.h:152
int pdgId() const final
PDG identifier.
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
void setCharge(Charge q) final
set electric charge
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
void setIdProbability(ParticleType type, float value)
bool isNull() const
Checks for null.
Definition: Ptr.h:144
double p() const final
magnitude of momentum vector
void setRawEnergy(float rawEnergy)
T sqrt(T t)
Definition: SSEVec.h:23
std::array< float, 8 > idProbabilities_
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:148
double f[11][100]
float id_probability(ParticleType type) const
Definition: value.py:1
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:141
ticl::Trackster::ParticleType ParticleType
Definition: TICLCandidate.h:18
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
float MTDtime() const
Definition: TICLCandidate.h:90
float timeError() const
Definition: TICLCandidate.h:83
constexpr float mpion2
Definition: Common.h:41
void addTrackster(const edm::Ptr< ticl::Trackster > &trackster)
const float time() const
Definition: Trackster.h:151
float time() const
Definition: TICLCandidate.h:82
void setMTDTime(float time, float timeError)
Definition: TICLCandidate.h:93
const std::vector< edm::Ptr< ticl::Trackster > > tracksters() const
void setPdgId(int pdgId) final
TICLCandidate(Charge q, const LorentzVector &p4)
Definition: TICLCandidate.h:20
void setTrackPtr(const edm::Ptr< reco::Track > &trackPtr)
Definition: TICLCandidate.h:99
void setP4(const LorentzVector &p4) final
set 4-momentum
float rawEnergy() const
double energy() const final
energy
TICLCandidate(const edm::Ptr< ticl::Trackster > &trackster)
Definition: TICLCandidate.h:25