CMS 3D CMS Logo

BTLDeviceSim.cc
Go to the documentation of this file.
4 
5 #include "CLHEP/Random/RandGaussQ.h"
6 
8  bxTime_(pset.getParameter<double>("bxTime") ),
9  LightYield_(pset.getParameter<double>("LightYield")),
10  LightCollEff_(pset.getParameter<double>("LightCollectionEff")),
11  LightCollTime_(pset.getParameter<double>("LightCollectionTime")),
12  smearLightCollTime_(pset.getParameter<double>("smearLightCollectionTime")),
13  PDE_(pset.getParameter<double>("PhotonDetectionEff")) { }
14 
15 
16 void BTLDeviceSim::getHitsResponse(const std::vector<std::tuple<int,uint32_t,float> > &hitRefs,
18  mtd_digitizer::MTDSimHitDataAccumulator *simHitAccumulator,
19  CLHEP::HepRandomEngine *hre){
20 
21  //loop over sorted simHits
22  const int nchits = hitRefs.size();
23  for(int ihit=0; ihit<nchits; ++ihit) {
24 
25  const int hitidx = std::get<0>(hitRefs[ihit]);
26  const uint32_t id = std::get<1>(hitRefs[ihit]);
27  const MTDDetId detId(id);
28  const PSimHit &hit = hits->at( hitidx );
29 
30  // --- Safety check on the detector ID
31  if ( detId.det()!=DetId::Forward || detId.mtdSubDetector()!=1 ) continue;
32 
33  // --- Store the detector element ID as a key of the MTDSimHitDataAccumulator map
34  auto simHitIt = simHitAccumulator->emplace(id,mtd_digitizer::MTDCellInfo()).first;
35 
36  // --- Get the simHit energy and convert it from MeV to photo-electrons
37  float Npe = 1000.*hit.energyLoss()*LightYield_*LightCollEff_*PDE_;
38 
39  // --- Get the simHit time of arrival and add the light collection time
40  float toa = std::get<2>(hitRefs[ihit]) + LightCollTime_;
41 
42  if ( smearLightCollTime_ > 0. )
43  toa += CLHEP::RandGaussQ::shoot(hre, 0., smearLightCollTime_);
44 
45  // --- Accumulate in 15 buckets of 25 ns (9 pre-samples, 1 in-time, 5 post-samples)
46  const int itime = std::floor( toa/bxTime_ ) + 9;
47  if(itime<0 || itime>14) continue;
48 
49  // --- Check if the time index is ok and accumulate the energy
50  if(itime >= (int)simHitIt->second.hit_info[0].size() ) continue;
51 
52  (simHitIt->second).hit_info[0][itime] += Npe;
53 
54  // --- Store the time of the first SimHit in the right DataFrame bucket
55  const float tof = toa - (itime-9)*bxTime_;
56 
57  if( (simHitIt->second).hit_info[1][itime] == 0 ||
58  tof < (simHitIt->second).hit_info[1][itime] )
59  (simHitIt->second).hit_info[1][itime] = tof;
60 
61  } // ihit loop
62 
63 }
const float LightYield_
Definition: BTLDeviceSim.h:36
void getHitsResponse(const std::vector< std::tuple< int, uint32_t, float > > &hitRefs, const edm::Handle< edm::PSimHitContainer > &hits, mtd_digitizer::MTDSimHitDataAccumulator *simHitAccumulator, CLHEP::HepRandomEngine *hre)
Definition: BTLDeviceSim.cc:16
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21
BTLDeviceSim(const edm::ParameterSet &pset)
Definition: BTLDeviceSim.cc:7
const float smearLightCollTime_
Definition: BTLDeviceSim.h:39
const float bxTime_
Definition: BTLDeviceSim.h:35
const float LightCollTime_
Definition: BTLDeviceSim.h:38
const float PDE_
Definition: BTLDeviceSim.h:40
float energyLoss() const
The energy deposit in the PSimHit, in ???.
Definition: PSimHit.h:75
std::unordered_map< uint32_t, MTDCellInfo > MTDSimHitDataAccumulator
const float LightCollEff_
Definition: BTLDeviceSim.h:37