33 #include "CLHEP/Geometry/Point3D.h"
34 #include "CLHEP/Geometry/Vector3D.h"
35 #include "CLHEP/Units/GlobalSystemOfUnits.h"
36 #include "CLHEP/Units/GlobalPhysicalConstants.h"
65 for (HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
66 p != myGenEvent->particles_end(); ++
p, ++
k) {
67 edm::LogInfo(
"HGCalValidation") <<
"Particle[" << k <<
"] with pt "
68 << (*p)->momentum().perp() <<
" eta "
69 << (*p)->momentum().eta() <<
" phi "
70 << (*p)->momentum().phi();
77 if (theCaloHitContainers.
isValid()) {
80 << theCaloHitContainers->size();
81 std::vector<PCaloHit> caloHits;
82 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(),
83 theCaloHitContainers->end());
85 for (
unsigned int i=0;
i<caloHits.size(); ++
i) {
86 unsigned int id_ = caloHits[
i].
id();
87 int subdet,
z, depth0, eta0, phi0, lay;
89 int sign = (z==0) ? (-1):(1);
92 << subdet <<
" z " << z <<
" depth "
93 << depth0 <<
" eta " << eta0
94 <<
" phi " << phi0 <<
" lay " << lay;
99 caloHits[
i].setID(hid.
rawId());
101 edm::LogInfo(
"HGCalValidation") <<
"Hit[" <<
i <<
"] " << hid;
106 edm::LogInfo(
"HGCalValidation") <<
"PCaloHitContainer does not exist !!!";
112 std::map<int, int> OccupancyMap_plus[
netaBins];
113 std::map<int, int> OccupancyMap_minus[
netaBins];
115 OccupancyMap_plus[
i].clear();
116 OccupancyMap_minus[
i].clear();
119 std::map<uint32_t,std::pair<hitsinfo,energysum> > map_hits;
124 <<
" PcaloHit elements";
125 unsigned int nused(0);
126 for (
unsigned int i=0;
i<hits.size();
i++) {
127 double energy = hits[
i].energy();
128 double time = hits[
i].time();
129 uint32_t id_ = hits[
i].id();
130 int cell, sector, subsector, layer,
zside;
135 if (subdet != static_cast<int>(
HcalEndcap))
continue;
137 sector = detId.
iphi();
139 layer = detId.
depth();
140 zside = detId.
zside();
151 <<
" zside = " << zside
152 <<
" sector|wafer = " << sector
153 <<
" subsector|type = " << subsector
154 <<
" layer = " << layer
155 <<
" cell = " << cell
156 <<
" energy = " << energy
157 <<
" energyem = " << hits[
i].energyEM()
158 <<
" energyhad = " << hits[
i].energyHad()
159 <<
" time = " << time;
161 HepGeom::Point3D<float> gcoord;
164 double rz =
hcons_->
getRZ(subdet,zside*cell,layer);
166 gcoord = HepGeom::Point3D<float>(rz*
cos(etaphi.second)/cosh(etaphi.first),
167 rz*
sin(etaphi.second)/cosh(etaphi.first),
168 rz*tanh(etaphi.first));
172 const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
173 int subs = (
symmDet_ ? 0 : subsector);
178 if (zp < 0) gcoord = HepGeom::Point3D<float>(-xy.first,xy.second,zp);
179 else gcoord = HepGeom::Point3D<float>( xy.first,xy.second,zp);
182 double tof = (gcoord.mag()*CLHEP::mm)/CLHEP::c_light;
185 <<
" global coordinate " << gcoord
186 <<
" time " << time <<
":" << tof;
191 if (map_hits.count(id_) != 0) {
192 hinfo = map_hits[id_].first;
193 esum = map_hits[id_].second;
195 hinfo.
x = gcoord.x();
196 hinfo.
y = gcoord.y();
197 hinfo.
z = gcoord.z();
201 hinfo.
phi = gcoord.getPhi();
202 hinfo.
eta = gcoord.getEta();
204 if (time > 0 && time < 1000) {
224 edm::LogInfo(
"HGCalValidation") <<
" -------------------------- gx = "
225 << hinfo.
x <<
" gy = " << hinfo.
y
226 <<
" gz = " << hinfo.
z <<
" phi = "
227 << hinfo.
phi <<
" eta = " << hinfo.
eta;
228 std::pair<hitsinfo,energysum> pair_tmp(hinfo,esum);
229 map_hits[id_] = pair_tmp;
234 <<
" detector elements being hit";
236 std::map<uint32_t,std::pair<hitsinfo,energysum> >::iterator itr;
237 for (itr = map_hits.begin() ; itr != map_hits.end(); ++itr) {
240 int layer = hinfo.
layer;
243 std::vector<double> esumVector;
244 esumVector.push_back(esum.
e15);
245 esumVector.push_back(esum.
e25);
246 esumVector.push_back(esum.
e50);
247 esumVector.push_back(esum.
e100);
248 esumVector.push_back(esum.
e250);
249 esumVector.push_back(esum.
e1000);
251 for(
unsigned int itimeslice = 0; itimeslice < esumVector.size();
253 fillHitsInfo((*itr).second, itimeslice, esumVector.at(itimeslice));
258 if (eta >= 1.75 && eta <= 2.5)
fillOccupancyMap(OccupancyMap_plus[0], layer-1);
259 if (eta >= 1.75 && eta <= 2.0)
fillOccupancyMap(OccupancyMap_plus[1], layer-1);
260 else if (eta >= 2.0 && eta <= 2.25)
fillOccupancyMap(OccupancyMap_plus[2], layer-1);
261 else if(eta >= 2.25 && eta <= 2.5)
fillOccupancyMap(OccupancyMap_plus[3], layer-1);
263 if (eta >= -2.5 && eta <= -1.75)
fillOccupancyMap(OccupancyMap_minus[0], layer-1);
264 if (eta >= -2.0 && eta <= -1.75)
fillOccupancyMap(OccupancyMap_minus[1], layer-1);
265 else if (eta >= -2.25 && eta <= -2.0)
fillOccupancyMap(OccupancyMap_minus[2], layer-1);
266 else if (eta >= -2.5 && eta <= -2.25)
fillOccupancyMap(OccupancyMap_minus[3], layer-1);
268 edm::LogInfo(
"HGCalValidation") <<
"With map:used:total " << hits.size()
269 <<
"|" << nused <<
"|" << map_hits.size()
272 for(
int indx=0; indx<
netaBins;++indx) {
273 for (
auto itr = OccupancyMap_plus[indx].
begin() ; itr != OccupancyMap_plus[indx].end(); ++itr) {
274 int layer = (*itr).first;
275 int occupancy = (*itr).second;
278 for (
auto itr = OccupancyMap_minus[indx].
begin() ; itr != OccupancyMap_minus[indx].end(); ++itr) {
279 int layer = (*itr).first;
280 int occupancy = (*itr).second;
287 if (OccupancyMap.find(layer) != OccupancyMap.end()) {
288 OccupancyMap[layer] ++;
290 OccupancyMap[layer] = 1;
295 unsigned int itimeslice,
double esum) {
297 unsigned int ilayer = hits.first.layer - 1;
299 energy_[itimeslice].at(ilayer)->Fill(esum);
301 EtaPhi_Plus_.at(ilayer)->Fill(hits.first.eta , hits.first.phi);
302 EtaPhi_Minus_.at(ilayer)->Fill(hits.first.eta , hits.first.phi);
306 edm::LogInfo(
"HGCalValidation") <<
"Problematic Hit for "
308 << hits.first.sector <<
" layer "
309 << hits.first.layer <<
" cell "
310 << hits.first.cell <<
" energy "
311 << hits.second.etotal;
317 edm::LogInfo(
"HGCalValidation") <<
"Initialize HGCalDDDConstants for "
324 DDValue val(attribute, value, 0);
335 int isd = (name.find(
nameDetector_) == std::string::npos) ? -1 : 1;
338 int nsiz = (int)(copy.size());
339 int lay = (nsiz > 0) ? copy[nsiz-1] : -1;
340 int sec = (nsiz > 1) ? copy[nsiz-2] : -1;
341 int zp = (nsiz > 3) ? copy[nsiz-4] : -1;
342 if (zp !=1 ) zp = -1;
344 int subs = (trp.
alpha1()>0 ? 1 : 0);
348 fv.
rotation().GetComponents( x, y, z ) ;
349 const CLHEP::HepRep3x3
rotation ( x.X(), y.X(), z.X(),
351 x.Z(), y.Z(), z.Z() );
353 const CLHEP::Hep3Vector h3v ( fv.
translation().X(),
356 const HepGeom::Transform3D ht3d (hr, h3v);
357 transMap_.insert(std::make_pair(
id,ht3d));
360 <<
" Transform using " << h3v
367 <<
" elements and SymmDet_ = " <<
symmDet_;
399 std::ostringstream histoname;
400 for (
unsigned int ilayer = 0; ilayer <
layers_; ilayer++ ) {
401 for (
int indx=0; indx<
netaBins; ++indx){
402 histoname.str(
""); histoname <<
"HitOccupancy_Plus"<< indx <<
"_layer_" << ilayer;
404 histoname.str(
""); histoname <<
"HitOccupancy_Minus" << indx <<
"_layer_" << ilayer;
408 histoname.str(
""); histoname <<
"EtaPhi_Plus_" <<
"layer_" << ilayer;
409 EtaPhi_Plus_.push_back(iB.
book2D(histoname.str().c_str(),
"Occupancy", 31, 1.45, 3.0, 72, -3.14, 3.14));
410 histoname.str(
""); histoname <<
"EtaPhi_Minus_" <<
"layer_" << ilayer;
411 EtaPhi_Minus_.push_back(iB.
book2D(histoname.str().c_str(),
"Occupancy", 31, -3.0, -1.45, 72, -3.14, 3.14));
413 for (
int itimeslice = 0; itimeslice < 6 ; itimeslice++ ) {
414 histoname.str(
""); histoname <<
"energy_time_"<< itimeslice <<
"_layer_" << ilayer;
415 energy_[itimeslice].push_back(iB.
book1D(histoname.str().c_str(),
"energy_",100,0,0.1));
418 for(
int indx=0; indx<
netaBins; ++indx) {
419 histoname.str(
""); histoname <<
"MeanHitOccupancy_Plus"<< indx ;
421 histoname.str(
""); histoname <<
"MeanHitOccupancy_Minus"<< indx ;
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< MonitorElement * > energy_[6]
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
void fillOccupancyMap(std::map< int, int > &OccupancyMap, int layer)
double getRZ(int subdet, int ieta, int depth) const
HcalSubdetector subdet() const
get the subdetector
void addFilter(const DDFilter &, DDLogOp op=DDLogOp::AND)
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)
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< edm::HepMCProduct > tok_hepMC_
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
Sin< T >::type sin(const T &t)
void analyzeHits(std::vector< PCaloHit > &hits)
std::vector< MonitorElement * > HitOccupancy_Minus_[netaBins]
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
type of data representation of DDCompactView
A DDSolid represents the shape of a part.
uint32_t rawId() const
get the raw id
bool defineGeometry(edm::ESTransientHandle< DDCompactView > &ddViewH)
int getMaxDepth(const int type) const
int depth() const
get the tower depth
void addDefault(ParameterSetDescription const &psetDescription)
unsigned int layers(bool reco) const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
MonitorElement * MeanHitOccupancy_Minus_[netaBins]
bool next()
set current node to the next node in the filtered tree
const HcalDDDRecConstants * hcons_
HcalID getHCID(int subdet, int ieta, int iphi, int lay, int idepth) const
Cos< T >::type cos(const T &t)
MonitorElement * book1D(Args &&...args)
Interface to a Trapezoid.
std::pair< T, T > etaphi(T x, T y, T z)
static void unpackHcalIndex(const uint32_t &idx, int &det, int &z, int &depth, int &eta, int &phi, int &lay)
HGCalGeometryMode geomMode() const
std::vector< MonitorElement * > EtaPhi_Plus_
HGCalSimHitValidation(const edm::ParameterSet &)
double waferZ(int layer, bool reco) const
static const int netaBins
int ietaAbs() const
get the absolute value of the cell ieta
int iphi() const
get the cell iphi
void setCurrentFolder(const std::string &fullpath)
MonitorElement * book2D(Args &&...args)
std::string nameDetector_
MonitorElement * MeanHitOccupancy_Plus_[netaBins]
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_
std::vector< MonitorElement * > HitOccupancy_Plus_[netaBins]
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_
void analyze(const edm::Event &, const edm::EventSetup &)
std::string caloHitSource_
std::vector< MonitorElement * > EtaPhi_Minus_
const DDTranslation & translation() const
The absolute translation of the current node.
static uint32_t packSquareIndex(int z, int lay, int sec, int subsec, int cell)
std::pair< double, double > getEtaPhi(int subdet, int ieta, int iphi) const
void fillHitsInfo(std::pair< hitsinfo, energysum > hit_, unsigned int itimeslice, double esum)
void setCriteria(const DDValue &nameVal, DDCompOp, DDLogOp l=DDLogOp::AND, bool asString=true, bool merged=true)
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
void dqmBeginRun(const edm::Run &, const edm::EventSetup &)
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.