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 37 of file GEMHitAssociator.h.

Definition at line 38 of file GEMHitAssociator.h.

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

Definition at line 39 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  :
8  GEMdigisimlinkTag(conf.getParameter<edm::InputTag>("GEMdigisimlinkTag")),
9  // CrossingFrame used or not ?
10  crossingframe(conf.getParameter<bool>("crossingframe")),
11  useGEMs_(conf.getParameter<bool>("useGEMs")),
12  GEMsimhitsTag(conf.getParameter<edm::InputTag>("GEMsimhitsTag")),
13  GEMsimhitsXFTag(conf.getParameter<edm::InputTag>("GEMsimhitsXFTag"))
14 {
15  if (crossingframe){
17  } else if (!GEMsimhitsTag.label().empty()) {
19  }
20 
22 }
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 24 of file GEMHitAssociator.cc.

References initEvent().

24  :
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 {
32  initEvent(e,eventSetup);
33 }
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 48 of file GEMHitAssociator.h.

References associateRecHit().

48 {}

Member Function Documentation

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

Definition at line 82 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().

82  {
83 
84  std::vector<SimHitIdpr> matched;
85 
86  if(useGEMs_){
87  if (gemrechit) {
88 
89  GEMDetId gemDetId = gemrechit->gemId();
90  int fstrip = gemrechit->firstClusterStrip();
91  int cls = gemrechit->clusterSize();
92  //int bx = gemrechit->BunchX();
93 
94  DigiSimLinks::const_iterator layerLinks = theDigiSimLinks->find(gemDetId);
95 
96  if (layerLinks != theDigiSimLinks->end()) {
97 
98  for(int i = fstrip; i < (fstrip+cls); ++i) {
99 
100  for(LayerLinks::const_iterator itlink = layerLinks->begin(); itlink != layerLinks->end(); ++itlink) {
101 
102  int ch = static_cast<int>(itlink->channel());
103  if(ch != i) continue;
104 
105  SimHitIdpr currentId(itlink->SimTrackId(), itlink->eventId());
106  if(find(matched.begin(),matched.end(),currentId ) == matched.end())
107  matched.push_back(currentId);
108 
109  }
110 
111  }
112 
113  }else edm::LogWarning("GEMHitAssociator")
114  <<"*** WARNING in GEMHitAssociator: GEM layer "<<gemDetId<<" has no DigiSimLinks !"<<std::endl;
115 
116  } else edm::LogWarning("GEMHitAssociator")<<"*** WARNING in GEMHitAssociator::associateRecHit, null dynamic_cast !";
117 
118  }
119 
120  return matched;
121 
122 }
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 35 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().

36 {
37 
38  if(useGEMs_){
39 
40  if (crossingframe) {
41 
43  LogTrace("GEMHitAssociator") <<"getting CrossingFrame<PSimHit> collection - "<<GEMsimhitsXFTag;
45 
46  std::unique_ptr<MixCollection<PSimHit> >
47  GEMsimhits( new MixCollection<PSimHit>(cf.product()) );
48  LogTrace("GEMHitAssociator") <<"... size = "<<GEMsimhits->size();
49 
50  // MixCollection<PSimHit> & simHits = *hits;
51 
52  for(MixCollection<PSimHit>::MixItr hitItr = GEMsimhits->begin();
53  hitItr != GEMsimhits->end(); ++hitItr)
54  {
55  _SimHitMap[hitItr->detUnitId()].push_back(*hitItr);
56  }
57 
58  } else if (!GEMsimhitsTag.label().empty()) {
60  LogTrace("GEMHitAssociator") <<"getting PSimHit collection - "<<GEMsimhitsTag;
61  e.getByLabel(GEMsimhitsTag, GEMsimhits);
62  LogTrace("GEMHitAssociator") <<"... size = "<<GEMsimhits->size();
63 
64  // arrange the hits by detUnit
65  for(edm::PSimHitContainer::const_iterator hitItr = GEMsimhits->begin();
66  hitItr != GEMsimhits->end(); ++hitItr)
67  {
68  _SimHitMap[hitItr->detUnitId()].push_back(*hitItr);
69  }
70  }
71 
73  LogTrace("GEMHitAssociator") <<"getting GEM Strip DigiSimLink collection - "<<GEMdigisimlinkTag;
74  e.getByLabel(GEMdigisimlinkTag, digiSimLinks);
75  theDigiSimLinks = digiSimLinks.product();
76 
77  }
78 
79 }
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:535
#define LogTrace(id)
T const * product() const
Definition: Handle.h:81
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 66 of file GEMHitAssociator.h.

Referenced by initEvent().

bool GEMHitAssociator::crossingframe
private

Definition at line 57 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator(), and initEvent().

edm::InputTag GEMHitAssociator::GEMdigisimlinkTag
private

Definition at line 55 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator(), and initEvent().

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

Definition at line 64 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator().

edm::InputTag GEMHitAssociator::GEMsimhitsTag
private

Definition at line 59 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator(), and initEvent().

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

Definition at line 63 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator().

edm::InputTag GEMHitAssociator::GEMsimhitsXFTag
private

Definition at line 60 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator(), and initEvent().

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

Definition at line 62 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator().

const DigiSimLinks* GEMHitAssociator::theDigiSimLinks
private

Definition at line 54 of file GEMHitAssociator.h.

Referenced by associateRecHit(), and initEvent().

bool GEMHitAssociator::useGEMs_
private

Definition at line 58 of file GEMHitAssociator.h.

Referenced by associateRecHit(), and initEvent().