CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TrackTimeValueMapProducer Class Reference
Inheritance diagram for TrackTimeValueMapProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
 TrackTimeValueMapProducer (const edm::ParameterSet &)
 
 ~TrackTimeValueMapProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

float extractTrackVertexTime (const TrackingParticle &, const reco::TransientTrack &) const
 

Private Attributes

const std::vector< edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > > associators_
 
const float etaMax_
 
const float etaMaxForPtThreshold_
 
const float etaMin_
 
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupSummaryInfo_
 
const float pMin_
 
const float ptMin_
 
std::vector< std::unique_ptr< const ResolutionModel > > resolutions_
 
const edm::EDGetTokenT< TrackingParticleCollectiontrackingParticles_
 
const edm::EDGetTokenT< TrackingVertexCollectiontrackingVertices_
 
const edm::EDGetTokenT< edm::View< reco::Track > > tracks_
 
const std::string tracksName_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 46 of file TrackTimeValueMapProducer.cc.

Constructor & Destructor Documentation

TrackTimeValueMapProducer::TrackTimeValueMapProducer ( const edm::ParameterSet conf)

Definition at line 89 of file TrackTimeValueMapProducer.cc.

References etaMax_, etaMaxForPtThreshold_, etaMin_, Exception, reco::get(), dataset::name, pMin_, ptMin_, fftjetproducer_cfi::resolution, resolutions_, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, and tracksName_.

