CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TrackerToMuonPropagator Class Reference

#include <Alignment/TrackerToMuonPropagator/src/TrackerToMuonPropagator.cc>

Inheritance diagram for TrackerToMuonPropagator:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 TrackerToMuonPropagator (const edm::ParameterSet &)
 
 ~TrackerToMuonPropagator () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () 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

void beginJob () override
 
void endJob () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::InputTag m_globalMuons
 
edm::InputTag m_globalMuonTracks
 
std::string m_propagator
 
bool m_refitTracker
 
TrackTransformerm_trackTransformer
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer 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::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- 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

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 62 of file TrackerToMuonPropagator.cc.

Constructor & Destructor Documentation

TrackerToMuonPropagator::TrackerToMuonPropagator ( const edm::ParameterSet iConfig)
explicit

Definition at line 92 of file TrackerToMuonPropagator.cc.

References edm::ParameterSet::getParameter(), m_globalMuons, m_globalMuonTracks, m_propagator, m_refitTracker, m_trackTransformer, AlCaHLTBitMon_QueryRunRegistry::string, and HLT_2018_cff::TrackTransformer.

92  {
93  m_globalMuons = iConfig.getParameter<edm::InputTag>("globalMuons");
94  m_globalMuonTracks = iConfig.getParameter<edm::InputTag>("globalMuonTracks");
95  m_propagator = iConfig.getParameter<std::string>("propagator");
96  m_refitTracker = iConfig.getParameter<bool>("refitTrackerTrack");
97  if (m_refitTracker) {
98  m_trackTransformer = new TrackTransformer(iConfig.getParameter<edm::ParameterSet>("trackerTrackTransformer"));
99  } else
100  m_trackTransformer = nullptr;
101 
102  produces<std::vector<Trajectory>>();
103  produces<TrajTrackAssociationCollection>();
104 }
T getParameter(std::string const &) const
TrackTransformer * m_trackTransformer
TrackerToMuonPropagator::~TrackerToMuonPropagator ( )
override

Definition at line 106 of file TrackerToMuonPropagator.cc.

106  {
107  // do anything here that needs to be done at desctruction time
108  // (e.g. close files, deallocate resources etc.)
109 }

Member Function Documentation

void TrackerToMuonPropagator::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 270 of file TrackerToMuonPropagator.cc.

270 {}
void TrackerToMuonPropagator::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 273 of file TrackerToMuonPropagator.cc.

References DEFINE_FWK_MODULE.

Referenced by o2olib.O2ORunMgr::executeJob().

273 {}
void TrackerToMuonPropagator::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 116 of file TrackerToMuonPropagator.cc.

References alongMomentum, MuonTransientTrackingRecHitBuilder::build(), ALCARECOTkAlJpsiMuMu_cff::charge, MuonSubdetId::CSC, MuonSubdetId::DT, MillePedeFileConverter_cfg::e, edm::OwnVector< T, P >::empty(), Exception, Trajectory::firstMeasurement(), TrajectoryMeasurement::forwardPredictedState(), edm::EventSetup::get(), edm::Event::getByLabel(), susybsm::HSCParticleType::globalMuon, globalMuons_cfi::globalMuons, mps_fire::i, DTGeometry::idToDet(), TrackerGeometry::idToDet(), CSCGeometry::idToDet(), TrajectoryStateOnSurface::isValid(), m_globalMuons, m_globalMuonTracks, m_propagator, m_refitTracker, m_trackTransformer, HLT_2018_cff::magneticField, eostools::move(), DetId::Muon, trajectoryStateTransform::persistentState(), Propagator::propagate(), TrackCandidateProducer_cfi::propagator, Trajectory::push(), edm::OwnVector< T, P >::push_back(), edm::Event::put(), DetId::rawId(), TrajectoryMeasurement::recHit(), TrackTransformer::setServices(), edm::OwnVector< T, P >::size(), GeomDet::surface(), and TrackTransformer::transform().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

