Skip to content

Commit

Permalink
Merge pull request cms-sw#9 from valsdav/master
Browse files Browse the repository at this point in the history
Fixed superCluster indices in superClusterHits maps
  • Loading branch information
bmarzocc authored Oct 21, 2019
2 parents 3487749 + 02c5c40 commit c26e10c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions Dumpers/plugins/RecoSimDumper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ void RecoSimDumper::analyze(const edm::Event& ev, const edm::EventSetup& iSetup)
superClusterHit_iz.resize(nCaloParticles);

int nSuperClusters = (superClusterEB.product())->size() + (superClusterEE.product())->size();
int nSuperClusters_EB = (superClusterEB.product())->size();
superClusterHit_noCaloPart_energy.clear();
superClusterHit_noCaloPart_eta.clear();
superClusterHit_noCaloPart_phi.clear();
Expand Down Expand Up @@ -646,7 +647,6 @@ void RecoSimDumper::analyze(const edm::Event& ev, const edm::EventSetup& iSetup)
int simHit_index=-1;
int recHit_index=-1;
int pfRecHit_index=-1;
int superClusterHit_index=-1;

float calo_simEnergy=0.;
for(auto const& hit: caloParticleXtals_[iCaloCount])
Expand Down Expand Up @@ -738,6 +738,7 @@ void RecoSimDumper::analyze(const edm::Event& ev, const edm::EventSetup& iSetup)
//for matched SuperClusterHit
if(useEnergyRegression_) superClusterHit_energy_ = recHit_energy_*seedrechits[i].second;
else superClusterHit_energy_ = (iSuperCluster.rawEnergy()/iSuperCluster.energy())*recHit_energy_*seedrechits[i].second;
// Check if the supercluster exists already, add energy (overlapping pfclusters)
if(map_superCluster_energy.find(superCluster_index_tmp)!=map_superCluster_energy.end()) map_superCluster_energy.insert(pair<int,float>(superCluster_index_tmp,reduceFloat(superClusterHit_energy_,nBits_) ));
else map_superCluster_energy[superCluster_index_tmp]+=reduceFloat(superClusterHit_energy_,nBits_);
break;
Expand All @@ -746,7 +747,6 @@ void RecoSimDumper::analyze(const edm::Event& ev, const edm::EventSetup& iSetup)
}
superCluster_index_tmp++;
}
superClusterHit_index++;
superClusterHit_energy[iCaloCount].push_back(map_superCluster_energy);
if(!saveSimhits_ && !saveRechits_ && !savePFRechits_ && !savePFCluster_){
superClusterHit_eta[iCaloCount].push_back(reduceFloat(eta,nBits_));
Expand Down Expand Up @@ -795,7 +795,8 @@ void RecoSimDumper::analyze(const edm::Event& ev, const edm::EventSetup& iSetup)

//Save SuperClusterHit energy
float superClusterHit_energy_ = -1.;
int superCluster_index_tmp=0;
// Using nSuperClusterEB as an offset for global supercluster reference
int superCluster_index_tmp = nSuperClusters_EB;
if(saveSuperCluster_){
for(const auto& iSuperCluster : *(superClusterEE.product())){
for(reco::CaloCluster_iterator iBC = iSuperCluster.clustersBegin(); iBC != iSuperCluster.clustersEnd(); ++iBC){
Expand All @@ -804,15 +805,16 @@ void RecoSimDumper::analyze(const edm::Event& ev, const edm::EventSetup& iSetup)
if(seedrechits[i].first.rawId() == id.rawId()){
if(useEnergyRegression_) superClusterHit_energy_ = recHit_energy_*seedrechits[i].second;
else superClusterHit_energy_ = (iSuperCluster.rawEnergy()/iSuperCluster.energy())*recHit_energy_*seedrechits[i].second;

// We save superclusterindex with an offset = nSuperClustersEB
if(map_superCluster_energy.find(superCluster_index_tmp)!=map_superCluster_energy.end()) map_superCluster_energy.insert(pair<int,float>(superCluster_index_tmp,reduceFloat(superClusterHit_energy_,nBits_) ));
else map_superCluster_energy[superCluster_index_tmp]+=reduceFloat(superClusterHit_energy_,nBits_);
break;
}
}
}
superCluster_index_tmp++;
}
superClusterHit_index++;
}
superClusterHit_energy[iCaloCount].push_back(map_superCluster_energy);
if(!saveSimhits_ && !saveRechits_ && !savePFRechits_ && !savePFCluster_){
superClusterHit_eta[iCaloCount].push_back(reduceFloat(eta,nBits_));
Expand Down Expand Up @@ -1005,7 +1007,8 @@ void RecoSimDumper::analyze(const edm::Event& ev, const edm::EventSetup& iSetup)
}
iSC++;
}
iSC=0;
// The global SuperCluster indexing for EE has an offset = nSuperClusterEB
iSC = nSuperClusters_EB;
std::cout << "SuperClustersEE size: " << (superClusterEE.product())->size() << std::endl;
for(const auto& iSuperCluster : *(superClusterEE.product())){
reco::CaloCluster caloBC(*iSuperCluster.seed());
Expand Down
4 changes: 2 additions & 2 deletions Dumpers/python/RecoSimDumper_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
saveRechits = cms.bool(True), #save recHits information
savePFRechits = cms.bool(True), #save pfRecHits information
savePFCluster = cms.bool(True), #save pfClusters information
saveSuperCluster = cms.bool(False), #save superClusters information
saveShowerShapes = cms.bool(True), #save saveShowerShapes information
saveSuperCluster = cms.bool(True), #save superClusters information
saveShowerShapes = cms.bool(False), #save saveShowerShapes information
useEnergyRegression = cms.bool(False), #save corrected energy
genID = cms.vint32(22,11) #save only caloParticles with this pdgId
#genID = cms.vdouble(0), #save only caloParticles with this pdgId
Expand Down

0 comments on commit c26e10c

Please sign in to comment.