CMS 3D CMS Logo

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

#include <CSCHitAssociator.h>

Public Types

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

Public Member Functions

std::vector< SimHitIdprassociateCSCHitId (const CSCRecHit2D *) const
 
std::vector< SimHitIdprassociateHitId (const TrackingRecHit &) const
 
 CSCHitAssociator (const edm::Event &, const edm::EventSetup &, const edm::ParameterSet &)
 
 CSCHitAssociator (const edm::ParameterSet &, edm::ConsumesCollector &&iC)
 
void initEvent (const edm::Event &, const edm::EventSetup &)
 

Private Attributes

const CSCGeometrycscgeom
 
edm::InputTag linksTag
 
const DigiSimLinkstheDigiSimLinks
 

Detailed Description

Definition at line 24 of file CSCHitAssociator.h.

Member Typedef Documentation

Definition at line 27 of file CSCHitAssociator.h.

Definition at line 29 of file CSCHitAssociator.h.

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

Definition at line 30 of file CSCHitAssociator.h.

Definition at line 28 of file CSCHitAssociator.h.

Constructor & Destructor Documentation

CSCHitAssociator::CSCHitAssociator ( const edm::Event event,
const edm::EventSetup setup,
const edm::ParameterSet conf 
)

Definition at line 8 of file CSCHitAssociator.cc.

References initEvent().

8  :
9  theDigiSimLinks(nullptr),
10  linksTag(conf.getParameter<edm::InputTag>("CSClinksTag"))
11 {
12  initEvent(event,setup);
13 }
T getParameter(std::string const &) const
edm::InputTag linksTag
const DigiSimLinks * theDigiSimLinks
void initEvent(const edm::Event &, const edm::EventSetup &)
CSCHitAssociator::CSCHitAssociator ( const edm::ParameterSet conf,
edm::ConsumesCollector &&  iC 
)

Definition at line 15 of file CSCHitAssociator.cc.

References linksTag.

