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;
142 associatedTracks.emplace_back(
associator->associateRecoToSim(TrackCollectionH, TPCollectionH));
145 double sumSimTime = 0.;
146 double sumSimTimeSq = 0.;
149 if (puinfo.getBunchCrossing() == 0) {
150 for (
const float &
time : puinfo.getPU_times()) {
151 double simtime =
time;
152 sumSimTime += simtime;
153 sumSimTimeSq += simtime * simtime;
160 double meanSimTime = sumSimTime / double(nsim);
161 double varSimTime = sumSimTimeSq / double(nsim) - meanSimTime * meanSimTime;
163 std::normal_distribution<float> gausSimTime(meanSimTime, rmsSimTime);
166 unsigned int runNum_uint = static_cast<unsigned int>(evt.
id().
run());
167 unsigned int lumiNum_uint = static_cast<unsigned int>(evt.
id().
luminosityBlock());
168 unsigned int evNum_uint = static_cast<unsigned int>(evt.
id().
event());
170 std::uint32_t
seed = tkChi2_uint + (lumiNum_uint << 10) + (runNum_uint << 20) + evNum_uint;
171 std::mt19937 rng(
seed);
183 if (track_tps != associatedTracks.back().end() && track_tps->val.size() == 1) {
186 generalTrackTimes.push_back(
time);
188 float rndtime = gausSimTime(rng);
189 generalTrackTimes.push_back(rndtime);
190 if (track_tps != associatedTracks.back().end() && track_tps->val.size() > 1) {
191 LogDebug(
"TooManyTracks") <<
"track matched to " << track_tps->val.size() <<
" tracking particles!"
199 std::vector<float> times, resos;
207 bool inAcceptance = absEta < etaMax_ && absEta >=
etaMin_ && tk.
p() >
pMin_ &&
210 const float resolution = reso->getTimeResolution(tk);
211 std::normal_distribution<float> gausGeneralTime(generalTrackTimes[
i],
resolution);
212 times.push_back(gausGeneralTime(rng));
215 times.push_back(0.0
f);
216 resos.push_back(-1.);
228 const auto &tvertex =
tp.parentVertex();
232 if (tvertex->nSourceTracks() && tvertex->sourceTracks()[0]->pdgId() ==
pdgid) {
233 auto pvertex = tvertex->sourceTracks()[0]->parentVertex();
234 result = pvertex->position();
235 while (pvertex->nSourceTracks() && pvertex->sourceTracks()[0]->pdgId() ==
pdgid) {
236 pvertex = pvertex->sourceTracks()[0]->parentVertex();
237 result = pvertex->position();
244 const auto &tkstate =
tt.trajectoryStateClosestToPoint(result_pos);
245 float tkphi = tkstate.momentum().phi();
246 float tkz = tkstate.position().z();
248 float dz = tkz -
tt.track().vz();
251 float pathlengthrphi =
tt.track().charge() * dphi *
radius;
253 float pathlength =
std::sqrt(pathlengthrphi * pathlengthrphi +
dz *
dz);
254 float p =
tt.track().p();
256 float speed =
std::sqrt(1. / (1. + m_pion /
p)) * CLHEP::c_light / CLHEP::cm;