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

HCAL LUT generation and validation #19864

Merged
merged 7 commits into from Aug 22, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CalibCalorimetry/CaloTPG/src/CaloTPGTranscoderULUT.cc
Expand Up @@ -70,6 +70,7 @@ void CaloTPGTranscoderULUT::loadHCALCompress(HcalLutMetadata const& lutMetadata,
bool isHBHE = (abs(ieta) < theTrigTowerGeometry.firstHFTower(version));

unsigned int lutsize = getOutputLUTSize(id);
outputLUT_[index].resize(lutsize);

for (unsigned int i = 0; i < threshold; ++i)
Copy link
Contributor

Choose a reason for hiding this comment

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

please use range-based loop.

outputLUT_[index][i] = 0;
Expand Down
2 changes: 1 addition & 1 deletion CalibCalorimetry/CaloTPG/src/CaloTPGTranscoderULUT.h
Expand Up @@ -76,7 +76,7 @@ class CaloTPGTranscoderULUT : public CaloTPGTranscoder {
std::vector<int> ZS;
std::vector<int> LUTfactor;

std::vector<std::array<LUT, OUTPUT_LUT_SIZE>> outputLUT_;
std::vector<std::vector<LUT>> outputLUT_;
std::vector<RCTdecompression> hcaluncomp_;

std::set<HcalDetId> plan1_towers_;
Expand Down
2 changes: 1 addition & 1 deletion CalibCalorimetry/HcalAlgos/src/HcalDbASCIIIO.cc
Expand Up @@ -1022,7 +1022,7 @@ bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalL1TriggerObject
const HcalL1TriggerObject* item = fObject.getValues (*channel);
if (item) {
dumpId (fOutput, *channel);
sprintf (buffer, " %10.7f %10.7f %12d %10X\n",
sprintf (buffer, " %12.7f %13.10f %12d %10X\n",
item->getPedestal(), item->getRespGain(), item->getFlag(), channel->rawId ());
fOutput << buffer;
}
Expand Down
2 changes: 2 additions & 0 deletions CalibCalorimetry/HcalTPGAlgos/interface/HcaluLUTTPGCoder.h
Expand Up @@ -42,6 +42,7 @@ class HcaluLUTTPGCoder : public HcalTPGCoder {
virtual unsigned short adc2Linear(HcalQIESample sample,HcalDetId id) const override;
virtual float getLUTPedestal(HcalDetId id) const override;
virtual float getLUTGain(HcalDetId id) const override;
virtual std::vector<unsigned short> getLinearizationLUT(HcalDetId id) const override;

void update(const HcalDbService& conditions);
void update(const char* filename, bool appendMSB = false);
Expand Down Expand Up @@ -84,6 +85,7 @@ class HcaluLUTTPGCoder : public HcalTPGCoder {
std::vector< Lut > inputLUT_;
std::vector< Lut > upgradeQIE10LUT_;
std::vector< Lut > upgradeQIE11LUT_;
std::vector<int> QIEType_;
std::vector<float> gain_;
std::vector<float> ped_;
};
Expand Down
5 changes: 4 additions & 1 deletion CalibCalorimetry/HcalTPGAlgos/interface/LutXml.h
Expand Up @@ -39,6 +39,7 @@ class LutXml : public XMLDOMBlock
std::string targetfirmware;
int generalizedindex;
std::vector<unsigned int> lut;
std::vector<uint64_t> mask;
} Config;

LutXml();
Expand Down Expand Up @@ -82,7 +83,9 @@ class LutXml : public XMLDOMBlock
XMLCh * brick;
XERCES_CPP_NAMESPACE::DOMElement * addParameter( std::string _name, std::string _type, std::string _value );
XERCES_CPP_NAMESPACE::DOMElement * addParameter( std::string _name, std::string _type, int _value );
XERCES_CPP_NAMESPACE::DOMElement * addData( std::string _elements, std::string _encoding, const std::vector<unsigned int>& _lut );

template <typename T>
XERCES_CPP_NAMESPACE::DOMElement * addData( std::string _elements, std::string _encoding, const T& _lut );

XERCES_CPP_NAMESPACE::DOMElement * add_checksum(XERCES_CPP_NAMESPACE::DOMDocument * parent, Config & config );

Expand Down
15 changes: 14 additions & 1 deletion CalibCalorimetry/HcalTPGAlgos/src/HcaluLUTTPGCoder.cc
Expand Up @@ -53,6 +53,7 @@ HcaluLUTTPGCoder::HcaluLUTTPGCoder(const HcalTopology* top) : topo_(top), LUTGen
inputLUT_ = std::vector<HcaluLUTTPGCoder::Lut>(nluts,HcaluLUTTPGCoder::Lut(INPUT_LUT_SIZE, 0));
upgradeQIE10LUT_ = std::vector<HcaluLUTTPGCoder::Lut>(nluts,HcaluLUTTPGCoder::Lut(UPGRADE_LUT_SIZE, 0));
upgradeQIE11LUT_ = std::vector<HcaluLUTTPGCoder::Lut>(nluts,HcaluLUTTPGCoder::Lut(UPGRADE_LUT_SIZE, 0));
QIEType_ = std::vector<int> (nluts, 0);
gain_ = std::vector<float>(nluts, 0.);
ped_ = std::vector<float>(nluts, 0.);
}
Expand Down Expand Up @@ -267,9 +268,11 @@ void HcaluLUTTPGCoder::update(const HcalDbService& conditions) {
float gain = 0;
uint32_t status = 0;

QIEType_[lutId]=conditions.getHcalQIEType(cell)->getValue();

if (LUTGenerationMode_){
const HcalCalibrations& calibrations = conditions.getHcalCalibrations(cell);
for (int capId = 0; capId < 4; ++capId){
for (auto capId : {0,1,2,3}){
ped += calibrations.pedestal(capId);
gain += calibrations.LUTrespcorrgain(capId);
}
Expand Down Expand Up @@ -409,6 +412,16 @@ std::vector<unsigned short> HcaluLUTTPGCoder::getLinearizationLUTWithMSB(const H
return inputLUT_.at(lutId);
}

std::vector<unsigned short> HcaluLUTTPGCoder::getLinearizationLUT(HcalDetId id) const{

int lutId = getLUTId(id);
int type=QIEType_[lutId];
const std::vector<Lut>& lut= type==0 ? inputLUT_ :
type==1 ? upgradeQIE10LUT_ :
upgradeQIE11LUT_ ;
return lut.at(lutId);
}

void HcaluLUTTPGCoder::lookupMSB(const HBHEDataFrame& df, std::vector<bool>& msb) const{
msb.resize(df.size());
for (int i=0; i<df.size(); ++i)
Copy link
Contributor

Choose a reason for hiding this comment

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

use range-based loop.

Expand Down