CMS 3D CMS Logo

BTLBarDeviceSim.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 
25 
27  evs.get<MTDDigiGeometryRecord>().get(geom);
28  geom_ = geom.product();
29 
31  evs.get<MTDTopologyRcd>().get(mtdTopo);
32  topo_ = mtdTopo.product();
33 
34 }
35 
36 void BTLBarDeviceSim::getHitsResponse(const std::vector<std::tuple<int,uint32_t,float> > &hitRefs,
38  mtd_digitizer::MTDSimHitDataAccumulator *simHitAccumulator,
39  CLHEP::HepRandomEngine *hre){
40 
41  //loop over sorted simHits
42  for (auto const& hitRef: hitRefs) {
43 
44  const int hitidx = std::get<0>(hitRef);
45  const uint32_t id = std::get<1>(hitRef);
46  const MTDDetId detId(id);
47  const PSimHit &hit = hits->at( hitidx );
48 
49  // --- Safety check on the detector ID
50  if ( detId.det()!=DetId::Forward || detId.mtdSubDetector()!=1 ) continue;
51 
52  if(id==0) continue; // to be ignored at RECO level
53 
54  BTLDetId btlid(detId);
55  const int boundRef = ( topo_->getMTDTopologyMode() == (int ) BTLDetId::CrysLayout::barzflat ?
58  DetId geoId = BTLDetId(btlid.mtdSide(),btlid.mtdRR(),btlid.module()+boundRef*(btlid.modType()-1),0,1);
59  const MTDGeomDet* thedet = geom_->idToDet(geoId);
60 
61  if( thedet == nullptr ) {
62  throw cms::Exception("BTLBarDeviceSim") << "GeographicalID: " << std::hex
63  << geoId.rawId()
64  << " (" << detId.rawId()<< ") is invalid!" << std::dec
65  << std::endl;
66  }
67  const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology());
68  const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());
69  // calculate the simhit row and column
70  const auto& pentry = hit.entryPoint();
71  Local3DPoint simscaled(0.1*pentry.x(),0.1*pentry.y(),0.1*pentry.z()); // mm -> cm here is the switch
72  // translate from crystal-local coordinates to module-local coordinates to get the row and column
73  simscaled = topo.pixelToModuleLocalPoint(simscaled,btlid.row(topo.nrows()),btlid.column(topo.nrows()));
74  const auto& thepixel = topo.pixel(simscaled);
75  uint8_t row(thepixel.first), col(thepixel.second);
76 
77  if( btlid.row(topo.nrows()) != row || btlid.column(topo.nrows()) != col ) {
78  edm::LogWarning("BTLBarDeviceSim")
79  << "BTLDetId (row,column): (" << btlid.row(topo.nrows()) << ',' << btlid.column(topo.nrows()) <<") is not equal to "
80  << "topology (row,column): (" << uint32_t(row) << ',' << uint32_t(col) <<"), overriding to detid";
81  row = btlid.row(topo.nrows());
82  col = btlid.column(topo.nrows());
83  }
84 
85 
86  // --- Store the detector element ID as a key of the MTDSimHitDataAccumulator map
87  auto simHitIt = simHitAccumulator->emplace(mtd_digitizer::MTDCellId(id,row,col),
89 
90  // --- Get the simHit energy and convert it from MeV to photo-electrons
91  float Npe = 1000.*hit.energyLoss()*LightYield_*LightCollEff_*PDE_;
92 
93  // --- Get the simHit time of arrival
94  float toa = std::get<2>(hitRef);
95 
96  if ( toa > bxTime_ || toa < 0 ) //just consider BX==0
97  continue;
98 
99  // --- Accumulate the energy of simHits in the same crystal for the BX==0
100  // this is to simulate the charge integration in a 25 ns window
101  (simHitIt->second).hit_info[0][0] += Npe;
102  (simHitIt->second).hit_info[0][1] += Npe;
103 
104  double distR = 0.5*topo.pitch().second - 0.1*hit.localPosition().y();
105  double distL = 0.5*topo.pitch().second + 0.1*hit.localPosition().y();
106 
107  // This is for the layout with bars along phi
109  distR = 0.5*topo.pitch().first - 0.1*hit.localPosition().x();
110  distL = 0.5*topo.pitch().first + 0.1*hit.localPosition().x();
111  }
112 
113  double tR = toa + LightCollSlopeR_*distR;
114  double tL = toa + LightCollSlopeR_*distL;
115 
116  // --- Store the time of the first SimHit
117  if ( (simHitIt->second).hit_info[1][0] == 0
118  || tR < (simHitIt->second).hit_info[1][0] )
119  (simHitIt->second).hit_info[1][0] = tR;
120 
121  if ( (simHitIt->second).hit_info[1][1] == 0
122  || tL < (simHitIt->second).hit_info[1][1] )
123  (simHitIt->second).hit_info[1][1] = tL;
124 
125  } // hitRef loop
126 
127 }
const float LightCollEff_
BTLBarDeviceSim(const edm::ParameterSet &pset)
virtual const Topology & topology() const
Definition: GeomDet.cc:81
static constexpr std::array< int, 4 > kTypeBoundariesReference
Definition: BTLDetId.h:32
int getMTDTopologyMode() const
Definition: MTDTopology.h:74
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
T y() const
Definition: PV3DBase.h:63
std::unordered_map< MTDCellId, MTDCellInfo > MTDSimHitDataAccumulator
#define nullptr
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 MTDGeometry * geom_
Local3DPoint localPosition() const
Definition: PSimHit.h:44
virtual const PixelTopology & specificTopology() const
const MTDTopology * topo_
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
static constexpr std::array< int, 4 > kTypeBoundariesBarZflat
Definition: BTLDetId.h:33
const float LightYield_
int mtdSide() const
Definition: MTDDetId.h:61
Definition: DetId.h:18
void getEventSetup(const edm::EventSetup &evt)
const float PDE_
int module() const
Definition: BTLDetId.h:89
float energyLoss() const
The energy deposit in the PSimHit, in ???.
Definition: PSimHit.h:75
T get() const
Definition: EventSetup.h:68
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:103
std::pair< float, float > pitch() const override
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)
T x() const
Definition: PV3DBase.h:62
T const * product() const
Definition: ESHandle.h:84
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Definition: PSimHit.h:35
int modType() const
Definition: BTLDetId.h:92
const float LightCollSlopeR_
const float bxTime_
int row(unsigned nrows=16) const
Definition: BTLDetId.h:98