Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run3-sim104 Update the tools to investigate geometry setups #35015

Merged
merged 2 commits into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 25 additions & 4 deletions SimG4Core/PrintGeomInfo/test/SimFileCompare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ void CompareFiles(const char* fileFile1, const char* fileFile2, int type, int fi
std::cout << "\nEntries in " << fileFile1 << " and " << fileFile2 << " do not match in the content\n";
const double denmin = 0.0001;
int kount1(0), kount2(0);
double difmax1(0), difmax2(0);
std::string nameMax("");
if (type == 0) {
const double tol1 = 0.00001;
for (auto it1 : matFile1) {
Expand All @@ -285,6 +287,11 @@ void CompareFiles(const char* fileFile1, const char* fileFile2, int type, int fi
0.5 * (it1.second.radl - it2->second.radl) / std::max(denmin, (it1.second.radl + it2->second.radl));
double idif =
0.5 * (it1.second.intl - it2->second.intl) / std::max(denmin, (it1.second.intl + it2->second.intl));
if (std::abs(rdif) > difmax1) {
difmax1 = std::abs(rdif);
difmax2 = std::abs(idif);
nameMax = it1.first;
}
if ((std::abs(rdif) > tol1) || (std::abs(idif) > tol1)) {
++kount2;
std::cout << it1.first << " X0 " << it1.second.radl << ":" << it2->second.radl << ":" << rdif << " #L "
Expand All @@ -293,7 +300,7 @@ void CompareFiles(const char* fileFile1, const char* fileFile2, int type, int fi
}
}
std::cout << "\n " << kount2 << " out of " << kount1 << " entries having discrpancies at the level of " << tol1
<< " or more\n";
<< " or more; the maximum happens for " << nameMax << " with " << difmax1 << ":" << difmax2 << "\n";
} else if (type == 1) {
const double tol2 = 0.0001;
for (auto it1 : solidFile1) {
Expand All @@ -302,6 +309,10 @@ void CompareFiles(const char* fileFile1, const char* fileFile2, int type, int fi
++kount1;
double vdif =
0.5 * (it1.second.volume - it2->second.volume) / std::max(denmin, (it1.second.volume + it2->second.volume));
if (std::abs(vdif) > difmax1) {
difmax1 = std::abs(vdif);
nameMax = it1.first;
}
if (std::abs(vdif) > tol2) {
++kount2;
std::cout << it1.first << " Volume " << it1.second.volume << ":" << it2->second.volume << ":" << vdif
Expand All @@ -310,7 +321,7 @@ void CompareFiles(const char* fileFile1, const char* fileFile2, int type, int fi
}
}
std::cout << "\n " << kount2 << " out of " << kount1 << " entries having discrpancies at the level of " << tol2
<< " or more\n";
<< " or more; the maximum happens for " << nameMax << " with " << difmax1 << "\n";
} else if (type == 2) {
const double tol3 = 0.0001;
for (auto it1 : lvFile1) {
Expand All @@ -319,14 +330,18 @@ void CompareFiles(const char* fileFile1, const char* fileFile2, int type, int fi
++kount1;
double vdif =
0.5 * (it1.second.mass - it2->second.mass) / std::max(denmin, (it1.second.mass + it2->second.mass));
if (std::abs(vdif) > difmax1) {
difmax1 = std::abs(vdif);
nameMax = it1.first;
}
if (std::abs(vdif) > tol3) {
++kount2;
std::cout << it1.first << " Mass " << it1.second.mass << ":" << it2->second.mass << ":" << vdif << std::endl;
}
}
}
std::cout << "\n " << kount2 << " out of " << kount1 << " entries having discrpancies at the level of " << tol3
<< " or more\n";
<< " or more; the maximum happens for " << nameMax << " with " << difmax1 << "\n";
} else {
const double tol4 = 0.0001;
for (auto it1 : pvFile1) {
Expand All @@ -336,6 +351,12 @@ void CompareFiles(const char* fileFile1, const char* fileFile2, int type, int fi
double xdif = (it1.second.xx - it2->second.xx);
double ydif = (it1.second.yy - it2->second.yy);
double zdif = (it1.second.zz - it2->second.zz);
double vdif = std::max(std::abs(xdif), std::abs(ydif));
vdif = std::max(vdif, std::abs(zdif));
if (vdif > difmax1) {
difmax1 = vdif;
nameMax = it1.first;
}
if ((std::abs(xdif) > tol4) || (std::abs(ydif) > tol4) || (std::abs(zdif) > tol4)) {
++kount2;
std::cout << it1.first << " x " << it1.second.xx << ":" << it2->second.xx << ":" << xdif << " y "
Expand All @@ -345,7 +366,7 @@ void CompareFiles(const char* fileFile1, const char* fileFile2, int type, int fi
}
}
std::cout << "\n " << kount2 << " out of " << kount1 << " entries having discrpancies at the level of " << tol4
<< " or more\n";
<< " or more; the maximum happens for " << nameMax << " with " << difmax1 << "\n";
}
}

Expand Down
45 changes: 45 additions & 0 deletions SimG4Core/PrintGeomInfo/test/python/g4OverlapCheckBigXML_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import FWCore.ParameterSet.Config as cms

from Configuration.Eras.Era_Run3_cff import Run3
process = cms.Process('SIM',Run3)
process.load('SimG4Core.PrintGeomInfo.cmsExtendedGeometry2021_cfi')
process.load("Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cff")
process.load("Geometry.EcalCommonData.ecalSimulationParameters_cff")
process.load("Geometry.HcalCommonData.hcalDDDSimConstants_cff")
process.load("Geometry.HcalCommonData.hcalDDDRecConstants_cfi")
process.load("Geometry.MuonNumbering.muonGeometryConstants_cff")
process.load("Geometry.MuonNumbering.muonOffsetESProducer_cff")

process.load('FWCore.MessageService.MessageLogger_cfi')

#if hasattr(process,'MessageLogger'):
# process.MessageLogger.HCalGeom=dict()

from SimG4Core.PrintGeomInfo.g4TestGeometry_cfi import *
process = checkOverlap(process)

# enable Geant4 overlap check
process.g4SimHits.CheckGeometry = True

# Geant4 geometry check
process.g4SimHits.G4CheckOverlap.OutputBaseName = cms.string("cms2021")
process.g4SimHits.G4CheckOverlap.OverlapFlag = cms.bool(True)
process.g4SimHits.G4CheckOverlap.Tolerance = cms.double(0.1)
process.g4SimHits.G4CheckOverlap.Resolution = cms.int32(10000)
process.g4SimHits.G4CheckOverlap.Depth = cms.int32(-1)
# tells if NodeName is G4Region or G4PhysicalVolume
process.g4SimHits.G4CheckOverlap.RegionFlag = cms.bool(False)
# list of names
process.g4SimHits.G4CheckOverlap.NodeNames = cms.vstring('OCMS')
# enable dump gdml file
process.g4SimHits.G4CheckOverlap.gdmlFlag = cms.bool(False)
# if defined a G4PhysicsVolume info is printed
process.g4SimHits.G4CheckOverlap.PVname = ''
# if defined a list of daughter volumes is printed
process.g4SimHits.G4CheckOverlap.LVname = ''

# extra output files, created if a name is not empty
process.g4SimHits.FileNameField = ''
process.g4SimHits.FileNameGDML = ''
process.g4SimHits.FileNameRegions = ''
#
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import FWCore.ParameterSet.Config as cms

from Configuration.Eras.Era_Run3_dd4hep_cff import Run3_dd4hep
process = cms.Process('G4PrintGeometry',Run3_dd4hep)
process.load("Configuration.Geometry.GeometryDD4hep_cff")
process.load("Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cff")
process.load("Geometry.EcalCommonData.ecalSimulationParameters_cff")
process.load("Geometry.HcalCommonData.hcalDDDSimConstants_cff")
process.load("Geometry.HcalCommonData.hcalDDDRecConstants_cfi")
process.load("Geometry.MuonNumbering.muonGeometryConstants_cff")
process.load("Geometry.MuonNumbering.muonOffsetESProducer_cff")

process.load('FWCore.MessageService.MessageLogger_cfi')

#if hasattr(process,'MessageLogger'):
# process.MessageLogger.HCalGeom=dict()

from SimG4Core.PrintGeomInfo.g4TestGeometry_cfi import *
process = checkOverlap(process)

# enable Geant4 overlap check
process.g4SimHits.CheckGeometry = True

process.DDDetectorESProducer.confGeomXMLFiles = cms.FileInPath("SimG4Core/PrintGeomInfo/data/dd4hep/cmsExtendedGeometry2021.xml")

# Geant4 geometry check
process.g4SimHits.G4CheckOverlap.OutputBaseName = cms.string("cms2021")
process.g4SimHits.G4CheckOverlap.OverlapFlag = cms.bool(True)
process.g4SimHits.G4CheckOverlap.Tolerance = cms.double(0.1)
process.g4SimHits.G4CheckOverlap.Resolution = cms.int32(10000)
process.g4SimHits.G4CheckOverlap.Depth = cms.int32(-1)
# tells if NodeName is G4Region or G4PhysicalVolume
process.g4SimHits.G4CheckOverlap.RegionFlag = cms.bool(False)
# list of names
process.g4SimHits.G4CheckOverlap.NodeNames = cms.vstring('cms:OCMS_1')
# enable dump gdml file
process.g4SimHits.G4CheckOverlap.gdmlFlag = cms.bool(False)
# if defined a G4PhysicsVolume info is printed
process.g4SimHits.G4CheckOverlap.PVname = ''
# if defined a list of daughter volumes is printed
process.g4SimHits.G4CheckOverlap.LVname = ''

# extra output files, created if a name is not empty
process.g4SimHits.FileNameField = ''
process.g4SimHits.FileNameGDML = ''
process.g4SimHits.FileNameRegions = ''
#
15 changes: 11 additions & 4 deletions Validation/Geometry/macros/MatBudgetVolume.C
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// by one of dddXML/dd4hepXML/dddDB/dd4hepDB strings
// and finally with *tag* and ".root"
// txt (std::string) Part of the y-title coming after #frac for the plot
// ("{DDD}/{DD4Hep}")
// ("{DDD}{DD4Hep}")
//
///////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -299,7 +299,7 @@ void etaPhiPlotComp(
}
std::vector<double> xx, yy, dx, dy;
int ii = nflayer[i];
double sumNum(0), sumDen(0);
double sumNum(0), sumDen(0), maxtmp(0), maxDev(0), dmaxDev(0);
for (unsigned int k = 0; k < xx0.size(); ++k) {
if ((yy1[k] > 0) && (yy2[k] > 0)) {
double rat = yy1[k] / yy2[k];
Expand All @@ -314,13 +314,20 @@ void etaPhiPlotComp(
}
double temp1 = (rat > 1.0) ? 1.0 / rat : rat;
double temp2 = (rat > 1.0) ? drt / (rat * rat) : drt;
sumNum += (fabs(1.0 - temp1) / (temp2 * temp2));
double temp0 = (fabs(1.0 - temp1) / (temp2 * temp2));
sumNum += temp0;
sumDen += (1.0 / (temp2 * temp2));
if (temp0 >= maxtmp) {
maxtmp = temp0;
maxDev = fabs(1.0 - temp1);
dmaxDev = temp2;
}
}
}
sumNum = (sumDen > 0) ? (sumNum / sumDen) : 0;
sumDen = (sumDen > 0) ? 1.0 / sqrt(sumDen) : 0;
std::cout << "Mean deviation for " << title[ii] << " " << sumNum << " +- " << sumDen << std::endl;
std::cout << "Mean deviation for " << title[ii] << " " << sumNum << " +- " << sumDen << " Max " << maxDev
<< " +- " << dmaxDev << std::endl;
if (xx.size() > 0) {
TGraphErrors *graph = new TGraphErrors(xx.size(), &xx[0], &yy[0], &dx[0], &dy[0]);
graph->SetLineColor(colorLay[ii]);
Expand Down