CMS 3D CMS Logo

CSCHitAssociator.cc
Go to the documentation of this file.
7 
9  : theDigiSimLinks(nullptr), linksTag(conf.getParameter<edm::InputTag>("CSClinksTag")) {
10  initEvent(event, setup);
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 }
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:52
iterator find(det_id_type id)
Definition: DetSetVector.h:290
#define nullptr
edm::InputTag linksTag
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
std::vector< SimHitIdpr > associateCSCHitId(const CSCRecHit2D *) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
CSCHitAssociator(const edm::Event &, const edm::EventSetup &, const edm::ParameterSet &)
int channels(unsigned int i) const
Extracting strip channel numbers comprising the rechit - low.
Definition: CSCRecHit2D.h:55
std::vector< SimHitIdpr > associateHitId(const TrackingRecHit &) const
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
T const * product() const
Definition: Handle.h:74
const DigiSimLinks * theDigiSimLinks
ESHandle< TrackerGeometry > geometry
HLT enums.
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:139
T get() const
Definition: EventSetup.h:71
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 initEvent(const edm::Event &, const edm::EventSetup &)
Definition: event.py:1