CMS 3D CMS Logo

BTLTileDeviceSim.cc
Go to the documentation of this file.
5 
10 
11 #include "CLHEP/Random/RandGaussQ.h"
12 
14  geom_(nullptr),
15  bxTime_(pset.getParameter<double>("bxTime") ),
16  LightYield_(pset.getParameter<double>("LightYield")),
17  LightCollEff_(pset.getParameter<double>("LightCollectionEff")),
18  LightCollTime_(pset.getParameter<double>("LightCollectionTime")),
19  smearLightCollTime_(pset.getParameter<double>("smearLightCollectionTime")),
20  PDE_(pset.getParameter<double>("PhotonDetectionEff")) { }
21 
23 
25  evs.get<MTDDigiGeometryRecord>().get(geom);
26  geom_ = geom.product();
27 
28 }
29 
30 void BTLTileDeviceSim::getHitsResponse(const std::vector<std::tuple<int,uint32_t,float> > &hitRefs,
32  mtd_digitizer::MTDSimHitDataAccumulator *simHitAccumulator,
33  CLHEP::HepRandomEngine *hre){
34 
35  //loop over sorted simHits
36  for (auto const& hitRef: hitRefs) {
37 
38  const int hitidx = std::get<0>(hitRef);
39  const uint32_t id = std::get<1>(hitRef);
40  const MTDDetId detId(id);
41  const PSimHit &hit = hits->at( hitidx );
42 
43  // --- Safety check on the detector ID
44  if ( detId.det()!=DetId::Forward || detId.mtdSubDetector()!=1 ) continue;
45 
46  if(id==0) continue; // to be ignored at RECO level
47 
48  BTLDetId btlid(detId);
49  const int boundRef = BTLDetId::kTypeBoundariesReference[1];
50  DetId geoId = BTLDetId(btlid.mtdSide(),btlid.mtdRR(),btlid.module()+boundRef*(btlid.modType()-1),0,1);
51  const MTDGeomDet* thedet = geom_->idToDet(geoId);
52 
53  if( thedet == nullptr ) {
54  throw cms::Exception("BTLTileDeviceSim") << "GeographicalID: " << std::hex
55  << geoId.rawId()
56  << " (" << detId.rawId()<< ") is invalid!" << std::dec
57  << std::endl;
58  }
59  const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology());
60  const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());
61  // calculate the simhit row and column
62  const auto& pentry = hit.entryPoint();
63  Local3DPoint simscaled(0.1*pentry.x(),0.1*pentry.y(),0.1*pentry.z()); // mm -> cm here is the switch
64  // translate from crystal-local coordinates to module-local coordinates to get the row and column
65  simscaled = topo.pixelToModuleLocalPoint(simscaled,btlid.row(topo.nrows()),btlid.column(topo.nrows()));
66  const auto& thepixel = topo.pixel(simscaled);
67  uint8_t row(thepixel.first), col(thepixel.second);
68 
69  if( btlid.row(topo.nrows()) != row || btlid.column(topo.nrows()) != col ) {
70  edm::LogWarning("BTLTileDeviceSim")
71  << "BTLDetId (row,column): (" << btlid.row(topo.nrows()) << ',' << btlid.column(topo.nrows()) <<") is not equal to "
72  << "topology (row,column): (" << uint32_t(row) << ',' << uint32_t(col) <<"), overriding to detid";
73  row = btlid.row(topo.nrows());
74  col = btlid.column(topo.nrows());
75  }
76 
77 
78  // --- Store the detector element ID as a key of the MTDSimHitDataAccumulator map
79  auto simHitIt = simHitAccumulator->emplace(mtd_digitizer::MTDCellId(id,row,col),
81 
82  // --- Get the simHit energy and convert it from MeV to photo-electrons
83  float Npe = 1000.*hit.energyLoss()*LightYield_*LightCollEff_*PDE_;
84 
85  // --- Get the simHit time of arrival and add the light collection time
86  float toa = std::get<2>(hitRef) + LightCollTime_;
87 
88  if ( smearLightCollTime_ > 0. )
89  toa += CLHEP::RandGaussQ::shoot(hre, 0., smearLightCollTime_);
90 
91  if ( toa > bxTime_ || toa < 0 ) //just consider BX==0
92  continue;
93 
94  (simHitIt->second).hit_info[0][0] += Npe;
95 
96  // --- Store the time of the first SimHit
97  if( (simHitIt->second).hit_info[1][0] == 0 ||
98  toa < (simHitIt->second).hit_info[1][0]
99  )
100  (simHitIt->second).hit_info[1][0] = toa;
101 
102  } // hitRef loop
103 }
const float LightCollTime_
virtual const Topology & topology() const
Definition: GeomDet.cc:81
void getEventSetup(const edm::EventSetup &evt)
static constexpr std::array< int, 4 > kTypeBoundariesReference
Definition: BTLDetId.h:33
#define nullptr
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
const float LightCollEff_
std::unordered_map< MTDCellId, MTDCellInfo > MTDSimHitDataAccumulator
int nrows() const override
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21
const MTDGeomDet * idToDet(DetId) const override
Definition: MTDGeometry.cc:184
const float LightYield_
virtual const PixelTopology & specificTopology() const
const float bxTime_
std::pair< float, float > pixel(const LocalPoint &p) const override
LocalPoint pixelToModuleLocalPoint(const LocalPoint &plp, int row, int col) const
int mtdRR() const
Definition: MTDDetId.h:66
int mtdSide() const
Definition: MTDDetId.h:61
Definition: DetId.h:18
const float smearLightCollTime_
int module() const
Definition: BTLDetId.h:96
float energyLoss() const
The energy deposit in the PSimHit, in ???.
Definition: PSimHit.h:79
T get() const
Definition: EventSetup.h:71
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
Definition: BTLDetId.h:18
col
Definition: cuy.py:1010
int column(unsigned nrows=16) const
Definition: BTLDetId.h:110
BTLTileDeviceSim(const edm::ParameterSet &pset)
T const * product() const
Definition: ESHandle.h:86
const MTDGeometry * geom_
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Definition: PSimHit.h:43
int modType() const
Definition: BTLDetId.h:99
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)
int row(unsigned nrows=16) const
Definition: BTLDetId.h:105