CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob () override
 
virtual void endJob () override
 
virtual 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
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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

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

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

Definition at line 63 of file TrackerToMuonPropagator.cc.

Constructor & Destructor Documentation

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

Definition at line 93 of file TrackerToMuonPropagator.cc.

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

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

Definition at line 109 of file TrackerToMuonPropagator.cc.

110 {
111 
112  // do anything here that needs to be done at desctruction time
113  // (e.g. close files, deallocate resources etc.)
114 
115 }

Member Function Documentation

void TrackerToMuonPropagator::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 273 of file TrackerToMuonPropagator.cc.

274 {
275 }
void TrackerToMuonPropagator::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 279 of file TrackerToMuonPropagator.cc.

279  {
280 }
void TrackerToMuonPropagator::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 124 of file TrackerToMuonPropagator.cc.

References alongMomentum, MuonTransientTrackingRecHitBuilder::build(), MuonSubdetId::CSC, MuonSubdetId::DT, alignCSCRings::e, edm::hlt::Exception, Trajectory::firstMeasurement(), TrajectoryMeasurement::forwardPredictedState(), edm::EventSetup::get(), edm::Event::getByLabel(), susybsm::HSCParticleType::globalMuon, globalMuons_cfi::globalMuons, i, TrajectoryStateOnSurface::isValid(), m_globalMuons, m_globalMuonTracks, m_propagator, m_refitTracker, m_trackTransformer, DetId::Muon, trajectoryStateTransform::persistentState(), Trajectory::push(), edm::OwnVector< T, P >::push_back(), edm::Event::put(), DetId::rawId(), TrajectoryMeasurement::recHit(), TrackTransformer::setServices(), edm::OwnVector< T, P >::size(), and TrackTransformer::transform().

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

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

Member Data Documentation

edm::InputTag TrackerToMuonPropagator::m_globalMuons
private

Definition at line 75 of file TrackerToMuonPropagator.cc.

Referenced by produce(), and TrackerToMuonPropagator().

edm::InputTag TrackerToMuonPropagator::m_globalMuonTracks
private

Definition at line 75 of file TrackerToMuonPropagator.cc.

Referenced by produce(), and TrackerToMuonPropagator().

std::string TrackerToMuonPropagator::m_propagator
private

Definition at line 76 of file TrackerToMuonPropagator.cc.

Referenced by produce(), and TrackerToMuonPropagator().

bool TrackerToMuonPropagator::m_refitTracker
private

Definition at line 78 of file TrackerToMuonPropagator.cc.

Referenced by produce(), and TrackerToMuonPropagator().

TrackTransformer* TrackerToMuonPropagator::m_trackTransformer
private

Definition at line 79 of file TrackerToMuonPropagator.cc.

Referenced by produce(), and TrackerToMuonPropagator().