Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:37

0001 #include "DPGAnalysis/HcalNanoAOD/interface/HODigiSortedTable.h"
0002 
0003 HODigiSortedTable::HODigiSortedTable(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 
0011   ietas_.resize(dids_.size());
0012   iphis_.resize(dids_.size());
0013   subdets_.resize(dids_.size());
0014   depths_.resize(dids_.size());
0015   rawIds_.resize(dids_.size());
0016   fiberIdleOffsets_.resize(dids_.size());
0017   sois_.resize(dids_.size());
0018   valids_.resize(dids_.size());
0019 
0020   adcs_.resize(nTS_, std::vector<int>(dids_.size()));
0021   fcs_.resize(nTS_, std::vector<float>(dids_.size()));
0022   pedestalfcs_.resize(nTS_, std::vector<float>(dids_.size()));
0023   capids_.resize(nTS_, std::vector<int>(dids_.size()));
0024   fibers_.resize(nTS_, std::vector<int>(dids_.size()));
0025   fiberChans_.resize(nTS_, std::vector<int>(dids_.size()));
0026   dvs_.resize(nTS_, std::vector<int>(dids_.size()));
0027   ers_.resize(nTS_, std::vector<int>(dids_.size()));
0028 }
0029 
0030 void HODigiSortedTable::add(const HODataFrame* digi, const edm::ESHandle<HcalDbService>& dbService) {
0031   HcalDetId did = digi->id();
0032   unsigned int index = did_indexmap_.at(did);
0033 
0034   CaloSamples digiCaloSamples = hcaldqm::utilities::loadADC2fCDB<HODataFrame>(dbService, did, *digi);
0035   HcalCalibrations calibrations = dbService->getHcalCalibrations(did);
0036 
0037   ietas_[index] = did.ieta();
0038   iphis_[index] = did.iphi();
0039   subdets_[index] = did.subdet();
0040   depths_[index] = did.depth();
0041   rawIds_[index] = did.rawId();
0042   fiberIdleOffsets_[index] = digi->fiberIdleOffset();
0043   sois_[index] = digi->presamples();
0044 
0045   for (unsigned int iTS = 0; iTS < (unsigned int)digi->size(); ++iTS) {
0046     adcs_[iTS][index] = digi->sample(iTS).adc();
0047     capids_[iTS][index] = digi->sample(iTS).capid();
0048     fcs_[iTS][index] = digiCaloSamples[iTS];
0049     pedestalfcs_[iTS][index] = calibrations.pedestal(digi->sample(iTS).capid());
0050     dvs_[iTS][index] = digi->sample(iTS).dv();
0051     ers_[iTS][index] = digi->sample(iTS).er();
0052   }
0053   valids_[index] = true;
0054 }
0055 
0056 void HODigiSortedTable::reset() {
0057   std::fill(ietas_.begin(), ietas_.end(), 0);
0058   std::fill(iphis_.begin(), iphis_.end(), -100);
0059   std::fill(subdets_.begin(), subdets_.end(), -1);
0060   std::fill(depths_.begin(), depths_.end(), 0);
0061   std::fill(rawIds_.begin(), rawIds_.end(), 0);
0062   std::fill(fiberIdleOffsets_.begin(), fiberIdleOffsets_.end(), 0);
0063   std::fill(sois_.begin(), sois_.end(), -1);
0064   std::fill(valids_.begin(), valids_.end(), false);
0065 
0066   for (unsigned int i = 0; i < nTS_; ++i) {
0067     for (unsigned int j = 0; j < dids_.size(); ++j) {
0068       adcs_[i][j] = 0;
0069       fcs_[i][j] = 0;
0070       pedestalfcs_[i][j] = 0;
0071       capids_[i][j] = 0;
0072       fibers_[i][j] = 0;
0073       fiberChans_[i][j] = 0;
0074       dvs_[i][j] = 0;
0075       ers_[i][j] = 0;
0076     }
0077   }
0078 }