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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 41 of file TrackTimeValueMapProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 84 of file TrackTimeValueMapProducer.cc.

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

86  tracksName_(conf.getParameter<edm::InputTag>("trackSrc").label()),
87  trackingParticles_(consumes<TrackingParticleCollection>(conf.getParameter<edm::InputTag>("trackingParticleSrc"))),
88  trackingVertices_(consumes<TrackingVertexCollection>(conf.getParameter<edm::InputTag>("trackingVertexSrc"))),
90  consumes<std::vector<PileupSummaryInfo>>(conf.getParameter<edm::InputTag>("pileupSummaryInfo"))),
92  conf.getParameter<std::vector<edm::InputTag>>("associators"),
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")),
98  etaMaxForPtThreshold_(conf.getParameter<double>("etaMaxForPtThreshold")) {
99  // setup resolution models
100  const std::vector<edm::ParameterSet> &resos = conf.getParameterSetVector("resolutionModels");
101  for (const auto &reso : resos) {
102  const std::string &name = reso.getParameter<std::string>("modelName");
103  resolutions_.emplace_back(ResolutionModelFactory::get()->create(name, reso));
104 
105  // times and time resolutions for general tracks
106  produces<edm::ValueMap<float>>(tracksName_ + name);
107  produces<edm::ValueMap<float>>(tracksName_ + name + resolution);
108  }
109 }
T getParameter(std::string const &) const
VParameterSet const & getParameterSetVector(std::string const &name) const
const edm::EDGetTokenT< TrackingVertexCollection > trackingVertices_
def create(alignables, pedeDump, additionalData, outputFile, config)
std::vector< std::unique_ptr< const ResolutionModel > > resolutions_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< TrackingParticleCollection > trackingParticles_
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
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 44 of file TrackTimeValueMapProducer.cc.

References produce().

44 {}

Member Function Documentation

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

Definition at line 224 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(), PixelCPEClusterRepair_cfi::speed, mathSSE::sqrt(), ntuplemaker::time, reco::TransientTrack::track(), reco::TransientTrack::trajectoryStateClosestToPoint(), reco::TrackBase::vz(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by produce().

225  {
226  int pdgid = tp.pdgId();
227  const auto &tvertex = tp.parentVertex();
228  math::XYZTLorentzVectorD result = tvertex->position();
229 
230  // account for secondary vertices...
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();
237  }
238  }
239 
240  float time = result.T() * CLHEP::second;
241  // correct for time of flight from track reference position
242  GlobalPoint result_pos(result.x(), result.y(), result.z());
243  const auto &tkstate = tt.trajectoryStateClosestToPoint(result_pos);
244  float tkphi = tkstate.momentum().phi();
245  float tkz = tkstate.position().z();
246  float dphi = reco::deltaPhi(tkphi, tt.track().phi());
247  float dz = tkz - tt.track().vz();
248 
249  float radius = 100. * tt.track().pt() / (0.3 * tt.field()->inTesla(GlobalPoint(0, 0, 0)).z());
250  float pathlengthrphi = tt.track().charge() * dphi * radius;
251 
252  float pathlength = std::sqrt(pathlengthrphi * pathlengthrphi + dz * dz);
253  float p = tt.track().p();
254 
255  float speed = std::sqrt(1. / (1. + m_pion / p)) * CLHEP::c_light / CLHEP::cm; // speed in cm/ns
256  float dt = pathlength / speed;
257 
258  return time - dt;
259 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
double p() const
momentum vector magnitude
Definition: TrackBase.h:654
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:684
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:660
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 vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:708
const Track & track() const
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
int charge() const
track electric charge
Definition: TrackBase.h:606
void TrackTimeValueMapProducer::produce ( edm::StreamID  sid,
edm::Event evt,
const edm::EventSetup es 
) const
override

Definition at line 111 of file TrackTimeValueMapProducer.cc.

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

Referenced by ~TrackTimeValueMapProducer().

