Go to the documentation of this file.00001 #include "GEMSim.h"
00002 #include "SimMuon/GEMDigitizer/src/GEMSimSetUp.h"
00003 #include "SimDataFormats/EncodedEventId/interface/EncodedEventId.h"
00004
00005
00006 void GEMSim::fillDigis(int rollDetId, GEMDigiCollection& digis)
00007 {
00008 for (auto d: strips_)
00009 {
00010 if (d.second != -999)
00011 {
00012 GEMDigi digi(d.first, d.second);
00013 digis.insertDigi(GEMDetId(rollDetId), digi);
00014 addLinks(d.first, d.second);
00015 }
00016 }
00017 strips_.clear();
00018 }
00019
00020
00021 void GEMSim::addLinks(unsigned int strip, int bx)
00022 {
00023 std::pair<unsigned int, int> digi(strip, bx);
00024 auto channelHitItr = detectorHitMap_.equal_range(digi);
00025
00026
00027 std::map<int, float> simTrackChargeMap;
00028 std::map<int, EncodedEventId> eventIdMap;
00029 float totalCharge = 0;
00030 for(auto hitItr = channelHitItr.first; hitItr != channelHitItr.second; ++hitItr)
00031 {
00032 const PSimHit * hit = hitItr->second;
00033
00034 if(hit == nullptr) continue;
00035
00036 int simTrackId = hit->trackId();
00037
00038 const float charge = 1.f;
00039 auto chargeItr = simTrackChargeMap.find(simTrackId);
00040 if( chargeItr == simTrackChargeMap.end() )
00041 {
00042 simTrackChargeMap[simTrackId] = charge;
00043 eventIdMap[simTrackId] = hit->eventId();
00044 }
00045 else
00046 {
00047 chargeItr->second += charge;
00048 }
00049 totalCharge += charge;
00050 }
00051
00052 for(auto &charge: simTrackChargeMap)
00053 {
00054 int simTrackId = charge.first;
00055 stripDigiSimLinks_.push_back(
00056 StripDigiSimLink(strip, simTrackId, eventIdMap[simTrackId], charge.second/totalCharge ));
00057 }
00058 }
00059