CMS 3D CMS Logo

GEMDigiModel.cc
Go to the documentation of this file.
3 
4 void
6 {
7  for (auto d: strips_)
8  {
9  if (d.second == -999) continue;
10 
11  // (strip, bx)
12  GEMDigi digi(d.first, d.second);
13  digis.insertDigi(GEMDetId(rollDetId), digi);
14  addLinks(d.first, d.second);
15  addLinksWithPartId(d.first, d.second);
16  }
17  strips_.clear();
18 }
19 
20 void
21 GEMDigiModel::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(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 GEMDigiModel::addLinksWithPartId(unsigned int strip, int bx)
61 {
62 
63  std::pair<unsigned int, int > digi(strip, bx);
64  std::pair<DetectorHitMap::iterator, DetectorHitMap::iterator> channelHitItr
65  = detectorHitMap_.equal_range(digi);
66 
67  for( DetectorHitMap::iterator hitItr = channelHitItr.first; hitItr != channelHitItr.second; ++hitItr)
68  {
69  const PSimHit * hit = (hitItr->second);
70  // might be zero for unit tests and such
71  if (hit == nullptr) continue;
72 
74  hit->particleType(), hit->detUnitId(), hit->trackId(), hit->eventId(), hit->processType()));
75 
76  }
77 }
78 
void push_back(const T &t)
Definition: DetSet.h:68
LocalVector momentumAtEntry() const
The momentum of the track that produced the hit, at entry point.
Definition: PSimHit.h:47
GEMDigiSimLinks theGemDigiSimLinks_
Definition: GEMDigiModel.h:80
float timeOfFlight() const
Definition: PSimHit.h:69
double f[11][100]
EncodedEventId eventId() const
Definition: PSimHit.h:105
void addLinks(unsigned int strip, int bx)
creates links from Digi to SimTrack
Definition: GEMDigiModel.cc:21
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
std::set< std::pair< int, int > > strips_
Definition: GEMDigiModel.h:65
unsigned int trackId() const
Definition: PSimHit.h:102
void fillDigis(int rollDetId, GEMDigiCollection &)
Definition: GEMDigiModel.cc:5
DetectorHitMap detectorHitMap_
Definition: GEMDigiModel.h:78
StripDigiSimLinks stripDigiSimLinks_
Definition: GEMDigiModel.h:79
void addLinksWithPartId(unsigned int strip, int bx)
Definition: GEMDigiModel.cc:60
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Definition: PSimHit.h:35
unsigned int detUnitId() const
Definition: PSimHit.h:93