Skip to content

Commit

Permalink
Merge pull request cms-sw#28579 from bmarzocc/PR_11_1_X_CaloParticles
Browse files Browse the repository at this point in the history
CaloParticle additional hitsAndEnergies from SimClusters: data format change
  • Loading branch information
cmsbuild authored Jan 14, 2020
2 parents c487ee8 + 510b5de commit 2d3b452
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import FWCore.ParameterSet.Config as cms

# This modifier is for ECAL Run3 clustering studies

run3_ecalclustering = cms.Modifier()

18 changes: 18 additions & 0 deletions SimDataFormats/CaloAnalysis/interface/SimCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::pair<uint32_t, float>> hits_and_fractions() const {
std::vector<std::pair<uint32_t, float>> result;
Expand All @@ -186,12 +189,26 @@ class SimCluster {
return result;
}

/** @brief Returns list of rechit IDs and energies for this SimCluster */
std::vector<std::pair<uint32_t, float>> hits_and_energies() const {
assert(hits_.size() == energies_.size());
std::vector<std::pair<uint32_t, float>> 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<uint32_t>().swap(hits_);
std::vector<float>().swap(fractions_);
}

/** @brief clear the energies list */
void clearHitsEnergy() { std::vector<float>().swap(energies_); }

/** @brief returns the accumulated sim energy in the cluster */
float simEnergy() const { return simhit_energy_; }

Expand All @@ -206,6 +223,7 @@ class SimCluster {
float simhit_energy_;
std::vector<uint32_t> hits_;
std::vector<float> fractions_;
std::vector<float> energies_;

math::XYZTLorentzVectorF theMomentum_;

Expand Down
5 changes: 3 additions & 2 deletions SimDataFormats/CaloAnalysis/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
<class name="CaloParticleRefVector"/>
<class name="CaloParticleRefProd"/>
<class name="CaloParticleContainer"/>
<class name="SimCluster" ClassVersion="3">
<version ClassVersion="3" checksum="1773780587"/>
<class name="SimCluster" ClassVersion="4">
<version ClassVersion="4" checksum="3868743425"/>
<version ClassVersion="3" checksum="1773780587"/>
</class>
<class name="SimClusterCollection"/>
<class name="edm::Wrapper<SimClusterCollection>"/>
Expand Down
2 changes: 2 additions & 0 deletions SimGeneral/CaloAnalysis/plugins/CaloTruthAccumulator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.;
Expand All @@ -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);
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions SimGeneral/MixingModule/python/caloTruthProducer_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

3 changes: 2 additions & 1 deletion SimGeneral/MixingModule/python/digitizers_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit 2d3b452

Please sign in to comment.