#include <HcaluLUTTPGCoder.h>
Public Member Functions | |
virtual void | adc2Linear (const HBHEDataFrame &df, IntegerCaloSamples &ics) const |
virtual void | adc2Linear (const HFDataFrame &df, IntegerCaloSamples &ics) const |
virtual unsigned short | adc2Linear (HcalQIESample sample, HcalDetId id) const |
virtual void | compress (const IntegerCaloSamples &ics, const std::vector< bool > &featureBits, HcalTriggerPrimitiveDigi &tp) const |
std::vector< unsigned short > | getLinearizationLUTWithMSB (const HcalDetId &id) const |
virtual float | getLUTGain (HcalDetId id) const |
int | getLUTId (HcalSubdetector id, int ieta, int iphi, int depth) const |
int | getLUTId (uint32_t rawid) const |
int | getLUTId (const HcalDetId &detid) const |
virtual float | getLUTPedestal (HcalDetId id) const |
bool | getMSB (const HcalDetId &id, int adc) const |
HcaluLUTTPGCoder () | |
void | lookupMSB (const HBHEDataFrame &df, std::vector< bool > &msb) const |
void | setLUTGenerationMode (bool gen) |
void | setMaskBit (int bit) |
void | update (const char *filename, bool appendMSB=false) |
void | update (const HcalDbService &conditions) |
void | updateXML (const char *filename) |
virtual | ~HcaluLUTTPGCoder () |
Private Types | |
typedef std::vector< LutElement > | Lut |
typedef unsigned short | LutElement |
Private Attributes | |
int | bitToMask_ |
std::vector< float > | gain_ |
static const size_t | INPUT_LUT_SIZE = 128 |
std::vector< Lut > | inputLUT_ |
bool | LUTGenerationMode_ |
std::vector< float > | ped_ |
Static Private Attributes | |
static const float | lsb_ = 1./16 |
static const size_t | nluts = 46007 |
The nominal coder uses a user-supplied table to linearize the ADC values.
[number of ieta slices] [low tower 1] [low tower 2] ... [high tower 1] [ high tower 2] ... [LUT 1(0)] [LUT 2(0)] ... [LUT 1(1)] [LUT 2(1)] ... . . . [LUT 1(127)] [LUT 2(127)] ...
Definition at line 31 of file HcaluLUTTPGCoder.h.
typedef std::vector<LutElement> HcaluLUTTPGCoder::Lut [private] |
Definition at line 58 of file HcaluLUTTPGCoder.h.
typedef unsigned short HcaluLUTTPGCoder::LutElement [private] |
Definition at line 57 of file HcaluLUTTPGCoder.h.
HcaluLUTTPGCoder::HcaluLUTTPGCoder | ( | ) |
Definition at line 30 of file HcaluLUTTPGCoder.cc.
: LUTGenerationMode_(true), bitToMask_(0), inputLUT_(nluts, Lut(INPUT_LUT_SIZE, 0)), gain_(nluts, 0.), ped_ (nluts, 0.){ }
HcaluLUTTPGCoder::~HcaluLUTTPGCoder | ( | ) | [virtual] |
Definition at line 39 of file HcaluLUTTPGCoder.cc.
{ }
void HcaluLUTTPGCoder::adc2Linear | ( | const HBHEDataFrame & | df, |
IntegerCaloSamples & | ics | ||
) | const [virtual] |
Implements HcalTPGCoder.
Definition at line 283 of file HcaluLUTTPGCoder.cc.
References ecalMGPA::adc(), getLUTId(), i, HBHEDataFrame::id(), inputLUT_, lumiPlot::lut, and HBHEDataFrame::size().
Referenced by HcalTriggerPrimitiveAlgo::addSignal().
void HcaluLUTTPGCoder::adc2Linear | ( | const HFDataFrame & | df, |
IntegerCaloSamples & | ics | ||
) | const [virtual] |
Implements HcalTPGCoder.
Definition at line 291 of file HcaluLUTTPGCoder.cc.
References ecalMGPA::adc(), getLUTId(), i, HFDataFrame::id(), inputLUT_, lumiPlot::lut, and HFDataFrame::size().
unsigned short HcaluLUTTPGCoder::adc2Linear | ( | HcalQIESample | sample, |
HcalDetId | id | ||
) | const [virtual] |
Implements HcalTPGCoder.
Definition at line 299 of file HcaluLUTTPGCoder.cc.
References HcalQIESample::adc(), asciidump::at, getLUTId(), and inputLUT_.
void HcaluLUTTPGCoder::compress | ( | const IntegerCaloSamples & | ics, |
const std::vector< bool > & | featureBits, | ||
HcalTriggerPrimitiveDigi & | tp | ||
) | const [virtual] |
Implements HcalTPGCoder.
Definition at line 35 of file HcaluLUTTPGCoder.cc.
References Exception.
{ throw cms::Exception("PROBLEM: This method should never be invoked!"); }
std::vector< unsigned short > HcaluLUTTPGCoder::getLinearizationLUTWithMSB | ( | const HcalDetId & | id | ) | const |
Definition at line 314 of file HcaluLUTTPGCoder.cc.
References getLUTId(), and inputLUT_.
float HcaluLUTTPGCoder::getLUTGain | ( | HcalDetId | id | ) | const [virtual] |
Implements HcalTPGCoder.
Definition at line 309 of file HcaluLUTTPGCoder.cc.
References gain_, and getLUTId().
int HcaluLUTTPGCoder::getLUTId | ( | const HcalDetId & | detid | ) | const |
Definition at line 54 of file HcaluLUTTPGCoder.cc.
References HcalDetId::depth(), getLUTId(), HcalDetId::ieta(), HcalDetId::iphi(), and HcalDetId::subdet().
int HcaluLUTTPGCoder::getLUTId | ( | uint32_t | rawid | ) | const |
Definition at line 49 of file HcaluLUTTPGCoder.cc.
References HcalDetId::depth(), cond::rpcobgas::detid, getLUTId(), HcalDetId::ieta(), HcalDetId::iphi(), and HcalDetId::subdet().
int HcaluLUTTPGCoder::getLUTId | ( | HcalSubdetector | id, |
int | ieta, | ||
int | iphi, | ||
int | depth | ||
) | const |
Definition at line 42 of file HcaluLUTTPGCoder.cc.
References cond::rpcobgas::detid, HcalEndcap, and HcalForward.
Referenced by adc2Linear(), getLinearizationLUTWithMSB(), getLUTGain(), getLUTId(), getLUTPedestal(), getMSB(), update(), and updateXML().
{ int detid = 0; if (id == HcalEndcap) detid = 1; else if (id == HcalForward) detid = 2; return iphi + 72 * ((ieta + 41) + 83 * (depth + 3 * detid)) - 7777; }
float HcaluLUTTPGCoder::getLUTPedestal | ( | HcalDetId | id | ) | const [virtual] |
Implements HcalTPGCoder.
Definition at line 304 of file HcaluLUTTPGCoder.cc.
References getLUTId(), and ped_.
bool HcaluLUTTPGCoder::getMSB | ( | const HcalDetId & | id, |
int | adc | ||
) | const |
Definition at line 325 of file HcaluLUTTPGCoder.cc.
References getLUTId(), inputLUT_, and lumiPlot::lut.
Referenced by lookupMSB().
void HcaluLUTTPGCoder::lookupMSB | ( | const HBHEDataFrame & | df, |
std::vector< bool > & | msb | ||
) | const |
Definition at line 319 of file HcaluLUTTPGCoder.cc.
References HcalQIESample::adc(), getMSB(), i, HBHEDataFrame::id(), HBHEDataFrame::sample(), and HBHEDataFrame::size().
Referenced by HcalTriggerPrimitiveAlgo::addSignal().
void HcaluLUTTPGCoder::setLUTGenerationMode | ( | bool | gen | ) | [inline] |
Definition at line 46 of file HcaluLUTTPGCoder.h.
References cmsDownloadME::gen, and LUTGenerationMode_.
Referenced by HcalTPGCoderULUT::HcalTPGCoderULUT().
{ LUTGenerationMode_ = gen; };
void HcaluLUTTPGCoder::setMaskBit | ( | int | bit | ) | [inline] |
Definition at line 47 of file HcaluLUTTPGCoder.h.
References bitToMask_.
Referenced by HcalTPGCoderULUT::HcalTPGCoderULUT().
{ bitToMask_ = bit; };
void HcaluLUTTPGCoder::update | ( | const HcalDbService & | conditions | ) |
Definition at line 184 of file HcaluLUTTPGCoder.cc.
References abs, ecalMGPA::adc(), HcalCoderDb::adc2fC(), adc2fC, bitToMask_, HcalQIECoder::charge(), gain_, HcalL1TriggerObject::getFlag(), HcalDbService::getHcalCalibrations(), HcalDbService::getHcalChannelStatus(), HcalDbService::getHcalCoder(), HcalDbService::getHcalL1TriggerObject(), HcalDbService::getHcalLutMetadata(), HcalDbService::getHcalShape(), HcalLutMetadatum::getLutGranularity(), getLUTId(), HcalLutMetadata::getNominalGain(), HcalL1TriggerObject::getPedestal(), HcalLutMetadatum::getRCalib(), HcalL1TriggerObject::getRespGain(), HcalChannelStatus::getValue(), HcalCondObjectContainer< Item >::getValues(), HcalBarrel, HcalEndcap, HcalForward, i, inputLUT_, lsb_, LUTGenerationMode_, HcalCalibrations::LUTrespcorrgain(), max(), min, evf::evtn::offset(), ped_, HcalCalibrations::pedestal(), HBHEDataFrame::setSample(), HFDataFrame::setSample(), HBHEDataFrame::setSize(), HFDataFrame::setSize(), ntuplemaker::status, subdets, theHFEtaBounds, and HcalDetId::validDetId().
Referenced by HcalTPGCoderULUT::dbRecordCallback(), and HcalTPGCoderULUT::HcalTPGCoderULUT().
{ const HcalQIEShape* shape = conditions.getHcalShape(); HcalCalibrations calibrations; const HcalLutMetadata *metadata = conditions.getHcalLutMetadata(); assert(metadata !=0); float nominalgain_ = metadata->getNominalGain(); std::map<int, float> cosh_ieta; for (int i = 0; i < 13; ++i) cosh_ieta[i+29] = cosh((theHFEtaBounds[i+1] + theHFEtaBounds[i])/2.); HcalSubdetector subdets[] = {HcalBarrel, HcalEndcap, HcalForward}; for (int isub = 0; isub < 3; ++isub){ HcalSubdetector subdet = subdets[isub]; for (int ieta = -41; ieta <= 41; ++ieta){ for (int iphi = 1; iphi <= 72; ++iphi){ for (int depth = 1; depth <= 3; ++depth){ if (!HcalDetId::validDetId(subdet, ieta, iphi, depth)) continue; HcalDetId cell(subdet, ieta, iphi, depth); const HcalQIECoder* channelCoder = conditions.getHcalCoder (cell); HcalCoderDb coder (*channelCoder, *shape); const HcalLutMetadatum *meta = metadata->getValues(cell); 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 (int adc = 0; adc <= 0x7F; ++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)), 0x3FF); } } // endif HBHE else if (subdet == HcalForward){ HFDataFrame frame(cell); frame.setSize(1); CaloSamples samples(cell, 1); float one_adc2fC = 0.0; for (int capId = 0; capId < 4; ++capId) one_adc2fC += channelCoder->charge(*shape, 1, capId) - channelCoder->charge(*shape, 0, capId); one_adc2fC /= 4.0; // Lumi offset of 1 adc (in fC) for the four rings used to measure lumi float offset = (abs(ieta) >= 33 && abs(ieta) <= 36) ? one_adc2fC : 0; for (int adc = 0; adc <= 0x7F; ++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 + offset) * gain * rcalib / lsb_ / cosh_ieta[abs(ieta)] )), 0x3FF); } } // endif HF } // for depth } // for iphi } // for iphi }// for subdet }
void HcaluLUTTPGCoder::update | ( | const char * | filename, |
bool | appendMSB = false |
||
) |
Definition at line 58 of file HcaluLUTTPGCoder.cc.
References ecalMGPA::adc(), mergeVDriftHistosByStation::file, getLUTId(), HcalBarrel, HcalEndcap, HcalForward, i, recoMuon::in, getHLTprescales::index, INPUT_LUT_SIZE, inputLUT_, findQualityFiles::size, and HcalDetId::validDetId().
{ std::ifstream file(filename, std::ios::in); assert(file.is_open()); std::vector<HcalSubdetector> subdet; std::string buffer; // Drop first (comment) line std::getline(file, buffer); std::getline(file, buffer); unsigned int index = buffer.find("H", 0); while (index < buffer.length()){ std::string subdetStr = buffer.substr(index, 2); if (subdetStr == "HB") subdet.push_back(HcalBarrel); else if (subdetStr == "HE") subdet.push_back(HcalEndcap); else if (subdetStr == "HF") subdet.push_back(HcalForward); //TODO Check subdet //else exception index += 2; index = buffer.find("H", index); } // Get upper/lower ranges for ieta/iphi/depth size_t nCol = subdet.size(); std::vector<int> ietaU; std::vector<int> ietaL; std::vector<int> iphiU; std::vector<int> iphiL; std::vector<int> depU; std::vector<int> depL; std::vector< Lut > lutFromFile(nCol); LutElement lutValue; for (size_t i=0; i<nCol; ++i) { int ieta; file >> ieta; ietaL.push_back(ieta); } for (size_t i=0; i<nCol; ++i) { int ieta; file >> ieta; ietaU.push_back(ieta); } for (size_t i=0; i<nCol; ++i) { int iphi; file >> iphi; iphiL.push_back(iphi); } for (size_t i=0; i<nCol; ++i) { int iphi; file >> iphi; iphiU.push_back(iphi); } for (size_t i=0; i<nCol; ++i) { int dep; file >> dep; depL.push_back(dep); } for (size_t i=0; i<nCol; ++i) { int dep; file >> dep; depU.push_back(dep); } // Read Lut Entry for (size_t i=0; file >> lutValue; i = (i+1) % nCol){ lutFromFile[i].push_back(lutValue); } // Check lut size for (size_t i=0; i<nCol; ++i) assert(lutFromFile[i].size() == INPUT_LUT_SIZE); for (size_t i=0; i<nCol; ++i){ for (int ieta = ietaL[i]; ieta <= ietaU[i]; ++ieta){ for (int iphi = iphiL[i]; iphi <= iphiU[i]; ++iphi){ for (int depth = depL[i]; depth <= depU[i]; ++depth){ if (!HcalDetId::validDetId(subdet[i], ieta, iphi, depth)) continue; HcalDetId id(subdet[i], ieta, iphi, depth); int lutId = getLUTId(id); for (size_t adc = 0; adc < INPUT_LUT_SIZE; ++adc){ if (appendMSB){ // Append FG bit LUT to MSB // MSB = Most Significant Bit = bit 10 // Overwrite bit 10 LutElement msb = (lutFromFile[i][adc] != 0 ? 0x400 : 0); inputLUT_[lutId][adc] = (msb | (inputLUT_[lutId][adc] & 0x3FF)); } else inputLUT_[lutId][adc] = lutFromFile[i][adc]; }// for adc }// for depth }// for iphi }// for ieta }// for nCol }
void HcaluLUTTPGCoder::updateXML | ( | const char * | filename | ) |
Definition at line 160 of file HcaluLUTTPGCoder.cc.
References LutXml::create_lut_map(), cond::rpcobgas::detid, Exception, XMLProcessor::getInstance(), LutXml::getLutFast(), getLUTId(), HcalBarrel, HcalEndcap, HcalForward, i, inputLUT_, lumiPlot::lut, XMLProcessor::terminate(), and HcalTopology::valid().
Referenced by HcalTPGCoderULUT::HcalTPGCoderULUT().
{ HcalTopology theTopo; LutXml * _xml = new LutXml(filename); _xml->create_lut_map(); HcalSubdetector subdet[3] = {HcalBarrel, HcalEndcap, HcalForward}; for (int ieta=-41; ieta<=41; ++ieta){ for (int iphi=1; iphi<=72; ++iphi){ for (int depth=1; depth<=3; ++depth){ for (int isub=0; isub<3; ++isub){ HcalDetId detid(subdet[isub], ieta, iphi, depth); if (!theTopo.valid(detid)) continue; int id = getLUTId(subdet[isub], ieta, iphi, depth); std::vector<unsigned int>* lut = _xml->getLutFast(detid); if (lut==0) throw cms::Exception("PROBLEM: No inputLUT_ in xml file for ") << detid << std::endl; if (lut->size()!=128) throw cms::Exception ("PROBLEM: Wrong inputLUT_ size in xml file for ") << detid << std::endl; for (int i=0; i<128; ++i) inputLUT_[id][i] = (LutElement)lut->at(i); } } } } delete _xml; XMLProcessor::getInstance()->terminate(); }
int HcaluLUTTPGCoder::bitToMask_ [private] |
Definition at line 66 of file HcaluLUTTPGCoder.h.
Referenced by setMaskBit(), and update().
std::vector<float> HcaluLUTTPGCoder::gain_ [private] |
Definition at line 68 of file HcaluLUTTPGCoder.h.
Referenced by getLUTGain(), and update().
const size_t HcaluLUTTPGCoder::INPUT_LUT_SIZE = 128 [private] |
Definition at line 61 of file HcaluLUTTPGCoder.h.
Referenced by update().
std::vector< Lut > HcaluLUTTPGCoder::inputLUT_ [private] |
Definition at line 67 of file HcaluLUTTPGCoder.h.
Referenced by adc2Linear(), getLinearizationLUTWithMSB(), getMSB(), update(), and updateXML().
const float HcaluLUTTPGCoder::lsb_ = 1./16 [static, private] |
Definition at line 62 of file HcaluLUTTPGCoder.h.
Referenced by update().
bool HcaluLUTTPGCoder::LUTGenerationMode_ [private] |
Definition at line 65 of file HcaluLUTTPGCoder.h.
Referenced by setLUTGenerationMode(), and update().
const size_t HcaluLUTTPGCoder::nluts = 46007 [static, private] |
Definition at line 61 of file HcaluLUTTPGCoder.h.
std::vector<float> HcaluLUTTPGCoder::ped_ [private] |
Definition at line 69 of file HcaluLUTTPGCoder.h.
Referenced by getLUTPedestal(), and update().