CMS 3D CMS Logo

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

#include <GEMHitAssociator.h>

Public Types

typedef edm::DetSetVector< StripDigiSimLinkDigiSimLinks
 
typedef edm::DetSet< StripDigiSimLinkLayerLinks
 
typedef std::pair< uint32_t, EncodedEventIdSimHitIdpr
 

Public Member Functions

std::vector< SimHitIdprassociateRecHit (const GEMRecHit *gemrechit) const
 
 GEMHitAssociator (const edm::ParameterSet &, edm::ConsumesCollector &&ic)
 
 GEMHitAssociator (const edm::Event &e, const edm::EventSetup &eventSetup, const edm::ParameterSet &conf)
 
void initEvent (const edm::Event &, const edm::EventSetup &)
 
 ~GEMHitAssociator ()
 

Private Attributes

std::map< unsigned int, edm::PSimHitContainer_SimHitMap
 
bool crossingframe
 
edm::InputTag GEMdigisimlinkTag
 
edm::EDGetTokenT< edm::DetSetVector< StripDigiSimLink > > GEMdigisimlinkToken_
 
edm::InputTag GEMsimhitsTag
 
edm::EDGetTokenT< edm::PSimHitContainerGEMsimhitsToken_
 
edm::InputTag GEMsimhitsXFTag
 
edm::EDGetTokenT< CrossingFrame< PSimHit > > GEMsimhitsXFToken_
 
const DigiSimLinkstheDigiSimLinks
 
bool useGEMs_
 

Detailed Description

Definition at line 33 of file GEMHitAssociator.h.

Member Typedef Documentation

Definition at line 35 of file GEMHitAssociator.h.

Definition at line 36 of file GEMHitAssociator.h.

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

Definition at line 37 of file GEMHitAssociator.h.

Constructor & Destructor Documentation

GEMHitAssociator::GEMHitAssociator ( const edm::ParameterSet conf,
edm::ConsumesCollector &&  ic 
)

Definition at line 6 of file GEMHitAssociator.cc.

References crossingframe, GEMdigisimlinkTag, GEMdigisimlinkToken_, GEMsimhitsTag, GEMsimhitsToken_, GEMsimhitsXFTag, GEMsimhitsXFToken_, and edm::InputTag::label().

