Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-08-30 22:38:35

0001 // -*- C++ -*-
0002 //
0003 // Package:    EcalFEDErrorFilter
0004 // Class:      EcalFEDErrorFilter
0005 //
0006 /**\class EcalFEDErrorFilter EcalFEDErrorFilter.cc filter/EcalFEDErrorFilter/src/EcalFEDErrorFilter.cc
0007 
0008 Description: <one line class summary>
0009 
0010 Implementation:
0011 <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Giovanni FRANZONI
0015 //         Created:  Tue Jan 22 13:55:00 CET 2008
0016 //
0017 //
0018 
0019 #include "CaloOnlineTools/EcalTools/plugins/EcalFEDErrorFilter.h"
0020 
0021 //
0022 // constructors and destructor
0023 //
0024 EcalFEDErrorFilter::EcalFEDErrorFilter(const edm::ParameterSet& iConfig)
0025     : HLTFilter(iConfig),
0026       dataToken_(consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("InputLabel"))) {
0027   //now do what ever initialization is needed
0028   fedUnpackList_ = iConfig.getUntrackedParameter<std::vector<int> >("FEDs", std::vector<int>());
0029   if (fedUnpackList_.empty())
0030     for (int i = FEDNumbering::MINECALFEDID; i <= FEDNumbering::MAXECALFEDID; i++)
0031       fedUnpackList_.push_back(i);
0032 }
0033 
0034 EcalFEDErrorFilter::~EcalFEDErrorFilter() {
0035   // do anything here that needs to be done at desctruction time
0036   // (e.g. close files, deallocate resources etc.)
0037 }
0038 
0039 //
0040 // member functions
0041 //
0042 
0043 // ------------ method called on each new Event  ------------
0044 bool EcalFEDErrorFilter::hltFilter(edm::Event& iEvent,
0045                                    const edm::EventSetup& iSetup,
0046                                    trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0047   using namespace edm;
0048 
0049   const edm::Handle<FEDRawDataCollection>& rawdata = iEvent.getHandle(dataToken_);
0050 
0051   // get fed raw data and SM id
0052 
0053   // loop over FEDS
0054   for (std::vector<int>::const_iterator i = fedUnpackList_.begin(); i != fedUnpackList_.end(); i++) {
0055     // get fed raw data and SM id
0056     const FEDRawData& fedData = rawdata->FEDData(*i);
0057     int length = fedData.size() / sizeof(uint64_t);
0058 
0059     //    LogDebug("EcalRawToDigi") << "raw data length: " << length ;
0060     //if data size is not null interpret data
0061     if (length >= 1) {
0062       uint64_t* pData = (uint64_t*)(fedData.data());
0063       //When crc error is found return true
0064       uint64_t* fedTrailer = pData + (length - 1);
0065       bool crcError = (*fedTrailer >> 2) & 0x1;
0066       if (crcError) {
0067         edm::LogVerbatim("EcalTools") << "CRCERROR in FED " << *i << " trailer is " << std::setw(8) << std::hex
0068                                       << (*fedTrailer) << std::dec;
0069         return true;
0070       }
0071     }
0072   }
0073 
0074   return false;
0075 }