Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:12

0001 #ifndef compareMissingEnergySums_h
0002 #define compareMissingEnergySums_h
0003 
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
0006 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h"
0007 
0008 #include "FWCore/Framework/interface/Frameworkfwd.h"
0009 
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/Framework/interface/MakerMacros.h"
0012 
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 
0015 #include "FWCore/Utilities/interface/InputTag.h"
0016 
0017 #include "L1Trigger/L1GctAnalyzer/interface/GctErrorAnalyzerDefinitions.h"
0018 
0019 #include "TH2.h"
0020 #include "TH1.h"
0021 
0022 template <class T>
0023 class compareMissingEnergySums {
0024 public:
0025   compareMissingEnergySums(const T &data, const T &emu, const GctErrorAnalyzerMBxInfo &mbxparams);
0026   ~compareMissingEnergySums();
0027 
0028   bool doCompare(TH1I *errorFlag_hist_);
0029 
0030 private:
0031   T data_, emu_;
0032   GctErrorAnalyzerMBxInfo mbxparams_;
0033 };
0034 
0035 template <class T>
0036 compareMissingEnergySums<T>::compareMissingEnergySums(const T &data,
0037                                                       const T &emu,
0038                                                       const GctErrorAnalyzerMBxInfo &mbxparams)
0039     : data_(data), emu_(emu), mbxparams_(mbxparams) {}
0040 
0041 template <class T>
0042 compareMissingEnergySums<T>::~compareMissingEnergySums() {}
0043 
0044 template <class T>
0045 bool compareMissingEnergySums<T>::doCompare(TH1I *errorFlag_hist_) {
0046   bool errorFlag = false;
0047 
0048   for (unsigned int i = 0; i < data_->size(); i++) {
0049     if (data_->at(i).bx() != mbxparams_.GCTTrigBx)
0050       continue;
0051 
0052     for (unsigned int j = 0; j < emu_->size(); j++) {
0053       if (emu_->at(j).bx() != mbxparams_.EmuTrigBx)
0054         continue;
0055 
0056       if (data_->at(i).overFlow() && emu_->at(j).overFlow()) {
0057         //if both overflow bits are set then = match
0058         errorFlag_hist_->Fill(0);
0059         return errorFlag;
0060       }
0061 
0062       //check that we consider non-zero candidates - if we don't, return (don't fill hist)
0063       if (!data_->at(i).overFlow() && !emu_->at(j).overFlow() && data_->at(i).et() == 0 && emu_->at(j).et() == 0)
0064         return errorFlag;
0065 
0066       if (!data_->at(i).overFlow() && !emu_->at(j).overFlow() && data_->at(i).et() == emu_->at(j).et() &&
0067           data_->at(i).phi() == emu_->at(j).phi()) {
0068         //similarly, if the overflow bits are both off but the mag/phi agree = match
0069         errorFlag_hist_->Fill(0);
0070         return errorFlag;
0071       }
0072 
0073       if (!data_->at(i).overFlow() && !emu_->at(j).overFlow() && data_->at(i).et() == emu_->at(j).et() &&
0074           data_->at(i).phi() != emu_->at(j).phi()) {
0075         //if the overflow bits are both off but only the mag agree = mag match
0076         errorFlag_hist_->Fill(1);
0077         return errorFlag = true;
0078       }
0079 
0080       if (!data_->at(i).overFlow() && !emu_->at(j).overFlow() && data_->at(i).et() != emu_->at(j).et() &&
0081           data_->at(i).phi() == emu_->at(j).phi()) {
0082         //if the overflow bits are both off but only the phi agree = phi match
0083         errorFlag_hist_->Fill(2);
0084         return errorFlag = true;
0085       }
0086 
0087       //otherwise it's a total unmatch
0088       errorFlag_hist_->Fill(3);
0089       errorFlag = true;
0090       return errorFlag;
0091     }
0092   }
0093   return errorFlag;
0094 }
0095 
0096 #endif