89  :
91  tracksName_(conf.getParameter<edm::InputTag>("trackSrc").label()),
92  trackingParticles_(consumes<TrackingParticleCollection>( conf.getParameter<edm::InputTag>("trackingParticleSrc") ) ),
93  trackingVertices_(consumes<TrackingVertexCollection>( conf.getParameter<edm::InputTag>("trackingVertexSrc") ) ),
94  pileupSummaryInfo_(consumes<std::vector<PileupSummaryInfo> >( conf.getParameter<edm::InputTag>("pileupSummaryInfo") ) ),
95  associators_( edm::vector_transform( conf.getParameter<std::vector<edm::InputTag> >("associators"), [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") )
101 {
102  // setup resolution models
103  const std::vector<edm::ParameterSet>& resos = conf.getParameterSetVector("resolutionModels");
104  for( const auto& reso : resos ) {
105  const std::string& name = reso.getParameter<std::string>("modelName");
106  ResolutionModel* resomod = ResolutionModelFactory::get()->create(name,reso);
107  resolutions_.emplace_back( resomod );
108 
109  // times and time resolutions for general tracks
110  produces<edm::ValueMap<float> >(tracksName_+name);
111  produces<edm::ValueMap<float> >(tracksName_+name+resolution);
112  }
113  // get RNG engine
115  if (!rng.isAvailable()){
116  throw cms::Exception("Configuration")
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.";
119  }
120 
121 }
T getParameter(std::string const &) const
VParameterSet const & getParameterSetVector(std::string const &name) const
const edm::EDGetTokenT< TrackingVertexCollection > trackingVertices_
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 >
Definition: transform.h:11
std::vector< std::unique_ptr< const ResolutionModel > > resolutions_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< TrackingParticleCollection > trackingParticles_
const std::vector< edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > > associators_
std::string const & label() const
Definition: InputTag.h:36
const edm::EDGetTokenT< edm::View< reco::Track > > tracks_
T get(const Candidate &c)
Definition: component.h:55
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupSummaryInfo_
TrackTimeValueMapProducer::~TrackTimeValueMapProducer ( )
inlineoverride

Definition at line 49 of file TrackTimeValueMapProducer.cc.

References produce().

49 { }

Member Function Documentation

float TrackTimeValueMapProducer::extractTrackVertexTime ( const TrackingParticle tp,
const reco::TransientTrack tt 
) const
private

Definition at line 231 of file TrackTimeValueMapProducer.cc.

References reco::TrackBase::charge(), reco::deltaPhi(), dt, PVValHelper::dz, reco::TransientTrack::field(), MagneticField::inTesla(), TrajectoryStateClosestToPoint::momentum(), AlCaHLTBitMon_ParallelJobs::p, reco::TrackBase::p(), TrackingParticle::parentVertex(), BPhysicsValidation_cfi::pdgid, TrackingParticle::pdgId(), PV3DBase< T, PVType, FrameType >::phi(), reco::TrackBase::phi(), reco::TrackBase::pt(), TCMET_cfi::radius, mps_fire::result, edm::second(), PixelCPETemplateReco_cfi::speed, mathSSE::sqrt(), ntuplemaker::time, reco::TransientTrack::track(), reco::TransientTrack::trajectoryStateClosestToPoint(), reco::TrackBase::vz(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by produce().

231  {
232  int pdgid = tp.pdgId();
233  const auto& tvertex = tp.parentVertex();
234  math::XYZTLorentzVectorD result = tvertex->position();
235 
236  // account for secondary vertices...
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();
243  }
244  }
245 
246  float time = result.T()*CLHEP::second;
247  //correct for time of flight from track reference position
248  GlobalPoint result_pos(result.x(),result.y(),result.z());
249  const auto &tkstate = tt.trajectoryStateClosestToPoint(result_pos);
250  float tkphi = tkstate.momentum().phi();
251  float tkz = tkstate.position().z();
252  float dphi = reco::deltaPhi(tkphi,tt.track().phi());
253  float dz = tkz - tt.track().vz();
254 
255  float radius = 100.*tt.track().pt()/(0.3*tt.field()->inTesla(GlobalPoint(0,0,0)).z());
256  float pathlengthrphi = tt.track().charge()*dphi*radius;
257 
258  float pathlength = std::sqrt(pathlengthrphi*pathlengthrphi + dz*dz);
259  float p = tt.track().p();
260 
261  float speed = std::sqrt(1./(1.+m_pion/p))*CLHEP::c_light/CLHEP::cm; //speed in cm/ns
262  float dt = pathlength/speed;
263 
264  return time-dt;
265 }
double p() const
momentum vector magnitude
Definition: TrackBase.h:615
float dt
Definition: AMPTWrapper.h:126
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
int pdgId() const
PDG ID.
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:645
const MagneticField * field() const
U second(std::pair< T, U > const &p)
T sqrt(T t)
Definition: SSEVec.h:18
double pt() const
track transverse momentum
Definition: TrackBase.h:621
T z() const
Definition: PV3DBase.h:64
const TrackingVertexRef & parentVertex() const
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:669
const Track & track() const
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
int charge() const
track electric charge
Definition: TrackBase.h:567
void TrackTimeValueMapProducer::produce ( edm::StreamID  sid,
edm::Event evt,
const edm::EventSetup es 
) const
override

Definition at line 123 of file TrackTimeValueMapProducer.cc.

References funct::abs(), TrackValidation_cff::association, ctfWithMaterialTrackMCMatch_cfi::associator, simPFProducer_cfi::associators, associators_, TransientTrackBuilder::build(), edm::AssociationMap< Tag >::const_iterator, reco::TrackBase::eta(), etaMaxForPtThreshold_, etaMin_, extractTrackVertexTime(), f, edm::EventSetup::get(), edm::Event::getByToken(), edm::RandomNumberGenerator::getEngine(), mps_fire::i, LogDebug, hpstanc_transforms::max, dataset::name, reco::TrackBase::p(), pileupSummaryInfo_, pMin_, reco::TrackBase::pt(), ptMin_, edm::View< T >::refAt(), fftjetproducer_cfi::resolution, resolutions_, edm::View< T >::size(), mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, ntuplemaker::time, create_public_lumi_plots::times, trackingParticles_, tracks_, tracksName_, and groupFilesInBlocks::tt.

Referenced by ~TrackTimeValueMapProducer().

123  {
124  // get RNG engine
126  auto rng_engine = &(rng->getEngine(sid));
127 
128  // get sim track associators
129  std::vector<edm::Handle<reco::TrackToTrackingParticleAssociator> > associators;
130  for( const auto& token : associators_ ) {
131  associators.emplace_back();
132  auto& back = associators.back();
133  evt.getByToken(token,back);
134  }
135 
136  std::vector<float> generalTrackTimes;
137 
138  //get track collections
139  edm::Handle<edm::View<reco::Track> > TrackCollectionH;
140  evt.getByToken(tracks_, TrackCollectionH);
141  const edm::View<reco::Track>& TrackCollection = *TrackCollectionH;
142 
143  //get tracking particle collections
145  evt.getByToken(trackingParticles_, TPCollectionH);
146 
148  evt.getByToken(pileupSummaryInfo_, pileupSummaryH);
149 
150  //transient track builder
152  es.get<TransientTrackRecord>().get("TransientTrackBuilder",theB);
153 
154  // associate the reco tracks / gsf Tracks
155  std::vector<reco::RecoToSimCollection> associatedTracks;
156  for( auto associator : associators ) {
157  associatedTracks.emplace_back(associator->associateRecoToSim(TrackCollectionH, TPCollectionH));
158  }
159 
160 
161  double sumSimTime = 0.;
162  double sumSimTimeSq = 0.;
163  int nsim = 0;
164  for (const PileupSummaryInfo &puinfo : *pileupSummaryH) {
165  if (puinfo.getBunchCrossing() == 0) {
166  for (const float &time : puinfo.getPU_times()) {
167  double simtime = time;
168  sumSimTime += simtime;
169  sumSimTimeSq += simtime*simtime;
170  ++nsim;
171  }
172  break;
173  }
174  }
175 
176  double meanSimTime = sumSimTime/double(nsim);
177  double varSimTime = sumSimTimeSq/double(nsim) - meanSimTime*meanSimTime;
178  double rmsSimTime = std::sqrt(std::max(0.1*0.1,varSimTime));
179 
180  for( unsigned itk = 0; itk < TrackCollection.size(); ++itk ) {
181  const auto tkref = TrackCollection.refAt(itk);
182  reco::RecoToSimCollection::const_iterator track_tps = associatedTracks.back().end();
183 
184  for( const auto& association : associatedTracks ) {
185  track_tps = association.find(tkref);
186  if( track_tps != association.end() ) break;
187  }
188 
189  if (track_tps != associatedTracks.back().end() && track_tps->val.size() == 1) {
190  reco::TransientTrack tt = theB->build(*tkref);
191  float time = extractTrackVertexTime(*track_tps->val[0].first,tt);
192  generalTrackTimes.push_back(time);
193  }
194  else {
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;
199  }
200  }
201  }
202 
203  for( const auto& reso : resolutions_ ) {
204  const std::string& name = reso->name();
205  std::vector<float> times, resos;
206 
207  times.reserve(TrackCollection.size());
208  resos.reserve(TrackCollection.size());
209 
210  for( unsigned i = 0; i < TrackCollection.size(); ++i ) {
211  const reco::Track& tk = TrackCollection[i];
212  const float absEta = std::abs(tk.eta());
213  bool inAcceptance = absEta < etaMax_ && absEta >= etaMin_ && tk.p()>pMin_ && (absEta>etaMaxForPtThreshold_ || tk.pt()>ptMin_);
214  if (inAcceptance) {
215  const float resolution = reso->getTimeResolution(tk);
216  times.push_back( CLHEP::RandGauss::shoot(rng_engine, generalTrackTimes[i], resolution) );
217  resos.push_back( resolution );
218  }
219  else {
220  times.push_back(0.0f);
221  resos.push_back(-1.);
222  }
223  }
224 
225  writeValueMap( evt, TrackCollectionH, times, tracksName_+name );
226  writeValueMap( evt, TrackCollectionH, resos, tracksName_+name+resolution );
227  }
228 }
#define LogDebug(id)
double p() const
momentum vector magnitude
Definition: TrackBase.h:615
friend struct const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
reco::TransientTrack build(const reco::Track *p) const
size_type size() const
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
std::vector< std::unique_ptr< const ResolutionModel > > resolutions_
RefToBase< value_type > refAt(size_type i) const
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:651
T sqrt(T t)
Definition: SSEVec.h:18
double pt() const
track transverse momentum
Definition: TrackBase.h:621
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float extractTrackVertexTime(const TrackingParticle &, const reco::TransientTrack &) const
double f[11][100]
const edm::EDGetTokenT< TrackingParticleCollection > trackingParticles_
const T & get() const
Definition: EventSetup.h:55
const std::vector< edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > > associators_
const edm::EDGetTokenT< edm::View< reco::Track > > tracks_
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupSummaryInfo_

Member Data Documentation

const std::vector<edm::EDGetTokenT<reco::TrackToTrackingParticleAssociator> > TrackTimeValueMapProducer::associators_
private

Definition at line 61 of file TrackTimeValueMapProducer.cc.

Referenced by produce().

const float TrackTimeValueMapProducer::etaMax_
private

Definition at line 63 of file TrackTimeValueMapProducer.cc.

Referenced by TrackTimeValueMapProducer().

const float TrackTimeValueMapProducer::etaMaxForPtThreshold_
private

Definition at line 63 of file TrackTimeValueMapProducer.cc.

Referenced by produce(), and TrackTimeValueMapProducer().

const float TrackTimeValueMapProducer::etaMin_
private

Definition at line 63 of file TrackTimeValueMapProducer.cc.

Referenced by produce(), and TrackTimeValueMapProducer().

const edm::EDGetTokenT<std::vector<PileupSummaryInfo> > TrackTimeValueMapProducer::pileupSummaryInfo_
private

Definition at line 59 of file TrackTimeValueMapProducer.cc.

Referenced by produce().

const float TrackTimeValueMapProducer::pMin_
private

Definition at line 63 of file TrackTimeValueMapProducer.cc.

Referenced by produce(), and TrackTimeValueMapProducer().

const float TrackTimeValueMapProducer::ptMin_
private

Definition at line 63 of file TrackTimeValueMapProducer.cc.

Referenced by produce(), and TrackTimeValueMapProducer().

std::vector<std::unique_ptr<const ResolutionModel> > TrackTimeValueMapProducer::resolutions_
private

Definition at line 65 of file TrackTimeValueMapProducer.cc.

Referenced by produce(), and TrackTimeValueMapProducer().

const edm::EDGetTokenT<TrackingParticleCollection> TrackTimeValueMapProducer::trackingParticles_
private

Definition at line 57 of file TrackTimeValueMapProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<TrackingVertexCollection> TrackTimeValueMapProducer::trackingVertices_
private

Definition at line 58 of file TrackTimeValueMapProducer.cc.

const edm::EDGetTokenT<edm::View<reco::Track> > TrackTimeValueMapProducer::tracks_
private

Definition at line 55 of file TrackTimeValueMapProducer.cc.

Referenced by produce().

const std::string TrackTimeValueMapProducer::tracksName_
private

Definition at line 56 of file TrackTimeValueMapProducer.cc.

Referenced by produce(), and TrackTimeValueMapProducer().