CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
< GEMDigiSimLink
DigiSimLinks
 
typedef edm::DetSet
< GEMDigiSimLink
LayerLinks
 
typedef std::pair< uint32_t,
EncodedEventId
SimHitIdpr
 

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

Definition at line 54 of file GEMHitAssociator.h.

Definition at line 55 of file GEMHitAssociator.h.

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

Definition at line 56 of file GEMHitAssociator.h.

Constructor & Destructor Documentation

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

Definition at line 23 of file GEMHitAssociator.cc.

References initEvent().

23 : theConfig(config) { initEvent(e); }
void initEvent(const edm::Event &)
tuple config
parse the configuration file
const Config & theConfig

Member Function Documentation

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, 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 }
int clusterSize() const
Definition: GEMRecHit.h:71
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
int firstClusterStrip() const
Definition: GEMRecHit.h:69
const DigiSimLinks * theDigiSimLinks
const Config & theConfig
GEMDetId gemId() const
Return the gemId.
Definition: GEMRecHit.h:65
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
void GEMHitAssociator::initEvent ( const edm::Event e)
private

Definition at line 25 of file GEMHitAssociator.cc.

References _SimHitMap, GEMHitAssociator::Config::crossingframe, GEMHitAssociator::Config::GEMdigisimlinkTag, GEMHitAssociator::Config::GEMdigisimlinkToken_, GEMHitAssociator::Config::GEMsimhitsTag, GEMHitAssociator::Config::GEMsimhitsToken_, GEMHitAssociator::Config::GEMsimhitsXFTag, GEMHitAssociator::Config::GEMsimhitsXFToken_, edm::Event::get(), 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
#define LogTrace(id)
edm::EDGetTokenT< edm::DetSetVector< GEMDigiSimLink > > GEMdigisimlinkToken_
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
edm::EDGetTokenT< edm::PSimHitContainer > GEMsimhitsToken_
edm::EDGetTokenT< CrossingFrame< PSimHit > > GEMsimhitsXFToken_
const DigiSimLinks * theDigiSimLinks
std::string const & label() const
Definition: InputTag.h:36
const Config & theConfig
std::vector< PSimHit > PSimHitContainer

Member Data Documentation

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

Definition at line 68 of file GEMHitAssociator.h.

Referenced by initEvent().

const Config& GEMHitAssociator::theConfig
private

Definition at line 66 of file GEMHitAssociator.h.

Referenced by associateRecHit(), and initEvent().

const DigiSimLinks* GEMHitAssociator::theDigiSimLinks
private

Definition at line 67 of file GEMHitAssociator.h.

Referenced by associateRecHit(), and initEvent().