Skip to content

Commit 98fd036

Browse files
authored
Merge pull request cms-sw#43250 from bsunanda/Phase2-hgx349
Phase2-hgx349 Modify the material budget script to enable obtaining material budget plots for HFNose
2 parents e9fb336 + 1cecf30 commit 98fd036

9 files changed

+203
-23
lines changed

Validation/Geometry/macros/MatBudgetVolume.C

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,29 @@ void etaPhiPlotComp4(std::string filePreFix = "files/matbdgRun3",
7575
bool debug = false);
7676
void setStyle();
7777

78-
const int nlay = 13;
79-
const int ngrp = 9;
80-
int nlayers[ngrp] = {5, 1, 1, 1, 1, 1, 1, 1, 1};
81-
int nflayer[ngrp] = {0, 5, 6, 7, 8, 9, 10, 11, 12};
82-
int colorLay[nlay] = {2, 2, 2, 2, 2, 3, 5, 4, 8, 6, 3, 7, 1};
83-
int styleLay[nlay] = {20, 20, 20, 20, 20, 21, 22, 23, 24, 25, 26, 27, 30};
84-
int legends[nlay] = {1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1};
78+
const int nlay = 14;
79+
const int ngrp = 10;
80+
int nlayers[ngrp] = {5, 1, 1, 1, 1, 1, 1, 1, 1, 1};
81+
int nflayer[ngrp] = {0, 5, 6, 7, 8, 9, 10, 11, 12, 13};
82+
int colorLay[nlay] = {2, 2, 2, 2, 2, 3, 5, 4, 1, 6, 3, 7, 22, 46};
83+
int styleLay[nlay] = {20, 20, 20, 20, 20, 21, 22, 23, 24, 25, 26, 27, 32, 34};
84+
int legends[nlay] = {1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1};
8585
std::string title[nlay] = {
86-
"Beam Pipe", "", "", "", "", "Tracker", "ECAL", "HCAL", "HGCAL", "HF", "Magnet", "MUON", "Forward"};
87-
std::string names[nlay] = {
88-
"BEAM", "BEAM1", "BEAM2", "BEAM3", "BEAM4", "Tracker", "ECAL", "HCal", "CALOEC", "VCAL", "MGNT", "MUON", "OQUA"};
86+
"Beam Pipe", "", "", "", "", "Tracker", "ECAL", "HCAL", "HGCAL", "HF", "Magnet", "MUON", "Forward", "HFNose"};
87+
std::string names[nlay] = {"BEAM",
88+
"BEAM1",
89+
"BEAM2",
90+
"BEAM3",
91+
"BEAM4",
92+
"Tracker",
93+
"ECAL",
94+
"HCal",
95+
"CALOEC",
96+
"VCAL",
97+
"MGNT",
98+
"MUON",
99+
"OQUA",
100+
"HFNoseVol"};
89101

