diff --git a/Geometry/HGCalGeometry/test/HGCalGeometryDump.cc b/Geometry/HGCalGeometry/test/HGCalGeometryDump.cc index f2d8a52ff34fc..d5be4bb6c1fd0 100644 --- a/Geometry/HGCalGeometry/test/HGCalGeometryDump.cc +++ b/Geometry/HGCalGeometry/test/HGCalGeometryDump.cc @@ -1,6 +1,5 @@ #include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" diff --git a/Geometry/HGCalGeometry/test/HGCalTestRecHitTool.cc b/Geometry/HGCalGeometry/test/HGCalTestRecHitTool.cc index d2c682ffac380..db104d24f0427 100644 --- a/Geometry/HGCalGeometry/test/HGCalTestRecHitTool.cc +++ b/Geometry/HGCalGeometry/test/HGCalTestRecHitTool.cc @@ -8,7 +8,6 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" diff --git a/Validation/HGCalValidation/plugins/HGCGeometryValidation.cc b/Validation/HGCalValidation/plugins/HGCGeometryValidation.cc index 191b52e11c38f..6967f86f9f583 100644 --- a/Validation/HGCalValidation/plugins/HGCGeometryValidation.cc +++ b/Validation/HGCalValidation/plugins/HGCGeometryValidation.cc @@ -2,10 +2,7 @@ #include #include "Geometry/Records/interface/IdealGeometryRecord.h" -#include "Geometry/Records/interface/HcalSimNumberingRecord.h" #include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h" -#include "Geometry/HcalCommonData/interface/HcalDDDSimConstants.h" -#include "Geometry/HcalCommonData/interface/HcalCellType.h" #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h" @@ -29,7 +26,6 @@ #include "SimDataFormats/CaloHit/interface/PCaloHit.h" #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h" #include "SimDataFormats/ValidationFormats/interface/PHGCalValidInfo.h" -#include "DataFormats/HcalDetId/interface/HcalTestNumbering.h" #include "SimDataFormats/CaloTest/interface/HGCalTestNumbering.h" #include "PhysicsTools/HepMCCandAlgos/interface/GenParticlesHelper.h" @@ -56,10 +52,10 @@ class HGCGeometryValidation : public DQMEDAnalyzer { edm::EDGetTokenT g4Token_; std::vector geometrySource_; int verbosity_; + std::vector> geomToken_; //HGCal geometry scheme std::vector hgcGeometry_; - const HcalDDDSimConstants *hcons_; //histogram related stuff MonitorElement *heedzVsZ, *heedyVsY, *heedxVsX; @@ -79,10 +75,13 @@ class HGCGeometryValidation : public DQMEDAnalyzer { MonitorElement *hebdX, *hebdY, *hebdZ; }; -HGCGeometryValidation::HGCGeometryValidation(const edm::ParameterSet &cfg) : hcons_(nullptr) { +HGCGeometryValidation::HGCGeometryValidation(const edm::ParameterSet &cfg) { g4Token_ = consumes(cfg.getParameter("g4Source")); - geometrySource_ = cfg.getUntrackedParameter >("geometrySource"); + geometrySource_ = cfg.getUntrackedParameter>("geometrySource"); verbosity_ = cfg.getUntrackedParameter("verbosity", 0); + for (const auto &name : geometrySource_) + geomToken_.emplace_back( + esConsumes(edm::ESInputTag{"", name})); } HGCGeometryValidation::~HGCGeometryValidation() {} @@ -96,24 +95,7 @@ void HGCGeometryValidation::fillDescriptions(edm::ConfigurationDescriptions &des void HGCGeometryValidation::dqmBeginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) { //initiating hgcnumbering for (size_t i = 0; i < geometrySource_.size(); i++) { - if (geometrySource_[i].find("Hcal") != std::string::npos) { - edm::ESHandle pHRNDC; - iSetup.get().get(pHRNDC); - if (pHRNDC.isValid()) { - hcons_ = &(*pHRNDC); - hgcGeometry_.push_back(nullptr); - } else { - edm::LogWarning("HGCalValid") << "Cannot initiate HGCalGeometry for " << geometrySource_[i]; - } - } else { - edm::ESHandle hgcGeom; - iSetup.get().get(geometrySource_[i], hgcGeom); - if (hgcGeom.isValid()) { - hgcGeometry_.push_back(hgcGeom.product()); - } else { - edm::LogWarning("HGCalValid") << "Cannot initiate HGCalGeometry for " << geometrySource_[i]; - } - } + hgcGeometry_.emplace_back(&iSetup.getData(geomToken_[i])); } } @@ -301,36 +283,7 @@ void HGCGeometryValidation::analyze(const edm::Event &iEvent, const edm::EventSe hebdZ->Fill((hitVtxZ.at(i) - zz)); hebdY->Fill((hitVtxY.at(i) - yy)); } - - } else if (hitDet.at(i) == (unsigned int)(DetId::Hcal)) { - int subdet, zside, depth, eta, phi, lay; - HcalTestNumbering::unpackHcalIndex(hitIdx.at(i), subdet, zside, depth, eta, phi, lay); - HcalCellType::HcalCell cell = hcons_->cell(subdet, zside, lay, eta, phi); - - double zz = mmtocm * cell.rz; //mm --> cm - if (zside == 0) - zz = -zz; - double rho = zz * tan(2.0 * atan(exp(-cell.eta))); - double xx = rho * cos(cell.phi); //cm - double yy = rho * sin(cell.phi); //cm - - hebdzVsZ->Fill(zz, (hitVtxZ.at(i) - zz)); - hebdyVsY->Fill(yy, (hitVtxY.at(i) - yy)); - hebdxVsX->Fill(xx, (hitVtxX.at(i) - xx)); - - hebXG4VsId->Fill(hitVtxX.at(i), xx); - hebYG4VsId->Fill(hitVtxY.at(i), yy); - hebZG4VsId->Fill(hitVtxZ.at(i), zz); - - hebdzVsLayer->Fill(lay, (hitVtxZ.at(i) - zz)); - hebdyVsLayer->Fill(lay, (hitVtxY.at(i) - yy)); - hebdxVsLayer->Fill(lay, (hitVtxX.at(i) - xx)); - - hebdX->Fill((hitVtxX.at(i) - xx)); - hebdZ->Fill((hitVtxZ.at(i) - zz)); - hebdY->Fill((hitVtxY.at(i) - yy)); } - } //end G4 hits } else { diff --git a/Validation/HGCalValidation/plugins/SimG4HGCalValidation.cc b/Validation/HGCalValidation/plugins/SimG4HGCalValidation.cc index 0e4758e575892..c8ec4008e2822 100644 --- a/Validation/HGCalValidation/plugins/SimG4HGCalValidation.cc +++ b/Validation/HGCalValidation/plugins/SimG4HGCalValidation.cc @@ -12,12 +12,10 @@ // to retreive hits #include "DataFormats/DetId/interface/DetId.h" -#include "DataFormats/HcalDetId/interface/HcalSubdetector.h" #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h" #include "DataFormats/Math/interface/Point3D.h" #include "SimDataFormats/ValidationFormats/interface/PHGCalValidInfo.h" #include "SimDataFormats/CaloTest/interface/HGCalTestNumbering.h" -#include "DataFormats/HcalDetId/interface/HcalTestNumbering.h" #include "SimG4CMS/Calo/interface/HGCNumberingScheme.h" #include "SimG4CMS/Calo/interface/HGCalNumberingScheme.h" @@ -28,9 +26,6 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/Records/interface/IdealGeometryRecord.h" -#include "Geometry/Records/interface/HcalSimNumberingRecord.h" -#include "Geometry/HcalCommonData/interface/HcalNumberingFromDDD.h" -#include "Geometry/HcalCommonData/interface/HcalDDDSimConstants.h" #include "Geometry/HGCalCommonData/interface/HGCalGeometryMode.h" #include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h" @@ -79,9 +74,6 @@ class SimG4HGCalValidation : public SimProducer, void clear(); private: - //Keep reference to instantiate HcalNumberingFromDDD later - HcalNumberingFromDDD* numberingFromDDD_; - //HGCal numbering scheme std::vector hgcNumbering_; std::vector hgcalNumbering_; @@ -103,8 +95,7 @@ class SimG4HGCalValidation : public SimProducer, std::vector hgchitX_, hgchitY_, hgchitZ_; }; -SimG4HGCalValidation::SimG4HGCalValidation(const edm::ParameterSet& p) - : numberingFromDDD_(nullptr), levelT1_(999), levelT2_(999), count_(0) { +SimG4HGCalValidation::SimG4HGCalValidation(const edm::ParameterSet& p) : levelT1_(999), levelT2_(999), count_(0) { edm::ParameterSet m_Anal = p.getParameter("SimG4HGCalValidation"); names_ = m_Anal.getParameter >("Names"); types_ = m_Anal.getParameter >("Types"); @@ -126,7 +117,6 @@ SimG4HGCalValidation::SimG4HGCalValidation(const edm::ParameterSet& p) } SimG4HGCalValidation::~SimG4HGCalValidation() { - delete numberingFromDDD_; for (auto number : hgcNumbering_) delete number; for (auto number : hgcalNumbering_) @@ -190,18 +180,8 @@ void SimG4HGCalValidation::update(const BeginOfJob* job) { throw cms::Exception("Unknown", "ValidHGCal") << "Cannot find HGCalDDDConstants for " << nameX << "\n"; } } else { - nameX = "HcalEndcap"; - dets_.push_back((unsigned int)(DetId::Hcal)); - subdet_.push_back((int)(HcalSubdetector::HcalEndcap)); - edm::ESHandle hdc; - es->get().get(hdc); - if (hdc.isValid()) { - numberingFromDDD_ = new HcalNumberingFromDDD(hdc.product()); - layers = 18; - } else { - edm::LogError("ValidHGCal") << "Cannot find HcalDDDSimConstant"; - throw cms::Exception("Unknown", "ValidHGCal") << "Cannot find HcalDDDSimConstant\n"; - } + edm::LogError("ValidHGCal") << "Wrong Type " << types_[type]; + throw cms::Exception("Unknown", "ValidHGCal") << "Wrong Type " << types_[type] << "\n"; } if (detType == 0) { for (int i = 0; i < layers; ++i) @@ -272,51 +252,35 @@ void SimG4HGCalValidation::update(const G4Step* aStep) { unsigned int index(0); int layer(0); G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition(); - if (types_[type] <= 1) { - // HGCal - G4ThreeVector localpos = touchable->GetHistory()->GetTopTransform().TransformPoint(hitPoint); - float globalZ = touchable->GetTranslation(0).z(); - int iz(globalZ > 0 ? 1 : -1); - int module(-1), cell(-1); - if (types_[type] == 1) { - if (touchable->GetHistoryDepth() == levelT1_) { - layer = touchable->GetReplicaNumber(0); - } else { - layer = touchable->GetReplicaNumber(2); - module = touchable->GetReplicaNumber(1); - cell = touchable->GetReplicaNumber(0); - } - index = - hgcNumbering_[type]->getUnitID((ForwardSubdetector)(subdet_[type]), layer, module, cell, iz, localpos); + // HGCal + G4ThreeVector localpos = touchable->GetHistory()->GetTopTransform().TransformPoint(hitPoint); + float globalZ = touchable->GetTranslation(0).z(); + int iz(globalZ > 0 ? 1 : -1); + int module(-1), cell(-1); + if (types_[type] == 1) { + if (touchable->GetHistoryDepth() == levelT1_) { + layer = touchable->GetReplicaNumber(0); } else { - if ((touchable->GetHistoryDepth() == levelT1_) || (touchable->GetHistoryDepth() == levelT2_)) { - layer = touchable->GetReplicaNumber(0); - } else { - layer = touchable->GetReplicaNumber(3); - module = touchable->GetReplicaNumber(2); - cell = touchable->GetReplicaNumber(1); - } - double weight(0); - index = hgcalNumbering_[type]->getUnitID(layer, module, cell, iz, hitPoint, weight); + layer = touchable->GetReplicaNumber(2); + module = touchable->GetReplicaNumber(1); + cell = touchable->GetReplicaNumber(0); } - if (verbosity_ > 1) - edm::LogVerbatim("ValidHGCal") - << "HGCal: " << name << " Layer " << layer << " Module " << module << " Cell " << cell; + index = + hgcNumbering_[type]->getUnitID((ForwardSubdetector)(subdet_[type]), layer, module, cell, iz, localpos); } else { - // Hcal - int depth = (touchable->GetReplicaNumber(0)) % 10 + 1; - int lay = (touchable->GetReplicaNumber(0) / 10) % 100 + 1; - int det = (touchable->GetReplicaNumber(1)) / 1000; - HcalNumberingFromDDD::HcalID tmp = - numberingFromDDD_->unitID(det, math::XYZVectorD(hitPoint.x(), hitPoint.y(), hitPoint.z()), depth, lay); - index = HcalTestNumbering::packHcalIndex(tmp.subdet, tmp.zside, tmp.depth, tmp.etaR, tmp.phis, tmp.lay); - layer = tmp.lay; - if (verbosity_ > 1) - edm::LogVerbatim("ValidHGCal") - << "HCAL: " << det << ":" << depth << ":" << lay << " o/p " << tmp.subdet << ":" << tmp.zside << ":" - << tmp.depth << ":" << tmp.etaR << ":" << tmp.phis << ":" << tmp.lay << " point " << hitPoint << " " - << hitPoint.rho() << ":" << hitPoint.eta() << ":" << hitPoint.phi(); + if ((touchable->GetHistoryDepth() == levelT1_) || (touchable->GetHistoryDepth() == levelT2_)) { + layer = touchable->GetReplicaNumber(0); + } else { + layer = touchable->GetReplicaNumber(3); + module = touchable->GetReplicaNumber(2); + cell = touchable->GetReplicaNumber(1); + } + double weight(0); + index = hgcalNumbering_[type]->getUnitID(layer, module, cell, iz, hitPoint, weight); } + if (verbosity_ > 1) + edm::LogVerbatim("ValidHGCal") << "HGCal: " << name << " Layer " << layer << " Module " << module << " Cell " + << cell; double edeposit = aStep->GetTotalEnergyDeposit(); if (verbosity_ > 0) diff --git a/Validation/HGCalValidation/python/hgcGeometryValidationV6_cfi.py b/Validation/HGCalValidation/python/hgcGeometryValidationV6_cfi.py deleted file mode 100644 index ca2a7bc10e95e..0000000000000 --- a/Validation/HGCalValidation/python/hgcGeometryValidationV6_cfi.py +++ /dev/null @@ -1,26 +0,0 @@ -import FWCore.ParameterSet.Config as cms -from SimG4Core.Configuration.SimG4Core_cff import * - -g4SimHits.Watchers = cms.VPSet(cms.PSet( - SimG4HGCalValidation = cms.PSet( - Names = cms.vstring( - 'HGCalEECell', - 'HGCalHECell', - 'HEScintillator', - ), - Types = cms.vint32(1,1,2), - LabelLayerInfo = cms.string("HGCalInfoLayer"), - ), - type = cms.string('SimG4HGCalValidation') - ) - ) - -from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer -hgcGeomAnalysis = DQMEDAnalyzer('HGCGeometryValidation', - geometrySource = cms.untracked.vstring( - 'HGCalEESensitive', - 'HGCalHESiliconSensitive', - 'Hcal'), - g4Source = cms.InputTag("g4SimHits","HGCalInfoLayer"), - verbosity= cms.int32(0), - ) diff --git a/Validation/HGCalValidation/python/hgcGeometryValidationV9_cfi.py b/Validation/HGCalValidation/python/hgcGeometryValidationV9_cfi.py deleted file mode 100644 index 07922948b8644..0000000000000 --- a/Validation/HGCalValidation/python/hgcGeometryValidationV9_cfi.py +++ /dev/null @@ -1,26 +0,0 @@ -import FWCore.ParameterSet.Config as cms -from SimG4Core.Configuration.SimG4Core_cff import * - -g4SimHits.Watchers = cms.VPSet(cms.PSet( - SimG4HGCalValidation = cms.PSet( - Names = cms.vstring( - 'HGCalEESensitive', - 'HGCalHESiliconSensitive', - 'HGCalHEScintillatorSensitive', - ), - Types = cms.vint32(1,1,1), - LabelLayerInfo = cms.string("HGCalInfoLayer"), - ), - type = cms.string('SimG4HGCalValidation') - ) - ) - -from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer -hgcGeomAnalysis = DQMEDAnalyzer('HGCGeometryValidation', - geometrySource = cms.untracked.vstring( - 'HGCalEESensitive', - 'HGCalHESiliconSensitive', - 'HGCalHEScintillatorSensitive'), - g4Source = cms.InputTag("g4SimHits","HGCalInfoLayer"), - verbosity= cms.int32(0), - ) diff --git a/Validation/HGCalValidation/python/hgcGeometryValidation_cfi.py b/Validation/HGCalValidation/python/hgcGeometryValidation_cfi.py index ca2a7bc10e95e..07922948b8644 100644 --- a/Validation/HGCalValidation/python/hgcGeometryValidation_cfi.py +++ b/Validation/HGCalValidation/python/hgcGeometryValidation_cfi.py @@ -4,11 +4,11 @@ g4SimHits.Watchers = cms.VPSet(cms.PSet( SimG4HGCalValidation = cms.PSet( Names = cms.vstring( - 'HGCalEECell', - 'HGCalHECell', - 'HEScintillator', + 'HGCalEESensitive', + 'HGCalHESiliconSensitive', + 'HGCalHEScintillatorSensitive', ), - Types = cms.vint32(1,1,2), + Types = cms.vint32(1,1,1), LabelLayerInfo = cms.string("HGCalInfoLayer"), ), type = cms.string('SimG4HGCalValidation') @@ -20,7 +20,7 @@ geometrySource = cms.untracked.vstring( 'HGCalEESensitive', 'HGCalHESiliconSensitive', - 'Hcal'), + 'HGCalHEScintillatorSensitive'), g4Source = cms.InputTag("g4SimHits","HGCalInfoLayer"), verbosity= cms.int32(0), )