15  :
16  theDigiSimLinks(nullptr),
17  linksTag(conf.getParameter<edm::InputTag>("CSClinksTag"))
18 {
20 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::InputTag linksTag
edm::DetSetVector< StripDigiSimLink > DigiSimLinks
const DigiSimLinks * theDigiSimLinks

Member Function Documentation

std::vector< CSCHitAssociator::SimHitIdpr > CSCHitAssociator::associateCSCHitId ( const CSCRecHit2D cscrechit) const

Definition at line 35 of file CSCHitAssociator.cc.

References CSCLayerGeometry::channel(), CSCRecHit2D::channels(), CSCRecHit2D::cscDetId(), cscgeom, edm::DetSetVector< T >::end(), spr::find(), edm::DetSetVector< T >::find(), TrackingRecHit::geographicalId(), geometry, CSCGeometry::layer(), LogTrace, CSCRecHit2D::nStrips(), DetId::rawId(), and theDigiSimLinks.

Referenced by MuonAssociatorByHitsHelper::getMatchedIds().

35  {
36  std::vector<SimHitIdpr> simtrackids;
37 
38  unsigned int detId = cscrechit->geographicalId().rawId();
39  int nchannels = cscrechit->nStrips();
40  const CSCLayerGeometry * laygeom = cscgeom->layer(cscrechit->cscDetId())->geometry();
41 
43 
44  if (layerLinks != theDigiSimLinks->end()) {
45 
46  for(int idigi = 0; idigi < nchannels; ++idigi) {
47  // strip and readout channel numbers may differ in ME1/1A
48  int istrip = cscrechit->channels(idigi);
49  int channel = laygeom->channel(istrip);
50 
51  for (LayerLinks::const_iterator link=layerLinks->begin(); link!=layerLinks->end(); ++link) {
52  int ch = static_cast<int>(link->channel());
53  if (ch == channel) {
54  SimHitIdpr currentId(link->SimTrackId(), link->eventId());
55  if (find(simtrackids.begin(), simtrackids.end(), currentId) == simtrackids.end())
56  simtrackids.push_back(currentId);
57  }
58  }
59  }
60 
61  } else LogTrace("CSCHitAssociator")
62  <<"*** WARNING in CSCHitAssociator::associateCSCHitId - CSC layer "<<detId<<" has no DigiSimLinks !"<<std::endl;
63 
64  return simtrackids;
65 }
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:52
iterator find(det_id_type id)
Definition: DetSetVector.h:290
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
int channels(unsigned int i) const
Extracting strip channel numbers comprising the rechit - low.
Definition: CSCRecHit2D.h:55
unsigned int nStrips() const
Definition: CSCRecHit2D.h:56
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:361
#define LogTrace(id)
int channel(int strip) const
std::pair< uint32_t, EncodedEventId > SimHitIdpr
const DigiSimLinks * theDigiSimLinks
ESHandle< TrackerGeometry > geometry
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:139
const CSCGeometry * cscgeom
DetId geographicalId() const
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:104
std::vector< CSCHitAssociator::SimHitIdpr > CSCHitAssociator::associateHitId ( const TrackingRecHit hit) const

Definition at line 68 of file CSCHitAssociator.cc.

References CSCLayerGeometry::channel(), CSCRecHit2D::channels(), CSCRecHit2D::cscDetId(), cscgeom, edm::DetSetVector< T >::end(), spr::find(), edm::DetSetVector< T >::find(), TrackingRecHit::geographicalId(), geometry, CSCGeometry::layer(), LogTrace, CSCRecHit2D::nStrips(), DetId::rawId(), and theDigiSimLinks.

69 {
70  std::vector<SimHitIdpr> simtrackids;
71 
72  const TrackingRecHit * hitp = &hit;
73  const CSCRecHit2D * cscrechit = dynamic_cast<const CSCRecHit2D *>(hitp);
74 
75  if (cscrechit) {
76 
77  unsigned int detId = cscrechit->geographicalId().rawId();
78  int nchannels = cscrechit->nStrips();
79  const CSCLayerGeometry * laygeom = cscgeom->layer(cscrechit->cscDetId())->geometry();
80 
82 
83  if (layerLinks != theDigiSimLinks->end()) {
84 
85  for(int idigi = 0; idigi < nchannels; ++idigi) {
86  // strip and readout channel numbers may differ in ME1/1A
87  int istrip = cscrechit->channels(idigi);
88  int channel = laygeom->channel(istrip);
89 
90  for (LayerLinks::const_iterator link=layerLinks->begin(); link!=layerLinks->end(); ++link) {
91  int ch = static_cast<int>(link->channel());
92  if (ch == channel) {
93  SimHitIdpr currentId(link->SimTrackId(), link->eventId());
94  if (find(simtrackids.begin(), simtrackids.end(), currentId) == simtrackids.end())
95  simtrackids.push_back(currentId);
96  }
97  }
98  }
99 
100  } else LogTrace("CSCHitAssociator")
101  <<"*** WARNING in CSCHitAssociator::associateHitId - CSC layer "<<detId<<" has no DigiSimLinks !"<<std::endl;
102 
103  } else LogTrace("CSCHitAssociator")<<"*** WARNING in CSCHitAssociator::associateHitId, null dynamic_cast !";
104 
105  return simtrackids;
106 }
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:52
iterator find(det_id_type id)
Definition: DetSetVector.h:290
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
int channels(unsigned int i) const
Extracting strip channel numbers comprising the rechit - low.
Definition: CSCRecHit2D.h:55
unsigned int nStrips() const
Definition: CSCRecHit2D.h:56
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:361
#define LogTrace(id)
int channel(int strip) const
std::pair< uint32_t, EncodedEventId > SimHitIdpr
const DigiSimLinks * theDigiSimLinks
ESHandle< TrackerGeometry > geometry
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:139
const CSCGeometry * cscgeom
DetId geographicalId() const
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:104
void CSCHitAssociator::initEvent ( const edm::Event event,
const edm::EventSetup setup 
)

Definition at line 22 of file CSCHitAssociator.cc.

References cscgeom, TTClusterAssociation_cfi::digiSimLinks, edm::EventSetup::get(), linksTag, LogTrace, edm::Handle< T >::product(), and theDigiSimLinks.

Referenced by CSCHitAssociator().

22  {
23 
25  LogTrace("CSCHitAssociator") <<"getting CSC Strip DigiSimLink collection - "<<linksTag;
26  event.getByLabel(linksTag, digiSimLinks);
27  theDigiSimLinks = digiSimLinks.product();
28 
29  // get CSC Geometry to use CSCLayer methods
31  setup.get<MuonGeometryRecord>().get( mugeom );
32  cscgeom = &*mugeom;
33 }
edm::InputTag linksTag
#define LogTrace(id)
T const * product() const
Definition: Handle.h:81
const DigiSimLinks * theDigiSimLinks
T get() const
Definition: EventSetup.h:62
const CSCGeometry * cscgeom

Member Data Documentation

const CSCGeometry* CSCHitAssociator::cscgeom
private

Definition at line 47 of file CSCHitAssociator.h.

Referenced by associateCSCHitId(), associateHitId(), and initEvent().

edm::InputTag CSCHitAssociator::linksTag
private

Definition at line 45 of file CSCHitAssociator.h.

Referenced by CSCHitAssociator(), and initEvent().

const DigiSimLinks* CSCHitAssociator::theDigiSimLinks
private

Definition at line 43 of file CSCHitAssociator.h.

Referenced by associateCSCHitId(), associateHitId(), and initEvent().