CMS 3D CMS Logo

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

#include <MuonAssociatorByHits.h>

Public Member Functions

reco::RecoToSimCollection associateRecoToSim (const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event=nullptr, const edm::EventSetup *setup=nullptr) const
 Association Reco To Sim with Collections. More...
 
reco::RecoToSimCollection associateRecoToSim (edm::Handle< edm::View< reco::Track >> &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const
 
reco::SimToRecoCollection associateSimToReco (const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event=nullptr, const edm::EventSetup *setup=nullptr) const
 Association Sim To Reco with Collections. More...
 
virtual reco::SimToRecoCollection associateSimToReco (edm::Handle< edm::View< reco::Track >> &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const
 
 MuonAssociatorByHits (const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
 
virtual ~MuonAssociatorByHits ()
 

Private Attributes

const edm::ParameterSet conf_
 
std::unique_ptr< muonAssociatorByHitsDiagnostics::InputDumperdiagnostics_
 
MuonAssociatorByHitsHelper helper_
 
TrackerHitAssociator::Config trackerHitAssociatorConfig_
 

Detailed Description

Definition at line 25 of file MuonAssociatorByHits.h.

Constructor & Destructor Documentation

◆ MuonAssociatorByHits()

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

Definition at line 139 of file MuonAssociatorByHits.cc.

140  : helper_(conf), conf_(conf), trackerHitAssociatorConfig_(conf, std::move(iC)) {
141  // hack for consumes
142  RPCHitAssociator rpctruth(conf, std::move(iC));
143  GEMHitAssociator gemtruth(conf, std::move(iC));
144  DTHitAssociator dttruth(conf, std::move(iC));
145  CSCHitAssociator muonTruth(conf, std::move(iC));
146  if (conf.getUntrackedParameter<bool>("dumpInputCollections")) {
147  diagnostics_ = std::make_unique<InputDumper>(conf, std::move(iC));
148  }
149 }

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

◆ ~MuonAssociatorByHits()

MuonAssociatorByHits::~MuonAssociatorByHits ( )
virtual

Definition at line 151 of file MuonAssociatorByHits.cc.

151 {}

Member Function Documentation

◆ associateRecoToSim() [1/2]

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

Association Reco To Sim with Collections.

Definition at line 153 of file MuonAssociatorByHits.cc.

157  {
158  RecoToSimCollection outputCollection(&e->productGetter());
159 
161  for (auto it = tC.begin(), ed = tC.end(); it != ed; ++it) {
162  tH.push_back(std::make_pair((*it)->recHitsBegin(), (*it)->recHitsEnd()));
163  }
164 
165  // Retrieve tracker topology from geometry
167  setup->get<TrackerTopologyRcd>().get(tTopoHand);
168  const TrackerTopology *tTopo = tTopoHand.product();
169 
170  // Tracker hit association
172  // CSC hit association
173  CSCHitAssociator csctruth(*e, *setup, conf_);
174  // DT hit association
175  bool printRtS(true);
176  DTHitAssociator dttruth(*e, *setup, conf_, printRtS);
177  // RPC hit association
178  RPCHitAssociator rpctruth(*e, *setup, conf_);
179  // GEM hit association
180  GEMHitAssociator gemtruth(*e, *setup, conf_);
181 
183  tTopo, &trackertruth, &csctruth, &dttruth, &rpctruth, &gemtruth, {}};
184 
185  if (diagnostics_) {
186  resources.diagnostics_ = [this, e](const TrackHitsCollection &hC, const TrackingParticleCollection &pC) {
187  diagnostics_->dump(hC, pC, *e);
188  };
189  }
190 
191  auto bareAssoc = helper_.associateRecoToSimIndices(tH, TPCollectionH, resources);
192  for (auto it = bareAssoc.begin(), ed = bareAssoc.end(); it != ed; ++it) {
193  for (auto itma = it->second.begin(), edma = it->second.end(); itma != edma; ++itma) {
194  outputCollection.insert(tC[it->first], std::make_pair(TPCollectionH[itma->idx], itma->quality));
195  }
196  }
197 
198  outputCollection.post_insert(); // perhaps not even necessary
199  return outputCollection;
200 }

References MuonAssociatorByHitsHelper::associateRecoToSimIndices(), edm::RefToBaseVector< T >::begin(), conf_, diagnostics_, MillePedeFileConverter_cfg::e, edm::RefToBaseVector< T >::end(), get, helper_, edm::ESHandle< T >::product(), mps_fire::resources, singleTopDQM_cfi::setup, and trackerHitAssociatorConfig_.

◆ associateRecoToSim() [2/2]

reco::RecoToSimCollection MuonAssociatorByHits::associateRecoToSim ( edm::Handle< edm::View< reco::Track >> &  tCH,
edm::Handle< TrackingParticleCollection > &  tPCH,
const edm::Event event,
const edm::EventSetup setup 
) const
inline

Definition at line 32 of file MuonAssociatorByHits.h.

35  {
37  for (unsigned int j = 0; j < tCH->size(); j++)
38  tc.push_back(tCH->refAt(j));
39 
41  for (unsigned int j = 0; j < tPCH->size(); j++)
43 
44  return associateRecoToSim(tc, tpc, event, setup);
45  }

References edm::HandleBase::id(), dqmiolumiharvest::j, edm::RefToBaseVector< T >::push_back(), edm::RefVector< C, T, F >::push_back(), and singleTopDQM_cfi::setup.

Referenced by MuonAssociatorEDProducer::produce().

◆ associateSimToReco() [1/2]

SimToRecoCollection MuonAssociatorByHits::associateSimToReco ( const edm::RefToBaseVector< reco::Track > &  tC,
const edm::RefVector< TrackingParticleCollection > &  TPCollectionH,
const edm::Event event = nullptr,
const edm::EventSetup setup = nullptr 
) const

Association Sim To Reco with Collections.

Definition at line 202 of file MuonAssociatorByHits.cc.

206  {
207  SimToRecoCollection outputCollection(&e->productGetter());
209  for (auto it = tC.begin(), ed = tC.end(); it != ed; ++it) {
210  tH.push_back(std::make_pair((*it)->recHitsBegin(), (*it)->recHitsEnd()));
211  }
212 
213  // Retrieve tracker topology from geometry
215  setup->get<TrackerTopologyRcd>().get(tTopoHand);
216  const TrackerTopology *tTopo = tTopoHand.product();
217 
218  // Tracker hit association
220  // CSC hit association
221  CSCHitAssociator csctruth(*e, *setup, conf_);
222  // DT hit association
223  bool printRtS = false;
224  DTHitAssociator dttruth(*e, *setup, conf_, printRtS);
225  // RPC hit association
226  RPCHitAssociator rpctruth(*e, *setup, conf_);
227  // GEM hit association
228  GEMHitAssociator gemtruth(*e, *setup, conf_);
229 
231  tTopo, &trackertruth, &csctruth, &dttruth, &rpctruth, &gemtruth, {}};
232 
233  auto bareAssoc = helper_.associateSimToRecoIndices(tH, TPCollectionH, resources);
234  for (auto it = bareAssoc.begin(), ed = bareAssoc.end(); it != ed; ++it) {
235  for (auto itma = it->second.begin(), edma = it->second.end(); itma != edma; ++itma) {
236  outputCollection.insert(TPCollectionH[it->first], std::make_pair(tC[itma->idx], itma->quality));
237  }
238  }
239 
240  outputCollection.post_insert(); // perhaps not even necessary
241  return outputCollection;
242 }

References MuonAssociatorByHitsHelper::associateSimToRecoIndices(), edm::RefToBaseVector< T >::begin(), conf_, MillePedeFileConverter_cfg::e, edm::RefToBaseVector< T >::end(), get, helper_, edm::ESHandle< T >::product(), mps_fire::resources, singleTopDQM_cfi::setup, and trackerHitAssociatorConfig_.

◆ associateSimToReco() [2/2]

virtual reco::SimToRecoCollection MuonAssociatorByHits::associateSimToReco ( edm::Handle< edm::View< reco::Track >> &  tCH,
edm::Handle< TrackingParticleCollection > &  tPCH,
const edm::Event event,
const edm::EventSetup setup 
) const
inlinevirtual

Definition at line 47 of file MuonAssociatorByHits.h.

50  {
52  for (unsigned int j = 0; j < tCH->size(); j++)
53  tc.push_back(tCH->refAt(j));
54 
56  for (unsigned int j = 0; j < tPCH->size(); j++)
58 
59  return associateSimToReco(tc, tpc, event, setup);
60  }

References edm::HandleBase::id(), dqmiolumiharvest::j, edm::RefToBaseVector< T >::push_back(), edm::RefVector< C, T, F >::push_back(), and singleTopDQM_cfi::setup.

Referenced by MuonAssociatorEDProducer::produce().

Member Data Documentation

◆ conf_

const edm::ParameterSet MuonAssociatorByHits::conf_
private

Definition at line 77 of file MuonAssociatorByHits.h.

Referenced by associateRecoToSim(), and associateSimToReco().

◆ diagnostics_

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

Definition at line 80 of file MuonAssociatorByHits.h.

Referenced by associateRecoToSim(), and MuonAssociatorByHits().

◆ helper_

MuonAssociatorByHitsHelper MuonAssociatorByHits::helper_
private

Definition at line 76 of file MuonAssociatorByHits.h.

Referenced by associateRecoToSim(), and associateSimToReco().

◆ trackerHitAssociatorConfig_

TrackerHitAssociator::Config MuonAssociatorByHits::trackerHitAssociatorConfig_
private

Definition at line 78 of file MuonAssociatorByHits.h.

Referenced by associateRecoToSim(), and associateSimToReco().

edm::RefToBaseVector::end
const_iterator end() const
Definition: RefToBaseVector.h:186
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
MuonAssociatorByHits::conf_
const edm::ParameterSet conf_
Definition: MuonAssociatorByHits.h:77
MuonAssociatorByHits::trackerHitAssociatorConfig_
TrackerHitAssociator::Config trackerHitAssociatorConfig_
Definition: MuonAssociatorByHits.h:78
MuonAssociatorByHits::diagnostics_
std::unique_ptr< muonAssociatorByHitsDiagnostics::InputDumper > diagnostics_
Definition: MuonAssociatorByHits.h:80
TrackerTopology
Definition: TrackerTopology.h:16
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::RefVector< TrackingParticleCollection >
MuonAssociatorByHitsHelper::TrackHitsCollection
std::vector< std::pair< trackingRecHit_iterator, trackingRecHit_iterator > > TrackHitsCollection
Definition: MuonAssociatorByHitsHelper.h:34
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
muonAssociatorByHitsDiagnostics::TrackHitsCollection
MuonAssociatorByHitsHelper::TrackHitsCollection TrackHitsCollection
Definition: MuonAssociatorByHits.cc:23
edm::Ref< TrackingParticleCollection >
MuonAssociatorByHits::helper_
MuonAssociatorByHitsHelper helper_
Definition: MuonAssociatorByHits.h:76
DTHitAssociator
Definition: DTHitAssociator.h:22
edm::RefToBaseVector::push_back
void push_back(const RefToBase< T > &)
Definition: RefToBaseVector.h:217
MuonAssociatorByHitsHelper::associateSimToRecoIndices
IndexAssociation associateSimToRecoIndices(const TrackHitsCollection &, const edm::RefVector< TrackingParticleCollection > &, Resources const &) const
Definition: MuonAssociatorByHitsHelper.cc:406
edm::ESHandle< TrackerTopology >
MuonAssociatorByHits::associateRecoToSim
reco::RecoToSimCollection associateRecoToSim(edm::Handle< edm::View< reco::Track >> &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const
Definition: MuonAssociatorByHits.h:32
edm::AssociationMap< edm::OneToManyWithQualityGeneric< edm::View< reco::Track >, TrackingParticleCollection, double > >
MuonAssociatorByHits::associateSimToReco
virtual reco::SimToRecoCollection associateSimToReco(edm::Handle< edm::View< reco::Track >> &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const
Definition: MuonAssociatorByHits.h:47
get
#define get
edm::RefVector::push_back
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
edm::RefToBaseVector< reco::Track >
MuonAssociatorByHitsHelper::Resources
Definition: MuonAssociatorByHitsHelper.h:38
TrackerHitAssociator
Definition: TrackerHitAssociator.h:55
eostools.move
def move(src, dest)
Definition: eostools.py:511
RPCHitAssociator
Definition: RPCHitAssociator.h:32
MuonAssociatorByHitsHelper::associateRecoToSimIndices
IndexAssociation associateRecoToSimIndices(const TrackHitsCollection &, const edm::RefVector< TrackingParticleCollection > &, Resources const &) const
Definition: MuonAssociatorByHitsHelper.cc:65
mps_fire.resources
resources
Definition: mps_fire.py:263
TrackingParticleCollection
std::vector< TrackingParticle > TrackingParticleCollection
Definition: TrackingParticleFwd.h:8
edm::RefToBaseVector::begin
const_iterator begin() const
Definition: RefToBaseVector.h:181
CSCHitAssociator
Definition: CSCHitAssociator.h:24
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
event
Definition: event.py:1
edm::HandleBase::id
ProductID id() const
Definition: HandleBase.cc:29
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
GEMHitAssociator
Definition: GEMHitAssociator.h:33