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