CMS 3D CMS Logo

GEMHitAssociator.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 
5 // Constructor
7  : GEMdigisimlinkTag(conf.getParameter<edm::InputTag>("GEMdigisimlinkTag")),
8  // CrossingFrame used or not ?
9  crossingframe(conf.getParameter<bool>("crossingframe")),
10  useGEMs_(conf.getParameter<bool>("useGEMs")),
11  GEMsimhitsTag(conf.getParameter<edm::InputTag>("GEMsimhitsTag")),
12  GEMsimhitsXFTag(conf.getParameter<edm::InputTag>("GEMsimhitsXFTag")) {
13  if (crossingframe) {
15  } else if (!GEMsimhitsTag.label().empty()) {
17  }
18 
20 }
21 
23  const edm::EventSetup &eventSetup,
24  const edm::ParameterSet &conf)
25  : GEMdigisimlinkTag(conf.getParameter<edm::InputTag>("GEMdigisimlinkTag")),
26  // CrossingFrame used or not ?
27  crossingframe(conf.getParameter<bool>("crossingframe")),
28  useGEMs_(conf.getParameter<bool>("useGEMs")),
29  GEMsimhitsTag(conf.getParameter<edm::InputTag>("GEMsimhitsTag")),
30  GEMsimhitsXFTag(conf.getParameter<edm::InputTag>("GEMsimhitsXFTag")) {
31  initEvent(e, eventSetup);
32 }
33 
34 void GEMHitAssociator::initEvent(const edm::Event &e, const edm::EventSetup &eventSetup) {
35  if (useGEMs_) {
36  if (crossingframe) {
38  LogTrace("GEMHitAssociator") << "getting CrossingFrame<PSimHit> collection - " << GEMsimhitsXFTag;
39  e.getByLabel(GEMsimhitsXFTag, cf);
40 
41  std::unique_ptr<MixCollection<PSimHit>> GEMsimhits(new MixCollection<PSimHit>(cf.product()));
42  LogTrace("GEMHitAssociator") << "... size = " << GEMsimhits->size();
43 
44  // MixCollection<PSimHit> & simHits = *hits;
45 
46  for (MixCollection<PSimHit>::MixItr hitItr = GEMsimhits->begin(); hitItr != GEMsimhits->end(); ++hitItr) {
47  _SimHitMap[hitItr->detUnitId()].push_back(*hitItr);
48  }
49 
50  } else if (!GEMsimhitsTag.label().empty()) {
52  LogTrace("GEMHitAssociator") << "getting PSimHit collection - " << GEMsimhitsTag;
53  e.getByLabel(GEMsimhitsTag, GEMsimhits);
54  LogTrace("GEMHitAssociator") << "... size = " << GEMsimhits->size();
55 
56  // arrange the hits by detUnit
57  for (edm::PSimHitContainer::const_iterator hitItr = GEMsimhits->begin(); hitItr != GEMsimhits->end(); ++hitItr) {
58  _SimHitMap[hitItr->detUnitId()].push_back(*hitItr);
59  }
60  }
61 
63  LogTrace("GEMHitAssociator") << "getting GEM Strip DigiSimLink collection - " << GEMdigisimlinkTag;
64  e.getByLabel(GEMdigisimlinkTag, digiSimLinks);
65  theDigiSimLinks = digiSimLinks.product();
66  }
67 }
68 // end of constructor
69 
70 std::vector<GEMHitAssociator::SimHitIdpr> GEMHitAssociator::associateRecHit(const GEMRecHit *gemrechit) const {
71  std::vector<SimHitIdpr> matched;
72 
73  if (useGEMs_) {
74  if (gemrechit) {
75  GEMDetId gemDetId = gemrechit->gemId();
76  int fstrip = gemrechit->firstClusterStrip();
77  int cls = gemrechit->clusterSize();
78  // int bx = gemrechit->BunchX();
79 
80  DigiSimLinks::const_iterator layerLinks = theDigiSimLinks->find(gemDetId);
81 
82  if (layerLinks != theDigiSimLinks->end()) {
83  for (int i = fstrip; i < (fstrip + cls); ++i) {
84  for (LayerLinks::const_iterator itlink = layerLinks->begin(); itlink != layerLinks->end(); ++itlink) {
85  int ch = static_cast<int>(itlink->channel());
86  if (ch != i)
87  continue;
88 
89  SimHitIdpr currentId(itlink->SimTrackId(), itlink->eventId());
90  if (find(matched.begin(), matched.end(), currentId) == matched.end())
91  matched.push_back(currentId);
92  }
93  }
94 
95  } else
96  edm::LogWarning("GEMHitAssociator")
97  << "*** WARNING in GEMHitAssociator: GEM layer " << gemDetId << " has no DigiSimLinks !" << std::endl;
98 
99  } else
100  edm::LogWarning("GEMHitAssociator") << "*** WARNING in GEMHitAssociator::associateRecHit, null "
101  "dynamic_cast !";
102  }
103 
104  return matched;
105 }
muonTagProbeFilters_cff.matched
matched
Definition: muonTagProbeFilters_cff.py:62
edm::DetSetVector
Definition: DetSetVector.h:61
electrons_cff.bool
bool
Definition: electrons_cff.py:393
mps_fire.i
i
Definition: mps_fire.py:428
edm::Handle::product
T const * product() const
Definition: Handle.h:70
edm::DetSetVector::end
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:325
GEMHitAssociator::_SimHitMap
std::map< unsigned int, edm::PSimHitContainer > _SimHitMap
Definition: GEMHitAssociator.h:63
edm
HLT enums.
Definition: AlignableModifier.h:19
MuonAssociatorByHits_cfi.GEMsimhitsTag
GEMsimhitsTag
Definition: MuonAssociatorByHits_cfi.py:65
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
MuonAssociatorByHits_cfi.GEMsimhitsXFTag
GEMsimhitsXFTag
Definition: MuonAssociatorByHits_cfi.py:66
MuonAssociatorByHits_cfi.crossingframe
crossingframe
Definition: MuonAssociatorByHits_cfi.py:38
GEMHitAssociator::GEMsimhitsToken_
edm::EDGetTokenT< edm::PSimHitContainer > GEMsimhitsToken_
Definition: GEMHitAssociator.h:60
GEMHitAssociator::initEvent
void initEvent(const edm::Event &, const edm::EventSetup &)
Definition: GEMHitAssociator.cc:34
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::Handle
Definition: AssociativeIterator.h:50
GEMHitAssociator::useGEMs_
bool useGEMs_
Definition: GEMHitAssociator.h:55
MixCollection::MixItr
Definition: MixCollection.h:62
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
GEMHitAssociator::GEMsimhitsXFToken_
edm::EDGetTokenT< CrossingFrame< PSimHit > > GEMsimhitsXFToken_
Definition: GEMHitAssociator.h:59
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
CrossingFrame
Definition: CrossingFrame.h:38
TTClusterAssociation_cfi.digiSimLinks
digiSimLinks
Definition: TTClusterAssociation_cfi.py:8
GEMHitAssociator::GEMHitAssociator
GEMHitAssociator(const edm::ParameterSet &, edm::ConsumesCollector &&ic)
Definition: GEMHitAssociator.cc:6
GEMHitAssociator::SimHitIdpr
std::pair< uint32_t, EncodedEventId > SimHitIdpr
Definition: GEMHitAssociator.h:37
MixCollection
Definition: MixCollection.h:11
GEMHitAssociator::crossingframe
bool crossingframe
Definition: GEMHitAssociator.h:54
GEMHitAssociator::GEMsimhitsTag
edm::InputTag GEMsimhitsTag
Definition: GEMHitAssociator.h:56
GEMHitAssociator::associateRecHit
std::vector< SimHitIdpr > associateRecHit(const GEMRecHit *gemrechit) const
Definition: GEMHitAssociator.cc:70
edm::ParameterSet
Definition: ParameterSet.h:47
edm::DetSetVector::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:102
GEMHitAssociator::GEMdigisimlinkToken_
edm::EDGetTokenT< edm::DetSetVector< StripDigiSimLink > > GEMdigisimlinkToken_
Definition: GEMHitAssociator.h:61
GEMDetId
Definition: GEMDetId.h:18
GEMRecHit::firstClusterStrip
int firstClusterStrip() const
Definition: GEMRecHit.h:69
edm::DetSetVector::find
iterator find(det_id_type id)
Definition: DetSetVector.h:264
GEMHitAssociator::GEMsimhitsXFTag
edm::InputTag GEMsimhitsXFTag
Definition: GEMHitAssociator.h:57
GEMRecHit::gemId
GEMDetId gemId() const
Return the gemId.
Definition: GEMRecHit.h:65
edm::EventSetup
Definition: EventSetup.h:57
GEMRecHit::clusterSize
int clusterSize() const
Definition: GEMRecHit.h:71
GEMHitAssociator::GEMdigisimlinkTag
edm::InputTag GEMdigisimlinkTag
Definition: GEMHitAssociator.h:52
std
Definition: JetResolutionObject.h:76
GEMHitAssociator::theDigiSimLinks
const DigiSimLinks * theDigiSimLinks
Definition: GEMHitAssociator.h:51
GEMRecHit
Definition: GEMRecHit.h:14
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
edm::PSimHitContainer
std::vector< PSimHit > PSimHitContainer
Definition: PSimHitContainer.h:11
GEMHitAssociator.h
edm::Event
Definition: Event.h:73
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
MuonAssociatorByHits_cfi.GEMdigisimlinkTag
GEMdigisimlinkTag
Definition: MuonAssociatorByHits_cfi.py:67
edm::DetSet< StripDigiSimLink >::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSet.h:31