40 #include "CLHEP/Geometry/Point3D.h"
41 #include "CLHEP/Geometry/Transform3D.h"
42 #include "CLHEP/Geometry/Vector3D.h"
43 #include "CLHEP/Units/GlobalSystemOfUnits.h"
44 #include "CLHEP/Units/GlobalPhysicalConstants.h"
79 std::vector<const HGCalDDDConstants*>
hgcons_;
82 std::vector<edm::EDGetTokenT<edm::PCaloHitContainer> >
tok_hits_;
92 : nameDetectors_(iConfig.getParameter<
std::vector<
std::
string> >(
"detectorNames")),
93 caloHitSources_(iConfig.getParameter<
std::vector<
std::
string> >(
"caloHitSources")),
94 rmin_(iConfig.getUntrackedParameter<double>(
"rMin", 0.0)),
95 rmax_(iConfig.getUntrackedParameter<double>(
"rMax", 3000.0)),
96 zmin_(iConfig.getUntrackedParameter<double>(
"zMin", 3000.0)),
97 zmax_(iConfig.getUntrackedParameter<double>(
"zMax", 6000.0)),
98 etamin_(iConfig.getUntrackedParameter<double>(
"etaMin", 1.0)),
99 etamax_(iConfig.getUntrackedParameter<double>(
"etaMax", 3.0)),
100 nbinR_(iConfig.getUntrackedParameter<
int>(
"nBinR", 300)),
101 nbinZ_(iConfig.getUntrackedParameter<
int>(
"nBinZ", 300)),
102 nbinEta_(iConfig.getUntrackedParameter<
int>(
"nBinEta", 200)),
103 nLayers_(iConfig.getUntrackedParameter<
int>(
"layers", 50)),
104 verbosity_(iConfig.getUntrackedParameter<
int>(
"verbosity", 0)),
105 ifNose_(iConfig.getUntrackedParameter<
bool>(
"ifNose",
false)),
106 ifLayer_(iConfig.getUntrackedParameter<
bool>(
"ifLayer",
false)) {
122 std::vector<std::string>
names = {
"HGCalEESensitive",
"HGCalHESiliconSensitive",
"Hcal"};
123 std::vector<std::string>
sources = {
"HGCHitsEE",
"HGCHitsHEfront",
"HcalHits"};
124 desc.
add<std::vector<std::string> >(
"detectorNames",
names);
125 desc.
add<std::vector<std::string> >(
"caloHitSources",
sources);
139 descriptions.
add(
"hgcalSimHitStudy", desc);
147 if (theCaloHitContainers.
isValid()) {
149 edm::LogVerbatim(
"HGCalValidation") <<
" PcalohitItr = " << theCaloHitContainers->size();
150 std::vector<PCaloHit> caloHits;
152 for (
auto const&
hit : *(theCaloHitContainers.
product())) {
153 unsigned int id =
hit.
id();
156 caloHits.emplace_back(
hit);
157 caloHits.back().setID(hid.
rawId());
159 edm::LogVerbatim(
"HGCalValidation") <<
"Hit[" << caloHits.size() <<
"] " << hid;
163 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), theCaloHitContainers->end());
177 std::map<uint32_t, hitsinfo> map_hits;
180 unsigned int nused(0);
184 uint32_t
id =
hit.
id();
187 HepGeom::Point3D<float> gcoord;
192 sector = detId.
iphi();
193 layer = detId.
depth();
198 edm::LogVerbatim(
"HGCalValidation") <<
"i/p " << subdet <<
":" <<
zside <<
":" << cell <<
":" << sector <<
":"
199 << layer <<
" o/p " <<
etaphi.first <<
":" <<
etaphi.second <<
":" << rz;
200 gcoord = HepGeom::Point3D<float>(rz *
cos(
etaphi.second) / cosh(
etaphi.first),
204 std::pair<float, float>
xy;
208 cell = detId.
cellU();
213 layer = detId.
layer();
222 subdet = static_cast<int>(detId.
det());
223 cell = detId.
cellU();
228 layer = detId.
layer();
235 subdet = static_cast<int>(detId.
det());
236 sector = detId.
ieta();
239 layer = detId.
layer();
241 xy =
hgcons_[ih]->locateCellTrap(layer, sector, cell,
false);
244 xy =
hgcons_[ih]->locateCell(cell, layer, sector,
false);
246 double zp =
hgcons_[ih]->waferZ(layer,
false);
249 double xp = (zp < 0) ? -
xy.first :
xy.first;
250 gcoord = HepGeom::Point3D<float>(xp,
xy.second, zp);
253 <<
"i/p " << subdet <<
":" <<
zside <<
":" << layer <<
":" << sector <<
":" <<
sector2 <<
":" << cell <<
":"
254 <<
cell2 <<
" o/p " <<
xy.first <<
":" <<
xy.second <<
":" << zp;
257 double tof = (gcoord.mag() * CLHEP::mm) / CLHEP::c_light;
260 <<
"Detector " <<
name <<
" zside = " <<
zside <<
" layer = " << layer <<
" type = " <<
type
261 <<
" wafer = " << sector <<
":" <<
sector2 <<
" cell = " << cell <<
":" <<
cell2 <<
" positon = " << gcoord
262 <<
" energy = " <<
energy <<
" time = " <<
time <<
":" << tof;
267 if (map_hits.count(
id) != 0) {
271 hinfo.phi = gcoord.getPhi();
272 hinfo.eta = gcoord.getEta();
282 if (
hinfo.layer <= static_cast<int>(
h_XY_.size()))
283 h_XY_[
hinfo.layer - 1]->Fill(gcoord.x(), gcoord.y());
288 h_Ly_[ih]->Fill(layer);
289 h_W1_[ih]->Fill(sector);
290 h_C1_[ih]->Fill(cell);
293 edm::LogVerbatim(
"HGCalValidation") <<
name <<
" with " << map_hits.size() <<
":" << nused <<
" detector elements"
296 for (
auto const&
hit : map_hits) {
300 <<
" ---------------------- eta = " <<
hinfo.eta <<
" phi = " <<
hinfo.phi <<
" layer = " <<
hinfo.layer
301 <<
" E = " <<
hinfo.energy <<
" T = " <<
hinfo.time;
337 hgcons_.emplace_back(&(*pHGDC));
358 name <<
"RZ_AllDetectors";
359 title <<
"R vs Z for All Detectors";
368 for (
int ly = 0; ly <
nLayers_; ++ly) {
371 name <<
"XY_L" << (ly + 1);
372 title <<
"Y vs X at Layer " << (ly + 1);
381 name <<
"EtaPhi_AllDetectors";
382 title <<
"#phi vs #eta for All Detectors";
392 name <<
"EtFiZp_AllDetectors";
393 title <<
"#phi vs #eta (+z) for All Detectors";
403 name <<
"EtFiZm_AllDetectors";
404 title <<
"#phi vs #eta (-z) for All Detectors";
415 name <<
"LayerZp_AllDetectors";
416 title <<
"Energy vs Layer (+z) for All Detectors";
425 name <<
"LayerZm_AllDetectors";
426 title <<
"Energy vs Layer (-z) for All Detectors";
436 name <<
"E_AllDetectors";
437 title <<
"Energy Deposit for All Detectors";
442 h_E_.emplace_back(fs->
make<TH1D>(
name.str().c_str(),
title.str().c_str(), 1000, 0.0, 1.0));
447 name <<
"T_AllDetectors";
448 title <<
"Time for All Detectors";
453 h_T_.emplace_back(fs->
make<TH1D>(
name.str().c_str(),
title.str().c_str(), 1000, 0.0, 200.0));
461 h_Ly_.emplace_back(fs->
make<TH1D>(
name.str().c_str(),
title.str().c_str(), 200, 0, 100));
467 h_W1_.emplace_back(fs->
make<TH1D>(
name.str().c_str(),
title.str().c_str(), 200, -50, 50));
472 h_C1_.emplace_back(fs->
make<TH1D>(
name.str().c_str(),
title.str().c_str(), 720, 0, 360));
478 h_W1_.emplace_back(fs->
make<TH1D>(
name.str().c_str(),
title.str().c_str(), 200, -50, 50));
483 h_W2_.emplace_back(fs->
make<TH1D>(
name.str().c_str(),
title.str().c_str(), 100, -50, 50));
488 h_C1_.emplace_back(fs->
make<TH1D>(
name.str().c_str(),
title.str().c_str(), 100, 0, 50));
493 h_C2_.emplace_back(fs->
make<TH1D>(
name.str().c_str(),
title.str().c_str(), 100, 0, 50));