From e0ce70709b9b575ef87f4c39434d0c75f5e640f5 Mon Sep 17 00:00:00 2001 From: Kenneth Long Date: Tue, 15 Dec 2020 21:18:05 +0100 Subject: [PATCH] Make work without fine calo --- IOMC/ParticleGuns/src/SealModule.cc | 3 +++ PhysicsTools/NanoAOD/python/hgcSimHits_cff.py | 2 +- .../NanoAOD/python/hgcSimTracks_cff.py | 19 ++++++++++--------- .../NanoAOD/python/simClusters_cff.py | 16 ++++++++++------ .../CaloAnalysis/src/classes_def.xml | 4 ++++ .../plugins/CaloTruthAccumulator.cc | 7 ++++--- 6 files changed, 32 insertions(+), 19 deletions(-) diff --git a/IOMC/ParticleGuns/src/SealModule.cc b/IOMC/ParticleGuns/src/SealModule.cc index d21e3d2b1f01f..020315ce98a68 100644 --- a/IOMC/ParticleGuns/src/SealModule.cc +++ b/IOMC/ParticleGuns/src/SealModule.cc @@ -23,6 +23,7 @@ #include "IOMC/ParticleGuns/interface/RandomtXiGunProducer.h" #include "IOMC/ParticleGuns/interface/RandomMultiParticlePGunProducer.h" #include "IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h" +#include "IOMC/ParticleGuns/interface/FlatEtaRangeGunProducer.h" // particle gun prototypes // @@ -67,3 +68,5 @@ using edm::RandomMultiParticlePGunProducer; DEFINE_FWK_MODULE(RandomMultiParticlePGunProducer); using edm::RandomXiThetaGunProducer; DEFINE_FWK_MODULE(RandomXiThetaGunProducer); +using edm::FlatEtaRangeGunProducer; +DEFINE_FWK_MODULE(FlatEtaRangeGunProducer); diff --git a/PhysicsTools/NanoAOD/python/hgcSimHits_cff.py b/PhysicsTools/NanoAOD/python/hgcSimHits_cff.py index d45e32626c810..175c832641bff 100644 --- a/PhysicsTools/NanoAOD/python/hgcSimHits_cff.py +++ b/PhysicsTools/NanoAOD/python/hgcSimHits_cff.py @@ -12,7 +12,7 @@ detId = Var('id', 'int', precision=-1, doc='detId'), energy = Var('energy', 'float', precision=14, doc='energy'), trackId = Var('geantTrackId', 'int', precision=-1, doc='Geant4 track ID'), - fineTrackId = Var('geantFineTrackId', 'int', precision=-1, doc='granular Geant4 track ID'), + #fineTrackId = Var('geantFineTrackId', 'int', precision=-1, doc='granular Geant4 track ID'), ) ) diff --git a/PhysicsTools/NanoAOD/python/hgcSimTracks_cff.py b/PhysicsTools/NanoAOD/python/hgcSimTracks_cff.py index 8a9870c44bb0c..e5f972be25915 100644 --- a/PhysicsTools/NanoAOD/python/hgcSimTracks_cff.py +++ b/PhysicsTools/NanoAOD/python/hgcSimTracks_cff.py @@ -3,29 +3,30 @@ simTrackTable = cms.EDProducer("SimpleSimTrackFlatTableProducer", src = cms.InputTag("g4SimHits"), - cut = cms.string("abs(momentum().eta) > 1.52 || abs(getMomentumAtBoundary().eta()) > 1.52"), + #cut = cms.string("abs(momentum().eta) > 1.52 || abs(getMomentumAtBoundary().eta()) > 1.52"), + cut = cms.string(""), name = cms.string("SimTrack"), doc = cms.string("Geant4 sim tracks in HGCAL Electromagnetic endcap"), singleton = cms.bool(False), # the number of entries is variable extension = cms.bool(False), # this is the main table for the muons variables = cms.PSet( - crossedBoundary = Var('crossedBoundary', 'bool', doc='track crossed boundary'), pdgId = Var('type', 'int', doc='pdgId (track type)'), charge = Var('charge', 'int', doc='ID'), trackId = Var('trackId', 'int', precision=-1, doc='ID'), - trackIdAtBoundary = Var('getIDAtBoundary', 'int', precision=-1, doc='ID at boundary crossing'), + #trackIdAtBoundary = Var('getIDAtBoundary', 'int', precision=-1, doc='ID at boundary crossing'), pt = Var('momentum().pt()', 'float', precision=14, doc='pt'), eta = Var('momentum().eta()', 'float', precision=14, doc='eta'), phi = Var('momentum().phi()', 'float', precision=14, doc='phi'), lastPos_x = Var('trackerSurfacePosition().x()', 'float', precision=14, doc='x position at HGCAL boundary'), lastPos_y = Var('trackerSurfacePosition().y()', 'float', precision=14, doc='y position at HGCAL boundary'), lastPos_z = Var('trackerSurfacePosition().z()', 'float', precision=14, doc='z position at HGCAL boundary'), - boundaryPos_x = Var('getPositionAtBoundary().x()', 'float', precision=14, doc='x position at HGCAL boundary'), - boundaryPos_y = Var('getPositionAtBoundary().y()', 'float', precision=14, doc='y position at HGCAL boundary'), - boundaryPos_z = Var('getPositionAtBoundary().z()', 'float', precision=14, doc='z position at HGCAL boundary'), - boundaryMomentum_pt = Var('getMomentumAtBoundary().pt()', 'float', precision=14, doc='pt at HGCAL boundary'), - boundaryMomentum_eta = Var('getMomentumAtBoundary().eta()', 'float', precision=14, doc='eta position at HGCAL boundary'), - boundaryMomentum_phi = Var('getMomentumAtBoundary().phi()', 'float', precision=14, doc='phi position at HGCAL boundary'), + #crossedBoundary = Var('crossedBoundary', 'bool', doc='track crossed boundary'), + #boundaryPos_x = Var('getPositionAtBoundary().x()', 'float', precision=14, doc='x position at HGCAL boundary'), + #boundaryPos_y = Var('getPositionAtBoundary().y()', 'float', precision=14, doc='y position at HGCAL boundary'), + #boundaryPos_z = Var('getPositionAtBoundary().z()', 'float', precision=14, doc='z position at HGCAL boundary'), + #boundaryMomentum_pt = Var('getMomentumAtBoundary().pt()', 'float', precision=14, doc='pt at HGCAL boundary'), + #boundaryMomentum_eta = Var('getMomentumAtBoundary().eta()', 'float', precision=14, doc='eta position at HGCAL boundary'), + #boundaryMomentum_phi = Var('getMomentumAtBoundary().phi()', 'float', precision=14, doc='phi position at HGCAL boundary'), ) ) diff --git a/PhysicsTools/NanoAOD/python/simClusters_cff.py b/PhysicsTools/NanoAOD/python/simClusters_cff.py index 2d49f5f3ed0c4..d6bf348eba1cb 100644 --- a/PhysicsTools/NanoAOD/python/simClusters_cff.py +++ b/PhysicsTools/NanoAOD/python/simClusters_cff.py @@ -9,15 +9,19 @@ singleton = cms.bool(False), # the number of entries is variable extension = cms.bool(False), # this is the main table for the muons variables = cms.PSet(CandVars, - y = Var('impactPoint().y()', 'float', precision=14, doc='y position'), - z = Var('impactPoint().z()', 'float', precision=14, doc='z position'), - impactPointX = Var('impactPoint().x()', 'float', precision=14, doc='x position'), - impactPointY = Var('impactPoint().y()', 'float', precision=14, doc='y position'), - impactPointZ = Var('impactPoint().z()', 'float', precision=14, doc='z position'), + #x = Var('impactPoint().x()', 'float', precision=14, doc='x position'), + #y = Var('impactPoint().y()', 'float', precision=14, doc='y position'), + #z = Var('impactPoint().z()', 'float', precision=14, doc='z position'), + #impactPointX = Var('impactPoint().x()', 'float', precision=14, doc='x position'), + #impactPointY = Var('impactPoint().y()', 'float', precision=14, doc='y position'), + #impactPointZ = Var('impactPoint().z()', 'float', precision=14, doc='z position'), + lastPos_x = Var('g4Tracks.at(0).trackerSurfacePosition().x()', 'float', precision=14, doc='track x final position'), + lastPos_y = Var('g4Tracks.at(0).trackerSurfacePosition().y()', 'float', precision=14, doc='track y final position'), + lastPos_z = Var('g4Tracks.at(0).trackerSurfacePosition().z()', 'float', precision=14, doc='track z final position'), nSimHits = Var('numberOfSimHits', 'int', precision=-1, doc='total energy of simhits'), simEnergy = Var('simEnergy', 'float', precision=14, doc='total energy of simhits'), trackId = Var('g4Tracks().at(0).trackId()', 'int', precision=10, doc='Geant track id'), - trackIdAtBoundary = Var('g4Tracks().at(0).getIDAtBoundary()', 'int', precision=-1, doc='Track ID at boundary'), + #trackIdAtBoundary = Var('g4Tracks().at(0).getIDAtBoundary()', 'int', precision=-1, doc='Track ID at boundary'), ) ) diff --git a/SimDataFormats/CaloAnalysis/src/classes_def.xml b/SimDataFormats/CaloAnalysis/src/classes_def.xml index 89a2b4c9f5aaf..a8a1e3ad56f62 100644 --- a/SimDataFormats/CaloAnalysis/src/classes_def.xml +++ b/SimDataFormats/CaloAnalysis/src/classes_def.xml @@ -12,6 +12,10 @@ + + + + diff --git a/SimGeneral/CaloAnalysis/plugins/CaloTruthAccumulator.cc b/SimGeneral/CaloAnalysis/plugins/CaloTruthAccumulator.cc index 6389f8e1cc5ea..14022527c0ef6 100644 --- a/SimGeneral/CaloAnalysis/plugins/CaloTruthAccumulator.cc +++ b/SimGeneral/CaloAnalysis/plugins/CaloTruthAccumulator.cc @@ -562,13 +562,14 @@ void CaloTruthAccumulator::finalizeEvent(edm::Event &event, edm::EventSetup cons event.put(std::move(output_.pHGCHEfrontHitSCAssoc), "simHitHGCHEfrontToSimCluster"); event.put(std::move(output_.pHGCHEbackHitSCAssoc), "simHitHGCHEbackToSimCluster"); - std::unordered_map simClusIdxToCaloParticleIdxMap_; + std::unordered_map simClusIdxToCaloParticleIdxMap; // now fill the calo particles for (unsigned i = 0; i < output_.pCaloParticles->size(); ++i) { auto &cp = (*output_.pCaloParticles)[i]; for (unsigned j = m_caloParticles.sc_start_[i]; j < m_caloParticles.sc_stop_[i]; ++j) { edm::Ref ref(scHandle, j); + simClusIdxToCaloParticleIdxMap[j] = i; cp.addSimCluster(ref); } } @@ -583,8 +584,8 @@ void CaloTruthAccumulator::finalizeEvent(edm::Event &event, edm::EventSetup cons std::vector caloPartIdx; for (size_t i = 0; i < scHandle->size(); i++) { int matchIdx = -1; - if (simClusIdxToCaloParticleIdxMap_.find(i) != simClusIdxToCaloParticleIdxMap_.end()) - matchIdx = simClusIdxToCaloParticleIdxMap_[i]; + if (simClusIdxToCaloParticleIdxMap.find(i) != simClusIdxToCaloParticleIdxMap.end()) + matchIdx = simClusIdxToCaloParticleIdxMap[i]; caloPartIdx.emplace_back(matchIdx); } auto assocMap = std::make_unique>(cpHandle);