33 #include "CLHEP/Geometry/Point3D.h"
34 #include "CLHEP/Geometry/Vector3D.h"
35 #include "CLHEP/Units/GlobalSystemOfUnits.h"
36 #include "CLHEP/Units/GlobalPhysicalConstants.h"
50 nTimes_ = (times_.size() > 6) ? 6 : times_.size();
64 const HepMC::GenEvent * myGenEvent = evtMC->GetEvent();
66 for (HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
67 p != myGenEvent->particles_end(); ++
p, ++
k) {
68 edm::LogInfo(
"HGCalValidation") <<
"Particle[" << k <<
"] with pt "
69 << (*p)->momentum().perp() <<
" eta "
70 << (*p)->momentum().eta() <<
" phi "
71 << (*p)->momentum().phi() << std::endl;
78 if (theCaloHitContainers.
isValid()) {
81 << theCaloHitContainers->size() <<
"\n";
82 std::vector<PCaloHit> caloHits;
83 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(),
84 theCaloHitContainers->end());
86 for (
unsigned int i=0;
i<caloHits.size(); ++
i) {
87 unsigned int id_ = caloHits[
i].
id();
88 int subdet,
z, depth0, eta0, phi0, lay;
90 int sign = (z==0) ? (-1):(1);
93 << subdet <<
" z " << z <<
" depth "
94 << depth0 <<
" eta " << eta0
95 <<
" phi " << phi0 <<
" lay " << lay
101 caloHits[
i].setID(hid.
rawId());
103 edm::LogInfo(
"HGCalValidation") <<
"Hit[" <<
i <<
"] " << hid <<
"\n";
108 edm::LogInfo(
"HGCalValidation") <<
"PCaloHitContainer does not exist !!!\n";
114 std::map<int, int> OccupancyMap_plus, OccupancyMap_minus;
115 OccupancyMap_plus.clear(); OccupancyMap_minus.clear();
117 std::map<uint32_t,std::pair<hitsinfo,energysum> > map_hits;
122 <<
" PcaloHit elements\n";
123 unsigned int nused(0);
124 for (
unsigned int i=0;
i<hits.size();
i++) {
125 double energy = hits[
i].energy();
126 double time = hits[
i].time();
127 uint32_t id_ = hits[
i].id();
128 int cell, sector, subsector, layer,
zside;
133 if (subdet != static_cast<int>(
HcalEndcap))
continue;
135 sector = detId.
iphi();
137 layer = detId.
depth();
138 zside = detId.
zside();
149 <<
" zside = " << zside
150 <<
" sector|wafer = " << sector
151 <<
" subsector|type = " << subsector
152 <<
" layer = " << layer
153 <<
" cell = " << cell
154 <<
" energy = " << energy
155 <<
" energyem = " << hits[
i].energyEM()
156 <<
" energyhad = " << hits[
i].energyHad()
157 <<
" time = " << time <<
"\n";
159 HepGeom::Point3D<float> gcoord;
162 double rz =
hcons_->
getRZ(subdet,zside*cell,layer);
164 gcoord = HepGeom::Point3D<float>(rz*
cos(etaphi.second)/cosh(etaphi.first),
165 rz*
sin(etaphi.second)/cosh(etaphi.first),
166 rz*tanh(etaphi.first));
170 const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
171 int subs = (
symmDet_ ? 0 : subsector);
177 if (zside < 0) zp = -zp;
178 float xp = (zp < 0) ? -xy.first : xy.first;
179 gcoord = HepGeom::Point3D<float>(xp,xy.second,zp);
182 double tof = (gcoord.mag()*CLHEP::mm)/CLHEP::c_light;
185 <<
" global coordinate " << gcoord
186 <<
" time " << time <<
":" << tof <<
"\n";
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();
209 edm::LogInfo(
"HGCalValidation") <<
" -------------------------- gx = "
210 << hinfo.
x <<
" gy = " << hinfo.
y
211 <<
" gz = " << hinfo.
z <<
" phi = "
212 << hinfo.
phi <<
" eta = " << hinfo.
eta
214 map_hits[id_] = std::pair<hitsinfo,energysum>(hinfo,esum);
219 <<
" detector elements being hit\n";
221 std::map<uint32_t,std::pair<hitsinfo,energysum> >::iterator itr;
222 for (itr = map_hits.begin() ; itr != map_hits.end(); ++itr) {
225 int layer = hinfo.
layer;
227 for (
unsigned int itimeslice = 0; itimeslice <
nTimes_; itimeslice++ ) {
236 edm::LogInfo(
"HGCalValidation") <<
"With map:used:total " << hits.size()
237 <<
"|" << nused <<
"|" << map_hits.size()
240 for (
auto itr = OccupancyMap_plus.begin() ; itr != OccupancyMap_plus.end(); ++itr) {
241 int layer = (*itr).first;
242 int occupancy = (*itr).second;
245 for (
auto itr = OccupancyMap_minus.begin() ; itr != OccupancyMap_minus.end(); ++itr) {
246 int layer = (*itr).first;
247 int occupancy = (*itr).second;
253 if (OccupancyMap.find(layer) != OccupancyMap.end()) {
254 OccupancyMap[layer] ++;
256 OccupancyMap[layer] = 1;
261 unsigned int itimeslice,
double esum){
263 unsigned int ilayer = hits.first.layer - 1;
265 energy_[itimeslice].at(ilayer)->Fill(esum);
267 EtaPhi_Plus_.at(ilayer)->Fill(hits.first.eta , hits.first.phi);
268 EtaPhi_Minus_.at(ilayer)->Fill(hits.first.eta , hits.first.phi);
272 edm::LogInfo(
"HGCalValidation") <<
"Problematic Hit for "
274 << hits.first.sector <<
" layer "
275 << hits.first.layer <<
" cell "
276 << hits.first.cell <<
" energy "
277 << hits.second.etotal << std::endl;
283 edm::LogInfo(
"HGCalValidation") <<
"Initialize HGCalDDDConstants for "
301 int isd = (name.find(
nameDetector_) == std::string::npos) ? -1 : 1;
304 int nsiz = (int)(copy.size());
305 int lay = (nsiz > 0) ? copy[nsiz-1] : -1;
306 int sec = (nsiz > 1) ? copy[nsiz-2] : -1;
307 int zp = (nsiz > 3) ? copy[nsiz-4] : -1;
308 if (zp !=1 ) zp = -1;
310 int subs = (trp.
alpha1()>0 ? 1 : 0);
314 fv.
rotation().GetComponents( x, y, z ) ;
315 const CLHEP::HepRep3x3
rotation ( x.X(), y.X(), z.X(),
317 x.Z(), y.Z(), z.Z() );
319 const CLHEP::Hep3Vector h3v ( fv.
translation().X(),
322 const HepGeom::Transform3D ht3d (hr, h3v);
323 transMap_.insert(std::make_pair(
id,ht3d));
326 <<
" Transform using " << h3v
327 <<
" and " << hr << std::endl;
333 <<
" elements and SymmDet_ = "
367 std::ostringstream histoname;
368 for (
unsigned int ilayer = 0; ilayer <
layers_; ilayer++ ) {
369 histoname.str(
""); histoname <<
"HitOccupancy_Plus_layer_" << ilayer;
371 histoname.str(
""); histoname <<
"HitOccupancy_Minus_layer_" << ilayer;
374 histoname.str(
""); histoname <<
"EtaPhi_Plus_" <<
"layer_" << ilayer;
376 histoname.str(
""); histoname <<
"EtaPhi_Minus_" <<
"layer_" << ilayer;
379 for (
unsigned int itimeslice = 0; itimeslice <
nTimes_ ; itimeslice++ ) {
380 histoname.str(
""); histoname <<
"energy_time_"<< itimeslice <<
"_layer_" << ilayer;
381 energy_[itimeslice].push_back(iB.
book1D(histoname.str().c_str(),
"energy_",100,0,0.1));
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MonitorElement * MeanHitOccupancy_Plus_
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
std::vector< MonitorElement * > HitOccupancy_Plus_
void analyze(const edm::Event &, const edm::EventSetup &) override
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_
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.
MonitorElement * MeanHitOccupancy_Minus_
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.
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)
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
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
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_
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 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.
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)
std::vector< double > times_
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)
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.