116  {
117  if (m_trackTransformer)
119 
121  iEvent.getByLabel(m_globalMuons, globalMuons);
122 
123  edm::Handle<reco::TrackCollection> globalMuonTracks;
124  iEvent.getByLabel(m_globalMuonTracks, globalMuonTracks);
125 
127  iSetup.get<TrackingComponentsRecord>().get(m_propagator, propagator);
128 
129  edm::ESHandle<TrackerGeometry> trackerGeometry;
130  iSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometry);
131 
132  edm::ESHandle<DTGeometry> dtGeometry;
133  iSetup.get<MuonGeometryRecord>().get(dtGeometry);
134 
135  edm::ESHandle<CSCGeometry> cscGeometry;
136  iSetup.get<MuonGeometryRecord>().get(cscGeometry);
137 
139  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
140 
142  iSetup.get<GlobalTrackingGeometryRecord>().get(globalGeometry);
143 
144  // Create these factories once per event
145 
146  MuonTransientTrackingRecHitBuilder muonTransBuilder;
147 
148  // Create a collection of Trajectories, to put in the Event
149  auto trajectoryCollection = std::make_unique<std::vector<Trajectory>>();
150 
151  // Remember which trajectory is associated with which track
152  std::map<edm::Ref<std::vector<Trajectory>>::key_type, edm::Ref<reco::TrackCollection>::key_type> reference_map;
153  edm::Ref<std::vector<Trajectory>>::key_type trajCounter = 0;
154 
155  for (reco::MuonCollection::const_iterator globalMuon = globalMuons->begin(); globalMuon != globalMuons->end();
156  ++globalMuon) {
157  // get the counter for this global muon (that's why we needed to extract the collection explicitly
159  reco::TrackCollection::const_iterator globalMuonTrack = globalMuonTracks->begin();
160  for (; globalMuonTrack != globalMuonTracks->end(); ++globalMuonTrack) {
161  trackCounter++;
162  if (fabs(globalMuon->combinedMuon()->phi() - globalMuonTrack->phi()) < 1e-10 &&
163  fabs(globalMuon->combinedMuon()->eta() - globalMuonTrack->eta()) < 1e-10)
164  break;
165  }
166  if (globalMuonTrack == globalMuonTracks->end()) {
167  throw cms::Exception("BadConfig") << "The tracks label doesn't correspond to the same objects as the muons label"
168  << std::endl;
169  }
170 
171  TrajectoryStateOnSurface tracker_tsos;
172  DetId outerDetId;
173  if (m_refitTracker) {
174  std::vector<Trajectory> trackerTrajectories = m_trackTransformer->transform(*globalMuon->track());
175  if (trackerTrajectories.size() == 1) {
176  const Trajectory trackerTrajectory = *(trackerTrajectories.begin());
177 
178  // surprisingly, firstMeasurement() corresponds to the outermost state of the tracker
179  tracker_tsos = trackerTrajectory.firstMeasurement().forwardPredictedState();
180  outerDetId = trackerTrajectory.firstMeasurement().recHit()->geographicalId();
181  } else
182  continue;
183  } else {
184  // get information about the outermost tracker hit
185  GlobalPoint outerPosition(globalMuon->track()->outerPosition().x(),
186  globalMuon->track()->outerPosition().y(),
187  globalMuon->track()->outerPosition().z());
188  GlobalVector outerMomentum(globalMuon->track()->outerMomentum().x(),
189  globalMuon->track()->outerMomentum().y(),
190  globalMuon->track()->outerMomentum().z());
191  int charge = globalMuon->track()->charge();
192  const reco::Track::CovarianceMatrix outerStateCovariance = globalMuon->track()->outerStateCovariance();
193  outerDetId = DetId(globalMuon->track()->outerDetId());
194 
195  // construct the information necessary to make a TrajectoryStateOnSurface
196  GlobalTrajectoryParameters globalTrajParams(outerPosition, outerMomentum, charge, &(*magneticField));
197  CurvilinearTrajectoryError curviError(outerStateCovariance);
198  FreeTrajectoryState tracker_state(globalTrajParams, curviError);
199 
200  // starting point for propagation into the muon system
201  tracker_tsos =
202  TrajectoryStateOnSurface(globalTrajParams, curviError, trackerGeometry->idToDet(outerDetId)->surface());
203  }
204 
205  TrajectoryStateOnSurface last_tsos = tracker_tsos;
206 
207  // loop over the muon hits, keeping track of the successful extrapolations
209  std::vector<TrajectoryStateOnSurface> TSOSes;
210  for (auto const& hit : globalMuon->combinedMuon()->recHits()) {
211  DetId id = hit->geographicalId();
212 
213  TrajectoryStateOnSurface extrapolation;
214  bool extrapolated = false;
215  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::DT) {
216  extrapolation = propagator->propagate(last_tsos, dtGeometry->idToDet(id)->surface());
217  extrapolated = true;
218  } else if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC) {
219  extrapolation = propagator->propagate(last_tsos, cscGeometry->idToDet(id)->surface());
220  extrapolated = true;
221  }
222 
223  if (extrapolated && extrapolation.isValid()) {
224  muonHits.push_back(hit->clone());
225  TSOSes.push_back(extrapolation);
226  }
227  } // end loop over standAloneMuon hits
228 
229  // if it has any successful extrapolations, make them into a Trajectory
230  if (!muonHits.empty()) {
231  PTrajectoryStateOnDet const& PTraj = trajectoryStateTransform::persistentState(tracker_tsos, outerDetId.rawId());
232  TrajectorySeed trajectorySeed(PTraj, muonHits, alongMomentum);
233  Trajectory trajectory(trajectorySeed, alongMomentum);
234 
235  for (unsigned int i = 0; i < muonHits.size(); i++) {
236  TrajectoryMeasurement::ConstRecHitPointer hitPtr(muonTransBuilder.build(&(muonHits[i]), globalGeometry));
237  TrajectoryStateOnSurface TSOS = TSOSes[i];
238  trajectory.push(TrajectoryMeasurement(TSOS, TSOS, TSOS, hitPtr));
239  } // end filling Trajectory
240 
241  trajectoryCollection->push_back(trajectory);
242 
243  // Remember which Trajectory is associated with which Track
244  trajCounter++;
245  reference_map[trajCounter] = trackCounter;
246 
247  } // end if we have some good extrapolations
248 
249  } // end loop over globalMuons
250 
251  unsigned int numTrajectories = trajectoryCollection->size();
252 
253  // insert the trajectories into the Event
254  edm::OrphanHandle<std::vector<Trajectory>> ohTrajs = iEvent.put(std::move(trajectoryCollection));
255 
256  // create the trajectory <-> track association map
257  auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>();
258 
259  for (trajCounter = 0; trajCounter < numTrajectories; trajCounter++) {
260  edm::Ref<reco::TrackCollection>::key_type trackCounter = reference_map[trajCounter];
261 
262  trajTrackMap->insert(edm::Ref<std::vector<Trajectory>>(ohTrajs, trajCounter),
263  edm::Ref<reco::TrackCollection>(globalMuonTracks, trackCounter));
264  }
265  // and put it in the Event, also
266  iEvent.put(std::move(trajTrackMap));
267 }
RecHitPointer build(const TrackingRecHit *p, edm::ESHandle< GlobalTrackingGeometry > trackingGeometry) const
Call the MuonTransientTrackingRecHit::specificBuild.
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:164
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
void setServices(const edm::EventSetup &) override
set the services needed by the TrackTransformer
ConstRecHitPointer const & recHit() const
const GeomDet * idToDet(DetId) const override
Definition: CSCGeometry.cc:91
size_type size() const
Definition: OwnVector.h:300
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
TrackTransformer * m_trackTransformer
void push_back(D *&d)
Definition: OwnVector.h:326
bool empty() const
Definition: OwnVector.h:305
std::vector< Trajectory > transform(const reco::Track &) const override
Convert a reco::Track into Trajectory.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
Definition: DetId.h:17
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:166
TrackingRecHit::ConstRecHitPointer ConstRecHitPointer
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
T get() const
Definition: EventSetup.h:73
const GeomDet * idToDet(DetId) const override
Definition: DTGeometry.cc:77
const TrackerGeomDet * idToDet(DetId) const override
static constexpr int DT
Definition: MuonSubdetId.h:11
static constexpr int CSC
Definition: MuonSubdetId.h:12
def move(src, dest)
Definition: eostools.py:511
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:74

Member Data Documentation

edm::InputTag TrackerToMuonPropagator::m_globalMuons
private

Definition at line 74 of file TrackerToMuonPropagator.cc.

Referenced by produce(), and TrackerToMuonPropagator().

edm::InputTag TrackerToMuonPropagator::m_globalMuonTracks
private

Definition at line 74 of file TrackerToMuonPropagator.cc.

Referenced by produce(), and TrackerToMuonPropagator().

std::string TrackerToMuonPropagator::m_propagator
private

Definition at line 75 of file TrackerToMuonPropagator.cc.

Referenced by produce(), and TrackerToMuonPropagator().

bool TrackerToMuonPropagator::m_refitTracker
private

Definition at line 77 of file TrackerToMuonPropagator.cc.

Referenced by produce(), and TrackerToMuonPropagator().

TrackTransformer* TrackerToMuonPropagator::m_trackTransformer
private

Definition at line 78 of file TrackerToMuonPropagator.cc.

Referenced by produce(), and TrackerToMuonPropagator().