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 137 of file MuonAssociatorByHits.cc.

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

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

◆ ~MuonAssociatorByHits()

MuonAssociatorByHits::~MuonAssociatorByHits ( )
virtual

Definition at line 149 of file MuonAssociatorByHits.cc.

149 {}

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 151 of file MuonAssociatorByHits.cc.

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

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 200 of file MuonAssociatorByHits.cc.

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

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:33
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
muonAssociatorByHitsDiagnostics::TrackHitsCollection
MuonAssociatorByHitsHelper::TrackHitsCollection TrackHitsCollection
Definition: MuonAssociatorByHits.cc:21
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:37
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:255
TrackingParticleCollection
std::vector< TrackingParticle > TrackingParticleCollection
Definition: TrackingParticleFwd.h:8
edm::RefToBaseVector::begin
const_iterator begin() const
Definition: RefToBaseVector.h:181
muonAssociatorByHitsDiagnostics::InputDumper
Definition: MuonAssociatorByHits.cc:23
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:13
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
GEMHitAssociator
Definition: GEMHitAssociator.h:33