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

Phase2-hgx346X Add new collection names and information of Calibration Cells to the HGCal SD Class #42982

Merged
merged 1 commit into from
Oct 16, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Geometry/HGCalCommonData/interface/HGCalDDDConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ class HGCalDDDConstants {
std::pair<int, int> assignCell(float x, float y, int lay, int subSec, bool reco) const;
std::array<int, 5> assignCellHex(float x, float y, int zside, int lay, bool reco, bool extend, bool debug) const;
std::array<int, 3> assignCellTrap(float x, float y, float z, int lay, bool reco) const;
std::vector<int> calibCells(bool hd, bool full) const {
if (hd) {
return (full ? hgpar_->calibCellFullHD_ : hgpar_->calibCellPartHD_);
} else {
return (full ? hgpar_->calibCellFullLD_ : hgpar_->calibCellPartLD_);
}
}
double calibCellRad(bool hd) const { return (hd ? hgpar_->calibCellRHD_ : hgpar_->calibCellRLD_); }
bool cassetteMode() const {
return ((mode_ == HGCalGeometryMode::Hexagon8Cassette) || (mode_ == HGCalGeometryMode::TrapezoidCassette) ||
(mode_ == HGCalGeometryMode::Hexagon8CalibCell));
Expand Down
5 changes: 4 additions & 1 deletion SimG4CMS/Calo/interface/HGCalSD.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ class HGCalSD : public CaloSD, public Observer<const BeginOfJob *> {
bool storeAllG4Hits_;
bool fiducialCut_, rejectMB_, waferRot_, checkID_;
int useSimWt_, verbose_;
bool dd4hep_;
bool dd4hep_, calibCells_;
double calibCellRHD_, calibCellRLD_;
std::vector<int> calibCellFullHD_, calibCellPartHD_;
std::vector<int> calibCellFullLD_, calibCellPartLD_;
const double tan30deg_, cos30deg_;
std::vector<double> angles_;
std::string missingFile_;
Expand Down
4 changes: 2 additions & 2 deletions SimG4CMS/Calo/src/CaloSD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,10 @@ void CaloSD::EndOfEvent(G4HCofThisEvent*) {
cleanHitCollection();

#ifdef EDM_ML_DEBUG
if (theHC == nullptr)
if (theHC[0] == nullptr)
edm::LogVerbatim("CaloSim") << "CaloSD: EndofEvent entered with no entries";
else
edm::LogVerbatim("CaloSim") << "CaloSD: EndofEvent entered with " << theHC->entries() << " entries";
edm::LogVerbatim("CaloSim") << "CaloSD: EndofEvent entered with " << theHC[0]->entries() << " entries";
#endif
}

Expand Down
32 changes: 32 additions & 0 deletions SimG4CMS/Calo/src/HGCalSD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <iomanip>
#include <iostream>
#include <memory>
#include <sstream>

//#define EDM_ML_DEBUG

Expand All @@ -44,6 +45,7 @@ HGCalSD::HGCalSD(const std::string& name,
levelT1_(99),
levelT2_(99),
useSimWt_(0),
calibCells_(false),
tan30deg_(std::tan(30.0 * CLHEP::deg)),
cos30deg_(std::cos(30.0 * CLHEP::deg)) {
numberingScheme_.reset(nullptr);
Expand Down Expand Up @@ -279,6 +281,36 @@ void HGCalSD::update(const BeginOfJob* job) {
guardRing_ = std::make_unique<HGCGuardRing>(*hgcons_);
guardRingPartial_ = std::make_unique<HGCGuardRingPartial>(*hgcons_);
}

//Now for calibration cells
calibCellRHD_ = hgcons_->calibCellRad(true);
calibCellRLD_ = hgcons_->calibCellRad(false);
calibCellFullHD_ = hgcons_->calibCells(true, true);
calibCellPartHD_ = hgcons_->calibCells(true, false);
calibCellFullLD_ = hgcons_->calibCells(false, true);
calibCellPartLD_ = hgcons_->calibCells(false, false);
calibCells_ = ((!calibCellFullHD_.empty()) || (!calibCellPartHD_.empty()));
calibCells_ |= ((!calibCellFullLD_.empty()) || (!calibCellPartLD_.empty()));
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCSim") << "HGCalSD::Calibration cells initialized with flag " << calibCells_;
edm::LogVerbatim("HGCSim") << " Radii " << calibCellRHD_ << ":" << calibCellRLD_;
std::ostringstream st1;
for (const auto& cell : calibCellFullHD_)
st1 << " " << cell;
edm::LogVerbatim("HGCSim") << calibCellFullHD_.size() << " cells for High Density full wafers: " << st1.str();
std::ostringstream st2;
for (const auto& cell : calibCellPartHD_)
st2 << " " << cell;
edm::LogVerbatim("HGCSim") << calibCellPartHD_.size() << " cells for High Density partial wafers: " << st2.str();
std::ostringstream st3;
for (const auto& cell : calibCellFullLD_)
st3 << " " << cell;
edm::LogVerbatim("HGCSim") << calibCellFullLD_.size() << " cells for Low Density full wafers: " << st3.str();
std::ostringstream st4;
for (const auto& cell : calibCellPartLD_)
st4 << " " << cell;
edm::LogVerbatim("HGCSim") << calibCellPartLD_.size() << " cells for Low Density partial wafers: " << st4.str();
#endif
} else {
throw cms::Exception("Unknown", "HGCalSD") << "Cannot find HGCalDDDConstants for " << nameX_ << "\n";
}
Expand Down
32 changes: 30 additions & 2 deletions SimG4CMS/Calo/test/python/runHGC1_cfg.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,41 @@
###############################################################################
# Way to use this:
# cmsRun ttbar.py geometry=V18
# Options for geometry V17Shift, V18
#
###############################################################################
import FWCore.ParameterSet.Config as cms
from Configuration.Eras.Era_Phase2C11_cff import Phase2C11
import os, sys, imp, re
import FWCore.ParameterSet.VarParsing as VarParsing

####################################################################
### SETUP OPTIONS
options = VarParsing.VarParsing('standard')
options.register('geometry',
"V18",
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"geometry of operations: V17Shift, V18")

### get and parse the command line arguments

options.parseArguments()
print(options)

####################################################################

from Configuration.Eras.Era_Phase2C11_cff import Phase2C11
process = cms.Process("PROD",Phase2C11)

geomFile = "Geometry.HGCalCommonData.testHGCal" + options.geometry + "Reco_cff"
print("Geometry file: ", geomFile)

process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")
process.load('Configuration.StandardSequences.Generator_cff')
process.load("IOMC.EventVertexGenerators.VtxSmearedGauss_cfi")
process.load('GeneratorInterface.Core.genFilterSummary_cff')
process.load('Configuration.StandardSequences.SimIdeal_cff')
process.load("Configuration.Geometry.GeometryExtended2026D49Reco_cff")
process.load(geomFile)
process.load("Configuration.StandardSequences.MagneticField_cff")
process.load("Configuration.EventContent.EventContent_cff")
process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
Expand Down
3 changes: 3 additions & 0 deletions SimG4Core/Application/plugins/OscarMTProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ OscarMTProducer::OscarMTProducer(edm::ParameterSet const& p, const OscarMTMaster
produces<edm::PCaloHitContainer>("HGCHitsEE");
produces<edm::PCaloHitContainer>("HGCHitsHEfront");
produces<edm::PCaloHitContainer>("HGCHitsHEback");
produces<edm::PCaloHitContainer>("CalibrationHGCHitsEE");
produces<edm::PCaloHitContainer>("CalibrationHGCHitsHEfront");
produces<edm::PCaloHitContainer>("CalibrationHGCHitsHEback");

produces<edm::PSimHitContainer>("MuonDTHits");
produces<edm::PSimHitContainer>("MuonCSCHits");
Expand Down