36 #include "CLHEP/Units/SystemOfUnits.h" 57 const std::vector<edm::EDGetTokenT<reco::TrackToTrackingParticleAssociator>>
associators_;
69 constexpr
float m_pion = 139.57061e-3;
72 template <
typename ParticleType,
typename T>
75 const std::vector<T> &
values,
95 [this](
const edm::
InputTag &
tag) {
return this->consumes<reco::TrackToTrackingParticleAssociator>(
tag); })),
96 etaMin_(conf.getParameter<
double>(
"etaMin")),
97 etaMax_(conf.getParameter<
double>(
"etaMax")),
98 ptMin_(conf.getParameter<
double>(
"ptMin")),
99 pMin_(conf.getParameter<
double>(
"pMin")),
100 etaMaxForPtThreshold_(conf.getParameter<
double>(
"etaMaxForPtThreshold")) {
102 const std::vector<edm::ParameterSet> &resos = conf.getParameterSetVector(
"resolutionModels");
103 for (
const auto &reso : resos) {
108 produces<edm::ValueMap<float>>(tracksName_ +
name);
115 std::vector<edm::Handle<reco::TrackToTrackingParticleAssociator>>
associators;
122 std::vector<float> generalTrackTimes;
140 std::vector<reco::RecoToSimCollection> associatedTracks;
143 associatedTracks.emplace_back(
associator->associateRecoToSim(TrackCollectionH, TPCollectionH));
146 double sumSimTime = 0.;
147 double sumSimTimeSq = 0.;
150 if (puinfo.getBunchCrossing() == 0) {
151 for (
const float &
time : puinfo.getPU_times()) {
152 double simtime =
time;
153 sumSimTime += simtime;
154 sumSimTimeSq += simtime * simtime;
161 double meanSimTime = sumSimTime / double(nsim);
162 double varSimTime = sumSimTimeSq / double(nsim) - meanSimTime * meanSimTime;
164 std::normal_distribution<float> gausSimTime(meanSimTime, rmsSimTime);
167 unsigned int runNum_uint =
static_cast<unsigned int>(evt.
id().
run());
168 unsigned int lumiNum_uint =
static_cast<unsigned int>(evt.
id().
luminosityBlock());
169 unsigned int evNum_uint =
static_cast<unsigned int>(evt.
id().
event());
171 std::uint32_t
seed = tkChi2_uint + (lumiNum_uint << 10) + (runNum_uint << 20) + evNum_uint;
172 std::mt19937 rng(
seed);
184 if (track_tps != associatedTracks.back().end() && track_tps->
val.size() == 1) {
187 generalTrackTimes.push_back(
time);
189 float rndtime = gausSimTime(rng);
190 generalTrackTimes.push_back(rndtime);
191 if (track_tps != associatedTracks.back().end() && track_tps->
val.size() > 1) {
192 LogDebug(
"TooManyTracks") <<
"track matched to " << track_tps->
val.size() <<
" tracking particles!" 200 std::vector<float> times, resos;
208 bool inAcceptance = absEta < etaMax_ && absEta >=
etaMin_ && tk.
p() >
pMin_ &&
211 const float resolution = reso->getTimeResolution(tk);
212 std::normal_distribution<float> gausGeneralTime(generalTrackTimes[
i],
resolution);
213 times.push_back(gausGeneralTime(rng));
216 times.push_back(0.0
f);
217 resos.push_back(-1.);
229 const auto &tvertex =
tp.parentVertex();
233 if (tvertex->nSourceTracks() && tvertex->sourceTracks()[0]->pdgId() ==
pdgid) {
234 auto pvertex = tvertex->sourceTracks()[0]->parentVertex();
235 result = pvertex->position();
236 while (pvertex->nSourceTracks() && pvertex->sourceTracks()[0]->pdgId() ==
pdgid) {
237 pvertex = pvertex->sourceTracks()[0]->parentVertex();
238 result = pvertex->position();
245 const auto &tkstate =
tt.trajectoryStateClosestToPoint(result_pos);
246 float tkphi = tkstate.momentum().phi();
247 float tkz = tkstate.position().z();
249 float dz = tkz -
tt.track().vz();
252 float pathlengthrphi =
tt.track().charge() * dphi *
radius;
254 float pathlength =
std::sqrt(pathlengthrphi * pathlengthrphi +
dz *
dz);
255 float p =
tt.track().p();
constexpr double deltaPhi(double phi1, double phi2)
const edm::EDGetTokenT< TrackingVertexCollection > trackingVertices_
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
def create(alignables, pedeDump, additionalData, outputFile, config)
double p() const
momentum vector magnitude
Global3DPoint GlobalPoint
std::vector< Track > TrackCollection
collection of Tracks
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const std::string tracksName_
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
std::vector< std::unique_ptr< const ResolutionModel > > resolutions_
LuminosityBlockNumber_t luminosityBlock() const
U second(std::pair< T, U > const &p)
double pt() const
track transverse momentum
std::tuple< layerClusterToCaloParticle, caloParticleToLayerCluster > association
~TrackTimeValueMapProducer() override
Abs< T >::type abs(const T &t)
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > builderToken_
#define DEFINE_FWK_MODULE(type)
bool getData(T &iHolder) const
TrackTimeValueMapProducer(const edm::ParameterSet &)
const edm::EDGetTokenT< TrackingParticleCollection > trackingParticles_
double eta() const
pseudorapidity of momentum vector
const float etaMaxForPtThreshold_
std::vector< TrackingVertex > TrackingVertexCollection
const std::vector< edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > > associators_
const edm::EDGetTokenT< edm::View< reco::Track > > tracks_
Monte Carlo truth information used for tracking validation.
std::vector< TrackingParticle > TrackingParticleCollection
float extractTrackVertexTime(const TrackingParticle &, const reco::TransientTrack &) const
EventNumber_t event() const
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupSummaryInfo_
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override