39 #include "CLHEP/Geometry/Point3D.h"
40 #include "CLHEP/Geometry/Transform3D.h"
41 #include "CLHEP/Geometry/Vector3D.h"
42 #include "CLHEP/Units/GlobalSystemOfUnits.h"
43 #include "CLHEP/Units/GlobalPhysicalConstants.h"
79 std::vector<edm::ESGetToken<HGCalDDDConstants, IdealGeometryRecord> >
tok_hgcGeom_;
80 std::vector<const HGCalDDDConstants*>
hgcons_;
83 std::vector<edm::EDGetTokenT<edm::PCaloHitContainer> >
tok_hits_;
95 rmin_(iConfig.getUntrackedParameter<double>(
"rMin", 0.0)),
96 rmax_(iConfig.getUntrackedParameter<double>(
"rMax", 3000.0)),
97 zmin_(iConfig.getUntrackedParameter<double>(
"zMin", 3000.0)),
98 zmax_(iConfig.getUntrackedParameter<double>(
"zMax", 6000.0)),
99 etamin_(iConfig.getUntrackedParameter<double>(
"etaMin", 1.0)),
100 etamax_(iConfig.getUntrackedParameter<double>(
"etaMax", 3.0)),
101 nbinR_(iConfig.getUntrackedParameter<
int>(
"nBinR", 300)),
102 nbinZ_(iConfig.getUntrackedParameter<
int>(
"nBinZ", 300)),
103 nbinEta_(iConfig.getUntrackedParameter<
int>(
"nBinEta", 200)),
104 nLayers_(iConfig.getUntrackedParameter<
int>(
"layers", 50)),
105 verbosity_(iConfig.getUntrackedParameter<
int>(
"verbosity", 0)),
106 ifNose_(iConfig.getUntrackedParameter<
bool>(
"ifNose",
false)),
107 ifLayer_(iConfig.getUntrackedParameter<
bool>(
"ifLayer",
false)) {
111 if (
name ==
"HCal") {
113 tok_hrndc_ = esConsumes<HcalDDDRecConstants, HcalRecNumberingRecord, edm::Transition::BeginRun>();
114 tok_hgcGeom_.emplace_back(esConsumes<HGCalDDDConstants, IdealGeometryRecord, edm::Transition::BeginRun>(
119 esConsumes<HGCalDDDConstants, IdealGeometryRecord, edm::Transition::BeginRun>(
edm::ESInputTag{
"",
name}));
129 std::vector<std::string>
names = {
"HGCalEESensitive",
"HGCalHESiliconSensitive",
"HGCalHEScintillatorSensitive"};
130 std::vector<std::string>
sources = {
"HGCHitsEE",
"HGCHitsHEfront",
"HGCHitsHEback"};
131 desc.add<std::vector<std::string> >(
"detectorNames",
names);
132 desc.add<std::vector<std::string> >(
"caloHitSources",
sources);
133 desc.addUntracked<
double>(
"rMin", 0.0);
134 desc.addUntracked<
double>(
"rMax", 3000.0);
135 desc.addUntracked<
double>(
"zMin", 3000.0);
136 desc.addUntracked<
double>(
"zMax", 6000.0);
137 desc.addUntracked<
double>(
"etaMin", 1.0);
138 desc.addUntracked<
double>(
"etaMax", 3.0);
139 desc.addUntracked<
int>(
"nBinR", 300);
140 desc.addUntracked<
int>(
"nBinZ", 300);
141 desc.addUntracked<
int>(
"nBinEta", 200);
142 desc.addUntracked<
int>(
"layers", 50);
143 desc.addUntracked<
int>(
"verbosity", 0);
144 desc.addUntracked<
bool>(
"ifNose",
false);
145 desc.addUntracked<
bool>(
"ifLayer",
false);
146 descriptions.
add(
"hgcalSimHitStudy",
desc);
154 if (theCaloHitContainers.
isValid()) {
156 edm::LogVerbatim(
"HGCalValidation") <<
" PcalohitItr = " << theCaloHitContainers->size();
157 std::vector<PCaloHit> caloHits;
159 for (
auto const&
hit : *(theCaloHitContainers.
product())) {
160 unsigned int id =
hit.
id();
163 caloHits.emplace_back(
hit);
164 caloHits.back().setID(hid.
rawId());
166 edm::LogVerbatim(
"HGCalValidation") <<
"Hit[" << caloHits.size() <<
"] " << hid;
170 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), theCaloHitContainers->end());
184 std::map<uint32_t, hitsinfo> map_hits;
187 unsigned int nused(0);
191 uint32_t
id =
hit.
id();
194 HepGeom::Point3D<float> gcoord;
199 sector = detId.
iphi();
205 edm::LogVerbatim(
"HGCalValidation") <<
"i/p " << subdet <<
":" <<
zside <<
":" << cell <<
":" << sector <<
":"
207 gcoord = HepGeom::Point3D<float>(rz *
cos(
etaphi.second) / cosh(
etaphi.first),
211 std::pair<float, float>
xy;
215 cell = detId.
cellU();
226 }
else if (
hgcons_[ih]->waferHexagon8()) {
228 subdet = static_cast<int>(detId.
det());
229 cell = detId.
cellU();
239 }
else if (
hgcons_[ih]->tileTrapezoid()) {
241 subdet = static_cast<int>(detId.
det());
242 sector = detId.
ieta();
255 double xp = (zp < 0) ? -
xy.first :
xy.first;
256 gcoord = HepGeom::Point3D<float>(xp,
xy.second, zp);
259 <<
"i/p " << subdet <<
":" <<
zside <<
":" <<
layer <<
":" << sector <<
":" <<
sector2 <<
":" << cell <<
":"
260 <<
cell2 <<
" o/p " <<
xy.first <<
":" <<
xy.second <<
":" << zp;
263 double tof = (gcoord.mag() * CLHEP::mm) / CLHEP::c_light;
266 <<
"Detector " <<
name <<
" zside = " <<
zside <<
" layer = " <<
layer <<
" type = " <<
type
267 <<
" wafer = " << sector <<
":" <<
sector2 <<
" cell = " << cell <<
":" <<
cell2 <<
" positon = " << gcoord
268 <<
" energy = " <<
energy <<
" time = " <<
time <<
":" << tof;
273 if (map_hits.count(
id) != 0) {
277 hinfo.phi = gcoord.getPhi();
278 hinfo.eta = gcoord.getEta();
288 if (
hinfo.layer <= static_cast<int>(
h_XY_.size()))
289 h_XY_[
hinfo.layer - 1]->Fill(gcoord.x(), gcoord.y());
295 h_W1_[ih]->Fill(sector);
296 h_C1_[ih]->Fill(cell);
299 edm::LogVerbatim(
"HGCalValidation") <<
name <<
" with " << map_hits.size() <<
":" << nused <<
" detector elements"
302 for (
auto const&
hit : map_hits) {
306 <<
" ---------------------- eta = " <<
hinfo.eta <<
" phi = " <<
hinfo.phi <<
" layer = " <<
hinfo.layer
307 <<
" E = " <<
hinfo.energy <<
" T = " <<
hinfo.time;
362 name <<
"RZ_AllDetectors";
363 title <<
"R vs Z for All Detectors";
372 for (
int ly = 0; ly <
nLayers_; ++ly) {
375 name <<
"XY_L" << (ly + 1);
376 title <<
"Y vs X at Layer " << (ly + 1);
385 name <<
"EtaPhi_AllDetectors";
386 title <<
"#phi vs #eta for All Detectors";
396 name <<
"EtFiZp_AllDetectors";
397 title <<
"#phi vs #eta (+z) for All Detectors";
407 name <<
"EtFiZm_AllDetectors";
408 title <<
"#phi vs #eta (-z) for All Detectors";
419 name <<
"LayerZp_AllDetectors";
420 title <<
"Energy vs Layer (+z) for All Detectors";
429 name <<
"LayerZm_AllDetectors";
430 title <<
"Energy vs Layer (-z) for All Detectors";
440 name <<
"E_AllDetectors";
441 title <<
"Energy Deposit for All Detectors";
446 h_E_.emplace_back(fs->
make<TH1D>(
name.str().c_str(),
title.str().c_str(), 1000, 0.0, 1.0));
451 name <<
"T_AllDetectors";
452 title <<
"Time for All Detectors";
457 h_T_.emplace_back(fs->
make<TH1D>(
name.str().c_str(),
title.str().c_str(), 1000, 0.0, 200.0));
465 h_Ly_.emplace_back(fs->
make<TH1D>(
name.str().c_str(),
title.str().c_str(), 200, 0, 100));
471 h_W1_.emplace_back(fs->
make<TH1D>(
name.str().c_str(),
title.str().c_str(), 200, -50, 50));
476 h_C1_.emplace_back(fs->
make<TH1D>(
name.str().c_str(),
title.str().c_str(), 720, 0, 360));
482 h_W1_.emplace_back(fs->
make<TH1D>(
name.str().c_str(),
title.str().c_str(), 200, -50, 50));
487 h_W2_.emplace_back(fs->
make<TH1D>(
name.str().c_str(),
title.str().c_str(), 100, -50, 50));
492 h_C1_.emplace_back(fs->
make<TH1D>(
name.str().c_str(),
title.str().c_str(), 100, 0, 50));
497 h_C2_.emplace_back(fs->
make<TH1D>(
name.str().c_str(),
title.str().c_str(), 100, 0, 50));