Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <string>
00023 #include <iostream>
00024 #include <memory>
00025
00026
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
00045
00046 HLTHcalCalibTypeFilter::HLTHcalCalibTypeFilter(const edm::ParameterSet& iConfig)
00047 {
00048
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
00060
00061
00062 }
00063
00064
00065
00066
00067
00068
00069
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
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)++ ;
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 ;
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
00107 void
00108 HLTHcalCalibTypeFilter::beginJob(void)
00109 {
00110 eventsByType.clear() ;
00111 eventsByType.resize(8,0) ;
00112 }
00113
00114
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 }