diff --git a/Configuration/ProcessModifiers/python/run3_ecalclustering_cff.py b/Configuration/ProcessModifiers/python/run3_ecalclustering_cff.py new file mode 100644 index 0000000000000..170677a51d9c4 --- /dev/null +++ b/Configuration/ProcessModifiers/python/run3_ecalclustering_cff.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +# This modifier is for ECAL Run3 clustering studies + +run3_ecalclustering = cms.Modifier() + diff --git a/SimDataFormats/CaloAnalysis/interface/SimCluster.h b/SimDataFormats/CaloAnalysis/interface/SimCluster.h index 09433efb7a06d..30b75545cc0dd 100644 --- a/SimDataFormats/CaloAnalysis/interface/SimCluster.h +++ b/SimDataFormats/CaloAnalysis/interface/SimCluster.h @@ -177,6 +177,9 @@ class SimCluster { fractions_.emplace_back(fraction); } + /** @brief add rechit energy */ + void addHitEnergy(float energy) { energies_.emplace_back(energy); } + /** @brief Returns list of rechit IDs and fractions for this SimCluster */ std::vector> hits_and_fractions() const { std::vector> result; @@ -186,12 +189,26 @@ class SimCluster { return result; } + /** @brief Returns list of rechit IDs and energies for this SimCluster */ + std::vector> hits_and_energies() const { + assert(hits_.size() == energies_.size()); + std::vector> result; + result.reserve(hits_.size()); + for (size_t i = 0; i < hits_.size(); ++i) { + result.emplace_back(hits_[i], energies_[i]); + } + return result; + } + /** @brief clear the hits and fractions list */ void clearHitsAndFractions() { std::vector().swap(hits_); std::vector().swap(fractions_); } + /** @brief clear the energies list */ + void clearHitsEnergy() { std::vector().swap(energies_); } + /** @brief returns the accumulated sim energy in the cluster */ float simEnergy() const { return simhit_energy_; } @@ -206,6 +223,7 @@ class SimCluster { float simhit_energy_; std::vector hits_; std::vector fractions_; + std::vector energies_; math::XYZTLorentzVectorF theMomentum_; diff --git a/SimDataFormats/CaloAnalysis/src/classes_def.xml b/SimDataFormats/CaloAnalysis/src/classes_def.xml index 3d54f8b2be929..89a2b4c9f5aaf 100644 --- a/SimDataFormats/CaloAnalysis/src/classes_def.xml +++ b/SimDataFormats/CaloAnalysis/src/classes_def.xml @@ -8,8 +8,9 @@ - - + + + diff --git a/SimGeneral/CaloAnalysis/plugins/CaloTruthAccumulator.cc b/SimGeneral/CaloAnalysis/plugins/CaloTruthAccumulator.cc index 4dbc4252beef3..ff7e8a22fd75b 100644 --- a/SimGeneral/CaloAnalysis/plugins/CaloTruthAccumulator.cc +++ b/SimGeneral/CaloAnalysis/plugins/CaloTruthAccumulator.cc @@ -486,6 +486,7 @@ void CaloTruthAccumulator::finalizeEvent(edm::Event &event, edm::EventSetup cons for (auto &sc : *(output_.pSimClusters)) { auto hitsAndEnergies = sc.hits_and_fractions(); sc.clearHitsAndFractions(); + sc.clearHitsEnergy(); for (auto &hAndE : hitsAndEnergies) { const float totalenergy = m_detIdToTotalSimEnergy[hAndE.first]; float fraction = 0.; @@ -495,6 +496,7 @@ void CaloTruthAccumulator::finalizeEvent(edm::Event &event, edm::EventSetup cons edm::LogWarning(messageCategory_) << "TotalSimEnergy for hit " << hAndE.first << " is 0! The fraction for this hit cannot be computed."; sc.addRecHitAndFraction(hAndE.first, fraction); + sc.addHitEnergy(hAndE.second); } } } diff --git a/SimGeneral/MixingModule/python/caloTruthProducer_cfi.py b/SimGeneral/MixingModule/python/caloTruthProducer_cfi.py index 071fa1cd7dc0f..a4bad8726d169 100644 --- a/SimGeneral/MixingModule/python/caloTruthProducer_cfi.py +++ b/SimGeneral/MixingModule/python/caloTruthProducer_cfi.py @@ -46,6 +46,18 @@ simHitCollections = dict(hgc = caloParticles.simHitCollections.hgc + [cms.InputTag('g4SimHits','HFNoseHits')]) ) +from Configuration.ProcessModifiers.run3_ecalclustering_cff import run3_ecalclustering +run3_ecalclustering.toModify( + caloParticles, + simHitCollections = cms.PSet( + ecal = cms.VInputTag( + cms.InputTag('g4SimHits','EcalHitsEE'), + cms.InputTag('g4SimHits','EcalHitsEB'), + cms.InputTag('g4SimHits','EcalHitsES') + ) + ) +) + from Configuration.Eras.Modifier_fastSim_cff import fastSim fastSim.toReplaceWith(caloParticles, cms.PSet()) # don't allow this to run in fastsim diff --git a/SimGeneral/MixingModule/python/digitizers_cfi.py b/SimGeneral/MixingModule/python/digitizers_cfi.py index 12682181c7264..247acfe7a0415 100644 --- a/SimGeneral/MixingModule/python/digitizers_cfi.py +++ b/SimGeneral/MixingModule/python/digitizers_cfi.py @@ -102,7 +102,8 @@ theDigitizersValid = cms.PSet(theDigitizers) theDigitizers.mergedtruth.select.signalOnlyTP = True -phase2_hgcal.toModify( theDigitizersValid, +from Configuration.ProcessModifiers.run3_ecalclustering_cff import run3_ecalclustering +(run3_ecalclustering | phase2_hgcal).toModify( theDigitizersValid, calotruth = cms.PSet( caloParticles ) ) # Doesn't HGCal need these also without validation? (premix_stage2 & phase2_hgcal).toModify(theDigitizersValid, calotruth = dict(premixStage1 = True))