CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Protected Attributes
VertexTimeAlgorithmFromTracksPID Class Reference

#include <VertexTimeAlgorithmFromTracksPID.h>

Inheritance diagram for VertexTimeAlgorithmFromTracksPID:
VertexTimeAlgorithmBase

Classes

struct  TrackInfo
 

Public Member Functions

void setEvent (edm::Event &iEvent, edm::EventSetup const &iSetup) override
 
bool vertexTime (float &vtxTime, float &vtxTimeError, TransientVertex const &vtx) const override
 
 VertexTimeAlgorithmFromTracksPID (const edm::ParameterSet &conf, edm::ConsumesCollector &iC)
 
 ~VertexTimeAlgorithmFromTracksPID () override=default
 
- Public Member Functions inherited from VertexTimeAlgorithmBase
virtual void fill_vertex_times (std::vector< TransientVertex > &pvs)
 
VertexTimeAlgorithmBaseoperator= (const VertexTimeAlgorithmBase &)=delete
 
 VertexTimeAlgorithmBase (const edm::ParameterSet &conf, edm::ConsumesCollector &iC)
 
 VertexTimeAlgorithmBase (const VertexTimeAlgorithmBase &)=delete
 
virtual ~VertexTimeAlgorithmBase ()=default
 

Static Public Member Functions

static void fillPSetDescription (edm::ParameterSetDescription &iDesc)
 
- Static Public Member Functions inherited from VertexTimeAlgorithmBase
static void fillPSetDescription (edm::ParameterSetDescription &iDesc)
 

Protected Attributes

double const coolingFactor_
 
double const minTrackTimeQuality_
 
double const minTrackVtxWeight_
 
double const probKaon_
 
double const probPion_
 
double const probProton_
 
edm::ValueMap< float > trackMTDTimeErrors_
 
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTimeErrorToken_
 
edm::ValueMap< float > trackMTDTimeQualities_
 
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTimeQualityToken_
 
edm::ValueMap< float > trackMTDTimes_
 
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTimeToken_
 
edm::ValueMap< float > trackMTDTofK_
 
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTofKToken_
 
edm::ValueMap< float > trackMTDTofP_
 
edm::ValueMap< float > trackMTDTofPi_
 
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTofPiToken_
 
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTofPToken_
 
double const Tstart_
 

Detailed Description

Definition at line 10 of file VertexTimeAlgorithmFromTracksPID.h.

Constructor & Destructor Documentation

◆ VertexTimeAlgorithmFromTracksPID()

VertexTimeAlgorithmFromTracksPID::VertexTimeAlgorithmFromTracksPID ( const edm::ParameterSet conf,
edm::ConsumesCollector iC 
)

Definition at line 17 of file VertexTimeAlgorithmFromTracksPID.cc.

19  : VertexTimeAlgorithmBase(iConfig, iCC),
20  trackMTDTimeToken_(iCC.consumes(iConfig.getParameter<edm::InputTag>("trackMTDTimeVMapTag"))),
21  trackMTDTimeErrorToken_(iCC.consumes(iConfig.getParameter<edm::InputTag>("trackMTDTimeErrorVMapTag"))),
22  trackMTDTimeQualityToken_(iCC.consumes(iConfig.getParameter<edm::InputTag>("trackMTDTimeQualityVMapTag"))),
23  trackMTDTofPiToken_(iCC.consumes(iConfig.getParameter<edm::InputTag>("trackMTDTofPiVMapTag"))),
24  trackMTDTofKToken_(iCC.consumes(iConfig.getParameter<edm::InputTag>("trackMTDTofKVMapTag"))),
25  trackMTDTofPToken_(iCC.consumes(iConfig.getParameter<edm::InputTag>("trackMTDTofPVMapTag"))),
26  minTrackVtxWeight_(iConfig.getParameter<double>("minTrackVtxWeight")),
27  minTrackTimeQuality_(iConfig.getParameter<double>("minTrackTimeQuality")),
28  probPion_(iConfig.getParameter<double>("probPion")),
29  probKaon_(iConfig.getParameter<double>("probKaon")),
30  probProton_(iConfig.getParameter<double>("probProton")),
31  Tstart_(iConfig.getParameter<double>("Tstart")),
32  coolingFactor_(iConfig.getParameter<double>("coolingFactor")) {}
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTofKToken_
VertexTimeAlgorithmBase(const edm::ParameterSet &conf, edm::ConsumesCollector &iC)
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTofPToken_
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTimeQualityToken_
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTimeToken_
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTofPiToken_
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTimeErrorToken_

◆ ~VertexTimeAlgorithmFromTracksPID()

VertexTimeAlgorithmFromTracksPID::~VertexTimeAlgorithmFromTracksPID ( )
overridedefault

