CMS 3D CMS Logo

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

#include <CSCHitAssociator.h>

Classes

class  Config
 

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 Config &)
 

Private Member Functions

void initEvent (const edm::Event &, const edm::EventSetup &)
 

Private Attributes

const CSCGeometrycscgeom
 
const ConfigtheConfig
 
const DigiSimLinkstheDigiSimLinks
 

Detailed Description

Definition at line 26 of file CSCHitAssociator.h.

Member Typedef Documentation

◆ DigiSimLinks

Definition at line 28 of file CSCHitAssociator.h.

◆ LayerLinks

Definition at line 30 of file CSCHitAssociator.h.

◆ SimHitIdpr

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

Definition at line 31 of file CSCHitAssociator.h.

◆ WireDigiSimLinks

Definition at line 29 of file CSCHitAssociator.h.

Constructor & Destructor Documentation

◆ CSCHitAssociator()

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

Definition at line 13 of file CSCHitAssociator.cc.

References initEvent(), and singleTopDQM_cfi::setup.

14  : theConfig(conf), theDigiSimLinks(nullptr) {
16 }
const Config & theConfig
const DigiSimLinks * theDigiSimLinks
void initEvent(const edm::Event &, const edm::EventSetup &)
Definition: event.py:1

Member Function Documentation

◆ associateCSCHitId()

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

Definition at line 26 of file CSCHitAssociator.cc.

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

Referenced by MuonAssociatorByHitsHelper::getMatchedIds().

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

◆ associateHitId()

std::vector< CSCHitAssociator::SimHitIdpr > CSCHitAssociator::associateHitId ( const TrackingRecHit hit) const

Definition at line 58 of file CSCHitAssociator.cc.

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

58  {
59  std::vector<SimHitIdpr> simtrackids;
60 
61  const TrackingRecHit *hitp = &hit;
62  const CSCRecHit2D *cscrechit = dynamic_cast<const CSCRecHit2D *>(hitp);
63 
64  if (cscrechit) {
65  unsigned int detId = cscrechit->geographicalId().rawId();
66  int nchannels = cscrechit->nStrips();
67  const CSCLayerGeometry *laygeom = cscgeom->layer(cscrechit->cscDetId())->geometry();
68 
70 
71  if (layerLinks != theDigiSimLinks->end()) {
72  for (int idigi = 0; idigi < nchannels; ++idigi) {
73  // strip and readout channel numbers may differ in ME1/1A
74  int istrip = cscrechit->channels(idigi);
75  int channel = laygeom->channel(istrip);
76 
77  for (LayerLinks::const_iterator link = layerLinks->begin(); link != layerLinks->end(); ++link) {
78  int ch = static_cast<int>(link->channel());
79  if (ch == channel) {
80  SimHitIdpr currentId(link->SimTrackId(), link->eventId());
81  if (find(simtrackids.begin(), simtrackids.end(), currentId) == simtrackids.end())
82  simtrackids.push_back(currentId);
83  }
84  }
85  }
86 
87  } else
88  LogTrace("CSCHitAssociator") << "*** WARNING in CSCHitAssociator::associateHitId - CSC layer " << detId
89  << " has no DigiSimLinks !" << std::endl;
90 
91  } else
92  LogTrace("CSCHitAssociator") << "*** WARNING in CSCHitAssociator::associateHitId, null dynamic_cast "
93  "!";
94 
95  return simtrackids;
96 }
unsigned int nStrips() const
Definition: CSCRecHit2D.h:62
iterator find(det_id_type id)
Definition: DetSetVector.h:255
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:58
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
int channel(int strip) const
#define LogTrace(id)
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:316
std::pair< uint32_t, EncodedEventId > SimHitIdpr
DetId geographicalId() const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const DigiSimLinks * theDigiSimLinks
const CSCGeometry * cscgeom
int channels(unsigned int i) const
Extracting strip channel numbers comprising the rechit - low.
Definition: CSCRecHit2D.h:61
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:102
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:105

◆ initEvent()

void CSCHitAssociator::initEvent ( const edm::Event event,
const edm::EventSetup setup 
)
private

Definition at line 18 of file CSCHitAssociator.cc.

References cscgeom, CSCHitAssociator::Config::geomToken_, CSCHitAssociator::Config::linksTag_, CSCHitAssociator::Config::linksToken_, LogTrace, singleTopDQM_cfi::setup, theConfig, and theDigiSimLinks.

Referenced by CSCHitAssociator().

18  {
19  LogTrace("CSCHitAssociator") << "getting CSC Strip DigiSimLink collection - " << theConfig.linksTag_;
21 
22  // get CSC Geometry to use CSCLayer methods
23  cscgeom = &setup.getData(theConfig.geomToken_);
24 }
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > geomToken_
const edm::EDGetTokenT< DigiSimLinks > linksToken_
const edm::InputTag linksTag_
#define LogTrace(id)
const Config & theConfig
const DigiSimLinks * theDigiSimLinks
const CSCGeometry * cscgeom

Member Data Documentation

◆ cscgeom

const CSCGeometry* CSCHitAssociator::cscgeom
private

Definition at line 55 of file CSCHitAssociator.h.

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

◆ theConfig

const Config& CSCHitAssociator::theConfig
private

Definition at line 52 of file CSCHitAssociator.h.

Referenced by initEvent().

◆ theDigiSimLinks

const DigiSimLinks* CSCHitAssociator::theDigiSimLinks
private

Definition at line 53 of file CSCHitAssociator.h.

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