CMS 3D CMS Logo

CSCHitAssociator.cc
Go to the documentation of this file.
7 
9  : theDigiSimLinks(nullptr), linksTag(conf.getParameter<edm::InputTag>("CSClinksTag")) {
11 }
12 
14  : theDigiSimLinks(nullptr), linksTag(conf.getParameter<edm::InputTag>("CSClinksTag")) {
15  iC.consumes<DigiSimLinks>(linksTag);
16 }
17 
20  LogTrace("CSCHitAssociator") << "getting CSC Strip DigiSimLink collection - " << linksTag;
21  event.getByLabel(linksTag, digiSimLinks);
22  theDigiSimLinks = digiSimLinks.product();
23 
24  // get CSC Geometry to use CSCLayer methods
26  setup.get<MuonGeometryRecord>().get(mugeom);
27  cscgeom = &*mugeom;
28 }
29 
30 std::vector<CSCHitAssociator::SimHitIdpr> CSCHitAssociator::associateCSCHitId(const CSCRecHit2D *cscrechit) const {
31  std::vector<SimHitIdpr> simtrackids;
32 
33  unsigned int detId = cscrechit->geographicalId().rawId();
34  int nchannels = cscrechit->nStrips();
35  const CSCLayerGeometry *laygeom = cscgeom->layer(cscrechit->cscDetId())->geometry();
36 
38 
39  if (layerLinks != theDigiSimLinks->end()) {
40  for (int idigi = 0; idigi < nchannels; ++idigi) {
41  // strip and readout channel numbers may differ in ME1/1A
42  int istrip = cscrechit->channels(idigi);
43  int channel = laygeom->channel(istrip);
44 
45  for (LayerLinks::const_iterator link = layerLinks->begin(); link != layerLinks->end(); ++link) {
46  int ch = static_cast<int>(link->channel());
47  if (ch == channel) {
48  SimHitIdpr currentId(link->SimTrackId(), link->eventId());
49  if (find(simtrackids.begin(), simtrackids.end(), currentId) == simtrackids.end())
50  simtrackids.push_back(currentId);
51  }
52  }
53  }
54 
55  } else
56  LogTrace("CSCHitAssociator") << "*** WARNING in CSCHitAssociator::associateCSCHitId - CSC layer " << detId
57  << " has no DigiSimLinks !" << std::endl;
58 
59  return simtrackids;
60 }
61 
62 std::vector<CSCHitAssociator::SimHitIdpr> CSCHitAssociator::associateHitId(const TrackingRecHit &hit) const {
63  std::vector<SimHitIdpr> simtrackids;
64 
65  const TrackingRecHit *hitp = &hit;
66  const CSCRecHit2D *cscrechit = dynamic_cast<const CSCRecHit2D *>(hitp);
67 
68  if (cscrechit) {
69  unsigned int detId = cscrechit->geographicalId().rawId();
70  int nchannels = cscrechit->nStrips();
71  const CSCLayerGeometry *laygeom = cscgeom->layer(cscrechit->cscDetId())->geometry();
72 
74 
75  if (layerLinks != theDigiSimLinks->end()) {
76  for (int idigi = 0; idigi < nchannels; ++idigi) {
77  // strip and readout channel numbers may differ in ME1/1A
78  int istrip = cscrechit->channels(idigi);
79  int channel = laygeom->channel(istrip);
80 
81  for (LayerLinks::const_iterator link = layerLinks->begin(); link != layerLinks->end(); ++link) {
82  int ch = static_cast<int>(link->channel());
83  if (ch == channel) {
84  SimHitIdpr currentId(link->SimTrackId(), link->eventId());
85  if (find(simtrackids.begin(), simtrackids.end(), currentId) == simtrackids.end())
86  simtrackids.push_back(currentId);
87  }
88  }
89  }
90 
91  } else
92  LogTrace("CSCHitAssociator") << "*** WARNING in CSCHitAssociator::associateHitId - CSC layer " << detId
93  << " has no DigiSimLinks !" << std::endl;
94 
95  } else
96  LogTrace("CSCHitAssociator") << "*** WARNING in CSCHitAssociator::associateHitId, null dynamic_cast "
97  "!";
98 
99  return simtrackids;
100 }
edm::DetSetVector
Definition: DetSetVector.h:61
CSCHitAssociator.h
MessageLogger.h
CSCHitAssociator::associateCSCHitId
std::vector< SimHitIdpr > associateCSCHitId(const CSCRecHit2D *) const
Definition: CSCHitAssociator.cc:30
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
ESHandle.h
edm::DetSetVector::end
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:325
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
relativeConstraints.geometry
geometry
Definition: relativeConstraints.py:39
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
CSCHitAssociator::SimHitIdpr
std::pair< uint32_t, EncodedEventId > SimHitIdpr
Definition: CSCHitAssociator.h:29
edm::Handle
Definition: AssociativeIterator.h:50
TrackingRecHit::geographicalId
DetId geographicalId() const
Definition: TrackingRecHit.h:120
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
CSCRecHit2D::cscDetId
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:58
TTClusterAssociation_cfi.digiSimLinks
digiSimLinks
Definition: TTClusterAssociation_cfi.py:8
CSCHitAssociator::theDigiSimLinks
const DigiSimLinks * theDigiSimLinks
Definition: CSCHitAssociator.h:40
CSCLayerGeometry
Definition: CSCLayerGeometry.h:25
edm::ESHandle< CSCGeometry >
CSCHitAssociator::cscgeom
const CSCGeometry * cscgeom
Definition: CSCHitAssociator.h:44
CSCHitAssociator::initEvent
void initEvent(const edm::Event &, const edm::EventSetup &)
Definition: CSCHitAssociator.cc:18
edm::ParameterSet
Definition: ParameterSet.h:47
CSCRecHit2D
Definition: CSCRecHit2D.h:18
edm::DetSetVector::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:102
edm::DetSetVector::find
iterator find(det_id_type id)
Definition: DetSetVector.h:264
edm::EventSetup
Definition: EventSetup.h:58
DetSetVector.h
CSCHitAssociator::linksTag
edm::InputTag linksTag
Definition: CSCHitAssociator.h:42
get
#define get
CSCHitAssociator::associateHitId
std::vector< SimHitIdpr > associateHitId(const TrackingRecHit &) const
Definition: CSCHitAssociator.cc:62
TrackingRecHit
Definition: TrackingRecHit.h:21
CSCRecHit2D::channels
int channels(unsigned int i) const
Extracting strip channel numbers comprising the rechit - low.
Definition: CSCRecHit2D.h:61
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
CSCGeometry::layer
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:105
CSCLayerGeometry::channel
int channel(int strip) const
Definition: CSCLayerGeometry.h:112
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
CSCRecHit2D::nStrips
unsigned int nStrips() const
Definition: CSCRecHit2D.h:62
MuonGeometryRecord.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
CSCHitAssociator::CSCHitAssociator
CSCHitAssociator(const edm::Event &, const edm::EventSetup &, const edm::ParameterSet &)
Definition: CSCHitAssociator.cc:8
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
hit
Definition: SiStripHitEffFromCalibTree.cc:88
edm::DetSet< StripDigiSimLink >::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSet.h:31