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

Tower update: include all TCs into TSs #463

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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class HGCalConcentratorProcessorSelection : public HGCalConcentratorProcessorBas

private:
bool fixedDataSizePerHGCROC_;
bool allTrigCellsInTrigSums_;
std::vector<unsigned> coarsenTriggerCells_;
static constexpr int kHighDensityThickness_ = 0;
static constexpr int kNSubDetectors_ = 3;
Expand Down
43 changes: 25 additions & 18 deletions L1Trigger/L1THGCal/plugins/backend/HGCalTowerProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class HGCalTowerProcessor : public HGCalTowerProcessorBase {
public:
HGCalTowerProcessor(const edm::ParameterSet& conf) : HGCalTowerProcessorBase(conf) {
includeTrigCells_ = conf.getParameter<bool>("includeTrigCells"),
towermap2D_ = std::make_unique<HGCalTowerMap2DImpl>(conf.getParameterSet("towermap_parameters"));
towermap3D_ = std::make_unique<HGCalTowerMap3DImpl>();
}
Expand All @@ -33,33 +34,39 @@ class HGCalTowerProcessor : public HGCalTowerProcessorBase {
towerMapsPtrs.emplace_back(towerMapCollHandle, i);
}

/* create additional TowerMaps from the unclustered TCs */
if (includeTrigCells_) {
/* create additional TowerMaps from the unclustered TCs */

// translate our HGCalClusters into HGCalTriggerCells
std::vector<edm::Ptr<l1t::HGCalTriggerCell>> trigCellVec;
for (unsigned i = 0; i < unclTCsCollHandle->size(); ++i) {
edm::Ptr<l1t::HGCalCluster> ptr(unclTCsCollHandle, i);
for (const auto& itTC : ptr->constituents()) {
trigCellVec.push_back(itTC.second);
// translate our HGCalClusters into HGCalTriggerCells
std::vector<edm::Ptr<l1t::HGCalTriggerCell>> trigCellVec;
for (unsigned i = 0; i < unclTCsCollHandle->size(); ++i) {
edm::Ptr<l1t::HGCalCluster> ptr(unclTCsCollHandle, i);
for (const auto& itTC : ptr->constituents()) {
trigCellVec.push_back(itTC.second);
}
}
}

// fill the TowerMaps with the HGCalTriggersCells
l1t::HGCalTowerMapBxCollection towerMapsFromUnclTCs;
towermap2D_->buildTowerMap2D(trigCellVec, towerMapsFromUnclTCs);
// fill the TowerMaps with the HGCalTriggersCells
l1t::HGCalTowerMapBxCollection towerMapsFromUnclTCs;
towermap2D_->buildTowerMap2D(trigCellVec, towerMapsFromUnclTCs);

/* merge the two sets of TowerMaps */
unsigned int towerMapsPtrsSize = towerMapsPtrs.size();
for (unsigned int i = 0; i < towerMapsFromUnclTCs.size(); ++i) {
towerMapsPtrs.emplace_back(&(towerMapsFromUnclTCs[i]), i + towerMapsPtrsSize);
}
/* merge the two sets of TowerMaps */
unsigned int towerMapsPtrsSize = towerMapsPtrs.size();
for (unsigned int i = 0; i < towerMapsFromUnclTCs.size(); ++i) {
towerMapsPtrs.emplace_back(&(towerMapsFromUnclTCs[i]), i + towerMapsPtrsSize);
}

/* call to towerMap3D clustering */
towermap3D_->buildTowerMap3D(towerMapsPtrs, collTowers);
/* call to towerMap3D clustering */
towermap3D_->buildTowerMap3D(towerMapsPtrs, collTowers);
} else {
/* call to towerMap3D clustering */
towermap3D_->buildTowerMap3D(towerMapsPtrs, collTowers);
}
Comment on lines +60 to +64
Copy link

Choose a reason for hiding this comment

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

This could be simplified by removing the else and moving towermap3D_->buildTowerMap3D(towerMapsPtrs, collTowers); outside the if statement, since it is called in any case.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, this is what I had tried first. But this fails with the following error message (in the default case when partial module sums are used and the code enters the if part):

StdException HGCalTowerMap: Trying to add HGCalTowerMaps with different bins: 2592 and 0

I think this is because towerMapsFromUnclTCs only lives within the if statement now, and dies outside. What I could do, though, is construct this object outside the if statement, which would work too.

Copy link

Choose a reason for hiding this comment

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

I see. I think it is fine as it is then.

}

private:
edm::ESHandle<HGCalTriggerGeometryBase> triggerGeometry_;
bool includeTrigCells_;

/* algorithms instances */
std::unique_ptr<HGCalTowerMap2DImpl> towermap2D_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ DEFINE_EDM_PLUGIN(HGCalConcentratorFactory, HGCalConcentratorProcessorSelection,
HGCalConcentratorProcessorSelection::HGCalConcentratorProcessorSelection(const edm::ParameterSet& conf)
: HGCalConcentratorProcessorBase(conf),
fixedDataSizePerHGCROC_(conf.getParameter<bool>("fixedDataSizePerHGCROC")),
allTrigCellsInTrigSums_(conf.getParameter<bool>("allTrigCellsInTrigSums")),
coarsenTriggerCells_(conf.getParameter<std::vector<unsigned>>("coarsenTriggerCells")),
selectionType_(kNSubDetectors_) {
std::vector<std::string> selectionType(conf.getParameter<std::vector<std::string>>("Method"));
Expand Down Expand Up @@ -164,7 +165,11 @@ void HGCalConcentratorProcessorSelection::run(const edm::Handle<l1t::HGCalTrigge

// trigger sum
if (trigSumImpl_) {
trigSumImpl_->doSum(module_trigcell.first, trigCellVecNotSelected, trigSumsVecOutput);
if (allTrigCellsInTrigSums_) { // using all TCs
trigSumImpl_->doSum(module_trigcell.first, module_trigcell.second, trigSumsVecOutput);
} else { // using only unselected TCs
trigSumImpl_->doSum(module_trigcell.first, trigCellVecNotSelected, trigSumsVecOutput);
}
}

for (const auto& trigCell : trigCellVecOutput) {
Expand Down
32 changes: 32 additions & 0 deletions L1Trigger/L1THGCal/python/customTriggerSums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import FWCore.ParameterSet.Config as cms
import math

def custom_partial_trigger_sums(process):
process.tower.includeTrigCells = cms.bool(True)
process.hgcalTowerProducer.ProcessorParameters.includeTrigCells = cms.bool(True)
process.hgcalTowerProducerHFNose.ProcessorParameters.includeTrigCells = cms.bool(True)
process.threshold_conc_proc.allTrigCellsInTrigSums = cms.bool(False)
process.best_conc_proc.allTrigCellsInTrigSums = cms.bool(False)
process.supertc_conc_proc.allTrigCellsInTrigSums = cms.bool(False)
process.custom_conc_proc.allTrigCellsInTrigSums = cms.bool(False)
process.coarsetc_onebitfraction_proc.allTrigCellsInTrigSums = cms.bool(False)
process.coarsetc_equalshare_proc.allTrigCellsInTrigSums = cms.bool(False)
process.autoEncoder_conc_proc.allTrigCellsInTrigSums = cms.bool(False)
process.hgcalConcentratorProducer.ProcessorParameters.allTrigCellsInTrigSums = cms.bool(False)
process.hgcalConcentratorProducerHFNose.ProcessorParameters.allTrigCellsInTrigSums = cms.bool(False)
return process

def custom_full_trigger_sums(process):
process.tower.includeTrigCells = cms.bool(False)
process.hgcalTowerProducer.ProcessorParameters.includeTrigCells = cms.bool(False)
process.hgcalTowerProducerHFNose.ProcessorParameters.includeTrigCells = cms.bool(False)
process.threshold_conc_proc.allTrigCellsInTrigSums = cms.bool(True)
process.best_conc_proc.allTrigCellsInTrigSums = cms.bool(True)
process.supertc_conc_proc.allTrigCellsInTrigSums = cms.bool(True)
process.custom_conc_proc.allTrigCellsInTrigSums = cms.bool(True)
process.coarsetc_onebitfraction_proc.allTrigCellsInTrigSums = cms.bool(True)
process.coarsetc_equalshare_proc.allTrigCellsInTrigSums = cms.bool(True)
process.autoEncoder_conc_proc.allTrigCellsInTrigSums = cms.bool(True)
process.hgcalConcentratorProducer.ProcessorParameters.allTrigCellsInTrigSums = cms.bool(True)
process.hgcalConcentratorProducerHFNose.ProcessorParameters.allTrigCellsInTrigSums = cms.bool(True)
return process
7 changes: 7 additions & 0 deletions L1Trigger/L1THGCal/python/hgcalConcentratorProducer_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
threshold_scintillator = cms.double(2.), # MipT
coarsenTriggerCells = cms.vuint32(0,0,0),
fixedDataSizePerHGCROC = cms.bool(False),
allTrigCellsInTrigSums = cms.bool(False),
ctcSize = cms.vuint32(CTC_SIZE),
)

Expand Down Expand Up @@ -81,6 +82,7 @@
NData = cms.vuint32(bestchoice_ndata_decentralized),
coarsenTriggerCells = cms.vuint32(0,0,0),
fixedDataSizePerHGCROC = cms.bool(False),
allTrigCellsInTrigSums = cms.bool(False),
coarseTCCompression = coarseTCCompression_proc.clone(),
superTCCalibration_ee = vfe_proc.calibrationCfg_ee.clone(),
superTCCalibration_hesi = vfe_proc.calibrationCfg_hesi.clone(),
Expand All @@ -95,6 +97,7 @@
stcSize = cms.vuint32(STC_SIZE),
ctcSize = cms.vuint32(CTC_SIZE),
fixedDataSizePerHGCROC = cms.bool(False),
allTrigCellsInTrigSums = cms.bool(False),
coarsenTriggerCells = cms.vuint32(0,0,0),
superTCCompression = superTCCompression_proc.clone(),
coarseTCCompression = coarseTCCompression_proc.clone(),
Expand All @@ -111,6 +114,7 @@
threshold_scintillator = cms.double(2.), # MipT
coarsenTriggerCells = cms.vuint32(0,0,0),
fixedDataSizePerHGCROC = cms.bool(False),
allTrigCellsInTrigSums = cms.bool(False),
type_energy_division = cms.string('superTriggerCell'),# superTriggerCell,oneBitFraction,equalShare
stcSize = cms.vuint32(STC_SIZE),
ctcSize = cms.vuint32(CTC_SIZE),
Expand All @@ -129,6 +133,7 @@
stcSize = cms.vuint32([4]*(MAX_LAYERS+1)+ [8]*(MAX_LAYERS+1)*3),
ctcSize = cms.vuint32(CTC_SIZE),
fixedDataSizePerHGCROC = cms.bool(True),
allTrigCellsInTrigSums = cms.bool(False),
coarsenTriggerCells = cms.vuint32(0,0,0),
oneBitFractionThreshold = cms.double(0.125),
oneBitFractionLowValue = cms.double(0.0625),
Expand All @@ -148,6 +153,7 @@
stcSize = cms.vuint32([4]*(MAX_LAYERS+1)+ [8]*(MAX_LAYERS+1)*3),
ctcSize = cms.vuint32(CTC_SIZE),
fixedDataSizePerHGCROC = cms.bool(True),
allTrigCellsInTrigSums = cms.bool(False),
coarsenTriggerCells = cms.vuint32(0,0,0),
superTCCompression = superTCCompression_proc.clone(),
coarseTCCompression = coarseTCCompression_proc.clone(),
Expand Down Expand Up @@ -211,6 +217,7 @@
stcSize = supertc_conc_proc.stcSize,
ctcSize = supertc_conc_proc.ctcSize,
fixedDataSizePerHGCROC = supertc_conc_proc.fixedDataSizePerHGCROC,
allTrigCellsInTrigSums = supertc_conc_proc.allTrigCellsInTrigSums,
coarsenTriggerCells = supertc_conc_proc.coarsenTriggerCells,
superTCCompression = superTCCompression_proc.clone(),
coarseTCCompression = coarseTCCompression_proc.clone(),
Expand Down
1 change: 1 addition & 0 deletions L1Trigger/L1THGCal/python/hgcalTowerProducer_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import L1Trigger.L1THGCal.hgcalTowerMapProducer_cfi as hgcalTowerMapProducer_cfi

tower = cms.PSet( ProcessorName = cms.string('HGCalTowerProcessor'),
includeTrigCells = cms.bool(True),
towermap_parameters = hgcalTowerMapProducer_cfi.towerMap2D_parValues.clone()
)

Expand Down