File indexing completed on 2024-04-06 11:58:11
0001
0002
0003
0004
0005
0006 #include "CondFormats/CastorObjects/interface/CastorQIEShape.h"
0007 #include "CondFormats/CastorObjects/interface/CastorQIECoder.h"
0008
0009 #include "CalibFormats/CastorObjects/interface/CastorCoderDb.h"
0010
0011 CastorCoderDb::CastorCoderDb(const CastorQIECoder& fCoder, const CastorQIEShape& fShape)
0012 : mCoder(&fCoder), mShape(&fShape) {}
0013
0014 template <class Digi>
0015 void CastorCoderDb::adc2fC_(const Digi& df, CaloSamples& clf) const {
0016 clf = CaloSamples(df.id(), df.size());
0017 for (int i = 0; i < df.size(); i++) {
0018 clf[i] = mCoder->charge(*mShape, df[i].adc(), df[i].capid());
0019 }
0020 clf.setPresamples(df.presamples());
0021 }
0022
0023 template <class Digi>
0024 void CastorCoderDb::fC2adc_(const CaloSamples& clf, Digi& df, int fCapIdOffset) const {
0025 df = Digi(clf.id());
0026 df.setSize(clf.size());
0027 df.setPresamples(clf.presamples());
0028 for (int i = 0; i < clf.size(); i++) {
0029 int capId = (fCapIdOffset + i) % 4;
0030 df.setSample(i, HcalQIESample(mCoder->adc(*mShape, clf[i], capId), capId, 0, 0));
0031 }
0032 }
0033
0034 void CastorCoderDb::adc2fC(const CastorDataFrame& df, CaloSamples& lf) const { adc2fC_(df, lf); }
0035
0036 void CastorCoderDb::fC2adc(const CaloSamples& clf, CastorDataFrame& df, int fCapIdOffset) const {
0037 fC2adc_(clf, df, fCapIdOffset);
0038 }