Skip to content

Commit

Permalink
Make work without fine calo
Browse files Browse the repository at this point in the history
  • Loading branch information
kdlong committed Feb 22, 2021
1 parent 9f98685 commit e0ce707
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 19 deletions.
3 changes: 3 additions & 0 deletions IOMC/ParticleGuns/src/SealModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
//

Expand Down Expand Up @@ -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);
2 changes: 1 addition & 1 deletion PhysicsTools/NanoAOD/python/hgcSimHits_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
)
)

Expand Down
19 changes: 10 additions & 9 deletions PhysicsTools/NanoAOD/python/hgcSimTracks_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
)
)

Expand Down
16 changes: 10 additions & 6 deletions PhysicsTools/NanoAOD/python/simClusters_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
)
)

Expand Down
4 changes: 4 additions & 0 deletions SimDataFormats/CaloAnalysis/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<version ClassVersion="4" checksum="3868743425"/>
<version ClassVersion="3" checksum="1773780587"/>
</class>
<class name="edm::Association<std::vector<SimCluster>>"/>
<class name="edm::Wrapper<edm::Association<std::vector<SimCluster>>>"/>
<class name="edm::Association<std::vector<CaloParticle>>"/>
<class name="edm::Wrapper<edm::Association<std::vector<CaloParticle>>>"/>
<class name="SimClusterCollection"/>
<class name="edm::Wrapper<SimClusterCollection>"/>
<class name="SimClusterRef"/>
Expand Down
7 changes: 4 additions & 3 deletions SimGeneral/CaloAnalysis/plugins/CaloTruthAccumulator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, int> simClusIdxToCaloParticleIdxMap_;
std::unordered_map<int, int> 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<SimClusterCollection> ref(scHandle, j);
simClusIdxToCaloParticleIdxMap[j] = i;
cp.addSimCluster(ref);
}
}
Expand All @@ -583,8 +584,8 @@ void CaloTruthAccumulator::finalizeEvent(edm::Event &event, edm::EventSetup cons
std::vector<int> 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<edm::Association<CaloParticleCollection>>(cpHandle);
Expand Down

0 comments on commit e0ce707

Please sign in to comment.