Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:14:35

0001 #include "EventFilter/CastorRawToDigi/interface/CastorDataFrameFilter.h"
0002 
0003 namespace CastorDataFrameFilter_impl {
0004 
0005   template <class DataFrame>
0006   bool check(const DataFrame& df, bool capcheck, bool dvercheck) {
0007     if (capcheck || dvercheck) {
0008       int lastcapid = 0, capid = 0;
0009       for (int i = 0; i < df.size(); i++) {
0010         capid = df[i].capid();
0011         if (capcheck && i != 0 && ((lastcapid + 1) % 4) != capid)
0012           return false;
0013         if (dvercheck && (df[i].er() || !df[i].dv()))
0014           return false;
0015         lastcapid = capid;
0016       }
0017     }
0018     return true;
0019   }
0020 
0021   template <class DataFrame>
0022   double energySum(const DataFrame& df, int fs, int ls) {
0023     double es = 0;
0024     for (int i = fs; i <= ls && i <= df.size(); i++)
0025       es += df[i].nominal_fC();
0026     return es;
0027   }
0028 
0029 }  // namespace CastorDataFrameFilter_impl
0030 
0031 CastorDataFrameFilter::CastorDataFrameFilter(
0032     bool requireCapid, bool requireDVER, bool energyFilter, int firstSample, int lastSample, double minAmpl)
0033     : requireCapid_(requireCapid),
0034       requireDVER_(requireDVER),
0035       energyFilter_(energyFilter),
0036       firstSample_(firstSample),
0037       lastSample_(lastSample),
0038       minimumAmplitude_(minAmpl) {}
0039 
0040 CastorDigiCollection CastorDataFrameFilter::filter(const CastorDigiCollection& incol, HcalUnpackerReport& r) {
0041   CastorDigiCollection output;
0042   for (CastorDigiCollection::const_iterator i = incol.begin(); i != incol.end(); i++) {
0043     if (!CastorDataFrameFilter_impl::check(*i, requireCapid_, requireDVER_))
0044       r.countBadQualityDigi();
0045     else if (!energyFilter_ || minimumAmplitude_ < CastorDataFrameFilter_impl::energySum(*i, firstSample_, lastSample_))
0046       output.push_back(*i);
0047   }
0048   return output;
0049 }
0050 
0051 bool CastorDataFrameFilter::active() const { return requireCapid_ | requireDVER_ | energyFilter_; }