7  : GEMdigisimlinkTag(conf.getParameter<edm::InputTag>("GEMdigisimlinkTag")),
8  // CrossingFrame used or not ?
9  crossingframe(conf.getParameter<bool>("crossingframe")),
10  useGEMs_(conf.getParameter<bool>("useGEMs")),
11  GEMsimhitsTag(conf.getParameter<edm::InputTag>("GEMsimhitsTag")),
12  GEMsimhitsXFTag(conf.getParameter<edm::InputTag>("GEMsimhitsXFTag")) {
13  if (crossingframe) {
15  } else if (!GEMsimhitsTag.label().empty()) {
17  }
18 
20 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::PSimHitContainer > GEMsimhitsToken_
edm::InputTag GEMsimhitsXFTag
edm::EDGetTokenT< CrossingFrame< PSimHit > > GEMsimhitsXFToken_
edm::InputTag GEMsimhitsTag
edm::EDGetTokenT< edm::DetSetVector< StripDigiSimLink > > GEMdigisimlinkToken_
edm::InputTag GEMdigisimlinkTag
std::string const & label() const
Definition: InputTag.h:36
std::vector< PSimHit > PSimHitContainer
GEMHitAssociator::GEMHitAssociator ( const edm::Event e,
const edm::EventSetup eventSetup,
const edm::ParameterSet conf 
)

Definition at line 22 of file GEMHitAssociator.cc.

References initEvent().

25  : GEMdigisimlinkTag(conf.getParameter<edm::InputTag>("GEMdigisimlinkTag")),
26  // CrossingFrame used or not ?
27  crossingframe(conf.getParameter<bool>("crossingframe")),
28  useGEMs_(conf.getParameter<bool>("useGEMs")),
29  GEMsimhitsTag(conf.getParameter<edm::InputTag>("GEMsimhitsTag")),
30  GEMsimhitsXFTag(conf.getParameter<edm::InputTag>("GEMsimhitsXFTag")) {
31  initEvent(e, eventSetup);
32 }
T getParameter(std::string const &) const
edm::InputTag GEMsimhitsXFTag
edm::InputTag GEMsimhitsTag
void initEvent(const edm::Event &, const edm::EventSetup &)
edm::InputTag GEMdigisimlinkTag
GEMHitAssociator::~GEMHitAssociator ( )
inline

Definition at line 46 of file GEMHitAssociator.h.

References associateRecHit().

46 {}

Member Function Documentation

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

Definition at line 70 of file GEMHitAssociator.cc.

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

Referenced by MuonAssociatorByHitsHelper::getMatchedIds(), and ~GEMHitAssociator().

70  {
71  std::vector<SimHitIdpr> matched;
72 
73  if (useGEMs_) {
74  if (gemrechit) {
75  GEMDetId gemDetId = gemrechit->gemId();
76  int fstrip = gemrechit->firstClusterStrip();
77  int cls = gemrechit->clusterSize();
78  // int bx = gemrechit->BunchX();
79 
80  DigiSimLinks::const_iterator layerLinks = theDigiSimLinks->find(gemDetId);
81 
82  if (layerLinks != theDigiSimLinks->end()) {
83  for (int i = fstrip; i < (fstrip + cls); ++i) {
84  for (LayerLinks::const_iterator itlink = layerLinks->begin(); itlink != layerLinks->end(); ++itlink) {
85  int ch = static_cast<int>(itlink->channel());
86  if (ch != i)
87  continue;
88 
89  SimHitIdpr currentId(itlink->SimTrackId(), itlink->eventId());
90  if (find(matched.begin(), matched.end(), currentId) == matched.end())
91  matched.push_back(currentId);
92  }
93  }
94 
95  } else
96  edm::LogWarning("GEMHitAssociator")
97  << "*** WARNING in GEMHitAssociator: GEM layer " << gemDetId << " has no DigiSimLinks !" << std::endl;
98 
99  } else
100  edm::LogWarning("GEMHitAssociator") << "*** WARNING in GEMHitAssociator::associateRecHit, null "
101  "dynamic_cast !";
102  }
103 
104  return matched;
105 }
int clusterSize() const
Definition: GEMRecHit.h:109
iterator find(det_id_type id)
Definition: DetSetVector.h:290
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:361
std::pair< uint32_t, EncodedEventId > SimHitIdpr
int firstClusterStrip() const
Definition: GEMRecHit.h:105
const DigiSimLinks * theDigiSimLinks
GEMDetId gemId() const
Return the gemId.
Definition: GEMRecHit.h:97
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:104
void GEMHitAssociator::initEvent ( const edm::Event e,
const edm::EventSetup eventSetup 
)

Definition at line 34 of file GEMHitAssociator.cc.

References _SimHitMap, crossingframe, TTClusterAssociation_cfi::digiSimLinks, GEMdigisimlinkTag, GEMsimhitsTag, GEMsimhitsXFTag, edm::Event::getByLabel(), edm::InputTag::label(), LogTrace, edm::Handle< T >::product(), theDigiSimLinks, and useGEMs_.

Referenced by GEMHitAssociator().

34  {
35  if (useGEMs_) {
36  if (crossingframe) {
38  LogTrace("GEMHitAssociator") << "getting CrossingFrame<PSimHit> collection - " << GEMsimhitsXFTag;
40 
41  std::unique_ptr<MixCollection<PSimHit>> GEMsimhits(new MixCollection<PSimHit>(cf.product()));
42  LogTrace("GEMHitAssociator") << "... size = " << GEMsimhits->size();
43 
44  // MixCollection<PSimHit> & simHits = *hits;
45 
46  for (MixCollection<PSimHit>::MixItr hitItr = GEMsimhits->begin(); hitItr != GEMsimhits->end(); ++hitItr) {
47  _SimHitMap[hitItr->detUnitId()].push_back(*hitItr);
48  }
49 
50  } else if (!GEMsimhitsTag.label().empty()) {
52  LogTrace("GEMHitAssociator") << "getting PSimHit collection - " << GEMsimhitsTag;
53  e.getByLabel(GEMsimhitsTag, GEMsimhits);
54  LogTrace("GEMHitAssociator") << "... size = " << GEMsimhits->size();
55 
56  // arrange the hits by detUnit
57  for (edm::PSimHitContainer::const_iterator hitItr = GEMsimhits->begin(); hitItr != GEMsimhits->end(); ++hitItr) {
58  _SimHitMap[hitItr->detUnitId()].push_back(*hitItr);
59  }
60  }
61 
63  LogTrace("GEMHitAssociator") << "getting GEM Strip DigiSimLink collection - " << GEMdigisimlinkTag;
64  e.getByLabel(GEMdigisimlinkTag, digiSimLinks);
65  theDigiSimLinks = digiSimLinks.product();
66  }
67 }
edm::InputTag GEMsimhitsXFTag
std::map< unsigned int, edm::PSimHitContainer > _SimHitMap
edm::InputTag GEMsimhitsTag
edm::InputTag GEMdigisimlinkTag
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
#define LogTrace(id)
T const * product() const
Definition: Handle.h:74
const DigiSimLinks * theDigiSimLinks
std::string const & label() const
Definition: InputTag.h:36

Member Data Documentation

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

Definition at line 63 of file GEMHitAssociator.h.

Referenced by initEvent().

bool GEMHitAssociator::crossingframe
private

Definition at line 54 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator(), and initEvent().

edm::InputTag GEMHitAssociator::GEMdigisimlinkTag
private

Definition at line 52 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator(), and initEvent().

edm::EDGetTokenT<edm::DetSetVector<StripDigiSimLink> > GEMHitAssociator::GEMdigisimlinkToken_
private

Definition at line 61 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator().

edm::InputTag GEMHitAssociator::GEMsimhitsTag
private

Definition at line 56 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator(), and initEvent().

edm::EDGetTokenT<edm::PSimHitContainer> GEMHitAssociator::GEMsimhitsToken_
private

Definition at line 60 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator().

edm::InputTag GEMHitAssociator::GEMsimhitsXFTag
private

Definition at line 57 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator(), and initEvent().

edm::EDGetTokenT<CrossingFrame<PSimHit> > GEMHitAssociator::GEMsimhitsXFToken_
private

Definition at line 59 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator().

const DigiSimLinks* GEMHitAssociator::theDigiSimLinks
private

Definition at line 51 of file GEMHitAssociator.h.

Referenced by associateRecHit(), and initEvent().

bool GEMHitAssociator::useGEMs_
private

Definition at line 55 of file GEMHitAssociator.h.

Referenced by associateRecHit(), and initEvent().