CMS 3D CMS Logo

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

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

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

Public Member Functions

 CSCOverlapsTrackPreparation (const edm::ParameterSet &)
 
 ~CSCOverlapsTrackPreparation () 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
 
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)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

enum  { kNothing, kSimpleFit, kAllButOne, kExtrapolate }
 

Private Member Functions

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

Private Attributes

edm::InputTag m_src
 

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::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 62 of file CSCOverlapsTrackPreparation.cc.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

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

Definition at line 89 of file CSCOverlapsTrackPreparation.cc.

90  : m_src(iConfig.getParameter<edm::InputTag>("src"))
91 {
92  produces<std::vector<Trajectory> >();
93  produces<TrajTrackAssociationCollection>();
94 }
T getParameter(std::string const &) const
CSCOverlapsTrackPreparation::~CSCOverlapsTrackPreparation ( )
override

Definition at line 97 of file CSCOverlapsTrackPreparation.cc.

98 {
99  // do anything here that needs to be done at desctruction time
100  // (e.g. close files, deallocate resources etc.)
101 }

Member Function Documentation

void CSCOverlapsTrackPreparation::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 208 of file CSCOverlapsTrackPreparation.cc.

208 {}
void CSCOverlapsTrackPreparation::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 211 of file CSCOverlapsTrackPreparation.cc.

References DEFINE_FWK_MODULE.

Referenced by o2olib.O2ORunMgr::executeJob().

211 {}
void CSCOverlapsTrackPreparation::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 110 of file CSCOverlapsTrackPreparation.cc.

References alongMomentum, edm::OwnVector< T, P >::begin(), MuonTransientTrackingRecHitBuilder::build(), MuonSubdetId::CSC, edm::OwnVector< T, P >::empty(), edm::OwnVector< T, P >::end(), edm::EventSetup::get(), edm::Event::getByLabel(), CSCGeometry::idToDet(), m_src, seedCreatorFromRegionConsecutiveHitsEDProducer_cff::magneticField, eostools::move(), DetId::Muon, trajectoryStateTransform::persistentState(), Trajectory::push(), edm::OwnVector< T, P >::push_back(), edm::Event::put(), edm::OwnVector< T, P >::size(), GeomDet::surface(), HiIsolationCommonParameters_cff::track, and l1t::tracks.

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

