48 #include "CLHEP/Geometry/Point3D.h" 49 #include "CLHEP/Geometry/Transform3D.h" 50 #include "CLHEP/Geometry/Vector3D.h" 51 #include "CLHEP/Units/GlobalSystemOfUnits.h" 52 #include "CLHEP/Units/GlobalPhysicalConstants.h" 59 for (
int i = 0;
i < 6; ++
i)
87 void fillHitsInfo(std::pair<hitsinfo, energysum> hit_,
unsigned int itimeslice,
double esum);
114 times_(iConfig.getParameter<
std::vector<double> >(
"TimeSlices")),
115 verbosity_(iConfig.getUntrackedParameter<
int>(
"Verbosity", 0)),
127 std::vector<double> times = {25.0, 1000.0};
130 desc.
add<std::vector<double> >(
"TimeSlices", times);
133 descriptions.
add(
"hgcalSimHitValidationEE", desc);
146 for (HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
p != myGenEvent->particles_end();
148 edm::LogVerbatim(
"HGCalValidation") <<
"Particle[" << k <<
"] with pt " << (*p)->momentum().perp() <<
" eta " 149 << (*p)->momentum().eta() <<
" phi " << (*p)->momentum().phi();
157 if (theCaloHitContainers.
isValid()) {
159 edm::LogVerbatim(
"HGCalValidation") <<
" PcalohitItr = " << theCaloHitContainers->size();
160 std::vector<PCaloHit> caloHits;
161 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), theCaloHitContainers->end());
163 for (
unsigned int i = 0;
i < caloHits.size(); ++
i) {
164 unsigned int id_ = caloHits[
i].
id();
168 caloHits[
i].setID(hid.
rawId());
180 std::map<int, int> OccupancyMap_plus, OccupancyMap_minus;
181 OccupancyMap_plus.clear();
182 OccupancyMap_minus.clear();
184 std::map<uint32_t, std::pair<hitsinfo, energysum> > map_hits;
189 unsigned int nused(0);
190 for (
unsigned int i = 0;
i < hits.size();
i++) {
191 double energy = hits[
i].energy();
192 double time = hits[
i].time();
193 uint32_t id_ = hits[
i].id();
194 int cell, sector, subsector(0), layer,
zside;
202 sector = detId.
iphi();
204 layer = detId.
depth();
205 zside = detId.
zside();
210 cell = detId.
cellU();
213 subsector = detId.
waferV();
215 layer = detId.
layer();
216 zside = detId.
zside();
226 layer = detId.
layer();
227 zside = detId.
zside();
234 <<
"Detector " <<
nameDetector_ <<
" zside = " << zside <<
" sector|wafer = " << sector <<
":" << subsector
235 <<
" type = " << type <<
" layer = " << layer <<
" cell = " << cell <<
":" <<
cell2 <<
" energy = " << energy
236 <<
" energyem = " << hits[
i].energyEM() <<
" energyhad = " << hits[
i].energyHad() <<
" time = " <<
time;
238 HepGeom::Point3D<float> gcoord;
241 double rz =
hcons_->
getRZ(subdet, zside * cell, layer);
243 edm::LogVerbatim(
"HGCalValidation") <<
"i/p " << subdet <<
":" << zside <<
":" << cell <<
":" << sector <<
":" 244 << layer <<
" o/p " << etaphi.first <<
":" << etaphi.second <<
":" << rz;
245 gcoord = HepGeom::Point3D<float>(rz *
cos(etaphi.second) / cosh(etaphi.first),
246 rz *
sin(etaphi.second) / cosh(etaphi.first),
247 rz * tanh(etaphi.first));
250 const HepGeom::Point3D<float> lcoord(xy.first, xy.second, 0);
251 int subs = (
symmDet_ ? 0 : subsector);
255 std::pair<float, float>
xy;
267 float xp = (zp < 0) ? -xy.first : xy.first;
268 gcoord = HepGeom::Point3D<float>(xp, xy.second, zp);
270 double tof = (gcoord.mag() * CLHEP::mm) / CLHEP::c_light;
273 << std::hex << id_ <<
std::dec <<
" global coordinate " << gcoord <<
" time " << time <<
":" << tof;
278 if (map_hits.count(id_) != 0) {
279 hinfo = map_hits[id_].first;
280 esum = map_hits[id_].second;
282 hinfo.
x = gcoord.x();
283 hinfo.
y = gcoord.y();
284 hinfo.
z = gcoord.z();
291 hinfo.
phi = gcoord.getPhi();
292 hinfo.
eta = gcoord.getEta();
296 if (time > 0 && time <
times_[
k])
301 edm::LogVerbatim(
"HGCalValidation") <<
" ----------------------- gx = " << hinfo.
x <<
" gy = " << hinfo.
y 302 <<
" gz = " << hinfo.
z <<
" phi = " << hinfo.
phi <<
" eta = " << hinfo.
eta;
303 map_hits[id_] = std::pair<hitsinfo, energysum>(hinfo, esum);
307 <<
" detector elements being hit";
309 std::map<uint32_t, std::pair<hitsinfo, energysum> >::iterator itr;
310 for (itr = map_hits.begin(); itr != map_hits.end(); ++itr) {
313 int layer = hinfo.
layer;
316 for (
unsigned int itimeslice = 0; itimeslice <
nTimes_; itimeslice++) {
326 edm::LogVerbatim(
"HGCalValidation") <<
"With map:used:total " << hits.size() <<
"|" << nused <<
"|" 327 << map_hits.size() <<
" hits";
329 for (
auto const& itr : OccupancyMap_plus) {
330 int layer = itr.first;
331 int occupancy = itr.second;
334 for (
auto const& itr : OccupancyMap_minus) {
335 int layer = itr.first;
336 int occupancy = itr.second;
342 if (OccupancyMap.find(layer) != OccupancyMap.end()) {
343 ++OccupancyMap[layer];
345 OccupancyMap[layer] = 1;
350 unsigned int ilayer = hits.first.layer;
352 energy_[itimeslice].at(ilayer)->Fill(esum);
353 if (itimeslice == 0) {
354 EtaPhi_Plus_.at(ilayer)->Fill(hits.first.eta, hits.first.phi);
355 EtaPhi_Minus_.at(ilayer)->Fill(hits.first.eta, hits.first.phi);
360 <<
"Problematic Hit for " <<
nameDetector_ <<
" at sector " << hits.first.sector <<
":" << hits.first.sector2
361 <<
" layer " << hits.first.layer <<
" cell " << hits.first.cell <<
":" << hits.first.cell2 <<
" energy " 362 << hits.second.etotal;
382 int isd = (name.find(
nameDetector_) == std::string::npos) ? -1 : 1;
385 int nsiz =
static_cast<int>(copy.size());
386 int lay = (nsiz > 0) ? copy[nsiz - 1] : -1;
387 int sec = (nsiz > 1) ? copy[nsiz - 2] : -1;
388 int zp = (nsiz > 3) ? copy[nsiz - 4] : -1;
392 int subs = (trp.
alpha1() > 0 ? 1 : 0);
396 fv.
rotation().GetComponents(x, y, z);
397 const CLHEP::HepRep3x3
rotation(x.X(), y.X(), z.X(), x.Y(), y.Y(), z.Y(), x.Z(), y.Z(), z.Z());
400 const HepGeom::Transform3D ht3d(hr, h3v);
401 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));
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::pair< T, T > etaphi(T x, T y, T z)
MonitorElement * MeanHitOccupancy_Plus_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
void fillOccupancyMap(std::map< int, int > &OccupancyMap, int layer)
std::pair< double, double > getEtaPhi(const int &subdet, const int &ieta, const int &iphi) const
HcalSubdetector subdet() const
get the subdetector
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::vector< MonitorElement * > HitOccupancy_Plus_
void analyze(const edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
nav_type copyNumbers() const
return the stack of copy numbers
int zside() const
get the z-side of the cell (1/-1)
void setCurrentFolder(std::string const &fullpath)
edm::EDGetTokenT< edm::HepMCProduct > tok_hepMC_
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
Sin< T >::type sin(const T &t)
constexpr uint32_t rawId() const
get the raw id
int type() const
get the type
void analyzeHits(std::vector< PCaloHit > &hits)
int zside() const
get the z-side of the cell (1/-1)
std::vector< MonitorElement * > HitOccupancy_Minus_
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
Compact representation of the geometrical detector hierarchy.
int cellU() const
get the cell #'s in u,v or in x,y
A DDSolid represents the shape of a part.
MonitorElement * MeanHitOccupancy_Minus_
bool defineGeometry(edm::ESTransientHandle< DDCompactView > &ddViewH)
int depth() const
get the tower depth
#define DEFINE_FWK_MODULE(type)
unsigned int layers(bool reco) const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
bool next()
set current node to the next node in the filtered tree
const HcalDDDRecConstants * hcons_
int type() const
get the type
int layer() const
get the layer #
std::pair< float, float > locateCellTrap(int lay, int ieta, int iphi, bool reco) const
double getRZ(const int &subdet, const int &ieta, const int &depth) const
Cos< T >::type cos(const T &t)
static const unsigned int maxTime_
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
int ieta() const
get the cell ieta
const std::string fullname() const
Interface to a Trapezoid.
~HGCalSimHitValidation() override
int iphi() const
get the phi index
HGCalGeometryMode::GeometryMode geomMode() const
std::vector< MonitorElement * > EtaPhi_Plus_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
HGCalSimHitValidation(const edm::ParameterSet &)
double waferZ(int layer, bool reco) const
int ietaAbs() const
get the absolute value of the cell ieta
int iphi() const
get the cell iphi
const HepMC::GenEvent * GetEvent() const
std::string nameDetector_
int getMaxDepth(const int &type) const
static void unpackSquareIndex(const uint32_t &idx, int &z, int &lay, int &sec, int &subsec, int &cell)
double alpha1(void) const
Angle with respect to the y axis from the centre of the side at y=-pDy1 to the centre at y=+pDy1 of t...
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hits_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< MonitorElement * > energy_[maxTime_]
int layer() const
get the layer #
int zside() const
get the z-side of the cell (1/-1)
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
std::map< uint32_t, HepGeom::Transform3D > transMap_
bool firstChild()
set the current node to the first child ...
const HGCalDDDConstants * hgcons_
std::string caloHitSource_
std::vector< MonitorElement * > EtaPhi_Minus_
const DDTranslation & translation() const
The absolute translation of the current node.
DetId relabel(const uint32_t testId) const
static uint32_t packSquareIndex(int z, int lay, int sec, int subsec, int cell)
void fillHitsInfo(std::pair< hitsinfo, energysum > hit_, unsigned int itimeslice, double esum)
std::vector< double > times_
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)