CMS 3D CMS Logo

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

#include <BTLDeviceSim.h>

Public Member Functions

 BTLDeviceSim (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

const float bxTime_
 
const MTDGeometrygeom_
 
const edm::ESGetToken< MTDGeometry, MTDDigiGeometryRecordgeomToken_
 
const float LCEpositionSlope_
 
const float LightCollEff_
 
const float LightCollSlope_
 
const float LightYield_
 
const float PDE_
 
const MTDTopologytopo_
 
const edm::ESGetToken< MTDTopology, MTDTopologyRcdtopoToken_
 

Detailed Description

Definition at line 23 of file BTLDeviceSim.h.

Constructor & Destructor Documentation

◆ BTLDeviceSim()

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

Definition at line 15 of file BTLDeviceSim.cc.

16  : geomToken_(iC.esConsumes()),
17  topoToken_(iC.esConsumes()),
18  geom_(nullptr),
19  topo_(nullptr),
20  bxTime_(pset.getParameter<double>("bxTime")),
21  LightYield_(pset.getParameter<double>("LightYield")),
22  LightCollEff_(pset.getParameter<double>("LightCollectionEff")),
23  LightCollSlope_(pset.getParameter<double>("LightCollectionSlope")),
24  PDE_(pset.getParameter<double>("PhotonDetectionEff")),
25  LCEpositionSlope_(pset.getParameter<double>("LCEpositionSlope")) {}
const float LightYield_
Definition: BTLDeviceSim.h:43
const MTDTopology * topo_
Definition: BTLDeviceSim.h:40
const MTDGeometry * geom_
Definition: BTLDeviceSim.h:39
const edm::ESGetToken< MTDGeometry, MTDDigiGeometryRecord > geomToken_
Definition: BTLDeviceSim.h:37
const float LightCollSlope_
Definition: BTLDeviceSim.h:46
const float bxTime_
Definition: BTLDeviceSim.h:42
const edm::ESGetToken< MTDTopology, MTDTopologyRcd > topoToken_
Definition: BTLDeviceSim.h:38
const float LCEpositionSlope_
Definition: BTLDeviceSim.h:48
const float PDE_
Definition: BTLDeviceSim.h:47
const float LightCollEff_
Definition: BTLDeviceSim.h:44

Member Function Documentation

◆ getEvent()

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

Definition at line 27 of file BTLDeviceSim.h.

27 {}

◆ getEventSetup()

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

Definition at line 27 of file BTLDeviceSim.cc.

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

27  {
28  geom_ = &evs.getData(geomToken_);
29  topo_ = &evs.getData(topoToken_);
30 }
const MTDTopology * topo_
Definition: BTLDeviceSim.h:40
const MTDGeometry * geom_
Definition: BTLDeviceSim.h:39
const edm::ESGetToken< MTDGeometry, MTDDigiGeometryRecord > geomToken_
Definition: BTLDeviceSim.h:37
const edm::ESGetToken< MTDTopology, MTDTopologyRcd > topoToken_
Definition: BTLDeviceSim.h:38

◆ getHitsResponse()

void BTLDeviceSim::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 32 of file BTLDeviceSim.cc.

References bxTime_, cuy::col, BTLDetId::column(), angle_units::operators::convertGeVToMeV(), angle_units::operators::convertMmToCm(), MTDTopologyMode::crysLayoutFromTopoMode(), TauDecayModes::dec, hcalRecHitTable_cff::detId, Exception, DetId::Forward, BTLDetId::geographicalId(), geom_, MTDTopology::getMTDTopologyMode(), hfClusterShapes_cfi::hits, MTDGeometry::idToDet(), mtd_digitizer::kInTimeBX, mtd_digitizer::kNumberOfBX, LCEpositionSlope_, LightCollEff_, LightCollSlope_, LightYield_, RectangularMTDTopology::nrows(), PDE_, RectangularMTDTopology::pitch(), RectangularMTDTopology::pixelIndex(), RectangularMTDTopology::pixelToModuleLocalPoint(), position, DetId::rawId(), BTLDetId::row(), ProxyMTDTopology::specificTopology(), topo_, GeomDet::topology(), and hit::x.

35  {
36  using namespace geant_units::operators;
37 
38  //loop over sorted simHits
39  for (auto const& hitRef : hitRefs) {
40  const int hitidx = std::get<0>(hitRef);
41  const uint32_t id = std::get<1>(hitRef);
42  const MTDDetId detId(id);
43  const PSimHit& hit = hits->at(hitidx);
44 
45  // --- Safety check on the detector ID
46  if (detId.det() != DetId::Forward || detId.mtdSubDetector() != 1)
47  continue;
48 
49  if (id == 0)
50  continue; // to be ignored at RECO level
51 
52  BTLDetId btlid(detId);
54  const MTDGeomDet* thedet = geom_->idToDet(geoId);
55 
56  if (thedet == nullptr) {
57  throw cms::Exception("BTLDeviceSim") << "GeographicalID: " << std::hex << geoId.rawId() << " (" << detId.rawId()
58  << ") is invalid!" << std::dec << std::endl;
59  }
60  const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology());
61  const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());
62  // calculate the simhit row and column
63  const auto& position = hit.localPosition();
65  // translate from crystal-local coordinates to module-local coordinates to get the row and column
66  simscaled = topo.pixelToModuleLocalPoint(simscaled, btlid.row(topo.nrows()), btlid.column(topo.nrows()));
67 
68  const auto& thepixel = topo.pixelIndex(simscaled);
69  uint8_t row = static_cast<uint8_t>(thepixel.first);
70  uint8_t col = static_cast<uint8_t>(thepixel.second);
71 
72  if (btlid.row(topo.nrows()) != row || btlid.column(topo.nrows()) != col) {
73  edm::LogWarning("BTLDeviceSim") << "BTLDetId (row,column): (" << btlid.row(topo.nrows()) << ','
74  << btlid.column(topo.nrows()) << ") is not equal to "
75  << "topology (row,column): (" << uint32_t(row) << ',' << uint32_t(col)
76  << "), overriding to detid";
77  row = btlid.row(topo.nrows());
78  col = btlid.column(topo.nrows());
79  }
80 
81  // --- Store the detector element ID as a key of the MTDSimHitDataAccumulator map
82  auto simHitIt =
83  simHitAccumulator->emplace(mtd_digitizer::MTDCellId(id, row, col), mtd_digitizer::MTDCellInfo()).first;
84 
85  // --- Get the simHit energy and convert it from MeV to photo-electrons
86  float Npe = convertGeVToMeV(hit.energyLoss()) * LightYield_ * LightCollEff_ * PDE_;
87 
88  // --- Calculate the light propagation time to the crystal bases (labeled L and R)
89  double distR = 0.5 * topo.pitch().first - convertMmToCm(hit.localPosition().x());
90  double distL = 0.5 * topo.pitch().first + convertMmToCm(hit.localPosition().x());
91 
92  double tR = std::get<2>(hitRef) + LightCollSlope_ * distR;
93  double tL = std::get<2>(hitRef) + LightCollSlope_ * distL;
94 
95  // --- Accumulate in 15 buckets of 25ns (9 pre-samples, 1 in-time, 5 post-samples)
96  const int iBXR = std::floor(tR / bxTime_) + mtd_digitizer::kInTimeBX;
97  const int iBXL = std::floor(tL / bxTime_) + mtd_digitizer::kInTimeBX;
98 
99  // --- Right side
100  if (iBXR > 0 && iBXR < mtd_digitizer::kNumberOfBX) {
101  // Accumulate the energy of simHits in the same crystal
102  (simHitIt->second).hit_info[0][iBXR] += Npe * (1. + LCEpositionSlope_ * convertMmToCm(hit.localPosition().x()));
103 
104  // Store the time of the first SimHit in the i-th BX
105  if ((simHitIt->second).hit_info[1][iBXR] == 0 || tR < (simHitIt->second).hit_info[1][iBXR])
106  (simHitIt->second).hit_info[1][iBXR] = tR - (iBXR - mtd_digitizer::kInTimeBX) * bxTime_;
107  }
108 
109  // --- Left side
110  if (iBXL > 0 && iBXL < mtd_digitizer::kNumberOfBX) {
111  // Accumulate the energy of simHits in the same crystal
112  (simHitIt->second).hit_info[2][iBXL] += Npe * (1. - LCEpositionSlope_ * convertMmToCm(hit.localPosition().x()));
113 
114  // Store the time of the first SimHit in the i-th BX
115  if ((simHitIt->second).hit_info[3][iBXL] == 0 || tL < (simHitIt->second).hit_info[3][iBXL])
116  (simHitIt->second).hit_info[3][iBXL] = tL - (iBXL - mtd_digitizer::kInTimeBX) * bxTime_;
117  }
118 
119  } // hitRef loop
120 }
int getMTDTopologyMode() const
Definition: MTDTopology.h:27
const float LightYield_
Definition: BTLDeviceSim.h:43
virtual const Topology & topology() const
Definition: GeomDet.cc:67
const MTDTopology * topo_
Definition: BTLDeviceSim.h:40
virtual const PixelTopology & specificTopology() const
const MTDGeometry * geom_
Definition: BTLDeviceSim.h:39
const float LightCollSlope_
Definition: BTLDeviceSim.h:46
LocalPoint pixelToModuleLocalPoint(const LocalPoint &plp, int row, int col) const
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21
constexpr NumType convertGeVToMeV(NumType gev)
Definition: angle_units.h:74
const MTDGeomDet * idToDet(DetId) const override
Definition: MTDGeometry.cc:171
const float bxTime_
Definition: BTLDeviceSim.h:42
int nrows() const override
Definition: DetId.h:17
const float LCEpositionSlope_
Definition: BTLDeviceSim.h:48
constexpr NumType convertMmToCm(NumType millimeters)
Definition: angle_units.h:44
const float PDE_
Definition: BTLDeviceSim.h:47
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
constexpr int kInTimeBX
std::pair< float, float > pitch() const override
static int position[264][3]
Definition: ReadPGInfo.cc:289
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
Definition: BTLDetId.h:19
col
Definition: cuy.py:1009
std::pair< int, int > pixelIndex(const LocalPoint &p) const
BTLDetId::CrysLayout crysLayoutFromTopoMode(const int &topoMode)
const float LightCollEff_
Definition: BTLDeviceSim.h:44
Log< level::Warning, false > LogWarning
constexpr int kNumberOfBX

