File indexing completed on 2024-04-06 12:25:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021 #include <string>
0022 #include <map>
0023 #include <iostream>
0024 using namespace std;
0025
0026
0027 #include "FWCore/Framework/interface/Frameworkfwd.h"
0028 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0029
0030 #include "FWCore/Framework/interface/Event.h"
0031 #include "FWCore/Framework/interface/MakerMacros.h"
0032
0033 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0034 #include "FWCore/Utilities/interface/InputTag.h"
0035 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0036 #include "FWCore/ServiceRegistry/interface/Service.h"
0037 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0038
0039 #include "DataFormats/HcalRecHit/interface/HBHERecHit.h"
0040 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
0041 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0042
0043 #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
0044 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
0045
0046 #include "SimCalorimetry/HcalSimAlgos/interface/HcalSimParameterMap.h"
0047
0048 #include "TH2F.h"
0049
0050
0051
0052
0053
0054 class HCALGPUAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0055 public:
0056 explicit HCALGPUAnalyzer(const edm::ParameterSet &);
0057 ~HCALGPUAnalyzer() override = default;
0058
0059 static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
0060
0061 private:
0062 void beginJob() override;
0063 void analyze(const edm::Event &, const edm::EventSetup &) override;
0064 void endJob() override;
0065
0066
0067
0068
0069
0070 double Method0Energy, Method0EnergyGPU;
0071 double RecHitEnergy, RecHitEnergyGPU;
0072 double RecHitTime, RecHitTimeGPU;
0073 double iEta, iEtaGPU;
0074 double iPhi, iPhiGPU;
0075 int depth, depthGPU;
0076
0077 TH2F *hEnergy_2dMahi;
0078 TH2F *hEnergy_2dM0;
0079 TH2F *hTime_2dMahi;
0080
0081 TH2F *Unmatched;
0082 TH2F *Matched;
0083 TH1F *hEnergy_cpu;
0084 TH1F *hEnergy_gpu;
0085 TH1F *hEnergy_cpugpu;
0086 TH1F *hEnergy_cpugpu_rel;
0087 TH1F *hEnergyM0_cpu;
0088 TH1F *hEnergyM0_gpu;
0089 TH1F *hTime_cpu;
0090 TH1F *hTime_gpu;
0091
0092
0093 edm::Service<TFileService> FileService;
0094
0095 edm::EDGetTokenT<HBHERecHitCollection> hRhToken;
0096 edm::EDGetTokenT<HBHERecHitCollection> hRhTokenGPU;
0097 };
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110 HCALGPUAnalyzer::HCALGPUAnalyzer(const edm::ParameterSet &iConfig) {
0111 usesResource("TFileService");
0112
0113 hRhToken = consumes<HBHERecHitCollection>(iConfig.getUntrackedParameter<string>("HBHERecHits", "hbheprereco"));
0114 hRhTokenGPU = consumes<HBHERecHitCollection>(
0115 iConfig.getUntrackedParameter<string>("HBHERecHits", "hcalCPURecHitsProducer:recHitsLegacyHBHE"));
0116
0117
0118
0119 hEnergy_2dM0 = FileService->make<TH2F>("hEnergy_2dM0", "hEnergy_2dM0", 1000, 0., 100., 1000, 0., 100.);
0120 hEnergy_2dM0->GetXaxis()->SetTitle("Cpu M0 Energy");
0121 hEnergy_2dM0->GetYaxis()->SetTitle("GPU M0 Energy");
0122
0123 hEnergy_2dMahi = FileService->make<TH2F>("hEnergy_2dMahi", "hEnergy_2dMahi", 1000, 0., 100., 1000, 0., 100.);
0124 hEnergy_2dMahi->GetXaxis()->SetTitle("CPU Energy");
0125 hEnergy_2dMahi->GetYaxis()->SetTitle("GPU Energy");
0126
0127 hTime_2dMahi = FileService->make<TH2F>("hTime_2dMahi", "hTime_2dMahi", 250, -12.5, 12.5, 250, -12.5, 12.5);
0128 hTime_2dMahi->GetXaxis()->SetTitle("Mahi Time CPU");
0129 hTime_2dMahi->GetYaxis()->SetTitle("Mahi Time GPU");
0130
0131
0132
0133 hEnergyM0_cpu = FileService->make<TH1F>("hEnergyM0_cpu", "hEnergyM0_cpu", 100, 0., 100.);
0134 hEnergyM0_cpu->GetXaxis()->SetTitle("CPU Energy");
0135
0136 hEnergy_cpu = FileService->make<TH1F>("hEnergy_cpu", "hEnergy_cpu", 50, 0., 50.);
0137 hEnergy_cpu->GetXaxis()->SetTitle("CPU Energy");
0138
0139 hEnergy_gpu = FileService->make<TH1F>("hEnergy_gpu", "hEnergy_gpu", 50, 0., 50.);
0140 hEnergy_gpu->GetXaxis()->SetTitle("GPU Energy");
0141
0142
0143
0144 hEnergy_cpugpu = FileService->make<TH1F>("hEnergy_cpugpu", "hEnergy_cpugpu", 500, -2.5, 2.5);
0145 hEnergy_cpugpu->GetXaxis()->SetTitle("GPU Energy - CPU Energy [GeV]");
0146 hEnergy_cpugpu->GetYaxis()->SetTitle("# RecHits");
0147
0148 hEnergy_cpugpu_rel =
0149 FileService->make<TH1F>("hEnergy_cpugpu_rel", "hEnergy_cpugpu_rel ( E > 0.005 GeV)", 500, -2.5, 2.5);
0150 hEnergy_cpugpu_rel->GetXaxis()->SetTitle("(GPU Energy - CPU Energy) / CPU energy");
0151 hEnergy_cpugpu_rel->GetYaxis()->SetTitle("# RecHits");
0152
0153
0154
0155 hTime_cpu = FileService->make<TH1F>("hTime_cpu", "hTime_cpu", 50, -25., 25.);
0156 hTime_cpu->GetXaxis()->SetTitle("CPU Time");
0157
0158 hTime_gpu = FileService->make<TH1F>("hTime_gpu", "hTime_gpu", 50, -25., 25.);
0159 hTime_gpu->GetXaxis()->SetTitle("GPU Time");
0160
0161 Unmatched = FileService->make<TH2F>("Unmatched", "Unmatched (eta,phi)", 100, -50., 50., 85, 0., 85.);
0162 Matched = FileService->make<TH2F>("Matched", "Matched (eta,phi)", 100, -50., 50., 85, 0., 85.);
0163
0164
0165 }
0166
0167
0168
0169
0170
0171
0172 void HCALGPUAnalyzer::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
0173 using namespace edm;
0174
0175
0176 Handle<HBHERecHitCollection> hRecHits;
0177 iEvent.getByToken(hRhToken, hRecHits);
0178
0179 Handle<HBHERecHitCollection> hRecHitsGPU;
0180 iEvent.getByToken(hRhTokenGPU, hRecHitsGPU);
0181
0182
0183 for (int i = 0; i < (int)hRecHits->size(); i++) {
0184
0185 HcalDetId detID_rh = (*hRecHits)[i].id().rawId();
0186
0187
0188 depth = (*hRecHits)[i].id().depth();
0189 iEta = detID_rh.ieta();
0190 iPhi = detID_rh.iphi();
0191
0192
0193 Method0Energy = (*hRecHits)[i].eraw();
0194 RecHitEnergy = (*hRecHits)[i].energy();
0195 RecHitTime = (*hRecHits)[i].time();
0196
0197 hEnergy_cpu->Fill(RecHitEnergy);
0198 hTime_cpu->Fill(RecHitTime);
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209 }
0210
0211 for (int i = 0; i < (int)hRecHitsGPU->size(); i++) {
0212
0213 HcalDetId detID_rh = (*hRecHitsGPU)[i].id().rawId();
0214
0215
0216 depthGPU = (*hRecHitsGPU)[i].id().depth();
0217 iEtaGPU = detID_rh.ieta();
0218 iPhiGPU = detID_rh.iphi();
0219
0220
0221 Method0EnergyGPU = (*hRecHitsGPU)[i].eraw();
0222 RecHitEnergyGPU = (*hRecHitsGPU)[i].energy();
0223 RecHitTimeGPU = (*hRecHitsGPU)[i].time();
0224
0225 hEnergy_gpu->Fill(RecHitEnergyGPU);
0226 hTime_gpu->Fill(RecHitTimeGPU);
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237 }
0238
0239
0240 for (int i = 0; i < (int)hRecHits->size(); i++) {
0241 HcalDetId detID_rh = (*hRecHits)[i].id().rawId();
0242
0243 bool unmatched = true;
0244
0245
0246 for (int j = 0; j < (int)hRecHitsGPU->size(); j++) {
0247 HcalDetId detID_gpu = (*hRecHitsGPU)[j].id().rawId();
0248
0249 if ((detID_rh == detID_gpu)) {
0250
0251
0252
0253
0254
0255
0256
0257
0258 auto relValue = ((*hRecHitsGPU)[j].energy() - (*hRecHits)[i].energy()) / (*hRecHits)[i].energy();
0259
0260 hEnergy_2dM0->Fill((*hRecHits)[i].eraw(), (*hRecHitsGPU)[j].eraw());
0261 hEnergy_2dMahi->Fill((*hRecHits)[i].energy(), (*hRecHitsGPU)[j].energy());
0262 hEnergy_cpugpu->Fill((*hRecHitsGPU)[j].energy() - (*hRecHits)[i].energy());
0263 if ((*hRecHits)[i].energy() > 0.005)
0264 hEnergy_cpugpu_rel->Fill(relValue);
0265 hTime_2dMahi->Fill((*hRecHits)[i].time(), (*hRecHitsGPU)[j].time());
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276 Matched->Fill(detID_rh.ieta(), detID_rh.iphi());
0277
0278 unmatched = false;
0279 }
0280 }
0281
0282
0283
0284 if (unmatched) {
0285 Unmatched->Fill(detID_rh.ieta(), detID_rh.iphi());
0286
0287 }
0288 }
0289 }
0290
0291
0292 void HCALGPUAnalyzer::beginJob() {}
0293
0294
0295 void HCALGPUAnalyzer::endJob() {}
0296
0297
0298 void HCALGPUAnalyzer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
0299
0300
0301 edm::ParameterSetDescription desc;
0302 desc.setUnknown();
0303 descriptions.addDefault(desc);
0304 }
0305
0306
0307 DEFINE_FWK_MODULE(HCALGPUAnalyzer);