Member Function Documentation

◆ fillPSetDescription()

void VertexTimeAlgorithmFromTracksPID::fillPSetDescription ( edm::ParameterSetDescription iDesc)
static

Definition at line 34 of file VertexTimeAlgorithmFromTracksPID.cc.

References edm::ParameterSetDescription::add(), VertexTimeAlgorithmBase::fillPSetDescription(), ProducerED_cfi::InputTag, and edm::ParameterDescriptionNode::setComment().

Referenced by PrimaryVertexProducer::fillDescriptions().

34  {
36 
37  iDesc.add<edm::InputTag>("trackMTDTimeVMapTag", edm::InputTag("trackExtenderWithMTD:generalTracktmtd"))
38  ->setComment("Input ValueMap for track time at MTD");
39  iDesc.add<edm::InputTag>("trackMTDTimeErrorVMapTag", edm::InputTag("trackExtenderWithMTD:generalTracksigmatmtd"))
40  ->setComment("Input ValueMap for track time uncertainty at MTD");
41  iDesc.add<edm::InputTag>("trackMTDTimeQualityVMapTag", edm::InputTag("mtdTrackQualityMVA:mtdQualMVA"))
42  ->setComment("Input ValueMap for track MVA quality value");
43  iDesc.add<edm::InputTag>("trackMTDTofPiVMapTag", edm::InputTag("trackExtenderWithMTD:generalTrackTofPi"))
44  ->setComment("Input ValueMap for track tof as pion");
45  iDesc.add<edm::InputTag>("trackMTDTofKVMapTag", edm::InputTag("trackExtenderWithMTD:generalTrackTofK"))
46  ->setComment("Input ValueMap for track tof as kaon");
47  iDesc.add<edm::InputTag>("trackMTDTofPVMapTag", edm::InputTag("trackExtenderWithMTD:generalTrackTofP"))
48  ->setComment("Input ValueMap for track tof as proton");
49 
50  iDesc.add<double>("minTrackVtxWeight", 0.5)->setComment("Minimum track weight");
51  iDesc.add<double>("minTrackTimeQuality", 0.8)->setComment("Minimum MVA Quality selection on tracks");
52 
53  iDesc.add<double>("probPion", 0.7)->setComment("A priori probability pions");
54  iDesc.add<double>("probKaon", 0.2)->setComment("A priori probability kaons");
55  iDesc.add<double>("probProton", 0.1)->setComment("A priori probability protons");
56 
57  iDesc.add<double>("Tstart", 256.)->setComment("DA initial temperature T");
58  iDesc.add<double>("coolingFactor", 0.5)->setComment("DA cooling factor");
59 }
void setComment(std::string const &value)
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)
ParameterDescriptionBase * add(U const &iLabel, T const &value)

◆ setEvent()

void VertexTimeAlgorithmFromTracksPID::setEvent ( edm::Event iEvent,
edm::EventSetup const &  iSetup 
)
overridevirtual

Implements VertexTimeAlgorithmBase.

Definition at line 61 of file VertexTimeAlgorithmFromTracksPID.cc.

References iEvent, trackMTDTimeErrors_, trackMTDTimeErrorToken_, trackMTDTimeQualities_, trackMTDTimeQualityToken_, trackMTDTimes_, trackMTDTimeToken_, trackMTDTofK_, trackMTDTofKToken_, trackMTDTofP_, trackMTDTofPi_, trackMTDTofPiToken_, and trackMTDTofPToken_.

61  {
62  // additional collections required for vertex-time calculation
69 }
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTofKToken_
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTofPToken_
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTimeQualityToken_
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTimeToken_
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTofPiToken_
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTimeErrorToken_

◆ vertexTime()

bool VertexTimeAlgorithmFromTracksPID::vertexTime ( float &  vtxTime,
float &  vtxTimeError,
TransientVertex const &  vtx 
) const
overridevirtual

estimate the vertex time and time uncertainty for transient vertex

returns true when a valid time has been determined, otherwise return false

Implements VertexTimeAlgorithmBase.

Definition at line 71 of file VertexTimeAlgorithmFromTracksPID.cc.

References a, funct::abs(), HLT_2024v12_cff::beta, coolingFactor_, dt, MillePedeFileConverter_cfg::e, dqmiolumiharvest::j, LOG, SiStripPI::min, minTrackTimeQuality_, minTrackVtxWeight_, probKaon_, probPion_, probProton_, mathSSE::sqrt(), FrontierCondition_GT_autoExpress_cfi::t0, trackMTDTimeErrors_, trackMTDTimeQualities_, trackMTDTimes_, trackMTDTofK_, trackMTDTofP_, trackMTDTofPi_, Tstart_, parallelization::uint, L1BJetProducer_cff::vtx, w(), and beamSpotPI::Z.

