CMS 3D CMS Logo

ME0DigiModel.cc
Go to the documentation of this file.
3 
4 void ME0DigiModel::fillDigis(int rollDetId, ME0DigiCollection &digis) {
5  for (const auto &d : strips_) {
6  if (d.second == -999)
7  continue;
8 
9  // (strip, bx)
10  ME0Digi digi(d.first, d.second);
11  digis.insertDigi(ME0DetId(rollDetId), digi);
12  addLinks(d.first, d.second);
13  addLinksWithPartId(d.first, d.second);
14  }
15  strips_.clear();
16 }
17 
18 void ME0DigiModel::addLinks(unsigned int strip, int bx) {
19  std::pair<unsigned int, int> digi(strip, bx);
20  auto channelHitItr = detectorHitMap_.equal_range(digi);
21 
22  // find the fraction contribution for each SimTrack
23  std::map<int, float> simTrackChargeMap;
24  std::map<int, EncodedEventId> eventIdMap;
25  float totalCharge(0.);
26  for (auto hitItr = channelHitItr.first; hitItr != channelHitItr.second; ++hitItr) {
27  const PSimHit *hit(hitItr->second);
28  // might be zero for unit tests and such
29  if (hit == nullptr)
30  continue;
31 
32  int simTrackId(hit->trackId());
33  //float charge = hit->getCharge();
34  const float charge(1.f);
35  auto chargeItr = simTrackChargeMap.find(simTrackId);
36  if (chargeItr == simTrackChargeMap.end()) {
37  simTrackChargeMap[simTrackId] = charge;
38  eventIdMap[simTrackId] = hit->eventId();
39  } else {
40  chargeItr->second += charge;
41  }
42  totalCharge += charge;
43  }
44 
45  for (const auto &charge : simTrackChargeMap) {
46  const int simTrackId(charge.first);
47  auto link(StripDigiSimLink(strip, simTrackId, eventIdMap[simTrackId], charge.second / totalCharge));
49  }
50 }
51 
52 void ME0DigiModel::addLinksWithPartId(unsigned int strip, int bx) {
53  std::pair<unsigned int, int> digi(strip, bx);
54  auto channelHitItr = detectorHitMap_.equal_range(digi);
55  for (auto hitItr = channelHitItr.first; hitItr != channelHitItr.second; ++hitItr) {
56  const PSimHit *hit = (hitItr->second);
57  // might be zero for unit tests and such
58  if (hit == nullptr)
59  continue;
60 
62  hit->entryPoint(),
63  hit->momentumAtEntry(),
64  hit->timeOfFlight(),
65  hit->energyLoss(),
66  hit->particleType(),
67  hit->detUnitId(),
68  hit->trackId(),
69  hit->eventId(),
70  hit->processType()));
71  }
72 }
edm::DetSet::push_back
void push_back(const T &t)
Definition: DetSet.h:66
ME0DigiModel.h
ME0Digi
Definition: ME0Digi.h:15
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
ME0DigiModel::addLinksWithPartId
void addLinksWithPartId(unsigned int strip, int bx)
Definition: ME0DigiModel.cc:52
ME0DigiModel::theME0DigiSimLinks_
ME0DigiSimLinks theME0DigiSimLinks_
Definition: ME0DigiModel.h:76
ME0DigiCollection
ME0DigiModel::strips_
std::set< std::pair< int, int > > strips_
Definition: ME0DigiModel.h:64
ME0DigiModel::fillDigis
void fillDigis(int rollDetId, ME0DigiCollection &)
Definition: ME0DigiModel.cc:4
ME0DigiModel::detectorHitMap_
DetectorHitMap detectorHitMap_
Definition: ME0DigiModel.h:74
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
ME0DetId
Definition: ME0DetId.h:16
ME0DigiModel::stripDigiSimLinks_
StripDigiSimLinks stripDigiSimLinks_
Definition: ME0DigiModel.h:75
ztail.d
d
Definition: ztail.py:151
PSimHit
Definition: PSimHit.h:15
hit
Definition: SiStripHitEffFromCalibTree.cc:88
ME0DigiModel::addLinks
void addLinks(unsigned int strip, int bx)
creates links from Digi to SimTrack
Definition: ME0DigiModel.cc:18
EncodedEventId.h