110  {
112  iEvent.getByLabel(m_src, tracks);
113 
114  edm::ESHandle<CSCGeometry> cscGeometry;
115  iSetup.get<MuonGeometryRecord>().get(cscGeometry);
116 
118  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
119 
121  iSetup.get<GlobalTrackingGeometryRecord>().get(globalGeometry);
122 
123 
124  MuonTransientTrackingRecHitBuilder muonTransBuilder;
125 
126  // Create a collection of Trajectories, to put in the Event
127  auto trajectoryCollection = std::make_unique<std::vector<Trajectory>>();
128 
129  // Remember which trajectory is associated with which track
130  std::map<edm::Ref<std::vector<Trajectory> >::key_type, edm::Ref<reco::TrackCollection>::key_type> reference_map;
131  edm::Ref<std::vector<Trajectory> >::key_type trajCounter = 0;
133 
134  for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
135  trackCounter++;
136 
137  // now we'll actually put hits on the new trajectory
138  // these must be in lock-step
140  std::vector<TrajectoryMeasurement::ConstRecHitPointer> transHits;
141  std::vector<TrajectoryStateOnSurface> TSOSes;
142 
143  for (trackingRecHit_iterator hit = track->recHitsBegin(); hit != track->recHitsEnd(); ++hit) {
144  DetId id = (*hit)->geographicalId();
145  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC) {
146  const Surface &layerSurface = cscGeometry->idToDet(id)->surface();
147  TrajectoryMeasurement::ConstRecHitPointer hitPtr(muonTransBuilder.build(&**hit, globalGeometry));
148 
149  AlgebraicVector5 params; // meaningless, CSCOverlapsAlignmentAlgorithm does the fit internally
150  params[0] = 1.; // straight-forward direction
151  params[1] = 0.;
152  params[2] = 0.;
153  params[3] = 0.; // center of the chamber
154  params[4] = 0.;
155  LocalTrajectoryParameters localTrajectoryParameters(params, 1., false);
156  LocalTrajectoryError localTrajectoryError(0.001, 0.001, 0.001, 0.001, 0.001);
157 
158  // these must be in lock-step
159  clonedHits.push_back((*hit)->clone());
160  transHits.push_back(hitPtr);
161  TSOSes.push_back(TrajectoryStateOnSurface(localTrajectoryParameters, localTrajectoryError, layerSurface, &*magneticField));
162  } // end if CSC
163  } // end loop over hits
164 
165  assert(clonedHits.size() == transHits.size());
166  assert(transHits.size() == TSOSes.size());
167 
168  // build the trajectory
169  if (!clonedHits.empty()) {
170  PTrajectoryStateOnDet const PTraj = trajectoryStateTransform::persistentState(*(TSOSes.begin()), clonedHits.begin()->geographicalId().rawId());
171  TrajectorySeed trajectorySeed(PTraj, clonedHits, alongMomentum);
172  Trajectory trajectory(trajectorySeed, alongMomentum);
173 
174  edm::OwnVector<TrackingRecHit>::const_iterator clonedHit = clonedHits.begin();
175  std::vector<TrajectoryMeasurement::ConstRecHitPointer>::const_iterator transHitPtr = transHits.begin();
176  std::vector<TrajectoryStateOnSurface>::const_iterator TSOS = TSOSes.begin();
177  for (; clonedHit != clonedHits.end(); ++clonedHit, ++transHitPtr, ++TSOS) {
178  trajectory.push(TrajectoryMeasurement(*TSOS, *TSOS, *TSOS, (*transHitPtr)));
179  }
180 
181  trajectoryCollection->push_back(trajectory);
182 
183  // Remember which Trajectory is associated with which Track
184  trajCounter++;
185  reference_map[trajCounter] = trackCounter;
186 
187  } // end if there are any clonedHits/TSOSes to work with
188  } // end loop over tracks
189 
190  unsigned int numTrajectories = trajectoryCollection->size();
191 
192  // insert the trajectories into the Event
193  edm::OrphanHandle<std::vector<Trajectory> > ohTrajs = iEvent.put(std::move(trajectoryCollection));
194 
195  // create the trajectory <-> track association map
196  auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>();
197 
198  for (trajCounter = 0; trajCounter < numTrajectories; trajCounter++) {
199  edm::Ref<reco::TrackCollection>::key_type trackCounter = reference_map[trajCounter];
200 
201  trajTrackMap->insert(edm::Ref<std::vector<Trajectory> >(ohTrajs, trajCounter), edm::Ref<reco::TrackCollection>(tracks, trackCounter));
202  }
203  // and put it in the Event, also
204  iEvent.put(std::move(trajTrackMap));
205 }
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:169
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
const GeomDet * idToDet(DetId) const override
Definition: CSCGeometry.cc:99
size_type size() const
Definition: OwnVector.h:264
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
iterator begin()
Definition: OwnVector.h:244
void push_back(D *&d)
Definition: OwnVector.h:290
bool empty() const
Definition: OwnVector.h:269
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:535
Definition: DetId.h:18
TrajectoryStateOnSurface TSOS
Definition: TestHits.cc:19
iterator end()
Definition: OwnVector.h:249
ROOT::Math::SVector< double, 5 > AlgebraicVector5
TrackingRecHit::ConstRecHitPointer ConstRecHitPointer
T get() const
Definition: EventSetup.h:63
static constexpr int CSC
Definition: MuonSubdetId.h:13
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

edm::InputTag CSCOverlapsTrackPreparation::m_src
private

Definition at line 75 of file CSCOverlapsTrackPreparation.cc.

Referenced by produce().