Skip to content

Commit

Permalink
Merge pull request #19307 from cms-egamma/ECALPFClusterCorrection90X
Browse files Browse the repository at this point in the history
ECAL PFCluster Correction 9X
  • Loading branch information
cmsbuild committed Jul 3, 2017
2 parents aee2fec + f6602a1 commit 514d35a
Show file tree
Hide file tree
Showing 12 changed files with 509 additions and 265 deletions.
3 changes: 3 additions & 0 deletions CalibCalorimetry/EcalTPGTools/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<use name="FWCore/Framework"/>
<use name="FWCore/Utilities"/>
<use name="CondCore/DBOutputService"/>
<use name="Geometry/Records"/>
<use name="Geometry/CaloTopology"/>
<use name="Geometry/EcalMapping"/>
<export>
<lib name="1"/>
</export>
28 changes: 28 additions & 0 deletions CalibCalorimetry/EcalTPGTools/interface/EcalReadoutTools.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef CalibCalorimetry_EcalTPGTools_EcalReadoutTools_H
#define CalibCalorimetry_EcalTPGTools_EcalReadoutTools_H

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "Geometry/CaloTopology/interface/EcalTrigTowerConstituentsMap.h"
#include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
#include "Geometry/EcalMapping/interface/EcalMappingRcd.h"

class EcalReadoutTools {

private:
const EcalTrigTowerConstituentsMap * triggerTowerMap_;
const EcalElectronicsMapping* elecMap_;

public:
EcalReadoutTools(const edm::Event &iEvent, const edm::EventSetup &iSetup);
EcalReadoutTools(const EcalReadoutTools&) = delete;
EcalReadoutTools& operator=(const EcalReadoutTools&) = delete;

EcalTrigTowerDetId readOutUnitOf(const EBDetId& xtalId) const;
EcalScDetId readOutUnitOf(const EEDetId& xtalId) const;
};

#endif
26 changes: 26 additions & 0 deletions CalibCalorimetry/EcalTPGTools/src/EcalReadoutTools.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "CalibCalorimetry/EcalTPGTools/interface/EcalReadoutTools.h"

EcalReadoutTools::EcalReadoutTools(const edm::Event &iEvent, const edm::EventSetup &iSetup) {

edm::ESHandle<EcalTrigTowerConstituentsMap> hTriggerTowerMap;
iSetup.get<IdealGeometryRecord>().get(hTriggerTowerMap);
triggerTowerMap_ = hTriggerTowerMap.product();

edm::ESHandle< EcalElectronicsMapping > ecalmapping;
iSetup.get< EcalMappingRcd >().get(ecalmapping);
elecMap_ = ecalmapping.product();

}

EcalTrigTowerDetId EcalReadoutTools::readOutUnitOf(const EBDetId& xtalId) const{
return triggerTowerMap_->towerOf(xtalId);
}

EcalScDetId EcalReadoutTools::readOutUnitOf(const EEDetId& xtalId) const{
const EcalElectronicsId& EcalElecId = elecMap_->getElectronicsId(xtalId);
int iDCC= EcalElecId.dccId();
int iDccChan = EcalElecId.towerId();
const bool ignoreSingle = true;
const std::vector<EcalScDetId> id = elecMap_->getEcalScDetId(iDCC, iDccChan, ignoreSingle);
return id.size()>0?id[0]:EcalScDetId();
}
52 changes: 26 additions & 26 deletions Configuration/AlCa/python/autoCond.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,60 @@

