Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include <iomanip>
0002 #include <iostream>
0003 #include <string>
0004 #include <vector>
0005 #include <fstream>
0006 
0007 #include <TCanvas.h>
0008 #include <TStyle.h>
0009 #include <TPad.h>
0010 #include <TFile.h>
0011 #include <TH1D.h>
0012 #include <TH2D.h>
0013 #include <TTree.h>
0014 #include <TPaveStats.h>
0015 
0016 #include "DataFormats/Common/interface/Wrapper.h"
0017 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
0018 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0019 #include "CUDADataFormats/EcalRecHitSoA/interface/EcalRecHit.h"
0020 
0021 int main(int argc, char *argv[]) {
0022   if (argc < 3) {
0023     std::cout << "run with: ./makeEcalRechitValidationPlots <path to input file> <output file>\n";
0024     exit(0);
0025   }
0026   // Set the GPU and CPU pointers for both EB and EE
0027   edm::Wrapper<ecal::RecHit<calo::common::VecStoragePolicy<calo::common::CUDAHostAllocatorAlias>>> *wgpuEB = nullptr;
0028   edm::Wrapper<ecal::RecHit<calo::common::VecStoragePolicy<calo::common::CUDAHostAllocatorAlias>>> *wgpuEE = nullptr;
0029   edm::Wrapper<EBRecHitCollection> *wcpuEB = nullptr;
0030   edm::Wrapper<EERecHitCollection> *wcpuEE = nullptr;
0031 
0032   std::string fileName = argv[1];     // The input file containing the data to be validated (i.e. result.root)
0033   std::string outFileName = argv[2];  //The output file in which the validation results will be saved (i.e. output.root)
0034 
0035   //output
0036   TFile rfout{outFileName.c_str(), "recreate"};
0037 
0038   int nbins = 200;
0039   int last = 5000.;
0040 
0041   int nbins_energy = 300;
0042   float last_energy = 2.;
0043 
0044   int nbins_chi2 = 200;
0045   float last_chi2 = 100.;
0046 
0047   int nbins_flag = 40;
0048   //   int nbins_flag = 1000;
0049   int last_flag = 1500;
0050   //   int nbins_flag = 40;
0051   //   int last_flag = 10000;
0052 
0053   int nbins_extra = 200;
0054   int last_extra = 200;
0055 
0056   int nbins_delta = 201;  // use an odd number to center around 0
0057   float delta = 0.2;
0058 
0059   // RecHits plots for EB and EE on both GPU and CPU
0060   auto hRechitsEBGPU = new TH1D("RechitsEBGPU", "RechitsEBGPU; No. of Rechits. No Filter GPU", nbins, 0, last);
0061   auto hRechitsEBCPU = new TH1D("RechitsEBCPU", "RechitsEBCPU; No. of Rechits. No Filter GPU", nbins, 0, last);
0062   auto hRechitsEEGPU = new TH1D("RechitsEEGPU", "RechitsEEGPU; No. of Rechits. No Filter GPU", nbins, 0, last);
0063   auto hRechitsEECPU = new TH1D("RechitsEECPU", "RechitsEECPU; No. of Rechits. No Filter GPU", nbins, 0, last);
0064   auto hRechitsEBGPUvsCPU =
0065       new TH2D("RechitsEBGPUvsCPU", "RechitsEBGPUvsCPU; CPU; GPU. No Filter GPU", last, 0, last, last, 0, last);
0066   auto hRechitsEEGPUvsCPU =
0067       new TH2D("RechitsEEGPUvsCPU", "RechitsEEGPUvsCPU; CPU; GPU. No Filter GPU", last, 0, last, last, 0, last);
0068   auto hRechitsEBGPUCPUratio =
0069       new TH1D("RechitsEBGPU/CPUratio", "RechitsEBGPU/CPUratio; GPU/CPU. No Filter GPU", 200, 0.95, 1.05);
0070   auto hRechitsEEGPUCPUratio =
0071       new TH1D("RechitsEEGPU/CPUratio", "RechitsEEGPU/CPUratio; GPU/CPU. No Filter GPU", 200, 0.95, 1.05);
0072   auto hRechitsEBdeltavsCPU =
0073       new TH2D("RechitsEBdeltavsCPU", "RechitsEBdeltavsCPU. No Filter GPU", nbins, 0, last, nbins_delta, -delta, delta);
0074   auto hRechitsEEdeltavsCPU =
0075       new TH2D("RechitsEEdeltavsCPU", "RechitsEEdeltavsCPU. No Filter GPU", nbins, 0, last, nbins_delta, -delta, delta);
0076 
0077   // RecHits plots for EB and EE on both GPU and CPU
0078   auto hSelectedRechitsEBGPU = new TH1D("RechitsEBGPU", "RechitsEBGPU; No. of Rechits", nbins, 0, last);
0079   auto hSelectedRechitsEBCPU = new TH1D("RechitsEBCPU", "RechitsEBCPU; No. of Rechits", nbins, 0, last);
0080   auto hSelectedRechitsEEGPU = new TH1D("RechitsEEGPU", "RechitsEEGPU; No. of Rechits", nbins, 0, last);
0081   auto hSelectedRechitsEECPU = new TH1D("RechitsEECPU", "RechitsEECPU; No. of Rechits", nbins, 0, last);
0082   auto hSelectedRechitsEBGPUvsCPU =
0083       new TH2D("RechitsEBGPUvsCPU", "RechitsEBGPUvsCPU; CPU; GPU", last, 0, last, last, 0, last);
0084   auto hSelectedRechitsEEGPUvsCPU =
0085       new TH2D("RechitsEEGPUvsCPU", "RechitsEEGPUvsCPU; CPU; GPU", last, 0, last, last, 0, last);
0086   auto hSelectedRechitsEBGPUCPUratio =
0087       new TH1D("RechitsEBGPU/CPUratio", "RechitsEBGPU/CPUratio; GPU/CPU", 200, 0.95, 1.05);
0088   auto hSelectedRechitsEEGPUCPUratio =
0089       new TH1D("RechitsEEGPU/CPUratio", "RechitsEEGPU/CPUratio; GPU/CPU", 200, 0.95, 1.05);
0090   auto hSelectedRechitsEBdeltavsCPU =
0091       new TH2D("RechitsEBdeltavsCPU", "RechitsEBdeltavsCPU", nbins, 0, last, nbins_delta, -delta, delta);
0092   auto hSelectedRechitsEEdeltavsCPU =
0093       new TH2D("RechitsEEdeltavsCPU", "RechitsEEdeltavsCPU", nbins, 0, last, nbins_delta, -delta, delta);
0094 
0095   // RecHits plots for EB and EE on both GPU and CPU
0096   auto hPositiveRechitsEBGPU = new TH1D("RechitsEBGPU", "RechitsEBGPU; No. of Rechits", nbins, 0, last);
0097   auto hPositiveRechitsEBCPU = new TH1D("RechitsEBCPU", "RechitsEBCPU; No. of Rechits", nbins, 0, last);
0098   auto hPositiveRechitsEEGPU = new TH1D("RechitsEEGPU", "RechitsEEGPU; No. of Rechits", nbins, 0, last);
0099   auto hPositiveRechitsEECPU = new TH1D("RechitsEECPU", "RechitsEECPU; No. of Rechits", nbins, 0, last);
0100   auto hPositiveRechitsEBGPUvsCPU =
0101       new TH2D("RechitsEBGPUvsCPU", "RechitsEBGPUvsCPU; CPU; GPU", last, 0, last, last, 0, last);
0102   auto hPositiveRechitsEEGPUvsCPU =
0103       new TH2D("RechitsEEGPUvsCPU", "RechitsEEGPUvsCPU; CPU; GPU", last, 0, last, last, 0, last);
0104   auto hPositiveRechitsEBGPUCPUratio =
0105       new TH1D("RechitsEBGPU/CPUratio", "RechitsEBGPU/CPUratio; GPU/CPU", 200, 0.95, 1.05);
0106   auto hPositiveRechitsEEGPUCPUratio =
0107       new TH1D("RechitsEEGPU/CPUratio", "RechitsEEGPU/CPUratio; GPU/CPU", 200, 0.95, 1.05);
0108   auto hPositiveRechitsEBdeltavsCPU =
0109       new TH2D("RechitsEBdeltavsCPU", "RechitsEBdeltavsCPU", nbins, 0, last, nbins_delta, -delta, delta);
0110   auto hPositiveRechitsEEdeltavsCPU =
0111       new TH2D("RechitsEEdeltavsCPU", "RechitsEEdeltavsCPU", nbins, 0, last, nbins_delta, -delta, delta);
0112 
0113   // Energies plots for EB and EE on both GPU and CPU
0114   auto hEnergiesEBGPU = new TH1D("EnergiesEBGPU", "EnergiesEBGPU; Energy [GeV]", nbins_energy, 0, last_energy);
0115   auto hEnergiesEEGPU = new TH1D("EnergiesEEGPU", "EnergiesEEGPU; Energy [GeV]", nbins_energy, 0, last_energy);
0116   auto hEnergiesEBCPU = new TH1D("EnergiesEBCPU", "EnergiesEBCPU; Energy [GeV]", nbins_energy, 0, last_energy);
0117   auto hEnergiesEECPU = new TH1D("EnergiesEECPU", "EnergiesEECPU; Energy [GeV]", nbins_energy, 0, last_energy);
0118   auto hEnergiesEBGPUvsCPU = new TH2D(
0119       "EnergiesEBGPUvsCPU", "EnergiesEBGPUvsCPU; CPU; GPU", nbins_energy, 0, last_energy, nbins_energy, 0, last_energy);
0120   auto hEnergiesEEGPUvsCPU = new TH2D(
0121       "EnergiesEEGPUvsCPU", "EnergiesEEGPUvsCPU; CPU; GPU", nbins_energy, 0, last_energy, nbins_energy, 0, last_energy);
0122   auto hEnergiesEBGPUCPUratio = new TH1D("EnergiesEBGPU/CPUratio", "EnergiesEBGPU/CPUratio; GPU/CPU", 100, 0.8, 1.2);
0123   auto hEnergiesEEGPUCPUratio = new TH1D("EnergiesEEGPU/CPUratio", "EnergiesEEGPU/CPUratio; GPU/CPU", 100, 0.8, 1.2);
0124   auto hEnergiesEBdeltavsCPU =
0125       new TH2D("EnergiesEBdeltavsCPU", "EnergiesEBdeltavsCPU", nbins, 0, last, nbins_delta, -delta, delta);
0126   auto hEnergiesEEdeltavsCPU =
0127       new TH2D("EnergiesEEdeltavsCPU", "EnergiesEEdeltavsCPU", nbins, 0, last, nbins_delta, -delta, delta);
0128 
0129   // Chi2 plots for EB and EE on both GPU and CPU
0130   auto hChi2EBGPU = new TH1D("Chi2EBGPU", "Chi2EBGPU; Ch^{2}", nbins_chi2, 0, last_chi2);
0131   auto hChi2EEGPU = new TH1D("Chi2EEGPU", "Chi2EEGPU; Ch^{2}", nbins_chi2, 0, last_chi2);
0132   auto hChi2EBCPU = new TH1D("Chi2EBCPU", "Chi2EBCPU; Ch^{2}", nbins_chi2, 0, last_chi2);
0133   auto hChi2EECPU = new TH1D("Chi2EECPU", "Chi2EECPU; Ch^{2}", nbins_chi2, 0, last_chi2);
0134   auto hChi2EBGPUvsCPU = new TH2D("Chi2EBGPUvsCPU", "Chi2EBGPUvsCPU; CPU; GPU", nbins_chi2, 0, 100, nbins_chi2, 0, 100);
0135   auto hChi2EEGPUvsCPU = new TH2D("Chi2EEGPUvsCPU", "Chi2EEGPUvsCPU; CPU; GPU", nbins_chi2, 0, 100, nbins_chi2, 0, 100);
0136   auto hChi2EBGPUCPUratio = new TH1D("Chi2EBGPU/CPUratio", "Chi2EBGPU/CPUratio; GPU/CPU", 100, 0.8, 1.2);
0137   auto hChi2EEGPUCPUratio = new TH1D("Chi2EEGPU/CPUratio", "Chi2EEGPU/CPUratio; GPU/CPU", 100, 0.8, 1.2);
0138   auto hChi2EBdeltavsCPU =
0139       new TH2D("Chi2EBdeltavsCPU", "Chi2EBdeltavsCPU", nbins_chi2, 0, last_chi2, nbins_delta, -delta, delta);
0140   auto hChi2EEdeltavsCPU =
0141       new TH2D("Chi2EEdeltavsCPU", "Chi2EEdeltavsCPU", nbins_chi2, 0, last_chi2, nbins_delta, -delta, delta);
0142 
0143   // Flags plots for EB and EE on both GPU and CPU
0144   auto hFlagsEBGPU = new TH1D("FlagsEBGPU", "FlagsEBGPU; Flags", nbins_flag, -10, last_flag);
0145   auto hFlagsEBCPU = new TH1D("FlagsEBCPU", "FlagsEBCPU; Flags", nbins_flag, -10, last_flag);
0146   auto hFlagsEEGPU = new TH1D("FlagsEEGPU", "FlagsEEGPU; Flags", nbins_flag, -10, last_flag);
0147   auto hFlagsEECPU = new TH1D("FlagsEECPU", "FlagsEECPU; Flags", nbins_flag, -10, last_flag);
0148   auto hFlagsEBGPUvsCPU =
0149       new TH2D("FlagsEBGPUvsCPU", "FlagsEBGPUvsCPU; CPU; GPU", nbins_flag, -10, last_flag, nbins_flag, -10, last_flag);
0150   auto hFlagsEEGPUvsCPU =
0151       new TH2D("FlagsEEGPUvsCPU", "FlagsEEGPUvsCPU; CPU; GPU", nbins_flag, -10, last_flag, nbins_flag, -10, last_flag);
0152   auto hFlagsEBGPUCPUratio = new TH1D("FlagsEBGPU/CPUratio", "FlagsEBGPU/CPUratio; GPU/CPU", 50, -5, 10);
0153   auto hFlagsEEGPUCPUratio = new TH1D("FlagsEEGPU/CPUratio", "FlagsEEGPU/CPUratio; GPU/CPU", 50, -5, 10);
0154   auto hFlagsEBdeltavsCPU =
0155       new TH2D("FlagsEBdeltavsCPU", "FlagsEBdeltavsCPU", nbins_flag, -10, last_flag, nbins_delta, -delta, delta);
0156   auto hFlagsEEdeltavsCPU =
0157       new TH2D("FlagsEEdeltavsCPU", "FlagsEEdeltavsCPU", nbins_flag, -10, last_flag, nbins_delta, -delta, delta);
0158 
0159   // Extras plots for EB and EE on both GPU and CPU
0160   auto hExtrasEBGPU = new TH1D("ExtrasEBGPU", "ExtrasEBGPU; No. of Extras", nbins_extra, 0, last_extra);
0161   auto hExtrasEBCPU = new TH1D("ExtrasEBCPU", "ExtrasEBCPU; No. of Extras", nbins_extra, 0, last_extra);
0162   auto hExtrasEEGPU = new TH1D("ExtrasEEGPU", "ExtrasEEGPU; No. of Extras", nbins_extra, 0, last_extra);
0163   auto hExtrasEECPU = new TH1D("ExtrasEECPU", "ExtrasEECPU; No. of Extras", nbins_extra, 0, last_extra);
0164   auto hExtrasEBGPUvsCPU = new TH2D(
0165       "ExtrasEBGPUvsCPU", "ExtrasEBGPUvsCPU; CPU; GPU", nbins_extra, 0, last_extra, nbins_extra, 0, last_extra);
0166   auto hExtrasEEGPUvsCPU = new TH2D(
0167       "ExtrasEEGPUvsCPU", "ExtrasEEGPUvsCPU; CPU; GPU", nbins_extra, 0, last_extra, nbins_extra, 0, last_extra);
0168   auto hExtrasEBGPUCPUratio = new TH1D("ExtrasEBGPU/CPUratio", "ExtrasEBGPU/CPUratio; GPU/CPU", 50, 0.0, 2.0);
0169   auto hExtrasEEGPUCPUratio = new TH1D("ExtrasEEGPU/CPUratio", "ExtrasEEGPU/CPUratio; GPU/CPU", 50, 0.0, 2.0);
0170   auto hExtrasEBdeltavsCPU =
0171       new TH2D("ExtrasEBdeltavsCPU", "ExtrasEBdeltavsCPU", nbins_extra, 0, last_extra, nbins_delta, -delta, delta);
0172   auto hExtrasEEdeltavsCPU =
0173       new TH2D("ExtrasEEdeltavsCPU", "ExtrasEEdeltavsCPU", nbins_extra, 0, last_extra, nbins_delta, -delta, delta);
0174 
0175   // input file setup for tree
0176   std::cout << "validating file " << fileName << std::endl;
0177   TFile rf{fileName.c_str()};
0178   TTree *rt = (TTree *)rf.Get("Events");
0179 
0180   // Allocating the appropriate data to their respective pointers
0181   rt->SetBranchAddress("ecalTagsoaecalRecHit_ecalCPURecHitProducer_EcalRecHitsEB_RECO.", &wgpuEB);
0182   rt->SetBranchAddress("ecalTagsoaecalRecHit_ecalCPURecHitProducer_EcalRecHitsEE_RECO.", &wgpuEE);
0183   rt->SetBranchAddress("EcalRecHitsSorted_ecalRecHit_EcalRecHitsEB_RECO.", &wcpuEB);
0184   rt->SetBranchAddress("EcalRecHitsSorted_ecalRecHit_EcalRecHitsEE_RECO.", &wcpuEE);
0185 
0186   // constexpr float eps_diff = 1e-3;
0187 
0188   // accumulate sizes for events and sizes of each event on both GPU and CPU
0189   //   auto const nentries = rt->GetEntries();
0190   int nentries = rt->GetEntries();
0191 
0192   //---- AM: tests
0193   if (nentries > 1000) {
0194     nentries = 1000;
0195   }
0196   //   nentries = 1;
0197 
0198   std::cout << "#events to validate over: " << nentries << std::endl;
0199   for (int ie = 0; ie < nentries; ++ie) {
0200     rt->GetEntry(ie);
0201 
0202     //     const char* ordinal[] = { "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th" };
0203     auto cpu_eb_size = wcpuEB->bareProduct().size();
0204     auto cpu_ee_size = wcpuEE->bareProduct().size();
0205     auto gpu_eb_size = wgpuEB->bareProduct().energy.size();
0206     auto gpu_ee_size = wgpuEE->bareProduct().energy.size();
0207     float eb_ratio = (float)gpu_eb_size / cpu_eb_size;
0208     float ee_ratio = (float)gpu_ee_size / cpu_ee_size;
0209 
0210     // Filling up the histograms on events sizes for EB and EE on both GPU and CPU
0211     hRechitsEBGPU->Fill(gpu_eb_size);
0212     hRechitsEBCPU->Fill(cpu_eb_size);
0213     hRechitsEEGPU->Fill(gpu_ee_size);
0214     hRechitsEECPU->Fill(cpu_ee_size);
0215     hRechitsEBGPUvsCPU->Fill(cpu_eb_size, gpu_eb_size);
0216     hRechitsEEGPUvsCPU->Fill(cpu_ee_size, gpu_ee_size);
0217     hRechitsEBGPUCPUratio->Fill(eb_ratio);
0218     hRechitsEEGPUCPUratio->Fill(ee_ratio);
0219     hRechitsEBdeltavsCPU->Fill(cpu_eb_size, gpu_eb_size - cpu_eb_size);
0220     hRechitsEEdeltavsCPU->Fill(cpu_ee_size, gpu_ee_size - cpu_ee_size);
0221 
0222     /*    
0223      *    // condition that sizes on GPU and CPU should be the same for EB or EE
0224      *       if (cpu_eb_size != gpu_eb_size or cpu_ee_size != gpu_ee_size) {
0225      *         std::cerr << ie << ordinal[ie % 10] << " entry:\n"
0226      *                   << "  EB size: " << std::setw(4) << cpu_eb_size << " (cpu) vs " << std::setw(4) << gpu_eb_size << " (gpu)\n"
0227      *                   << "  EE size: " << std::setw(4) << cpu_ee_size << " (cpu) vs " << std::setw(4) << gpu_ee_size << " (gpu)" << std::endl;
0228      *                  
0229      *         continue;
0230   }
0231   assert(wgpuEB->bareProduct().energy.size() == wcpuEB->bareProduct().size());
0232   assert(wgpuEE->bareProduct().energy.size() == wcpuEE->bareProduct().size()); 
0233   auto const neb = wcpuEB->bareProduct().size(); //like cpu_eb_size but set to constant
0234   auto const nee = wcpuEE->bareProduct().size(); //like cpu_ee_size but set to constant
0235   */
0236 
0237     uint selected_gpu_eb_size = 0;
0238     uint selected_gpu_ee_size = 0;
0239 
0240     uint positive_gpu_eb_size = 0;
0241     uint positive_gpu_ee_size = 0;
0242 
0243     // EB:
0244     for (uint32_t i = 0; i < gpu_eb_size; ++i) {
0245       auto const did_gpu = wgpuEB->bareProduct().did[i];  // set the did for the current RecHit
0246       // Set the variables for GPU
0247       auto const enr_gpu = wgpuEB->bareProduct().energy[i];
0248       auto const chi2_gpu = wgpuEB->bareProduct().chi2[i];
0249       auto const flag_gpu = wgpuEB->bareProduct().flagBits[i];
0250       auto const extra_gpu = wgpuEB->bareProduct().extra[i];
0251 
0252       // you have "-1" if the crystal is not selected
0253       if (enr_gpu >= 0) {
0254         selected_gpu_eb_size++;
0255 
0256         if (enr_gpu > 0) {
0257           positive_gpu_eb_size++;
0258         }
0259 
0260         // find the Rechit on CPU reflecting the same did
0261         auto const cpu_iter = wcpuEB->bareProduct().find(DetId{did_gpu});
0262         if (cpu_iter == wcpuEB->bareProduct().end()) {
0263           //           std::cerr << ie << ordinal[ie % 10] << " entry\n"
0264           //                   << "  Did not find a DetId " << did_gpu_eb
0265           //                 << " in a CPU collection\n";
0266           std::cerr << "  Did not find a DetId " << did_gpu << " in a CPU collection\n";
0267           continue;
0268         }
0269         // Set the variables for CPU
0270         auto const enr_cpu = cpu_iter->energy();
0271         auto const chi2_cpu = cpu_iter->chi2();
0272         //         auto const flag_cpu = cpu_iter->flagBits();
0273         auto const flag_cpu = 1;
0274         //         auto const extra_cpu = cpu_iter->extra();
0275         auto const extra_cpu = 1;
0276         //       auto const flag_cpu = cpu_iter->flagBits() ? cpu_iter->flagBits():-1;
0277         //       auto const extra_cpu = cpu_iter->extra() ? cpu_iter->extra():-1;
0278 
0279         // AM: TEST
0280         //       if (extra_cpu != 10) continue;
0281 
0282         // Fill the energy and Chi2 histograms for GPU and CPU and their comparisons with delta
0283         hEnergiesEBGPU->Fill(enr_gpu);
0284         hEnergiesEBCPU->Fill(enr_cpu);
0285         //       std::cout<<"EB CPU Energy:\t"<<enr_cpu<<std::endl;
0286         hEnergiesEBGPUvsCPU->Fill(enr_cpu, enr_gpu);
0287         hEnergiesEBGPUCPUratio->Fill(enr_gpu / enr_cpu);
0288         hEnergiesEBdeltavsCPU->Fill(enr_cpu, enr_gpu - enr_cpu);
0289 
0290         hChi2EBGPU->Fill(chi2_gpu);
0291         hChi2EBCPU->Fill(chi2_cpu);
0292         hChi2EBGPUvsCPU->Fill(chi2_cpu, chi2_gpu);
0293         hChi2EBGPUCPUratio->Fill(chi2_gpu / chi2_cpu);
0294         hChi2EBdeltavsCPU->Fill(chi2_cpu, chi2_gpu - chi2_cpu);
0295 
0296         hFlagsEBGPU->Fill(flag_gpu);
0297         hFlagsEBCPU->Fill(flag_cpu);
0298         hFlagsEBGPUvsCPU->Fill(flag_cpu, flag_gpu);
0299         hFlagsEBGPUCPUratio->Fill(flag_cpu ? flag_gpu / flag_cpu : -1);
0300         hFlagsEBdeltavsCPU->Fill(flag_cpu, flag_gpu - flag_cpu);
0301 
0302         hExtrasEBGPU->Fill(extra_gpu);
0303         hExtrasEBCPU->Fill(extra_cpu);
0304         hExtrasEBGPUvsCPU->Fill(extra_cpu, extra_gpu);
0305         hExtrasEBGPUCPUratio->Fill(extra_cpu ? extra_gpu / extra_cpu : -1);
0306         hExtrasEBdeltavsCPU->Fill(extra_cpu, extra_gpu - extra_cpu);
0307 
0308         // Check if abs difference between GPU and CPU values for energy and Chi2 are smaller than eps, if not print message
0309         // if ((std::abs(enr_gpu - enr_cpu) >= eps_diff) or
0310         //      (std::abs(chi2_gpu - chi2_cpu) >= eps_diff) or std::isnan(chi2_gpu))
0311         //  {
0312         //      printf("EB eventid = %d chid = %d energy_gpu = %f energy_cpu %f chi2_gpu = %f chi2_cpu = %f\n",
0313         //          ie, i, enr_gpu, enr_cpu, chi2_gpu, chi2_cpu);
0314         //      if (std::isnan(chi2_gpu))
0315         //        printf("*** nan ***\n");
0316         //  }
0317       }
0318     }
0319 
0320     // EE:
0321     for (uint32_t i = 0; i < gpu_ee_size; ++i) {
0322       auto const did_gpu = wgpuEE->bareProduct().did[i];  // set the did for the current RecHit
0323       // Set the variables for GPU
0324       auto const enr_gpu = wgpuEE->bareProduct().energy[i];
0325       auto const chi2_gpu = wgpuEE->bareProduct().chi2[i];
0326       auto const flag_gpu = wgpuEE->bareProduct().flagBits[i];
0327       auto const extra_gpu = wgpuEE->bareProduct().extra[i];
0328 
0329       // you have "-1" if the crystal is not selected
0330       if (enr_gpu >= 0) {
0331         selected_gpu_ee_size++;
0332 
0333         if (enr_gpu > 0) {
0334           positive_gpu_ee_size++;
0335         }
0336 
0337         // find the Rechit on CPU reflecting the same did
0338         auto const cpu_iter = wcpuEE->bareProduct().find(DetId{did_gpu});
0339         if (cpu_iter == wcpuEE->bareProduct().end()) {
0340           //    std::cerr << ie << ordinal[ie % 10] << " entry\n"
0341           //            << "  Did not find a DetId " << did_gpu
0342           //          << " in a CPU collection\n";
0343           std::cerr << "  Did not find a DetId " << did_gpu << " in a CPU collection\n";
0344           continue;
0345         }
0346         // Set the variables for CPU
0347         auto const enr_cpu = cpu_iter->energy();
0348         auto const chi2_cpu = cpu_iter->chi2();
0349         //         auto const flag_cpu = cpu_iter->flagBits();
0350         auto const flag_cpu = 1;
0351         //         auto const extra_cpu = cpu_iter->extra();
0352         auto const extra_cpu = 1;
0353         //       auto const flag_cpu = cpu_iter->flagBits()?cpu_iter->flagBits():-1;
0354         //       auto const extra_cpu = cpu_iter->extra()?cpu_iter->extra():-1;
0355 
0356         // AM: TEST
0357         //       if (extra_cpu != 10) continue;
0358 
0359         // Fill the energy and Chi2 histograms for GPU and CPU and their comparisons with delta
0360         hEnergiesEEGPU->Fill(enr_gpu);
0361         hEnergiesEECPU->Fill(enr_cpu);
0362         hEnergiesEEGPUvsCPU->Fill(enr_cpu, enr_gpu);
0363         hEnergiesEEGPUCPUratio->Fill(enr_gpu / enr_cpu);
0364         hEnergiesEEdeltavsCPU->Fill(enr_cpu, enr_gpu - enr_cpu);
0365 
0366         hChi2EEGPU->Fill(chi2_gpu);
0367         hChi2EECPU->Fill(chi2_cpu);
0368         hChi2EEGPUvsCPU->Fill(chi2_cpu, chi2_gpu);
0369         hChi2EEGPUCPUratio->Fill(chi2_gpu / chi2_cpu);
0370         hChi2EEdeltavsCPU->Fill(chi2_cpu, chi2_gpu - chi2_cpu);
0371 
0372         hFlagsEEGPU->Fill(flag_gpu);
0373         hFlagsEECPU->Fill(flag_cpu);
0374         hFlagsEEGPUvsCPU->Fill(flag_cpu, flag_gpu);
0375         hFlagsEEGPUCPUratio->Fill(flag_cpu ? flag_gpu / flag_cpu : -1);
0376         hFlagsEEdeltavsCPU->Fill(flag_cpu, flag_gpu - flag_cpu);
0377 
0378         hExtrasEEGPU->Fill(extra_gpu);
0379         hExtrasEECPU->Fill(extra_cpu);
0380         hExtrasEEGPUvsCPU->Fill(extra_cpu, extra_gpu);
0381         hExtrasEEGPUCPUratio->Fill(extra_cpu ? extra_gpu / extra_cpu : -1);
0382         hExtrasEEdeltavsCPU->Fill(extra_cpu, extra_gpu - extra_cpu);
0383 
0384         // Check if abs difference between GPU and CPU values for energy and Chi2 are smaller than eps, if not print message
0385         // if ((std::abs(enr_gpu - enr_cpu) >= eps_diff) or
0386         //      (std::abs(chi2_gpu - chi2_cpu) >= eps_diff) or std::isnan(chi2_gpu))
0387         //  {
0388         //      printf("EE eventid = %d chid = %d energy_gpu = %f energy_cpu %f chi2_gpu = %f chi2_cpu = %f\n",
0389         //          ie, i, enr_gpu, enr_cpu, chi2_gpu, chi2_cpu);
0390         //      if (std::isnan(chi2_gpu))
0391         //        printf("*** nan ***\n");
0392         //  }
0393       }
0394     }
0395 
0396     //
0397     // now the rechit counting
0398     //
0399     float selected_eb_ratio = (float)selected_gpu_eb_size / cpu_eb_size;
0400     float selected_ee_ratio = (float)selected_gpu_ee_size / cpu_ee_size;
0401 
0402     // Filling up the histograms on events sizes for EB and EE on both GPU and CPU
0403     hSelectedRechitsEBGPU->Fill(selected_gpu_eb_size);
0404     hSelectedRechitsEBCPU->Fill(cpu_eb_size);
0405     hSelectedRechitsEEGPU->Fill(selected_gpu_ee_size);
0406     hSelectedRechitsEECPU->Fill(cpu_ee_size);
0407     hSelectedRechitsEBGPUvsCPU->Fill(cpu_eb_size, selected_gpu_eb_size);
0408     hSelectedRechitsEEGPUvsCPU->Fill(cpu_ee_size, selected_gpu_ee_size);
0409     hSelectedRechitsEBGPUCPUratio->Fill(selected_eb_ratio);
0410     hSelectedRechitsEEGPUCPUratio->Fill(selected_ee_ratio);
0411     hSelectedRechitsEBdeltavsCPU->Fill(cpu_eb_size, selected_gpu_eb_size - cpu_eb_size);
0412     hSelectedRechitsEEdeltavsCPU->Fill(cpu_ee_size, selected_gpu_ee_size - cpu_ee_size);
0413 
0414     //
0415     // now the rechit counting
0416     //
0417 
0418     uint positive_cpu_eb_size = 0;
0419     uint positive_cpu_ee_size = 0;
0420 
0421     // EB:
0422     for (uint32_t i = 0; i < cpu_eb_size; ++i) {
0423       auto const enr_cpu = wcpuEB->bareProduct()[i].energy();
0424       if (enr_cpu > 0) {
0425         positive_cpu_eb_size++;
0426       }
0427     }
0428     // EE:
0429     for (uint32_t i = 0; i < cpu_ee_size; ++i) {
0430       auto const enr_cpu = wcpuEE->bareProduct()[i].energy();
0431       if (enr_cpu > 0) {
0432         positive_cpu_ee_size++;
0433       }
0434     }
0435 
0436     float positive_eb_ratio = (float)positive_gpu_eb_size / positive_cpu_eb_size;
0437     float positive_ee_ratio = (float)positive_gpu_ee_size / positive_cpu_ee_size;
0438 
0439     // Filling up the histograms on events sizes for EB and EE on both GPU and CPU
0440     hPositiveRechitsEBGPU->Fill(positive_gpu_eb_size);
0441     hPositiveRechitsEBCPU->Fill(positive_cpu_eb_size);
0442     hPositiveRechitsEEGPU->Fill(positive_gpu_ee_size);
0443     hPositiveRechitsEECPU->Fill(positive_cpu_ee_size);
0444     hPositiveRechitsEBGPUvsCPU->Fill(positive_cpu_eb_size, positive_gpu_eb_size);
0445     hPositiveRechitsEEGPUvsCPU->Fill(positive_cpu_ee_size, positive_gpu_ee_size);
0446     hPositiveRechitsEBGPUCPUratio->Fill(positive_eb_ratio);
0447     hPositiveRechitsEEGPUCPUratio->Fill(positive_ee_ratio);
0448     hPositiveRechitsEBdeltavsCPU->Fill(positive_cpu_eb_size, positive_gpu_eb_size - positive_cpu_eb_size);
0449     hPositiveRechitsEEdeltavsCPU->Fill(positive_cpu_ee_size, positive_gpu_ee_size - positive_cpu_ee_size);
0450 
0451     if (cpu_eb_size != selected_gpu_eb_size or cpu_ee_size != selected_gpu_ee_size) {
0452       //       std::cerr << ie << ordinal[ie % 10] << " entry:\n"
0453       std::cerr << ie << " entry:\n"
0454                 << "  EB size: " << std::setw(4) << cpu_eb_size << " (cpu) vs " << std::setw(4) << selected_gpu_eb_size
0455                 << " (gpu)\n"
0456                 << "  EE size: " << std::setw(4) << cpu_ee_size << " (cpu) vs " << std::setw(4) << selected_gpu_ee_size
0457                 << " (gpu)" << std::endl;
0458     }
0459   }
0460 
0461   // Plotting the results:
0462   {
0463     // Canvases Setup:
0464     TCanvas cAllRechits("AllRechits", "AllRechits", 1750, 860);
0465     cAllRechits.Divide(3, 2);
0466     TCanvas cRechits("Rechits", "Rechits", 1750, 860);
0467     cRechits.Divide(3, 2);
0468     TCanvas cRechitsPositive("RechitsPositive", "RechitsPositive", 1750, 860);
0469     cRechitsPositive.Divide(3, 2);
0470     TCanvas cEnergies("Energies", "Energies", 1750, 860);
0471     cEnergies.Divide(3, 2);
0472     TCanvas cChi2("Chi2", "Chi2", 1750, 860);
0473     cChi2.Divide(3, 2);
0474     TCanvas cFlags("Flags", "Flags", 1750, 860);
0475     cFlags.Divide(3, 2);
0476     TCanvas cExtras("Extras", "Extras", 1750, 860);
0477     cExtras.Divide(3, 2);
0478 
0479     // Plotting the sizes of GPU vs CPU for each event of EB
0480     cAllRechits.cd(1);
0481     {
0482       gPad->SetLogy();
0483       hRechitsEBCPU->SetLineColor(kRed);
0484       hRechitsEBCPU->SetLineWidth(2);
0485       hRechitsEBCPU->Draw("");
0486       hRechitsEBGPU->SetLineColor(kBlue);
0487       hRechitsEBGPU->SetLineWidth(2);
0488       hRechitsEBGPU->Draw("sames");
0489       cAllRechits.Update();
0490       auto stats = (TPaveStats *)hRechitsEBGPU->FindObject("stats");
0491       auto y2 = stats->GetY2NDC();
0492       auto y1 = stats->GetY1NDC();
0493       stats->SetY2NDC(y1);
0494       stats->SetY1NDC(y1 - (y2 - y1));
0495     }
0496     cAllRechits.cd(4);
0497     {
0498       gPad->SetLogy();
0499       hRechitsEECPU->SetLineColor(kRed);
0500       hRechitsEECPU->SetLineWidth(2);
0501       hRechitsEECPU->Draw("");
0502       hRechitsEEGPU->SetLineColor(kBlue);
0503       hRechitsEEGPU->SetLineWidth(2);
0504       hRechitsEEGPU->Draw("sames");
0505       cAllRechits.Update();
0506       auto stats = (TPaveStats *)hRechitsEEGPU->FindObject("stats");
0507       auto y2 = stats->GetY2NDC();
0508       auto y1 = stats->GetY1NDC();
0509       stats->SetY2NDC(y1);
0510       stats->SetY1NDC(y1 - (y2 - y1));
0511     }
0512     cAllRechits.cd(2);
0513     {
0514       gStyle->SetPalette(55);
0515       hRechitsEBGPUvsCPU->Draw("COLZ");
0516     }
0517     cAllRechits.cd(5);
0518     {
0519       gStyle->SetPalette(55);
0520       hRechitsEEGPUvsCPU->Draw("COLZ");
0521     }
0522     cAllRechits.cd(3);
0523     {
0524       gPad->SetLogy();
0525       //hRechitsEBdeltavsCPU->Draw("COLZ");
0526       hRechitsEBGPUCPUratio->Draw("");
0527     }
0528     cAllRechits.cd(6);
0529     {
0530       gPad->SetLogy();
0531       //hRechitsEEdeltavsCPU->Draw("COLZ");
0532       hRechitsEEGPUCPUratio->Draw("");
0533     }
0534     cAllRechits.SaveAs("ecal-allrechits.root");
0535     cAllRechits.SaveAs("ecal-allrechits.png");
0536 
0537     // Plotting the sizes of GPU vs CPU for each event of EB
0538     cRechits.cd(1);
0539     {
0540       gPad->SetLogy();
0541       hSelectedRechitsEBCPU->SetLineColor(kRed);
0542       hSelectedRechitsEBCPU->SetLineWidth(2);
0543       hSelectedRechitsEBCPU->Draw("");
0544       hSelectedRechitsEBGPU->SetLineColor(kBlue);
0545       hSelectedRechitsEBGPU->SetLineWidth(2);
0546       hSelectedRechitsEBGPU->Draw("sames");
0547       cRechits.Update();
0548       auto stats = (TPaveStats *)hSelectedRechitsEBGPU->FindObject("stats");
0549       auto y2 = stats->GetY2NDC();
0550       auto y1 = stats->GetY1NDC();
0551       stats->SetY2NDC(y1);
0552       stats->SetY1NDC(y1 - (y2 - y1));
0553     }
0554     cRechits.cd(4);
0555     {
0556       gPad->SetLogy();
0557       hSelectedRechitsEECPU->SetLineColor(kRed);
0558       hSelectedRechitsEECPU->SetLineWidth(2);
0559       hSelectedRechitsEECPU->Draw("");
0560       hSelectedRechitsEEGPU->SetLineColor(kBlue);
0561       hSelectedRechitsEEGPU->SetLineWidth(2);
0562       hSelectedRechitsEEGPU->Draw("sames");
0563       cRechits.Update();
0564       auto stats = (TPaveStats *)hSelectedRechitsEEGPU->FindObject("stats");
0565       auto y2 = stats->GetY2NDC();
0566       auto y1 = stats->GetY1NDC();
0567       stats->SetY2NDC(y1);
0568       stats->SetY1NDC(y1 - (y2 - y1));
0569     }
0570     cRechits.cd(2);
0571     {
0572       gStyle->SetPalette(55);
0573       hSelectedRechitsEBGPUvsCPU->Draw("COLZ");
0574     }
0575     cRechits.cd(5);
0576     {
0577       gStyle->SetPalette(55);
0578       hSelectedRechitsEEGPUvsCPU->Draw("COLZ");
0579     }
0580     cRechits.cd(3);
0581     {
0582       gPad->SetLogy();
0583       //hSelectedRechitsEBdeltavsCPU->Draw("COLZ");
0584       hSelectedRechitsEBGPUCPUratio->Draw("");
0585     }
0586     cRechits.cd(6);
0587     {
0588       gPad->SetLogy();
0589       //hSelectedRechitsEEdeltavsCPU->Draw("COLZ");
0590       hSelectedRechitsEEGPUCPUratio->Draw("");
0591     }
0592     cRechits.SaveAs("ecal-rechits.root");
0593     cRechits.SaveAs("ecal-rechits.png");
0594 
0595     // Plotting the sizes of GPU vs CPU for each event of EB
0596     cRechitsPositive.cd(1);
0597     {
0598       gPad->SetLogy();
0599       hPositiveRechitsEBCPU->SetLineColor(kRed);
0600       hPositiveRechitsEBCPU->SetLineWidth(2);
0601       hPositiveRechitsEBCPU->Draw("");
0602       hPositiveRechitsEBGPU->SetLineColor(kBlue);
0603       hPositiveRechitsEBGPU->SetLineWidth(2);
0604       hPositiveRechitsEBGPU->Draw("sames");
0605       cRechitsPositive.Update();
0606       auto stats = (TPaveStats *)hPositiveRechitsEBGPU->FindObject("stats");
0607       auto y2 = stats->GetY2NDC();
0608       auto y1 = stats->GetY1NDC();
0609       stats->SetY2NDC(y1);
0610       stats->SetY1NDC(y1 - (y2 - y1));
0611     }
0612     cRechitsPositive.cd(4);
0613     {
0614       gPad->SetLogy();
0615       hPositiveRechitsEECPU->SetLineColor(kRed);
0616       hPositiveRechitsEECPU->SetLineWidth(2);
0617       hPositiveRechitsEECPU->Draw("");
0618       hPositiveRechitsEEGPU->SetLineColor(kBlue);
0619       hPositiveRechitsEEGPU->SetLineWidth(2);
0620       hPositiveRechitsEEGPU->Draw("sames");
0621       cRechitsPositive.Update();
0622       auto stats = (TPaveStats *)hPositiveRechitsEEGPU->FindObject("stats");
0623       auto y2 = stats->GetY2NDC();
0624       auto y1 = stats->GetY1NDC();
0625       stats->SetY2NDC(y1);
0626       stats->SetY1NDC(y1 - (y2 - y1));
0627     }
0628     cRechitsPositive.cd(2);
0629     {
0630       gStyle->SetPalette(55);
0631       hPositiveRechitsEBGPUvsCPU->Draw("COLZ");
0632     }
0633     cRechitsPositive.cd(5);
0634     {
0635       gStyle->SetPalette(55);
0636       hPositiveRechitsEEGPUvsCPU->Draw("COLZ");
0637     }
0638     cRechitsPositive.cd(3);
0639     {
0640       gPad->SetLogy();
0641       //hPositiveRechitsEBdeltavsCPU->Draw("COLZ");
0642       hPositiveRechitsEBGPUCPUratio->Draw("");
0643     }
0644     cRechitsPositive.cd(6);
0645     {
0646       gPad->SetLogy();
0647       //hPositiveRechitsEEdeltavsCPU->Draw("COLZ");
0648       hPositiveRechitsEEGPUCPUratio->Draw("");
0649     }
0650     cRechitsPositive.SaveAs("ecal-rechits-positive.root");
0651     cRechitsPositive.SaveAs("ecal-rechits-positive.png");
0652 
0653     cEnergies.cd(1);
0654     {
0655       gPad->SetLogy();
0656       hEnergiesEBCPU->SetLineColor(kBlack);
0657       hEnergiesEBCPU->SetLineWidth(2);
0658       hEnergiesEBCPU->Draw("");
0659       hEnergiesEBGPU->SetLineColor(kBlue);
0660       hEnergiesEBGPU->SetLineWidth(2);
0661       hEnergiesEBGPU->Draw("sames");
0662       gPad->Update();
0663       auto stats = (TPaveStats *)hEnergiesEBGPU->FindObject("stats");
0664       auto y2 = stats->GetY2NDC();
0665       auto y1 = stats->GetY1NDC();
0666       stats->SetY2NDC(y1);
0667       stats->SetY1NDC(y1 - (y2 - y1));
0668     }
0669     cEnergies.cd(4);
0670     {
0671       gPad->SetLogy();
0672       hEnergiesEECPU->SetLineColor(kBlack);
0673       hEnergiesEECPU->SetLineWidth(2);
0674       hEnergiesEECPU->Draw("");
0675       hEnergiesEEGPU->SetLineColor(kBlue);
0676       hEnergiesEEGPU->SetLineWidth(2);
0677       hEnergiesEEGPU->Draw("sames");
0678       gPad->Update();
0679       auto stats = (TPaveStats *)hEnergiesEEGPU->FindObject("stats");
0680       auto y2 = stats->GetY2NDC();
0681       auto y1 = stats->GetY1NDC();
0682       stats->SetY2NDC(y1);
0683       stats->SetY1NDC(y1 - (y2 - y1));
0684     }
0685     cEnergies.cd(2);
0686     { hEnergiesEBGPUvsCPU->Draw("COLZ"); }
0687     cEnergies.cd(5);
0688     { hEnergiesEEGPUvsCPU->Draw("COLZ"); }
0689     cEnergies.cd(3);
0690     {
0691       gPad->SetLogy();
0692       //hEnergiesEBdeltavsCPU->Draw("COLZ");
0693       hEnergiesEBGPUCPUratio->Draw("");
0694     }
0695     cEnergies.cd(6);
0696     {
0697       gPad->SetLogy();
0698       //hEnergiesEEdeltavsCPU->Draw("COLZ");
0699       hEnergiesEEGPUCPUratio->Draw("");
0700     }
0701     cEnergies.SaveAs("ecal-energies.root");
0702     cEnergies.SaveAs("ecal-energies.png");
0703 
0704     cChi2.cd(1);
0705     {
0706       gPad->SetLogy();
0707       hChi2EBCPU->SetLineColor(kBlack);
0708       hChi2EBCPU->SetLineWidth(2);
0709       hChi2EBCPU->Draw("");
0710       hChi2EBGPU->SetLineColor(kBlue);
0711       hChi2EBGPU->SetLineWidth(2);
0712       hChi2EBGPU->Draw("sames");
0713       gPad->Update();
0714       auto stats = (TPaveStats *)hChi2EBGPU->FindObject("stats");
0715       auto y2 = stats->GetY2NDC();
0716       auto y1 = stats->GetY1NDC();
0717       stats->SetY2NDC(y1);
0718       stats->SetY1NDC(y1 - (y2 - y1));
0719     }
0720     cChi2.cd(4);
0721     {
0722       gPad->SetLogy();
0723       hChi2EECPU->SetLineColor(kBlack);
0724       hChi2EECPU->SetLineWidth(2);
0725       hChi2EECPU->Draw("");
0726       hChi2EEGPU->SetLineColor(kBlue);
0727       hChi2EEGPU->SetLineWidth(2);
0728       hChi2EEGPU->Draw("sames");
0729       gPad->Update();
0730       auto stats = (TPaveStats *)hChi2EEGPU->FindObject("stats");
0731       auto y2 = stats->GetY2NDC();
0732       auto y1 = stats->GetY1NDC();
0733       stats->SetY2NDC(y1);
0734       stats->SetY1NDC(y1 - (y2 - y1));
0735     }
0736     cChi2.cd(2);
0737     { hChi2EBGPUvsCPU->Draw("COLZ"); }
0738     cChi2.cd(5);
0739     { hChi2EEGPUvsCPU->Draw("COLZ"); }
0740     cChi2.cd(3);
0741     {
0742       gPad->SetLogy();
0743       //hChi2EBdeltavsCPU->Draw("COLZ");
0744       hChi2EBGPUCPUratio->Draw("");
0745     }
0746     cChi2.cd(6);
0747     {
0748       gPad->SetLogy();
0749       //hChi2EEdeltavsCPU->Draw("COLZ");
0750       hChi2EEGPUCPUratio->Draw("");
0751     }
0752     cChi2.SaveAs("ecal-chi2.root");
0753     cChi2.SaveAs("ecal-chi2.png");
0754 
0755     cFlags.cd(1);
0756     {
0757       gPad->SetLogy();
0758       hFlagsEBCPU->SetLineColor(kBlack);
0759       hFlagsEBCPU->SetLineWidth(2);
0760       hFlagsEBCPU->Draw("");
0761       hFlagsEBGPU->SetLineColor(kBlue);
0762       hFlagsEBGPU->SetLineWidth(2);
0763       hFlagsEBGPU->Draw("sames");
0764       gPad->Update();
0765       auto stats = (TPaveStats *)hFlagsEBGPU->FindObject("stats");
0766       auto y2 = stats->GetY2NDC();
0767       auto y1 = stats->GetY1NDC();
0768       stats->SetY2NDC(y1);
0769       stats->SetY1NDC(y1 - (y2 - y1));
0770     }
0771     cFlags.cd(4);
0772     {
0773       gPad->SetLogy();
0774       hFlagsEECPU->SetLineColor(kBlack);
0775       hFlagsEECPU->SetLineWidth(2);
0776       hFlagsEECPU->Draw("");
0777       hFlagsEEGPU->SetLineColor(kBlue);
0778       hFlagsEEGPU->SetLineWidth(2);
0779       hFlagsEEGPU->Draw("sames");
0780       gPad->Update();
0781       auto stats = (TPaveStats *)hFlagsEEGPU->FindObject("stats");
0782       auto y2 = stats->GetY2NDC();
0783       auto y1 = stats->GetY1NDC();
0784       stats->SetY2NDC(y1);
0785       stats->SetY1NDC(y1 - (y2 - y1));
0786     }
0787     cFlags.cd(2);
0788     { hFlagsEBGPUvsCPU->Draw("COLZ"); }
0789     cFlags.cd(5);
0790     { hFlagsEEGPUvsCPU->Draw("COLZ"); }
0791     cFlags.cd(3);
0792     {
0793       gPad->SetLogy();
0794       //hFlagsEBdeltavsCPU->Draw("COLZ");
0795       hFlagsEBGPUCPUratio->Draw("");
0796     }
0797     cFlags.cd(6);
0798     {
0799       gPad->SetLogy();
0800       //hFlagsEEdeltavsCPU->Draw("COLZ");
0801       hFlagsEEGPUCPUratio->Draw("");
0802     }
0803     cFlags.SaveAs("ecal-flags.root");
0804     cFlags.SaveAs("ecal-flags.png");
0805 
0806     cExtras.cd(1);
0807     {
0808       gPad->SetLogy();
0809       hExtrasEBCPU->SetLineColor(kBlack);
0810       hExtrasEBCPU->SetLineWidth(2);
0811       hExtrasEBCPU->Draw("");
0812       hExtrasEBGPU->SetLineColor(kBlue);
0813       hExtrasEBGPU->SetLineWidth(2);
0814       hExtrasEBGPU->Draw("sames");
0815       gPad->Update();
0816       auto stats = (TPaveStats *)hExtrasEBGPU->FindObject("stats");
0817       auto y2 = stats->GetY2NDC();
0818       auto y1 = stats->GetY1NDC();
0819       stats->SetY2NDC(y1);
0820       stats->SetY1NDC(y1 - (y2 - y1));
0821     }
0822     cExtras.cd(4);
0823     {
0824       gPad->SetLogy();
0825       hExtrasEECPU->SetLineColor(kBlack);
0826       hExtrasEECPU->SetLineWidth(2);
0827       hExtrasEECPU->Draw("");
0828       hExtrasEEGPU->SetLineColor(kBlue);
0829       hExtrasEEGPU->SetLineWidth(2);
0830       hExtrasEEGPU->Draw("sames");
0831       gPad->Update();
0832       auto stats = (TPaveStats *)hExtrasEEGPU->FindObject("stats");
0833       auto y2 = stats->GetY2NDC();
0834       auto y1 = stats->GetY1NDC();
0835       stats->SetY2NDC(y1);
0836       stats->SetY1NDC(y1 - (y2 - y1));
0837     }
0838     cExtras.cd(2);
0839     { hExtrasEBGPUvsCPU->Draw("COLZ"); }
0840     cExtras.cd(5);
0841     { hExtrasEEGPUvsCPU->Draw("COLZ"); }
0842     cExtras.cd(3);
0843     {
0844       gPad->SetLogy();
0845       //hExtrasEBdeltavsCPU->Draw("COLZ");
0846       hExtrasEBGPUCPUratio->Draw("");
0847     }
0848     cExtras.cd(6);
0849     {
0850       gPad->SetLogy();
0851       //hExtrasEEdeltavsCPU->Draw("COLZ");
0852       hExtrasEEGPUCPUratio->Draw("");
0853     }
0854     cExtras.SaveAs("ecal-extras.root");
0855     cExtras.SaveAs("ecal-extras.png");
0856   }
0857 
0858   // Close all open files
0859   rf.Close();
0860   rfout.Write();
0861   rfout.Close();
0862 
0863   return 0;
0864 }