CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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) {
15  initEvent(event, setup);
16 }
17 
19  LogTrace("CSCHitAssociator") << "getting CSC Strip DigiSimLink collection - " << theConfig.linksTag_;
21 
22  // get CSC Geometry to use CSCLayer methods
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_
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:58
iterator find(det_id_type id)
Definition: DetSetVector.h:264
const edm::EDGetTokenT< DigiSimLinks > linksToken_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const edm::InputTag linksTag_
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:19
#define LogTrace(id)
const Config & theConfig
bool getData(T &iHolder) const
Definition: EventSetup.h:128
int channels(unsigned int i) const
Extracting strip channel numbers comprising the rechit - low.
Definition: CSCRecHit2D.h:61
std::vector< SimHitIdpr > associateHitId(const TrackingRecHit &) const
unsigned int nStrips() const
Definition: CSCRecHit2D.h:62
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:325
int channel(int strip) const
std::pair< uint32_t, EncodedEventId > SimHitIdpr
CSCHitAssociator(const edm::Event &, const edm::EventSetup &, const Config &)
const DigiSimLinks * theDigiSimLinks
Config(const edm::ParameterSet &, edm::ConsumesCollector iC)
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:105
const CSCGeometry * cscgeom
DetId geographicalId() const
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:102
void initEvent(const edm::Event &, const edm::EventSetup &)
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283