File indexing completed on 2024-04-06 12:05:37
0001 #include "DPGAnalysis/HcalNanoAOD/interface/QIE10DigiSortedTable.h"
0002
0003 QIE10DigiSortedTable::QIE10DigiSortedTable(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 flags_.resize(dids_.size());
0017 sois_.resize(dids_.size());
0018 valids_.resize(dids_.size());
0019
0020
0021 adcs_.resize(nTS_, std::vector<int>(dids_.size()));
0022 fcs_.resize(nTS_, std::vector<float>(dids_.size()));
0023 pedestalfcs_.resize(nTS_, std::vector<float>(dids_.size()));
0024 tdcs_.resize(nTS_, std::vector<int>(dids_.size()));
0025 capids_.resize(nTS_, std::vector<int>(dids_.size()));
0026 oks_.resize(nTS_, std::vector<bool>(dids_.size()));
0027 }
0028
0029 void QIE10DigiSortedTable::add(const QIE10DataFrame* 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<QIE10DataFrame>(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 flags_[index] = digi->flags();
0043
0044
0045 for (unsigned int iTS = 0; iTS < (unsigned int)digi->samples(); ++iTS) {
0046 if ((*digi)[iTS].soi()) {
0047 sois_[index] = iTS;
0048 }
0049 oks_[iTS][index] = (*digi)[iTS].ok();
0050 adcs_[iTS][index] = (*digi)[iTS].adc();
0051 tdcs_[iTS][index] = (*digi)[iTS].le_tdc();
0052
0053 capids_[iTS][index] = (*digi)[iTS].capid();
0054 fcs_[iTS][index] = digiCaloSamples[iTS];
0055 pedestalfcs_[iTS][index] = calibrations.pedestal((*digi)[iTS].capid());
0056 }
0057 valids_[index] = true;
0058 }
0059
0060 void QIE10DigiSortedTable::reset() {
0061 std::fill(ietas_.begin(), ietas_.end(), 0);
0062 std::fill(iphis_.begin(), iphis_.end(), 0);
0063 std::fill(subdets_.begin(), subdets_.end(), 0);
0064 std::fill(depths_.begin(), depths_.end(), 0);
0065 std::fill(rawIds_.begin(), rawIds_.end(), 0);
0066 std::fill(linkErrors_.begin(), linkErrors_.end(), 0);
0067 std::fill(flags_.begin(), flags_.end(), 0);
0068 std::fill(sois_.begin(), sois_.end(), -1);
0069 std::fill(valids_.begin(), valids_.end(), false);
0070
0071
0072 for (unsigned int i = 0; i < nTS_; ++i) {
0073 for (unsigned int j = 0; j < dids_.size(); ++j) {
0074 adcs_[i][j] = 0;
0075 fcs_[i][j] = 0.;
0076 pedestalfcs_[i][j] = 0.;
0077 tdcs_[i][j] = 0;
0078 capids_[i][j] = 0;
0079 oks_[i][j] = false;
0080 }
0081 }
0082 }