CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
GEMHitAssociator Class Reference

#include <GEMHitAssociator.h>

Classes

class  Config
 

Public Types

typedef edm::DetSetVector< GEMDigiSimLinkDigiSimLinks
 
typedef edm::DetSet< GEMDigiSimLinkLayerLinks
 
typedef std::pair< uint32_t, EncodedEventIdSimHitIdpr
 

Public Member Functions

std::vector< SimHitIdprassociateRecHit (const GEMRecHit *gemrechit) const
 
 GEMHitAssociator (const edm::Event &e, const Config &config)
 

Private Member Functions

void initEvent (const edm::Event &)
 

Private Attributes

std::map< unsigned int, edm::PSimHitContainer_SimHitMap
 
const ConfigtheConfig
 
const DigiSimLinkstheDigiSimLinks
 

Detailed Description

Definition at line 33 of file GEMHitAssociator.h.

Member Typedef Documentation

◆ DigiSimLinks

Definition at line 54 of file GEMHitAssociator.h.

◆ LayerLinks

Definition at line 55 of file GEMHitAssociator.h.

◆ SimHitIdpr

typedef std::pair<uint32_t, EncodedEventId> GEMHitAssociator::SimHitIdpr

Definition at line 56 of file GEMHitAssociator.h.

Constructor & Destructor Documentation

◆ GEMHitAssociator()

GEMHitAssociator::GEMHitAssociator ( const edm::Event e,
const Config config 
)

Definition at line 23 of file GEMHitAssociator.cc.

References MillePedeFileConverter_cfg::e, and initEvent().

Member Function Documentation

◆ associateRecHit()

std::vector< GEMHitAssociator::SimHitIdpr > GEMHitAssociator::associateRecHit ( const GEMRecHit gemrechit) const

Definition at line 57 of file GEMHitAssociator.cc.

References GEMRecHit::clusterSize(), edm::DetSetVector< T >::end(), spr::find(), edm::DetSetVector< T >::find(), GEMRecHit::firstClusterStrip(), GEMRecHit::gemId(), mps_fire::i, muonTagProbeFilters_cff::matched, theConfig, theDigiSimLinks, and GEMHitAssociator::Config::useGEMs_.

Referenced by MuonAssociatorByHitsHelper::getMatchedIds().

57  {
58  std::vector<SimHitIdpr> matched;
59 
60  if (theConfig.useGEMs_) {
61  if (gemrechit) {
62  GEMDetId gemDetId = gemrechit->gemId();
63  int fstrip = gemrechit->firstClusterStrip();
64  int cls = gemrechit->clusterSize();
65  // int bx = gemrechit->BunchX();
66 
67  DigiSimLinks::const_iterator layerLinks = theDigiSimLinks->find(gemDetId);
68 
69  if (layerLinks != theDigiSimLinks->end()) {
70  for (int i = fstrip; i < (fstrip + cls); ++i) {
71  for (LayerLinks::const_iterator itlink = layerLinks->begin(); itlink != layerLinks->end(); ++itlink) {
72  int ch = static_cast<int>(itlink->getStrip());
73  if (ch != i)
74  continue;
75 
76  SimHitIdpr currentId(itlink->getTrackId(), itlink->getEventId());
77  if (find(matched.begin(), matched.end(), currentId) == matched.end())
78  matched.push_back(currentId);
79  }
80  }
81 
82  } else
83  edm::LogWarning("GEMHitAssociator")
84  << "*** WARNING in GEMHitAssociator: GEM layer " << gemDetId << " has no DigiSimLinks !" << std::endl;
85 
86  } else
87  edm::LogWarning("GEMHitAssociator") << "*** WARNING in GEMHitAssociator::associateRecHit, null "
88  "dynamic_cast !";
89  }
90 
91  return matched;
92 }
iterator find(det_id_type id)
Definition: DetSetVector.h:264
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:325
std::pair< uint32_t, EncodedEventId > SimHitIdpr
GEMDetId gemId() const
Return the gemId.
Definition: GEMRecHit.h:65
const DigiSimLinks * theDigiSimLinks
int firstClusterStrip() const
Definition: GEMRecHit.h:69
const Config & theConfig
int clusterSize() const
Definition: GEMRecHit.h:71
Log< level::Warning, false > LogWarning
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:102

