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-hcx348 Try to address the issues of ieta=18 and ieta=15 towers in layer=2 of HCAL #42130

Merged
merged 3 commits into from
Jun 30, 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
57 changes: 32 additions & 25 deletions Geometry/HcalCommonData/src/HcalHitRelabeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,26 @@ void HcalHitRelabeller::process(std::vector<PCaloHit>& hcalHits) {
edm::LogVerbatim("HcalSim") << "Hit[" << ii << "] " << std::hex << hcalHit.id() << std::dec << " Neutral density "
<< neutralDensity_;
#endif
double energy = (hcalHit.energy());
if (neutralDensity_) {
energy *= (energyWt(hcalHit.id()));
hcalHit.setEnergy(energy);
}
DetId newid = relabel(hcalHit.id());
uint32_t hid;
int det, z, depth, eta, phi, layer;
HcalTestNumbering::unpackHcalIndex(hcalHit.id(), det, z, depth, eta, phi, layer);
if ((det == 2) && (layer == 2) && (eta == 18))
depth = 2;
hid = HcalTestNumbering::packHcalIndex(det, z, depth, eta, phi, layer);
double wt = (neutralDensity_) ? (energyWt(hid)) : 1.0;
double energy = wt * (hcalHit.energy());
hcalHit.setEnergy(energy);
uint32_t newid = relabel(hid).rawId();
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HcalSim") << "Hit " << ii << " out of " << hcalHits.size() << " " << std::hex << newid.rawId()
<< std::dec << " E " << energy;
edm::LogVerbatim("HcalSim") << "Hit " << ii << " out of " << hcalHits.size() << " " << std::hex << newid
<< std::dec << " E " << energy << " wt " << wt;
#endif
hcalHit.setID(newid.rawId());
hcalHit.setID(newid);
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HcalSim") << "Modified Hit " << HcalDetId(hcalHit.id());
edm::LogVerbatim("HcalSim") << "Final Setting::subdet: " << HcalDetId(newid).subdet()
<< " z: " << HcalDetId(newid).zside() << " depth: " << HcalDetId(newid).depth()
<< " ieta: " << HcalDetId(newid).ietaAbs() << " iphi: " << HcalDetId(newid).iphi()
<< " wt " << wt;
++ii;
#endif
}
Expand All @@ -57,30 +64,30 @@ DetId HcalHitRelabeller::relabel(const uint32_t testId, const HcalDDDRecConstant
HcalDetId hid;
int det, z, depth, eta, phi, layer, sign;
HcalTestNumbering::unpackHcalIndex(testId, det, z, depth, eta, phi, layer);
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HcalSim") << "det: " << det << " "
<< "z: " << z << " "
<< "depth: " << depth << " "
<< "ieta: " << eta << " "
<< "iphi: " << phi << " "
<< "layer: " << layer;
#endif

sign = (z == 0) ? (-1) : (1);
HcalDDDRecConstants::HcalID id = theRecNumber->getHCID(det, sign * eta, phi, layer, depth);
int depth0 = ((det == 1) && (layer == 2) && (eta == 15)) ? depth : id.depth;

if (id.subdet == int(HcalBarrel)) {
hid = HcalDetId(HcalBarrel, sign * id.eta, id.phi, id.depth);
hid = HcalDetId(HcalBarrel, sign * id.eta, id.phi, depth0);
} else if (id.subdet == int(HcalEndcap)) {
hid = HcalDetId(HcalEndcap, sign * id.eta, id.phi, id.depth);
hid = HcalDetId(HcalEndcap, sign * id.eta, id.phi, depth0);
} else if (id.subdet == int(HcalOuter)) {
hid = HcalDetId(HcalOuter, sign * id.eta, id.phi, id.depth);
hid = HcalDetId(HcalOuter, sign * id.eta, id.phi, depth0);
} else if (id.subdet == int(HcalForward)) {
hid = HcalDetId(HcalForward, sign * id.eta, id.phi, id.depth);
hid = HcalDetId(HcalForward, sign * id.eta, id.phi, depth0);
}
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HcalSim") << " new HcalDetId -> hex.RawID = " << std::hex << hid.rawId() << std::dec
<< " det, z, depth, eta, phi = " << det << " " << z << " " << id.depth << " " << id.eta
<< " " << id.phi << " ---> " << hid;
edm::LogVerbatim("HcalSim") << "Initial indices:"
<< "subdet: " << det << " "
<< "z: " << z << " "
<< "depth: " << depth << " "
<< "ieta: " << eta << " "
<< "iphi: " << phi << " "
<< "layer: " << layer << " new HcalDetId -> hex.RawID = " << std::hex << hid.rawId()
<< std::dec << " subdet, z, depth, eta, phi = " << det << " " << z << " " << id.depth
<< " " << id.eta << " " << id.phi << " ---> " << hid;
#endif
return hid;
}
Expand Down
88 changes: 88 additions & 0 deletions SimG4CMS/Calo/test/python/runHcalHitRelabeller_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import FWCore.ParameterSet.Config as cms