73  {
74  if (vtx.originalTracks().empty()) {
75  return false;
76  }
77 
78  auto const vtxTime_init = vtxTime;
79  auto const vtxTimeError_init = vtxTimeError;
80  const int max_iterations = 100;
81 
82  double tsum = 0;
83  double wsum = 0;
84  double w2sum = 0;
85 
86  double const a[3] = {probPion_, probKaon_, probProton_};
87 
88  std::vector<TrackInfo> v_trackInfo;
89  v_trackInfo.reserve(vtx.originalTracks().size());
90 
91  // initial guess
92  for (const auto& trk : vtx.originalTracks()) {
93  auto const trkWeight = vtx.trackWeight(trk);
94  if (trkWeight > minTrackVtxWeight_) {
95  auto const trkTimeQuality = trackMTDTimeQualities_[trk.trackBaseRef()];
96 
97  if (trkTimeQuality >= minTrackTimeQuality_) {
98  auto const trkTime = trackMTDTimes_[trk.trackBaseRef()];
99  auto const trkTimeError = trackMTDTimeErrors_[trk.trackBaseRef()];
100 
101  v_trackInfo.emplace_back();
102  auto& trkInfo = v_trackInfo.back();
103 
104  trkInfo.trkWeight = trkWeight;
105  trkInfo.trkTimeError = trkTimeError;
106 
107  trkInfo.trkTimeHyp[0] = trkTime - trackMTDTofPi_[trk.trackBaseRef()];
108  trkInfo.trkTimeHyp[1] = trkTime - trackMTDTofK_[trk.trackBaseRef()];
109  trkInfo.trkTimeHyp[2] = trkTime - trackMTDTofP_[trk.trackBaseRef()];
110 
111  auto const wgt = trkWeight / (trkTimeError * trkTimeError);
112  wsum += wgt;
113 
114  for (uint j = 0; j < 3; ++j) {
115  tsum += wgt * trkInfo.trkTimeHyp[j] * a[j];
116  }
117  LOG << "vertexTimeFromTracks: track"
118  << " pt=" << trk.track().pt() << " eta=" << trk.track().eta() << " phi=" << trk.track().phi()
119  << " vtxWeight=" << trkWeight << " time=" << trkTime << " timeError=" << trkTimeError
120  << " timeQuality=" << trkTimeQuality << " timeHyp[pion]=" << trkInfo.trkTimeHyp[0]
121  << " timeHyp[kaon]=" << trkInfo.trkTimeHyp[1] << " timeHyp[proton]=" << trkInfo.trkTimeHyp[2];
122  }
123  }
124  }
125  if (wsum > 0) {
126  auto t0 = tsum / wsum;
127  auto beta = 1. / Tstart_;
128  int nit = 0;
129  while ((nit++) < max_iterations) {
130  tsum = 0;
131  wsum = 0;
132  w2sum = 0;
133 
134  for (auto const& trkInfo : v_trackInfo) {
135  double dt = trkInfo.trkTimeError;
136  double e[3] = {0, 0, 0};
137  const double cut_off = 4.5;
138  double Z = vdt::fast_exp(
139  -beta * cut_off); // outlier rejection term Z_0 = exp(-beta * cut_off) = exp(-beta * 0.5 * 3 * 3)
140  for (unsigned int j = 0; j < 3; j++) {
141  auto const tpull = (trkInfo.trkTimeHyp[j] - t0) / dt;
142  e[j] = vdt::fast_exp(-0.5 * beta * tpull * tpull);
143  Z += a[j] * e[j];
144  }
145 
146  double wsum_trk = 0;
147  for (uint j = 0; j < 3; j++) {
148  double wt = a[j] * e[j] / Z;
149  double w = wt * trkInfo.trkWeight / (dt * dt);
150  wsum_trk += w;
151  tsum += w * trkInfo.trkTimeHyp[j];
152  }
153 
154  wsum += wsum_trk;
155  w2sum += wsum_trk * wsum_trk * (dt * dt) / trkInfo.trkWeight;
156  }
157 
158  if (wsum < 1e-10) {
159  LOG << "vertexTimeFromTracks: failed while iterating";
160  return false;
161  }
162 
163  vtxTime = tsum / wsum;
164 
165  LOG << "vertexTimeFromTracks: iteration=" << nit << ", T= " << 1 / beta << ", t=" << vtxTime
166  << ", t-t0=" << vtxTime - t0;
167 
168  if ((std::abs(vtxTime - t0) < 1e-4 / std::sqrt(beta)) and beta >= 1.) {
169  vtxTimeError = std::sqrt(w2sum) / wsum;
170 
171  LOG << "vertexTimeFromTracks: tfit = " << vtxTime << " +/- " << vtxTimeError << " trec = " << vtx.time()
172  << ", iteration=" << nit;
173 
174  return true;
175  }
176 
177  if ((std::abs(vtxTime - t0) < 1e-3) and beta < 1.) {
178  beta = std::min(1., beta / coolingFactor_);
179  }
180 
181  t0 = vtxTime;
182  }
183 
184  LOG << "vertexTimeFromTracks: failed to converge";
185  } else {
186  LOG << "vertexTimeFromTracks: has no track timing info";
187  }
188 
189  vtxTime = vtxTime_init;
190  vtxTimeError = vtxTimeError_init;
191 
192  return false;
193 }
float dt
Definition: AMPTWrapper.h:136
T w() const
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double a
Definition: hdecay.h:121

