CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/L1Trigger/L1GctAnalyzer/interface/compareMissingEnergySums.h

Go to the documentation of this file.
00001 #ifndef compareMissingEnergySums_h
00002 #define compareMissingEnergySums_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 compareMissingEnergySums {
00025  public:
00026   compareMissingEnergySums(const T &data, const T &emu, const GctErrorAnalyzerMBxInfo &mbxparams);
00027   ~compareMissingEnergySums();
00028 
00029   bool doCompare(TH1I *errorFlag_hist_);
00030 
00031  private:  
00032   T data_, emu_;
00033   GctErrorAnalyzerMBxInfo mbxparams_;
00034 };
00035 
00036 template<class T>
00037 compareMissingEnergySums<T>::compareMissingEnergySums(const T &data, const T &emu, const GctErrorAnalyzerMBxInfo &mbxparams) :
00038   data_(data),
00039   emu_(emu),
00040   mbxparams_(mbxparams)
00041 {
00042 
00043 }
00044 
00045 template<class T>
00046 compareMissingEnergySums<T>::~compareMissingEnergySums() {
00047 
00048 }
00049 
00050 template<class T>
00051 bool compareMissingEnergySums<T>::doCompare(TH1I *errorFlag_hist_) {
00052 
00053   bool errorFlag=0;
00054   
00055   for(unsigned int i=0; i < data_->size(); i++) {
00056     if(data_->at(i).bx() != mbxparams_.GCTTrigBx) continue;
00057 
00058     for(unsigned int j=0; j < emu_->size(); j++) {
00059       if(emu_->at(j).bx() != mbxparams_.EmuTrigBx) continue;
00060 
00061       if(data_->at(i).overFlow() && emu_->at(j).overFlow()) {
00062         //if both overflow bits are set then = match
00063         errorFlag_hist_->Fill(0);
00064         return errorFlag;
00065       }
00066       
00067       //check that we consider non-zero candidates - if we don't, return (don't fill hist)
00068       if(!data_->at(i).overFlow() && !emu_->at(j).overFlow() && data_->at(i).et() == 0 && emu_->at(j).et() == 0) return errorFlag;
00069 
00070       if(!data_->at(i).overFlow() && !emu_->at(j).overFlow() && data_->at(i).et() == emu_->at(j).et() && data_->at(i).phi() == emu_->at(j).phi()) {
00071       //similarly, if the overflow bits are both off but the mag/phi agree = match
00072         errorFlag_hist_->Fill(0);
00073         return errorFlag;
00074       }
00075 
00076       if(!data_->at(i).overFlow() && !emu_->at(j).overFlow() && data_->at(i).et() == emu_->at(j).et() && data_->at(i).phi() != emu_->at(j).phi()) {
00077         //if the overflow bits are both off but only the mag agree = mag match
00078         errorFlag_hist_->Fill(1);
00079         return errorFlag=1;
00080       }
00081 
00082       if(!data_->at(i).overFlow() && !emu_->at(j).overFlow() && data_->at(i).et() != emu_->at(j).et() && data_->at(i).phi() == emu_->at(j).phi()) {
00083         //if the overflow bits are both off but only the phi agree = phi match
00084         errorFlag_hist_->Fill(2);
00085         return errorFlag=1;
00086       }
00087 
00088       //otherwise it's a total unmatch
00089       errorFlag_hist_->Fill(3);
00090       errorFlag=1;
00091       return errorFlag;
00092     }  
00093   }
00094   return errorFlag;
00095 }
00096 
00097 #endif