from Configuration.StandardSequences.Eras import eras
process = cms.Process("TEST",eras.Run3)
### RANDOM setting (change last digit(s) to make runs different !)
process.load("Configuration.StandardSequences.SimulationRandomNumberGeneratorSeeds_cff")

process.load('FWCore.MessageService.MessageLogger_cfi')
process.load("SimG4Core.Application.g4SimHits_cfi")
process.load("SimCalorimetry.Configuration.ecalDigiSequence_cff")
process.load("SimCalorimetry.Configuration.hcalDigiSequence_cff")
process.load("SimGeneral.PileupInformation.AddPileupSummary_cfi")
process.load("Configuration.StandardSequences.Reconstruction_cff")

process.load("Configuration.EventContent.EventContent_cff")
process.load("SimGeneral.MixingModule.mixNoPU_cfi")
process.load("Configuration.StandardSequences.DigiToRaw_cff")
process.load("Configuration.StandardSequences.RawToDigi_cff")

process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
from Configuration.AlCa.autoCond import autoCond
process.GlobalTag.globaltag = autoCond["phase1_2022_realistic"]

process.load("IOMC.EventVertexGenerators.VtxSmearedGauss_cfi")
process.load("Configuration.StandardSequences.GeometryDB_cff")
process.load("Configuration.StandardSequences.MagneticField_cff")
process.g4SimHits.UseMagneticField = False

from Configuration.AlCa.autoCond import autoCond
process.GlobalTag.globaltag = autoCond['phase1_2022_realistic']

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(500)
)

if 'MessageLogger' in process.__dict__:
process.MessageLogger.HcalSim=dict()

process.source = cms.Source("EmptySource")
process.generator = cms.EDProducer("FlatRandomEGunProducer",
PGunParameters = cms.PSet(
PartID = cms.vint32(13), #mu ieta=15-18
MinEta = cms.double(1.22),
MaxEta = cms.double(1.56),
MinPhi = cms.double(-3.15926),
MaxPhi = cms.double(3.15926),
MinE = cms.double(20.0),
MaxE = cms.double(20.0)
),
firstRun = cms.untracked.uint32(1),
AddAntiParticle = cms.bool(False)
)

process.VtxSmeared.SigmaX = 0.00001
process.VtxSmeared.SigmaY = 0.00001
process.VtxSmeared.SigmaZ = 0.00001

process.FEVT = cms.OutputModule("PoolOutputModule",
outputCommands = process.FEVTDEBUGEventContent.outputCommands,
splitLevel = cms.untracked.int32(0),
fileName = cms.untracked.string("output.root")
)

process.VtxSmeared.src = cms.InputTag("generator", "unsmeared")
process.generatorSmeared = cms.EDProducer("GeneratorSmearedProducer")
process.g4SimHits.Generator.HepMCProductLabel = cms.InputTag('VtxSmeared')
process.g4SimHits.LHCTransport = False

process.p = cms.Path(
process.generator *
process.VtxSmeared *
process.generatorSmeared *
process.g4SimHits *
process.mix *
process.ecalDigiSequence *
process.hcalDigiSequence *
process.addPileupInfo *
process.bunchSpacingProducer *
process.ecalPacker *
process.esDigiToRaw *
process.hcalRawData *
process.rawDataCollector *
process.ecalDigis *
process.ecalPreshowerDigis *
process.hcalDigis
)

###process.outpath = cms.EndPath(process.FEVT)