Member Data Documentation

◆ coolingFactor_

double const VertexTimeAlgorithmFromTracksPID::coolingFactor_
protected

Definition at line 41 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by vertexTime().

◆ minTrackTimeQuality_

double const VertexTimeAlgorithmFromTracksPID::minTrackTimeQuality_
protected

Definition at line 36 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by vertexTime().

◆ minTrackVtxWeight_

double const VertexTimeAlgorithmFromTracksPID::minTrackVtxWeight_
protected

Definition at line 35 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by vertexTime().

◆ probKaon_

double const VertexTimeAlgorithmFromTracksPID::probKaon_
protected

Definition at line 38 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by vertexTime().

◆ probPion_

double const VertexTimeAlgorithmFromTracksPID::probPion_
protected

Definition at line 37 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by vertexTime().

◆ probProton_

double const VertexTimeAlgorithmFromTracksPID::probProton_
protected

Definition at line 39 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by vertexTime().

◆ trackMTDTimeErrors_

edm::ValueMap<float> VertexTimeAlgorithmFromTracksPID::trackMTDTimeErrors_
protected

Definition at line 44 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by setEvent(), and vertexTime().

◆ trackMTDTimeErrorToken_

edm::EDGetTokenT<edm::ValueMap<float> > const VertexTimeAlgorithmFromTracksPID::trackMTDTimeErrorToken_
protected

Definition at line 29 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by setEvent().

◆ trackMTDTimeQualities_

edm::ValueMap<float> VertexTimeAlgorithmFromTracksPID::trackMTDTimeQualities_
protected

Definition at line 45 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by setEvent(), and vertexTime().

◆ trackMTDTimeQualityToken_

edm::EDGetTokenT<edm::ValueMap<float> > const VertexTimeAlgorithmFromTracksPID::trackMTDTimeQualityToken_
protected

Definition at line 30 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by setEvent().

◆ trackMTDTimes_

edm::ValueMap<float> VertexTimeAlgorithmFromTracksPID::trackMTDTimes_
protected

Definition at line 43 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by setEvent(), and vertexTime().

◆ trackMTDTimeToken_

edm::EDGetTokenT<edm::ValueMap<float> > const VertexTimeAlgorithmFromTracksPID::trackMTDTimeToken_
protected

Definition at line 28 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by setEvent().

◆ trackMTDTofK_

edm::ValueMap<float> VertexTimeAlgorithmFromTracksPID::trackMTDTofK_
protected

Definition at line 47 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by setEvent(), and vertexTime().

◆ trackMTDTofKToken_

edm::EDGetTokenT<edm::ValueMap<float> > const VertexTimeAlgorithmFromTracksPID::trackMTDTofKToken_
protected

Definition at line 32 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by setEvent().

◆ trackMTDTofP_

edm::ValueMap<float> VertexTimeAlgorithmFromTracksPID::trackMTDTofP_
protected

Definition at line 48 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by setEvent(), and vertexTime().

◆ trackMTDTofPi_

edm::ValueMap<float> VertexTimeAlgorithmFromTracksPID::trackMTDTofPi_
protected

Definition at line 46 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by setEvent(), and vertexTime().

◆ trackMTDTofPiToken_

edm::EDGetTokenT<edm::ValueMap<float> > const VertexTimeAlgorithmFromTracksPID::trackMTDTofPiToken_
protected

Definition at line 31 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by setEvent().

◆ trackMTDTofPToken_

edm::EDGetTokenT<edm::ValueMap<float> > const VertexTimeAlgorithmFromTracksPID::trackMTDTofPToken_
protected

Definition at line 33 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by setEvent().

◆ Tstart_

double const VertexTimeAlgorithmFromTracksPID::Tstart_
protected

Definition at line 40 of file VertexTimeAlgorithmFromTracksPID.h.

Referenced by vertexTime().