diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/lib/CaloGeometry.cxx b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/lib/CaloGeometry.cxx index a62e63d45b23f45b2d518854e072d2fe93b97713..5beb479f7d9c575665ce2fdcc8549d2a9eb74862 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/lib/CaloGeometry.cxx +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/lib/CaloGeometry.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "ISF_FastCaloSimParametrization/CaloGeometry.h" @@ -353,6 +353,9 @@ void CaloGeometry::InitRZmaps() TGraph* CaloGeometry::DrawGeoSampleForPhi0(int sample, int calocol, bool print) { + if (sample < CaloSampling::PreSamplerB || sample >= CaloSampling::Unknown) { + return nullptr; + } TGraph* firstgr=0; cout<<"Start sample "<<sample<<" ("<<SamplingName(sample)<<")"<<endl; int ngr=0; diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/AtlasUtils.C b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/AtlasUtils.C index 58cbccee1a8982bbc8195c1f1d638798d5e43729..bda6ce2379e1bf8203aba6e1392ad3a4931ed4ce 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/AtlasUtils.C +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/AtlasUtils.C @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ @@ -27,8 +27,14 @@ TGraphErrors* myTGraphErrorsDivide(TGraphErrors* g1,TGraphErrors* g2) { const Int_t debug=0; - if (!g1) printf("**myTGraphErrorsDivide: g1 does not exist ! \n"); - if (!g2) printf("**myTGraphErrorsDivide: g2 does not exist ! \n"); + if (!g1) { + printf("**myTGraphErrorsDivide: g1 does not exist ! \n"); + return nullptr; + } + if (!g2) { + printf("**myTGraphErrorsDivide: g2 does not exist ! \n"); + return nullptr; + } Int_t n1=g1->GetN(); @@ -249,7 +255,10 @@ void myAddtoBand(TGraphErrors* g1, TGraphAsymmErrors* g2) { TGraphErrors* TH1TOTGraph(TH1 *h1){ - if (!h1) std::cout << "TH1TOTGraph: histogram not found !" << std::endl; + if (!h1) { + std::cout << "TH1TOTGraph: histogram not found !" << std::endl; + return nullptr; + } TGraphErrors* g1= new TGraphErrors(); diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/CaloGeometryFromFile.cxx b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/CaloGeometryFromFile.cxx index c05285be250dd3e408809179814a791baa82b5fe..50e2aeef58b124447be4cd9040fa83dbd37c8520 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/CaloGeometryFromFile.cxx +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/CaloGeometryFromFile.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "CaloGeometryFromFile.h" @@ -155,11 +155,15 @@ bool CaloGeometryFromFile::LoadGeometryFromFile(TString filename,TString treenam std::cout << "\n \n"; std::cout << "Testing whether CaloGeoGeometry is loaded properly" << std::endl; - if(!mcell)std::cout << "Cell is not found" << std::endl; - std::cout << "Identifier " << mcell->identify() <<" sampling " << mcell->getSampling() << " eta: " << mcell->eta() << " phi: " << mcell->phi() << " CaloDetDescrElement="<<mcell << std::endl<< std::endl; + if(!mcell) { + std::cout << "Cell is not found" << std::endl; + } + else { + std::cout << "Identifier " << mcell->identify() <<" sampling " << mcell->getSampling() << " eta: " << mcell->eta() << " phi: " << mcell->phi() << " CaloDetDescrElement="<<mcell << std::endl<< std::endl; - const CaloDetDescrElement* mcell2 = this->getDDE(mcell->getSampling(),mcell->eta(),mcell->phi()); - std::cout << "Identifier " << mcell2->identify() <<" sampling " << mcell2->getSampling() << " eta: " << mcell2->eta() << " phi: " << mcell2->phi() << " CaloDetDescrElement="<<mcell2<< std::endl<< std::endl; + const CaloDetDescrElement* mcell2 = this->getDDE(mcell->getSampling(),mcell->eta(),mcell->phi()); + std::cout << "Identifier " << mcell2->identify() <<" sampling " << mcell2->getSampling() << " eta: " << mcell2->eta() << " phi: " << mcell2->phi() << " CaloDetDescrElement="<<mcell2<< std::endl<< std::endl; + } return ok; } diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/wiggleClosureAndComparison.cxx b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/wiggleClosureAndComparison.cxx index 9f51c4f948786f388c913db23f7cc7a00a3336b1..6513050e117116f69d578642a7e9aafed54a61f4 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/wiggleClosureAndComparison.cxx +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/wiggleClosureAndComparison.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "FCS_Cell.h" @@ -326,16 +326,18 @@ void wiggleClosureAndComparison(TString sampling="Sampling_0"){ if(hitSampling<21)someCell=geo->getDDE(hitSampling,hitVec->Eta(),hitVec->Phi()); else if (hitSampling<24)someCell=geo->getFCalDDE(hitSampling,x,y,z); else someCell=0; - Long64_t someCellID = someCell->identify(); + if (someCell) { + Long64_t someCellID = someCell->identify(); - if (Eoriginal.find(someCellID) != Eoriginal.end()){ - std::map<Long64_t, double>::iterator someit = Eoriginal.find(someCellID); - someit->second+=((FCS_matchedcell)(*vec)[j]).hit[ihit].hit_energy; - } //end cells exist + if (Eoriginal.find(someCellID) != Eoriginal.end()){ + std::map<Long64_t, double>::iterator someit = Eoriginal.find(someCellID); + someit->second+=((FCS_matchedcell)(*vec)[j]).hit[ihit].hit_energy; + } //end cells exist - else { - Eoriginal.insert(std::pair<Long64_t, double>(someCellID, ((FCS_matchedcell)(*vec)[j]).hit[ihit].hit_energy)); - }//end of else creating new cell + else { + Eoriginal.insert(std::pair<Long64_t, double>(someCellID, ((FCS_matchedcell)(*vec)[j]).hit[ihit].hit_energy)); + }//end of else creating new cell + } } //end hit loop //Eoriginal.insert(std::pair<Long64_t, double>(((FCS_matchedcell)(*vec)[j]).cell.cell_identifier, sum_energy_hit)); @@ -415,16 +417,18 @@ void wiggleClosureAndComparison(TString sampling="Sampling_0"){ else foundCell=0; //deposit energy in specific cell - Long64_t foundCellID = foundCell->identify(); - if (Eclosure.find(foundCellID) != Eclosure.end()){ - std::map<Long64_t, double>::iterator it = Eclosure.find(foundCellID); - // found cell iD: foundCell->identify() - it->second+=((FCS_matchedcell)(*vec)[j]).hit[ihit].hit_energy; - } //end cells exist - else { - //create the cell --> OK assigned probabilistically although not really in terms of cell IDs - Eclosure.insert(std::pair<Long64_t, double>(foundCellID, ((FCS_matchedcell)(*vec)[j]).hit[ihit].hit_energy)); - }//end of else creating new cell + if (foundCell) { + Long64_t foundCellID = foundCell->identify(); + if (Eclosure.find(foundCellID) != Eclosure.end()){ + std::map<Long64_t, double>::iterator it = Eclosure.find(foundCellID); + // found cell iD: foundCell->identify() + it->second+=((FCS_matchedcell)(*vec)[j]).hit[ihit].hit_energy; + } //end cells exist + else { + //create the cell --> OK assigned probabilistically although not really in terms of cell IDs + Eclosure.insert(std::pair<Long64_t, double>(foundCellID, ((FCS_matchedcell)(*vec)[j]).hit[ihit].hit_energy)); + }//end of else creating new cell + } } //end if cell ok } //end loop over hits @@ -538,7 +542,10 @@ void wiggleClosureAndComparison(TString sampling="Sampling_0"){ for (int i=0; i<11; i++){ // c2[i]= new TCanvas(); - c2[i] = new TCanvas("c2"+i,"c2"+i,2); + { + std::string hname = "c2_" + std::to_string(i); + c2[i] = new TCanvas(hname.c_str(),hname.c_str(),2); + } c2[i]->Divide(2,2); c2[i]->cd(1); @@ -554,7 +561,10 @@ void wiggleClosureAndComparison(TString sampling="Sampling_0"){ //c3[i]= new TCanvas(); - c3[i] = new TCanvas("c3"+i,"c3"+i,2); + { + std::string hname = "c3_" + std::to_string(i); + c3[i] = new TCanvas(hname.c_str(),hname.c_str(),2); + } c3[i]->Divide(2,2); c3[i]->cd(1); @@ -577,7 +587,10 @@ void wiggleClosureAndComparison(TString sampling="Sampling_0"){ c3[i]->Print("wiggle_plots_ClosureTest"+sampling+".pdf"); //cc2[i] = new TCanvas(); - cc2[i] = new TCanvas("cc22"+i,"cc22"+i,2); + { + std::string hname = "cc22_" + std::to_string(i); + cc2[i] = new TCanvas(hname.c_str(),hname.c_str(),2); + } //cc2[i]->Divide(2,1); @@ -612,7 +625,10 @@ void wiggleClosureAndComparison(TString sampling="Sampling_0"){ //ccc2[i] = new TCanvas(); - ccc2[i] = new TCanvas("cc2"+i,"cc2"+i,2); + { + std::string hname = "cc2_" + std::to_string(i); + ccc2[i] = new TCanvas(hname.c_str(),hname.c_str(),2); + } //ccc2[i]->SetLogz(); //dEta_dPhi_FCS_matched_overAvg[i]->GetZaxis()->SetRangeUser(0.1,10); @@ -624,7 +640,10 @@ void wiggleClosureAndComparison(TString sampling="Sampling_0"){ ccc2[i]->Print("wiggle_plots_ClosureTest"+sampling+".pdf"); // ccc3[i] = new TCanvas(); - ccc3[i] = new TCanvas("cc3"+i,"cc3"+i,2); + { + std::string hname = "cc3_" + std::to_string(i); + ccc3[i] = new TCanvas(hname.c_str(),hname.c_str(),2); + } subtraction[i] = (TProfile2D*)dEta_dPhi_FCS_orig_overAvg[i]->Clone("subtraction_"+sampling); subtraction[i]->Add(dEta_dPhi_FCS_matched_overAvg[i],-1); @@ -634,7 +653,10 @@ void wiggleClosureAndComparison(TString sampling="Sampling_0"){ // ccc4[i] = new TCanvas(); - ccc4[i] = new TCanvas("cc4"+i,"cc4"+i,2); + { + std::string hname = "cc4_" + std::to_string(i); + ccc4[i] = new TCanvas(hname.c_str(),hname.c_str(),2); + } //ccc4[i]->SetLogz(); dEta_dPhi_FCS_orig_overAvg[i]->GetXaxis()->SetRangeUser(-0.1,0.1); @@ -644,7 +666,10 @@ void wiggleClosureAndComparison(TString sampling="Sampling_0"){ ccc4[i]->Print("wiggle_plots_ClosureTest"+sampling+".pdf"); //ccc5[i] = new TCanvas(); - ccc5[i] = new TCanvas("cc5"+i,"cc5"+i,2); + { + std::string hname = "cc5_" + std::to_string(i); + ccc5[i] = new TCanvas(hname.c_str(),hname.c_str(),2); + } //ccc5[i]->SetLogz(); dEta_dPhi_FCS_matched_overAvg[i]->GetXaxis()->SetRangeUser(-0.1,0.1); @@ -653,7 +678,10 @@ void wiggleClosureAndComparison(TString sampling="Sampling_0"){ dEta_dPhi_FCS_matched_overAvg[i]->Draw("colz"); ccc5[i]->Print("wiggle_plots_ClosureTest"+sampling+".pdf"); - ccc6[i] = new TCanvas("cc6"+i,"cc6"+i,2); + { + std::string hname = "cc6_" + std::to_string(i); + ccc6[i] = new TCanvas(hname.c_str(),hname.c_str(),2); + } subtraction[i]->GetXaxis()->SetRangeUser(-0.1,0.1); subtraction[i]->GetYaxis()->SetRangeUser(-0.1,0.1); subtraction[i]->Draw("colz");