CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CaloOnlineTools/EcalTools/plugins/EcalFEDErrorFilter.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    EcalFEDErrorFilter
00004 // Class:      EcalFEDErrorFilter
00005 // 
00013 //
00014 // Original Author:  Giovanni FRANZONI
00015 //         Created:  Tue Jan 22 13:55:00 CET 2008
00016 // $Id: EcalFEDErrorFilter.cc,v 1.4 2010/10/05 13:39:30 vlimant Exp $
00017 //
00018 //
00019 
00020 #include "CaloOnlineTools/EcalTools/plugins/EcalFEDErrorFilter.h"
00021 
00022 
00023 //
00024 // constructors and destructor
00025 //
00026 EcalFEDErrorFilter::EcalFEDErrorFilter(const edm::ParameterSet& iConfig)
00027 {
00028   //now do what ever initialization is needed
00029 
00030   DataLabel_     = iConfig.getParameter<edm::InputTag>("InputLabel");
00031   fedUnpackList_ = iConfig.getUntrackedParameter< std::vector<int> >("FEDs", std::vector<int>());
00032   if (fedUnpackList_.empty()) 
00033     for (int i=FEDNumbering::MINECALFEDID; i<=FEDNumbering::MAXECALFEDID; i++)
00034       fedUnpackList_.push_back(i);
00035 }
00036 
00037 
00038 EcalFEDErrorFilter::~EcalFEDErrorFilter()
00039 {
00040  
00041   // do anything here that needs to be done at desctruction time
00042   // (e.g. close files, deallocate resources etc.)
00043 
00044 }
00045 
00046 
00047 //
00048 // member functions
00049 //
00050 
00051 // ------------ method called on each new Event  ------------
00052 bool
00053 EcalFEDErrorFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00054 {
00055   using namespace edm;
00056 
00057   edm::Handle<FEDRawDataCollection> rawdata;  
00058   iEvent.getByLabel(DataLabel_,rawdata);
00059 
00060   // get fed raw data and SM id
00061 
00062   // loop over FEDS
00063   for (std::vector<int>::const_iterator i=fedUnpackList_.begin(); i!=fedUnpackList_.end(); i++) 
00064     {
00065 
00066       // get fed raw data and SM id
00067       const FEDRawData & fedData = rawdata->FEDData(*i);
00068       int length = fedData.size()/sizeof(uint64_t);
00069       
00070       //    LogDebug("EcalRawToDigi") << "raw data length: " << length ;
00071       //if data size is not null interpret data
00072       if ( length >= 1 )
00073         {
00074             uint64_t * pData = (uint64_t *)(fedData.data());
00075             //When crc error is found return true
00076             uint64_t * fedTrailer = pData + (length - 1);
00077             bool crcError = (*fedTrailer >> 2 ) & 0x1; 
00078             if (crcError)
00079               {
00080                 std::cout << "CRCERROR in FED " << *i << " trailer is " << std::setw(8)   << std::hex << (*fedTrailer) << std::endl;
00081                 return true;
00082               }
00083         }
00084     }
00085   
00086   return false;
00087 }