File indexing completed on 2023-03-17 11:11:44
0001 #ifndef compareCands_h
0002 #define compareCands_h
0003
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/Framework/interface/Frameworkfwd.h"
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "FWCore/Framework/interface/MakerMacros.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/Utilities/interface/InputTag.h"
0010 #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
0011 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h"
0012 #include "TH2.h"
0013 #include "TH1.h"
0014 #include "L1Trigger/L1GctAnalyzer/interface/GctErrorAnalyzerDefinitions.h"
0015
0016
0017
0018
0019 template <class T>
0020 class compareCands {
0021 public:
0022 compareCands(const T &data, const T &emu, const GctErrorAnalyzerMBxInfo &mbxparams);
0023 ~compareCands();
0024
0025 bool doCompare(TH1I *errorFlag_hist_,
0026 TH1I *mismatchD_Rank,
0027 TH2I *mismatchD_EtEtaPhi,
0028 TH1I *mismatchE_Rank,
0029 TH2I *mismatchE_EtEtaPhi);
0030
0031 private:
0032 T data_, emu_;
0033 GctErrorAnalyzerMBxInfo mbxparams_;
0034 };
0035
0036
0037 template <class T>
0038 compareCands<T>::compareCands(const T &data, const T &emu, const GctErrorAnalyzerMBxInfo &mbxparams)
0039 : data_(data), emu_(emu), mbxparams_(mbxparams) {
0040
0041 }
0042
0043 template <class T>
0044 compareCands<T>::~compareCands() {
0045
0046 }
0047
0048 template <class T>
0049 bool compareCands<T>::doCompare(TH1I *errorFlag_hist_,
0050 TH1I *mismatchD_Rank,
0051 TH2I *mismatchD_EtEtaPhi,
0052 TH1I *mismatchE_Rank,
0053 TH2I *mismatchE_EtEtaPhi) {
0054
0055
0056
0057
0058
0059 bool errorFlag = false;
0060 unsigned int i = 0, j = 0;
0061 std::vector<bool> matched(GCT_OBJECT_QUANTA);
0062
0063
0064
0065 for (i = 0; i < data_->size(); i++) {
0066
0067 if (data_->at(i).bx() != mbxparams_.GCTTrigBx)
0068 continue;
0069
0070
0071
0072 if (data_->at(i).rank() == 0)
0073 continue;
0074
0075 for (j = 0; j < emu_->size(); j++) {
0076
0077 if (emu_->at(j).bx() != mbxparams_.EmuTrigBx)
0078 continue;
0079
0080 if (data_->at(i).rank() == emu_->at(j).rank() &&
0081 data_->at(i).regionId().ieta() == emu_->at(j).regionId().ieta() &&
0082 data_->at(i).regionId().iphi() == emu_->at(j).regionId().iphi() && matched.at((j % GCT_OBJECT_QUANTA)) == 0) {
0083
0084 errorFlag_hist_->Fill(0);
0085 matched.at((j % GCT_OBJECT_QUANTA)) = true;
0086 break;
0087 }
0088
0089 if ((j % GCT_OBJECT_QUANTA) + 1 == GCT_OBJECT_QUANTA) {
0090 errorFlag_hist_->Fill(1);
0091 mismatchD_Rank->Fill(data_->at(i).rank());
0092 mismatchD_EtEtaPhi->Fill(data_->at(i).regionId().ieta(),
0093 data_->at(i).regionId().iphi(),
0094 data_->at(i).rank());
0095 errorFlag = true;
0096 }
0097 }
0098 }
0099
0100
0101 for (i = 0; i < matched.size(); i++) {
0102
0103
0104 if (matched.at(i))
0105 continue;
0106
0107
0108 for (j = 0; j < emu_->size(); j++) {
0109
0110 if (emu_->at(j).bx() != mbxparams_.EmuTrigBx)
0111 continue;
0112
0113
0114 if ((j % GCT_OBJECT_QUANTA == i) && (emu_->at(j).rank() > 0)) {
0115 errorFlag_hist_->Fill(2);
0116 mismatchE_Rank->Fill(emu_->at(j).rank());
0117 mismatchE_EtEtaPhi->Fill(emu_->at(j).regionId().ieta(),
0118 emu_->at(j).regionId().iphi(),
0119 emu_->at(j).rank());
0120 errorFlag = true;
0121 }
0122 }
0123 }
0124
0125 return errorFlag;
0126 }
0127
0128 #endif