Skip to content

Commit

Permalink
Merge pull request #33199 from bsunanda/Run3-hcx294
Browse files Browse the repository at this point in the history
Run3-hcx294 Update HCAL code in material budget studies for DD4HEP
  • Loading branch information
cmsbuild committed Mar 19, 2021
2 parents b27fcd0 + 5899517 commit c7e8c5b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
22 changes: 14 additions & 8 deletions Validation/Geometry/src/MaterialBudgetHcalHistos.cc
Expand Up @@ -10,6 +10,8 @@
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"

#include "DD4hep/Filter.h"

#include <string>
#include <vector>

Expand Down Expand Up @@ -43,6 +45,7 @@ MaterialBudgetHcalHistos::MaterialBudgetHcalHistos(const edm::ParameterSet& p) {
}

void MaterialBudgetHcalHistos::fillBeginJob(const DDCompactView& cpv) {
constexpr int32_t addLevel = 0;
if (fillHistos_) {
std::string attribute = "ReadOutName";
std::string value = "HcalHits";
Expand All @@ -66,7 +69,7 @@ void MaterialBudgetHcalHistos::fillBeginJob(const DDCompactView& cpv) {
<< value << " has " << hfNames_.size() << " elements";
for (unsigned int i = 0; i < hfNames_.size(); i++) {
int level = static_cast<int>(temp[i]);
hfLevels_.push_back(level);
hfLevels_.push_back(level + addLevel);
edm::LogVerbatim("MaterialBudgetFull")
<< "MaterialBudgetHcalHistos: HF[" << i << "] = " << hfNames_[i] << " at level " << hfLevels_[i];
}
Expand All @@ -90,6 +93,7 @@ void MaterialBudgetHcalHistos::fillBeginJob(const DDCompactView& cpv) {
}

void MaterialBudgetHcalHistos::fillBeginJob(const cms::DDCompactView& cpv) {
constexpr int32_t addLevel = 1;
if (fillHistos_) {
std::string attribute = "ReadOutName";
std::string value = "HcalHits";
Expand All @@ -110,7 +114,7 @@ void MaterialBudgetHcalHistos::fillBeginJob(const cms::DDCompactView& cpv) {
edm::LogVerbatim("MaterialBudgetFull") << "MaterialBudgetHcalHistos: Names to be tested for " << attribute << " = "
<< value << " has " << hfNames_.size() << " elements";
for (unsigned int i = 0; i < hfNames_.size(); i++) {
hfLevels_.push_back(temp[i]);
hfLevels_.push_back(temp[i] + addLevel);
edm::LogVerbatim("MaterialBudgetFull")
<< "MaterialBudgetHcalHistos: HF[" << i << "] = " << hfNames_[i] << " at level " << hfLevels_[i];
}
Expand Down Expand Up @@ -171,8 +175,8 @@ void MaterialBudgetHcalHistos::fillPerStep(const G4Step* aStep) {

int idOld = id_;
const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
std::string name = touch->GetVolume(0)->GetName();
const std::string& matName = material->GetName();
std::string name = (static_cast<std::string>(dd4hep::dd::noNamespace(touch->GetVolume(0)->GetName())));
std::string matName = (static_cast<std::string>(dd4hep::dd::noNamespace(material->GetName())));
if (printSum_) {
bool found = false;
for (unsigned int ii = 0; ii < matList_.size(); ii++) {
Expand Down Expand Up @@ -272,9 +276,10 @@ void MaterialBudgetHcalHistos::fillPerStep(const G4Step* aStep) {
if (id_ == 21) {
if (!isItHF(aStep->GetPostStepPoint()->GetTouchable())) {
if ((abseta >= etaMinP_) && (abseta <= etaMaxP_))
edm::LogVerbatim("MaterialBudget")
<< "MaterialBudgetHcalHistos: After HF in " << name << ":"
<< aStep->GetPostStepPoint()->GetTouchable()->GetVolume(0)->GetName() << " calls fillHisto with " << id_;
edm::LogVerbatim("MaterialBudget") << "MaterialBudgetHcalHistos: After HF in " << name << ":"
<< static_cast<std::string>(dd4hep::dd::noNamespace(
aStep->GetPostStepPoint()->GetTouchable()->GetVolume(0)->GetName()))
<< " calls fillHisto with " << id_;
fillHisto(idOld);
++id_;
layer_ = 0;
Expand Down Expand Up @@ -595,7 +600,8 @@ bool MaterialBudgetHcalHistos::isItHF(const G4VTouchable* touch) {
int levels = ((touch->GetHistoryDepth()) + 1);
for (unsigned int it = 0; it < hfNames_.size(); it++) {
if (levels >= hfLevels_[it]) {
std::string name = touch->GetVolume(levels - hfLevels_[it])->GetName();
std::string name =
(static_cast<std::string>(dd4hep::dd::noNamespace(touch->GetVolume(levels - hfLevels_[it])->GetName())));
if (name == hfNames_[it]) {
return true;
}
Expand Down
13 changes: 1 addition & 12 deletions Validation/Geometry/test/runP_HCAL_Debug_dd4hep_cfg.py
Expand Up @@ -4,6 +4,7 @@
process = cms.Process('PROD',Run3_dd4hep)

process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")
process.load('Configuration.Geometry.GeometryDD4hepExtended2021_cff')
process.load("Configuration.StandardSequences.MagneticField_38T_cff")
process.load("SimG4Core.Application.g4SimHits_cfi")
process.load("GeneratorInterface.Core.generatorSmeared_cfi")
Expand All @@ -21,18 +22,6 @@
process.MessageLogger.MaterialBudget=dict()
# process.MessageLogger.MaterialBudgetFull=dict()

process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer",
confGeomXMLFiles = cms.FileInPath('Validation/Geometry/data/cmsExtendedGeometryNoMuon2021.xml'),
appendToDataLabel = cms.string(''))
process.DDSpecParRegistryESProducer = cms.ESProducer("DDSpecParRegistryESProducer",
appendToDataLabel = cms.string(''))
process.DDVectorRegistryESProducer = cms.ESProducer("DDVectorRegistryESProducer",
appendToDataLabel = cms.string(''))
process.DDCompactViewESProducer = cms.ESProducer("DDCompactViewESProducer",
appendToDataLabel = cms.string(''))
process.load("Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cff")
process.load("Geometry.EcalCommonData.ecalSimulationParameters_cff")
process.load("Geometry.HcalCommonData.hcalDDDSimConstants_cff")

process.source = cms.Source("EmptySource",
firstRun = cms.untracked.uint32(1),
Expand Down

0 comments on commit c7e8c5b

Please sign in to comment.