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 Attributes
MuonAssociatorByHits Class Reference

#include <MuonAssociatorByHits.h>

Inheritance diagram for MuonAssociatorByHits:
TrackAssociatorBase

Public Member Functions

reco::RecoToSimCollection associateRecoToSim (const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) const override
 Association Reco To Sim with Collections. More...
 
reco::SimToRecoCollection associateSimToReco (const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) const override
 Association Sim To Reco with Collections. More...
 
 MuonAssociatorByHits (const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
 
 MuonAssociatorByHits (const edm::ParameterSet &conf)
 
 ~MuonAssociatorByHits ()
 
- Public Member Functions inherited from TrackAssociatorBase
virtual reco::RecoToSimCollection associateRecoToSim (edm::Handle< edm::View< reco::Track > > &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const
 compare reco to sim the handle of reco::Track and TrackingParticle collections More...
 
virtual
reco::RecoToSimCollectionSeed 
associateRecoToSim (edm::Handle< edm::View< TrajectorySeed > > &, edm::Handle< TrackingParticleCollection > &, const edm::Event *event, const edm::EventSetup *setup) const
 
virtual
reco::RecoToSimCollectionTCandidate 
associateRecoToSim (edm::Handle< TrackCandidateCollection > &, edm::Handle< TrackingParticleCollection > &, const edm::Event *event, const edm::EventSetup *setup) const
 
virtual reco::SimToRecoCollection associateSimToReco (edm::Handle< edm::View< reco::Track > > &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const
 compare reco to sim the handle of reco::Track and TrackingParticle collections More...
 
virtual
reco::SimToRecoCollectionSeed 
associateSimToReco (edm::Handle< edm::View< TrajectorySeed > > &, edm::Handle< TrackingParticleCollection > &, const edm::Event *event, const edm::EventSetup *setup) const
 
virtual
reco::SimToRecoCollectionTCandidate 
associateSimToReco (edm::Handle< TrackCandidateCollection > &, edm::Handle< TrackingParticleCollection > &, const edm::Event *event, const edm::EventSetup *setup) const
 
 TrackAssociatorBase ()
 Constructor. More...
 
virtual ~TrackAssociatorBase ()
 Destructor. More...
 

Private Attributes

edm::ParameterSet const conf_
 
std::unique_ptr
< muonAssociatorByHitsDiagnostics::InputDumper
diagnostics_
 
MuonAssociatorByHitsHelper helper_
 

Detailed Description

Definition at line 25 of file MuonAssociatorByHits.h.

Constructor & Destructor Documentation

MuonAssociatorByHits::MuonAssociatorByHits ( const edm::ParameterSet conf,
edm::ConsumesCollector &&  iC 
)

Definition at line 138 of file MuonAssociatorByHits.cc.

References diagnostics_, edm::ParameterSet::getUntrackedParameter(), and eostools::move().

138  :
139  helper_(conf),
140  conf_(conf)
141 {
142  //hack for consumes
143  RPCHitAssociator rpctruth(conf,std::move(iC));
144  DTHitAssociator dttruth(conf,std::move(iC));
145  CSCHitAssociator muonTruth(conf,std::move(iC));
146  TrackerHitAssociator trackertruth(conf,std::move(iC));
147  if( conf.getUntrackedParameter<bool>("dumpInputCollections") ) {
148  diagnostics_.reset( new InputDumper(conf, std::move(iC)) );
149  }
150 }
T getUntrackedParameter(std::string const &, T const &) const
edm::ParameterSet const conf_
std::unique_ptr< muonAssociatorByHitsDiagnostics::InputDumper > diagnostics_
def move
Definition: eostools.py:508
MuonAssociatorByHitsHelper helper_
MuonAssociatorByHits::MuonAssociatorByHits ( const edm::ParameterSet conf)

Definition at line 153 of file MuonAssociatorByHits.cc.

References diagnostics_, and edm::ParameterSet::getUntrackedParameter().

153  :
154  helper_(conf),
155  conf_(conf)
156 {
157  if( conf.getUntrackedParameter<bool>("dumpInputCollections") ) {
158  diagnostics_.reset( new InputDumper(conf) );
159  }
160 }
T getUntrackedParameter(std::string const &, T const &) const
edm::ParameterSet const conf_
std::unique_ptr< muonAssociatorByHitsDiagnostics::InputDumper > diagnostics_
MuonAssociatorByHitsHelper helper_
MuonAssociatorByHits::~MuonAssociatorByHits ( )

Definition at line 164 of file MuonAssociatorByHits.cc.

165 {
166 }

Member Function Documentation

RecoToSimCollection MuonAssociatorByHits::associateRecoToSim ( const edm::RefToBaseVector< reco::Track > &  tC,
const edm::RefVector< TrackingParticleCollection > &  TPCollectionH,
const edm::Event event = 0,
const edm::EventSetup setup = 0 
) const
overridevirtual

Association Reco To Sim with Collections.

Implements TrackAssociatorBase.

Definition at line 169 of file MuonAssociatorByHits.cc.

References MuonAssociatorByHitsHelper::associateRecoToSimIndices(), edm::RefToBaseVector< T >::begin(), conf_, MuonAssociatorByHitsHelper::Resources::diagnostics_, diagnostics_, alignCSCRings::e, edm::RefToBaseVector< T >::end(), edm::EventSetup::get(), helper_, edm::AssociationMap< Tag >::insert(), edm::AssociationMap< Tag >::post_insert(), and edm::ESHandle< class >::product().

Referenced by MuonAssociatorEDProducer::produce().

171  {
172  RecoToSimCollection outputCollection;
173 
175  for (auto it = tC.begin(), ed = tC.end(); it != ed; ++it) {
176  tH.push_back(std::make_pair((*it)->recHitsBegin(), (*it)->recHitsEnd()));
177  }
178 
179  //Retrieve tracker topology from geometry
181  setup->get<IdealGeometryRecord>().get(tTopoHand);
182  const TrackerTopology *tTopo=tTopoHand.product();
183 
184 
185  // Tracker hit association
186  TrackerHitAssociator trackertruth(*e, conf_);
187  // CSC hit association
188  CSCHitAssociator csctruth(*e,*setup,conf_);
189  // DT hit association
190  bool printRtS(true);
191  DTHitAssociator dttruth(*e,*setup,conf_,printRtS);
192  // RPC hit association
193  RPCHitAssociator rpctruth(*e,*setup,conf_);
194 
195  MuonAssociatorByHitsHelper::Resources resources = {tTopo, &trackertruth, &csctruth, &dttruth, &rpctruth};
196 
197  if(diagnostics_) {
198  resources.diagnostics_ = [this, e](const TrackHitsCollection& hC, const TrackingParticleCollection& pC) {
199  diagnostics_->dump(hC,pC, *e);
200  };
201  }
202 
203  auto bareAssoc = helper_.associateRecoToSimIndices(tH, TPCollectionH, resources);
204  for (auto it = bareAssoc.begin(), ed = bareAssoc.end(); it != ed; ++it) {
205  for (auto itma = it->second.begin(), edma = it->second.end(); itma != edma; ++itma) {
206  outputCollection.insert(tC[it->first], std::make_pair(TPCollectionH[itma->idx], itma->quality));
207  }
208  }
209 
210  outputCollection.post_insert(); // perhaps not even necessary
211  return outputCollection;
212 }
edm::ParameterSet const conf_
std::vector< TrackingParticle > TrackingParticleCollection
const_iterator end() const
std::unique_ptr< muonAssociatorByHitsDiagnostics::InputDumper > diagnostics_
std::vector< std::pair< trackingRecHit_iterator, trackingRecHit_iterator > > TrackHitsCollection
void post_insert()
post insert action
std::function< void(const TrackHitsCollection &, const TrackingParticleCollection &)> diagnostics_
MuonAssociatorByHitsHelper::TrackHitsCollection TrackHitsCollection
void insert(const key_type &k, const data_type &v)
insert an association
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
const_iterator begin() const
IndexAssociation associateRecoToSimIndices(const TrackHitsCollection &, const edm::RefVector< TrackingParticleCollection > &, Resources const &) const
MuonAssociatorByHitsHelper helper_
SimToRecoCollection MuonAssociatorByHits::associateSimToReco ( const edm::RefToBaseVector< reco::Track > &  tC,
const edm::RefVector< TrackingParticleCollection > &  TPCollectionH,
const edm::Event event = 0,
const edm::EventSetup setup = 0 
) const
overridevirtual

Association Sim To Reco with Collections.

Implements TrackAssociatorBase.

Definition at line 215 of file MuonAssociatorByHits.cc.

References MuonAssociatorByHitsHelper::associateSimToRecoIndices(), edm::RefToBaseVector< T >::begin(), conf_, edm::RefToBaseVector< T >::end(), edm::EventSetup::get(), helper_, edm::AssociationMap< Tag >::insert(), edm::AssociationMap< Tag >::post_insert(), and edm::ESHandle< class >::product().

Referenced by MuonAssociatorEDProducer::produce().

217  {
218 
219  SimToRecoCollection outputCollection;
221  for (auto it = tC.begin(), ed = tC.end(); it != ed; ++it) {
222  tH.push_back(std::make_pair((*it)->recHitsBegin(), (*it)->recHitsEnd()));
223  }
224 
225  //Retrieve tracker topology from geometry
227  setup->get<IdealGeometryRecord>().get(tTopoHand);
228  const TrackerTopology *tTopo=tTopoHand.product();
229 
230  // Tracker hit association
231  TrackerHitAssociator trackertruth(*e, conf_);
232  // CSC hit association
233  CSCHitAssociator csctruth(*e,*setup,conf_);
234  // DT hit association
235  bool printRtS = false;
236  DTHitAssociator dttruth(*e,*setup,conf_,printRtS);
237  // RPC hit association
238  RPCHitAssociator rpctruth(*e,*setup,conf_);
239 
240  MuonAssociatorByHitsHelper::Resources resources = {tTopo, &trackertruth, &csctruth, &dttruth, &rpctruth};
241 
242  auto bareAssoc = helper_.associateSimToRecoIndices(tH, TPCollectionH, resources);
243  for (auto it = bareAssoc.begin(), ed = bareAssoc.end(); it != ed; ++it) {
244  for (auto itma = it->second.begin(), edma = it->second.end(); itma != edma; ++itma) {
245  outputCollection.insert(TPCollectionH[ it->first],
246  std::make_pair(tC[itma->idx], itma->quality));
247  }
248  }
249 
250  outputCollection.post_insert(); // perhaps not even necessary
251  return outputCollection;
252 }
edm::ParameterSet const conf_
const_iterator end() const
IndexAssociation associateSimToRecoIndices(const TrackHitsCollection &, const edm::RefVector< TrackingParticleCollection > &, Resources const &) const
std::vector< std::pair< trackingRecHit_iterator, trackingRecHit_iterator > > TrackHitsCollection
void post_insert()
post insert action
void insert(const key_type &k, const data_type &v)
insert an association
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
const_iterator begin() const
MuonAssociatorByHitsHelper helper_

Member Data Documentation

edm::ParameterSet const MuonAssociatorByHits::conf_
private

Definition at line 51 of file MuonAssociatorByHits.h.

Referenced by associateRecoToSim(), and associateSimToReco().

std::unique_ptr<muonAssociatorByHitsDiagnostics::InputDumper> MuonAssociatorByHits::diagnostics_
private

Definition at line 53 of file MuonAssociatorByHits.h.

Referenced by associateRecoToSim(), and MuonAssociatorByHits().

MuonAssociatorByHitsHelper MuonAssociatorByHits::helper_
private

Definition at line 50 of file MuonAssociatorByHits.h.

Referenced by associateRecoToSim(), and associateSimToReco().