Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate calotower code to use HCAL thresholds from GT #43329

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion RecoLocalCalo/CaloTowersCreator/python/calotowermaker_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@
AllowMissingInputs = cms.bool(False),

# specify hcal upgrade phase - 0, 1, 2
HcalPhase = cms.int32(0)
HcalPhase = cms.int32(0),

# Read HBHE thresholds from Global Tag
usePFThresholdsFromDB = cms.bool(False)

)

Expand Down Expand Up @@ -175,3 +178,8 @@
HBThreshold2 = 0.2,
HBThreshold = 0.3,
)

#--- Use DB conditions for HBHE thresholds for Run3 and phase2
from Configuration.Eras.Modifier_hcalPfCutsFromDB_cff import hcalPfCutsFromDB
hcalPfCutsFromDB.toModify( calotowermaker,
usePFThresholdsFromDB = True)
23 changes: 20 additions & 3 deletions RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreationAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ CaloTowersCreationAlgo::CaloTowersCreationAlgo(double EBthreshold,
// nalgo=N;
}

void CaloTowersCreationAlgo::setThresFromDB(const HcalPFCuts* cuts) { hcalCuts = cuts; }

void CaloTowersCreationAlgo::setGeometry(const CaloTowerTopology* cttopo,
const CaloTowerConstituentsMap* ctmap,
const HcalTopology* htopo,
Expand Down Expand Up @@ -1271,7 +1273,12 @@ void CaloTowersCreationAlgo::getThresholdAndWeight(const DetId& detId, double& t
int depth = hcalDetId.depth();

if (subdet == HcalBarrel) {
threshold = (depth == 1) ? theHBthreshold1 : (depth == 2) ? theHBthreshold2 : theHBthreshold;
if (hcalCuts == nullptr) { // this means cutsFromDB is false
threshold = (depth == 1) ? theHBthreshold1 : (depth == 2) ? theHBthreshold2 : theHBthreshold;
} else { // hcalCuts is not nullptr, i.e. cutsFromDB is true
const HcalPFCut* item = hcalCuts->getValues(hcalDetId.rawId());
threshold = item->noiseThreshold();
}
weight = theHBweight;
if (weight <= 0.) {
ROOT::Math::Interpolator my(theHBGrid, theHBWeights, ROOT::Math::Interpolation::kAKIMA);
Expand All @@ -1282,14 +1289,24 @@ void CaloTowersCreationAlgo::getThresholdAndWeight(const DetId& detId, double& t
else if (subdet == HcalEndcap) {
// check if it's single or double tower
if (hcalDetId.ietaAbs() < theHcalTopology->firstHEDoublePhiRing()) {
threshold = (depth == 1) ? theHESthreshold1 : theHESthreshold;
if (hcalCuts == nullptr) { // this means cutsFromDB is false
threshold = (depth == 1) ? theHESthreshold1 : theHESthreshold;
} else { // hcalCuts is not nullptr, i.e. cutsFromDB is true
const HcalPFCut* item = hcalCuts->getValues(hcalDetId.rawId());
threshold = item->noiseThreshold();
}
weight = theHESweight;
if (weight <= 0.) {
ROOT::Math::Interpolator my(theHESGrid, theHESWeights, ROOT::Math::Interpolation::kAKIMA);
weight = my.Eval(theHESEScale);
}
} else {
threshold = (depth == 1) ? theHEDthreshold1 : theHEDthreshold;
if (hcalCuts == nullptr) { // this means cutsFromDB is false
threshold = (depth == 1) ? theHEDthreshold1 : theHEDthreshold;
} else { // hcalCuts is not nullptr, i.e. cutsFromDB is true
const HcalPFCut* item = hcalCuts->getValues(hcalDetId.rawId());
threshold = item->noiseThreshold();
}
weight = theHEDweight;
if (weight <= 0.) {
ROOT::Math::Interpolator my(theHEDGrid, theHEDWeights, ROOT::Math::Interpolation::kAKIMA);
Expand Down
6 changes: 6 additions & 0 deletions RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreationAlgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#include <tuple>

#include <map>

#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h"
#include "CondTools/Hcal/interface/HcalPFCutsHandler.h"

class CaloTowerTopology;
class HcalTopology;
class CaloGeometry;
Expand Down Expand Up @@ -158,6 +162,7 @@ class CaloTowersCreationAlgo {
const HcalTopology* htopo,
const CaloGeometry* geo);

void setThresFromDB(const HcalPFCuts* cuts);
// pass the containers of channels status from the event record (stored in DB)
// these are called in CaloTowersCreator
void setHcalChStatusFromDB(const HcalChannelQuality* s) { theHcalChStatus = s; }
Expand Down Expand Up @@ -317,6 +322,7 @@ class CaloTowersCreationAlgo {
double theHOEScale;
double theHF1EScale;
double theHF2EScale;
const HcalPFCuts* hcalCuts;
const CaloTowerTopology* theTowerTopology;
const HcalTopology* theHcalTopology;
const CaloGeometry* theGeometry;
Expand Down
22 changes: 20 additions & 2 deletions RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Now we allow for the creation of towers from
// rejected hists as well: requested by the MET group
// for studies of the effect of noise clean up.

#include "CaloTowersCreationAlgo.h"
#include "EScales.h"

Expand All @@ -25,12 +24,15 @@
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h"
#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h"
#include "CondTools/Hcal/interface/HcalPFCutsHandler.h"

class CaloTowersCreator : public edm::stream::EDProducer<> {
public:
explicit CaloTowersCreator(const edm::ParameterSet& ps);
~CaloTowersCreator() override {}
void produce(edm::Event& e, const edm::EventSetup& c) override;
void beginRun(edm::Run const&, edm::EventSetup const&) override;
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
double EBEScale, EEEScale, HBEScale, HESEScale;
double HEDEScale, HOEScale, HF1EScale, HF2EScale;
Expand Down Expand Up @@ -84,6 +86,10 @@ class CaloTowersCreator : public edm::stream::EDProducer<> {
edm::ESWatcher<IdealGeometryRecord> caloTowerConstituentsWatcher_;
edm::ESWatcher<EcalSeverityLevelAlgoRcd> ecalSevLevelWatcher_;
EScales eScales_;

edm::ESGetToken<HcalPFCuts, HcalPFCutsRcd> hcalCutsToken_;
bool cutsFromDB;
HcalPFCuts const* paramPF = nullptr;
};

#include "FWCore/Framework/interface/MakerMacros.h"
Expand Down Expand Up @@ -165,7 +171,8 @@ CaloTowersCreator::CaloTowersCreator(const edm::ParameterSet& conf)
conf.getParameter<unsigned int>("HcalAcceptSeverityLevelForRejectedHit")),

useRejectedRecoveredHcalHits_(conf.getParameter<bool>("UseRejectedRecoveredHcalHits")),
useRejectedRecoveredEcalHits_(conf.getParameter<bool>("UseRejectedRecoveredEcalHits"))
useRejectedRecoveredEcalHits_(conf.getParameter<bool>("UseRejectedRecoveredEcalHits")),
cutsFromDB(conf.getParameter<bool>("usePFThresholdsFromDB"))

{
algo_.setMissingHcalRescaleFactorForEcal(conf.getParameter<double>("missingHcalRescaleFactorForEcal"));
Expand All @@ -183,6 +190,9 @@ CaloTowersCreator::CaloTowersCreator(const edm::ParameterSet& conf)
tok_hcalSevComputer_ = esConsumes<HcalSeverityLevelComputer, HcalSeverityLevelComputerRcd>();
tok_ecalSevAlgo_ = esConsumes<EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd>();

if (cutsFromDB) {
hcalCutsToken_ = esConsumes<HcalPFCuts, HcalPFCutsRcd, edm::Transition::BeginRun>(edm::ESInputTag("", "withTopo"));
}
const unsigned nLabels = ecalLabels_.size();
for (unsigned i = 0; i != nLabels; i++)
toks_ecal_.push_back(consumes<EcalRecHitCollection>(ecalLabels_[i]));
Expand Down Expand Up @@ -217,6 +227,13 @@ CaloTowersCreator::CaloTowersCreator(const edm::ParameterSet& conf)
#endif
}

void CaloTowersCreator::beginRun(const edm::Run& run, const edm::EventSetup& es) {
if (cutsFromDB) {
paramPF = &es.getData(hcalCutsToken_);
}
algo_.setThresFromDB(paramPF);
}

void CaloTowersCreator::produce(edm::Event& e, const edm::EventSetup& c) {
// get the necessary event setup objects...
edm::ESHandle<CaloGeometry> pG = c.getHandle(tok_geom_);
Expand Down Expand Up @@ -452,6 +469,7 @@ void CaloTowersCreator::fillDescriptions(edm::ConfigurationDescriptions& descrip
desc.add<unsigned int>("HcalAcceptSeverityLevelForRejectedHit", 9999);
desc.add<std::vector<std::string> >("EcalSeveritiesToBeUsedInBadTowers", {});
desc.add<int>("HcalPhase", 0);
desc.add<bool>("usePFThresholdsFromDB", true);

descriptions.addDefault(desc);
}