Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 23:30:31

0001 #include <iomanip>
0002 #include <iostream>
0003 #include <string>
0004 #include <vector>
0005 
0006 #include <TCanvas.h>
0007 #include <TFile.h>
0008 #include <TH1D.h>
0009 #include <TH2D.h>
0010 #include <TTree.h>
0011 #include <TPaveStats.h>
0012 
0013 #include "DataFormats/Common/interface/Wrapper.h"
0014 #include "DataFormats/EcalRecHit/interface/EcalUncalibratedRecHit.h"
0015 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0016 #include "CUDADataFormats/EcalRecHitSoA/interface/EcalUncalibratedRecHit.h"
0017 
0018 #include "TStyle.h"
0019 
0020 void setAxis(TH2D *histo) {
0021   histo->GetXaxis()->SetTitle("cpu");
0022   histo->GetYaxis()->SetTitle("gpu");
0023 }
0024 
0025 void setAxisDelta(TH2D *histo) {
0026   histo->GetXaxis()->SetTitle("cpu");
0027   histo->GetYaxis()->SetTitle("#Delta gpu-cpu");
0028 }
0029 
0030 int main(int argc, char *argv[]) {
0031   if (argc < 3) {
0032     std::cout << "run with: ./validateGPU <path to input file> <output file>\n";
0033     exit(0);
0034   }
0035 
0036   gStyle->SetOptStat("ourme");
0037 
0038   edm::Wrapper<ecal::UncalibratedRecHit<calo::common::VecStoragePolicy<calo::common::CUDAHostAllocatorAlias>>> *wgpuEB =
0039       nullptr;
0040   edm::Wrapper<ecal::UncalibratedRecHit<calo::common::VecStoragePolicy<calo::common::CUDAHostAllocatorAlias>>> *wgpuEE =
0041       nullptr;
0042   edm::Wrapper<EBUncalibratedRecHitCollection> *wcpuEB = nullptr;
0043   edm::Wrapper<EEUncalibratedRecHitCollection> *wcpuEE = nullptr;
0044 
0045   std::string fileName = argv[1];
0046   std::string outFileName = argv[2];
0047 
0048   // output
0049   TFile rfout{outFileName.c_str(), "recreate"};
0050 
0051   int nbins_count = 200;
0052   float last_count = 5000.;
0053   int nbins_count_delta = 201;
0054 
0055   int nbins = 300;
0056   float last = 3000.;
0057 
0058   //     int nbins_chi2 = 1000;
0059   //     float last_chi2 = 1000.;
0060   int nbins_chi2 = 1000;
0061   float last_chi2 = 200.;
0062 
0063   int nbins_flags = 100;
0064   float last_flags = 100.;
0065   float delta_flags = 20;
0066 
0067   int nbins_delta = 201;  // use an odd number to center around 0
0068   float delta = 0.2;
0069 
0070   // RecHits plots for EB and EE on both GPU and CPU
0071   auto hRechitsEBGPU = new TH1D("RechitsEBGPU", "RechitsEBGPU; No. of Rechits", nbins_count, 0, last_count);
0072   auto hRechitsEBCPU = new TH1D("RechitsEBCPU", "RechitsEBCPU; No. of Rechits", nbins_count, 0, last_count);
0073   auto hRechitsEEGPU = new TH1D("RechitsEEGPU", "RechitsEEGPU; No. of Rechits", nbins_count, 0, last_count);
0074   auto hRechitsEECPU = new TH1D("RechitsEECPU", "RechitsEECPU; No. of Rechits", nbins_count, 0, last_count);
0075   auto hRechitsEBGPUCPUratio = new TH1D("RechitsEBGPU/CPUratio", "RechitsEBGPU/CPUratio; GPU/CPU", 50, 0.9, 1.1);
0076   auto hRechitsEEGPUCPUratio = new TH1D("RechitsEEGPU/CPUratio", "RechitsEEGPU/CPUratio; GPU/CPU", 50, 0.9, 1.1);
0077 
0078   auto hSOIAmplitudesEBGPU = new TH1D("hSOIAmplitudesEBGPU", "hSOIAmplitudesEBGPU", nbins, 0, last);
0079   auto hSOIAmplitudesEEGPU = new TH1D("hSOIAmplitudesEEGPU", "hSOIAmplitudesEEGPU", nbins, 0, last);
0080   auto hSOIAmplitudesEBCPU = new TH1D("hSOIAmplitudesEBCPU", "hSOIAmplitudesEBCPU", nbins, 0, last);
0081   auto hSOIAmplitudesEECPU = new TH1D("hSOIAmplitudesEECPU", "hSOIAmplitudesEECPU", nbins, 0, last);
0082   auto hSOIAmplitudesEBGPUCPUratio =
0083       new TH1D("SOIAmplitudesEBGPU/CPUratio", "SOIAmplitudesEBGPU/CPUratio; GPU/CPU", 200, 0.9, 1.1);
0084   auto hSOIAmplitudesEEGPUCPUratio =
0085       new TH1D("SOIAmplitudesEEGPU/CPUratio", "SOIAmplitudesEEGPU/CPUratio; GPU/CPU", 200, 0.9, 1.1);
0086 
0087   auto hChi2EBGPU = new TH1D("hChi2EBGPU", "hChi2EBGPU", nbins_chi2, 0, last_chi2);
0088   auto hChi2EEGPU = new TH1D("hChi2EEGPU", "hChi2EEGPU", nbins_chi2, 0, last_chi2);
0089   auto hChi2EBCPU = new TH1D("hChi2EBCPU", "hChi2EBCPU", nbins_chi2, 0, last_chi2);
0090   auto hChi2EECPU = new TH1D("hChi2EECPU", "hChi2EECPU", nbins_chi2, 0, last_chi2);
0091   auto hChi2EBGPUCPUratio = new TH1D("Chi2EBGPU/CPUratio", "Chi2EBGPU/CPUratio; GPU/CPU", 200, 0.9, 1.1);
0092   auto hChi2EEGPUCPUratio = new TH1D("Chi2EEGPU/CPUratio", "Chi2EEGPU/CPUratio; GPU/CPU", 200, 0.9, 1.1);
0093 
0094   auto hFlagsEBGPU = new TH1D("hFlagsEBGPU", "hFlagsEBGPU", nbins_flags, 0, last_flags);
0095   auto hFlagsEEGPU = new TH1D("hFlagsEEGPU", "hFlagsEEGPU", nbins_flags, 0, last_flags);
0096   auto hFlagsEBCPU = new TH1D("hFlagsEBCPU", "hFlagsEBCPU", nbins_flags, 0, last_flags);
0097   auto hFlagsEECPU = new TH1D("hFlagsEECPU", "hFlagsEECPU", nbins_flags, 0, last_flags);
0098   auto hFlagsEBGPUCPUratio = new TH1D("FlagsEBGPU/CPUratio", "FlagsEBGPU/CPUratio; GPU/CPU", 200, 0.9, 1.1);
0099   auto hFlagsEEGPUCPUratio = new TH1D("FlagsEEGPU/CPUratio", "FlagsEEGPU/CPUratio; GPU/CPU", 200, 0.9, 1.1);
0100 
0101   auto hSOIAmplitudesEBGPUvsCPU =
0102       new TH2D("hSOIAmplitudesEBGPUvsCPU", "hSOIAmplitudesEBGPUvsCPU", nbins, 0, last, nbins, 0, last);
0103   setAxis(hSOIAmplitudesEBGPUvsCPU);
0104   auto hSOIAmplitudesEEGPUvsCPU =
0105       new TH2D("hSOIAmplitudesEEGPUvsCPU", "hSOIAmplitudesEEGPUvsCPU", nbins, 0, last, nbins, 0, last);
0106   setAxis(hSOIAmplitudesEEGPUvsCPU);
0107   auto hSOIAmplitudesEBdeltavsCPU =
0108       new TH2D("hSOIAmplitudesEBdeltavsCPU", "hSOIAmplitudesEBdeltavsCPU", nbins, 0, last, nbins_delta, -delta, delta);
0109   setAxisDelta(hSOIAmplitudesEBdeltavsCPU);
0110   auto hSOIAmplitudesEEdeltavsCPU =
0111       new TH2D("hSOIAmplitudesEEdeltavsCPU", "hSOIAmplitudesEEdeltavsCPU", nbins, 0, last, nbins_delta, -delta, delta);
0112   setAxisDelta(hSOIAmplitudesEEdeltavsCPU);
0113 
0114   auto hChi2EBGPUvsCPU =
0115       new TH2D("hChi2EBGPUvsCPU", "hChi2EBGPUvsCPU", nbins_chi2, 0, last_chi2, nbins_chi2, 0, last_chi2);
0116   setAxis(hChi2EBGPUvsCPU);
0117   auto hChi2EEGPUvsCPU =
0118       new TH2D("hChi2EEGPUvsCPU", "hChi2EEGPUvsCPU", nbins_chi2, 0, last_chi2, nbins_chi2, 0, last_chi2);
0119   setAxis(hChi2EEGPUvsCPU);
0120   auto hChi2EBdeltavsCPU =
0121       new TH2D("hChi2EBdeltavsCPU", "hChi2EBdeltavsCPU", nbins_chi2, 0, last_chi2, nbins_delta, -delta, delta);
0122   setAxisDelta(hChi2EBdeltavsCPU);
0123   auto hChi2EEdeltavsCPU =
0124       new TH2D("hChi2EEdeltavsCPU", "hChi2EEdeltavsCPU", nbins_chi2, 0, last_chi2, nbins_delta, -delta, delta);
0125   setAxisDelta(hChi2EEdeltavsCPU);
0126 
0127   auto hFlagsEBGPUvsCPU =
0128       new TH2D("hFlagsEBGPUvsCPU", "hFlagsEBGPUvsCPU", nbins_flags, 0, last_flags, nbins_flags, 0, last_flags);
0129   setAxis(hFlagsEBGPUvsCPU);
0130   auto hFlagsEEGPUvsCPU =
0131       new TH2D("hFlagsEEGPUvsCPU", "hFlagsEEGPUvsCPU", nbins_flags, 0, last_flags, nbins_flags, 0, last_flags);
0132   setAxis(hFlagsEEGPUvsCPU);
0133   auto hFlagsEBdeltavsCPU = new TH2D(
0134       "hFlagsEBdeltavsCPU", "hFlagsEBdeltavsCPU", nbins_flags, 0, last_flags, nbins_delta, -delta_flags, delta_flags);
0135   setAxisDelta(hFlagsEBdeltavsCPU);
0136   auto hFlagsEEdeltavsCPU = new TH2D(
0137       "hFlagsEEdeltavsCPU", "hFlagsEEdeltavsCPU", nbins_flags, 0, last_flags, nbins_delta, -delta_flags, delta_flags);
0138   setAxisDelta(hFlagsEEdeltavsCPU);
0139 
0140   auto hRechitsEBGPUvsCPU = new TH2D(
0141       "RechitsEBGPUvsCPU", "RechitsEBGPUvsCPU; CPU; GPU", last_count, 0, last_count, last_count, 0, last_count);
0142   setAxis(hRechitsEBGPUvsCPU);
0143   auto hRechitsEEGPUvsCPU = new TH2D(
0144       "RechitsEEGPUvsCPU", "RechitsEEGPUvsCPU; CPU; GPU", last_count, 0, last_count, last_count, 0, last_count);
0145   setAxis(hRechitsEEGPUvsCPU);
0146   auto hRechitsEBdeltavsCPU = new TH2D(
0147       "RechitsEBdeltavsCPU", "RechitsEBdeltavsCPU", nbins_count, 0, last_count, nbins_count_delta, -delta, delta);
0148   setAxisDelta(hRechitsEBdeltavsCPU);
0149   auto hRechitsEEdeltavsCPU = new TH2D(
0150       "RechitsEEdeltavsCPU", "RechitsEEdeltavsCPU", nbins_count, 0, last_count, nbins_count_delta, -delta, delta);
0151   setAxisDelta(hRechitsEEdeltavsCPU);
0152 
0153   // input
0154   std::cout << "validating file " << fileName << std::endl;
0155   TFile rf{fileName.c_str()};
0156   TTree *rt = (TTree *)rf.Get("Events");
0157   rt->SetBranchAddress(
0158       "calocommonCUDAHostAllocatorAliascalocommonVecStoragePolicyecalUncalibratedRecHit_ecalCPUUncalibRecHitProducer_"
0159       "EcalUncalibRecHitsEB_RECO.",
0160       &wgpuEB);
0161   rt->SetBranchAddress(
0162       "calocommonCUDAHostAllocatorAliascalocommonVecStoragePolicyecalUncalibratedRecHit_ecalCPUUncalibRecHitProducer_"
0163       "EcalUncalibRecHitsEE_RECO.",
0164       &wgpuEE);
0165   rt->SetBranchAddress("EcalUncalibratedRecHitsSorted_ecalMultiFitUncalibRecHit_EcalUncalibRecHitsEB_RECO.", &wcpuEB);
0166   rt->SetBranchAddress("EcalUncalibratedRecHitsSorted_ecalMultiFitUncalibRecHit_EcalUncalibRecHitsEE_RECO.", &wcpuEE);
0167 
0168   constexpr float eps_diff = 1e-3;
0169 
0170   // accumulate
0171   auto const nentries = rt->GetEntries();
0172   std::cout << "#events to validate over: " << nentries << std::endl;
0173   for (int ie = 0; ie < nentries; ++ie) {
0174     rt->GetEntry(ie);
0175 
0176     const char *ordinal[] = {"th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"};
0177     auto cpu_eb_size = wcpuEB->bareProduct().size();
0178     auto cpu_ee_size = wcpuEE->bareProduct().size();
0179     auto gpu_eb_size = wgpuEB->bareProduct().amplitude.size();
0180     auto gpu_ee_size = wgpuEE->bareProduct().amplitude.size();
0181 
0182     float eb_ratio = (float)gpu_eb_size / cpu_eb_size;
0183     float ee_ratio = (float)gpu_ee_size / cpu_ee_size;
0184 
0185     // Filling up the histograms on events sizes for EB and EE on both GPU and CPU
0186     hRechitsEBGPU->Fill(gpu_eb_size);
0187     hRechitsEBCPU->Fill(cpu_eb_size);
0188     hRechitsEEGPU->Fill(gpu_ee_size);
0189     hRechitsEECPU->Fill(cpu_ee_size);
0190     hRechitsEBGPUvsCPU->Fill(cpu_eb_size, gpu_eb_size);
0191     hRechitsEEGPUvsCPU->Fill(cpu_ee_size, gpu_ee_size);
0192     hRechitsEBGPUCPUratio->Fill(eb_ratio);
0193     hRechitsEEGPUCPUratio->Fill(ee_ratio);
0194     hRechitsEBdeltavsCPU->Fill(cpu_eb_size, gpu_eb_size - cpu_eb_size);
0195     hRechitsEEdeltavsCPU->Fill(cpu_ee_size, gpu_ee_size - cpu_ee_size);
0196 
0197     if (cpu_eb_size != gpu_eb_size or cpu_ee_size != gpu_ee_size) {
0198       std::cerr << ie << ordinal[ie % 10] << " entry:\n"
0199                 << "  EB size: " << std::setw(4) << cpu_eb_size << " (cpu) vs " << std::setw(4) << gpu_eb_size
0200                 << " (gpu)\n"
0201                 << "  EE size: " << std::setw(4) << cpu_ee_size << " (cpu) vs " << std::setw(4) << gpu_ee_size
0202                 << " (gpu)" << std::endl;
0203       continue;
0204     }
0205 
0206     assert(wgpuEB->bareProduct().amplitude.size() == wcpuEB->bareProduct().size());
0207     assert(wgpuEE->bareProduct().amplitude.size() == wcpuEE->bareProduct().size());
0208     auto const neb = wcpuEB->bareProduct().size();
0209     auto const nee = wcpuEE->bareProduct().size();
0210 
0211     for (uint32_t i = 0; i < neb; ++i) {
0212       auto const did_gpu = wgpuEB->bareProduct().did[i];
0213       auto const soi_amp_gpu = wgpuEB->bareProduct().amplitude[i];
0214       auto const cpu_iter = wcpuEB->bareProduct().find(DetId{did_gpu});
0215       if (cpu_iter == wcpuEB->bareProduct().end()) {
0216         std::cerr << ie << ordinal[ie % 10] << " entry\n"
0217                   << "  Did not find a DetId " << did_gpu << " in a CPU collection\n";
0218         continue;
0219       }
0220       auto const soi_amp_cpu = cpu_iter->amplitude();
0221       auto const chi2_gpu = wgpuEB->bareProduct().chi2[i];
0222       auto const chi2_cpu = cpu_iter->chi2();
0223 
0224       auto const flags_gpu = wgpuEB->bareProduct().flags[i];
0225       auto const flags_cpu = cpu_iter->flags();
0226 
0227       hSOIAmplitudesEBGPU->Fill(soi_amp_gpu);
0228       hSOIAmplitudesEBCPU->Fill(soi_amp_cpu);
0229       hSOIAmplitudesEBGPUvsCPU->Fill(soi_amp_cpu, soi_amp_gpu);
0230       hSOIAmplitudesEBdeltavsCPU->Fill(soi_amp_cpu, soi_amp_gpu - soi_amp_cpu);
0231       if (soi_amp_cpu > 0)
0232         hSOIAmplitudesEBGPUCPUratio->Fill((float)soi_amp_gpu / soi_amp_cpu);
0233 
0234       hChi2EBGPU->Fill(chi2_gpu);
0235       hChi2EBCPU->Fill(chi2_cpu);
0236       hChi2EBGPUvsCPU->Fill(chi2_cpu, chi2_gpu);
0237       hChi2EBdeltavsCPU->Fill(chi2_cpu, chi2_gpu - chi2_cpu);
0238       if (chi2_cpu > 0)
0239         hChi2EBGPUCPUratio->Fill((float)chi2_gpu / chi2_cpu);
0240 
0241       if (std::abs(chi2_gpu / chi2_cpu - 1) > 0.05 || std::abs(soi_amp_gpu / soi_amp_cpu - 1) > 0.05) {
0242         std::cout << " ---- EB  " << std::endl;
0243         std::cout << " eventid = " << ie << " xtal = " << i << std::endl;
0244         std::cout << " chi2_gpu    = " << chi2_gpu << " chi2_cpu =    " << chi2_cpu << std::endl;
0245         std::cout << " soi_amp_gpu = " << soi_amp_gpu << " soi_amp_cpu = " << soi_amp_cpu << std::endl;
0246         std::cout << " flags_gpu   = " << flags_gpu << " flags_cpu =   " << flags_cpu << std::endl;
0247       }
0248 
0249       hFlagsEBGPU->Fill(flags_gpu);
0250       hFlagsEBCPU->Fill(flags_cpu);
0251       hFlagsEBGPUvsCPU->Fill(flags_cpu, flags_gpu);
0252       hFlagsEBdeltavsCPU->Fill(flags_cpu, flags_gpu - flags_cpu);
0253       if (flags_cpu > 0)
0254         hFlagsEBGPUCPUratio->Fill((float)flags_gpu / flags_cpu);
0255 
0256       if (flags_cpu != flags_gpu) {
0257         std::cout << "    >>  No! Different flag cpu:gpu = " << flags_cpu << " : " << flags_gpu;
0258         std::cout << std::endl;
0259       }
0260 
0261       if ((std::abs(soi_amp_gpu - soi_amp_cpu) >= eps_diff) or (std::abs(chi2_gpu - chi2_cpu) >= eps_diff) or
0262           std::isnan(chi2_gpu) or (flags_cpu != flags_gpu)) {
0263         printf("EB eventid = %d chid = %d amp_gpu = %f amp_cpu %f chi2_gpu = %f chi2_cpu = %f\n",
0264                ie,
0265                i,
0266                soi_amp_gpu,
0267                soi_amp_cpu,
0268                chi2_gpu,
0269                chi2_cpu);
0270         if (std::isnan(chi2_gpu))
0271           printf("*** nan ***\n");
0272       }
0273     }
0274 
0275     for (uint32_t i = 0; i < nee; ++i) {
0276       auto const did_gpu = wgpuEE->bareProduct().did[i];
0277       auto const soi_amp_gpu = wgpuEE->bareProduct().amplitude[i];
0278       auto const cpu_iter = wcpuEE->bareProduct().find(DetId{did_gpu});
0279       if (cpu_iter == wcpuEE->bareProduct().end()) {
0280         std::cerr << ie << ordinal[ie % 10] << " entry\n"
0281                   << "  did not find a DetId " << did_gpu << " in a CPU collection\n";
0282         continue;
0283       }
0284       auto const soi_amp_cpu = cpu_iter->amplitude();
0285       auto const chi2_gpu = wgpuEE->bareProduct().chi2[i];
0286       auto const chi2_cpu = cpu_iter->chi2();
0287 
0288       auto const flags_gpu = wgpuEE->bareProduct().flags[i];
0289       auto const flags_cpu = cpu_iter->flags();
0290 
0291       hSOIAmplitudesEEGPU->Fill(soi_amp_gpu);
0292       hSOIAmplitudesEECPU->Fill(soi_amp_cpu);
0293       hSOIAmplitudesEEGPUvsCPU->Fill(soi_amp_cpu, soi_amp_gpu);
0294       hSOIAmplitudesEEdeltavsCPU->Fill(soi_amp_cpu, soi_amp_gpu - soi_amp_cpu);
0295       if (soi_amp_cpu > 0)
0296         hSOIAmplitudesEEGPUCPUratio->Fill((float)soi_amp_gpu / soi_amp_cpu);
0297 
0298       hChi2EEGPU->Fill(chi2_gpu);
0299       hChi2EECPU->Fill(chi2_cpu);
0300       hChi2EEGPUvsCPU->Fill(chi2_cpu, chi2_gpu);
0301       hChi2EEdeltavsCPU->Fill(chi2_cpu, chi2_gpu - chi2_cpu);
0302       if (chi2_cpu > 0)
0303         hChi2EEGPUCPUratio->Fill((float)chi2_gpu / chi2_cpu);
0304 
0305       if (std::abs(chi2_gpu / chi2_cpu - 1) > 0.05 || std::abs(soi_amp_gpu / soi_amp_cpu - 1) > 0.05) {
0306         std::cout << " ---- EE  " << std::endl;
0307         std::cout << " eventid = " << ie << " xtal = " << i << std::endl;
0308         std::cout << " chi2_gpu    = " << chi2_gpu << " chi2_cpu =    " << chi2_cpu << std::endl;
0309         std::cout << " soi_amp_gpu = " << soi_amp_gpu << " soi_amp_cpu = " << soi_amp_cpu << std::endl;
0310         std::cout << " flags_gpu   = " << flags_gpu << " flags_cpu =   " << flags_cpu << std::endl;
0311       }
0312 
0313       hFlagsEEGPU->Fill(flags_gpu);
0314       hFlagsEECPU->Fill(flags_cpu);
0315       hFlagsEEGPUvsCPU->Fill(flags_cpu, flags_gpu);
0316       hFlagsEEdeltavsCPU->Fill(flags_cpu, flags_gpu - flags_cpu);
0317       if (flags_cpu > 0)
0318         hFlagsEEGPUCPUratio->Fill((float)flags_gpu / flags_cpu);
0319 
0320       if (flags_cpu != flags_gpu) {
0321         std::cout << "    >>  No! Different flag cpu:gpu = " << flags_cpu << " : " << flags_gpu;
0322         std::cout << std::endl;
0323       }
0324 
0325       if ((std::abs(soi_amp_gpu - soi_amp_cpu) >= eps_diff) or (std::abs(chi2_gpu - chi2_cpu) >= eps_diff) or
0326           std::isnan(chi2_gpu) or (flags_cpu != flags_gpu)) {
0327         printf("EE eventid = %d chid = %d amp_gpu = %f amp_cpu %f chi2_gpu = %f chi2_cpu = %f\n",
0328                ie,
0329                static_cast<int>(neb + i),
0330                soi_amp_gpu,
0331                soi_amp_cpu,
0332                chi2_gpu,
0333                chi2_cpu);
0334         if (std::isnan(chi2_gpu))
0335           printf("*** nan ***\n");
0336       }
0337     }
0338   }
0339 
0340   {
0341     TCanvas c("plots", "plots", 1750, 860);
0342     c.Divide(3, 2);
0343 
0344     c.cd(1);
0345     {
0346       gPad->SetLogy();
0347       hSOIAmplitudesEBCPU->SetLineColor(kBlack);
0348       hSOIAmplitudesEBCPU->SetLineWidth(1.);
0349       hSOIAmplitudesEBCPU->Draw("");
0350       hSOIAmplitudesEBGPU->SetLineColor(kBlue);
0351       hSOIAmplitudesEBGPU->SetLineWidth(1.);
0352       hSOIAmplitudesEBGPU->Draw("sames");
0353       gPad->Update();
0354       auto stats = (TPaveStats *)hSOIAmplitudesEBGPU->FindObject("stats");
0355       auto y2 = stats->GetY2NDC();
0356       auto y1 = stats->GetY1NDC();
0357       stats->SetY2NDC(y1);
0358       stats->SetY1NDC(y1 - (y2 - y1));
0359     }
0360 
0361     c.cd(4);
0362     {
0363       gPad->SetLogy();
0364       hSOIAmplitudesEECPU->SetLineColor(kBlack);
0365       hSOIAmplitudesEECPU->SetLineWidth(1.);
0366       hSOIAmplitudesEECPU->Draw("");
0367       hSOIAmplitudesEEGPU->SetLineColor(kBlue);
0368       hSOIAmplitudesEEGPU->SetLineWidth(1.);
0369       hSOIAmplitudesEEGPU->Draw("sames");
0370       gPad->Update();
0371       auto stats = (TPaveStats *)hSOIAmplitudesEEGPU->FindObject("stats");
0372       auto y2 = stats->GetY2NDC();
0373       auto y1 = stats->GetY1NDC();
0374       stats->SetY2NDC(y1);
0375       stats->SetY1NDC(y1 - (y2 - y1));
0376     }
0377 
0378     c.cd(2);
0379     gPad->SetGrid();
0380     hSOIAmplitudesEBGPUvsCPU->Draw("COLZ");
0381 
0382     c.cd(5);
0383     gPad->SetGrid();
0384     hSOIAmplitudesEEGPUvsCPU->Draw("COLZ");
0385 
0386     c.cd(3);
0387 
0388     hSOIAmplitudesEBGPUCPUratio->Draw("");
0389 
0390     c.cd(6);
0391 
0392     hSOIAmplitudesEEGPUCPUratio->Draw("");
0393 
0394     c.SaveAs("ecal-amplitudes.root");
0395     c.SaveAs("ecal-amplitudes.png");
0396 
0397     // chi2
0398 
0399     c.cd(1);
0400     {
0401       gPad->SetLogy();
0402       hChi2EBCPU->SetLineColor(kBlack);
0403       hChi2EBCPU->SetLineWidth(1.);
0404       hChi2EBCPU->Draw("");
0405       hChi2EBGPU->SetLineColor(kBlue);
0406       hChi2EBGPU->SetLineWidth(1.);
0407       hChi2EBGPU->Draw("sames");
0408       gPad->Update();
0409       auto stats = (TPaveStats *)hChi2EBGPU->FindObject("stats");
0410       auto y2 = stats->GetY2NDC();
0411       auto y1 = stats->GetY1NDC();
0412       stats->SetY2NDC(y1);
0413       stats->SetY1NDC(y1 - (y2 - y1));
0414     }
0415 
0416     c.cd(4);
0417     {
0418       gPad->SetLogy();
0419       hChi2EECPU->SetLineColor(kBlack);
0420       hChi2EECPU->SetLineWidth(1.);
0421       hChi2EECPU->Draw("");
0422       hChi2EEGPU->SetLineColor(kBlue);
0423       hChi2EEGPU->SetLineWidth(1.);
0424       hChi2EEGPU->Draw("sames");
0425       gPad->Update();
0426       auto stats = (TPaveStats *)hChi2EEGPU->FindObject("stats");
0427       auto y2 = stats->GetY2NDC();
0428       auto y1 = stats->GetY1NDC();
0429       stats->SetY2NDC(y1);
0430       stats->SetY1NDC(y1 - (y2 - y1));
0431     }
0432 
0433     c.cd(2);
0434     gPad->SetGrid();
0435     hChi2EBGPUvsCPU->Draw("COLZ");
0436 
0437     c.cd(5);
0438     gPad->SetGrid();
0439     hChi2EEGPUvsCPU->Draw("COLZ");
0440 
0441     c.cd(3);
0442 
0443     hChi2EBGPUCPUratio->Draw("");
0444 
0445     c.cd(6);
0446 
0447     hChi2EEGPUCPUratio->Draw("");
0448 
0449     c.SaveAs("ecal-chi2.root");
0450     c.SaveAs("ecal-chi2.png");
0451 
0452     // flags
0453 
0454     c.cd(1);
0455     {
0456       gPad->SetLogy();
0457       hFlagsEBCPU->SetLineColor(kBlack);
0458       hFlagsEBCPU->SetLineWidth(1.);
0459       hFlagsEBCPU->Draw("");
0460       hFlagsEBGPU->SetLineColor(kBlue);
0461       hFlagsEBGPU->SetLineWidth(1.);
0462       hFlagsEBGPU->Draw("sames");
0463       gPad->Update();
0464       auto stats = (TPaveStats *)hFlagsEBGPU->FindObject("stats");
0465       auto y2 = stats->GetY2NDC();
0466       auto y1 = stats->GetY1NDC();
0467       stats->SetY2NDC(y1);
0468       stats->SetY1NDC(y1 - (y2 - y1));
0469     }
0470 
0471     c.cd(4);
0472     {
0473       gPad->SetLogy();
0474       hFlagsEECPU->SetLineColor(kBlack);
0475       hFlagsEECPU->SetLineWidth(1.);
0476       hFlagsEECPU->Draw("");
0477       hFlagsEEGPU->SetLineColor(kBlue);
0478       hFlagsEEGPU->SetLineWidth(1.);
0479       hFlagsEEGPU->Draw("sames");
0480       gPad->Update();
0481       auto stats = (TPaveStats *)hFlagsEEGPU->FindObject("stats");
0482       auto y2 = stats->GetY2NDC();
0483       auto y1 = stats->GetY1NDC();
0484       stats->SetY2NDC(y1);
0485       stats->SetY1NDC(y1 - (y2 - y1));
0486     }
0487 
0488     c.cd(2);
0489     gPad->SetGrid();
0490     hFlagsEBGPUvsCPU->Draw("COLZ");
0491 
0492     c.cd(5);
0493     gPad->SetGrid();
0494     hFlagsEEGPUvsCPU->Draw("COLZ");
0495 
0496     c.cd(3);
0497     hFlagsEBGPUCPUratio->Draw("");
0498 
0499     c.cd(6);
0500     hFlagsEEGPUCPUratio->Draw("");
0501 
0502     c.SaveAs("ecal-flags.root");
0503     c.SaveAs("ecal-flags.png");
0504 
0505     TCanvas cRechits("Rechits", "Rechits", 1750, 860);
0506     cRechits.Divide(3, 2);
0507 
0508     // Plotting the sizes of GPU vs CPU for each event of EB
0509     cRechits.cd(1);
0510     {
0511       gPad->SetLogy();
0512       hRechitsEBCPU->SetLineColor(kRed);
0513       hRechitsEBCPU->SetLineWidth(2);
0514       hRechitsEBCPU->Draw("");
0515       hRechitsEBGPU->SetLineColor(kBlue);
0516       hRechitsEBGPU->SetLineWidth(2);
0517       hRechitsEBGPU->Draw("sames");
0518       cRechits.Update();
0519       auto stats = (TPaveStats *)hRechitsEBGPU->FindObject("stats");
0520       auto y2 = stats->GetY2NDC();
0521       auto y1 = stats->GetY1NDC();
0522       stats->SetY2NDC(y1);
0523       stats->SetY1NDC(y1 - (y2 - y1));
0524     }
0525     cRechits.cd(4);
0526     {
0527       gPad->SetLogy();
0528       hRechitsEECPU->SetLineColor(kRed);
0529       hRechitsEECPU->SetLineWidth(2);
0530       hRechitsEECPU->Draw("");
0531       hRechitsEEGPU->SetLineColor(kBlue);
0532       hRechitsEEGPU->SetLineWidth(2);
0533       hRechitsEEGPU->Draw("sames");
0534       cRechits.Update();
0535       auto stats = (TPaveStats *)hRechitsEEGPU->FindObject("stats");
0536       auto y2 = stats->GetY2NDC();
0537       auto y1 = stats->GetY1NDC();
0538       stats->SetY2NDC(y1);
0539       stats->SetY1NDC(y1 - (y2 - y1));
0540     }
0541     cRechits.cd(2);
0542     { hRechitsEBGPUvsCPU->Draw("COLZ"); }
0543     cRechits.cd(5);
0544     { hRechitsEEGPUvsCPU->Draw("COLZ"); }
0545     cRechits.cd(3);
0546     {
0547       gPad->SetLogy();
0548       hRechitsEBGPUCPUratio->Draw("");
0549     }
0550     cRechits.cd(6);
0551     {
0552       gPad->SetLogy();
0553       hRechitsEEGPUCPUratio->Draw("");
0554     }
0555     cRechits.SaveAs("ecal-rechits.root");
0556     cRechits.SaveAs("ecal-rechits.png");
0557   }
0558 
0559   rf.Close();
0560   rfout.Write();
0561   rfout.Close();
0562 
0563   return 0;
0564 }