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

Pr90x L1T Stage2 for Phase2 #17248

Merged
merged 10 commits into from Jan 31, 2017
235 changes: 115 additions & 120 deletions CalibCalorimetry/HcalTPGAlgos/src/HcaluLUTTPGCoder.cc
Expand Up @@ -238,126 +238,121 @@ void HcaluLUTTPGCoder::update(const HcalDbService& conditions) {
cosh_ieta[i] = cosh((eta1 + eta2)/2.);
}

HcalSubdetector subdets[] = {HcalBarrel, HcalEndcap, HcalForward};
for (int isub = 0; isub < 3; ++isub){
HcalSubdetector subdet = subdets[isub];
for (int ieta = -HcalDetId::kHcalEtaMask2; ieta <= HcalDetId::kHcalEtaMask2; ++ieta) {
for (int iphi = 0; iphi <= HcalDetId::kHcalPhiMask2; ++iphi) {
for (int depth = 1; depth < HcalDetId::kHcalDepthMask2; ++depth) {
HcalDetId cell(subdet, ieta, iphi, depth);
if (!topo_->valid(cell)) continue;

const HcalQIECoder* channelCoder = conditions.getHcalCoder (cell);
const HcalQIEShape* shape = conditions.getHcalShape(cell);
HcalCoderDb coder (*channelCoder, *shape);
const HcalLutMetadatum *meta = metadata->getValues(cell);

unsigned int mipMax = 0;
unsigned int mipMin = 0;

if (topo_->triggerMode() >= HcalTopologyMode::TriggerMode_2017) {
const HcalTPChannelParameter *channelParameters = conditions.getHcalTPChannelParameter(cell);
mipMax = channelParameters->getFGBitInfo() >> 16;
mipMin = channelParameters->getFGBitInfo() & 0xFFFF;
}

int lutId = getLUTId(subdet, ieta, iphi, depth);
float ped = 0;
float gain = 0;
uint32_t status = 0;

if (LUTGenerationMode_){
const HcalCalibrations& calibrations = conditions.getHcalCalibrations(cell);
for (int capId = 0; capId < 4; ++capId){
ped += calibrations.pedestal(capId);
gain += calibrations.LUTrespcorrgain(capId);
}
ped /= 4.0;
gain /= 4.0;

//Get Channel Quality
const HcalChannelStatus* channelStatus = conditions.getHcalChannelStatus(cell);
status = channelStatus->getValue();
} else {
const HcalL1TriggerObject* myL1TObj = conditions.getHcalL1TriggerObject(cell);
ped = myL1TObj->getPedestal();
gain = myL1TObj->getRespGain();
status = myL1TObj->getFlag();
} // LUTGenerationMode_

ped_[lutId] = ped;
gain_[lutId] = gain;
bool isMasked = ( (status & bitToMask_) > 0 );
float rcalib = meta->getRCalib();

// Input LUT for HB/HE/HF
if (subdet == HcalBarrel || subdet == HcalEndcap){
HBHEDataFrame frame(cell);
frame.setSize(1);
CaloSamples samples(cell, 1);

int granularity = meta->getLutGranularity();

for (unsigned int adc = 0; adc < INPUT_LUT_SIZE; ++adc) {
frame.setSample(0,HcalQIESample(adc));
coder.adc2fC(frame,samples);
float adc2fC = samples[0];

if (isMasked) inputLUT_[lutId][adc] = 0;
else inputLUT_[lutId][adc] = (LutElement) std::min(std::max(0, int((adc2fC -ped) * gain * rcalib / nominalgain_ / granularity)), QIE8_LUT_BITMASK);
}

unsigned short data[] = {0, 0, 0};
QIE11DataFrame upgradeFrame(edm::DataFrame(0, data, 3));
CaloSamples upgradeSamples(cell, 1);
for (unsigned int adc = 0; adc < UPGRADE_LUT_SIZE; ++adc) {
upgradeFrame.setSample(0, adc, 0, true);
coder.adc2fC(upgradeFrame, upgradeSamples);
float adc2fC = upgradeSamples[0];

if (isMasked) {
upgradeQIE11LUT_[lutId][adc] = 0;
} else {
upgradeQIE11LUT_[lutId][adc] = (LutElement) std::min(std::max(0, int((adc2fC -ped) * gain * rcalib / nominalgain_ / granularity)), QIE11_LUT_BITMASK);
if (adc >= mipMin and adc < mipMax)
upgradeQIE11LUT_[lutId][adc] |= QIE11_LUT_MSB0;
else if (adc >= mipMax)
upgradeQIE11LUT_[lutId][adc] |= QIE11_LUT_MSB1;
}
}
} // endif HBHE
else if (subdet == HcalForward){
HFDataFrame frame(cell);
frame.setSize(1);
CaloSamples samples(cell, 1);

for (unsigned int adc = 0; adc < INPUT_LUT_SIZE; ++adc) {
frame.setSample(0,HcalQIESample(adc));
coder.adc2fC(frame,samples);
float adc2fC = samples[0];
if (isMasked) inputLUT_[lutId][adc] = 0;
else inputLUT_[lutId][adc] = std::min(std::max(0,int((adc2fC - ped) * gain * rcalib / lsb_ / cosh_ieta[abs(ieta)] )), QIE8_LUT_BITMASK);
}

unsigned short data[] = {0, 0, 0, 0};
QIE10DataFrame upgradeFrame(edm::DataFrame(0, data, 4));
CaloSamples upgradeSamples(cell, 1);
for (unsigned int adc = 0; adc < UPGRADE_LUT_SIZE; ++adc) {
upgradeFrame.setSample(0, adc, 0, 0, 0, true);
coder.adc2fC(upgradeFrame, upgradeSamples);
float adc2fC = upgradeSamples[0];

if (isMasked)
upgradeQIE10LUT_[lutId][adc] = 0;
else
upgradeQIE10LUT_[lutId][adc] = std::min(std::max(0,int((adc2fC - ped) * gain * rcalib / lsb_ / cosh_ieta[abs(ieta)] )), QIE10_LUT_BITMASK);
}
} // endif HF

} // for depth
} // for iphi
} // for iphi
}// for subdet
for (const auto& id: metadata->getAllChannels()) {
if (not (id.det() == DetId::Hcal and topo_->valid(id)))
continue;
HcalDetId cell(id);
HcalSubdetector subdet = cell.subdet();
if (subdet != HcalBarrel and subdet != HcalEndcap and subdet != HcalForward)
continue;

const HcalQIECoder* channelCoder = conditions.getHcalCoder (cell);
const HcalQIEShape* shape = conditions.getHcalShape(cell);
HcalCoderDb coder (*channelCoder, *shape);
const HcalLutMetadatum *meta = metadata->getValues(cell);

unsigned int mipMax = 0;
unsigned int mipMin = 0;

if (topo_->triggerMode() >= HcalTopologyMode::TriggerMode_2017) {
const HcalTPChannelParameter *channelParameters = conditions.getHcalTPChannelParameter(cell);
mipMax = channelParameters->getFGBitInfo() >> 16;
mipMin = channelParameters->getFGBitInfo() & 0xFFFF;
}

int lutId = getLUTId(cell);
float ped = 0;
float gain = 0;
uint32_t status = 0;

if (LUTGenerationMode_){
const HcalCalibrations& calibrations = conditions.getHcalCalibrations(cell);
for (int capId = 0; capId < 4; ++capId){
ped += calibrations.pedestal(capId);
gain += calibrations.LUTrespcorrgain(capId);
}
ped /= 4.0;
gain /= 4.0;

//Get Channel Quality
const HcalChannelStatus* channelStatus = conditions.getHcalChannelStatus(cell);
status = channelStatus->getValue();
} else {
const HcalL1TriggerObject* myL1TObj = conditions.getHcalL1TriggerObject(cell);
ped = myL1TObj->getPedestal();
gain = myL1TObj->getRespGain();
status = myL1TObj->getFlag();
} // LUTGenerationMode_

ped_[lutId] = ped;
gain_[lutId] = gain;
bool isMasked = ( (status & bitToMask_) > 0 );
float rcalib = meta->getRCalib();

// Input LUT for HB/HE/HF
if (subdet == HcalBarrel || subdet == HcalEndcap){
HBHEDataFrame frame(cell);
frame.setSize(1);
CaloSamples samples(cell, 1);

int granularity = meta->getLutGranularity();

for (unsigned int adc = 0; adc < INPUT_LUT_SIZE; ++adc) {
frame.setSample(0,HcalQIESample(adc));
coder.adc2fC(frame,samples);
float adc2fC = samples[0];

if (isMasked) inputLUT_[lutId][adc] = 0;
else inputLUT_[lutId][adc] = (LutElement) std::min(std::max(0, int((adc2fC -ped) * gain * rcalib / nominalgain_ / granularity)), QIE8_LUT_BITMASK);
}

unsigned short data[] = {0, 0, 0};
QIE11DataFrame upgradeFrame(edm::DataFrame(0, data, 3));
CaloSamples upgradeSamples(cell, 1);
for (unsigned int adc = 0; adc < UPGRADE_LUT_SIZE; ++adc) {
upgradeFrame.setSample(0, adc, 0, true);
coder.adc2fC(upgradeFrame, upgradeSamples);
float adc2fC = upgradeSamples[0];

if (isMasked) {
upgradeQIE11LUT_[lutId][adc] = 0;
} else {
upgradeQIE11LUT_[lutId][adc] = (LutElement) std::min(std::max(0, int((adc2fC -ped) * gain * rcalib / nominalgain_ / granularity)), QIE11_LUT_BITMASK);
if (adc >= mipMin and adc < mipMax)
upgradeQIE11LUT_[lutId][adc] |= QIE11_LUT_MSB0;
else if (adc >= mipMax)
upgradeQIE11LUT_[lutId][adc] |= QIE11_LUT_MSB1;
}
}
} // endif HBHE
else if (subdet == HcalForward){
HFDataFrame frame(cell);
frame.setSize(1);
CaloSamples samples(cell, 1);

for (unsigned int adc = 0; adc < INPUT_LUT_SIZE; ++adc) {
frame.setSample(0,HcalQIESample(adc));
coder.adc2fC(frame,samples);
float adc2fC = samples[0];
if (isMasked) inputLUT_[lutId][adc] = 0;
else inputLUT_[lutId][adc] = std::min(std::max(0,int((adc2fC - ped) * gain * rcalib / lsb_ / cosh_ieta[cell.ietaAbs()] )), QIE8_LUT_BITMASK);
}

unsigned short data[] = {0, 0, 0, 0};
QIE10DataFrame upgradeFrame(edm::DataFrame(0, data, 4));
CaloSamples upgradeSamples(cell, 1);
for (unsigned int adc = 0; adc < UPGRADE_LUT_SIZE; ++adc) {
upgradeFrame.setSample(0, adc, 0, 0, 0, true);
coder.adc2fC(upgradeFrame, upgradeSamples);
float adc2fC = upgradeSamples[0];

if (isMasked)
upgradeQIE10LUT_[lutId][adc] = 0;
else
upgradeQIE10LUT_[lutId][adc] = std::min(std::max(0,int((adc2fC - ped) * gain * rcalib / lsb_ / cosh_ieta[cell.ietaAbs()] )), QIE10_LUT_BITMASK);
}
} // endif HF
}// for cell
}

