CMS 3D CMS Logo

BTLDeviceSim.cc
Go to the documentation of this file.
5 
11 
12 #include "CLHEP/Random/RandGaussQ.h"
13 
15  : geom_(nullptr),
16  topo_(nullptr),
17  bxTime_(pset.getParameter<double>("bxTime")),
18  LightYield_(pset.getParameter<double>("LightYield")),
19  LightCollEff_(pset.getParameter<double>("LightCollectionEff")),
20  LightCollSlopeR_(pset.getParameter<double>("LightCollectionSlopeR")),
21  LightCollSlopeL_(pset.getParameter<double>("LightCollectionSlopeL")),
22  PDE_(pset.getParameter<double>("PhotonDetectionEff")) {}
23 
27  geom_ = geom.product();
28 
30  evs.get<MTDTopologyRcd>().get(mtdTopo);
31  topo_ = mtdTopo.product();
32 }
33 
34 void BTLDeviceSim::getHitsResponse(const std::vector<std::tuple<int, uint32_t, float> >& hitRefs,
36  mtd_digitizer::MTDSimHitDataAccumulator* simHitAccumulator,
37  CLHEP::HepRandomEngine* hre) {
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  DetId geoId = BTLDetId(btlid.mtdSide(), btlid.mtdRR(), btlid.module() + boundRef * (btlid.modType() - 1), 0, 1);
55  const MTDGeomDet* thedet = geom_->idToDet(geoId);
56 
57  if (thedet == nullptr) {
58  throw cms::Exception("BTLDeviceSim") << "GeographicalID: " << std::hex << geoId.rawId() << " (" << detId.rawId()
59  << ") is invalid!" << std::dec << std::endl;
60  }
61  const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology());
62  const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());
63  // calculate the simhit row and column
64  const auto& pentry = hit.entryPoint();
65  Local3DPoint simscaled(0.1 * pentry.x(), 0.1 * pentry.y(), 0.1 * pentry.z()); // mm -> cm here is the switch
66  // translate from crystal-local coordinates to module-local coordinates to get the row and column
67  simscaled = topo.pixelToModuleLocalPoint(simscaled, btlid.row(topo.nrows()), btlid.column(topo.nrows()));
68  const auto& thepixel = topo.pixel(simscaled);
69  uint8_t row(thepixel.first), col(thepixel.second);
70 
71  if (btlid.row(topo.nrows()) != row || btlid.column(topo.nrows()) != col) {
72  edm::LogWarning("BTLDeviceSim") << "BTLDetId (row,column): (" << btlid.row(topo.nrows()) << ','
73  << btlid.column(topo.nrows()) << ") is not equal to "
74  << "topology (row,column): (" << uint32_t(row) << ',' << uint32_t(col)
75  << "), overriding to detid";
76  row = btlid.row(topo.nrows());
77  col = btlid.column(topo.nrows());
78  }
79 
80  // --- Store the detector element ID as a key of the MTDSimHitDataAccumulator map
81  auto simHitIt =
82  simHitAccumulator->emplace(mtd_digitizer::MTDCellId(id, row, col), mtd_digitizer::MTDCellInfo()).first;
83 
84  // --- Get the simHit energy and convert it from MeV to photo-electrons
85  float Npe = 1000. * hit.energyLoss() * LightYield_ * LightCollEff_ * PDE_;
86 
87  // --- Calculate the light propagation time to the crystal bases (labeled L and R)
88  double distR = 0.5 * topo.pitch().second - 0.1 * hit.localPosition().y();
89  double distL = 0.5 * topo.pitch().second + 0.1 * hit.localPosition().y();
90 
91  // This is for the layouts with bars along phi
94  distR = 0.5 * topo.pitch().first - 0.1 * hit.localPosition().x();
95  distL = 0.5 * topo.pitch().first + 0.1 * hit.localPosition().x();
96  }
97 
98  double tR = std::get<2>(hitRef) + LightCollSlopeR_ * distR;
99  double tL = std::get<2>(hitRef) + LightCollSlopeL_ * distL;
100 
101  // --- Accumulate in 15 buckets of 25ns (9 pre-samples, 1 in-time, 5 post-samples)
102  const int iBXR = std::floor(tR / bxTime_) + mtd_digitizer::kInTimeBX;
103  const int iBXL = std::floor(tL / bxTime_) + mtd_digitizer::kInTimeBX;
104 
105  // --- Right side
106  if (iBXR > 0 && iBXR < mtd_digitizer::kNumberOfBX) {
107  // Accumulate the energy of simHits in the same crystal
108  (simHitIt->second).hit_info[0][iBXR] += Npe;
109 
110  // Store the time of the first SimHit in the i-th BX
111  if ((simHitIt->second).hit_info[1][iBXR] == 0 || tR < (simHitIt->second).hit_info[1][iBXR])
112  (simHitIt->second).hit_info[1][iBXR] = tR - (iBXR - mtd_digitizer::kInTimeBX) * bxTime_;
113  }
114 
115  // --- Left side
116  if (iBXL > 0 && iBXL < mtd_digitizer::kNumberOfBX) {
117  // Accumulate the energy of simHits in the same crystal
118  (simHitIt->second).hit_info[2][iBXL] += Npe;
119 
120  // Store the time of the first SimHit in the i-th BX
121  if ((simHitIt->second).hit_info[3][iBXL] == 0 || tL < (simHitIt->second).hit_info[3][iBXL])
122  (simHitIt->second).hit_info[3][iBXL] = tL - (iBXL - mtd_digitizer::kInTimeBX) * bxTime_;
123  }
124 
125  } // hitRef loop
126 }
MTDDigiGeometryRecord
Definition: MTDDigiGeometryRecord.h:15
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
BTLDeviceSim::BTLDeviceSim
BTLDeviceSim(const edm::ParameterSet &pset)
Definition: BTLDeviceSim.cc:14
BTLDeviceSim::LightYield_
const float LightYield_
Definition: BTLDeviceSim.h:41
BTLDeviceSim::geom_
const MTDGeometry * geom_
Definition: BTLDeviceSim.h:37
BTLDetId.h
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
hit::y
double y
Definition: SiStripHitEffFromCalibTree.cc:90
ESHandle.h
BTLDeviceSim.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
BTLDeviceSim::bxTime_
const float bxTime_
Definition: BTLDeviceSim.h:40
GeomDetType.h
ProxyMTDTopology::specificTopology
virtual const PixelTopology & specificTopology() const
Definition: ProxyMTDTopology.h:89
GeomDet::topology
virtual const Topology & topology() const
Definition: GeomDet.cc:67
MTDDetId::mtdRR
int mtdRR() const
Definition: MTDDetId.h:64
MTDTopologyMode.h
edm::Handle< edm::PSimHitContainer >
MTDTopology::getMTDTopologyMode
int getMTDTopologyMode() const
Definition: MTDTopology.h:73
hit::x
double x
Definition: SiStripHitEffFromCalibTree.cc:89
mtd_digitizer::kNumberOfBX
constexpr int kNumberOfBX
Definition: MTDDigitizerTypes.h:41
DetId
Definition: DetId.h:17
BTLDetId::module
int module() const
Definition: BTLDetId.h:96
MTDGeometry::idToDet
const MTDGeomDet * idToDet(DetId) const override
Definition: MTDGeometry.cc:171
BTLDetId
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0,...
Definition: BTLDetId.h:18
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
BTLDeviceSim::LightCollSlopeR_
const float LightCollSlopeR_
Definition: BTLDeviceSim.h:44
BTLDeviceSim::topo_
const MTDTopology * topo_
Definition: BTLDeviceSim.h:38
BTLDetId::modulesPerType
int modulesPerType(CrysLayout lay) const
Definition: BTLDetId.cc:161
BTLDetId::row
int row(unsigned nrows=16) const
Definition: BTLDetId.h:105
BTLDeviceSim::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: BTLDeviceSim.cc:34
edm::ESHandle
Definition: DTSurvey.h:22
RectangularMTDTopology.h
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
BTLDetId::CrysLayout::barphiflat
Point3DBase< float, LocalTag >
edm::LogWarning
Definition: MessageLogger.h:141
MTDDetId::mtdSubDetector
int mtdSubDetector() const
Definition: MTDDetId.h:56
edm::ParameterSet
Definition: ParameterSet.h:36
BTLDetId::modType
int modType() const
Definition: BTLDetId.h:99
MTDTopologyRcd
Definition: MTDTopologyRcd.h:10
MTDTopologyMode::crysLayoutFromTopoMode
BTLDetId::CrysLayout crysLayoutFromTopoMode(const int &topoMode)
Definition: MTDTopologyMode.h:19
MTDDetId.h
BTLDetId::CrysLayout::bar
mtd_digitizer::MTDCellId
Definition: MTDDigitizerTypes.h:26
edm::EventSetup
Definition: EventSetup.h:57
BTLDeviceSim::LightCollSlopeL_
const float LightCollSlopeL_
Definition: BTLDeviceSim.h:45
get
#define get
BTLDeviceSim::getEventSetup
void getEventSetup(const edm::EventSetup &evt)
Definition: BTLDeviceSim.cc:24
RectangularMTDTopology
Definition: RectangularMTDTopology.h:39
ProxyMTDTopology
Definition: ProxyMTDTopology.h:28
ProxyMTDTopology.h
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
MTDDetId
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21
Exception
Definition: hltDiff.cc:246
mtd_digitizer::MTDSimHitDataAccumulator
std::unordered_map< MTDCellId, MTDCellInfo > MTDSimHitDataAccumulator
Definition: MTDDigitizerTypes.h:39
BTLDeviceSim::LightCollEff_
const float LightCollEff_
Definition: BTLDeviceSim.h:42
PSimHit
Definition: PSimHit.h:15
DetId::Forward
Definition: DetId.h:30
mtd_digitizer::kInTimeBX
constexpr int kInTimeBX
Definition: MTDDigitizerTypes.h:42
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
BTLDeviceSim::PDE_
const float PDE_
Definition: BTLDeviceSim.h:46
hit
Definition: SiStripHitEffFromCalibTree.cc:88
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
BTLDetId::column
int column(unsigned nrows=16) const
Definition: BTLDetId.h:110