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

[HGC trigger] FE customization, OOT subtraction, separate HFNose sequence #29762

Merged
merged 5 commits into from
May 17, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
7 changes: 7 additions & 0 deletions L1Trigger/L1THGCal/interface/HGCalTriggerTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ class HGCalTriggerTools {

static constexpr unsigned kScintillatorPseudoThicknessIndex_ = 3;

enum SubDetectorType {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems redundant with the enums already defined in https://github.com/cms-sw/cmssw/blob/master/DataFormats/ForwardDetId/interface/ForwardSubdetector.h. Is there a reason for it to be separate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case the enum values are used to index vectors. So we need values 0,1,2. The information encoded here is indeed redundant with enums in ForwardSubdetector.h, but we would need to manipulate them further if ForwardSubdetector or HGCalTriggerSubdetector were used.

hgcal_silicon_CEE,
hgcal_silicon_CEH,
hgcal_scintillator,
};
SubDetectorType getSubDetectorType(const DetId& id) const;

private:
const HGCalTriggerGeometryBase* geom_;
unsigned eeLayers_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class HGCalConcentratorProcessorSelection : public HGCalConcentratorProcessorBase {
private:
enum SelectionType { thresholdSelect, bestChoiceSelect, superTriggerCellSelect, mixedBestChoiceSuperTriggerCell };
enum SelectionType { thresholdSelect, bestChoiceSelect, superTriggerCellSelect, noSelection };

public:
HGCalConcentratorProcessorSelection(const edm::ParameterSet& conf);
Expand All @@ -23,10 +23,12 @@ class HGCalConcentratorProcessorSelection : public HGCalConcentratorProcessorBas
const edm::EventSetup& es) override;

private:
SelectionType selectionType_;
bool fixedDataSizePerHGCROC_;
bool coarsenTriggerCells_;
std::vector<unsigned> coarsenTriggerCells_;
static constexpr int kHighDensityThickness_ = 0;
static constexpr int kNSubDetectors_ = 3;

std::vector<SelectionType> selectionType_;

std::unique_ptr<HGCalConcentratorThresholdImpl> thresholdImpl_;
std::unique_ptr<HGCalConcentratorBestChoiceImpl> bestChoiceImpl_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ class HGCalConcentratorSuperTriggerCellImpl {
oneBitFraction,
equalShare,
};

EnergyDivisionType energyDivisionType_;
static constexpr int kHighDensityThickness_ = 0;
static constexpr int kOddNumberMask_ = 1;

HGCalTriggerTools triggerTools_;
bool fixedDataSizePerHGCROC_;
bool coarsenTriggerCells_;
std::vector<unsigned> coarsenTriggerCells_;
HGCalCoarseTriggerCellMapping coarseTCmapping_;
HGCalCoarseTriggerCellMapping superTCmapping_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class HGCalVFELinearizationImpl {
//
uint32_t linMax_;
uint32_t linnBits_;
std::vector<double> oot_coefficients_;
};

#endif
71 changes: 71 additions & 0 deletions L1Trigger/L1THGCal/plugins/HFNoseVFEProducer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "DataFormats/HGCDigi/interface/HGCDigiCollections.h"
#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h"
#include "DataFormats/L1THGCal/interface/HGCalTriggerSums.h"

#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"

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

#include <memory>

class HFNoseVFEProducer : public edm::stream::EDProducer<> {
public:
HFNoseVFEProducer(const edm::ParameterSet&);
~HFNoseVFEProducer() override {}

void beginRun(const edm::Run&, const edm::EventSetup&) override;
void produce(edm::Event&, const edm::EventSetup&) override;

private:
// inputs
edm::EDGetToken inputnose_;
edm::ESHandle<HGCalTriggerGeometryBase> triggerGeometry_;

std::unique_ptr<HGCalVFEProcessorBase> vfeProcess_;
};

DEFINE_FWK_MODULE(HFNoseVFEProducer);

HFNoseVFEProducer::HFNoseVFEProducer(const edm::ParameterSet& conf)
: inputnose_(consumes<HGCalDigiCollection>(conf.getParameter<edm::InputTag>("noseDigis"))) {
// setup VFE parameters
const edm::ParameterSet& vfeParamConfig = conf.getParameterSet("ProcessorParameters");
const std::string& vfeProcessorName = vfeParamConfig.getParameter<std::string>("ProcessorName");
vfeProcess_ = std::unique_ptr<HGCalVFEProcessorBase>{
HGCalVFEProcessorBaseFactory::get()->create(vfeProcessorName, vfeParamConfig)};

produces<l1t::HGCalTriggerCellBxCollection>(vfeProcess_->name());
produces<l1t::HGCalTriggerSumsBxCollection>(vfeProcess_->name());
}

void HFNoseVFEProducer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) {
es.get<CaloGeometryRecord>().get(triggerGeometry_);
vfeProcess_->setGeometry(triggerGeometry_.product());
}