90102
void etaPhiPlot(TString fileName, std::string plot, bool drawLeg, bool ifEta, double maxEta, std::string tag) {
91103
TFile *hcalFile = new TFile(fileName);

Validation/Geometry/python/materialBudgetVolume_cfi.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44
g4SimHits.Watchers = cms.VPSet(cms.PSet(
55
MaterialBudgetVolume = cms.PSet(
6-
lvNames = cms.vstring('BEAM', 'BEAM1', 'BEAM2', 'BEAM3', 'BEAM4', 'Tracker', 'ECAL', 'HCal', 'VCAL', 'MGNT', 'MUON', 'OQUA', 'CALOEC'),
7-
lvLevels = cms.vint32(3, 3, 3, 3, 3, 3, 4, 4, 3, 4, 3, 3, 4),
6+
lvNames = cms.vstring('BEAM', 'BEAM1', 'BEAM2', 'BEAM3', 'BEAM4', 'Tracker', 'ECAL', 'HCal', 'VCAL', 'MGNT', 'MUON', 'OQUA', 'CALOEC', 'HFNoseVol'),
7+
lvLevels = cms.vint32(3, 3, 3, 3, 3, 3, 4, 4, 3, 4, 3, 3, 4, 3),
88
useDD4hep = cms.bool(False),
9+
rMax = cms.double(-1.),
10+
zMax = cms.double(-1.),
911
),
1012
type = cms.string('MaterialBudgetVolume'),
1113
))

Validation/Geometry/src/MaterialBudgetVolume.cc

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@ class MaterialBudgetVolume : public SimProducer,
6363
void endOfEvent(edm::MaterialInformationContainer& matbg);
6464
bool loadLV();
6565
int findLV(const G4VTouchable*);
66+
bool stopAfter(const G4Step*);
6667

6768
private:
6869
std::vector<std::string> lvNames_;
6970
std::vector<int> lvLevel_;
7071
int iaddLevel_;
72+
double rMax_, zMax_;
7173
bool init_;
7274
std::map<int, std::pair<G4LogicalVolume*, int> > mapLV_;
7375
std::vector<MatInfo> lengths_;
@@ -80,9 +82,12 @@ MaterialBudgetVolume::MaterialBudgetVolume(const edm::ParameterSet& p) : init_(f
8082
lvNames_ = m_p.getParameter<std::vector<std::string> >("lvNames");
8183
lvLevel_ = m_p.getParameter<std::vector<int> >("lvLevels");
8284
iaddLevel_ = (m_p.getParameter<bool>("useDD4hep")) ? 1 : 0;
85+
rMax_ = m_p.getParameter<double>("rMax") * CLHEP::m;
86+
zMax_ = m_p.getParameter<double>("zMax") * CLHEP::m;
8387

8488
edm::LogVerbatim("MaterialBudget") << "MaterialBudgetVolume: Studies Material budget for " << lvNames_.size()
85-
<< " volumes with addLevel " << iaddLevel_;
89+
<< " volumes with addLevel " << iaddLevel_ << " and with rMax " << rMax_
90+
<< " mm; zMax " << zMax_ << " mm";
8691
std::ostringstream st1;
8792
for (unsigned int k = 0; k < lvNames_.size(); ++k)
8893
st1 << " [" << k << "] " << lvNames_[k] << " at " << lvLevel_[k];
@@ -151,6 +156,12 @@ void MaterialBudgetVolume::update(const G4Step* aStep) {
151156
<< touch->GetVolume(0)->GetLogicalVolume()->GetName() << " Index " << index
152157
<< " Step " << step << " RadL " << step / radl << " IntL " << step / intl;
153158
#endif
159+
160+
//----- Stop tracking after selected position
161+
if (stopAfter(aStep)) {
162+
G4Track* track = aStep->GetTrack();
163+
track->SetTrackStatus(fStopAndKill);
164+
}
154165
}
155166

156167
void MaterialBudgetVolume::update(const EndOfTrack* trk) {
@@ -242,6 +253,23 @@ int MaterialBudgetVolume::findLV(const G4VTouchable* touch) {
242253
return level;
243254
}
244255

256+
bool MaterialBudgetVolume::stopAfter(const G4Step* aStep) {
257+
bool flag(false);
258+
if ((rMax_ > 0.0) && (zMax_ > 0.0)) {
259+
G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition();
260+
double rr = hitPoint.perp();
261+
double zz = std::abs(hitPoint.z());
262+
263+
if (rr > rMax_ || zz > zMax_) {
264+
#ifdef EDM_ML_DEBUG
265+
edm::LogVerbatim("MaterialBudget") << " MaterialBudgetHcal::StopAfter R = " << rr << " and Z = " << zz;
266+
#endif
267+
flag = true;
268+
}
269+
}
270+
return flag;
271+
}
272+
245273
#include "FWCore/Framework/interface/MakerMacros.h"
246274
#include "FWCore/PluginManager/interface/ModuleDef.h"
247275
#include "SimG4Core/Watcher/interface/SimWatcherFactory.h"

Validation/Geometry/src/MaterialBudgetVolumeAnalysis.cc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,20 @@ MaterialBudgetVolumeAnalysis::MaterialBudgetVolumeAnalysis(const edm::ParameterS
7070

7171
void MaterialBudgetVolumeAnalysis::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
7272
edm::ParameterSetDescription desc;
73-
std::vector<std::string> names = {
74-
"BEAM", "BEAM1", "BEAM2", "BEAM3", "BEAM4", "Tracker", "ECAL", "HCal", "MUON", "VCAL", "MGNT", "OQUA", "CALOEC"};
73+
std::vector<std::string> names = {"BEAM",
74+
"BEAM1",
75+
"BEAM2",
76+
"BEAM3",
77+
"BEAM4",
78+
"Tracker",
79+
"ECAL",
80+
"HCal",
81+
"MUON",
82+
"VCAL",
83+
"MGNT",
84+
"OQUA",
85+
"CALOEC",
86+
"HFNoseVol"};
7587
desc.add<std::vector<std::string> >("names", names);
7688
desc.add<edm::InputTag>("inputTag", edm::InputTag("g4SimHits", "MaterialInformation"));
7789
desc.add<int>("nBinEta", 300);
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
###############################################################################
2+
# Way to use this:
3+
# cmsRun runMaterialBudgetHFNose_cfg.py geometry=D94 type=DD4hep pos=Start
4+
#
5+
# Options for geometry D92, D94
6+
# Options for type DD4hep, DDD
7+
# Options for pos Start, End
8+
#
9+
###############################################################################
10+
import FWCore.ParameterSet.Config as cms
11+
import os, sys, importlib, re
12+
import FWCore.ParameterSet.VarParsing as VarParsing
13+
14+
####################################################################
15+
### SETUP OPTIONS
16+
options = VarParsing.VarParsing('standard')
17+
options.register('geometry',
18+
"D94",
19+
VarParsing.VarParsing.multiplicity.singleton,
20+
VarParsing.VarParsing.varType.string,
21+
"geometry of operations: D92, D94")
22+
options.register('type',
23+
"DDD",
24+
VarParsing.VarParsing.multiplicity.singleton,
25+
VarParsing.VarParsing.varType.string,
26+
"type of operations: DDD, DD4hep")
27+
options.register('pos',
28+
"Start",
29+
VarParsing.VarParsing.multiplicity.singleton,
30+
VarParsing.VarParsing.varType.string,
31+
"type of operations: Start, End")
32+
### get and parse the command line arguments
33+
options.parseArguments()
34+
35+
print(options)
36+
37+
####################################################################
38+
# Use the options
39+
40+
if (options.geometry == "D94"):
41+
nose = 1
42+
else:
43+
nose = 0
44+
45+
if (options.type == "DD4hep"):
46+
flag = "DD4hep"
47+
ddFlag = True
48+
else:
49+
flag = ""
50+
ddFlag = False
51+
52+
if (options.pos == "End"):
53+
zMax = 10.560
54+
tag = "End"
55+
else:
56+
zMax = 9.6072
57+
tag = "Front"
58+
59+
from Configuration.ProcessModifiers.dd4hep_cff import dd4hep
60+
if (nose == 1):
61+
from Configuration.Eras.Era_Phase2C20I13M9_cff import Phase2C20I13M9
62+
if (ddFlag == True):
63+
process = cms.Process('MaterialBudgetVolume',Phase2C20I13M9,dd4hep)
64+
else:
65+
process = cms.Process('MaterialBudgetVolume',Phase2C20I13M9)
66+
else:
67+
from Configuration.Eras.Era_Phase2C17I13M9_cff import Phase2C17I13M9
68+
if (ddFlag == True):
69+
process = cms.Process('MaterialBudgetVolume',Phase2C17I13M9,dd4hep)
70+
else:
71+
process = cms.Process('MaterialBudgetVolume',Phase2C17I13M9)
72+
73+
geomFile = "Configuration.Geometry.Geometry" + flag + "Extended2026" + options.geometry + "Reco_cff"
74+
fileName = "matbdgHFNose" + flag + options.geometry + tag + ".root"
75+
76+
print("Geometry file Name: ", geomFile)
77+
print("Root file Name: ", fileName)
78+
print("nose Flag: ", nose)
79+
print("ddFlag Flag: ", ddFlag)
80+
print("zMax (m): ", zMax)
81+
82+
process.load(geomFile)
83+
process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")
84+
process.load("Configuration.StandardSequences.MagneticField_cff")
85+
process.load("SimG4Core.Application.g4SimHits_cfi")
86+
87+
process.load("IOMC.RandomEngine.IOMC_cff")
88+
process.RandomNumberGeneratorService.g4SimHits.initialSeed = 9876
89+
90+
process.load('FWCore.MessageService.MessageLogger_cfi')
91+
process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32(1000)
92+
if hasattr(process,'MessageLogger'):
93+
process.MessageLogger.MaterialBudget=dict()
94+
95+
process.source = cms.Source("PoolSource",
96+
noEventSort = cms.untracked.bool(True),
97+
duplicateCheckMode = cms.untracked.string("noDuplicateCheck"),
98+
fileNames = cms.untracked.vstring('file:single_neutrino_random.root')
99+
)
100+
101+
process.maxEvents = cms.untracked.PSet(
102+
input = cms.untracked.int32(-1)
103+
)
104+
105+
process.TFileService = cms.Service("TFileService",
106+
fileName = cms.string(fileName)
107+
)
108+
109+
process.g4SimHits.UseMagneticField = False
110+
process.g4SimHits.Physics.type = 'SimG4Core/Physics/DummyPhysics'
111+
process.g4SimHits.StackingAction.TrackNeutrino = True
112+
process.g4SimHits.Physics.DummyEMPhysics = True
113+
process.g4SimHits.Physics.CutsPerRegion = False
114+
process.g4SimHits.Watchers = cms.VPSet(cms.PSet(
115+
MaterialBudgetVolume = cms.PSet(
116+
lvNames = cms.vstring('BEAM', 'BEAM1', 'BEAM2', 'BEAM3', 'BEAM4', 'Tracker', 'ECAL', 'HCal', 'VCAL', 'MGNT', 'MUON', 'OQUA', 'CALOEC', 'HFNoseVol'),
117+
lvLevels = cms.vint32(3, 3, 3, 3, 3, 3, 4, 4, 3, 4, 3, 3, 4, 3),
118+
useDD4hep = cms.bool(ddFlag),
119+
rMax = cms.double(1.8),
120+
zMax = cms.double(zMax),
121+
),
122+
type = cms.string('MaterialBudgetVolume'),
123+
))
124+
125+
process.load("Validation.Geometry.materialBudgetVolumeAnalysis_cfi")
126+
process.p1 = cms.Path(process.g4SimHits+process.materialBudgetVolumeAnalysis)

Validation/Geometry/test/runMaterialBudgetVolume2026DD4hep_cfg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
# cmsRun runMaterialBudgetVolume2026DD4hep_cfg.py geometry=D92
44
#
55
# Options for geometry D86, D88, D91, D92, D93, D94, D95, D96, D97, D98,
6-
# D99, D100, D101
6+
# D99, D100, D101, D102, D103
77
#
88
###############################################################################
99
import FWCore.ParameterSet.Config as cms
10-
import os, sys, imp, re
10+
import os, sys, importlib, re
1111
import FWCore.ParameterSet.VarParsing as VarParsing
1212

1313
####################################################################
@@ -17,7 +17,7 @@
1717
"D88",
1818
VarParsing.VarParsing.multiplicity.singleton,
1919
VarParsing.VarParsing.varType.string,
20-
"geometry of operations: D86, D88, D91, D92, D93, D94, D95, D96, D97, D98, D99, D100, D101")
20+
"geometry of operations: D86, D88, D91, D92, D93, D94, D95, D96, D97, D98, D99, D100, D101, D102, D103")
2121
### get and parse the command line arguments
2222
options.parseArguments()
2323

Validation/Geometry/test/runMaterialBudgetVolume2026DDD_cfg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
# cmsRun runMaterialBudgetVolume2026DDD_cfg.py geometry=D92
44
#
55
# Options for geometry D86, D88, D91, D92, D93, D94, D95, D96, D97, D98,
6-
# D99, D100, D101
6+
# D99, D100, D101, D102, D103
77
#
88
###############################################################################
99
import FWCore.ParameterSet.Config as cms
10-
import os, sys, imp, re
10+
import os, sys, importlib, re
1111
import FWCore.ParameterSet.VarParsing as VarParsing
1212

1313
####################################################################
@@ -17,7 +17,7 @@
1717
"D88",
1818
VarParsing.VarParsing.multiplicity.singleton,
1919
VarParsing.VarParsing.varType.string,
20-
"geometry of operations: D86, D88, D91, D92, D93, D94, D95, D96, D97, D98, D99, D100, D101")
20+
"geometry of operations: D86, D88, D91, D92, D93, D94, D95, D96, D97, D98, D99, D100, D101, D102, D103")
2121
### get and parse the command line arguments
2222
options.parseArguments()
2323

Validation/Geometry/test/runMaterialBudgetVolumeDB_cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
###############################################################################
88
import FWCore.ParameterSet.Config as cms
9-
import os, sys, imp, re
9+
import os, sys, importlib, re
1010
import FWCore.ParameterSet.VarParsing as VarParsing
1111

1212
####################################################################

Validation/Geometry/test/runMaterialBudgetVolumeXML_cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
###############################################################################
88
import FWCore.ParameterSet.Config as cms
9-
import os, sys, imp, re
9+
import os, sys, importlib, re
1010
import FWCore.ParameterSet.VarParsing as VarParsing
1111

1212
####################################################################

0 commit comments

Comments
 (0)