Skip to content

Commit

Permalink
Add backward compatible nutple interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jbsauvan committed Sep 28, 2021
1 parent 60c1753 commit 0344ed8
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 27 deletions.
5 changes: 5 additions & 0 deletions L1Trigger/L1THGCal/interface/HGCalTriggerTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@
#include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
#include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"

namespace edm {
class EventSetup;
}

class HGCalTriggerTools {
public:
HGCalTriggerTools() : geom_(nullptr), eeLayers_(0), fhLayers_(0), bhLayers_(0), noseLayers_(0), totalLayers_(0) {}
~HGCalTriggerTools() {}

void setGeometry(const HGCalTriggerGeometryBase* const);
void eventSetup(const edm::EventSetup&); // Kept for backward compatibility: used in L1Trigger/L1CaloTrigger/test
GlobalPoint getTCPosition(const DetId& id) const;
unsigned layers(ForwardSubdetector type) const;
unsigned layers(DetId::Detector type) const;
Expand Down
11 changes: 11 additions & 0 deletions L1Trigger/L1THGCal/src/HGCalTriggerTools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "SimDataFormats/CaloTest/interface/HGCalTestNumbering.h"

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

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

namespace {
template <typename DDD>
inline void check_ddd(const DDD* ddd) {
Expand All @@ -26,6 +30,13 @@ namespace {
}
} // namespace

// Kept for backward compatibility: used in L1Trigger/L1CaloTrigger/test
void HGCalTriggerTools::eventSetup(const edm::EventSetup& es) {
edm::ESHandle<HGCalTriggerGeometryBase> triggerGeometry;
es.get<CaloGeometryRecord>().get(triggerGeometry);
setGeometry(triggerGeometry.product());
}

void HGCalTriggerTools::setGeometry(const HGCalTriggerGeometryBase* const geom) {
geom_ = geom;
eeLayers_ = geom_->eeTopology().dddConstants().layers(true);
Expand Down
36 changes: 21 additions & 15 deletions L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,9 @@
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
// #include "SimGeneral/HepPDTRecord/interface/PDTRecord.h"
// #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
// #include "MagneticField/Engine/interface/MagneticField.h"
// #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "TTree.h"

// #include "MagneticField/Engine/interface/MagneticField.h"
// #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
// #include "TrackPropagation/RungeKutta/interface/defaultRKPropagator.h"
// #include "TrackPropagation/RungeKutta/interface/RKPropagatorInS.h"
// #include "FastSimulation/Event/interface/FSimEvent.h"
// #include "SimGeneral/HepPDTRecord/interface/PDTRecord.h"
//
// #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"

namespace HepPDT {
class ParticleDataTable;
}
Expand All @@ -35,13 +23,31 @@ struct HGCalTriggerNtupleEventSetup {

class HGCalTriggerNtupleBase {
public:
HGCalTriggerNtupleBase(const edm::ParameterSet& conf){};
HGCalTriggerNtupleBase(const edm::ParameterSet& conf) : name_(conf.getParameter<std::string>("NtupleName")){};
virtual ~HGCalTriggerNtupleBase(){};
const std::string& name() const { return name_; }
virtual void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) = 0;
virtual void fill(const edm::Event&, const HGCalTriggerNtupleEventSetup&) = 0;
virtual void fill(const edm::Event&, const HGCalTriggerNtupleEventSetup&) {
edm::LogWarning("NotImplemented") << "Calling ntuplizer fill(edm::Event, HGCalTriggerNtupleEventSetup), but it is "
"not implemented in the concrete class '"
<< name() << "'. "
<< "You might want to set 'accessEventSetup_' to true in order to call "
"fill(edm::Event, edm::EventSetup) instead.";
}
// Kept for backward compatibility: used in L1Trigger/L1CaloTrigger/test
virtual void fill(const edm::Event&, const edm::EventSetup&) {
edm::LogWarning("NotImplemented")
<< "Calling ntuplizer fill(edm::Event, edm::EventSetup), but it is not implemented in the concrete class '"
<< name() << "'. "
<< "You might want to set 'accessEventSetup_' to false in order to call fill(edm::Event, "
"HGCalTriggerNtupleEventSetup) instead.";
}
bool accessEventSetup() const { return accessEventSetup_; }

protected:
virtual void clear() = 0;
bool accessEventSetup_ = true;
const std::string name_;
};

#include "FWCore/PluginManager/interface/PluginFactory.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ class HGCalTriggerNtupleEvent : public HGCalTriggerNtupleBase {

DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleEvent, "HGCalTriggerNtupleEvent");

HGCalTriggerNtupleEvent::HGCalTriggerNtupleEvent(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) {}
HGCalTriggerNtupleEvent::HGCalTriggerNtupleEvent(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) {
accessEventSetup_ = false;
}

void HGCalTriggerNtupleEvent::initialize(TTree& tree, const edm::ParameterSet&, edm::ConsumesCollector&&) {
clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ class HGCalTriggerNtupleGen : public HGCalTriggerNtupleBase {

DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleGen, "HGCalTriggerNtupleGen");

HGCalTriggerNtupleGen::HGCalTriggerNtupleGen(const edm::ParameterSet &conf) : HGCalTriggerNtupleBase(conf) {}
HGCalTriggerNtupleGen::HGCalTriggerNtupleGen(const edm::ParameterSet &conf) : HGCalTriggerNtupleBase(conf) {
accessEventSetup_ = false;
}

void HGCalTriggerNtupleGen::initialize(TTree &tree, const edm::ParameterSet &conf, edm::ConsumesCollector &&collector) {
edm::ParameterSet particleFilter_(conf.getParameter<edm::ParameterSet>("particleFilter"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ class HGCalTriggerNtupleGenJet : public HGCalTriggerNtupleBase {

DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleGenJet, "HGCalTriggerNtupleGenJet");

HGCalTriggerNtupleGenJet::HGCalTriggerNtupleGenJet(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) {}
HGCalTriggerNtupleGenJet::HGCalTriggerNtupleGenJet(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) {
accessEventSetup_ = false;
}

void HGCalTriggerNtupleGenJet::initialize(TTree& tree,
const edm::ParameterSet& conf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ class HGCalTriggerNtupleGenTau : public HGCalTriggerNtupleBase {

DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleGenTau, "HGCalTriggerNtupleGenTau");

HGCalTriggerNtupleGenTau::HGCalTriggerNtupleGenTau(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) {}
HGCalTriggerNtupleGenTau::HGCalTriggerNtupleGenTau(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) {
accessEventSetup_ = false;
}

void HGCalTriggerNtupleGenTau::initialize(TTree& tree,
const edm::ParameterSet& conf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleHGCClusters, "HGC

HGCalTriggerNtupleHGCClusters::HGCalTriggerNtupleHGCClusters(const edm::ParameterSet& conf)
: HGCalTriggerNtupleBase(conf),
filter_clusters_in_multiclusters_(conf.getParameter<bool>("FilterClustersInMulticlusters")) {}
filter_clusters_in_multiclusters_(conf.getParameter<bool>("FilterClustersInMulticlusters")) {
accessEventSetup_ = false;
}

void HGCalTriggerNtupleHGCClusters::initialize(TTree& tree,
const edm::ParameterSet& conf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory,
"HGCalTriggerNtupleHGCConcentratorData");

HGCalTriggerNtupleHGCConcentratorData::HGCalTriggerNtupleHGCConcentratorData(const edm::ParameterSet& conf)
: HGCalTriggerNtupleBase(conf) {}
: HGCalTriggerNtupleBase(conf) {
accessEventSetup_ = false;
}

void HGCalTriggerNtupleHGCConcentratorData::initialize(TTree& tree,
const edm::ParameterSet& conf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class HGCalTriggerNtupleHGCDigis : public HGCalTriggerNtupleBase {
DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleHGCDigis, "HGCalTriggerNtupleHGCDigis");

HGCalTriggerNtupleHGCDigis::HGCalTriggerNtupleHGCDigis(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) {
accessEventSetup_ = false;
is_Simhit_comp_ = conf.getParameter<bool>("isSimhitComp");
digiBXselect_ = conf.getParameter<std::vector<unsigned int>>("digiBXselect");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleHGCMulticlusters,
HGCalTriggerNtupleHGCMulticlusters::HGCalTriggerNtupleHGCMulticlusters(const edm::ParameterSet& conf)
: HGCalTriggerNtupleBase(conf),
fill_layer_info_(conf.getParameter<bool>("FillLayerInfo")),
fill_interpretation_info_(conf.getParameter<bool>("FillInterpretationInfo")) {}
fill_interpretation_info_(conf.getParameter<bool>("FillInterpretationInfo")) {
accessEventSetup_ = false;
}

void HGCalTriggerNtupleHGCMulticlusters::initialize(TTree& tree,
const edm::ParameterSet& conf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ HGCalTriggerNtupleHGCTriggerCells::HGCalTriggerNtupleHGCTriggerCells(const edm::
keV2fC_(conf.getParameter<double>("keV2fC")),
fcPerMip_(conf.getParameter<std::vector<double>>("fcPerMip")),
layerWeights_(conf.getParameter<std::vector<double>>("layerWeights")),
thicknessCorrections_(conf.getParameter<std::vector<double>>("thicknessCorrections")) {}
thicknessCorrections_(conf.getParameter<std::vector<double>>("thicknessCorrections")) {
accessEventSetup_ = false;
}

void HGCalTriggerNtupleHGCTriggerCells::initialize(TTree& tree,
const edm::ParameterSet& conf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class HGCalTriggerNtupleHGCTriggerSums : public HGCalTriggerNtupleBase {
DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleHGCTriggerSums, "HGCalTriggerNtupleHGCTriggerSums");

HGCalTriggerNtupleHGCTriggerSums::HGCalTriggerNtupleHGCTriggerSums(const edm::ParameterSet& conf)
: HGCalTriggerNtupleBase(conf) {}
: HGCalTriggerNtupleBase(conf) {
accessEventSetup_ = false;
}

void HGCalTriggerNtupleHGCTriggerSums::initialize(TTree& tree,
const edm::ParameterSet& conf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ void HGCalTriggerNtupleManager::beginRun(const edm::Run& run, const edm::EventSe

void HGCalTriggerNtupleManager::analyze(const edm::Event& e, const edm::EventSetup& es) {
for (auto& hgc_ntuple : hgc_ntuples_) {
hgc_ntuple->fill(e, ntuple_es_);
if (hgc_ntuple->accessEventSetup()) {
hgc_ntuple->fill(e, es);
} else {
hgc_ntuple->fill(e, ntuple_es_);
}
}

tree_->Fill();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ class HGCalTriggerNtupleHGCTowers : public HGCalTriggerNtupleBase {

DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleHGCTowers, "HGCalTriggerNtupleHGCTowers");

HGCalTriggerNtupleHGCTowers::HGCalTriggerNtupleHGCTowers(const edm::ParameterSet& conf)
: HGCalTriggerNtupleBase(conf) {}
HGCalTriggerNtupleHGCTowers::HGCalTriggerNtupleHGCTowers(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) {
accessEventSetup_ = false;
}

void HGCalTriggerNtupleHGCTowers::initialize(TTree& tree,
const edm::ParameterSet& conf,
Expand Down

0 comments on commit 0344ed8

Please sign in to comment.