### NEW KEYS ###
# GlobalTag for MC production with perfectly aligned and calibrated detector for Run1
'run1_design' : '92X_mcRun1_design_v1',
'run1_design' : '92X_mcRun1_design_v2',
# GlobalTag for MC production (pp collisions) with realistic alignment and calibrations for Run1
'run1_mc' : '92X_mcRun1_realistic_v1',
'run1_mc' : '92X_mcRun1_realistic_v2',
# GlobalTag for MC production (Heavy Ions collisions) with realistic alignment and calibrations for Run1
'run1_mc_hi' : '92X_mcRun1_HeavyIon_v1',
'run1_mc_hi' : '92X_mcRun1_HeavyIon_v2',
# GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run1
'run1_mc_pa' : '92X_mcRun1_pA_v1',
'run1_mc_pa' : '92X_mcRun1_pA_v2',
# GlobalTag for MC production with perfectly aligned and calibrated detector for Run2
'run2_design' : '92X_mcRun2_design_v1',
'run2_design' : '92X_mcRun2_design_v2',
# GlobalTag for MC production with pessimistic alignment and calibrations for Run2
'run2_mc_50ns' : '92X_mcRun2_startup_v1',
'run2_mc_50ns' : '92X_mcRun2_startup_v2',
#GlobalTag for MC production with optimistic alignment and calibrations for Run2
'run2_mc' : '92X_mcRun2_asymptotic_v1',
'run2_mc' : '92X_mcRun2_asymptotic_v2',
# GlobalTag for MC production (cosmics) with starup-like alignment and calibrations for Run2, Strip tracker in peak mode
'run2_mc_cosmics' : '92X_mcRun2cosmics_startup_deco_v1',
'run2_mc_cosmics' : '92X_mcRun2cosmics_startup_deco_v2',
# GlobalTag for MC production (Heavy Ions collisions) with optimistic alignment and calibrations for Run2
'run2_mc_hi' : '92X_mcRun2_HeavyIon_v1',
'run2_mc_hi' : '92X_mcRun2_HeavyIon_v2',
# GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2
'run2_mc_pa' : '92X_mcRun2_pA_v1',
'run2_mc_pa' : '92X_mcRun2_pA_v2',
# GlobalTag for Run1 data reprocessing
'run1_data' : '92X_dataRun2_v1',
'run1_data' : '92X_dataRun2_v2',
# GlobalTag for Run2 data reprocessing
'run2_data' : '92X_dataRun2_v1',
'run2_data' : '92X_dataRun2_v2',
# GlobalTag for Run2 data relvals: allows customization to run with fixed L1 menu
'run2_data_relval' : '92X_dataRun2_relval_v1',
'run2_data_relval' : '92X_dataRun2_relval_v2',
# GlobalTag for Run2 data 2016H relvals only: Prompt Conditions + fixed L1 menu (to be removed)
'run2_data_promptlike' : '92X_dataRun2_PromptLike_v0',
'run2_data_promptlike' : '92X_dataRun2_PromptLike_v1',

# GlobalTag for Run1 HLT: it points to the online GT
'run1_hlt' : '92X_dataRun2_HLT_frozen_v1',
'run1_hlt' : '92X_dataRun2_HLT_frozen_v2',
# GlobalTag for Run2 HLT: it points to the online GT
'run2_hlt' : '92X_dataRun2_HLT_frozen_v1',
'run2_hlt' : '92X_dataRun2_HLT_frozen_v2',
# GlobalTag for Run2 HLT RelVals: customizations to run with fixed L1 Menu
'run2_hlt_relval' : '92X_dataRun2_HLT_relval_v3',
'run2_hlt_relval' : '92X_dataRun2_HLT_relval_v4',
# GlobalTag for Run2 HLT for HI: it points to the online GT
'run2_hlt_hi' : '92X_dataRun2_HLTHI_frozen_v2',
'run2_hlt_hi' : '92X_dataRun2_HLTHI_frozen_v3',
# GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2017 (and 0,0,~0-centred beamspot)
'phase1_2017_design' : '92X_upgrade2017_design_IdealBS_v5',
'phase1_2017_design' : '92X_upgrade2017_design_IdealBS_v6',
# GlobalTag for MC production with realistic conditions for Phase1 2017 detector
'phase1_2017_realistic' : '92X_upgrade2017_realistic_v5',
'phase1_2017_realistic' : '92X_upgrade2017_realistic_v6',
# GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in DECO mode
'phase1_2017_cosmics' : '92X_upgrade2017cosmics_realistic_deco_v5',
'phase1_2017_cosmics' : '92X_upgrade2017cosmics_realistic_deco_v6',
# GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in PEAK mode
'phase1_2017_cosmics_peak' : '92X_upgrade2017cosmics_realistic_peak_v5',
'phase1_2017_cosmics_peak' : '92X_upgrade2017cosmics_realistic_peak_v6',
# GlobalTag for MC production with perfectly aligned and calibrated detector for full Phase1 2018 (and 0,0,0-centred beamspot)
'phase1_2018_design' : '92X_upgrade2018_design_IdealBS_v4',
'phase1_2018_design' : '92X_upgrade2018_design_IdealBS_v5',
# GlobalTag for MC production with realistic conditions for full Phase1 2018 detector
'phase1_2018_realistic' : '92X_upgrade2018_realistic_v5',
'phase1_2018_realistic' : '92X_upgrade2018_realistic_v6',
# GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in DECO mode
'phase1_2018_cosmics' : '92X_upgrade2018cosmics_realistic_deco_v5',
'phase1_2018_cosmics' : '92X_upgrade2018cosmics_realistic_deco_v6',
# GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2019
'phase1_2019_design' : 'DES19_70_V2', # placeholder (GT not meant for standard RelVal)
# GlobalTag for MC production with realistic conditions for Phase2 2023
'phase2_realistic' : '92X_upgrade2023_realistic_v0'
'phase2_realistic' : '92X_upgrade2023_realistic_v1'
}

