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();
90 caloHits[
i].setID(hid.
rawId());
92 edm::LogInfo(
"HGCalValidation") <<
"Hit[" <<
i <<
"] " << hid <<
"\n";
97 edm::LogInfo(
"HGCalValidation") <<
"PCaloHitContainer does not exist !!!\n";
103 std::map<int, int> OccupancyMap_plus, OccupancyMap_minus;
104 OccupancyMap_plus.clear(); OccupancyMap_minus.clear();
106 std::map<uint32_t,std::pair<hitsinfo,energysum> > map_hits;
111 <<
" PcaloHit elements\n";
112 unsigned int nused(0);
113 for (
unsigned int i=0;
i<hits.size();
i++) {
114 double energy = hits[
i].energy();
115 double time = hits[
i].time();
116 uint32_t id_ = hits[
i].id();
117 int cell, sector, subsector, layer,
zside;
122 if (subdet != static_cast<int>(
HcalEndcap))
continue;
124 sector = detId.
iphi();
126 layer = detId.
depth();
127 zside = detId.
zside();
138 <<
" zside = " << zside
139 <<
" sector|wafer = " << sector
140 <<
" subsector|type = " << subsector
141 <<
" layer = " << layer
142 <<
" cell = " << cell
143 <<
" energy = " << energy
144 <<
" energyem = " << hits[
i].energyEM()
145 <<
" energyhad = " << hits[
i].energyHad()
146 <<
" time = " << time <<
"\n";
148 HepGeom::Point3D<float> gcoord;
151 double rz =
hcons_->
getRZ(subdet,zside*cell,layer);
153 gcoord = HepGeom::Point3D<float>(rz*
cos(etaphi.second)/cosh(etaphi.first),
154 rz*
sin(etaphi.second)/cosh(etaphi.first),
155 rz*tanh(etaphi.first));
159 const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
160 int subs = (
symmDet_ ? 0 : subsector);
166 if (zside < 0) zp = -zp;
167 float xp = (zp < 0) ? -xy.first : xy.first;
168 gcoord = HepGeom::Point3D<float>(xp,xy.second,zp);
171 double tof = (gcoord.mag()*CLHEP::mm)/CLHEP::c_light;
174 <<
" global coordinate " << gcoord
175 <<
" time " << time <<
":" << tof <<
"\n";
180 if (map_hits.count(id_) != 0) {
181 hinfo = map_hits[id_].first;
182 esum = map_hits[id_].second;
184 hinfo.
x = gcoord.x();
185 hinfo.
y = gcoord.y();
186 hinfo.
z = gcoord.z();
190 hinfo.
phi = gcoord.getPhi();
191 hinfo.
eta = gcoord.getEta();
198 edm::LogInfo(
"HGCalValidation") <<
" -------------------------- gx = " 199 << hinfo.
x <<
" gy = " << hinfo.
y 200 <<
" gz = " << hinfo.
z <<
" phi = " 201 << hinfo.
phi <<
" eta = " << hinfo.
eta 203 map_hits[id_] = std::pair<hitsinfo,energysum>(hinfo,esum);
208 <<
" detector elements being hit\n";
210 std::map<uint32_t,std::pair<hitsinfo,energysum> >::iterator itr;
211 for (itr = map_hits.begin() ; itr != map_hits.end(); ++itr) {
214 int layer = hinfo.
layer;
216 for (
unsigned int itimeslice = 0; itimeslice <
nTimes_; itimeslice++ ) {
225 edm::LogInfo(
"HGCalValidation") <<
"With map:used:total " << hits.size()
226 <<
"|" << nused <<
"|" << map_hits.size()
229 for (
auto itr = OccupancyMap_plus.begin() ; itr != OccupancyMap_plus.end(); ++itr) {
230 int layer = (*itr).first;
231 int occupancy = (*itr).second;
234 for (
auto itr = OccupancyMap_minus.begin() ; itr != OccupancyMap_minus.end(); ++itr) {
235 int layer = (*itr).first;
236 int occupancy = (*itr).second;
242 if (OccupancyMap.find(layer) != OccupancyMap.end()) {
243 OccupancyMap[layer] ++;
245 OccupancyMap[layer] = 1;
250 unsigned int itimeslice,
double esum){
252 unsigned int ilayer = hits.first.layer - 1;
254 energy_[itimeslice].at(ilayer)->Fill(esum);
256 EtaPhi_Plus_.at(ilayer)->Fill(hits.first.eta , hits.first.phi);
257 EtaPhi_Minus_.at(ilayer)->Fill(hits.first.eta , hits.first.phi);
261 edm::LogInfo(
"HGCalValidation") <<
"Problematic Hit for " 263 << hits.first.sector <<
" layer " 264 << hits.first.layer <<
" cell " 265 << hits.first.cell <<
" energy " 266 << hits.second.etotal << std::endl;
272 edm::LogInfo(
"HGCalValidation") <<
"Initialize HGCalDDDConstants for " 287 int isd = (name.find(
nameDetector_) == std::string::npos) ? -1 : 1;
290 int nsiz = (
int)(copy.size());
291 int lay = (nsiz > 0) ? copy[nsiz-1] : -1;
292 int sec = (nsiz > 1) ? copy[nsiz-2] : -1;
293 int zp = (nsiz > 3) ? copy[nsiz-4] : -1;
294 if (zp !=1 ) zp = -1;
296 int subs = (trp.
alpha1()>0 ? 1 : 0);
300 fv.
rotation().GetComponents( x, y, z ) ;
301 const CLHEP::HepRep3x3
rotation ( x.X(), y.X(), z.X(),
303 x.Z(), y.Z(), z.Z() );
305 const CLHEP::Hep3Vector h3v ( fv.
translation().X(),
308 const HepGeom::Transform3D ht3d (hr, h3v);
309 transMap_.insert(std::make_pair(
id,ht3d));
312 <<
" Transform using " << h3v
313 <<
" and " << hr << std::endl;
319 <<
" elements and SymmDet_ = " 353 std::ostringstream histoname;
354 for (
unsigned int ilayer = 0; ilayer <
layers_; ilayer++ ) {
355 histoname.str(
""); histoname <<
"HitOccupancy_Plus_layer_" << ilayer;
357 histoname.str(
""); histoname <<
"HitOccupancy_Minus_layer_" << ilayer;
360 histoname.str(
""); histoname <<
"EtaPhi_Plus_" <<
"layer_" << ilayer;
362 histoname.str(
""); histoname <<
"EtaPhi_Minus_" <<
"layer_" << ilayer;
365 for (
unsigned int itimeslice = 0; itimeslice <
nTimes_ ; itimeslice++ ) {
366 histoname.str(
""); histoname <<
"energy_time_"<< itimeslice <<
"_layer_" << ilayer;
367 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)
std::pair< double, double > getEtaPhi(const int &subdet, const int &ieta, const int &iphi) const
HcalSubdetector subdet() const
get the subdetector
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)
#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 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_
double getRZ(const int &subdet, const int &ieta, const int &depth) const
Cos< T >::type cos(const T &t)
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
int ieta() const
get the cell ieta
MonitorElement * book1D(Args &&...args)
Interface to a Trapezoid.
std::pair< T, T > etaphi(T x, T y, T z)
HGCalGeometryMode::GeometryMode 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)
const HepMC::GenEvent * GetEvent() const
MonitorElement * book2D(Args &&...args)
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 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)