CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
GEMHitAssociator Class Reference

#include <GEMHitAssociator.h>

Public Types

typedef edm::DetSetVector
< StripDigiSimLink
DigiSimLinks
 
typedef edm::DetSet
< StripDigiSimLink
LayerLinks
 
typedef std::pair< uint32_t,
EncodedEventId
SimHitIdpr
 

Public Member Functions

std::vector< SimHitIdprassociateRecHit (const TrackingRecHit &hit) 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::PSimHitContainer
GEMsimhitsToken_
 
edm::InputTag GEMsimhitsXFTag
 
edm::EDGetTokenT
< CrossingFrame< PSimHit > > 
GEMsimhitsXFToken_
 
const DigiSimLinkstheDigiSimLinks
 
bool useGEMs_
 

Detailed Description

Definition at line 32 of file GEMHitAssociator.h.

Member Typedef Documentation

Definition at line 36 of file GEMHitAssociator.h.

Definition at line 37 of file GEMHitAssociator.h.

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

Definition at line 38 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 47 of file GEMHitAssociator.h.

47 {}

Member Function Documentation

std::vector< GEMHitAssociator::SimHitIdpr > GEMHitAssociator::associateRecHit ( const TrackingRecHit hit) 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(), i, theDigiSimLinks, and useGEMs_.

Referenced by MuonAssociatorByHitsHelper::getMatchedIds().

82  {
83 
84  std::vector<SimHitIdpr> matched;
85 
86  if(useGEMs_){
87 
88  //std::cout<<"gemboo "<<useGEMs_<<std::endl;
89 
90  const TrackingRecHit * hitp = &hit;
91  const GEMRecHit * gemrechit = dynamic_cast<const GEMRecHit *>(hitp);
92 
93  if (gemrechit) {
94 
95  GEMDetId gemDetId = gemrechit->gemId();
96  int fstrip = gemrechit->firstClusterStrip();
97  int cls = gemrechit->clusterSize();
98  //int bx = gemrechit->BunchX();
99 
100  DigiSimLinks::const_iterator layerLinks = theDigiSimLinks->find(gemDetId);
101 
102  if (layerLinks != theDigiSimLinks->end()) {
103 
104  for(int i = fstrip; i < (fstrip+cls); ++i) {
105 
106  for(LayerLinks::const_iterator itlink = layerLinks->begin(); itlink != layerLinks->end(); ++itlink) {
107 
108  int ch = static_cast<int>(itlink->channel());
109  if(ch != i) continue;
110 
111  SimHitIdpr currentId(itlink->SimTrackId(), itlink->eventId());
112  if(find(matched.begin(),matched.end(),currentId ) == matched.end())
113  matched.push_back(currentId);
114 
115  }
116 
117  }
118 
119  }else edm::LogWarning("GEMHitAssociator")
120  <<"*** WARNING in GEMHitAssociator: GEM layer "<<gemDetId<<" has no DigiSimLinks !"<<std::endl;
121 
122  } else edm::LogWarning("GEMHitAssociator")<<"*** WARNING in GEMHitAssociator::associateRecHit, null dynamic_cast !";
123 
124  }
125 
126  return matched;
127 
128 }
int i
Definition: DBlmapReader.cc:9
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:7
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, 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::auto_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 
72  edm::Handle<DigiSimLinks> digiSimLinks;
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:418
#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 65 of file GEMHitAssociator.h.

Referenced by initEvent().

bool GEMHitAssociator::crossingframe
private

Definition at line 56 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator(), and initEvent().

edm::InputTag GEMHitAssociator::GEMdigisimlinkTag
private

Definition at line 54 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator(), and initEvent().

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

Definition at line 63 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator().

edm::InputTag GEMHitAssociator::GEMsimhitsTag
private

Definition at line 58 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator(), and initEvent().

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

Definition at line 62 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator().

edm::InputTag GEMHitAssociator::GEMsimhitsXFTag
private

Definition at line 59 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator(), and initEvent().

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

Definition at line 61 of file GEMHitAssociator.h.

Referenced by GEMHitAssociator().

const DigiSimLinks* GEMHitAssociator::theDigiSimLinks
private

Definition at line 53 of file GEMHitAssociator.h.

Referenced by associateRecHit(), and initEvent().

bool GEMHitAssociator::useGEMs_
private

Definition at line 57 of file GEMHitAssociator.h.

Referenced by associateRecHit(), and initEvent().