CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/HLTrigger/special/src/HLTHcalNZSFilter.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    HLTHcalNZSFilter
00004 // Class:      HLTHcalNZSFilter
00005 // 
00013 //
00014 // Original Author:  Bryan DAHMES
00015 //         Created:  Tue Jan 22 13:55:00 CET 2008
00016 // $Id: HLTHcalNZSFilter.cc,v 1.9 2009/10/06 14:05:56 fwyzard Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <string>
00023 #include <iostream>
00024 #include <memory>
00025 
00026 // user include files
00027 #include "FWCore/Framework/interface/Frameworkfwd.h"
00028 
00029 #include "HLTrigger/HLTcore/interface/HLTFilter.h"
00030 #include "FWCore/Framework/interface/Event.h"
00031 #include "FWCore/Framework/interface/MakerMacros.h"
00032 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00033 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00034 
00035 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
00036 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00037 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00038 #include "DataFormats/HcalDigi/interface/HcalCalibrationEventTypes.h"
00039 #include "EventFilter/HcalRawToDigi/interface/HcalDCCHeader.h"
00040 #include "EventFilter/HcalRawToDigi/interface/HcalHTRData.h"
00041 
00042 #include "HLTrigger/special/interface/HLTHcalNZSFilter.h"
00043 
00044 //
00045 // constructors and destructor
00046 //
00047 HLTHcalNZSFilter::HLTHcalNZSFilter(const edm::ParameterSet& iConfig)
00048 {
00049   //now do what ever initialization is needed
00050 
00051   dataInputTag_ = iConfig.getParameter<edm::InputTag>("InputTag") ;
00052   summary_      = iConfig.getUntrackedParameter<bool>("FilterSummary",false) ;
00053 }
00054 
00055 
00056 HLTHcalNZSFilter::~HLTHcalNZSFilter()
00057 {
00058  
00059   // do anything here that needs to be done at desctruction time
00060   // (e.g. close files, deallocate resources etc.)
00061 
00062 }
00063 
00064 
00065 //
00066 // member functions
00067 //
00068 
00069 // ------------ method called on each new Event  ------------
00070 bool
00071 HLTHcalNZSFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00072 {
00073   using namespace edm;
00074 
00075   // MC treatment for this filter (NZS not fully emulated in HTR for MC)
00076   if (!iEvent.isRealData()) return false;
00077 
00078   edm::Handle<FEDRawDataCollection> rawdata;  
00079   iEvent.getByLabel(dataInputTag_,rawdata);
00080 
00081   int nFEDs = 0 ; int nNZSfed = 0 ; int nZSfed = 0 ; 
00082   for (int i=FEDNumbering::MINHCALFEDID; i<=FEDNumbering::MAXHCALFEDID; i++) {
00083       const FEDRawData& fedData = rawdata->FEDData(i) ; 
00084       if ( fedData.size() < 24 ) continue ; 
00085       nFEDs++ ;
00086       
00087       // Check for Zero-suppression
00088       HcalHTRData htr;
00089       const HcalDCCHeader* dccHeader = (const HcalDCCHeader*)(fedData.data()) ; 
00090       int nZS = 0 ; int nUS = 0 ; int nSpigot = 0 ; 
00091       for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) {    
00092           if (!dccHeader->getSpigotPresent(spigot)) continue;
00093           
00094           // Load the given decoder with the pointer and length from this spigot.
00095           dccHeader->getSpigotData(spigot,htr, fedData.size()); 
00096           if ((htr.getFirmwareFlavor()&0xE0)==0x80) continue ; // This is TTP data
00097 
00098           nSpigot++ ; 
00099           // check min length, correct wordcount, empty event, or total length if histo event.
00100           if ( htr.isUnsuppressed() ) nUS++ ; 
00101           else nZS++ ; 
00102       }
00103 
00104       if ( nUS == nSpigot ) nNZSfed++ ; 
00105       else {
00106           nZSfed++ ; 
00107           if ( nUS > 0 ) LogWarning("HLTHcalNZSFilter") << "Mixture of ZS(" << nZS
00108                                                         << ") and NZS(" << nUS
00109                                                         << ") spigots in FED " << i ;
00110       }
00111   }
00112   
00113   if ( (nNZSfed == nFEDs) && (nFEDs > 0) ) { eventsNZS_++ ; return true ; }
00114   else {
00115       if ( nNZSfed > 0 ) LogWarning("HLTHcalNZSFilter") << "Mixture of ZS(" << nZSfed
00116                                                         << ") and NZS(" << nNZSfed
00117                                                         << ") FEDs in this event" ; 
00118       return false ;
00119   }
00120 
00121 }
00122 
00123 // ------------ method called once each job just before starting event loop  ------------
00124 void 
00125 HLTHcalNZSFilter::beginJob(void)
00126 {
00127   eventsNZS_ = 0 ; 
00128 }
00129 
00130 // ------------ method called once each job just after ending the event loop  ------------
00131 void 
00132 HLTHcalNZSFilter::endJob(void) {
00133   if ( summary_ ) edm::LogWarning("HLTHcalNZSFilter") << "Kept " << eventsNZS_ << " non-ZS events" ;  
00134 }