CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
61  theME0DigiSimLinks_.push_back(ME0DigiSimLink(strip, bx, hit->particleType(), hit->trackId(), hit->eventId()));
62  }
63 }
void push_back(const T &t)
Definition: DetSet.h:66
void fillDigis(int rollDetId, ME0DigiCollection &)
Definition: ME0DigiModel.cc:4
StripDigiSimLinks stripDigiSimLinks_
Definition: ME0DigiModel.h:75
void addLinks(unsigned int strip, int bx)
creates links from Digi to SimTrack
Definition: ME0DigiModel.cc:18
tuple d
Definition: ztail.py:151
EncodedEventId eventId() const
Definition: PSimHit.h:108
void addLinksWithPartId(unsigned int strip, int bx)
Definition: ME0DigiModel.cc:52
ME0DigiSimLinks theME0DigiSimLinks_
Definition: ME0DigiModel.h:76
std::set< std::pair< int, int > > strips_
Definition: ME0DigiModel.h:64
int particleType() const
Definition: PSimHit.h:89
unsigned int trackId() const
Definition: PSimHit.h:106
DetectorHitMap detectorHitMap_
Definition: ME0DigiModel.h:74