36 #include "CLHEP/Units/SystemOfUnits.h" 56 const std::vector<edm::EDGetTokenT<reco::TrackToTrackingParticleAssociator>>
associators_;
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")),
100 const std::vector<edm::ParameterSet> &resos = conf.getParameterSetVector(
"resolutionModels");
101 for (
const auto &reso : resos) {
113 std::vector<edm::Handle<reco::TrackToTrackingParticleAssociator>>
associators;
115 associators.emplace_back();
116 auto &back = associators.back();
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());
168 unsigned int tkChi2_uint = uint32_t(TrackCollection.
empty() ? 0 : TrackCollection.
refAt(0)->chi2() / 0.01);
169 std::uint32_t
seed = tkChi2_uint + (lumiNum_uint << 10) + (runNum_uint << 20) + evNum_uint;
170 std::mt19937 rng(seed);
172 for (
unsigned itk = 0; itk < TrackCollection.
size(); ++itk) {
173 const auto tkref = TrackCollection.
refAt(itk);
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;
200 times.reserve(TrackCollection.
size());
201 resos.reserve(TrackCollection.
size());
203 for (
unsigned i = 0;
i < TrackCollection.
size(); ++
i) {
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));
212 resos.push_back(resolution);
214 times.push_back(0.0
f);
215 resos.push_back(-1.);
219 writeValueMap(evt, TrackCollectionH, times,
tracksName_ + name);
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();
242 GlobalPoint result_pos(result.x(), result.y(), result.z());
245 float tkz = tkstate.position().z();
252 float pathlength =
std::sqrt(pathlengthrphi * pathlengthrphi + dz * dz);
255 float speed =
std::sqrt(1. / (1. + m_pion / p)) * CLHEP::c_light / CLHEP::cm;
constexpr double deltaPhi(double phi1, double phi2)
double p() const
momentum vector magnitude
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
EventNumber_t event() const
const edm::EDGetTokenT< TrackingVertexCollection > trackingVertices_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
std::vector< TrackingParticle > TrackingParticleCollection
def create(alignables, pedeDump, additionalData, outputFile, config)
friend struct const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
int pdgId() const
PDG ID.
Geom::Phi< T > phi() const
Global3DPoint GlobalPoint
std::vector< Track > TrackCollection
collection of Tracks
reco::TransientTrack build(const reco::Track *p) const
double phi() const
azimuthal angle of momentum vector
const MagneticField * field() const
const std::string tracksName_
LuminosityBlockNumber_t luminosityBlock() const
std::vector< std::unique_ptr< const ResolutionModel > > resolutions_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
RefToBase< value_type > refAt(size_type i) const
U second(std::pair< T, U > const &p)
#define DEFINE_FWK_MODULE(type)
double eta() const
pseudorapidity of momentum vector
~TrackTimeValueMapProducer() override
double pt() const
track transverse momentum
Abs< T >::type abs(const T &t)
float extractTrackVertexTime(const TrackingParticle &, const reco::TransientTrack &) const
const TrackingVertexRef & parentVertex() const
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
TrackTimeValueMapProducer(const edm::ParameterSet &)
const edm::EDGetTokenT< TrackingParticleCollection > trackingParticles_
double vz() const
z coordinate of the reference point on track
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 >
const float etaMaxForPtThreshold_
const Track & track() const
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
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.
int charge() const
track electric charge
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupSummaryInfo_
GlobalVector momentum() const