44 #include "CLHEP/Geometry/Point3D.h"
45 #include "CLHEP/Geometry/Transform3D.h"
46 #include "CLHEP/Geometry/Vector3D.h"
47 #include "CLHEP/Units/GlobalSystemOfUnits.h"
48 #include "CLHEP/Units/GlobalPhysicalConstants.h"
55 for (
int i = 0;
i < 6; ++
i)
83 void fillHitsInfo(std::pair<hitsinfo, energysum> hit_,
unsigned int itimeslice,
double esum);
112 : nameDetector_(iConfig.getParameter<
std::
string>(
"DetectorName")),
113 caloHitSource_(iConfig.getParameter<
std::
string>(
"CaloHitSource")),
114 times_(iConfig.getParameter<
std::
vector<double> >(
"TimeSlices")),
115 verbosity_(iConfig.getUntrackedParameter<
int>(
"Verbosity", 0)),
116 fromDDD_(iConfig.getUntrackedParameter<
bool>(
"fromDDD",
true)),
119 tok_cpv_(esConsumes<DDCompactView, IdealGeometryRecord, edm::Transition::BeginRun>()),
120 tok_cpvc_(esConsumes<cms::DDCompactView, IdealGeometryRecord, edm::Transition::BeginRun>()),
123 tok_hepMC_ = consumes<edm::HepMCProduct>(
edm::InputTag(
"generatorSmeared"));
124 tok_hits_ = consumes<edm::PCaloHitContainer>(
edm::InputTag(
"g4SimHits", caloHitSource_));
125 nTimes_ = (times_.size() > maxTime_) ? maxTime_ : times_.size();
130 std::vector<double> times = {25.0, 1000.0};
133 desc.add<std::vector<double> >(
"TimeSlices", times);
134 desc.addUntracked<
int>(
"Verbosity", 0);
135 desc.addUntracked<
bool>(
"TestNumber",
true);
136 desc.addUntracked<
bool>(
"fromDDD",
true);
137 descriptions.
add(
"hgcalSimHitValidationEE",
desc);
150 for (HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
p != myGenEvent->particles_end();
152 edm::LogVerbatim(
"HGCalValidation") <<
"Particle[" <<
k <<
"] with pt " << (*p)->momentum().perp() <<
" eta "
153 << (*p)->momentum().eta() <<
" phi " << (*p)->momentum().phi();
161 if (theCaloHitContainers.
isValid()) {
163 edm::LogVerbatim(
"HGCalValidation") <<
" PcalohitItr = " << theCaloHitContainers->size();
164 std::vector<PCaloHit> caloHits;
165 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), theCaloHitContainers->end());
173 std::map<int, int> OccupancyMap_plus, OccupancyMap_minus;
174 OccupancyMap_plus.clear();
175 OccupancyMap_minus.clear();
177 std::map<uint32_t, std::pair<hitsinfo, energysum> > map_hits;
182 unsigned int nused(0);
183 for (
unsigned int i = 0;
i <
hits.size();
i++) {
186 uint32_t id_ =
hits[
i].id();
192 cell = detId.
cellU();
195 subsector = detId.
waferV();
214 <<
"Detector " <<
nameDetector_ <<
" zside = " <<
zside <<
" sector|wafer = " << sector <<
":" << subsector
215 <<
" type = " <<
type <<
" layer = " <<
layer <<
" cell = " << cell <<
":" <<
cell2 <<
" energy = " <<
energy
216 <<
" energyem = " <<
hits[
i].energyEM() <<
" energyhad = " <<
hits[
i].energyHad() <<
" time = " <<
time;
218 HepGeom::Point3D<float> gcoord;
219 std::pair<float, float>
xy;
230 float xp = (zp < 0) ? -
xy.first :
xy.first;
231 gcoord = HepGeom::Point3D<float>(xp,
xy.second, zp);
232 double tof = (gcoord.mag() * CLHEP::mm) / CLHEP::c_light;
235 << std::hex << id_ <<
std::dec <<
" global coordinate " << gcoord <<
" time " <<
time <<
":" << tof;
240 if (map_hits.count(id_) != 0) {
241 hinfo = map_hits[id_].first;
242 esum = map_hits[id_].second;
244 hinfo.x = gcoord.x();
245 hinfo.y = gcoord.y();
246 hinfo.z = gcoord.z();
247 hinfo.sector = sector;
248 hinfo.sector2 = subsector;
253 hinfo.phi = gcoord.getPhi();
254 hinfo.eta = gcoord.getEta();
264 <<
" gz = " <<
hinfo.z <<
" phi = " <<
hinfo.phi <<
" eta = " <<
hinfo.eta;
265 map_hits[id_] = std::pair<hitsinfo, energysum>(
hinfo, esum);
269 <<
" detector elements being hit";
271 std::map<uint32_t, std::pair<hitsinfo, energysum> >::iterator itr;
272 for (itr = map_hits.begin(); itr != map_hits.end(); ++itr) {
278 for (
unsigned int itimeslice = 0; itimeslice <
nTimes_; itimeslice++) {
288 edm::LogVerbatim(
"HGCalValidation") <<
"With map:used:total " <<
hits.size() <<
"|" << nused <<
"|"
289 << map_hits.size() <<
" hits";
291 for (
auto const& itr : OccupancyMap_plus) {
292 int layer = itr.first;
293 int occupancy = itr.second;
296 for (
auto const& itr : OccupancyMap_minus) {
297 int layer = itr.first;
298 int occupancy = itr.second;
304 if (OccupancyMap.find(
layer) != OccupancyMap.end()) {
305 ++OccupancyMap[
layer];
307 OccupancyMap[
layer] = 1;
312 unsigned int ilayer =
hits.first.layer;
314 energy_[itimeslice].at(ilayer)->Fill(esum);
315 if (itimeslice == 0) {
322 <<
"Problematic Hit for " <<
nameDetector_ <<
" at sector " <<
hits.first.sector <<
":" <<
hits.first.sector2
323 <<
" layer " <<
hits.first.layer <<
" cell " <<
hits.first.cell <<
":" <<
hits.first.cell2 <<
" energy "
324 <<
hits.second.etotal;
348 int nsiz = static_cast<int>(
copy.size());
349 int lay = (nsiz > 0) ?
copy[nsiz - 1] : -1;
350 int sec = (nsiz > 1) ?
copy[nsiz - 2] : -1;
351 int zp = (nsiz > 3) ?
copy[nsiz - 4] : -1;
354 const DDTrap& trp = static_cast<DDTrap>(sol);
355 int subs = (trp.
alpha1() > 0 ? 1 : 0);
360 const CLHEP::HepRep3x3
rotation(
x.X(),
y.X(),
z.X(),
x.Y(),
y.Y(),
z.Y(),
x.Z(),
y.Z(),
z.Z());
361 const CLHEP::HepRotation hr(
rotation);
363 const HepGeom::Transform3D ht3d(hr, h3v);
364 transMap_.insert(std::make_pair(
id, ht3d));
391 int nsiz = static_cast<int>(
copy.size());
392 int lay = (nsiz > 0) ?
copy[0] : -1;
393 int sec = (nsiz > 1) ?
copy[1] : -1;
394 int zp = (nsiz > 3) ?
copy[3] : -1;
398 int subs = (pars[6] > 0 ? 1 : 0);
403 const CLHEP::HepRep3x3
rotation(
x.X(),
y.X(),
z.X(),
x.Y(),
y.Y(),
z.Y(),
x.Z(),
y.Z(),
z.Z());
404 const CLHEP::HepRotation hr(
rotation);
406 const HepGeom::Transform3D ht3d(hr, h3v);
407 transMap_.insert(std::make_pair(
id, ht3d));
438 std::ostringstream histoname;
439 for (
unsigned int il = 0; il <
layers_; ++il) {
441 auto istr1 = std::to_string(ilayer);
442 while (istr1.size() < 2) {
443 istr1.insert(0,
"0");
446 histoname <<
"HitOccupancy_Plus_layer_" << istr1;
449 histoname <<
"HitOccupancy_Minus_layer_" << istr1;
453 histoname <<
"EtaPhi_Plus_"
454 <<
"layer_" << istr1;
457 histoname <<
"EtaPhi_Minus_"
458 <<
"layer_" << istr1;
462 for (
unsigned int itimeslice = 0; itimeslice <
nTimes_; itimeslice++) {
464 histoname <<
"energy_time_" << itimeslice <<
"_layer_" << istr1;
465 energy_[itimeslice].push_back(iB.
book1D(histoname.str().c_str(),
"energy_", 100, 0, 0.1));