Skip to content
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
7 changes: 6 additions & 1 deletion CalibCalorimetry/HcalTPGAlgos/interface/HcaluLUTTPGCoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class HcalDbService;
class HcaluLUTTPGCoder : public HcalTPGCoder {
public:
static const float lsb_;
static const float zdc_lsb_;

HcaluLUTTPGCoder();
HcaluLUTTPGCoder(const HcalTopology* topo, const HcalTimeSlew* delay);
Expand All @@ -41,7 +42,7 @@ class HcaluLUTTPGCoder : public HcalTPGCoder {

void adc2Linear(const HBHEDataFrame& df, IntegerCaloSamples& ics) const override;
void adc2Linear(const HFDataFrame& df, IntegerCaloSamples& ics) const override;
void adc2Linear(const QIE10DataFrame& df, IntegerCaloSamples& ics) const override;
void adc2Linear(const QIE10DataFrame& df, IntegerCaloSamples& ics, bool ootpu_lut) const override;
void adc2Linear(const QIE11DataFrame& df, IntegerCaloSamples& ics) const override;
std::vector<unsigned short> group0FGbits(const QIE11DataFrame& df) const;
void compress(const IntegerCaloSamples& ics,
Expand All @@ -51,6 +52,7 @@ class HcaluLUTTPGCoder : public HcalTPGCoder {
float getLUTPedestal(HcalDetId id) const override;
float getLUTGain(HcalDetId id) const override;
std::vector<unsigned short> getLinearizationLUT(HcalDetId id) const override;
std::vector<unsigned short> getLinearizationLUT(HcalZDCDetId id, bool ootpu_lut) const override;

double cosh_ieta(int ieta, int depth, HcalSubdetector subdet);
void make_cosh_ieta_map(void);
Expand Down Expand Up @@ -84,10 +86,12 @@ class HcaluLUTTPGCoder : public HcalTPGCoder {
int getLUTId(HcalSubdetector id, int ieta, int iphi, int depth) const;
int getLUTId(uint32_t rawid) const;
int getLUTId(const HcalDetId& detid) const;
int getLUTId(const HcalZDCDetId& detid) const;

static const int QIE8_LUT_BITMASK = 0x3FF;
static const int QIE10_LUT_BITMASK = 0x7FF;
static const int QIE11_LUT_BITMASK = 0x3FF;
static const int QIE10_ZDC_LUT_BITMASK = 0x3FF;

private:
// typedef
Expand All @@ -114,6 +118,7 @@ class HcaluLUTTPGCoder : public HcalTPGCoder {
int firstHBEta_, lastHBEta_, nHBEta_, maxDepthHB_, sizeHB_;
int firstHEEta_, lastHEEta_, nHEEta_, maxDepthHE_, sizeHE_;
int firstHFEta_, lastHFEta_, nHFEta_, maxDepthHF_, sizeHF_;
int sizeZDC_;
std::vector<Lut> inputLUT_;
std::vector<float> gain_;
std::vector<float> ped_;
Expand Down
457 changes: 291 additions & 166 deletions CalibCalorimetry/HcalTPGAlgos/src/HcaluLUTTPGCoder.cc

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion CalibFormats/HcalObjects/interface/HcalTPGCoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "DataFormats/HcalDigi/interface/HcalTriggerPrimitiveDigi.h"
#include "DataFormats/HcalDigi/interface/QIE10DataFrame.h"
#include "DataFormats/HcalDigi/interface/QIE11DataFrame.h"
#include "DataFormats/HcalDetId/interface/HcalZDCDetId.h"

// forward declaration of EventSetup is all that is needed here
namespace edm {
Expand All @@ -28,7 +29,7 @@ class HcalTPGCoder {
virtual ~HcalTPGCoder() = default;
virtual void adc2Linear(const HBHEDataFrame& df, IntegerCaloSamples& ics) const = 0;
virtual void adc2Linear(const HFDataFrame& df, IntegerCaloSamples& ics) const = 0;
virtual void adc2Linear(const QIE10DataFrame& df, IntegerCaloSamples& ics) const = 0;
virtual void adc2Linear(const QIE10DataFrame& df, IntegerCaloSamples& ics, bool ootpu_lut) const = 0;
virtual void adc2Linear(const QIE11DataFrame& df, IntegerCaloSamples& ics) const = 0;
virtual unsigned short adc2Linear(HcalQIESample sample, HcalDetId id) const = 0;
unsigned short adc2Linear(unsigned char adc, HcalDetId id) const {
Expand All @@ -43,6 +44,7 @@ class HcalTPGCoder {
Default implementation just uses adc2Linear to get all values
*/
virtual std::vector<unsigned short> getLinearizationLUT(HcalDetId id) const;
virtual std::vector<unsigned short> getLinearizationLUT(HcalZDCDetId id, bool ootput_lut) const;
};

#endif
7 changes: 7 additions & 0 deletions CalibFormats/HcalObjects/src/HcalTPGCoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ std::vector<unsigned short> HcalTPGCoder::getLinearizationLUT(HcalDetId id) cons
lut[i] = adc2Linear(i, id);
return lut;
}

std::vector<unsigned short> HcalTPGCoder::getLinearizationLUT(HcalZDCDetId id, bool ootpu_lut) const {
std::vector<unsigned short> lut(128);
for (unsigned char i = 0; i < 128; ++i)
lut[i] = adc2Linear(i, id);
return lut;
}
5 changes: 4 additions & 1 deletion CaloOnlineTools/HcalOnlineDb/interface/HcalLutManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ class HcalLutManager {
std::string _tag,
bool split_by_crate = true);

std::map<int, std::shared_ptr<LutXml> > getZdcLutXml(std::string _tag, bool split_by_crate = true);
std::map<int, std::shared_ptr<LutXml> > getZdcLutXml(const HcalTPGCoder& _coder,
std::string _tag,
bool split_by_crate = true,
bool ootpu_lut = false);

std::map<int, std::shared_ptr<LutXml> > getHEFineGrainLUTs(std::string _tag, bool split_by_crate = true);

Expand Down
71 changes: 44 additions & 27 deletions CaloOnlineTools/HcalOnlineDb/src/HcalLutManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1643,15 +1643,15 @@ void HcalLutManager::test_emap(void) {
int HcalLutManager::test_direct_xml_parsing(std::string _filename) {
/*
XMLDOMBlock _xml(_filename);
//DOMElement * data_set_elem = (DOMElement *)(document -> getElementsByTagName( XMLProcessor::_toXMLCh( "DATA_SET" ) ) -> item(0));
DOMNodeList * brick_list = _xml . getDocument() -> getElementsByTagName( XMLProcessor::_toXMLCh( "CFGBrick" ));
//DOMElement * data_set_elem = (DOMElement *)(document -> getElementsByTagName( XMLProcessor::_toXMLCh( "DATA_SET" ) ) -> item(0));
DOMNodeList * brick_list = _xml . getDocument() -> getElementsByTagName( XMLProcessor::_toXMLCh( "CFGBrick" ));

double n_bricks = brick_list->getLength();
std::cout << "amount of LUT bricks: " << n_bricks << std::endl;

for (int iter=0; iter!=n_bricks; iter++){
DOMElement * _brick = (DOMElement *)(brick_list->item(iter));

DOMElement * _param = 0;
// loop over brick parameters
int par_iter = 0;
Expand Down Expand Up @@ -1703,6 +1703,11 @@ int HcalLutManager::createLutXmlFiles_HBEFFromCoder_HOFromAscii_ZDC(std::string
addLutMap(xml, masks);
}
//
const auto _zdc_lut_xml = getZdcLutXml(_coder, _tag, split_by_crate, false);
addLutMap(xml, _zdc_lut_xml);

const auto _zdc_ootpu_lut_xml = getZdcLutXml(_coder, _tag, split_by_crate, true);
addLutMap(xml, _zdc_ootpu_lut_xml);

writeLutXmlFiles(xml, _tag, split_by_crate);

Expand All @@ -1712,14 +1717,15 @@ int HcalLutManager::createLutXmlFiles_HBEFFromCoder_HOFromAscii_ZDC(std::string
return 0;
}

std::map<int, std::shared_ptr<LutXml>> HcalLutManager::getZdcLutXml(std::string _tag, bool split_by_crate) {
std::map<int, std::shared_ptr<LutXml>> HcalLutManager::getZdcLutXml(const HcalTPGCoder& _coder,
std::string _tag,
bool split_by_crate,
bool ootpu_lut) {
edm::LogInfo("HcalLutManager") << "Generating ZDC LUTs ...may the Force be with us...";
std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number

EMap _emap(emap);

ZdcLut zdc;

std::vector<EMap::EMapRow>& _map = _emap.get_map();
edm::LogInfo("HcalLutManager") << "EMap contains " << _map.size() << " channels";

Expand All @@ -1739,7 +1745,7 @@ std::map<int, std::shared_ptr<LutXml>> HcalLutManager::getZdcLutXml(std::string
_cfg.ieta = row->zdc_channel; // int
//_cfg.ieta = row->zdc_zside; // int
//_cfg.iphi = row->zdc_section; // string
_cfg.depth = row->idepth; // int
_cfg.depth = row->zdc_zside; // int
_cfg.crate = row->crate;
_cfg.slot = row->slot;
if (row->topbottom.find('t') != std::string::npos)
Expand All @@ -1748,7 +1754,12 @@ std::map<int, std::shared_ptr<LutXml>> HcalLutManager::getZdcLutXml(std::string
_cfg.topbottom = 0;
else
edm::LogWarning("HcalLutManager") << "fpga out of range...";
_cfg.fiber = row->fiber;

if (ootpu_lut)
_cfg.fiber = row->fiber + 6;
else
_cfg.fiber = row->fiber;

_cfg.fiberchan = row->fiberchan;
_cfg.lut_type = 1;
_cfg.creationtag = _tag;
Expand All @@ -1757,29 +1768,35 @@ std::map<int, std::shared_ptr<LutXml>> HcalLutManager::getZdcLutXml(std::string
_cfg.formatrevision = "1"; //???
_cfg.generalizedindex = 0;

//HcalZDCDetId _detid(row->zdc_section, (row->zdc_zside>0), row->zdc_channel);
HcalZDCDetId::Section section = HcalZDCDetId::Unknown;
if (row->zdc_section == "ZDC EM") {
section = HcalZDCDetId::EM;
_cfg.iphi = 1;
} else if (row->zdc_section == "ZDC HAD") {
section = HcalZDCDetId::HAD;
_cfg.iphi = 2;
} else if (row->zdc_section == "ZDC LUM") {
continue;
} else if (row->zdc_section == "ZDC RPD") {
continue;
}
HcalZDCDetId _detid(section, (row->zdc_zside > 0), row->zdc_channel);

std::vector<int> coder_lut = zdc.get_lut(row->zdc_section, row->zdc_zside, row->zdc_channel);
edm::LogInfo("HcalLutManager") << "***DEBUG: ZDC lut size: " << coder_lut.size();
if (!coder_lut.empty()) {
for (std::vector<int>::const_iterator _i = coder_lut.begin(); _i != coder_lut.end(); _i++) {
unsigned int _temp = (unsigned int)(*_i);
//if (_temp!=0) std::cout << "DEBUG non-zero LUT!!!!!!!!!!!!!!!" << (*_i) << " " << _temp << std::endl;
//unsigned int _temp = 0;
_cfg.lut.push_back(_temp);
}
//_cfg.lut = _set.lut[lut_index];
for (const auto i : _coder.getLinearizationLUT(_detid, ootpu_lut)) {
_cfg.lut.push_back(i);
}

if (split_by_crate) {
_xml[row->crate]->addLut(_cfg, lut_checksums_xml);
_counter.count();
} else {
_xml[0]->addLut(_cfg, lut_checksums_xml);
_counter.count();
}
} //size of lut
if (split_by_crate) {
_xml[row->crate]->addLut(_cfg, lut_checksums_xml);
_counter.count();
} else {
_xml[0]->addLut(_cfg, lut_checksums_xml);
_counter.count();
}
//size of lut
}
}

edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
<< "Generating ZDC LUTs...DONE" << std::endl;

Expand Down
2 changes: 2 additions & 0 deletions Geometry/HcalTowerAlgo/interface/HcalTrigTowerGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
#include <vector>
class HcalTrigTowerDetId;
class HcalDetId;
class HcalZDCDetId;

class HcalTrigTowerGeometry {
public:
HcalTrigTowerGeometry(const HcalTopology* topology);

/// the mapping to and from DetIds
std::vector<HcalTrigTowerDetId> towerIds(const HcalDetId& cellId) const;
std::vector<HcalTrigTowerDetId> towerIds_ZDC(const HcalZDCDetId& cellId) const;
std::vector<HcalDetId> detIds(const HcalTrigTowerDetId&) const;

int firstHFTower(int version) const { return (version == 1) ? (30) : (29); }
Expand Down
16 changes: 16 additions & 0 deletions Geometry/HcalTowerAlgo/src/HcalTrigTowerGeometry.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "Geometry/HcalTowerAlgo/interface/HcalTrigTowerGeometry.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "DataFormats/HcalDetId/interface/HcalZDCDetId.h"
#include "DataFormats/HcalDetId/interface/HcalTrigTowerDetId.h"

#include <iostream>
Expand Down Expand Up @@ -81,6 +82,21 @@ std::vector<HcalTrigTowerDetId> HcalTrigTowerGeometry::towerIds(const HcalDetId&
return results;
}

std::vector<HcalTrigTowerDetId> HcalTrigTowerGeometry::towerIds_ZDC(const HcalZDCDetId& cellId) const {
std::vector<HcalTrigTowerDetId> results;

int ieta = cellId.zside() > 0 ? 42 : -42;
int iphi = 99;
int channelId = cellId.channel();
if (cellId.depth() != 1)
channelId += 5;

results.emplace_back(HcalTrigTowerDetId(ieta, channelId));
Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking: is it correct that the second argument is a channelId rather that a iphi?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's correct

results.emplace_back(HcalTrigTowerDetId(ieta, iphi));

return results;
}

std::vector<HcalDetId> HcalTrigTowerGeometry::detIds(const HcalTrigTowerDetId& hcalTrigTowerDetId) const {
// Written, tested by E. Berry (Princeton)
std::vector<HcalDetId> results;
Expand Down
Loading