CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GEMSim.cc
Go to the documentation of this file.
1 #include "GEMSim.h"
4 
5 
6 void GEMSim::fillDigis(int rollDetId, GEMDigiCollection& digis)
7 {
8  for (auto d: strips_)
9  {
10  if (d.second != -999)
11  {
12  GEMDigi digi(d.first, d.second); // (strip, bx)
13  digis.insertDigi(GEMDetId(rollDetId), digi);
14  addLinks(d.first, d.second);
15  }
16  }
17  strips_.clear();
18 }
19 
20 
21 void GEMSim::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  int simTrackId = charge.first;
56  StripDigiSimLink(strip, simTrackId, eventIdMap[simTrackId], charge.second/totalCharge ));
57  }
58 }
59 
virtual void fillDigis(int rollDetId, GEMDigiCollection &digis)
Definition: GEMSim.cc:6
void push_back(const T &t)
Definition: DetSet.h:68
DetectorHitMap detectorHitMap_
Definition: GEMSim.h:67
std::set< std::pair< int, int > > strips_
Definition: GEMSim.h:54
double charge(const std::vector< uint8_t > &Ampls)
EncodedEventId eventId() const
Definition: PSimHit.h:105
virtual void addLinks(unsigned int strip, int bx)
Definition: GEMSim.cc:21
unsigned int trackId() const
Definition: PSimHit.h:102
StripDigiSimLinks stripDigiSimLinks_
Definition: GEMSim.h:68