CMS 3D CMS Logo

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