void HcaluLUTTPGCoder::adc2Linear(const HBHEDataFrame& df, IntegerCaloSamples& ics) const {
Expand Down
7 changes: 4 additions & 3 deletions L1Trigger/Configuration/python/L1TDigiToRaw_cff.py
Expand Up @@ -15,11 +15,12 @@
stage2L1Trigger.toModify( rawDataCollector.RawCollectionList, func = lambda list: list.append(cms.InputTag("caloStage2Raw")) )
stage2L1Trigger.toModify( rawDataCollector.RawCollectionList, func = lambda list: list.append(cms.InputTag("gmtStage2Raw")) )
stage2L1Trigger.toModify( rawDataCollector.RawCollectionList, func = lambda list: list.append(cms.InputTag("gtStage2Raw")) )
from Configuration.Eras.Modifier_phase2_common_cff import phase2_common

#
# Legacy Trigger:
#
if not (stage1L1Trigger.isChosen() or stage2L1Trigger.isChosen()):
if not (stage1L1Trigger.isChosen() or stage2L1Trigger.isChosen() or phase2_common.isChosen()):
print "L1TDigiToRaw Sequence configured for Run1 (Legacy) trigger. "
# legacy L1 packages:
from EventFilter.CSCTFRawToDigi.csctfpacker_cfi import *
Expand All @@ -40,7 +41,7 @@
#
# Stage-1 Trigger
#
if stage1L1Trigger.isChosen() and not stage2L1Trigger.isChosen():
if stage1L1Trigger.isChosen() and not (stage2L1Trigger.isChosen() or phase2_common.isChosen()):
print "L1TDigiToRaw Sequence configured for Stage-1 (2015) trigger. "
# legacy L1 packers, still in use for 2015:
from EventFilter.CSCTFRawToDigi.csctfpacker_cfi import *
Expand All @@ -65,7 +66,7 @@
#
# Stage-2 Trigger
#
if stage2L1Trigger.isChosen():
if (stage2L1Trigger.isChosen() or phase2_common.isChosen()):
print "L1TDigiToRaw Sequence configured for Stage-2 (2016) trigger. "
from EventFilter.L1TRawToDigi.caloStage2Raw_cfi import *
from EventFilter.L1TRawToDigi.gmtStage2Raw_cfi import *
Expand Down
7 changes: 4 additions & 3 deletions L1Trigger/Configuration/python/L1TRawToDigi_cff.py
Expand Up @@ -69,23 +69,24 @@ def unpack_stage2():
#
from Configuration.Eras.Modifier_stage1L1Trigger_cff import stage1L1Trigger
from Configuration.Eras.Modifier_stage2L1Trigger_cff import stage2L1Trigger
if not (stage1L1Trigger.isChosen() or stage2L1Trigger.isChosen()):
from Configuration.Eras.Modifier_phase2_common_cff import phase2_common
if not (stage1L1Trigger.isChosen() or stage2L1Trigger.isChosen() or phase2_common.isChosen()):
print "L1TRawToDigi Sequence configured for Run1 (Legacy) trigger. "
unpack_legacy()
L1TRawToDigi = cms.Sequence(L1TRawToDigi_Legacy);

#
# Stage-1 Trigger
#
if stage1L1Trigger.isChosen() and not stage2L1Trigger.isChosen():
if stage1L1Trigger.isChosen() and not (stage2L1Trigger.isChosen() or phase2_common.isChosen()):
print "L1TRawToDigi Sequence configured for Stage-1 (2015) trigger. "
unpack_stage1()
L1TRawToDigi = cms.Sequence(L1TRawToDigi_Stage1)

#
# Stage-2 Trigger: fow now, unpack Stage 1 and Stage 2 (in case both available)
#
if stage2L1Trigger.isChosen():
if (stage2L1Trigger.isChosen() or phase2_common.isChosen()):
print "L1TRawToDigi Sequence configured for Stage-2 (2016) trigger. "
unpack_stage1()
unpack_stage2()
Expand Down
3 changes: 2 additions & 1 deletion L1Trigger/Configuration/python/SimL1TechnicalTriggers_cff.py
Expand Up @@ -26,7 +26,8 @@
simCastorTechTrigDigis = SimCalorimetry.CastorTechTrigProducer.castorTTRecord_cfi.simCastorTTRecord.clone()

from Configuration.Eras.Modifier_stage2L1Trigger_cff import stage2L1Trigger
if not (stage2L1Trigger.isChosen()):
from Configuration.Eras.Modifier_phase2_common_cff import phase2_common
if not (stage2L1Trigger.isChosen() or phase2_common.isChosen()):
SimL1TechnicalTriggers = cms.Sequence(
simBscDigis +
simRpcTechTrigDigis +
Expand Down
3 changes: 2 additions & 1 deletion L1Trigger/L1TCalorimeter/python/hackConditions_cff.py
Expand Up @@ -15,6 +15,7 @@
#
from Configuration.Eras.Modifier_stage1L1Trigger_cff import stage1L1Trigger
from Configuration.Eras.Modifier_stage2L1Trigger_cff import stage2L1Trigger
from Configuration.Eras.Modifier_phase2_common_cff import phase2_common
#if not (stage1L1Trigger.isChosen() or stage2L1Trigger.isChosen()):
# print "L1TCalorimeter conditions configured for Run1 (Legacy) trigger. "
#
Expand All @@ -36,7 +37,7 @@
#
# Stage-2 Trigger
#
if stage2L1Trigger.isChosen():
if (stage2L1Trigger.isChosen() or phase2_common.isChosen()):
if pA_2016.isChosen():
print "L1TCalorimeter Conditions configured for Stage-2 (2016 pA) trigger. "
from L1Trigger.L1TCalorimeter.caloStage2Params_2016_v3_3_1_HI_cfi import *
Expand Down
5 changes: 3 additions & 2 deletions L1Trigger/L1TCalorimeter/python/simDigis_cff.py
Expand Up @@ -5,7 +5,8 @@
#
from Configuration.Eras.Modifier_stage1L1Trigger_cff import stage1L1Trigger
from Configuration.Eras.Modifier_stage2L1Trigger_cff import stage2L1Trigger
if not (stage1L1Trigger.isChosen() or stage2L1Trigger.isChosen()):
from Configuration.Eras.Modifier_phase2_common_cff import phase2_common
if not (stage1L1Trigger.isChosen() or stage2L1Trigger.isChosen() or phase2_common.isChosen()):
print "L1TCalorimeter Sequence configured for Run1 (Legacy) trigger. "
# - RCT (Regional Calorimeter Trigger) emulator
import L1Trigger.RegionalCaloTrigger.rctDigis_cfi
Expand Down Expand Up @@ -41,7 +42,7 @@
#
# Stage-2 Trigger
#
if stage2L1Trigger.isChosen():
if (stage2L1Trigger.isChosen() or phase2_common.isChosen()):
print "L1TCalorimeter Sequence configured for Stage-2 (2016) trigger. "
# select one of the following two options:
# - layer1 from L1Trigger/L1TCalorimeter package
Expand Down
3 changes: 2 additions & 1 deletion L1Trigger/L1TGlobal/python/hackConditions_cff.py
Expand Up @@ -15,6 +15,7 @@
#
from Configuration.Eras.Modifier_stage1L1Trigger_cff import stage1L1Trigger
from Configuration.Eras.Modifier_stage2L1Trigger_cff import stage2L1Trigger
from Configuration.Eras.Modifier_phase2_common_cff import phase2_common
#if not (stage1L1Trigger.isChosen() or stage2L1Trigger.isChosen()):
# print "L1TGlobal conditions configured for Run1 (Legacy) trigger. "
#
Expand All @@ -28,7 +29,7 @@
#
# Stage-2 Trigger
#
if stage2L1Trigger.isChosen():
if (stage2L1Trigger.isChosen() or phase2_common.isChosen()):
print "L1TGlobal Conditions configured for Stage-2 (2016) trigger. "
from L1Trigger.L1TGlobal.StableParameters_cff import *
# from L1Trigger.L1TGlobal.GlobalParameters_cff import *
Expand Down
5 changes: 3 additions & 2 deletions L1Trigger/L1TGlobal/python/simDigis_cff.py
Expand Up @@ -8,7 +8,8 @@
# Legacy Trigger:
#
from Configuration.Eras.Modifier_stage2L1Trigger_cff import stage2L1Trigger
if not (stage2L1Trigger.isChosen()):
from Configuration.Eras.Modifier_phase2_common_cff import phase2_common
if not (stage2L1Trigger.isChosen() or phase2_common.isChosen()):
print "L1TGlobal Sequence configured for Legacy trigger (Run1 and Run 2015). "
#
# - Global Trigger emulator
Expand All @@ -28,7 +29,7 @@
#
# Stage-2 Trigger
#
if stage2L1Trigger.isChosen():
if (stage2L1Trigger.isChosen() or phase2_common.isChosen()):
#
# - Global Trigger emulator
#
Expand Down