CMS 3D CMS Logo

ETLDeviceSim.cc
Go to the documentation of this file.
1 #include "CLHEP/Units/GlobalPhysicalConstants.h"
6 
9 
11  geom_(nullptr),
12  MIPPerMeV_( 1.0/pset.getParameter<double>("meVPerMIP") ),
13  bxTime_(pset.getParameter<double>("bxTime") ),
14  tofDelay_(pset.getParameter<double>("tofDelay") ) {}
15 
17 
19  evs.get<MTDDigiGeometryRecord>().get(geom);
20  geom_ = geom.product();
21 
22 }
23 
24 void ETLDeviceSim::getHitsResponse(const std::vector<std::tuple<int,uint32_t,float> > &hitRefs,
26  mtd_digitizer::MTDSimHitDataAccumulator *simHitAccumulator,
27  CLHEP::HepRandomEngine *hre){
28 
29  //loop over sorted hits
30  const int nchits = hitRefs.size();
31  for(int i=0; i<nchits; ++i) {
32  const int hitidx = std::get<0>(hitRefs[i]);
33  const uint32_t id = std::get<1>(hitRefs[i]);
34  const MTDDetId detId(id);
35 
36  // Safety check (this should never happen, it should be an exception
37  if ( detId.det()!=DetId::Forward || detId.mtdSubDetector()!=2 ) {
38  throw cms::Exception("ETLDeviceSim") << "got a DetId that was not ETL: Det = " << detId.det()
39  << " subDet = " << detId.mtdSubDetector();
40  }
41 
42  if(id==0) continue; // to be ignored at RECO level
43 
44  ETLDetId etlid(detId) ;
45  DetId geoId = ETLDetId(etlid.mtdSide(),etlid.mtdRR(),etlid.module(),0);
46  const MTDGeomDet* thedet = geom_->idToDet(geoId);
47  if( thedet == nullptr ) {
48  throw cms::Exception("ETLDeviceSim") << "GeographicalID: " << std::hex
49  << geoId.rawId()
50  << " (" << detId.rawId()<< ") is invalid!" << std::dec
51  << std::endl;
52  }
53  const PixelTopology& topo = static_cast<const PixelTopology&>(thedet->topology());
54 
55  const float toa = std::get<2>(hitRefs[i]) + tofDelay_;
56  const PSimHit &hit = hits->at( hitidx );
57  const float charge = 1000.f*hit.energyLoss()*MIPPerMeV_;
58 
59  // calculate the simhit row and column
60  const auto& pentry = hit.entryPoint();
61  // ETL is already in module-local coordinates so just scale to cm from mm
62  Local3DPoint simscaled(0.1*pentry.x(),0.1*pentry.y(),0.1*pentry.z());
63  const auto& thepixel = topo.pixel(simscaled); // mm -> cm here is the switch
64  const uint8_t row(thepixel.first), col(thepixel.second);
65 
66  auto simHitIt = simHitAccumulator->emplace(mtd_digitizer::MTDCellId(id,row,col),
68 
69  // Accumulate in 15 buckets of 25ns (9 pre-samples, 1 in-time, 5 post-samples)
70  const int itime = std::floor( toa/bxTime_ ) + 9;
71  if(itime<0 || itime>14) continue;
72 
73  // Check if time index is ok and store energy
74  if(itime >= (int)simHitIt->second.hit_info[0].size() ) continue;
75 
76  (simHitIt->second).hit_info[0][itime] += charge;
77 
78  // Store the time of the first SimHit in the right DataFrame bucket
79  const float tof = toa - (itime-9)*bxTime_;
80 
81  if( (simHitIt->second).hit_info[1][itime] == 0. ||
82  tof < (simHitIt->second).hit_info[1][itime] ) {
83  (simHitIt->second).hit_info[1][itime] = tof;
84 
85  }
86 
87  }
88 
89 }
const MTDGeometry * geom_
Definition: ETLDeviceSim.h:38
virtual std::pair< float, float > pixel(const LocalPoint &p) const =0
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
std::unordered_map< MTDCellId, MTDCellInfo > MTDSimHitDataAccumulator
#define nullptr
void getEventSetup(const edm::EventSetup &evt)
Definition: ETLDeviceSim.cc:16
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21
const MTDGeomDet * idToDet(DetId) const override
Definition: MTDGeometry.cc:184
int mtdRR() const
Definition: MTDDetId.h:66
int mtdSide() const
Definition: MTDDetId.h:61
Definition: DetId.h:18
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: ETLDeviceSim.cc:24
float tofDelay_
Definition: ETLDeviceSim.h:42
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:15
int module() const
Definition: ETLDetId.h:50
T get() const
Definition: EventSetup.h:68
col
Definition: cuy.py:1010
float MIPPerMeV_
Definition: ETLDeviceSim.h:40
T const * product() const
Definition: ESHandle.h:84
ETLDeviceSim(const edm::ParameterSet &pset)
Definition: ETLDeviceSim.cc:10