Skip to content

Commit

Permalink
Merge pull request #18864 from bsunanda/Phase2-hgx83
Browse files Browse the repository at this point in the history
Phase2-hgx83 Bug fixes to two codes
  • Loading branch information
cmsbuild committed May 24, 2017
2 parents 6b37f47 + 371f842 commit c58ba64
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 27 deletions.
63 changes: 39 additions & 24 deletions Validation/HGCalValidation/plugins/HGCalHitCalibration.cc
Expand Up @@ -13,6 +13,7 @@
#include "DataFormats/ForwardDetId/interface/HGCHEDetId.h"
#include "DataFormats/ForwardDetId/interface/HGCalDetId.h"

#include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h"
#include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
Expand Down Expand Up @@ -65,7 +66,8 @@ class HGCalHitCalibration : public edm::one::EDAnalyzer<edm::one::SharedResource
TH1F* h_EoP_CPene_100_calib_fraction_[6];
TH1F* h_EoP_CPene_200_calib_fraction_[6];
TH1F* h_EoP_CPene_300_calib_fraction_[6];
TH1F* LayerOccupancy_[6];
TH1F* h_LayerOccupancy_[6];
TH1F* h_MissingHit_[3];

std::vector<float> Energy_layer_calib;
std::vector<float> Energy_layer_calib_fraction;
Expand All @@ -78,17 +80,14 @@ HGCalHitCalibration::HGCalHitCalibration(const edm::ParameterSet& iConfig) :

usesResource(TFileService::kSharedResource);
std::string detector = iConfig.getParameter<std::string >("detector");
_recHitsEE = consumes<HGCRecHitCollection>(edm::InputTag("HGCalRecHit","HGCEERecHits"));
_recHitsFH = consumes<HGCRecHitCollection>(edm::InputTag("HGCalRecHit","HGCHEFRecHits"));
_recHitsBH = consumes<HGCRecHitCollection>(edm::InputTag("HGCalRecHit","HGCHEBRecHits"));
if (detector=="all") {
_recHitsEE = consumes<HGCRecHitCollection>(edm::InputTag("HGCalRecHit","HGCEERecHits"));
_recHitsFH = consumes<HGCRecHitCollection>(edm::InputTag("HGCalRecHit","HGCHEFRecHits"));
_recHitsBH = consumes<HGCRecHitCollection>(edm::InputTag("HGCalRecHit","HGCHEBRecHits"));
algo_ = 1;
} else if (detector=="EM") {
_recHitsEE = consumes<HGCRecHitCollection>(edm::InputTag("HGCalRecHit","HGCEERecHits"));
algo_ = 2;
} else if (detector=="HAD") {
_recHitsFH = consumes<HGCRecHitCollection>(edm::InputTag("HGCalRecHit","HGCHEFRecHits"));
_recHitsBH = consumes<HGCRecHitCollection>(edm::InputTag("HGCalRecHit","HGCHEBRecHits"));
algo_ = 3;
}
_caloParticles = consumes<std::vector<CaloParticle> >(edm::InputTag("mix","MergedCaloTruth"));
Expand All @@ -104,7 +103,12 @@ HGCalHitCalibration::HGCalHitCalibration(const edm::ParameterSet& iConfig) :
sprintf(name,"h_EoP_CPene_300_calib_fraction_%s",particle[k].c_str());
h_EoP_CPene_300_calib_fraction_[k] = fs->make<TH1F>(name,"",1000,-0.5,2.5);
sprintf(name,"h_LayerOccupancy_%s",particle[k].c_str());
LayerOccupancy_[k] = fs->make<TH1F>(name, "", 60, 0., 60.);
h_LayerOccupancy_[k] = fs->make<TH1F>(name, "", 60, 0., 60.);
}
std::string dets[3] = {"EE", "FH", "BH"};
for (int k=0; k<3; ++k) {
sprintf(name,"h_missHit_%s",dets[k].c_str());
h_MissingHit_[k] = fs->make<TH1F>(name, "", 200, 0., 200.);
}
}

