36 #include "CLHEP/Units/SystemOfUnits.h"
56 const std::vector<edm::EDGetTokenT<reco::TrackToTrackingParticleAssociator>>
associators_;
68 constexpr
float m_pion = 139.57061e-3;
71 template <
typename ParticleType,
typename T>
74 const std::vector<T> &
values,
93 [this](
const edm::
InputTag &
tag) {
return this->consumes<reco::TrackToTrackingParticleAssociator>(
tag); })),
94 etaMin_(conf.getParameter<
double>(
"etaMin")),
95 etaMax_(conf.getParameter<
double>(
"etaMax")),
96 ptMin_(conf.getParameter<
double>(
"ptMin")),
97 pMin_(conf.getParameter<
double>(
"pMin")),
98 etaMaxForPtThreshold_(conf.getParameter<
double>(
"etaMaxForPtThreshold")) {
100 const std::vector<edm::ParameterSet> &resos = conf.getParameterSetVector(
"resolutionModels");
101 for (
const auto &reso : resos) {
106 produces<edm::ValueMap<float>>(tracksName_ +
name);
113 std::vector<edm::Handle<reco::TrackToTrackingParticleAssociator>>
associators;
120 std::vector<float> generalTrackTimes;
139 std::vector<reco::RecoToSimCollection> associatedTracks;
141 associatedTracks.emplace_back(
associator->associateRecoToSim(TrackCollectionH, TPCollectionH));
144 double sumSimTime = 0.;
145 double sumSimTimeSq = 0.;
148 if (puinfo.getBunchCrossing() == 0) {
149 for (
const float &
time : puinfo.getPU_times()) {
150 double simtime =
time;
151 sumSimTime += simtime;
152 sumSimTimeSq += simtime * simtime;
159 double meanSimTime = sumSimTime / double(nsim);
160 double varSimTime = sumSimTimeSq / double(nsim) - meanSimTime * meanSimTime;
162 std::normal_distribution<float> gausSimTime(meanSimTime, rmsSimTime);
165 unsigned int runNum_uint = static_cast<unsigned int>(evt.
id().
run());
166 unsigned int lumiNum_uint = static_cast<unsigned int>(evt.
id().
luminosityBlock());
167 unsigned int evNum_uint = static_cast<unsigned int>(evt.
id().
event());
169 std::uint32_t
seed = tkChi2_uint + (lumiNum_uint << 10) + (runNum_uint << 20) + evNum_uint;
170 std::mt19937 rng(
seed);
182 if (track_tps != associatedTracks.back().end() && track_tps->val.size() == 1) {
185 generalTrackTimes.push_back(
time);
187 float rndtime = gausSimTime(rng);
188 generalTrackTimes.push_back(rndtime);
189 if (track_tps != associatedTracks.back().end() && track_tps->val.size() > 1) {
190 LogDebug(
"TooManyTracks") <<
"track matched to " << track_tps->val.size() <<
" tracking particles!"
198 std::vector<float> times, resos;
206 bool inAcceptance = absEta < etaMax_ && absEta >=
etaMin_ && tk.
p() >
pMin_ &&
209 const float resolution = reso->getTimeResolution(tk);
210 std::normal_distribution<float> gausGeneralTime(generalTrackTimes[
i],
resolution);
211 times.push_back(gausGeneralTime(rng));
214 times.push_back(0.0
f);
215 resos.push_back(-1.);
227 const auto &tvertex =
tp.parentVertex();
231 if (tvertex->nSourceTracks() && tvertex->sourceTracks()[0]->pdgId() ==
pdgid) {
232 auto pvertex = tvertex->sourceTracks()[0]->parentVertex();
233 result = pvertex->position();
234 while (pvertex->nSourceTracks() && pvertex->sourceTracks()[0]->pdgId() ==
pdgid) {
235 pvertex = pvertex->sourceTracks()[0]->parentVertex();
236 result = pvertex->position();
243 const auto &tkstate =
tt.trajectoryStateClosestToPoint(result_pos);
244 float tkphi = tkstate.momentum().phi();
245 float tkz = tkstate.position().z();
247 float dz = tkz -
tt.track().vz();
250 float pathlengthrphi =
tt.track().charge() * dphi *
radius;
252 float pathlength =
std::sqrt(pathlengthrphi * pathlengthrphi +
dz *
dz);
253 float p =
tt.track().p();
255 float speed =
std::sqrt(1. / (1. + m_pion /
p)) * CLHEP::c_light / CLHEP::cm;