37 #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,
91 etaMin_( conf.getParameter<
double>(
"etaMin") ),
92 etaMax_( conf.getParameter<
double>(
"etaMax") ),
93 ptMin_( conf.getParameter<
double>(
"ptMin") ),
94 pMin_( conf.getParameter<
double>(
"pMin") ),
98 const std::vector<edm::ParameterSet>& resos = conf.getParameterSetVector(
"resolutionModels");
99 for(
const auto& reso : resos ) {
112 std::vector<edm::Handle<reco::TrackToTrackingParticleAssociator> >
associators;
114 associators.emplace_back();
115 auto& back = associators.back();
119 std::vector<float> generalTrackTimes;
138 std::vector<reco::RecoToSimCollection> associatedTracks;
140 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);
176 for(
const auto&
association : associatedTracks ) {
181 if (track_tps != associatedTracks.back().end() && track_tps->val.size() == 1) {
184 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!" << std::endl;
197 std::vector<float>
times, resos;
199 times.reserve(TrackCollection.
size());
200 resos.reserve(TrackCollection.
size());
202 for(
unsigned i = 0;
i < TrackCollection.
size(); ++
i ) {
207 const float resolution = reso->getTimeResolution(tk);
208 std::normal_distribution<float> gausGeneralTime(generalTrackTimes[
i], resolution);
209 times.push_back( gausGeneralTime(rng) );
210 resos.push_back( resolution );
213 times.push_back(0.0
f);
214 resos.push_back(-1.);
230 if( tvertex->nSourceTracks() && tvertex->sourceTracks()[0]->pdgId()==
pdgid ) {
231 auto pvertex = tvertex->sourceTracks()[0]->parentVertex();
232 result = pvertex->position();
233 while( pvertex->nSourceTracks() && pvertex->sourceTracks()[0]->pdgId()==
pdgid ) {
234 pvertex = pvertex->sourceTracks()[0]->parentVertex();
235 result = pvertex->position();
241 GlobalPoint result_pos(result.x(),result.y(),result.z());
244 float tkz = tkstate.position().z();
251 float pathlength =
std::sqrt(pathlengthrphi*pathlengthrphi + dz*dz);
254 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
friend struct const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
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_
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 >
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)
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
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
T get(const Candidate &c)
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupSummaryInfo_
GlobalVector momentum() const