aliases = {
Expand Down
1 change: 1 addition & 0 deletions RecoParticleFlow/PFClusterProducer/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<use name="RecoEcal/EgammaCoreTools"/>
<use name="RecoParticleFlow/PFClusterTools"/>
<use name="Calibration/Tools"/>
<use name="CalibCalorimetry/EcalTPGTools"/>
<use name="vdt_headers"/>
<use name="rootmath"/>
<use name="root"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,23 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
#include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h"
#include "DataFormats/ParticleFlowReco/interface/PFRecHit.h"
#include "RecoParticleFlow/PFClusterTools/interface/PFEnergyCalibration.h"
#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
#include "DataFormats/EcalDigi/interface/EBSrFlag.h"
#include "DataFormats/EcalDigi/interface/EESrFlag.h"
#include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"

#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
#include "CalibCalorimetry/EcalTPGTools/interface/EcalReadoutTools.h"
#include "RecoParticleFlow/PFClusterTools/interface/PFEnergyCalibration.h"

#include "CondFormats/DataRecord/interface/GBRDWrapperRcd.h"
#include "CondFormats/EgammaObjects/interface/GBRForestD.h"

class PFClusterEMEnergyCorrector {
public:
Expand All @@ -23,25 +32,54 @@ class PFClusterEMEnergyCorrector {
void correctEnergies(const edm::Event &evt, const edm::EventSetup &es, const reco::PFCluster::EEtoPSAssociation &assoc, reco::PFClusterCollection& cs);

private:
bool _applyCrackCorrections;
bool _applyMVACorrections;
double _maxPtForMVAEvaluation;

bool autoDetectBunchSpacing_;
int bunchSpacingManual_;

double maxPtForMVAEvaluation_;

edm::EDGetTokenT<EBSrFlagCollection> ebSrFlagToken_;
edm::EDGetTokenT<EESrFlagCollection> eeSrFlagToken_;

//required for reading SR flags
edm::EDGetTokenT<EcalRecHitCollection> recHitsEB_;
edm::EDGetTokenT<EcalRecHitCollection> recHitsEE_;
edm::EDGetTokenT<unsigned int> bunchSpacing_;

edm::EDGetTokenT<EcalRecHitCollection> _recHitsEB;
edm::EDGetTokenT<EcalRecHitCollection> _recHitsEE;

std::vector<std::string> _condnames_mean_50ns;
std::vector<std::string> _condnames_sigma_50ns;
std::vector<std::string> _condnames_mean_25ns;
std::vector<std::string> _condnames_sigma_25ns;
std::vector<std::string> condnames_mean_;
std::vector<std::string> condnames_sigma_;

std::vector<std::string> condnames_mean_25ns_;
std::vector<std::string> condnames_sigma_25ns_;
std::vector<std::string> condnames_mean_50ns_;
std::vector<std::string> condnames_sigma_50ns_;

bool srfAwareCorrection_;
bool applyCrackCorrections_;
bool applyMVACorrections_;

bool autoDetectBunchSpacing_;
int bunchSpacingManual_;

std::unique_ptr<PFEnergyCalibration> calibrator_;
void getAssociatedPSEnergy(const size_t clusIdx, const reco::PFCluster::EEtoPSAssociation &assoc, float& e1, float& e2);

double meanlimlowEB_;
double meanlimhighEB_;
double meanoffsetEB_;
double meanscaleEB_;

std::unique_ptr<PFEnergyCalibration> _calibrator;
double meanlimlowEE_;
double meanlimhighEE_;
double meanoffsetEE_;
double meanscaleEE_;

double sigmalimlowEB_;
double sigmalimhighEB_;
double sigmaoffsetEB_;
double sigmascaleEB_;

double sigmalimlowEE_;
double sigmalimhighEE_;
double sigmaoffsetEE_;
double sigmascaleEE_;

};

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,16 @@ void CorrectedECALPFClusterProducer::fillDescriptions(edm::ConfigurationDescript
edm::ParameterSetDescription psd0;
psd0.add<bool>("applyCrackCorrections",false);
psd0.add<bool>("applyMVACorrections",false);
psd0.add<bool>("srfAwareCorrection",false);
psd0.add<bool>("autoDetectBunchSpacing",true);
psd0.add<int>("bunchSpacing",25);
psd0.add<double>("maxPtForMVAEvaluation",-99.);
psd0.add<std::string>("algoName","PFClusterEMEnergyCorrector");
psd0.add<edm::InputTag>("recHitsEBLabel",edm::InputTag("ecalRecHit","EcalRecHitsEB"));
psd0.add<edm::InputTag>("recHitsEELabel",edm::InputTag("ecalRecHit","EcalRecHitsEE"));
psd0.add<edm::InputTag>("verticesLabel",edm::InputTag("offlinePrimaryVertices"));
psd0.add<bool>("autoDetectBunchSpacing",true);
psd0.add<int>("bunchSpacing",25);
psd0.add<edm::InputTag>("ebSrFlagLabel",edm::InputTag("ecalDigis"));
psd0.add<edm::InputTag>("eeSrFlagLabel",edm::InputTag("ecalDigis"));
desc.add<edm::ParameterSetDescription>("energyCorrector",psd0);
}
desc.add<edm::InputTag>("inputECAL",edm::InputTag("particleFlowClusterECALUncorrected"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import FWCore.ParameterSet.Config as cms

from RecoParticleFlow.PFClusterProducer.particleFlowClusterECAL_cfi import particleFlowClusterECAL
particleFlowClusterECAL.energyCorrector.applyMVACorrections = True
particleFlowClusterECAL.energyCorrector.maxPtForMVAEvaluation = 90.

from Configuration.Eras.Modifier_run2_ECAL_2017_cff import run2_ECAL_2017
run2_ECAL_2017.toModify(particleFlowClusterECAL,
energyCorrector = dict(srfAwareCorrection = True, maxPtForMVAEvaluation = 300.))

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import FWCore.ParameterSet.Config as cms
from RecoParticleFlow.PFClusterProducer.particleFlowClusterECAL_cfi import *
from RecoParticleFlow.PFClusterProducer.particleFlowClusterECAL_cff import *

particleFlowClusterOOTECAL = particleFlowClusterECAL.clone()
particleFlowClusterOOTECAL.inputECAL = cms.InputTag("particleFlowClusterOOTECALUncorrected")
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
from RecoParticleFlow.PFClusterProducer.particleFlowRecHitPS_cfi import *

from RecoParticleFlow.PFClusterProducer.particleFlowClusterECALUncorrected_cfi import *
from RecoParticleFlow.PFClusterProducer.particleFlowClusterECAL_cfi import *

from RecoParticleFlow.PFClusterProducer.particleFlowClusterECAL_cff import *

from RecoParticleFlow.PFClusterProducer.particleFlowClusterHBHE_cfi import *
from RecoParticleFlow.PFClusterProducer.particleFlowClusterHBHETimeSelected_cfi import *
Expand All @@ -22,7 +21,6 @@
from RecoParticleFlow.PFClusterProducer.particleFlowClusterPS_cfi import *

particleFlowClusterECALSequence = cms.Sequence(particleFlowClusterECAL)

pfClusteringECAL = cms.Sequence(particleFlowRecHitECAL*
particleFlowClusterECALUncorrected *
particleFlowClusterECALSequence)
Expand Down
Loading

0 comments on commit 514d35a

Please sign in to comment.