CMS 3D CMS Logo

GEMDigiModule.cc
Go to the documentation of this file.
2 
8 
10  bool simulateBkgNoise_(config.getParameter<bool>("simulateBkgNoise"));
11  bool simulateIntrinsicNoise_(config.getParameter<bool>("simulateIntrinsicNoise"));
12  if (simulateIntrinsicNoise_) {
13  models.push_back(std::make_unique<GEMNoiseModel>(config));
14  }
15  if (simulateBkgNoise_) {
16  models.push_back(std::make_unique<GEMBkgModel>(config));
17  }
18  models.push_back(std::make_unique<GEMSignalModel>(config));
19 }
20 
22 
25  CLHEP::HepRandomEngine* engine) {
27  detectorHitMap_.clear();
28  stripDigiSimLinks_ = StripDigiSimLinks(roll->id().rawId());
30  theGemDigiSimLinks_ = GEMDigiSimLinks(roll->id().rawId());
31  for (auto&& model : models) {
32  model->simulate(roll, simHits, engine, strips_, detectorHitMap_);
33  }
34  return;
35 }
36 
37 void GEMDigiModule::fillDigis(int rollDetId, GEMDigiCollection& digis) {
38  for (const auto& d : strips_) {
39  if (d.second == -999)
40  continue;
41  // (strip, bx)
42  GEMDigi digi(d.first, d.second);
43  digis.insertDigi(GEMDetId(rollDetId), digi);
44  addLinks(d.first, d.second);
45  addLinksWithPartId(d.first, d.second);
46  }
47  strips_.clear();
48 }
49 
50 void GEMDigiModule::addLinks(unsigned int strip, int bx) {
51  std::pair<unsigned int, int> digi(strip, bx);
52  auto channelHitItr = detectorHitMap_.equal_range(digi);
53 
54  // find the fraction contribution for each SimTrack
55  std::map<int, float> simTrackChargeMap;
56  std::map<int, EncodedEventId> eventIdMap;
57  float totalCharge(0.);
58  for (auto hitItr = channelHitItr.first; hitItr != channelHitItr.second; ++hitItr) {
59  const PSimHit* hit(hitItr->second);
60  // might be zero for unit tests and such
61  if (hit == nullptr)
62  continue;
63 
64  int simTrackId(hit->trackId());
65  //float charge = hit->getCharge();
66  const float charge(1.f);
67  auto chargeItr = simTrackChargeMap.find(simTrackId);
68  if (chargeItr == simTrackChargeMap.end()) {
69  simTrackChargeMap[simTrackId] = charge;
70  eventIdMap[simTrackId] = hit->eventId();
71  } else {
72  chargeItr->second += charge;
73  }
74  totalCharge += charge;
75  }
76 
77  for (const auto& charge : simTrackChargeMap) {
78  const int simTrackId(charge.first);
79  auto link(StripDigiSimLink(strip, simTrackId, eventIdMap[simTrackId], charge.second / totalCharge));
81  }
82 }
83 
84 void GEMDigiModule::addLinksWithPartId(unsigned int strip, int bx) {
85  std::pair<unsigned int, int> digi(strip, bx);
86  std::pair<DetectorHitMap::iterator, DetectorHitMap::iterator> channelHitItr = detectorHitMap_.equal_range(digi);
87 
88  for (DetectorHitMap::iterator hitItr = channelHitItr.first; hitItr != channelHitItr.second; ++hitItr) {
89  const PSimHit* hit = (hitItr->second);
90  // might be zero for unit tests and such
91  if (hit == nullptr)
92  continue;
93 
94  theGemDigiSimLinks_.push_back(GEMDigiSimLink(strip, bx, hit->particleType(), hit->trackId(), hit->eventId()));
95  }
96 }
97 
99  for (auto&& model : models) {
100  model->setGeometry(geom);
101  }
102 }
edm::DetSet< StripDigiSimLink > StripDigiSimLinks
Definition: GEMDigiModule.h:41
void push_back(const T &t)
Definition: DetSet.h:66
StripDigiSimLinks stripDigiSimLinks_
Definition: GEMDigiModule.h:64
void simulate(const GEMEtaPartition *, const edm::PSimHitContainer &, CLHEP::HepRandomEngine *)
void addLinks(unsigned int strip, int bx)
creates links from Digi to SimTrack
Definition: config.py:1
Definition: models.py:1
GEMDigiSimLinks theGemDigiSimLinks_
Definition: GEMDigiModule.h:65
GEMDigiModule(const edm::ParameterSet &)
Definition: GEMDigiModule.cc:9
void addLinksWithPartId(unsigned int strip, int bx)
double f[11][100]
edm::DetSet< GEMDigiSimLink > GEMDigiSimLinks
Definition: GEMDigiModule.h:42
d
Definition: ztail.py:151
void fillDigis(int rollDetId, GEMDigiCollection &)
void clear()
Definition: DetSet.h:71
DetectorHitMap detectorHitMap_
Definition: GEMDigiModule.h:63
std::vector< PSimHit > PSimHitContainer
void setGeometry(const GEMGeometry *)