CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    HLTHcalCalibTypeFilter
00004 // Class:      HLTHcalCalibTypeFilter
00005 // 
00013 //
00014 // Original Author:  Bryan DAHMES
00015 //         Created:  Tue Jan 22 13:55:00 CET 2008
00016 // $Id: HLTHcalCalibTypeFilter.cc,v 1.8 2009/08/27 13:33:47 gruen 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 
00041 #include "HLTrigger/special/interface/HLTHcalCalibTypeFilter.h"
00042 
00043 //
00044 // constructors and destructor
00045 //
00046 HLTHcalCalibTypeFilter::HLTHcalCalibTypeFilter(const edm::ParameterSet& iConfig)
00047 {
00048   //now do what ever initialization is needed
00049 
00050   DataInputTag_ = iConfig.getParameter<edm::InputTag>("InputTag") ;
00051   Summary_      = iConfig.getUntrackedParameter<bool>("FilterSummary",false) ;
00052   CalibTypes_   = iConfig.getParameter< std::vector<int> >("CalibTypes") ; 
00053 }
00054 
00055 
00056 HLTHcalCalibTypeFilter::~HLTHcalCalibTypeFilter()
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 HLTHcalCalibTypeFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00072 {
00073   using namespace edm;
00074   
00075   edm::Handle<FEDRawDataCollection> rawdata;  
00076   iEvent.getByLabel(DataInputTag_,rawdata);
00077   
00078   // checking FEDs for calibration information
00079   int calibType = -1 ; int numEmptyFEDs = 0 ; 
00080   std::vector<int> calibTypeCounter(8,0) ;
00081   for (int i=FEDNumbering::MINHCALFEDID;
00082        i<=FEDNumbering::MAXHCALFEDID; i++) {
00083       const FEDRawData& fedData = rawdata->FEDData(i) ; 
00084       if ( fedData.size() < 24 ) numEmptyFEDs++ ; 
00085       if ( fedData.size() < 24 ) continue ; 
00086       int value = ((const HcalDCCHeader*)(fedData.data()))->getCalibType() ; 
00087       calibTypeCounter.at(value)++ ; // increment the counter for this calib type
00088   }
00089   int maxCount = 0 ;
00090   int numberOfFEDIds = FEDNumbering::MAXHCALFEDID - FEDNumbering::MINHCALFEDID + 1 ; 
00091   for (unsigned int i=0; i<calibTypeCounter.size(); i++) {
00092       if ( calibTypeCounter.at(i) > maxCount ) { calibType = i ; maxCount = calibTypeCounter.at(i) ; } 
00093       if ( maxCount == numberOfFEDIds ) break ;
00094   }
00095   if ( calibType < 0 ) return false ; // No HCAL FEDs, thus no calibration type
00096   if ( maxCount != (numberOfFEDIds-numEmptyFEDs) )
00097       edm::LogWarning("HLTHcalCalibTypeFilter") << "Conflicting calibration types found.  Assigning type " 
00098                                              << calibType ; 
00099   LogDebug("HLTHcalCalibTypeFilter") << "Calibration type is: " << calibType ; 
00100   eventsByType.at(calibType)++ ;
00101   for (unsigned int i=0; i<CalibTypes_.size(); i++) 
00102       if ( calibType == CalibTypes_.at(i) ) return true ;
00103   return false ; 
00104 }
00105 
00106 // ------------ method called once each job just before starting event loop  ------------
00107 void 
00108 HLTHcalCalibTypeFilter::beginJob(void)
00109 {
00110   eventsByType.clear() ; 
00111   eventsByType.resize(8,0) ; 
00112 }
00113 
00114 // ------------ method called once each job just after ending the event loop  ------------
00115 void 
00116 HLTHcalCalibTypeFilter::endJob() {
00117   if ( Summary_ )
00118     edm::LogWarning("HLTHcalCalibTypeFilter") << "Summary of filter decisions: " 
00119                                            << eventsByType.at(hc_Null) << "(No Calib), " 
00120                                            << eventsByType.at(hc_Pedestal) << "(Pedestal), " 
00121                                            << eventsByType.at(hc_RADDAM) << "(RADDAM), " 
00122                                            << eventsByType.at(hc_HBHEHPD) << "(HBHE/HPD), " 
00123                                            << eventsByType.at(hc_HOHPD) << "(HO/HPD), " 
00124                                            << eventsByType.at(hc_HFPMT) << "(HF/PMT)" ;  
00125 }