File indexing completed on 2024-04-06 12:19:53
0001
0002 #include <memory>
0003 #include <iostream>
0004
0005
0006
0007 #include "FWCore/Framework/interface/Event.h"
0008
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010
0011 #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
0012 #include "DataFormats/L1CaloTrigger/interface/L1CaloEmCand.h"
0013 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h"
0014
0015 #include "L1Trigger/GlobalCaloTrigger/test/FakeGctInputTester.h"
0016
0017
0018 #include "TFile.h"
0019 #include "TH1.h"
0020
0021 using std::cerr;
0022 using std::cout;
0023 using std::endl;
0024 using std::string;
0025
0026
0027
0028
0029 FakeGctInputTester::FakeGctInputTester(const edm::ParameterSet& iConfig) {
0030
0031
0032 hFileName_ = iConfig.getUntrackedParameter<string>("histoFile", "FakeRctTest.root");
0033 }
0034
0035
0036
0037
0038
0039
0040 void FakeGctInputTester::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0041 using namespace edm;
0042
0043 Handle<L1CaloEmCollection> rctCands;
0044 iEvent.getByLabel("fakeRct", rctCands);
0045
0046 Handle<L1CaloRegionCollection> rctRgns;
0047 iEvent.getByLabel("fakeRct", rctRgns);
0048
0049 Handle<L1GctEmCandCollection> gctIsoCands;
0050 iEvent.getByLabel("L1GctEmuDigis", "isoEm", gctIsoCands);
0051
0052 Handle<L1GctEmCandCollection> gctNonIsoCands;
0053 iEvent.getByLabel("L1GctEmuDigis", "nonIsoEm", gctNonIsoCands);
0054
0055 Handle<L1GctJetCandCollection> gctCJets;
0056 iEvent.getByLabel("L1GctEmuDigis", "cenJets", gctCJets);
0057
0058 Handle<L1GctJetCandCollection> gctTJets;
0059 iEvent.getByLabel("L1GctEmuDigis", "tauJets", gctTJets);
0060
0061 Handle<L1GctJetCandCollection> gctFJets;
0062 iEvent.getByLabel("L1GctEmuDigis", "forJets", gctFJets);
0063
0064
0065 int nRctIso = -1;
0066 for (unsigned i = 0; i < rctCands->size(); i++) {
0067 if (rctCands->at(i).isolated() && (rctCands->at(i).rank() > 0)) {
0068 nRctIso = i;
0069 }
0070 }
0071
0072 if (nRctIso >= 0) {
0073
0074
0075
0076 unsigned int rctEta = rctCands->at(nRctIso).regionId().ieta();
0077 unsigned int gctEta = gctIsoCands->at(0).regionId().ieta();
0078 unsigned int rctPhi = rctCands->at(nRctIso).regionId().iphi();
0079 unsigned int gctPhi = gctIsoCands->at(0).regionId().iphi();
0080
0081 isoEmDEta_->Fill(gctEta - rctEta);
0082 isoEmDPhi_->Fill(gctPhi - rctPhi);
0083
0084 if ((rctEta != gctEta) || (rctPhi != gctPhi)) {
0085 cerr << "Iso EM mismatch" << endl;
0086 cerr << "RCT eta,phi : " << rctEta << "," << rctPhi << endl;
0087 cerr << "GCT eta,phi : " << gctEta << "," << gctPhi << endl;
0088 }
0089 }
0090
0091
0092 int nRctNonIso = -1;
0093 for (unsigned i = 0; i < rctCands->size(); i++) {
0094 if (!(rctCands->at(i).isolated()) && (rctCands->at(i).rank() > 0)) {
0095 nRctNonIso = i;
0096 }
0097 }
0098
0099 if (nRctNonIso >= 0) {
0100
0101
0102
0103 unsigned int rctEta = rctCands->at(nRctNonIso).regionId().ieta();
0104 unsigned int gctEta = gctNonIsoCands->at(0).regionId().ieta();
0105 unsigned int rctPhi = rctCands->at(nRctNonIso).regionId().iphi();
0106 unsigned int gctPhi = gctNonIsoCands->at(0).regionId().iphi();
0107
0108 nonIsoEmDEta_->Fill(gctEta - rctEta);
0109 nonIsoEmDPhi_->Fill(gctPhi - rctPhi);
0110
0111 if ((rctEta != gctEta) || (rctPhi != gctPhi)) {
0112 cerr << "Noniso EM mismatch" << endl;
0113 cerr << "RCT eta,phi : " << rctEta << "," << rctPhi << endl;
0114 cerr << "GCT eta,phi : " << gctEta << "," << gctPhi << endl;
0115 }
0116 }
0117
0118
0119 int nRctRgn = -1;
0120 for (unsigned i = 0; i < rctRgns->size(); i++) {
0121 if (rctRgns->at(i).et() > 0) {
0122 nRctRgn = i;
0123 }
0124 }
0125
0126 if (nRctRgn >= 0) {
0127
0128
0129
0130 unsigned int rctEta = rctRgns->at(nRctRgn).id().ieta();
0131 unsigned int rctPhi = rctRgns->at(nRctRgn).id().iphi();
0132 unsigned int gctEta = 999;
0133 unsigned int gctPhi = 999;
0134
0135 for (unsigned i = 0; i < gctCJets->size(); i++) {
0136 if (gctCJets->at(i).rank() > 0) {
0137 gctEta = gctCJets->at(i).regionId().ieta();
0138 gctPhi = gctCJets->at(i).regionId().iphi();
0139 }
0140 }
0141 for (unsigned i = 0; i < gctTJets->size(); i++) {
0142 if (gctTJets->at(i).rank() > 0) {
0143 gctEta = gctTJets->at(i).regionId().ieta();
0144 gctPhi = gctTJets->at(i).regionId().iphi();
0145 }
0146 }
0147 for (unsigned i = 0; i < gctFJets->size(); i++) {
0148 if (gctFJets->at(i).rank() > 0) {
0149 gctEta = gctFJets->at(i).regionId().ieta();
0150 gctPhi = gctFJets->at(i).regionId().iphi();
0151 }
0152 }
0153
0154 jetDEta_->Fill(gctEta - rctEta);
0155 jetDPhi_->Fill(gctPhi - rctPhi);
0156
0157 if ((rctEta != gctEta) || (rctPhi != gctPhi)) {
0158 cerr << "Region mismatch" << endl;
0159 cerr << "RCT eta,phi : " << rctEta << "," << rctPhi << endl;
0160 cerr << "GCT eta,phi : " << gctEta << "," << gctPhi << endl;
0161 }
0162 }
0163
0164
0165 }
0166
0167
0168 void FakeGctInputTester::beginJob() {
0169 hFile_ = new TFile(hFileName_.c_str(), "RECREATE");
0170
0171 isoEmDEta_ = new TH1F("isoEmDEta", "Iso EM delta eta", 41, -20.5, 20.5);
0172 isoEmDPhi_ = new TH1F("isoEmDPhi", "Iso EM delta phi", 41, -20, 20);
0173
0174 nonIsoEmDEta_ = new TH1F("nonIsoEmDEta", "Non-iso EM delta eta", 41, -20.5, 20.5);
0175 nonIsoEmDPhi_ = new TH1F("nonIsoEmDPhi", "Non-iso EM delta phi", 41, -20.5, 20.5);
0176
0177 jetDEta_ = new TH1F("jetDEta", "jet delta eta", 41, -20.5, 20.5);
0178 jetDPhi_ = new TH1F("jetDPhi", "jet delta phi", 41, -20.5, 20.5);
0179 }
0180
0181
0182 void FakeGctInputTester::endJob() {
0183 hFile_->Write();
0184 hFile_->Close();
0185 }