CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
ETLDeviceSim Class Reference

#include <ETLDeviceSim.h>

Public Member Functions

 ETLDeviceSim (const edm::ParameterSet &pset, edm::ConsumesCollector iC)
 
void getEvent (const edm::Event &evt)
 
void getEventSetup (const edm::EventSetup &evt)
 
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)
 

Private Attributes

float bxTime_
 
const MTDGeometrygeom_
 
const edm::ESGetToken< MTDGeometry, MTDDigiGeometryRecordgeomToken_
 
float MIPPerMeV_
 
float tofDelay_
 

Detailed Description

Definition at line 21 of file ETLDeviceSim.h.

Constructor & Destructor Documentation

◆ ETLDeviceSim()

ETLDeviceSim::ETLDeviceSim ( const edm::ParameterSet pset,
edm::ConsumesCollector  iC 
)

Definition at line 15 of file ETLDeviceSim.cc.

16  : geomToken_(iC.esConsumes()),
17  geom_(nullptr),
18  MIPPerMeV_(1.0 / pset.getParameter<double>("meVPerMIP")),
19  bxTime_(pset.getParameter<double>("bxTime")),
20  tofDelay_(pset.getParameter<double>("tofDelay")) {}
const MTDGeometry * geom_
Definition: ETLDeviceSim.h:36
const edm::ESGetToken< MTDGeometry, MTDDigiGeometryRecord > geomToken_
Definition: ETLDeviceSim.h:35
float tofDelay_
Definition: ETLDeviceSim.h:40
float MIPPerMeV_
Definition: ETLDeviceSim.h:38

Member Function Documentation

◆ getEvent()

void ETLDeviceSim::getEvent ( const edm::Event evt)
inline

Definition at line 25 of file ETLDeviceSim.h.

25 {}

◆ getEventSetup()

void ETLDeviceSim::getEventSetup ( const edm::EventSetup evt)

Definition at line 22 of file ETLDeviceSim.cc.

References geom_, geomToken_, and edm::EventSetup::getData().

22 { geom_ = &evs.getData(geomToken_); }
const MTDGeometry * geom_
Definition: ETLDeviceSim.h:36
const edm::ESGetToken< MTDGeometry, MTDDigiGeometryRecord > geomToken_
Definition: ETLDeviceSim.h:35

◆ getHitsResponse()

void ETLDeviceSim::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 at line 24 of file ETLDeviceSim.cc.

References bxTime_, ALCARECOTkAlJpsiMuMu_cff::charge, cuy::col, angle_units::operators::convertGeVToMeV(), angle_units::operators::convertMmToCm(), TauDecayModes::dec, hcalRecHitTable_cff::detId, Exception, DetId::Forward, geom_, hfClusterShapes_cfi::hits, mps_fire::i, MTDGeometry::idToDet(), RectangularMTDTopology::isInPixel(), LogDebug, LogTrace, MIPPerMeV_, RectangularMTDTopology::pixel(), position, DetId::rawId(), ProxyMTDTopology::specificTopology(), tofDelay_, and GeomDet::topology().