111  {
112  // get sim track associators
113  std::vector<edm::Handle<reco::TrackToTrackingParticleAssociator>> associators;
114  for (const auto &token : associators_) {
115  associators.emplace_back();
116  auto &back = associators.back();
117  evt.getByToken(token, back);
118  }
119 
120  std::vector<float> generalTrackTimes;
121 
122  // get track collections
123  edm::Handle<edm::View<reco::Track>> TrackCollectionH;
124  evt.getByToken(tracks_, TrackCollectionH);
125  const edm::View<reco::Track> &TrackCollection = *TrackCollectionH;
126 
127  // get tracking particle collections
129  evt.getByToken(trackingParticles_, TPCollectionH);
130 
132  evt.getByToken(pileupSummaryInfo_, pileupSummaryH);
133 
134  // transient track builder
136  es.get<TransientTrackRecord>().get("TransientTrackBuilder", theB);
137 
138  // associate the reco tracks / gsf Tracks
139  std::vector<reco::RecoToSimCollection> associatedTracks;
140  for (auto associator : associators) {
141  associatedTracks.emplace_back(associator->associateRecoToSim(TrackCollectionH, TPCollectionH));
142  }
143 
144  double sumSimTime = 0.;
145  double sumSimTimeSq = 0.;
146  int nsim = 0;
147  for (const PileupSummaryInfo &puinfo : *pileupSummaryH) {
148  if (puinfo.getBunchCrossing() == 0) {
149  for (const float &time : puinfo.getPU_times()) {
150  double simtime = time;
151  sumSimTime += simtime;
152  sumSimTimeSq += simtime * simtime;
153  ++nsim;
154  }
155  break;
156  }
157  }
158 
159  double meanSimTime = sumSimTime / double(nsim);
160  double varSimTime = sumSimTimeSq / double(nsim) - meanSimTime * meanSimTime;
161  double rmsSimTime = std::sqrt(std::max(0.1 * 0.1, varSimTime));
162  std::normal_distribution<float> gausSimTime(meanSimTime, rmsSimTime);
163 
164  // get event-based seed for RNG
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);
171 
172  for (unsigned itk = 0; itk < TrackCollection.size(); ++itk) {
173  const auto tkref = TrackCollection.refAt(itk);
174  reco::RecoToSimCollection::const_iterator track_tps = associatedTracks.back().end();
175 
176  for (const auto &association : associatedTracks) {
177  track_tps = association.find(tkref);
178  if (track_tps != association.end())
179  break;
180  }
181 
182  if (track_tps != associatedTracks.back().end() && track_tps->val.size() == 1) {
183  reco::TransientTrack tt = theB->build(*tkref);
184  float time = extractTrackVertexTime(*track_tps->val[0].first, tt);
185  generalTrackTimes.push_back(time);
186  } else {
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!"
191  << std::endl;
192  }
193  }
194  }
195 
196  for (const auto &reso : resolutions_) {
197  const std::string &name = reso->name();
198  std::vector<float> times, resos;
199 
200  times.reserve(TrackCollection.size());
201  resos.reserve(TrackCollection.size());
202 
203  for (unsigned i = 0; i < TrackCollection.size(); ++i) {
204  const reco::Track &tk = TrackCollection[i];
205  const float absEta = std::abs(tk.eta());
206  bool inAcceptance = absEta < etaMax_ && absEta >= etaMin_ && tk.p() > pMin_ &&
207  (absEta > etaMaxForPtThreshold_ || tk.pt() > ptMin_);
208  if (inAcceptance) {
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);
213  } else {
214  times.push_back(0.0f);
215  resos.push_back(-1.);
216  }
217  }
218 
219  writeValueMap(evt, TrackCollectionH, times, tracksName_ + name);
220  writeValueMap(evt, TrackCollectionH, resos, tracksName_ + name + resolution);
221  }
222 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:39
double p() const
momentum vector magnitude
Definition: TrackBase.h:654
EventNumber_t event() const
Definition: EventID.h:41
friend struct const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:15
reco::TransientTrack build(const reco::Track *p) const
size_type size() const
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
std::vector< std::unique_ptr< const ResolutionModel > > resolutions_
void writeValueMap(edm::Event &iEvent, const edm::Handle< HandleType > &handle, const std::vector< ValueType > &values, const std::string &label)
Definition: Utils.h:13
RefToBase< value_type > refAt(size_type i) const
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:690
T sqrt(T t)
Definition: SSEVec.h:18
double pt() const
track transverse momentum
Definition: TrackBase.h:660
bool empty() const
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 std::vector< edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > > associators_
edm::EventID id() const
Definition: EventBase.h:59
T get() const
Definition: EventSetup.h:71
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 56 of file TrackTimeValueMapProducer.cc.

Referenced by produce().

const float TrackTimeValueMapProducer::etaMax_
private

Definition at line 58 of file TrackTimeValueMapProducer.cc.

Referenced by TrackTimeValueMapProducer().

const float TrackTimeValueMapProducer::etaMaxForPtThreshold_
private

Definition at line 58 of file TrackTimeValueMapProducer.cc.

Referenced by produce(), and TrackTimeValueMapProducer().

const float TrackTimeValueMapProducer::etaMin_
private

Definition at line 58 of file TrackTimeValueMapProducer.cc.

Referenced by produce(), and TrackTimeValueMapProducer().

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

Definition at line 54 of file TrackTimeValueMapProducer.cc.

Referenced by produce().

const float TrackTimeValueMapProducer::pMin_
private

Definition at line 58 of file TrackTimeValueMapProducer.cc.

Referenced by produce(), and TrackTimeValueMapProducer().

const float TrackTimeValueMapProducer::ptMin_
private

Definition at line 58 of file TrackTimeValueMapProducer.cc.

Referenced by produce(), and TrackTimeValueMapProducer().

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

Definition at line 60 of file TrackTimeValueMapProducer.cc.

Referenced by produce(), and TrackTimeValueMapProducer().

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

Definition at line 52 of file TrackTimeValueMapProducer.cc.

Referenced by produce().

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

Definition at line 53 of file TrackTimeValueMapProducer.cc.

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

Definition at line 50 of file TrackTimeValueMapProducer.cc.

Referenced by produce().

const std::string TrackTimeValueMapProducer::tracksName_
private

Definition at line 51 of file TrackTimeValueMapProducer.cc.

Referenced by produce(), and TrackTimeValueMapProducer().