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();
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 
95  hit->entryPoint(),
96  hit->momentumAtEntry(),
97  hit->timeOfFlight(),
98  hit->energyLoss(),
99  hit->particleType(),
100  hit->detUnitId(),
101  hit->trackId(),
102  hit->eventId(),
103  hit->processType()));
104  }
105 }
106 
108  for (auto&& model : models) {
109  model->setGeometry(geom);
110  }
111 }
GEMDigiModule::~GEMDigiModule
~GEMDigiModule()
edm::DetSet::push_back
void push_back(const T &t)
Definition: DetSet.h:66
models
Definition: models.py:1
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
GEMDigiModule::setGeometry
void setGeometry(const GEMGeometry *)
Definition: GEMDigiModule.cc:107
edm::DetSet::clear
void clear()
Definition: DetSet.h:71
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
GEMDigiModule.h
GEMEtaPartition
Definition: GEMEtaPartition.h:12
GEMBkgModel.h
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
GEMDigiModule::StripDigiSimLinks
edm::DetSet< StripDigiSimLink > StripDigiSimLinks
Definition: GEMDigiModule.h:41
FastTrackerRecHitCombiner_cfi.simHits
simHits
Definition: FastTrackerRecHitCombiner_cfi.py:5
GEMDigiModule::detectorHitMap_
DetectorHitMap detectorHitMap_
Definition: GEMDigiModule.h:63
GEMDigiModule::fillDigis
void fillDigis(int rollDetId, GEMDigiCollection &)
Definition: GEMDigiModule.cc:37
GEMDigiModule::strips_
Strips strips_
Definition: GEMDigiModule.h:62
GEMDigiModule::simulate
void simulate(const GEMEtaPartition *, const edm::PSimHitContainer &, CLHEP::HepRandomEngine *)
Definition: GEMDigiModule.cc:23
ReggeGribovPartonMC_EposLHC_2760GeV_PbPb_cfi.model
model
Definition: ReggeGribovPartonMC_EposLHC_2760GeV_PbPb_cfi.py:11
config
Definition: config.py:1
GEMEtaPartition.h
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
GEMDigiModule::GEMDigiModule
GEMDigiModule(const edm::ParameterSet &)
Definition: GEMDigiModule.cc:9
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
edm::ParameterSet
Definition: ParameterSet.h:47
GEMDigiModule::theGemDigiSimLinks_
GEMDigiSimLinks theGemDigiSimLinks_
Definition: GEMDigiModule.h:65
GEMSignalModel.h
GEMDetId
Definition: GEMDetId.h:18
GEMEtaPartition::id
GEMDetId id() const
Definition: GEMEtaPartition.h:18
GEMDigi
Definition: GEMDigi.h:15
GEMDigiModule::addLinks
void addLinks(unsigned int strip, int bx)
creates links from Digi to SimTrack
Definition: GEMDigiModule.cc:50
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
GEMDigiCollection
GEMDigiModule::addLinksWithPartId
void addLinksWithPartId(unsigned int strip, int bx)
Definition: GEMDigiModule.cc:84
GEMDigiModule::GEMDigiSimLinks
edm::DetSet< GEMDigiSimLink > GEMDigiSimLinks
Definition: GEMDigiModule.h:42
GEMGeometry
Definition: GEMGeometry.h:24
ztail.d
d
Definition: ztail.py:151
edm::PSimHitContainer
std::vector< PSimHit > PSimHitContainer
Definition: PSimHitContainer.h:11
PSimHit
Definition: PSimHit.h:15
GEMDigiModule::stripDigiSimLinks_
StripDigiSimLinks stripDigiSimLinks_
Definition: GEMDigiModule.h:64
hit
Definition: SiStripHitEffFromCalibTree.cc:88
GEMNoiseModel.h
EncodedEventId.h