27  {
28  using namespace geant_units::operators;
29 
30  //loop over sorted hits
31  const int nchits = hitRefs.size();
32  LogTrace("ETLDeviceSim") << "Processing " << nchits << " SIM hits";
33  for (int i = 0; i < nchits; ++i) {
34  const int hitidx = std::get<0>(hitRefs[i]);
35  const uint32_t id = std::get<1>(hitRefs[i]);
36  const MTDDetId detId(id);
37 
38  // Safety check (this should never happen, it should be an exception
39  if (detId.det() != DetId::Forward || detId.mtdSubDetector() != 2) {
40  throw cms::Exception("ETLDeviceSim")
41  << "got a DetId that was not ETL: Det = " << detId.det() << " subDet = " << detId.mtdSubDetector();
42  }
43 
44  if (id == 0)
45  continue; // to be ignored at RECO level
46 
47  ETLDetId etlid(detId);
48  DetId geoId = ETLDetId(etlid);
49  const MTDGeomDet* thedet = geom_->idToDet(geoId);
50  if (thedet == nullptr) {
51  throw cms::Exception("ETLDeviceSim") << "GeographicalID: " << std::hex << geoId.rawId() << " (" << detId.rawId()
52  << ") is invalid!" << std::dec << std::endl;
53  }
54  const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology());
55  const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());
56 
57  const float toa = std::get<2>(hitRefs[i]) + tofDelay_;
58  const PSimHit& hit = hits->at(hitidx);
59  const float charge = convertGeVToMeV(hit.energyLoss()) * MIPPerMeV_;
60 
61  // calculate the simhit row and column
62  const auto& position = hit.localPosition();
63  // ETL is already in module-local coordinates so just scale to cm from mm
65  //The following lines check whether the pixel point is actually out of the active area.
66  //If that is the case it simply ignores the point but in the future some more sophisticated function could be applied.
67  if (!topo.isInPixel(simscaled)) {
68  LogDebug("ETLDeviceSim") << "Skipping hit ouf of pixel # " << hitidx << " DetId " << etlid.rawId() << " tof "
69  << toa;
70  continue;
71  }
72  const auto& thepixel = topo.pixel(simscaled);
73  const uint8_t row(thepixel.first), col(thepixel.second);
74 
75  LogDebug("ETLDeviceSim") << "Processing hit in pixel # " << hitidx << " DetId " << etlid.rawId() << " row/col "
76  << (uint32_t)row << " " << (uint32_t)col << " tof " << toa;
77 
78  auto simHitIt =
79  simHitAccumulator->emplace(mtd_digitizer::MTDCellId(id, row, col), mtd_digitizer::MTDCellInfo()).first;
80 
81  // Accumulate in 15 buckets of 25ns (9 pre-samples, 1 in-time, 5 post-samples)
82  const int itime = std::floor(toa / bxTime_) + 9;
83  if (itime < 0 || itime > 14)
84  continue;
85 
86  // Check if time index is ok and store energy
87  if (itime >= (int)simHitIt->second.hit_info[0].size())
88  continue;
89 
90  (simHitIt->second).hit_info[0][itime] += charge;
91 
92  // Store the time of the first SimHit in the right DataFrame bucket
93  const float tof = toa - (itime - 9) * bxTime_;
94 
95  if ((simHitIt->second).hit_info[1][itime] == 0. || tof < (simHitIt->second).hit_info[1][itime]) {
96  (simHitIt->second).hit_info[1][itime] = tof;
97  }
98  }
99 }
const MTDGeometry * geom_
Definition: ETLDeviceSim.h:36
bool isInPixel(const LocalPoint &p) const
virtual const Topology & topology() const
Definition: GeomDet.cc:67
virtual const PixelTopology & specificTopology() const
#define LogTrace(id)
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21
std::pair< float, float > pixel(const LocalPoint &p) const override
constexpr NumType convertGeVToMeV(NumType gev)
Definition: angle_units.h:74
const MTDGeomDet * idToDet(DetId) const override
Definition: MTDGeometry.cc:171
Definition: DetId.h:17
constexpr NumType convertMmToCm(NumType millimeters)
Definition: angle_units.h:44
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
float tofDelay_
Definition: ETLDeviceSim.h:40
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:16
static int position[264][3]
Definition: ReadPGInfo.cc:289
col
Definition: cuy.py:1009
float MIPPerMeV_
Definition: ETLDeviceSim.h:38
#define LogDebug(id)

Member Data Documentation

◆ bxTime_

float ETLDeviceSim::bxTime_
private

Definition at line 39 of file ETLDeviceSim.h.

Referenced by getHitsResponse().

◆ geom_

const MTDGeometry* ETLDeviceSim::geom_
private

Definition at line 36 of file ETLDeviceSim.h.

Referenced by getEventSetup(), and getHitsResponse().

◆ geomToken_

const edm::ESGetToken<MTDGeometry, MTDDigiGeometryRecord> ETLDeviceSim::geomToken_
private

Definition at line 35 of file ETLDeviceSim.h.

Referenced by getEventSetup().

◆ MIPPerMeV_

float ETLDeviceSim::MIPPerMeV_
private

Definition at line 38 of file ETLDeviceSim.h.

Referenced by getHitsResponse().

◆ tofDelay_

float ETLDeviceSim::tofDelay_
private

Definition at line 40 of file ETLDeviceSim.h.

Referenced by getHitsResponse().