Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:20

0001 /** \class HcalCoderDB

0002 

0003     coder which uses DB services to convert to fC

0004     $Author: ratnikov

0005 */
0006 
0007 #include "CondFormats/HcalObjects/interface/HcalQIECoder.h"
0008 #include "CalibFormats/HcalObjects/interface/HcalCoderDb.h"
0009 
0010 HcalCoderDb::HcalCoderDb(const HcalQIECoder& fCoder, const HcalQIEShape& fShape) : mCoder(&fCoder), mShape(&fShape) {}
0011 
0012 template <class Digi>
0013 void HcalCoderDb::adc2fC_(const Digi& df, CaloSamples& clf) const {
0014   clf = CaloSamples(df.id(), df.size());
0015   for (int i = 0; i < df.size(); i++) {
0016     clf[i] = mCoder->charge(*mShape, df[i].adc(), df[i].capid());
0017   }
0018   clf.setPresamples(df.presamples());
0019 }
0020 
0021 template <>
0022 void HcalCoderDb::adc2fC_<QIE10DataFrame>(const QIE10DataFrame& df, CaloSamples& clf) const {
0023   clf = CaloSamples(df.id(), df.samples());
0024   for (int i = 0; i < df.samples(); i++) {
0025     clf[i] = mCoder->charge(*mShape, df[i].adc(), df[i].capid());
0026     if (df[i].soi())
0027       clf.setPresamples(i);
0028   }
0029 }
0030 
0031 template <>
0032 void HcalCoderDb::adc2fC_<QIE11DataFrame>(const QIE11DataFrame& df, CaloSamples& clf) const {
0033   clf = CaloSamples(df.id(), df.samples());
0034   for (int i = 0; i < df.samples(); i++) {
0035     clf[i] = mCoder->charge(*mShape, df[i].adc(), df[i].capid());
0036     if (df[i].soi())
0037       clf.setPresamples(i);
0038   }
0039 }
0040 
0041 template <class Digi>
0042 void HcalCoderDb::fC2adc_(const CaloSamples& clf, Digi& df, int fCapIdOffset) const {
0043   df = Digi(clf.id());
0044   df.setSize(clf.size());
0045   df.setPresamples(clf.presamples());
0046   for (int i = 0; i < clf.size(); i++) {
0047     int capId = (fCapIdOffset + i) % 4;
0048     df.setSample(i, HcalQIESample(mCoder->adc(*mShape, clf[i], capId), capId, 0, 0));
0049   }
0050 }
0051 
0052 template <>
0053 void HcalCoderDb::fC2adc_<QIE10DataFrame>(const CaloSamples& clf, QIE10DataFrame& df, int fCapIdOffset) const {
0054   int presample = clf.presamples();
0055   for (int i = 0; i < clf.size(); i++) {
0056     int capId = (fCapIdOffset + i) % 4;
0057     bool soi = (i == presample);
0058     df.setSample(i, mCoder->adc(*mShape, clf[i], capId), 0, 0, capId, soi, true);
0059   }
0060 }
0061 
0062 template <>
0063 void HcalCoderDb::fC2adc_<QIE11DataFrame>(const CaloSamples& clf, QIE11DataFrame& df, int fCapIdOffset) const {
0064   int presample = clf.presamples();
0065   df.setCapid0(fCapIdOffset % 4);
0066   for (int i = 0; i < clf.size(); i++) {
0067     int capId = (fCapIdOffset + i) % 4;
0068     bool soi = (i == presample);
0069     df.setSample(i, mCoder->adc(*mShape, clf[i], capId), 0, soi);
0070   }
0071 }
0072 
0073 void HcalCoderDb::adc2fC(const HBHEDataFrame& df, CaloSamples& lf) const { adc2fC_(df, lf); }
0074 void HcalCoderDb::adc2fC(const HODataFrame& df, CaloSamples& lf) const { adc2fC_(df, lf); }
0075 void HcalCoderDb::adc2fC(const HFDataFrame& df, CaloSamples& lf) const { adc2fC_(df, lf); }
0076 void HcalCoderDb::adc2fC(const ZDCDataFrame& df, CaloSamples& lf) const { adc2fC_(df, lf); }
0077 void HcalCoderDb::adc2fC(const HcalCalibDataFrame& df, CaloSamples& lf) const { adc2fC_(df, lf); }
0078 void HcalCoderDb::adc2fC(const QIE10DataFrame& df, CaloSamples& lf) const { adc2fC_(df, lf); }
0079 void HcalCoderDb::adc2fC(const QIE11DataFrame& df, CaloSamples& lf) const { adc2fC_(df, lf); }
0080 
0081 void HcalCoderDb::fC2adc(const CaloSamples& clf, HBHEDataFrame& df, int fCapIdOffset) const {
0082   fC2adc_(clf, df, fCapIdOffset);
0083 }
0084 void HcalCoderDb::fC2adc(const CaloSamples& clf, HFDataFrame& df, int fCapIdOffset) const {
0085   fC2adc_(clf, df, fCapIdOffset);
0086 }
0087 void HcalCoderDb::fC2adc(const CaloSamples& clf, HODataFrame& df, int fCapIdOffset) const {
0088   fC2adc_(clf, df, fCapIdOffset);
0089 }
0090 void HcalCoderDb::fC2adc(const CaloSamples& clf, ZDCDataFrame& df, int fCapIdOffset) const {
0091   fC2adc_(clf, df, fCapIdOffset);
0092 }
0093 void HcalCoderDb::fC2adc(const CaloSamples& clf, HcalCalibDataFrame& df, int fCapIdOffset) const {
0094   fC2adc_(clf, df, fCapIdOffset);
0095 }
0096 void HcalCoderDb::fC2adc(const CaloSamples& clf, QIE10DataFrame& df, int fCapIdOffset) const {
0097   fC2adc_(clf, df, fCapIdOffset);
0098 }
0099 void HcalCoderDb::fC2adc(const CaloSamples& clf, QIE11DataFrame& df, int fCapIdOffset) const {
0100   fC2adc_(clf, df, fCapIdOffset);
0101 }