Member Data Documentation

◆ bxTime_

const float BTLDeviceSim::bxTime_
private

Definition at line 42 of file BTLDeviceSim.h.

Referenced by getHitsResponse().

◆ geom_

const MTDGeometry* BTLDeviceSim::geom_
private

Definition at line 39 of file BTLDeviceSim.h.

Referenced by getEventSetup(), and getHitsResponse().

◆ geomToken_

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

Definition at line 37 of file BTLDeviceSim.h.

Referenced by getEventSetup().

◆ LCEpositionSlope_

const float BTLDeviceSim::LCEpositionSlope_
private

Definition at line 48 of file BTLDeviceSim.h.

Referenced by getHitsResponse().

◆ LightCollEff_

const float BTLDeviceSim::LightCollEff_
private

Definition at line 44 of file BTLDeviceSim.h.

Referenced by getHitsResponse().

◆ LightCollSlope_

const float BTLDeviceSim::LightCollSlope_
private

Definition at line 46 of file BTLDeviceSim.h.

Referenced by getHitsResponse().

◆ LightYield_

const float BTLDeviceSim::LightYield_
private

Definition at line 43 of file BTLDeviceSim.h.

Referenced by getHitsResponse().

◆ PDE_

const float BTLDeviceSim::PDE_
private

Definition at line 47 of file BTLDeviceSim.h.

Referenced by getHitsResponse().

◆ topo_

const MTDTopology* BTLDeviceSim::topo_
private

Definition at line 40 of file BTLDeviceSim.h.

Referenced by getEventSetup(), and getHitsResponse().

◆ topoToken_

const edm::ESGetToken<MTDTopology, MTDTopologyRcd> BTLDeviceSim::topoToken_
private

Definition at line 38 of file BTLDeviceSim.h.

Referenced by getEventSetup().