Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:12

0001 #include "CalibFormats/HcalObjects/interface/HcalNominalCoder.h"
0002 
0003 void HcalNominalCoder::adc2fC(const HBHEDataFrame& df, CaloSamples& lf) const {
0004   lf = CaloSamples(df.id(), df.size());
0005   for (int i = 0; i < df.size(); i++)
0006     lf[i] = df[i].nominal_fC();
0007   lf.setPresamples(df.presamples());
0008 }
0009 void HcalNominalCoder::adc2fC(const HODataFrame& df, CaloSamples& lf) const {
0010   lf = CaloSamples(df.id(), df.size());
0011   for (int i = 0; i < df.size(); i++)
0012     lf[i] = df[i].nominal_fC();
0013   lf.setPresamples(df.presamples());
0014 }
0015 void HcalNominalCoder::adc2fC(const HFDataFrame& df, CaloSamples& lf) const {
0016   lf = CaloSamples(df.id(), df.size());
0017   for (int i = 0; i < df.size(); i++)
0018     lf[i] = df[i].nominal_fC();
0019   lf.setPresamples(df.presamples());
0020 }
0021 void HcalNominalCoder::adc2fC(const ZDCDataFrame& df, CaloSamples& lf) const {
0022   lf = CaloSamples(df.id(), df.size());
0023   for (int i = 0; i < df.size(); i++)
0024     lf[i] = df[i].nominal_fC();
0025   lf.setPresamples(df.presamples());
0026 }
0027 void HcalNominalCoder::adc2fC(const HcalCalibDataFrame& df, CaloSamples& lf) const {
0028   lf = CaloSamples(df.id(), df.size());
0029   for (int i = 0; i < df.size(); i++)
0030     lf[i] = df[i].nominal_fC();
0031   lf.setPresamples(df.presamples());
0032 }
0033 
0034 namespace HcalNominalCoderTemplate {
0035   template <class Digi>
0036   void process(const CaloSamples& clf, Digi& df, int fCapIdOffset) {
0037     df = Digi(clf.id());
0038     df.setSize(clf.size());
0039     df.setPresamples(clf.presamples());
0040     for (int i = 0; i < clf.size(); i++) {
0041       int capId = (fCapIdOffset + i) % 4;
0042       for (int q = 1; q < 128; q++) {
0043         df.setSample(i, HcalQIESample(q, capId, 0, 0));
0044         if (df[i].nominal_fC() > clf[i]) {
0045           df.setSample(i, HcalQIESample(q - 1, capId, 0, 0));
0046           break;
0047         }
0048       }
0049     }
0050   }
0051 }  // namespace HcalNominalCoderTemplate
0052 
0053 void HcalNominalCoder::fC2adc(const CaloSamples& clf, HBHEDataFrame& df, int fCapIdOffset) const {
0054   HcalNominalCoderTemplate::process(clf, df, fCapIdOffset);
0055 }
0056 void HcalNominalCoder::fC2adc(const CaloSamples& clf, HFDataFrame& df, int fCapIdOffset) const {
0057   HcalNominalCoderTemplate::process(clf, df, fCapIdOffset);
0058 }
0059 void HcalNominalCoder::fC2adc(const CaloSamples& clf, HODataFrame& df, int fCapIdOffset) const {
0060   HcalNominalCoderTemplate::process(clf, df, fCapIdOffset);
0061 }
0062 void HcalNominalCoder::fC2adc(const CaloSamples& clf, ZDCDataFrame& df, int fCapIdOffset) const {
0063   HcalNominalCoderTemplate::process(clf, df, fCapIdOffset);
0064 }
0065 void HcalNominalCoder::fC2adc(const CaloSamples& clf, HcalCalibDataFrame& df, int fCapIdOffset) const {
0066   HcalNominalCoderTemplate::process(clf, df, fCapIdOffset);
0067 }