CMS 3D CMS Logo

CSCHitAssociator.cc
Go to the documentation of this file.
7 
9  : linksTag_(conf.getParameter<edm::InputTag>("CSClinksTag")),
10  linksToken_(iC.consumes(linksTag_)),
11  geomToken_(iC.esConsumes()) {}
12 
14  : theConfig(conf), theDigiSimLinks(nullptr) {
16 }
17 
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 }
25 
26 std::vector<CSCHitAssociator::SimHitIdpr> CSCHitAssociator::associateCSCHitId(const CSCRecHit2D *cscrechit) const {
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 }
57 
58 std::vector<CSCHitAssociator::SimHitIdpr> CSCHitAssociator::associateHitId(const TrackingRecHit &hit) const {
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 }
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > geomToken_
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
unsigned int nStrips() const
Definition: CSCRecHit2D.h:62
iterator find(det_id_type id)
Definition: DetSetVector.h:255
std::vector< SimHitIdpr > associateHitId(const TrackingRecHit &) const
const edm::EDGetTokenT< DigiSimLinks > linksToken_
const edm::InputTag linksTag_
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)
const Config & theConfig
std::vector< SimHitIdpr > associateCSCHitId(const CSCRecHit2D *) const
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
CSCHitAssociator(const edm::Event &, const edm::EventSetup &, const Config &)
const DigiSimLinks * theDigiSimLinks
Config(const edm::ParameterSet &, edm::ConsumesCollector iC)
HLT enums.
const CSCGeometry * cscgeom
Definition: Config.py:1
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
void initEvent(const edm::Event &, const edm::EventSetup &)
Definition: event.py:1