◆ initEvent()

void GEMHitAssociator::initEvent ( const edm::Event e)
private

Definition at line 25 of file GEMHitAssociator.cc.

References _SimHitMap, GEMHitAssociator::Config::crossingframe, MillePedeFileConverter_cfg::e, GEMHitAssociator::Config::GEMdigisimlinkTag, GEMHitAssociator::Config::GEMdigisimlinkToken_, GEMHitAssociator::Config::GEMsimhitsTag, GEMHitAssociator::Config::GEMsimhitsToken_, GEMHitAssociator::Config::GEMsimhitsXFTag, GEMHitAssociator::Config::GEMsimhitsXFToken_, edm::InputTag::label(), LogTrace, theConfig, theDigiSimLinks, and GEMHitAssociator::Config::useGEMs_.

Referenced by GEMHitAssociator().

25  {
26  if (theConfig.useGEMs_) {
28  LogTrace("GEMHitAssociator") << "getting CrossingFrame<PSimHit> collection - " << theConfig.GEMsimhitsXFTag;
30 
31  std::unique_ptr<MixCollection<PSimHit>> GEMsimhits(new MixCollection<PSimHit>(&cf));
32  LogTrace("GEMHitAssociator") << "... size = " << GEMsimhits->size();
33 
34  // MixCollection<PSimHit> & simHits = *hits;
35 
36  for (MixCollection<PSimHit>::MixItr hitItr = GEMsimhits->begin(); hitItr != GEMsimhits->end(); ++hitItr) {
37  _SimHitMap[hitItr->detUnitId()].push_back(*hitItr);
38  }
39 
40  } else if (!theConfig.GEMsimhitsTag.label().empty()) {
41  LogTrace("GEMHitAssociator") << "getting PSimHit collection - " << theConfig.GEMsimhitsTag;
42  edm::PSimHitContainer const &GEMsimhits = e.get(theConfig.GEMsimhitsToken_);
43  LogTrace("GEMHitAssociator") << "... size = " << GEMsimhits.size();
44 
45  // arrange the hits by detUnit
46  for (edm::PSimHitContainer::const_iterator hitItr = GEMsimhits.begin(); hitItr != GEMsimhits.end(); ++hitItr) {
47  _SimHitMap[hitItr->detUnitId()].push_back(*hitItr);
48  }
49  }
50 
51  LogTrace("GEMHitAssociator") << "getting GEM Strip DigiSimLink collection - " << theConfig.GEMdigisimlinkTag;
53  }
54 }
edm::InputTag GEMdigisimlinkTag
std::map< unsigned int, edm::PSimHitContainer > _SimHitMap
std::string const & label() const
Definition: InputTag.h:36
#define LogTrace(id)
edm::EDGetTokenT< edm::DetSetVector< GEMDigiSimLink > > GEMdigisimlinkToken_
edm::EDGetTokenT< edm::PSimHitContainer > GEMsimhitsToken_
edm::EDGetTokenT< CrossingFrame< PSimHit > > GEMsimhitsXFToken_
const DigiSimLinks * theDigiSimLinks
const Config & theConfig
std::vector< PSimHit > PSimHitContainer

Member Data Documentation

◆ _SimHitMap

std::map<unsigned int, edm::PSimHitContainer> GEMHitAssociator::_SimHitMap
private

Definition at line 68 of file GEMHitAssociator.h.

Referenced by initEvent().

◆ theConfig

const Config& GEMHitAssociator::theConfig
private

Definition at line 66 of file GEMHitAssociator.h.

Referenced by associateRecHit(), and initEvent().

◆ theDigiSimLinks

const DigiSimLinks* GEMHitAssociator::theDigiSimLinks
private

Definition at line 67 of file GEMHitAssociator.h.

Referenced by associateRecHit(), and initEvent().