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>

Public Member Functions

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

Private Attributes

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

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_, and edm::ParameterSet::getUntrackedParameter().

138  :
139  helper_(conf),
140  conf_(conf),
141  trackerHitAssociatorConfig_(conf, std::move(iC))
142 {
143  //hack for consumes
144  RPCHitAssociator rpctruth(conf,std::move(iC));
145  DTHitAssociator dttruth(conf,std::move(iC));
146  CSCHitAssociator muonTruth(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_
TrackerHitAssociator::Config trackerHitAssociatorConfig_
std::unique_ptr< muonAssociatorByHitsDiagnostics::InputDumper > diagnostics_
MuonAssociatorByHitsHelper helper_
MuonAssociatorByHits::~MuonAssociatorByHits ( )

Definition at line 154 of file MuonAssociatorByHits.cc.

155 {
156 }

Member Function Documentation

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 33 of file MuonAssociatorByHits.h.

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

Referenced by MuonAssociatorEDProducer::produce().

36  {
38  for (unsigned int j=0; j<tCH->size();j++)
39  tc.push_back(tCH->refAt(j));
40 
42  for (unsigned int j=0; j<tPCH->size();j++)
44 
45  return associateRecoToSim(tc,tpc,event,setup);
46  }
ProductID id() const
Definition: HandleBase.cc:15
int j
Definition: DBlmapReader.cc:9
reco::RecoToSimCollection associateRecoToSim(edm::Handle< edm::View< reco::Track > > &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const
void push_back(const RefToBase< T > &)
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:62
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

Association Reco To Sim with Collections.

Definition at line 159 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::ESHandle< class >::product(), edm::Event::productGetter(), and trackerHitAssociatorConfig_.

161  {
162  RecoToSimCollection outputCollection(&e->productGetter());
163 
165  for (auto it = tC.begin(), ed = tC.end(); it != ed; ++it) {
166  tH.push_back(std::make_pair((*it)->recHitsBegin(), (*it)->recHitsEnd()));
167  }
168 
169  //Retrieve tracker topology from geometry
171  setup->get<TrackerTopologyRcd>().get(tTopoHand);
172  const TrackerTopology *tTopo=tTopoHand.product();
173 
174 
175  // Tracker hit association
177  // CSC hit association
178  CSCHitAssociator csctruth(*e,*setup,conf_);
179  // DT hit association
180  bool printRtS(true);
181  DTHitAssociator dttruth(*e,*setup,conf_,printRtS);
182  // RPC hit association
183  RPCHitAssociator rpctruth(*e,*setup,conf_);
184 
185  MuonAssociatorByHitsHelper::Resources resources = {tTopo, &trackertruth, &csctruth, &dttruth, &rpctruth};
186 
187  if(diagnostics_) {
188  resources.diagnostics_ = [this, e](const TrackHitsCollection& hC, const TrackingParticleCollection& pC) {
189  diagnostics_->dump(hC,pC, *e);
190  };
191  }
192 
193  auto bareAssoc = helper_.associateRecoToSimIndices(tH, TPCollectionH, resources);
194  for (auto it = bareAssoc.begin(), ed = bareAssoc.end(); it != ed; ++it) {
195  for (auto itma = it->second.begin(), edma = it->second.end(); itma != edma; ++itma) {
196  outputCollection.insert(tC[it->first], std::make_pair(TPCollectionH[itma->idx], itma->quality));
197  }
198  }
199 
200  outputCollection.post_insert(); // perhaps not even necessary
201  return outputCollection;
202 }
edm::ParameterSet const conf_
std::vector< TrackingParticle > TrackingParticleCollection
const_iterator end() const
TrackerHitAssociator::Config trackerHitAssociatorConfig_
std::unique_ptr< muonAssociatorByHitsDiagnostics::InputDumper > diagnostics_
std::vector< std::pair< trackingRecHit_iterator, trackingRecHit_iterator > > TrackHitsCollection
std::function< void(const TrackHitsCollection &, const TrackingParticleCollection &)> diagnostics_
MuonAssociatorByHitsHelper::TrackHitsCollection TrackHitsCollection
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_
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 48 of file MuonAssociatorByHits.h.

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

Referenced by MuonAssociatorEDProducer::produce().

51  {
53  for (unsigned int j=0; j<tCH->size();j++)
54  tc.push_back(tCH->refAt(j));
55 
57  for (unsigned int j=0; j<tPCH->size();j++)
59 
60  return associateSimToReco(tc,tpc,event,setup);
61  }
ProductID id() const
Definition: HandleBase.cc:15
int j
Definition: DBlmapReader.cc:9
void push_back(const RefToBase< T > &)
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:62
virtual reco::SimToRecoCollection associateSimToReco(edm::Handle< edm::View< reco::Track > > &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const
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

Association Sim To Reco with Collections.

Definition at line 205 of file MuonAssociatorByHits.cc.

References MuonAssociatorByHitsHelper::associateSimToRecoIndices(), edm::RefToBaseVector< T >::begin(), conf_, edm::RefToBaseVector< T >::end(), edm::EventSetup::get(), helper_, edm::ESHandle< class >::product(), edm::Event::productGetter(), and trackerHitAssociatorConfig_.

207  {
208 
209  SimToRecoCollection outputCollection(&e->productGetter());
211  for (auto it = tC.begin(), ed = tC.end(); it != ed; ++it) {
212  tH.push_back(std::make_pair((*it)->recHitsBegin(), (*it)->recHitsEnd()));
213  }
214 
215  //Retrieve tracker topology from geometry
217  setup->get<TrackerTopologyRcd>().get(tTopoHand);
218  const TrackerTopology *tTopo=tTopoHand.product();
219 
220  // Tracker hit association
222  // CSC hit association
223  CSCHitAssociator csctruth(*e,*setup,conf_);
224  // DT hit association
225  bool printRtS = false;
226  DTHitAssociator dttruth(*e,*setup,conf_,printRtS);
227  // RPC hit association
228  RPCHitAssociator rpctruth(*e,*setup,conf_);
229 
230  MuonAssociatorByHitsHelper::Resources resources = {tTopo, &trackertruth, &csctruth, &dttruth, &rpctruth};
231 
232  auto bareAssoc = helper_.associateSimToRecoIndices(tH, TPCollectionH, resources);
233  for (auto it = bareAssoc.begin(), ed = bareAssoc.end(); it != ed; ++it) {
234  for (auto itma = it->second.begin(), edma = it->second.end(); itma != edma; ++itma) {
235  outputCollection.insert(TPCollectionH[ it->first],
236  std::make_pair(tC[itma->idx], itma->quality));
237  }
238  }
239 
240  outputCollection.post_insert(); // perhaps not even necessary
241  return outputCollection;
242 }
edm::ParameterSet const conf_
const_iterator end() const
TrackerHitAssociator::Config trackerHitAssociatorConfig_
IndexAssociation associateSimToRecoIndices(const TrackHitsCollection &, const edm::RefVector< TrackingParticleCollection > &, Resources const &) const
std::vector< std::pair< trackingRecHit_iterator, trackingRecHit_iterator > > TrackHitsCollection
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 78 of file MuonAssociatorByHits.h.

Referenced by associateRecoToSim(), and associateSimToReco().

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

Definition at line 81 of file MuonAssociatorByHits.h.

Referenced by associateRecoToSim(), and MuonAssociatorByHits().

MuonAssociatorByHitsHelper MuonAssociatorByHits::helper_
private

Definition at line 77 of file MuonAssociatorByHits.h.

Referenced by associateRecoToSim(), and associateSimToReco().

TrackerHitAssociator::Config MuonAssociatorByHits::trackerHitAssociatorConfig_
private

Definition at line 79 of file MuonAssociatorByHits.h.

Referenced by associateRecoToSim(), and associateSimToReco().