Skip to content

Commit

Permalink
Merge pull request cms-sw#58 from jbsauvan/geometry-esproduct
Browse files Browse the repository at this point in the history
Geometry included in EventSetup
  • Loading branch information
jbsauvan authored Oct 12, 2016
2 parents ce8f7b8 + fc1d011 commit 4388162
Show file tree
Hide file tree
Showing 22 changed files with 166 additions and 109 deletions.
21 changes: 14 additions & 7 deletions L1Trigger/L1THGCal/interface/HGCalTriggerBackendAlgorithmBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@

class HGCalTriggerBackendAlgorithmBase {
public:
HGCalTriggerBackendAlgorithmBase(const edm::ParameterSet& conf, const HGCalTriggerGeometryBase* const geom) :
geometry_(geom),
HGCalTriggerBackendAlgorithmBase(const edm::ParameterSet& conf) :
geometry_(nullptr),
name_(conf.getParameter<std::string>("AlgorithmName"))
{}
virtual ~HGCalTriggerBackendAlgorithmBase() {}

const std::string& name() const { return name_; }

virtual void setGeometry(const HGCalTriggerGeometryBase* const geom) {geometry_ = geom;}

//runs the trigger algorithm, storing internally the results
virtual void setProduces(edm::EDProducer& prod) const = 0;
Expand All @@ -47,7 +49,7 @@ class HGCalTriggerBackendAlgorithmBase {
virtual void reset() = 0;

protected:
const HGCalTriggerGeometryBase* const geometry_;
const HGCalTriggerGeometryBase* geometry_;

private:
const std::string name_;
Expand All @@ -59,16 +61,21 @@ namespace HGCalTriggerBackend {
template<typename FECODEC>
class Algorithm : public HGCalTriggerBackendAlgorithmBase {
public:
Algorithm(const edm::ParameterSet& conf, const HGCalTriggerGeometryBase* const geom) :
HGCalTriggerBackendAlgorithmBase(conf,geom),
codec_(conf.getParameterSet("FECodec"),geom){ }
Algorithm(const edm::ParameterSet& conf) :
HGCalTriggerBackendAlgorithmBase(conf),
codec_(conf.getParameterSet("FECodec")){ }

virtual void setGeometry(const HGCalTriggerGeometryBase* const geom) override final {
HGCalTriggerBackendAlgorithmBase::setGeometry(geom);
codec_.setGeometry(geom);
}

protected:
FECODEC codec_;
};
}

#include "FWCore/PluginManager/interface/PluginFactory.h"
typedef edmplugin::PluginFactory< HGCalTriggerBackendAlgorithmBase* (const edm::ParameterSet&, const HGCalTriggerGeometryBase* const) > HGCalTriggerBackendAlgorithmFactory;
typedef edmplugin::PluginFactory< HGCalTriggerBackendAlgorithmBase* (const edm::ParameterSet&) > HGCalTriggerBackendAlgorithmFactory;

#endif
4 changes: 3 additions & 1 deletion L1Trigger/L1THGCal/interface/HGCalTriggerBackendProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ class HGCalTriggerBackendProcessor {
public:
typedef std::unique_ptr<HGCalTriggerBackendAlgorithmBase> algo_ptr;

HGCalTriggerBackendProcessor(const edm::ParameterSet& conf, const HGCalTriggerGeometryBase* const geom);
HGCalTriggerBackendProcessor(const edm::ParameterSet& conf);

void setGeometry(const HGCalTriggerGeometryBase* const geom);

void setProduces(edm::EDProducer& prod) const;

Expand Down
15 changes: 8 additions & 7 deletions L1Trigger/L1THGCal/interface/HGCalTriggerFECodecBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

class HGCalTriggerFECodecBase {
public:
HGCalTriggerFECodecBase(const edm::ParameterSet& conf, const HGCalTriggerGeometryBase* const geom) :
geometry_(geom),
HGCalTriggerFECodecBase(const edm::ParameterSet& conf) :
geometry_(nullptr),
name_(conf.getParameter<std::string>("CodecName")),
codec_idx_(static_cast<unsigned char>(conf.getParameter<uint32_t>("CodecIndex")))
{}
Expand All @@ -35,8 +35,9 @@ class HGCalTriggerFECodecBase {
const std::string& name() const { return name_; }

const unsigned char getCodecType() const { return codec_idx_; }
void setGeometry(const HGCalTriggerGeometryBase* const geom) { geometry_ = geom;}

// give the FECodec the trigger geometry + input digis and it sets itself
// give the FECodec the input digis and it sets itself
// with the approprate data
virtual void setDataPayload(const HGCEEDigiCollection&,
const HGCHEDigiCollection&,
Expand All @@ -54,7 +55,7 @@ class HGCalTriggerFECodecBase {
std::ostream& out = std::cout) const = 0;

protected:
const HGCalTriggerGeometryBase* const geometry_;
const HGCalTriggerGeometryBase* geometry_;

private:
const std::string name_;
Expand All @@ -67,8 +68,8 @@ namespace HGCalTriggerFE {
template<typename Impl,typename DATA>
class Codec : public HGCalTriggerFECodecBase {
public:
Codec(const edm::ParameterSet& conf, const HGCalTriggerGeometryBase* const geom) :
HGCalTriggerFECodecBase(conf, geom),
Codec(const edm::ParameterSet& conf) :
HGCalTriggerFECodecBase(conf),
dataIsSet_(false) {
}

Expand Down Expand Up @@ -143,6 +144,6 @@ namespace HGCalTriggerFE {
}

#include "FWCore/PluginManager/interface/PluginFactory.h"
typedef edmplugin::PluginFactory< HGCalTriggerFECodecBase* (const edm::ParameterSet&, const HGCalTriggerGeometryBase* const) > HGCalTriggerFECodecFactory;
typedef edmplugin::PluginFactory< HGCalTriggerFECodecBase* (const edm::ParameterSet&) > HGCalTriggerFECodecFactory;

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class HGCal64BitRandomCodec : public HGCalTriggerFE::Codec<HGCal64BitRandomCodec
public:
typedef HGCal64BitRandomDataPayload data_type;

HGCal64BitRandomCodec(const edm::ParameterSet& conf, const HGCalTriggerGeometryBase* const geom) :
Codec(conf,geom),
HGCal64BitRandomCodec(const edm::ParameterSet& conf) :
Codec(conf),
codecImpl_(conf) {
data_.payload = std::numeric_limits<uint64_t>::max();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class HGCalBestChoiceCodec : public HGCalTriggerFE::Codec<HGCalBestChoiceCodec,H
public:
typedef HGCalBestChoiceDataPayload data_type;

HGCalBestChoiceCodec(const edm::ParameterSet& conf, const HGCalTriggerGeometryBase* const geom);
HGCalBestChoiceCodec(const edm::ParameterSet& conf);

void setDataPayloadImpl(const HGCEEDigiCollection& ee,
const HGCHEDigiCollection& fh,
Expand Down
27 changes: 6 additions & 21 deletions L1Trigger/L1THGCal/plugins/HGCalTriggerDigiFEReproducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class HGCalTriggerDigiFEReproducer : public edm::EDProducer
private:
// inputs
edm::EDGetToken inputdigi_;
edm::ESHandle<HGCalTriggerGeometryBase> triggerGeometry_;
// algorithm containers
std::unique_ptr<HGCalTriggerGeometryBase> triggerGeometry_;
std::unique_ptr<HGCalTriggerFECodecBase> codec_;
std::unique_ptr<HGCalTriggerBackendProcessor> backEndProcessor_;
};
Expand All @@ -41,22 +41,16 @@ HGCalTriggerDigiFEReproducer::HGCalTriggerDigiFEReproducer(const edm::ParameterS
inputdigi_(consumes<l1t::HGCFETriggerDigiCollection>(conf.getParameter<edm::InputTag>("feDigis")))
/*****************************************************************/
{
//setup geometry configuration
const edm::ParameterSet& geometryConfig = conf.getParameterSet("TriggerGeometry");
const std::string& trigGeomName = geometryConfig.getParameter<std::string>("TriggerGeometryName");
HGCalTriggerGeometryBase* geometry = HGCalTriggerGeometryFactory::get()->create(trigGeomName,geometryConfig);
triggerGeometry_.reset(geometry);

//setup FE codec
const edm::ParameterSet& feCodecConfig = conf.getParameterSet("FECodec");
const std::string& feCodecName = feCodecConfig.getParameter<std::string>("CodecName");
HGCalTriggerFECodecBase* codec = HGCalTriggerFECodecFactory::get()->create(feCodecName,feCodecConfig,triggerGeometry_.get());
HGCalTriggerFECodecBase* codec = HGCalTriggerFECodecFactory::get()->create(feCodecName,feCodecConfig);
codec_.reset(codec);
codec_->unSetDataPayload();

produces<l1t::HGCFETriggerDigiCollection>();
//setup BE processor
backEndProcessor_ = std::make_unique<HGCalTriggerBackendProcessor>(conf.getParameterSet("BEConfiguration"), triggerGeometry_.get());
backEndProcessor_ = std::make_unique<HGCalTriggerBackendProcessor>(conf.getParameterSet("BEConfiguration"));
// register backend processor products
backEndProcessor_->setProduces(*this);
}
Expand All @@ -65,18 +59,9 @@ HGCalTriggerDigiFEReproducer::HGCalTriggerDigiFEReproducer(const edm::ParameterS
void HGCalTriggerDigiFEReproducer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es)
/*****************************************************************/
{
triggerGeometry_->reset();
HGCalTriggerGeometryBase::es_info info;
const std::string& ee_sd_name = triggerGeometry_->eeSDName();
const std::string& fh_sd_name = triggerGeometry_->fhSDName();
const std::string& bh_sd_name = triggerGeometry_->bhSDName();
es.get<IdealGeometryRecord>().get(ee_sd_name,info.geom_ee);
es.get<IdealGeometryRecord>().get(fh_sd_name,info.geom_fh);
es.get<IdealGeometryRecord>().get(bh_sd_name,info.geom_bh);
es.get<IdealGeometryRecord>().get(ee_sd_name,info.topo_ee);
es.get<IdealGeometryRecord>().get(fh_sd_name,info.topo_fh);
es.get<IdealGeometryRecord>().get(bh_sd_name,info.topo_bh);
triggerGeometry_->initialize(info);
es.get<IdealGeometryRecord>().get(triggerGeometry_);
codec_->setGeometry(triggerGeometry_.product());
backEndProcessor_->setGeometry(triggerGeometry_.product());
}

/*****************************************************************/
Expand Down
30 changes: 7 additions & 23 deletions L1Trigger/L1THGCal/plugins/HGCalTriggerDigiProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class HGCalTriggerDigiProducer : public edm::EDProducer {
private:
// inputs
edm::EDGetToken inputee_, inputfh_, inputbh_;
edm::ESHandle<HGCalTriggerGeometryBase> triggerGeometry_;
// algorithm containers
std::unique_ptr<HGCalTriggerGeometryBase> triggerGeometry_;
std::unique_ptr<HGCalTriggerFECodecBase> codec_;
std::unique_ptr<HGCalTriggerBackendProcessor> backEndProcessor_;
};
Expand All @@ -42,46 +42,30 @@ HGCalTriggerDigiProducer(const edm::ParameterSet& conf):
//inputbh_(consumes<HGCHEDigiCollection>(conf.getParameter<edm::InputTag>("bhDigis")))
{

//setup geometry configuration
const edm::ParameterSet& geometryConfig =
conf.getParameterSet("TriggerGeometry");
const std::string& trigGeomName =
geometryConfig.getParameter<std::string>("TriggerGeometryName");
HGCalTriggerGeometryBase* geometry =
HGCalTriggerGeometryFactory::get()->create(trigGeomName,geometryConfig);
triggerGeometry_.reset(geometry);

//setup FE codec
const edm::ParameterSet& feCodecConfig =
conf.getParameterSet("FECodec");
const std::string& feCodecName =
feCodecConfig.getParameter<std::string>("CodecName");
HGCalTriggerFECodecBase* codec =
HGCalTriggerFECodecFactory::get()->create(feCodecName,feCodecConfig,triggerGeometry_.get());
HGCalTriggerFECodecFactory::get()->create(feCodecName,feCodecConfig);
codec_.reset(codec);
codec_->unSetDataPayload();

produces<l1t::HGCFETriggerDigiCollection>();
//setup BE processor
backEndProcessor_ = std::make_unique<HGCalTriggerBackendProcessor>(conf.getParameterSet("BEConfiguration"), triggerGeometry_.get());
backEndProcessor_ = std::make_unique<HGCalTriggerBackendProcessor>(conf.getParameterSet("BEConfiguration"));
// register backend processor products
backEndProcessor_->setProduces(*this);
}

void HGCalTriggerDigiProducer::beginRun(const edm::Run& /*run*/,
const edm::EventSetup& es) {
triggerGeometry_->reset();
HGCalTriggerGeometryBase::es_info info;
const std::string& ee_sd_name = triggerGeometry_->eeSDName();
const std::string& fh_sd_name = triggerGeometry_->fhSDName();
const std::string& bh_sd_name = triggerGeometry_->bhSDName();
es.get<IdealGeometryRecord>().get(ee_sd_name,info.geom_ee);
es.get<IdealGeometryRecord>().get(fh_sd_name,info.geom_fh);
es.get<IdealGeometryRecord>().get(bh_sd_name,info.geom_bh);
es.get<IdealGeometryRecord>().get(ee_sd_name,info.topo_ee);
es.get<IdealGeometryRecord>().get(fh_sd_name,info.topo_fh);
es.get<IdealGeometryRecord>().get(bh_sd_name,info.topo_bh);
triggerGeometry_->initialize(info);
es.get<IdealGeometryRecord>().get(triggerGeometry_);
codec_->setGeometry(triggerGeometry_.product());
backEndProcessor_->setGeometry(triggerGeometry_.product());

}

void HGCalTriggerDigiProducer::produce(edm::Event& e, const edm::EventSetup& es) {
Expand Down
67 changes: 67 additions & 0 deletions L1Trigger/L1THGCal/plugins/HGCalTriggerGeometryESProducer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

#include <memory>

#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/Framework/interface/ESProducer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ESProducts.h"

#include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"

class HGCalTriggerGeometryESProducer : public edm::ESProducer
{
public:
HGCalTriggerGeometryESProducer(const edm::ParameterSet&);
~HGCalTriggerGeometryESProducer();

typedef std::unique_ptr<HGCalTriggerGeometryBase> ReturnType;

ReturnType produce(const IdealGeometryRecord&);

private:
edm::ParameterSet geometry_config_;
std::string geometry_name_;
};

HGCalTriggerGeometryESProducer::
HGCalTriggerGeometryESProducer(const edm::ParameterSet& iConfig):
geometry_config_(iConfig.getParameterSet("TriggerGeometry")),
geometry_name_(geometry_config_.getParameter<std::string>("TriggerGeometryName"))
{
setWhatProduced(this);
}


HGCalTriggerGeometryESProducer::
~HGCalTriggerGeometryESProducer()
{

// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)

}

HGCalTriggerGeometryESProducer::ReturnType
HGCalTriggerGeometryESProducer::
produce(const IdealGeometryRecord& iRecord)
{
//using namespace edm::es;
ReturnType geometry(HGCalTriggerGeometryFactory::get()->create(geometry_name_,geometry_config_));
geometry->reset();
HGCalTriggerGeometryBase::es_info info;
const std::string& ee_sd_name = geometry->eeSDName();
const std::string& fh_sd_name = geometry->fhSDName();
const std::string& bh_sd_name = geometry->bhSDName();
iRecord.get(ee_sd_name, info.geom_ee);
iRecord.get(fh_sd_name, info.geom_fh);
iRecord.get(bh_sd_name, info.geom_bh);
iRecord.get(ee_sd_name, info.topo_ee);
iRecord.get(fh_sd_name, info.topo_fh);
iRecord.get(bh_sd_name, info.topo_bh);
geometry->initialize(info);
return geometry;

}

//define this as a plug-in
DEFINE_FWK_EVENTSETUP_MODULE(HGCalTriggerGeometryESProducer);
4 changes: 2 additions & 2 deletions L1Trigger/L1THGCal/plugins/be_algorithms/FullModuleSumAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class FullModuleSumAlgo : public Algorithm<HGCalBestChoiceCodec>
{
public:

FullModuleSumAlgo(const edm::ParameterSet& conf, const HGCalTriggerGeometryBase* const geom):
Algorithm<HGCalBestChoiceCodec>(conf,geom),
FullModuleSumAlgo(const edm::ParameterSet& conf):
Algorithm<HGCalBestChoiceCodec>(conf),
cluster_product_( new l1t::HGCalClusterBxCollection ){}

virtual void setProduces(edm::EDProducer& prod) const override final
Expand Down
4 changes: 2 additions & 2 deletions L1Trigger/L1THGCal/plugins/be_algorithms/RandomClusterAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ using namespace HGCalTriggerBackend;
class RandomClusterAlgo : public Algorithm<HGCal64BitRandomCodec> {
public:

RandomClusterAlgo(const edm::ParameterSet& conf, const HGCalTriggerGeometryBase* const geom):
Algorithm<HGCal64BitRandomCodec>(conf,geom),
RandomClusterAlgo(const edm::ParameterSet& conf):
Algorithm<HGCal64BitRandomCodec>(conf),
cluster_product_( new l1t::HGCalClusterBxCollection ){
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class SingleCellClusterAlgo : public Algorithm<HGCalBestChoiceCodec>
{
public:

SingleCellClusterAlgo(const edm::ParameterSet& conf, const HGCalTriggerGeometryBase* const geom):
Algorithm<HGCalBestChoiceCodec>(conf,geom),
SingleCellClusterAlgo(const edm::ParameterSet& conf):
Algorithm<HGCalBestChoiceCodec>(conf),
cluster_product_( new l1t::HGCalClusterBxCollection ){}

virtual void setProduces(edm::EDProducer& prod) const override final
Expand Down
5 changes: 3 additions & 2 deletions L1Trigger/L1THGCal/plugins/fe_codecs/HGCalBestChoiceCodec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ DEFINE_EDM_PLUGIN(HGCalTriggerFECodecFactory,
"HGCalBestChoiceCodec");

/*****************************************************************/
HGCalBestChoiceCodec::HGCalBestChoiceCodec(const edm::ParameterSet& conf, const HGCalTriggerGeometryBase* const geom) : Codec(conf,geom),
HGCalBestChoiceCodec::HGCalBestChoiceCodec(const edm::ParameterSet& conf) : Codec(conf),
codecImpl_(conf)
/*****************************************************************/
{
Expand Down Expand Up @@ -79,7 +79,8 @@ void HGCalBestChoiceCodec::setDataPayloadImpl(const l1t::HGCFETriggerDigi& digi)
conf.addParameter<uint32_t> ("tdcnBits", codecImpl_.tdcnBits());
conf.addParameter<double> ("tdcOnsetfC", codecImpl_.tdcOnsetfC());
conf.addParameter<uint32_t> ("triggerCellTruncationBits", codecImpl_.triggerCellTruncationBits());
HGCalBestChoiceCodec codecInput(conf, geometry_);
HGCalBestChoiceCodec codecInput(conf);
codecInput.setGeometry(geometry_);
digi.decode(codecInput,data_);
// choose best trigger cells in the module
codecImpl_.bestChoiceSelect(data_);
Expand Down
15 changes: 15 additions & 0 deletions L1Trigger/L1THGCal/python/hgcalTriggerGeometryESProducer_cfi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import FWCore.ParameterSet.Config as cms


geometry = cms.PSet( TriggerGeometryName = cms.string('HGCalTriggerGeometryHexImp2'),
L1TCellsMapping = cms.FileInPath("L1Trigger/L1THGCal/data/triggercell_mapping.txt"),
L1TModulesMapping = cms.FileInPath("L1Trigger/L1THGCal/data/module_mapping.txt"),
eeSDName = cms.string('HGCalEESensitive'),
fhSDName = cms.string('HGCalHESiliconSensitive'),
bhSDName = cms.string('HGCalHEScintillatorSensitive'),
)

hgcalTriggerGeometryESProducer = cms.ESProducer(
'HGCalTriggerGeometryESProducer',
TriggerGeometry = geometry
)
Loading

0 comments on commit 4388162

Please sign in to comment.