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" 66 cell=cell2=sector=sector2=
type=layer=0;
69 int cell, cell2, sector, sector2,
type, layer;
88 void fillHitsInfo(std::pair<hitsinfo,energysum> hit_,
unsigned int itimeslice,
double esum);
115 times_(iConfig.getParameter<
std::vector<double> >(
"TimeSlices")),
116 verbosity_(iConfig.getUntrackedParameter<
int>(
"Verbosity",0)),
128 std::vector<double>
times = {25.0,1000.0};
131 desc.
add<std::vector<double> >(
"TimeSlices",
times);
134 descriptions.
add(
"hgcalSimHitValidationEE",desc);
146 const HepMC::GenEvent * myGenEvent = evtMC->
GetEvent();
148 for (HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
149 p != myGenEvent->particles_end(); ++
p, ++
k) {
151 << (*p)->momentum().perp() <<
" eta " 152 << (*p)->momentum().eta() <<
" phi " 153 << (*p)->momentum().phi();
160 if (theCaloHitContainers.
isValid()) {
163 << theCaloHitContainers->size();
164 std::vector<PCaloHit> caloHits;
165 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(),
166 theCaloHitContainers->end());
168 for (
unsigned int i=0;
i<caloHits.size(); ++
i) {
169 unsigned int id_ = caloHits[
i].
id();
173 caloHits[
i].setID(hid.
rawId());
186 std::map<int, int> OccupancyMap_plus, OccupancyMap_minus;
187 OccupancyMap_plus.clear(); OccupancyMap_minus.clear();
189 std::map<uint32_t,std::pair<hitsinfo,energysum> > map_hits;
194 << hits.size() <<
" PcaloHit elements";
195 unsigned int nused(0);
196 for (
unsigned int i=0;
i<hits.size();
i++) {
197 double energy = hits[
i].energy();
198 double time = hits[
i].time();
199 uint32_t id_ = hits[
i].id();
200 int cell, sector, subsector(0), layer,
zside;
201 int subdet(0), cell2(0),
type(0);
205 if (subdet != static_cast<int>(
HcalEndcap))
continue;
207 sector = detId.
iphi();
209 layer = detId.
depth();
210 zside = detId.
zside();
215 cell = detId.
cellU();
216 cell2 = detId.
cellV();
218 subsector = detId.
waferV();
220 layer = detId.
layer();
221 zside = detId.
zside();
228 sector = detId.
iphi();
231 layer = detId.
layer();
232 zside = detId.
zside();
239 <<
" zside = " << zside
240 <<
" sector|wafer = " << sector
242 <<
" type = " << type
243 <<
" layer = " << layer
244 <<
" cell = " << cell
246 <<
" energy = " << energy
247 <<
" energyem = " << hits[
i].energyEM()
248 <<
" energyhad = " << hits[
i].energyHad()
249 <<
" time = " <<
time;
251 HepGeom::Point3D<float> gcoord;
255 double rz =
hcons_->
getRZ(subdet,zside*cell,layer);
258 << zside <<
":" << cell <<
":" 259 << sector <<
":" << layer <<
" o/p " 260 << etaphi.first <<
":" 261 << etaphi.second <<
":" << rz;
262 gcoord = HepGeom::Point3D<float>(rz*
cos(etaphi.second)/cosh(etaphi.first),
263 rz*
sin(etaphi.second)/cosh(etaphi.first),
264 rz*tanh(etaphi.first));
267 const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
268 int subs = (
symmDet_ ? 0 : subsector);
272 std::pair<float,float>
xy;
282 if (zside < 0) zp = -zp;
283 float xp = (zp < 0) ? -xy.first : xy.first;
284 gcoord = HepGeom::Point3D<float>(xp,xy.second,zp);
286 double tof = (gcoord.mag()*CLHEP::mm)/CLHEP::c_light;
289 <<
" global coordinate " << gcoord
290 <<
" time " << time <<
":" << tof;
295 if (map_hits.count(id_) != 0) {
296 hinfo = map_hits[id_].first;
297 esum = map_hits[id_].second;
299 hinfo.
x = gcoord.x();
300 hinfo.
y = gcoord.y();
301 hinfo.
z = gcoord.z();
308 hinfo.
phi = gcoord.getPhi();
309 hinfo.
eta = gcoord.getEta();
318 << hinfo.
x <<
" gy = " << hinfo.
y 319 <<
" gz = " << hinfo.
z <<
" phi = " 320 << hinfo.
phi <<
" eta = " 322 map_hits[id_] = std::pair<hitsinfo,energysum>(hinfo,esum);
327 <<
" detector elements being hit";
329 std::map<uint32_t,std::pair<hitsinfo,energysum> >::iterator itr;
330 for (itr = map_hits.begin() ; itr != map_hits.end(); ++itr) {
333 int layer = hinfo.
layer;
336 for (
unsigned int itimeslice = 0; itimeslice <
nTimes_; itimeslice++ ) {
343 edm::LogVerbatim(
"HGCalValidation") <<
"With map:used:total " << hits.size()
344 <<
"|" << nused <<
"|" << map_hits.size()
347 for (
auto const & itr : OccupancyMap_plus) {
348 int layer = itr.first;
349 int occupancy = itr.second;
352 for (
auto const & itr : OccupancyMap_minus) {
353 int layer = itr.first;
354 int occupancy = itr.second;
361 if (OccupancyMap.find(layer) != OccupancyMap.end()) {
362 ++OccupancyMap[layer];
364 OccupancyMap[layer] = 1;
369 unsigned int itimeslice,
double esum){
371 unsigned int ilayer = hits.first.layer;
373 energy_[itimeslice].at(ilayer)->Fill(esum);
375 EtaPhi_Plus_.at(ilayer) ->Fill(hits.first.eta , hits.first.phi);
376 EtaPhi_Minus_.at(ilayer)->Fill(hits.first.eta , hits.first.phi);
382 << hits.first.sector <<
":" 383 << hits.first.sector2 <<
" layer " 384 << hits.first.layer <<
" cell " 385 << hits.first.cell <<
":" 386 << hits.first.cell2 <<
" energy " 387 << hits.second.etotal;
408 int isd = (name.find(
nameDetector_) == std::string::npos) ? -1 : 1;
411 int nsiz = (
int)(copy.size());
412 int lay = (nsiz > 0) ? copy[nsiz-1] : -1;
413 int sec = (nsiz > 1) ? copy[nsiz-2] : -1;
414 int zp = (nsiz > 3) ? copy[nsiz-4] : -1;
415 if (zp !=1 ) zp = -1;
417 int subs = (trp.
alpha1()>0 ? 1 : 0);
421 fv.
rotation().GetComponents( x, y, z ) ;
422 const CLHEP::HepRep3x3
rotation ( x.X(), y.X(), z.X(),
424 x.Z(), y.Z(), z.Z() );
426 const CLHEP::Hep3Vector h3v ( fv.
translation().X(),
429 const HepGeom::Transform3D ht3d (hr, h3v);
430 transMap_.insert(std::make_pair(
id,ht3d));
433 <<
" Transform using " << h3v
440 <<
" elements and SymmDet_ = " 466 <<
layers_ <<
" Layers with first at " 476 std::ostringstream histoname;
477 for (
unsigned int il=0; il <
layers_; ++il) {
479 histoname.str(
""); histoname <<
"HitOccupancy_Plus_layer_" << ilayer;
481 histoname.str(
""); histoname <<
"HitOccupancy_Minus_layer_" << ilayer;
484 histoname.str(
""); histoname <<
"EtaPhi_Plus_" <<
"layer_" << ilayer;
486 histoname.str(
""); histoname <<
"EtaPhi_Minus_" <<
"layer_" << ilayer;
489 for (
unsigned int itimeslice = 0; itimeslice <
nTimes_ ; itimeslice++ ) {
490 histoname.str(
""); histoname <<
"energy_time_"<< itimeslice <<
"_layer_" << ilayer;
491 energy_[itimeslice].push_back(iB.
book1D(histoname.str().c_str(),
"energy_",100,0,0.1));
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MonitorElement * MeanHitOccupancy_Plus_
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)
#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)
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
unsigned int layers(bool reco) const
void setCurrentFolder(std::string const &fullpath)
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
MonitorElement * book1D(Args &&...args)
Interface to a Trapezoid.
std::pair< T, T > etaphi(T x, T y, T z)
~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
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 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)
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)