CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/L1Trigger/L1GctAnalyzer/interface/compareTotalEnergySums.h

Go to the documentation of this file.
00001 #ifndef compareTotalEnergySums_h
00002 #define compareTotalEnergySums_h
00003 
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h" 
00006 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h"
00007 
00008 #include "FWCore/Framework/interface/Frameworkfwd.h"
00009 #include "FWCore/Framework/interface/EDAnalyzer.h"
00010 
00011 #include "FWCore/Framework/interface/Event.h"
00012 #include "FWCore/Framework/interface/MakerMacros.h"
00013 
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 
00016 #include "FWCore/Utilities/interface/InputTag.h"
00017 
00018 #include "L1Trigger/L1GctAnalyzer/interface/GctErrorAnalyzerDefinitions.h"
00019 
00020 #include "TH2.h"
00021 #include "TH1.h"
00022 
00023 template <class T>
00024 class compareTotalEnergySums {
00025  public:
00026   compareTotalEnergySums(const T &data, const T &emu, const GctErrorAnalyzerMBxInfo &mbxparams);
00027   ~compareTotalEnergySums();
00028 
00029   bool doCompare(TH1I *errorFlag_hist_);
00030 
00031  private:  
00032   T data_, emu_;
00033   GctErrorAnalyzerMBxInfo mbxparams_;
00034 };
00035 
00036 template<class T>
00037 compareTotalEnergySums<T>::compareTotalEnergySums(const T &data, const T &emu, const GctErrorAnalyzerMBxInfo &mbxparams) :
00038   data_(data),
00039   emu_(emu),
00040   mbxparams_(mbxparams)    
00041 {
00042   //std::cout << "initialising..." << std::endl;
00043 }
00044 
00045 template<class T>
00046 compareTotalEnergySums<T>::~compareTotalEnergySums() {
00047   //anything need to be destructed?
00048 }
00049 
00050 template<class T>
00051 bool compareTotalEnergySums<T>::doCompare(TH1I *errorFlag_hist_) {
00052   
00053   bool errorFlag=0;
00054 
00055   for(unsigned int i=0; i < data_->size(); i++) {
00056     //check the GCTTrigBx is the one being considered
00057     if(data_->at(i).bx() != mbxparams_.GCTTrigBx) continue;
00058 
00059     for(unsigned int j=0; j < emu_->size(); j++) {
00060       //check the EmuTrigBx is the one being considered
00061       if(emu_->at(j).bx() != mbxparams_.EmuTrigBx) continue;
00062 
00063       //now check if both overflow bits (from the trigbx) are set
00064       if(data_->at(i).overFlow() && emu_->at(j).overFlow()) { 
00065         //if the overflow bits in data and emulator are set, that's enough to call a match
00066         errorFlag_hist_->Fill(0);
00067         return errorFlag;
00068       }
00069 
00070       //check if both over flow bits are not set and if both values are zero, and if so return the errorFlag
00071       //without making any modifications (a zero et match doesn't mean so much). 
00072       if(!data_->at(i).overFlow() && !emu_->at(j).overFlow() && data_->at(i).et() == 0 && emu_->at(j).et() == 0) return errorFlag;
00073 
00074       //now check if the values correspond, again with both overflow bits not set
00075       if(!data_->at(i).overFlow() && !emu_->at(j).overFlow() && data_->at(i).et() == emu_->at(j).et()) {
00076         //if they are both explicitly not set, and the resulting energies are identical, that's a match
00077         errorFlag_hist_->Fill(0);
00078         return errorFlag;
00079       }
00080 
00081       //otherwise, it's a fail
00082       errorFlag_hist_->Fill(1);
00083       errorFlag=1;
00084       return errorFlag;
00085     }
00086   }
00087   return errorFlag;
00088 }
00089 
00090 #endif