37 #include "CLHEP/Units/SystemOfUnits.h" 39 #include "CLHEP/Random/RandGauss.h" 61 const std::vector<edm::EDGetTokenT<reco::TrackToTrackingParticleAssociator> >
associators_;
76 template<
typename ParticleType,
typename T>
79 const std::vector<T> &
values,
96 etaMin_( conf.getParameter<
double>(
"etaMin") ),
97 etaMax_( conf.getParameter<
double>(
"etaMax") ),
98 ptMin_( conf.getParameter<
double>(
"ptMin") ),
99 pMin_( conf.getParameter<
double>(
"pMin") ),
103 const std::vector<edm::ParameterSet>& resos = conf.getParameterSetVector(
"resolutionModels");
104 for(
const auto& reso : resos ) {
115 if (!rng.isAvailable()){
117 <<
"TrackTimeValueMapProducer::TrackTimeValueMapProducer() - RandomNumberGeneratorService is not present in configuration file.\n" 118 <<
"Add the service in the configuration file or remove the modules that require it.";
126 auto rng_engine = &(rng->
getEngine(sid));
129 std::vector<edm::Handle<reco::TrackToTrackingParticleAssociator> >
associators;
131 associators.emplace_back();
132 auto& back = associators.back();
136 std::vector<float> generalTrackTimes;
155 std::vector<reco::RecoToSimCollection> associatedTracks;
157 associatedTracks.emplace_back(
associator->associateRecoToSim(TrackCollectionH, TPCollectionH));
161 double sumSimTime = 0.;
162 double sumSimTimeSq = 0.;
165 if (puinfo.getBunchCrossing() == 0) {
166 for (
const float &
time : puinfo.getPU_times()) {
167 double simtime =
time;
168 sumSimTime += simtime;
169 sumSimTimeSq += simtime*simtime;
176 double meanSimTime = sumSimTime/double(nsim);
177 double varSimTime = sumSimTimeSq/double(nsim) - meanSimTime*meanSimTime;
180 for(
unsigned itk = 0; itk < TrackCollection.
size(); ++itk ) {
181 const auto tkref = TrackCollection.
refAt(itk);
184 for(
const auto&
association : associatedTracks ) {
189 if (track_tps != associatedTracks.back().end() && track_tps->val.size() == 1) {
192 generalTrackTimes.push_back(time);
195 float rndtime = CLHEP::RandGauss::shoot(rng_engine, meanSimTime, rmsSimTime);
196 generalTrackTimes.push_back(rndtime);
197 if (track_tps != associatedTracks.back().end() && track_tps->val.size() > 1) {
198 LogDebug(
"TooManyTracks") <<
"track matched to " << track_tps->val.size() <<
" tracking particles!" << std::endl;
205 std::vector<float>
times, resos;
207 times.reserve(TrackCollection.
size());
208 resos.reserve(TrackCollection.
size());
210 for(
unsigned i = 0;
i < TrackCollection.
size(); ++
i ) {
215 const float resolution = reso->getTimeResolution(tk);
216 times.push_back( CLHEP::RandGauss::shoot(rng_engine, generalTrackTimes[
i], resolution) );
217 resos.push_back( resolution );
220 times.push_back(0.0
f);
221 resos.push_back(-1.);
225 writeValueMap( evt, TrackCollectionH, times,
tracksName_+name );
237 if( tvertex->nSourceTracks() && tvertex->sourceTracks()[0]->pdgId()==
pdgid ) {
238 auto pvertex = tvertex->sourceTracks()[0]->parentVertex();
239 result = pvertex->position();
240 while( pvertex->nSourceTracks() && pvertex->sourceTracks()[0]->pdgId()==
pdgid ) {
241 pvertex = pvertex->sourceTracks()[0]->parentVertex();
242 result = pvertex->position();
248 GlobalPoint result_pos(result.x(),result.y(),result.z());
251 float tkz = tkstate.position().z();
258 float pathlength =
std::sqrt(pathlengthrphi*pathlengthrphi + dz*dz);
261 float speed =
std::sqrt(1./(1.+m_pion/p))*CLHEP::c_light/CLHEP::cm;
double p() const
momentum vector magnitude
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
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 >
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
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 deltaPhi(double phi1, double phi2)
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