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 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 ()
 
- 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

enum  { kNothing, kSimpleFit, kAllButOne, kExtrapolate }
 

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_src
 

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 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 ( )

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.

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

Implements edm::EDProducer.

Definition at line 110 of file CSCOverlapsTrackPreparation.cc.

References alongMomentum, assert(), edm::OwnVector< T, P >::begin(), MuonTransientTrackingRecHitBuilder::build(), MuonSubdetId::CSC, edm::OwnVector< T, P >::end(), edm::EventSetup::get(), edm::Event::getByLabel(), m_src, HLT_25ns14e33_v1_cff::magneticField, DetId::Muon, trajectoryStateTransform::persistentState(), Trajectory::push(), edm::OwnVector< T, P >::push_back(), edm::Event::put(), edm::OwnVector< T, P >::size(), and testEve_cfg::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  std::auto_ptr<std::vector<Trajectory> > trajectoryCollection(new 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.size() > 0) {
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(trajectoryCollection);
194 
195  // create the trajectory <-> track association map
196  std::auto_ptr<TrajTrackAssociationCollection> trajTrackMap(new 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(trajTrackMap);
205 }
RecHitPointer build(const TrackingRecHit *p, edm::ESHandle< GlobalTrackingGeometry > trackingGeometry) const
Call the MuonTransientTrackingRecHit::specificBuild.
assert(m_qm.get())
size_type size() const
Definition: OwnVector.h:254
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
iterator begin()
Definition: OwnVector.h:234
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
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > > TrajTrackAssociationCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:405
Definition: DetId.h:18
TrajectoryStateOnSurface TSOS
Definition: TestHits.cc:19
iterator end()
Definition: OwnVector.h:239
ROOT::Math::SVector< double, 5 > AlgebraicVector5
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:55
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:170
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection

Member Data Documentation

edm::InputTag CSCOverlapsTrackPreparation::m_src
private

Definition at line 75 of file CSCOverlapsTrackPreparation.cc.

Referenced by produce().