void HFNoseVFEProducer::produce(edm::Event& e, const edm::EventSetup& es) {
// Output collections
auto vfe_trigcell_output = std::make_unique<l1t::HGCalTriggerCellBxCollection>();
auto vfe_trigsums_output = std::make_unique<l1t::HGCalTriggerSumsBxCollection>();

edm::Handle<HGCalDigiCollection> nose_digis_h;
e.getByToken(inputnose_, nose_digis_h);

if (nose_digis_h.isValid()) {
const HGCalDigiCollection& nose_digis = *nose_digis_h;
vfeProcess_->run(nose_digis, *vfe_trigcell_output, es);
}

// Put in the event
e.put(std::move(vfe_trigcell_output), vfeProcess_->name());
// At the moment the HGCalTriggerSumsBxCollection is empty
e.put(std::move(vfe_trigsums_output), vfeProcess_->name());
}
30 changes: 14 additions & 16 deletions L1Trigger/L1THGCal/plugins/HGCalVFEProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class HGCalVFEProducer : public edm::stream::EDProducer<> {

private:
// inputs
edm::EDGetToken inputee_, inputfh_, inputbh_, inputnose_;
edm::EDGetToken inputee_, inputfh_, inputbh_;
edm::ESHandle<HGCalTriggerGeometryBase> triggerGeometry_;

std::unique_ptr<HGCalVFEProcessorBase> vfeProcess_;
Expand All @@ -37,8 +37,7 @@ DEFINE_FWK_MODULE(HGCalVFEProducer);
HGCalVFEProducer::HGCalVFEProducer(const edm::ParameterSet& conf)
: inputee_(consumes<HGCalDigiCollection>(conf.getParameter<edm::InputTag>("eeDigis"))),
inputfh_(consumes<HGCalDigiCollection>(conf.getParameter<edm::InputTag>("fhDigis"))),
inputbh_(consumes<HGCalDigiCollection>(conf.getParameter<edm::InputTag>("bhDigis"))),
inputnose_(consumes<HGCalDigiCollection>(conf.getParameter<edm::InputTag>("noseDigis"))) {
inputbh_(consumes<HGCalDigiCollection>(conf.getParameter<edm::InputTag>("bhDigis"))) {
// setup VFE parameters
const edm::ParameterSet& vfeParamConfig = conf.getParameterSet("ProcessorParameters");
const std::string& vfeProcessorName = vfeParamConfig.getParameter<std::string>("ProcessorName");
Expand Down Expand Up @@ -68,21 +67,20 @@ void HGCalVFEProducer::produce(edm::Event& e, const edm::EventSetup& es) {
e.getByToken(inputfh_, fh_digis_h);
e.getByToken(inputbh_, bh_digis_h);

const HGCalDigiCollection& ee_digis = *ee_digis_h;
const HGCalDigiCollection& fh_digis = *fh_digis_h;
const HGCalDigiCollection& bh_digis = *bh_digis_h;

// Processing DigiCollections and putting the results into the HGCalTriggerCellBxCollection
vfeProcess_->run(ee_digis, *vfe_trigcell_output, es);
vfeProcess_->run(fh_digis, *vfe_trigcell_output, es);
vfeProcess_->run(bh_digis, *vfe_trigcell_output, es);
// Processing DigiCollections and putting the results into the HGCalTriggerCellBxCollectio
if (ee_digis_h.isValid()) {
const HGCalDigiCollection& ee_digis = *ee_digis_h;
vfeProcess_->run(ee_digis, *vfe_trigcell_output, es);
}

edm::Handle<HGCalDigiCollection> nose_digis_h;
e.getByToken(inputnose_, nose_digis_h);
if (fh_digis_h.isValid()) {
const HGCalDigiCollection& fh_digis = *fh_digis_h;
vfeProcess_->run(fh_digis, *vfe_trigcell_output, es);
}

if (nose_digis_h.isValid()) {
const HGCalDigiCollection& nose_digis = *nose_digis_h;
vfeProcess_->run(nose_digis, *vfe_trigcell_output, es);
if (bh_digis_h.isValid()) {
const HGCalDigiCollection& bh_digis = *bh_digis_h;
vfeProcess_->run(bh_digis, *vfe_trigcell_output, es);
}

// Put in the event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,37 @@ DEFINE_EDM_PLUGIN(HGCalConcentratorFactory, HGCalConcentratorProcessorSelection,
HGCalConcentratorProcessorSelection::HGCalConcentratorProcessorSelection(const edm::ParameterSet& conf)
: HGCalConcentratorProcessorBase(conf),
fixedDataSizePerHGCROC_(conf.getParameter<bool>("fixedDataSizePerHGCROC")),
coarsenTriggerCells_(conf.getParameter<bool>("coarsenTriggerCells")) {
std::string selectionType(conf.getParameter<std::string>("Method"));
if (selectionType == "thresholdSelect") {
selectionType_ = thresholdSelect;
thresholdImpl_ = std::make_unique<HGCalConcentratorThresholdImpl>(conf);
} else if (selectionType == "bestChoiceSelect") {
selectionType_ = bestChoiceSelect;
bestChoiceImpl_ = std::make_unique<HGCalConcentratorBestChoiceImpl>(conf);
} else if (selectionType == "superTriggerCellSelect") {
selectionType_ = superTriggerCellSelect;
superTriggerCellImpl_ = std::make_unique<HGCalConcentratorSuperTriggerCellImpl>(conf);
} else if (selectionType == "mixedBestChoiceSuperTriggerCell") {
selectionType_ = mixedBestChoiceSuperTriggerCell;
bestChoiceImpl_ = std::make_unique<HGCalConcentratorBestChoiceImpl>(conf);
superTriggerCellImpl_ = std::make_unique<HGCalConcentratorSuperTriggerCellImpl>(conf);
} else {
coarsenTriggerCells_(conf.getParameter<std::vector<unsigned>>("coarsenTriggerCells")),
selectionType_(kNSubDetectors_) {
std::vector<std::string> selectionType(conf.getParameter<std::vector<std::string>>("Method"));
if (selectionType.size() != kNSubDetectors_ || coarsenTriggerCells_.size() != kNSubDetectors_) {
throw cms::Exception("HGCTriggerParameterError")
<< "Unknown type of concentrator selection '" << selectionType << "'";
<< "Inconsistent number of sub-detectors (should be " << kNSubDetectors_ << ")";
}

if (coarsenTriggerCells_ || fixedDataSizePerHGCROC_) {
for (int subdet = 0; subdet < kNSubDetectors_; subdet++) {
if (selectionType[subdet] == "thresholdSelect") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these cases become a factory (as some other trigger algorithms are already)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am planning to make a global refactoring of the code in the near future. And definitely something should be done to better manage all the different types of algorithms we have in various places.

selectionType_[subdet] = thresholdSelect;
if (!thresholdImpl_)
thresholdImpl_ = std::make_unique<HGCalConcentratorThresholdImpl>(conf);
} else if (selectionType[subdet] == "bestChoiceSelect") {
selectionType_[subdet] = bestChoiceSelect;
if (!bestChoiceImpl_)
bestChoiceImpl_ = std::make_unique<HGCalConcentratorBestChoiceImpl>(conf);
} else if (selectionType[subdet] == "superTriggerCellSelect") {
selectionType_[subdet] = superTriggerCellSelect;
if (!superTriggerCellImpl_)
superTriggerCellImpl_ = std::make_unique<HGCalConcentratorSuperTriggerCellImpl>(conf);
} else if (selectionType[subdet] == "noSelection") {
selectionType_[subdet] = noSelection;
} else {
throw cms::Exception("HGCTriggerParameterError")
<< "Unknown type of concentrator selection '" << selectionType[subdet] << "'";
}
}

if (std::find(coarsenTriggerCells_.begin(), coarsenTriggerCells_.end(), true) != coarsenTriggerCells_.end() ||
fixedDataSizePerHGCROC_) {
coarsenerImpl_ = std::make_unique<HGCalConcentratorCoarsenerImpl>(conf);
}
}
Expand Down Expand Up @@ -60,10 +70,12 @@ void HGCalConcentratorProcessorSelection::run(const edm::Handle<l1t::HGCalTrigge

int thickness = triggerTools_.thicknessIndex(module_trigcell.second.at(0).detId(), true);

if (coarsenTriggerCells_ || (fixedDataSizePerHGCROC_ && thickness > kHighDensityThickness_)) {
HGCalTriggerTools::SubDetectorType subdet = triggerTools_.getSubDetectorType(module_trigcell.second.at(0).detId());

if (coarsenTriggerCells_[subdet] || (fixedDataSizePerHGCROC_ && thickness > kHighDensityThickness_)) {
coarsenerImpl_->coarsen(module_trigcell.second, trigCellVecCoarsened);

switch (selectionType_) {
switch (selectionType_[subdet]) {
case thresholdSelect:
thresholdImpl_->select(trigCellVecCoarsened, trigCellVecOutput);
break;
Expand All @@ -83,23 +95,16 @@ void HGCalConcentratorProcessorSelection::run(const edm::Handle<l1t::HGCalTrigge
case superTriggerCellSelect:
superTriggerCellImpl_->select(trigCellVecCoarsened, trigCellVecOutput);
break;
case mixedBestChoiceSuperTriggerCell:
if (triggerTools_.isEm(module_trigcell.first)) {
bestChoiceImpl_->select(geometry_->getLinksInModule(module_trigcell.first),
geometry_->getModuleSize(module_trigcell.first),
trigCellVecCoarsened,
trigCellVecOutput);
} else {
superTriggerCellImpl_->select(trigCellVecCoarsened, trigCellVecOutput);
}
case noSelection:
trigCellVecOutput = trigCellVecCoarsened;
break;
default:
// Should not happen, selection type checked in constructor
break;
}

} else {
switch (selectionType_) {
switch (selectionType_[subdet]) {
case thresholdSelect:
thresholdImpl_->select(module_trigcell.second, trigCellVecOutput);
break;
Expand All @@ -112,15 +117,8 @@ void HGCalConcentratorProcessorSelection::run(const edm::Handle<l1t::HGCalTrigge
case superTriggerCellSelect:
superTriggerCellImpl_->select(module_trigcell.second, trigCellVecOutput);
break;
case mixedBestChoiceSuperTriggerCell:
if (triggerTools_.isEm(module_trigcell.first)) {
bestChoiceImpl_->select(geometry_->getLinksInModule(module_trigcell.first),
geometry_->getModuleSize(module_trigcell.first),
module_trigcell.second,
trigCellVecOutput);
} else {
superTriggerCellImpl_->select(module_trigcell.second, trigCellVecOutput);
}
case noSelection:
trigCellVecOutput = module_trigcell.second;
break;
default:
// Should not happen, selection type checked in constructor
Expand Down
21 changes: 11 additions & 10 deletions L1Trigger/L1THGCal/python/customTriggerCellSelect.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import FWCore.ParameterSet.Config as cms
import SimCalorimetry.HGCalSimProducers.hgcalDigitizer_cfi as digiparam
from L1Trigger.L1THGCal.hgcalConcentratorProducer_cfi import threshold_conc_proc, best_conc_proc, supertc_conc_proc, coarsetc_onebitfraction_proc, coarsetc_equalshare_proc, bestchoice_ndata_decentralized, mixedbcstc_conc_proc
from L1Trigger.L1THGCal.hgcalConcentratorProducer_cfi import threshold_conc_proc, best_conc_proc, supertc_conc_proc, coarsetc_onebitfraction_proc, coarsetc_equalshare_proc, bestchoice_ndata_decentralized, custom_conc_proc

def custom_triggercellselect_supertriggercell(process,
stcSize=supertc_conc_proc.stcSize,
Expand Down Expand Up @@ -73,16 +73,17 @@ def custom_coarsetc_equalshare(process,
return process

def custom_triggercellselect_mixedBestChoiceSuperTriggerCell(process,
stcSize=mixedbcstc_conc_proc.stcSize,
type_energy_division=mixedbcstc_conc_proc.type_energy_division,
fixedDataSizePerHGCROC=mixedbcstc_conc_proc.fixedDataSizePerHGCROC,
triggercells=mixedbcstc_conc_proc.NData
stcSize=custom_conc_proc.stcSize,
type_energy_division=custom_conc_proc.type_energy_division,
fixedDataSizePerHGCROC=custom_conc_proc.fixedDataSizePerHGCROC,
triggercells=custom_conc_proc.NData
):
parameters = mixedbcstc_conc_proc.clone(stcSize = stcSize,
type_energy_division = type_energy_division,
fixedDataSizePerHGCROC = fixedDataSizePerHGCROC,
NData=triggercells
)
parameters = custom_conc_proc.clone(stcSize = stcSize,
type_energy_division = type_energy_division,
fixedDataSizePerHGCROC = fixedDataSizePerHGCROC,
NData=triggercells,
Method = cms.vstring('bestChoiceSelect','superTriggerCellSelect','superTriggerCellSelect'),
)
process.hgcalConcentratorProducer.ProcessorParameters = parameters
return process

Expand Down
10 changes: 10 additions & 0 deletions L1Trigger/L1THGCal/python/customVFE.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import FWCore.ParameterSet.Config as cms
import SimCalorimetry.HGCalSimProducers.hgcalDigitizer_cfi as digiparam
from L1Trigger.L1THGCal.hgcalVFEProducer_cfi import vfe_proc

def custom_hgcroc_oot(process,
oot_coefficients=vfe_proc.oot_coefficients
):
parameters = vfe_proc.clone(oot_coefficients = oot_coefficients)
process.hgcalVFEProducer.ProcessorParameters = parameters
return process
3 changes: 3 additions & 0 deletions L1Trigger/L1THGCal/python/hgcalBackEndLayer1Producer_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@
InputTriggerCells = cms.InputTag('hgcalConcentratorProducer:HGCalConcentratorProcessorSelection'),
ProcessorParameters = be_proc.clone()
)

hgcalBackEndLayer1ProducerHFNose = hgcalBackEndLayer1Producer.clone()
hgcalBackEndLayer1ProducerHFNose.InputTriggerCells = cms.InputTag('hgcalConcentratorProducerHFNose:HGCalConcentratorProcessorSelection')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make parameter changes inside clone() statement

2 changes: 2 additions & 0 deletions L1Trigger/L1THGCal/python/hgcalBackEndLayer1_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@

hgcalBackEndLayer1 = cms.Task(hgcalBackEndLayer1Producer)

hgcalBackEndLayer1HFNose = cms.Task(hgcalBackEndLayer1ProducerHFNose)

Loading