CMS 3D CMS Logo

GEMHitAssociator.cc
Go to the documentation of this file.
3 
4 using namespace std;
5 
6 // Constructor
8  : GEMdigisimlinkTag(conf.getParameter<edm::InputTag>("GEMdigisimlinkTag")),
9  // CrossingFrame used or not ?
10  GEMsimhitsTag(conf.getParameter<edm::InputTag>("GEMsimhitsTag")),
11  GEMsimhitsXFTag(conf.getParameter<edm::InputTag>("GEMsimhitsXFTag")),
12  crossingframe(conf.getParameter<bool>("crossingframe")),
13  useGEMs_(conf.getParameter<bool>("useGEMs")) {
14  if (crossingframe) {
16  } else if (!GEMsimhitsTag.label().empty()) {
18  }
19 
21 }
22 
24 
26  if (theConfig.useGEMs_) {
28  LogTrace("GEMHitAssociator") << "getting CrossingFrame<PSimHit> collection - " << theConfig.GEMsimhitsXFTag;
30 
31  std::unique_ptr<MixCollection<PSimHit>> GEMsimhits(new MixCollection<PSimHit>(&cf));
32  LogTrace("GEMHitAssociator") << "... size = " << GEMsimhits->size();
33 
34  // MixCollection<PSimHit> & simHits = *hits;
35 
36  for (MixCollection<PSimHit>::MixItr hitItr = GEMsimhits->begin(); hitItr != GEMsimhits->end(); ++hitItr) {
37  _SimHitMap[hitItr->detUnitId()].push_back(*hitItr);
38  }
39 
40  } else if (!theConfig.GEMsimhitsTag.label().empty()) {
41  LogTrace("GEMHitAssociator") << "getting PSimHit collection - " << theConfig.GEMsimhitsTag;
42  edm::PSimHitContainer const &GEMsimhits = e.get(theConfig.GEMsimhitsToken_);
43  LogTrace("GEMHitAssociator") << "... size = " << GEMsimhits.size();
44 
45  // arrange the hits by detUnit
46  for (edm::PSimHitContainer::const_iterator hitItr = GEMsimhits.begin(); hitItr != GEMsimhits.end(); ++hitItr) {
47  _SimHitMap[hitItr->detUnitId()].push_back(*hitItr);
48  }
49  }
50 
51  LogTrace("GEMHitAssociator") << "getting GEM Strip DigiSimLink collection - " << theConfig.GEMdigisimlinkTag;
53  }
54 }
55 // end of constructor
56 
57 std::vector<GEMHitAssociator::SimHitIdpr> GEMHitAssociator::associateRecHit(const GEMRecHit *gemrechit) const {
58  std::vector<SimHitIdpr> matched;
59 
60  if (theConfig.useGEMs_) {
61  if (gemrechit) {
62  GEMDetId gemDetId = gemrechit->gemId();
63  int fstrip = gemrechit->firstClusterStrip();
64  int cls = gemrechit->clusterSize();
65  // int bx = gemrechit->BunchX();
66 
67  DigiSimLinks::const_iterator layerLinks = theDigiSimLinks->find(gemDetId);
68 
69  if (layerLinks != theDigiSimLinks->end()) {
70  for (int i = fstrip; i < (fstrip + cls); ++i) {
71  for (LayerLinks::const_iterator itlink = layerLinks->begin(); itlink != layerLinks->end(); ++itlink) {
72  int ch = static_cast<int>(itlink->getStrip());
73  if (ch != i)
74  continue;
75 
76  SimHitIdpr currentId(itlink->getTrackId(), itlink->getEventId());
77  if (find(matched.begin(), matched.end(), currentId) == matched.end())
78  matched.push_back(currentId);
79  }
80  }
81 
82  } else
83  edm::LogWarning("GEMHitAssociator")
84  << "*** WARNING in GEMHitAssociator: GEM layer " << gemDetId << " has no DigiSimLinks !" << std::endl;
85 
86  } else
87  edm::LogWarning("GEMHitAssociator") << "*** WARNING in GEMHitAssociator::associateRecHit, null "
88  "dynamic_cast !";
89  }
90 
91  return matched;
92 }
GEMHitAssociator(const edm::Event &e, const Config &config)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::InputTag GEMdigisimlinkTag
iterator find(det_id_type id)
Definition: DetSetVector.h:264
void initEvent(const edm::Event &)
std::map< unsigned int, edm::PSimHitContainer > _SimHitMap
Definition: config.py:1
std::string const & label() const
Definition: InputTag.h:36
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
#define LogTrace(id)
edm::EDGetTokenT< edm::DetSetVector< GEMDigiSimLink > > GEMdigisimlinkToken_
std::pair< uint32_t, EncodedEventId > SimHitIdpr
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:325
edm::EDGetTokenT< edm::PSimHitContainer > GEMsimhitsToken_
edm::EDGetTokenT< CrossingFrame< PSimHit > > GEMsimhitsXFToken_
GEMDetId gemId() const
Return the gemId.
Definition: GEMRecHit.h:65
std::vector< SimHitIdpr > associateRecHit(const GEMRecHit *gemrechit) const
const DigiSimLinks * theDigiSimLinks
int firstClusterStrip() const
Definition: GEMRecHit.h:69
const Config & theConfig
HLT enums.
Definition: Config.py:1
std::vector< PSimHit > PSimHitContainer
int clusterSize() const
Definition: GEMRecHit.h:71
Log< level::Warning, false > LogWarning
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:102
Config(const edm::ParameterSet &, edm::ConsumesCollector ic)