Expand All @@ -120,13 +124,17 @@ void HGCalHitCalibration::analyze(const edm::Event& iEvent, const edm::EventSetu
iEvent.getByToken(_recHitsEE,recHitHandleEE);
iEvent.getByToken(_recHitsFH,recHitHandleFH);
iEvent.getByToken(_recHitsBH,recHitHandleBH);
const HGCRecHitCollection& rechitsEE = *recHitHandleEE;
const HGCRecHitCollection& rechitsFH = *recHitHandleFH;
const HGCRecHitCollection& rechitsBH = *recHitHandleBH;

edm::Handle<std::vector<CaloParticle> > caloParticleHandle;
iEvent.getByToken(_caloParticles, caloParticleHandle);
const std::vector<CaloParticle>& caloParticles = *caloParticleHandle;
const int pdgId[3] = {11, 13, 22};

// loop over caloParticles
int mhit[3] = {0,0,0};
for (auto it_caloPart = caloParticles.begin();
it_caloPart != caloParticles.end(); ++it_caloPart) {
double cut = (cutOnPt_) ? it_caloPart->pt() : it_caloPart->energy();
Expand Down Expand Up @@ -158,86 +166,92 @@ void HGCalHitCalibration::analyze(const edm::Event& iEvent, const edm::EventSetu
it_haf != hits_and_fractions.end(); ++it_haf) {
unsigned int hitlayer = recHitTools.getLayerWithOffset(it_haf->first);
DetId hitid = (it_haf->first);

// dump raw RecHits and match
if (rawRecHits_) {
if (hitid.det() == DetId::Forward && hitid.subdetId() == HGCEE &&
(algo_ == 1 || algo_ == 2)) {
const HGCRecHitCollection& rechitsEE = *recHitHandleEE;
// loop over EE RecHits
bool found(false);
for (auto it_hit = rechitsEE.begin();
it_hit < rechitsEE.end(); ++it_hit) {
const HGCalDetId detid = it_hit->detid();
unsigned int layer = recHitTools.getLayerWithOffset(detid);
if(detid == hitid){
if(hitlayer != layer) {
if (detid == hitid) {
found = true;
if (hitlayer != layer) {
#ifdef EDM_ML_DEBUG
std::cout << " recHit ID problem EE " << std::endl;
#endif
return;
}
Energy_layer_calib_fraction[layer] += it_hit->energy()*it_haf->second;
LayerOccupancy_[0]->Fill(layer);
LayerOccupancy_[type]->Fill(layer);
h_LayerOccupancy_[0]->Fill(layer);
h_LayerOccupancy_[type]->Fill(layer);
if(seedEnergy < it_hit->energy()){
seedEnergy = it_hit->energy();
seedDet = recHitTools.getSiThickness(detid);
}
break;
}
}
if (!found) ++mhit[0];
}
if (hitid.det() == DetId::Forward && hitid.subdetId() == HGCHEF &&
(algo_ == 1 || algo_ == 3)) {
const HGCRecHitCollection& rechitsFH = *recHitHandleFH;
// loop over HEF RecHits
bool found(false);
for (auto it_hit = rechitsFH.begin();
it_hit < rechitsFH.end(); ++it_hit) {
const HGCalDetId detid = it_hit->detid();
unsigned int layer = recHitTools.getLayerWithOffset(detid);
if(detid == hitid){
if (detid == hitid) {
found = true;
if (hitlayer != layer) {
#ifdef EDM_ML_DEBUG
std::cout << " recHit ID problem FH " << std::endl;
#endif
return;
}
Energy_layer_calib_fraction[layer] += it_hit->energy()*it_haf->second;
LayerOccupancy_[0]->Fill(layer);
LayerOccupancy_[type]->Fill(layer);
h_LayerOccupancy_[0]->Fill(layer);
h_LayerOccupancy_[type]->Fill(layer);
if(seedEnergy < it_hit->energy()){
seedEnergy = it_hit->energy();
seedDet = recHitTools.getSiThickness(detid);
}
break;
}
}
if (!found) ++mhit[1];
}
if (hitid.det() == DetId::Forward && hitid.subdetId() == HGCHEB &&
if (hitid.det() == DetId::Hcal && hitid.subdetId() == HcalEndcap &&
(algo_ == 1 || algo_ == 3)) {
const HGCRecHitCollection& rechitsBH = *recHitHandleBH;
// loop over BH RecHits
bool found(false);
for (auto it_hit = rechitsBH.begin();
it_hit < rechitsBH.end(); ++it_hit) {
const HcalDetId detid = it_hit->detid();
unsigned int layer = recHitTools.getLayerWithOffset(detid);
if(detid == hitid){
if (detid == hitid) {
found = true;
if (hitlayer != layer) {
#ifdef EDM_ML_DEBUG
std::cout << " recHit ID problem BH " << std::endl;
#endif
return;
}
Energy_layer_calib_fraction[layer] += it_hit->energy()*it_haf->second;
LayerOccupancy_[0]->Fill(layer);
LayerOccupancy_[type]->Fill(layer);
h_LayerOccupancy_[0]->Fill(layer);
h_LayerOccupancy_[type]->Fill(layer);
if (seedEnergy < it_hit->energy()){
seedEnergy = it_hit->energy();
seedDet = recHitTools.getSiThickness(detid);
seedDet = 300; // recHitTools.getSiThickness(detid);
}
break;
}
}
if (!found) ++mhit[2];
}

}//end recHits
Expand All @@ -263,6 +277,7 @@ void HGCalHitCalibration::analyze(const edm::Event& iEvent, const edm::EventSetu
}
}//end caloparticle

for (int k=0; k<3; ++k) h_MissingHit_[k]->Fill(mhit[k]);
}

// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
Expand Down
2 changes: 1 addition & 1 deletion Validation/HGCalValidation/python/rechitStudy_cff.py
@@ -1,6 +1,6 @@
import FWCore.ParameterSet.Config as cms

from Validation.HGCalValidation.hgcalRechitStudyEE_cfi import *
from Validation.HGCalValidation.hgcalRecHitStudyEE_cfi import *

hgcalRecHitStudyFH = hgcalRecHitStudyEE.clone(
DetectorName = cms.string("HGCalHESiliconSensitive"),
Expand Down
4 changes: 2 additions & 2 deletions Validation/HGCalValidation/test/HGCalRecHitStudy.cc
Expand Up @@ -111,7 +111,7 @@ HGCalRecHitStudy::HGCalRecHitStudy(const edm::ParameterSet& iConfig) {
recHitSource_ = consumes<HGCRecHitCollection>(temp);
} else if ( nameDetector_ == "HCal" ) {
if (ifHCAL_) recHitSource_ = consumes<HBHERecHitCollection>(temp);
else recHitSource_ = consumes<HGChebRecHitCollection>(temp);
else recHitSource_ = consumes<HGCRecHitCollection>(temp);
} else {
throw cms::Exception("BadHGCRecHitSource")
<< "HGCal DetectorName given as " << nameDetector_ << " must be: "
Expand Down Expand Up @@ -158,7 +158,7 @@ void HGCalRecHitStudy::analyze(const edm::Event& iEvent,
edm::LogWarning("HGCalValidation") << "HBHERecHitCollection Handle does not exist !!!";
}
} else {
edm::Handle<HGChebRecHitCollection> hbhecoll;
edm::Handle<HGCRecHitCollection> hbhecoll;
iEvent.getByToken(recHitSource_, hbhecoll);
if (hbhecoll.isValid()) {
if (verbosity_>0)
Expand Down
47 changes: 47 additions & 0 deletions Validation/HGCalValidation/test/runHGCalHitCalibration_cfg.py
@@ -0,0 +1,47 @@
import FWCore.ParameterSet.Config as cms
import FWCore.Utilities.FileUtils as FileUtils

process = cms.Process("HGCGeomAnalysis")

process.load('Configuration.StandardSequences.Services_cff')
process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
process.load('FWCore.MessageService.MessageLogger_cfi')
process.load('Configuration.EventContent.EventContent_cff')
process.load('Configuration.Geometry.GeometryExtended2023D13Reco_cff')
process.load('Configuration.StandardSequences.MagneticField_cff')
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')

from Configuration.AlCa.GlobalTag import GlobalTag
##Global Tag used for production in
process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '')

process.MessageLogger.cerr.FwkReport.reportEvery = 100

process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring(
'root://cms-xrd-global.cern.ch//store/relval/CMSSW_9_1_0_pre3/RelValTTbar_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D13-v2/10000/0E0708E1-582E-E711-8D30-0025905B8604.root',
#'root://cms-xrd-global.cern.ch//store/relval/CMSSW_9_1_0_pre3/RelValTTbar_14TeV/GEN-SIM-RECO/PU25ns_91X_upgrade2023_realistic_v1_D13PU200-v2/10000/04A22787-5E31-E711-A724-0025905A6090.root',
#'root://cms-xrd-global.cern.ch//store/relval/CMSSW_9_1_0_pre3/RelValTTbar_14TeV/GEN-SIM-RECO/PU25ns_91X_upgrade2023_realistic_v1_D13PU200-v2/10000/06E13ACA-5D31-E711-B32D-0025905A48F2.root',
#'root://cms-xrd-global.cern.ch//store/relval/CMSSW_9_1_0_pre3/RelValTTbar_14TeV/GEN-SIM-RECO/PU25ns_91X_upgrade2023_realistic_v1_D13PU200-v2/10000/0A4780A9-6031-E711-9762-0025905A60F8.root',
#'root://cms-xrd-global.cern.ch//store/relval/CMSSW_9_1_0_pre3/RelValTTbar_14TeV/GEN-SIM-RECO/PU25ns_91X_upgrade2023_realistic_v1_D13PU200-v2/10000/0A888C70-6531-E711-842E-0CC47A7C346E.root'
)
)
process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(100)
)

process.load('Validation.HGCalValidation.hgcalHitCalibration_cfi')

process.TFileService = cms.Service("TFileService",
fileName = cms.string('RelVal.root'),
closeFileFast = cms.untracked.bool(True)
)

SimpleMemoryCheck = cms.Service("SimpleMemoryCheck",ignoreTotal = cms.untracked.int32(1) )

#process.hgcHitAnalysis.ietaExcludeBH = [16,92,93,94,95,96,97,98,99,100]
#process.hgcHitAnalysis.ietaExcludeBH = [16, 32, 33]

process.p = cms.Path(process.hgcalHitCalibration)


44 changes: 44 additions & 0 deletions Validation/HGCalValidation/test/runHGCalRecHitStudy_cfg.py
@@ -0,0 +1,44 @@
import FWCore.ParameterSet.Config as cms
import FWCore.Utilities.FileUtils as FileUtils

process = cms.Process("HGCGeomAnalysis")

process.load('Configuration.StandardSequences.Services_cff')
process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
process.load('FWCore.MessageService.MessageLogger_cfi')
process.load('Configuration.EventContent.EventContent_cff')
process.load('Configuration.Geometry.GeometryExtended2023D13Reco_cff')
process.load('Configuration.StandardSequences.MagneticField_cff')
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')

from Configuration.AlCa.GlobalTag import GlobalTag
##Global Tag used for production in
process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '')

process.MessageLogger.cerr.FwkReport.reportEvery = 100

process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring(
'root://cms-xrd-global.cern.ch//store/relval/CMSSW_9_1_0_pre3/RelValTTbar_14TeV/GEN-SIM/91X_upgrade2023_realistic_v1_D13-v2/10000/0E0708E1-582E-E711-8D30-0025905B8604.root',
#'root://cms-xrd-global.cern.ch//store/relval/CMSSW_9_1_0_pre3/RelValTTbar_14TeV/GEN-SIM-RECO/PU25ns_91X_upgrade2023_realistic_v1_D13PU200-v2/10000/04A22787-5E31-E711-A724-0025905A6090.root',
#'root://cms-xrd-global.cern.ch//store/relval/CMSSW_9_1_0_pre3/RelValTTbar_14TeV/GEN-SIM-RECO/PU25ns_91X_upgrade2023_realistic_v1_D13PU200-v2/10000/06E13ACA-5D31-E711-B32D-0025905A48F2.root',
#'root://cms-xrd-global.cern.ch//store/relval/CMSSW_9_1_0_pre3/RelValTTbar_14TeV/GEN-SIM-RECO/PU25ns_91X_upgrade2023_realistic_v1_D13PU200-v2/10000/0A4780A9-6031-E711-9762-0025905A60F8.root',
#'root://cms-xrd-global.cern.ch//store/relval/CMSSW_9_1_0_pre3/RelValTTbar_14TeV/GEN-SIM-RECO/PU25ns_91X_upgrade2023_realistic_v1_D13PU200-v2/10000/0A888C70-6531-E711-842E-0CC47A7C346E.root'
)
)
process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(100)
)

process.load('Validation.HGCalValidation.rechitStudy_cff')

process.TFileService = cms.Service("TFileService",
fileName = cms.string('RelVal.root'),
closeFileFast = cms.untracked.bool(True)
)

SimpleMemoryCheck = cms.Service("SimpleMemoryCheck",ignoreTotal = cms.untracked.int32(1) )

process.p = cms.Path(process.hgcalRecHitStudyEE+process.hgcalRecHitStudyFH+process.hgcalRecHitStudyBH)


0 comments on commit c58ba64

Please sign in to comment.