File indexing completed on 2024-04-06 12:05:37
0001 #include "DPGAnalysis/HcalNanoAOD/interface/QIE11DigiSortedTable.h"
0002
0003 QIE11DigiSortedTable::QIE11DigiSortedTable(const std::vector<HcalDetId>& dids, const unsigned int nTS) {
0004 dids_ = dids;
0005 for (std::vector<HcalDetId>::const_iterator it_did = dids_.begin(); it_did != dids_.end(); ++it_did) {
0006 did_indexmap_[*it_did] = (unsigned int)(it_did - dids_.begin());
0007 }
0008
0009 nTS_ = nTS;
0010 ietas_.resize(dids_.size());
0011 iphis_.resize(dids_.size());
0012 subdets_.resize(dids_.size());
0013 depths_.resize(dids_.size());
0014 rawIds_.resize(dids_.size());
0015 linkErrors_.resize(dids_.size());
0016 capidErrors_.resize(dids_.size());
0017 flags_.resize(dids_.size());
0018 sois_.resize(dids_.size());
0019 valids_.resize(dids_.size());
0020 sipmTypes_.resize(dids_.size());
0021
0022 adcs_.resize(nTS_, std::vector<int>(dids_.size()));
0023 fcs_.resize(nTS_, std::vector<float>(dids_.size()));
0024 pedestalfcs_.resize(nTS_, std::vector<float>(dids_.size()));
0025 tdcs_.resize(nTS_, std::vector<int>(dids_.size()));
0026 capids_.resize(nTS_, std::vector<int>(dids_.size()));
0027 }
0028
0029 void QIE11DigiSortedTable::add(const QIE11DataFrame* digi, const edm::ESHandle<HcalDbService>& dbService) {
0030 HcalDetId did = digi->detid();
0031 unsigned int index = did_indexmap_.at(did);
0032
0033 CaloSamples digiCaloSamples = hcaldqm::utilities::loadADC2fCDB<QIE11DataFrame>(dbService, did, *digi);
0034 HcalCalibrations calibrations = dbService->getHcalCalibrations(did);
0035
0036 ietas_[index] = did.ieta();
0037 iphis_[index] = did.iphi();
0038 subdets_[index] = did.subdet();
0039 depths_[index] = did.depth();
0040 rawIds_[index] = did.rawId();
0041 linkErrors_[index] = digi->linkError();
0042 capidErrors_[index] = digi->capidError();
0043 flags_[index] = digi->flags();
0044 sipmTypes_[index] = (uint8_t)dbService->getHcalSiPMParameter(did)->getType();
0045
0046 for (unsigned int iTS = 0; iTS < (unsigned int)digi->samples(); ++iTS) {
0047 if ((*digi)[iTS].soi()) {
0048 sois_[index] = iTS;
0049 }
0050 adcs_[iTS][index] = (*digi)[iTS].adc();
0051 tdcs_[iTS][index] = (*digi)[iTS].tdc();
0052 capids_[iTS][index] = (*digi)[iTS].capid();
0053 fcs_[iTS][index] = digiCaloSamples[iTS];
0054 pedestalfcs_[iTS][index] = calibrations.pedestal((*digi)[iTS].capid());
0055 }
0056 valids_[index] = true;
0057 }
0058
0059 void QIE11DigiSortedTable::reset() {
0060 std::fill(ietas_.begin(), ietas_.end(), 0);
0061 std::fill(iphis_.begin(), iphis_.end(), 0);
0062 std::fill(subdets_.begin(), subdets_.end(), 0);
0063 std::fill(depths_.begin(), depths_.end(), 0);
0064 std::fill(rawIds_.begin(), rawIds_.end(), 0);
0065 std::fill(linkErrors_.begin(), linkErrors_.end(), false);
0066 std::fill(capidErrors_.begin(), capidErrors_.end(), false);
0067 std::fill(flags_.begin(), flags_.end(), 0);
0068 std::fill(sois_.begin(), sois_.end(), 0);
0069 std::fill(valids_.begin(), valids_.end(), false);
0070 std::fill(sipmTypes_.begin(), sipmTypes_.end(), 0);
0071
0072 for (auto& it : adcs_) {
0073 std::fill(it.begin(), it.end(), 0);
0074 }
0075 for (auto& it : fcs_) {
0076 std::fill(it.begin(), it.end(), 0);
0077 }
0078 for (auto& it : pedestalfcs_) {
0079 std::fill(it.begin(), it.end(), 0);
0080 }
0081 for (auto& it : tdcs_) {
0082 std::fill(it.begin(), it.end(), 0);
0083 }
0084 for (auto& it : capids_) {
0085 std::fill(it.begin(), it.end(), 0);
0086 }
0087 }