diff --git a/analysis/PWGC2F/femtoscopy/nicafemto/format/anatree/CbmAnaTreeSource.cxx b/analysis/PWGC2F/femtoscopy/nicafemto/format/anatree/CbmAnaTreeSource.cxx index 160c2b73cf0295d4c737d77f6b489052db68dcc3..a4c4e07f0ecefa081857ec6c093edbf5a8f45312 100644 --- a/analysis/PWGC2F/femtoscopy/nicafemto/format/anatree/CbmAnaTreeSource.cxx +++ b/analysis/PWGC2F/femtoscopy/nicafemto/format/anatree/CbmAnaTreeSource.cxx @@ -119,8 +119,11 @@ void CbmAnaTreeSource::LoadConf(TString name) TDirectory* oldDir = gDirectory; TFile* f = new TFile(name); - // TTree *tree = (TTree*)f->Get("aTree"); - AnalysisTree::Configuration* conf = (AnalysisTree::Configuration*) f->Get("Configuration"); + LOG_IF(fatal, !f) << "Could not open file " << name; + // TTree *tree = f->Get<TTree>("aTree"); + // AnalysisTree::Configuration* conf = (AnalysisTree::Configuration*) f->Get("Configuration"); + AnalysisTree::Configuration* conf = f->Get<AnalysisTree::Configuration>("Configuration"); + LOG_IF(fatal, !conf) << "Could not read AnalysisTree configuration from file " << name; if (fContainerReco) { fContainerReco->GetFieldIds().vtx_px = conf->GetBranchConfig("VtxTracks").GetFieldId("px"); fContainerReco->GetFieldIds().vtx_py = conf->GetBranchConfig("VtxTracks").GetFieldId("py"); diff --git a/analysis/PWGCHA/jpsi/CbmAnaJpsiSuperEvent.cxx b/analysis/PWGCHA/jpsi/CbmAnaJpsiSuperEvent.cxx index 0b509ab66b091bb2933f6bf93e8c0f72268a041e..0515279d6ed6712eb22d62bce421afc765458876 100644 --- a/analysis/PWGCHA/jpsi/CbmAnaJpsiSuperEvent.cxx +++ b/analysis/PWGCHA/jpsi/CbmAnaJpsiSuperEvent.cxx @@ -160,8 +160,9 @@ void CbmAnaJpsiSuperEvent::ReadCandidates() for (UInt_t iFile = 0; iFile < fFileNames.size(); iFile++) { cout << "-I- Reading file No " << iFile << " path:" << fFileNames[iFile] << endl; TFile* f = new TFile(fFileNames[iFile].c_str(), "R"); - TTree* t = (TTree*) f->Get("cbmsim"); - TFolder* fd = (TFolder*) f->Get("cbmout"); + LOG_IF(fatal, !f) << "Could not open file " << fFileNames[iFile].c_str(); + TTree* t = f->Get<TTree>("cbmsim"); + TFolder* fd = f->Get<TFolder>("cbmout"); if (fd == NULL) continue; TClonesArray* candidates = (TClonesArray*) fd->FindObjectAny("JpsiCandidates"); t->SetBranchAddress(candidates->GetName(), &candidates); diff --git a/analysis/PWGDIL/dielectron/lmvm/legacy/CbmAnaLmvmDrawStudy.cxx b/analysis/PWGDIL/dielectron/lmvm/legacy/CbmAnaLmvmDrawStudy.cxx index 21962ac43cc256069e8d3b01504223385ce45238..0fc91f1dbf2dfc43828921d56eefa6b4e4b1e628 100644 --- a/analysis/PWGDIL/dielectron/lmvm/legacy/CbmAnaLmvmDrawStudy.cxx +++ b/analysis/PWGDIL/dielectron/lmvm/legacy/CbmAnaLmvmDrawStudy.cxx @@ -50,6 +50,7 @@ void CbmAnaLmvmDrawStudy::DrawFromFile(const vector<string>& fileNames, const ve for (int i = 0; i < fNofStudies; i++) { fHM[i] = new CbmHistManager(); TFile* file = new TFile(fileNames[i].c_str()); + LOG_IF(fatal, !file) << "Could not open file " << fileNames[i].c_str(); fHM[i]->ReadFromFile(file); } @@ -89,11 +90,17 @@ void CbmAnaLmvmDrawStudy::DrawMinv() int nRebin = 20; for (unsigned int i = 0; i < fMeanFiles.size(); i++) { TFile* f = new TFile(fMeanFiles[i].c_str(), "READ"); + LOG_IF(fatal, !f) << "Could not open file " << fMeanFiles[i].c_str(); - hPtCut[i] = (TH1D*) f->Get("fh_bg_minv_ptcut")->Clone(); + hPtCut[i] = f->Get<TH1D>("fh_bg_minv_ptcut")->Clone(); + LOG_IF(fatal, !hPtCut[i]) << "Could not get histogram " << hPtCut[i]->GetName() << "from file " + << fMeanFiles[i].c_str(); hPtCut[i]->Rebin(nRebin); hPtCut[i]->SetMinimum(1e-6); - hTtCut[i] = (TH1D*) f->Get("fh_bg_minv_ttcut")->Clone(); + + hTtCut[i] = f->Get<TH1D>("fh_bg_minv_ttcut")->Clone(); + LOG_IF(fatal, !hTtCut[i]) << "Could not get histogram " << hTtCut[i]->GetName() << "from file " + << fMeanFiles[i].c_str(); hTtCut[i]->Rebin(nRebin); hPtCut[i]->SetMinimum(1e-6); //f->Close(); diff --git a/analysis/PWGDIL/dielectron/lmvm/legacy/CbmHaddBase.cxx b/analysis/PWGDIL/dielectron/lmvm/legacy/CbmHaddBase.cxx index d82df3f5748c08cc2f589c0c7dc43d73a94d5056..c99ed389c9cec27d2f99e8f871fca2b8fd397d88 100644 --- a/analysis/PWGDIL/dielectron/lmvm/legacy/CbmHaddBase.cxx +++ b/analysis/PWGDIL/dielectron/lmvm/legacy/CbmHaddBase.cxx @@ -68,7 +68,7 @@ Bool_t CbmHaddBase::CheckFile(TFile* file, Int_t fileSizeLimit, Int_t nofEvents) { if (file == NULL) return false; if (file->GetEND() < fileSizeLimit) return false; - TTree* tree = (TTree*) file->Get("cbmsim"); + TTree* tree = file->Get<TTree>("cbmsim"); if (tree == NULL) return false; Long64_t treeSizeAna = tree->GetEntriesFast(); if (treeSizeAna == nofEvents) return true; diff --git a/analysis/PWGDIL/dielectron/papaframework/PairAnalysisSpectrum.cxx b/analysis/PWGDIL/dielectron/papaframework/PairAnalysisSpectrum.cxx index f167b3cbe3d9e528319fd2bd999f142d64a55b2b..be04c79b73fd19cd557db5c8b561b4cc0af211f0 100644 --- a/analysis/PWGDIL/dielectron/papaframework/PairAnalysisSpectrum.cxx +++ b/analysis/PWGDIL/dielectron/papaframework/PairAnalysisSpectrum.cxx @@ -482,7 +482,7 @@ void PairAnalysisSpectrum::DrawSpectrum(const char* varexp, const char* selectio delete carr; return; } - TEventList* elist = (TEventList*) gDirectory->Get("elist"); + TEventList* elist = gDirectory->Get<TEventList>("elist"); if (elist) { elist->SetReapplyCut(kTRUE); // important! // elist->Print("all"); diff --git a/analysis/PWGDIL/dielectron/pi0eta/CbmKresGammaCorrection.cxx b/analysis/PWGDIL/dielectron/pi0eta/CbmKresGammaCorrection.cxx index a4499aaf2e0b170c45be5b6f87cc8237e03523a0..a69e475553486ab0151674b89a256edbe971191d 100644 --- a/analysis/PWGDIL/dielectron/pi0eta/CbmKresGammaCorrection.cxx +++ b/analysis/PWGDIL/dielectron/pi0eta/CbmKresGammaCorrection.cxx @@ -20,6 +20,8 @@ #include "CbmKresGammaCorrection.h" +#include <Logger.h> + #include "TFile.h" #include "TH2D.h" #include "TMath.h" @@ -58,10 +60,20 @@ void CbmKresGammaCorrection::Init(std::vector<std::vector<double>>& vect_all, TFile* fcorrection = new TFile( Correction_path.c_str()); // file with almost ?? Mio photons, homogeneously distributed over interested region // rapidity graphs - TH2D* mc = (TH2D*) fcorrection->Get("conversionKres/General/MC_info/MC_Direct_photons_Pt_vs_rap_est"); - TH2D* all = (TH2D*) fcorrection->Get("conversionKres/direct photons/Both/all/Ph_pt_vs_rap_est_all_Both"); - TH2D* two = (TH2D*) fcorrection->Get("conversionKres/direct photons/Both/two/Ph_pt_vs_rap_est_two_Both"); - TH2D* onetwo = (TH2D*) fcorrection->Get("conversionKres/direct photons/Both/onetwo/Ph_pt_vs_rap_est_onetwo_Both"); + LOG_IF(fatal, !fcorrection) << "Could not open file " << Correction_path.c_str(); + TH2D* mc = fcorrection->Get<TH2D>("conversionKres/General/MC_info/MC_Direct_photons_Pt_vs_rap_est"); + LOG_IF(fatal, !mc) << "Could not read histogram MC_Direct_photons_Pt_vs_rap_est from file " + << Correction_path.c_str(); + + TH2D* all = fcorrection->Get<TH2D>("conversionKres/direct photons/Both/all/Ph_pt_vs_rap_est_all_Both"); + LOG_IF(fatal, !all) << "Could not read histogram Ph_pt_vs_rap_est_all_Both from file " << Correction_path.c_str(); + + TH2D* two = fcorrection->Get<TH2D>("conversionKres/direct photons/Both/two/Ph_pt_vs_rap_est_two_Both"); + LOG_IF(fatal, !two) << "Could not read histogram Ph_pt_vs_rap_est_two_Both from file " << Correction_path.c_str(); + + TH2D* onetwo = fcorrection->Get<TH2D>("conversionKres/direct photons/Both/onetwo/Ph_pt_vs_rap_est_onetwo_Both"); + LOG_IF(fatal, !onetwo) << "Could not read histogram Ph_pt_vs_rap_est_onetwo_Both from file " + << Correction_path.c_str(); std::vector<double> rapidity_column; diff --git a/analysis/PWGDIL/dimuon/CbmAnaDimuonAnalysis.cxx b/analysis/PWGDIL/dimuon/CbmAnaDimuonAnalysis.cxx index f57030e7f863e6c4a4ab66230c02888dd4e85a0e..bd4ace66b3845ad935698250289e3326a65acf58 100644 --- a/analysis/PWGDIL/dimuon/CbmAnaDimuonAnalysis.cxx +++ b/analysis/PWGDIL/dimuon/CbmAnaDimuonAnalysis.cxx @@ -178,7 +178,9 @@ InitStatus CbmAnaDimuonAnalysis::Init() TDirectory* oldDir = gDirectory; fPlutoFile = new TFile(fPlutoFileName.Data()); - fInputTree = (TTree*) fPlutoFile->Get("data"); + LOG_IF(fatal, !fPlutoFile) << "Could not open file " << fPlutoFileName; + fInputTree = fPlutoFile->Get<TTree>("data"); + LOG_IF(fatal, !fInputTree) << "Could not read data tree from file " << fPlutoFileName; fInputTree->SetBranchAddress("Particles", &fParticles); for (int iEvent = 0; iEvent < fInputTree->GetEntries(); iEvent++) { fInputTree->GetEntry(iEvent); @@ -464,14 +466,18 @@ InitStatus CbmAnaDimuonAnalysis::Init() TDirectory* oldDir = gDirectory; TFile* FF = new TFile(name); + LOG_IF(fatal, !FF) << "Could not open file " << name; - TTree* MinParamMu = (TTree*) FF->Get("MinParam"); + + TTree* MinParamMu = FF->Get<TTree>("MinParam"); + LOG_IF(fatal, !MinParamMu) << "Could not read MinParam tree from file " << name; MinParamMu->SetBranchAddress("p0", &p0min); MinParamMu->SetBranchAddress("p1", &p1min); MinParamMu->SetBranchAddress("p2", &p2min); MinParamMu->GetEntry(0); - TTree* MaxParamMu = (TTree*) FF->Get("MaxParam"); + TTree* MaxParamMu = FF->Get<TTree>("MaxParam"); + LOG_IF(fatal, !MaxParamMu) << "Could not read MaxParam tree from file " << name; MaxParamMu->SetBranchAddress("p0", &p0max); MaxParamMu->SetBranchAddress("p1", &p1max); MaxParamMu->SetBranchAddress("p2", &p2max); diff --git a/analysis/PWGHAD/hadron/CbmHadronAnalysis.cxx b/analysis/PWGHAD/hadron/CbmHadronAnalysis.cxx index 4d32d3554df274546f7d9b67d58b4bd2c8b106b1..09968554b339bb9572ec0f343bbc1d294b7aeaf5 100644 --- a/analysis/PWGHAD/hadron/CbmHadronAnalysis.cxx +++ b/analysis/PWGHAD/hadron/CbmHadronAnalysis.cxx @@ -1650,7 +1650,7 @@ void CbmHadronAnalysis::ExecEvent(Option_t*) phirp1 = atan2(Qy1, Qx1); phirp2 = atan2(Qy2, Qx2); if (fflowFile != NULL) { // subevent RP flattening - TH1F* phirp_gen_fpar = (TH1F*) fflowFile->Get("phirps_gen_fpar"); + TH1F* phirp_gen_fpar = fflowFile->Get<TH1F>("phirps_gen_fpar"); Float_t dphir = 0.; for (int j = 0; j < 4; j++) { Float_t i = (float) (j + 1); @@ -1694,7 +1694,7 @@ void CbmHadronAnalysis::ExecEvent(Option_t*) phirp -= 360.; } if (fflowFile != NULL) { // RP flattening - TH1F* phirp_gen_fpar = (TH1F*) fflowFile->Get("phirp_gen_fpar"); + TH1F* phirp_gen_fpar = fflowFile->Get<TH1F>("phirp_gen_fpar"); Float_t dphir = 0.; for (int j = 0; j < 4; j++) { Float_t i = (float) (j + 1); @@ -1950,7 +1950,7 @@ void CbmHadronAnalysis::ExecEvent(Option_t*) phirp1 = atan2(Qy1, Qx1); phirp2 = atan2(Qy2, Qx2); if (fflowFile != NULL) { // subevent RP flattening - TH1F* phirp_poi_fpar = (TH1F*) fflowFile->Get("phirps_poi_fpar"); + TH1F* phirp_poi_fpar = fflowFile->Get<TH1F>("phirps_poi_fpar"); Float_t dphir = 0.; for (int j = 0; j < 4; j++) { Float_t i = (float) (j + 1); @@ -1990,7 +1990,7 @@ void CbmHadronAnalysis::ExecEvent(Option_t*) phirp -= 360.; } if (fflowFile != NULL) { // RP flattening - TH1F* phirp_poi_fpar = (TH1F*) fflowFile->Get("phirp_poi_fpar"); + TH1F* phirp_poi_fpar = fflowFile->Get<TH1F>("phirp_poi_fpar"); Float_t dphir = 0.; for (int j = 0; j < 4; j++) { Float_t i = (float) (j + 1); @@ -2449,7 +2449,7 @@ void CbmHadronAnalysis::ExecEvent(Option_t*) phirp1 = atan2(Qy1, Qx1); phirp2 = atan2(Qy2, Qx2); if (fflowFile != NULL) { // subevent RP flattening - TH1F* phirp_hit_fpar = (TH1F*) fflowFile->Get("phirps_hit_fpar"); + TH1F* phirp_hit_fpar = fflowFile->Get<TH1F>("phirps_hit_fpar"); Float_t dphir = 0.; for (int j = 0; j < 4; j++) { Float_t i = (float) (j + 1); @@ -2490,7 +2490,7 @@ void CbmHadronAnalysis::ExecEvent(Option_t*) phirp -= 360.; } if (fflowFile != NULL) { // RP flattening - TH1F* phirp_hit_fpar = (TH1F*) fflowFile->Get("phirp_hit_fpar"); + TH1F* phirp_hit_fpar = fflowFile->Get<TH1F>("phirp_hit_fpar"); Float_t dphir = 0.; for (int j = 0; j < 4; j++) { Float_t i = (float) (j + 1); @@ -3499,7 +3499,7 @@ void CbmHadronAnalysis::ExecEvent(Option_t*) phirp1 = atan2(Qy1, Qx1); phirp2 = atan2(Qy2, Qx2); if (fflowFile != NULL) { // subevent RP flattening - TH1F* phirp_glo_fpar = (TH1F*) fflowFile->Get("phirps_glo_fpar"); + TH1F* phirp_glo_fpar = fflowFile->Get<TH1F>("phirps_glo_fpar"); Float_t dphir = 0.; for (int j = 0; j < 4; j++) { Float_t i = (float) (j + 1); @@ -3537,7 +3537,7 @@ void CbmHadronAnalysis::ExecEvent(Option_t*) phirp -= 360.; } if (fflowFile != NULL) { // RP flattening - TH1F* phirp_glo_fpar = (TH1F*) fflowFile->Get("phirp_glo_fpar"); + TH1F* phirp_glo_fpar = fflowFile->Get<TH1F>("phirp_glo_fpar"); Float_t dphir = 0.; for (int j = 0; j < 4; j++) { Float_t i = (float) (j + 1); diff --git a/analysis/common/analysis_tree_converter/CbmSimTracksConverter.cxx b/analysis/common/analysis_tree_converter/CbmSimTracksConverter.cxx index 71d37ff2ee9e4825ddc751d2b8972bff39a08f1f..f175627ab4f84fd9e47c9ad1504f613aaae4e9de 100644 --- a/analysis/common/analysis_tree_converter/CbmSimTracksConverter.cxx +++ b/analysis/common/analysis_tree_converter/CbmSimTracksConverter.cxx @@ -48,10 +48,10 @@ ClassImp(CbmSimTracksConverter) fFile = new TFile(fUnigenFile, "READ"); fFile->Print(); if (fFile->IsOpen()) { - fTree = (TTree*) fFile->Get("events"); + fTree = fFile->Get<TTree>("events"); if (fTree) fUseUnigen = kTRUE; fTree->SetBranchAddress("event", &fUnigenEvent); - URun* run = dynamic_cast<URun*>(fFile->Get("run")); + URun* run = fFile->Get<URun>("run"); if (run == nullptr) { LOG(error) << "CbmSimTracksConverter: No run description in urqmd file!"; delete fFile; diff --git a/core/detectors/much/CbmMuchGeoScheme.cxx b/core/detectors/much/CbmMuchGeoScheme.cxx index 61d5f475a7b6636840b8863c6b510acfb12a184f..320dc31728ada3658e3d866db8eb887c4349186e 100644 --- a/core/detectors/much/CbmMuchGeoScheme.cxx +++ b/core/detectors/much/CbmMuchGeoScheme.cxx @@ -148,7 +148,9 @@ void CbmMuchGeoScheme::Init(TString digiFileName, Int_t flag) TDirectory* oldDir = gDirectory; TFile* file = new TFile(digiFileName); - TObjArray* stations = (TObjArray*) file->Get("stations"); + LOG_IF(fatal, !file) << "File " << digiFileName << " does not exist"; + TObjArray* stations = file->Get<TObjArray>("stations"); + LOG_IF(fatal, !stations) << "No TObjArray stations found in file " << digiFileName; file->Close(); file->Delete(); diff --git a/core/detectors/trd/CbmMcbm2020TrdTshiftPar.cxx b/core/detectors/trd/CbmMcbm2020TrdTshiftPar.cxx index db301c4560920634083072e16ad2129f219ff9b6..c234270691c69aee24000bf55f6f9c36355d85ea 100644 --- a/core/detectors/trd/CbmMcbm2020TrdTshiftPar.cxx +++ b/core/detectors/trd/CbmMcbm2020TrdTshiftPar.cxx @@ -190,10 +190,9 @@ double CbmMcbm2020TrdTshiftPar::GetNEvents(std::shared_ptr<TFile> mcbmanafile) // histo = CTAH::GetHistoFromFile(varvec, fillstation, htype, mcbmanafile, weight); std::string hpath = "FillStation-RunInfo/FullTrd/RunId_wNEvents-RunInfo"; - histo = (TH1*) mcbmanafile->Get(hpath.data()); - if (!histo) { - LOG(fatal) << " CbmMcbm2020TrdTshiftPar::GetNEvents " << hpath.data() << " not found in the file" << std::endl; - } + histo = mcbmanafile->Get<TH1>(hpath.data()); + LOG_IF(fatal, !histo) << " CbmMcbm2020TrdTshiftPar::GetNEvents " << hpath.data() << " not found in the file" + << std::endl; double nevents = histo->GetBinContent(histo->GetMaximumBin()); return nevents; } @@ -212,11 +211,10 @@ std::shared_ptr<TH3> CbmMcbm2020TrdTshiftPar::GetCalibHisto(std::shared_ptr<TFil std::string hpath = "FillStation-TrdT0Digi/FullTrd/" "TsSourceTsIndex_DigiTrdChannel_DigiDtCorrSlice-TrdT0Digi"; - hsparse = (THnSparse*) mcbmanafile->Get(hpath.data()); + hsparse = mcbmanafile->Get<THnSparse>(hpath.data()); - if (!hsparse) { - LOG(fatal) << " CbmMcbm2020TrdTshiftPar::GetCalibHisto " << hpath.data() << " not found in the file" << std::endl; - } + LOG_IF(fatal, !hsparse) << " CbmMcbm2020TrdTshiftPar::GetCalibHisto " << hpath.data() << " not found in the file" + << std::endl; auto nevents = GetNEvents(mcbmanafile); diff --git a/core/detectors/trd/CbmTrdParSetGas.cxx b/core/detectors/trd/CbmTrdParSetGas.cxx index 90dced4ead50cc66d70238407ddda649b3e2de10..5fcf2157c970d603e9c96fd6249bf266ed22dea7 100644 --- a/core/detectors/trd/CbmTrdParSetGas.cxx +++ b/core/detectors/trd/CbmTrdParSetGas.cxx @@ -124,13 +124,13 @@ void CbmTrdParSetGas::putParams(FairParamList* l) TH2F* CbmTrdParSetGas::GetDriftMap(const Char_t* g, const Int_t ua, const Int_t ud) { TString smap = Form("%s_%4d_%3d", g, ua, ud); - TH2F* hm = (TH2F*) gFile->Get(smap.Data()); + TH2F* hm = gFile->Get<TH2F>(smap.Data()); if (hm) return hm; LOG(debug) << GetName() << "::GetDriftMap() : Interpolate drift map for " << g << " Ua[" << ua << "]" << " Ud[" << ud << "]"; - return (TH2F*) gFile->Get(Form("%s_1500_300", g)); + return gFile->Get<TH2F>(Form("%s_1500_300", g)); } ClassImp(CbmTrdParSetGas) diff --git a/core/field/CbmFieldMapDistorted.cxx b/core/field/CbmFieldMapDistorted.cxx index d0fe3184b266ee70bd12a3fc3b272cbfd6ef6db2..f00f140dd83cb5ae20370a3067978e73e7cfcffd 100644 --- a/core/field/CbmFieldMapDistorted.cxx +++ b/core/field/CbmFieldMapDistorted.cxx @@ -250,12 +250,18 @@ void CbmFieldMapDistorted::ReadDistortionInformation(const char* filename) else { TFile* f = new TFile(fDistortionFilename + ".root"); if (f) { - fBxDistortionFormulaMult = (TFormula*) f->Get("BxDistortionFormulaMult"); - fBxDistortionFormulaAdd = (TFormula*) f->Get("BxDistortionFormulaAdd"); - fByDistortionFormulaMult = (TFormula*) f->Get("ByDistortionFormulaMult"); - fByDistortionFormulaAdd = (TFormula*) f->Get("ByDistortionFormulaAdd"); - fBzDistortionFormulaMult = (TFormula*) f->Get("BzDistortionFormulaMult"); - fBzDistortionFormulaAdd = (TFormula*) f->Get("BzDistortionFormulaAdd"); + fBxDistortionFormulaMult = f->Get<TFormula>("BxDistortionFormulaMult"); + LOG_IF(fatal, !fBxDistortionFormulaMult) << "fBxDistortionFormulaMult not found in file " << f->GetName(); + fBxDistortionFormulaAdd = f->Get<TFormula>("BxDistortionFormulaAdd"); + LOG_IF(fatal, !fBxDistortionFormulaAdd) << "fBxDistortionFormulaAdd not found in file " << f->GetName(); + fByDistortionFormulaMult = f->Get<TFormula>("ByDistortionFormulaMult"); + LOG_IF(fatal, !fByDistortionFormulaMult) << "fByDistortionFormulaMult not found in file " << f->GetName(); + fByDistortionFormulaAdd = f->Get<TFormula>("ByDistortionFormulaAdd"); + LOG_IF(fatal, !fByDistortionFormulaAdd) << "fByDistortionFormulaAdd not found in file " << f->GetName(); + fBzDistortionFormulaMult = f->Get<TFormula>("BzDistortionFormulaMult"); + LOG_IF(fatal, !fBzDistortionFormulaMult) << "fBzDistortionFormulaMult not found in file " << f->GetName(); + fBzDistortionFormulaAdd = f->Get<TFormula>("BzDistortionFormulaAdd"); + LOG_IF(fatal, !fBzDistortionFormulaAdd) << "fBzDistortionFormulaAdd not found in file " << f->GetName(); f->Close(); } else { diff --git a/macro/mcbm/mcbm_qa.C b/macro/mcbm/mcbm_qa.C index a7608ebb1b2869d549b9371c2f54859305755a0e..a6305fc5d35f6d093745a57c323cf20a9414d124 100644 --- a/macro/mcbm/mcbm_qa.C +++ b/macro/mcbm/mcbm_qa.C @@ -77,14 +77,16 @@ void mcbm_qa(Int_t nEvents = 0, TString dataset = "data/mcbm_beam_2020_03_test", TString geoTag; // - MUCH digitisation parameters + TString muchParFile {}; if (CbmSetup::Instance()->GetGeoTag(ECbmModuleId::kMuch, geoTag)) { bool mcbmFlag = geoTag.Contains("mcbm", TString::kIgnoreCase); - TString parFile = srcDir + "/parameters/much/much_"; - parFile += (mcbmFlag) ? geoTag : geoTag(0, 4); - parFile += "_digi_sector.root"; + muchParFile = srcDir + "/parameters/much/much_"; + muchParFile += (mcbmFlag) ? geoTag : geoTag(0, 4); + muchParFile += "_digi_sector.root"; { // init geometry from the file - TFile* f = new TFile(parFile, "R"); - TObjArray* stations = (TObjArray*) f->Get("stations"); + TFile* f = new TFile(muchParFile, "R"); + TObjArray* stations = f->Get<TObjArray>("stations"); + assert(stations); CbmMuchGeoScheme::Instance()->Init(stations, mcbmFlag); } } @@ -147,7 +149,9 @@ void mcbm_qa(Int_t nEvents = 0, TString dataset = "data/mcbm_beam_2020_03_test", if (CbmSetup::Instance()->IsActive(ECbmModuleId::kMuch)) { run->AddTask(new CbmMuchTransportQa()); run->AddTask(new CbmMuchDigitizerQa()); - run->AddTask(new CbmMuchHitFinderQa()); + CbmMuchHitFinderQa* muchHitFinderQa = new CbmMuchHitFinderQa(); + muchHitFinderQa->SetGeoFileName(muchParFile); + run->AddTask(muchHitFinderQa); } // ------------------------------------------------------------------------ diff --git a/macro/mcbm/mcbm_reco_event.C b/macro/mcbm/mcbm_reco_event.C index 1bf88a0050da22cb6cebabfacca49e3e924b98e5..db3ceb89e86cfac5f192aca6f3f6c8931225b967 100644 --- a/macro/mcbm/mcbm_reco_event.C +++ b/macro/mcbm/mcbm_reco_event.C @@ -385,7 +385,8 @@ void mcbm_reco_event(Int_t nEvents = 10, TString dataset = "data/test", if (geoTag.Contains("mcbm")) muchFlag = 1; TString parFile = gSystem->Getenv("VMCWORKDIR"); - parFile = parFile + "/parameters/much/much_" + geoTag(0, 4) + "_digi_sector.root"; + // parFile = parFile + "/parameters/much/much_" + geoTag(0, 4) + "_digi_sector.root"; + parFile = parFile + "/parameters/much/much_" + geoTag + "_digi_sector.root"; std::cout << "L1: Using parameter file " << parFile << std::endl; l1->SetMuchPar(parFile); diff --git a/macro/run/run_qa.C b/macro/run/run_qa.C index cb59c728db50d40a0179e48b09c037e3ffdf75e0..f462df4b65dc9d11bd6617fbfda91b6c4c25fd8d 100644 --- a/macro/run/run_qa.C +++ b/macro/run/run_qa.C @@ -88,13 +88,14 @@ void run_qa(TString dataTra = "data/sis100_muon_jpsi_test", TString dataRaw = "d TString geoTag; // - MUCH digitisation parameters + TString muchParFile {}; if (CbmSetup::Instance()->GetGeoTag(ECbmModuleId::kMuch, geoTag)) { bool mcbmFlag = geoTag.Contains("mcbm", TString::kIgnoreCase); - TString parFile = srcDir + "/parameters/much/much_"; - parFile += (mcbmFlag) ? geoTag : geoTag(0, 4); - parFile += "_digi_sector.root"; + muchParFile = srcDir + "/parameters/much/much_"; + muchParFile += (mcbmFlag) ? geoTag : geoTag(0, 4); + muchParFile += "_digi_sector.root"; { // init geometry from the file - TFile* f = new TFile(parFile, "R"); + TFile* f = new TFile(muchParFile, "R"); TObjArray* stations = (TObjArray*) f->Get("stations"); CbmMuchGeoScheme::Instance()->Init(stations, mcbmFlag); } @@ -167,7 +168,9 @@ void run_qa(TString dataTra = "data/sis100_muon_jpsi_test", TString dataRaw = "d if (CbmSetup::Instance()->IsActive(ECbmModuleId::kMuch)) { run->AddTask(new CbmMuchTransportQa()); run->AddTask(new CbmMuchDigitizerQa()); - run->AddTask(new CbmMuchHitFinderQa()); + CbmMuchHitFinderQa* muchHitFinderQa = new CbmMuchHitFinderQa(); + muchHitFinderQa->SetGeoFileName(muchParFile); + run->AddTask(muchHitFinderQa); } // ----- TRD QA --------------------------------- diff --git a/mvd/CbmMvdPileupManager.cxx b/mvd/CbmMvdPileupManager.cxx index 2bfb7bb856f0d8bd61adefadbb9495bb4bce5ae8..6d3455007411d525f6ba11a9058f4bf47f5ede27 100644 --- a/mvd/CbmMvdPileupManager.cxx +++ b/mvd/CbmMvdPileupManager.cxx @@ -8,6 +8,8 @@ // ------------------------------------------------------------------------- #include "CbmMvdPileupManager.h" +#include <Logger.h> + #include "TClonesArray.h" #include "TFile.h" #include "TObjArray.h" @@ -83,16 +85,17 @@ Int_t CbmMvdPileupManager::FillBuffer(TString fileName, TString branchName, Int_ TFile* bgfile = new TFile(fileName); if (!bgfile) { - cout << "-W- CbmMvdPileupManager::FillBuffer: Background file " << fileName << " could noy be opened! " << endl; + LOG(warning) << "CbmMvdPileupManager::FillBuffer: Background file " << fileName << " could noy be opened! " + << endl; return 0; } cout << "-I- CbmMvdPileupManager::FillBuffer: Opening file " << endl; cout << fileName << endl; - TTree* bgtree = (TTree*) bgfile->Get("cbmsim"); + TTree* bgtree = bgfile->Get<TTree>("cbmsim"); if (!bgtree) { - cout << "-W- CbmMvdPileupManager::FillBuffer: " - << "Could not find cbmsim tree in background file " << endl; + LOG(warning) << "CbmMvdPileupManager::FillBuffer: " + << "Could not find cbmsim tree in background file "; return 0; } diff --git a/reco/KF/CbmKFParticleFinderQa.cxx b/reco/KF/CbmKFParticleFinderQa.cxx index 71d9b44726fe658549ef44709f4784c1c06fa4a1..418d76c4ed39ddca0a2c95eb8fd02caf53b21687 100644 --- a/reco/KF/CbmKFParticleFinderQa.cxx +++ b/reco/KF/CbmKFParticleFinderQa.cxx @@ -509,7 +509,7 @@ void CbmKFParticleFinderQa::CheckDecayQA() //compare with the reference results TFile* referenceFile = new TFile(referenceFileName.Data(), "READ"); if (referenceFile->IsOpen()) { - TH1F* referenceHisto = (TH1F*) referenceFile->Get(qaHistoName); + TH1F* referenceHisto = referenceFile->Get<TH1F>(qaHistoName); if (referenceHisto) { fTestOk = true; for (int iBin = 1; iBin <= 7; iBin++) @@ -528,6 +528,9 @@ void CbmKFParticleFinderQa::CheckDecayQA() referenceFile->Close(); referenceFile->Delete(); } + else { + LOG(error) << "Could not open file " << referenceFileName << " with reference histograms"; + } if (qaFile) { qaFile->Close(); diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index e7cea72a07e16c174fce579874396b2a7bd6c638..cf52bd3074ac0f31a1e8cba3ff81265e38a8e182 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -421,7 +421,9 @@ InitStatus CbmL1::Init() TDirectory* oldDir = gDirectory; TFile* file = new TFile(fMuchDigiFile, "READ"); - TObjArray* stations = (TObjArray*) file->Get("stations"); + LOG_IF(fatal, !file) << "Could not open file " << fMuchDigiFile; + TObjArray* stations = file->Get<TObjArray>("stations"); + LOG_IF(fatal, !stations) << "No TObjArray stations in file " << fMuchDigiFile; fGeoScheme->Init(stations, 0); for (int iStation = 0; iStation < fGeoScheme->GetNStations(); iStation++) { const CbmMuchStation* station = fGeoScheme->GetStation(iStation); @@ -2228,11 +2230,9 @@ std::vector<L1Material> CbmL1::ReadMaterialBudget(L1DetectorID detectorID) for (int iSt = 0; iSt < fpInitManager->GetNstationsGeometry(detectorID); ++iSt) { // TODO: Unify material table names (S.Zharko) TString stationName = stationNamePrefix + (detectorID == L1DetectorID::kMvd ? iSt : iSt + 1); - auto* hStaRadLen = dynamic_cast<TProfile2D*>(rlFile.Get(stationName)); - if (!hStaRadLen) { - LOG(fatal) << "CbmL1: material budget profile " << stationName << " does not exist in file " - << fMatBudgetFileName.at(detectorID); - } + auto* hStaRadLen = rlFile.Get<TProfile2D>(stationName); + LOG_IF(fatal, !hStaRadLen) << "CbmL1: material budget profile " << stationName << " does not exist in file " + << fMatBudgetFileName.at(detectorID); int nBins = hStaRadLen->GetNbinsX(); float rMax = hStaRadLen->GetXaxis()->GetXmax(); result[iSt].SetBins(nBins, rMax); diff --git a/reco/detectors/much/CbmMuchFindHitsGem.cxx b/reco/detectors/much/CbmMuchFindHitsGem.cxx index ed1287358be1b8e8f9a069c46b5401b98f233bfc..ccdf47469443162dc1e50ab0788869ebdf3d9639 100644 --- a/reco/detectors/much/CbmMuchFindHitsGem.cxx +++ b/reco/detectors/much/CbmMuchFindHitsGem.cxx @@ -123,7 +123,9 @@ InitStatus CbmMuchFindHitsGem::Init() TDirectory* oldDir = gDirectory; TFile* file = new TFile(fDigiFile); - TObjArray* stations = (TObjArray*) file->Get("stations"); + LOG_IF(fatal, !file) << "Could not open file " << fDigiFile; + TObjArray* stations = file->Get<TObjArray>("stations"); + LOG_IF(fatal, !stations) << "TObjArray stations not found in file " << fDigiFile; file->Close(); file->Delete(); /// Restore old global file and folder pointer to avoid messing with FairRoot diff --git a/reco/detectors/much/CbmMuchHitProducerIdeal.cxx b/reco/detectors/much/CbmMuchHitProducerIdeal.cxx index ef5ecb13b63e21676559838b55f060a650d66e2e..34332ed585ab4fdaedd2303fae84782f450c54d3 100644 --- a/reco/detectors/much/CbmMuchHitProducerIdeal.cxx +++ b/reco/detectors/much/CbmMuchHitProducerIdeal.cxx @@ -55,7 +55,9 @@ InitStatus CbmMuchHitProducerIdeal::Init() TDirectory* oldDir = gDirectory; TFile* file = new TFile(fDigiFile); - TObjArray* stations = (TObjArray*) file->Get("stations"); + LOG_IF(fatal, !file) << "Could not open file " << fDigiFile; + TObjArray* stations = file->Get<TObjArray>("stations"); + LOG_IF(fatal, !stations) << "TObjArray stations not found in file " << fDigiFile; file->Close(); file->Delete(); /// Restore old global file and folder pointer to avoid messing with FairRoot diff --git a/reco/detectors/much/qa/CbmMuchHitFinderQa.cxx b/reco/detectors/much/qa/CbmMuchHitFinderQa.cxx index 9c044402da08f2a5ec024d6d8132ba6c1f8d6fa1..d60e2b742398e5a7191b1dc5149f35b64b691dc2 100644 --- a/reco/detectors/much/qa/CbmMuchHitFinderQa.cxx +++ b/reco/detectors/much/qa/CbmMuchHitFinderQa.cxx @@ -164,12 +164,14 @@ InitStatus CbmMuchHitFinderQa::Init() TDirectory* oldDir = gDirectory; TFile* f = new TFile(fGeoFileName, "R"); + LOG_IF(fatal, !f) << "Could not open file " << fGeoFileName; /// Restore old global file and folder pointer to avoid messing with FairRoot gFile = oldFile; gDirectory = oldDir; - TObjArray* stations = (TObjArray*) f->Get("stations"); + TObjArray* stations = f->Get<TObjArray>("stations"); + LOG_IF(fatal, !stations) << "TObjArray stations not found in file " << fGeoFileName; fGeoScheme->Init(stations, fFlag); if (!fManager) { diff --git a/reco/detectors/rich/alignment/CbmHistManager.cxx b/reco/detectors/rich/alignment/CbmHistManager.cxx index 164142ed647c1732cabfd3beb990754b34196a94..89d255df79316474b8eb3fa3ab91a6ac1de73f57 100644 --- a/reco/detectors/rich/alignment/CbmHistManager.cxx +++ b/reco/detectors/rich/alignment/CbmHistManager.cxx @@ -153,7 +153,7 @@ void CbmHistManager::ReadFromFile(TFile* file) if (obj->IsA()->InheritsFrom(TH1::Class()) || obj->IsA()->InheritsFrom(TGraph::Class()) || obj->IsA()->InheritsFrom(TGraph2D::Class())) { TNamed* h = (TNamed*) obj; - TNamed* h1 = (TNamed*) file->Get(h->GetName()); + TNamed* h1 = file->Get<TNamed>(h->GetName()); Add(string(h->GetName()), h1); //LOG(info) << c++ << " " << h->GetName(); } diff --git a/reco/detectors/rich/alignment/CbmRichAlignment.cxx b/reco/detectors/rich/alignment/CbmRichAlignment.cxx index 7f263da01741e2dba5681498f04ef494d1bea033..3b7b626d4d41d372dde9518076dc0ba5d99be2ff 100644 --- a/reco/detectors/rich/alignment/CbmRichAlignment.cxx +++ b/reco/detectors/rich/alignment/CbmRichAlignment.cxx @@ -353,17 +353,17 @@ void CbmRichAlignment::DrawFit(vector<Double_t>& outputFit, Int_t thresh) // -------------------- FIT SLICES AND FIT THE MEAN OF THE RESULT TO A SIN FUNCTION -------------------- // CloneArr_2->FitSlicesY(0, 0, -1, 1); c3->cd(3); - TH1D* histo_0 = (TH1D*) gDirectory->Get("fHCherenkovHitsDistribReduced_0"); + TH1D* histo_0 = gDirectory->Get<TH1D>("fHCherenkovHitsDistribReduced_0"); histo_0->Draw(); c3->cd(4); - TH1D* histo_1 = (TH1D*) gDirectory->Get("fHCherenkovHitsDistribReduced_1"); + TH1D* histo_1 = gDirectory->Get<TH1D>("fHCherenkovHitsDistribReduced_1"); //histo_1->GetYaxis()->SetRangeUser(-2.5, 2.5); histo_1->Draw(); c3->cd(5); - TH1D* histo_2 = (TH1D*) gDirectory->Get("fHCherenkovHitsDistribReduced_2"); + TH1D* histo_2 = gDirectory->Get<TH1D>("fHCherenkovHitsDistribReduced_2"); histo_2->Draw(); c3->cd(6); - TH1D* histo_chi2 = (TH1D*) gDirectory->Get("fHCherenkovHitsDistribReduced_chi2"); + TH1D* histo_chi2 = gDirectory->Get<TH1D>("fHCherenkovHitsDistribReduced_chi2"); histo_chi2->Draw(); c3->cd(7); @@ -499,6 +499,8 @@ void CbmRichAlignment::DrawHistFromFile(TString fileName) fHM = new CbmHistManager(); TFile* file = new TFile(fileName, "READ"); + LOG_IF(fatal, !file) << "Could not open file " << fileName; + fHM->ReadFromFile(file); DrawHistAlignment(); diff --git a/reco/detectors/rich/alignment/CbmRichCorrectionVector.cxx b/reco/detectors/rich/alignment/CbmRichCorrectionVector.cxx index 394f5e1ffa32ea404d6e0e69ad80619830b5ce05..057ec1c3173fa655f17ec1afa5b2cb487c98c771 100644 --- a/reco/detectors/rich/alignment/CbmRichCorrectionVector.cxx +++ b/reco/detectors/rich/alignment/CbmRichCorrectionVector.cxx @@ -1128,17 +1128,17 @@ void CbmRichCorrectionVector::DrawFit(vector<Double_t>& outputFit, Int_t thresh) // -------------------- FIT SLICES AND FIT THE MEAN OF THE RESULT TO A SIN FUNCTION -------------------- // CloneArr_2->FitSlicesY(0, 0, -1, 1); c3->cd(3); - TH1D* histo_0 = (TH1D*) gDirectory->Get("fHCherenkovHitsDistribReduced_0"); + TH1D* histo_0 = gDirectory->Get<TH1D>("fHCherenkovHitsDistribReduced_0"); histo_0->Draw(); c3->cd(4); - TH1D* histo_1 = (TH1D*) gDirectory->Get("fHCherenkovHitsDistribReduced_1"); + TH1D* histo_1 = gDirectory->Get<TH1D>("fHCherenkovHitsDistribReduced_1"); //histo_1->GetYaxis()->SetRangeUser(-2.5, 2.5); histo_1->Draw(); c3->cd(5); - TH1D* histo_2 = (TH1D*) gDirectory->Get("fHCherenkovHitsDistribReduced_2"); + TH1D* histo_2 = gDirectory->Get<TH1D>("fHCherenkovHitsDistribReduced_2"); histo_2->Draw(); c3->cd(6); - TH1D* histo_chi2 = (TH1D*) gDirectory->Get("fHCherenkovHitsDistribReduced_chi2"); + TH1D* histo_chi2 = gDirectory->Get<TH1D>("fHCherenkovHitsDistribReduced_chi2"); histo_chi2->Draw(); c3->cd(7); @@ -1357,6 +1357,8 @@ void CbmRichCorrectionVector::DrawHistFromFile(TString fileName) fHM = new CbmHistManager(); TFile* file = new TFile(fileName, "READ"); + LOG_IF(fatal, !file) << "Could not open file " << fileName; + fHM->ReadFromFile(file); DrawHistMapping(); diff --git a/reco/detectors/rich/alignment/CbmRichMirrorSortingAlignment.cxx b/reco/detectors/rich/alignment/CbmRichMirrorSortingAlignment.cxx index 4eb3bd541712a72ab8001764048ac3f984b14170..8108f3d3fd7bbb85316366d83521adf7393940ec 100644 --- a/reco/detectors/rich/alignment/CbmRichMirrorSortingAlignment.cxx +++ b/reco/detectors/rich/alignment/CbmRichMirrorSortingAlignment.cxx @@ -578,7 +578,7 @@ void CbmRichMirrorSortingAlignment::DrawFitAndExtractAngles(std::map<string, vec can->cd(2); string histoName = "CherenkovHitsDistribReduced_" + it->first + "_1"; //cout << "HistoName: " << histoName << endl; - TH1D* histo_1 = (TH1D*) gDirectory->Get((histoName).c_str()); + TH1D* histo_1 = gDirectory->Get<TH1D>((histoName).c_str()); histo_1->GetXaxis()->SetTitle("#Phi_{Ch} [rad]"); histo_1->GetYaxis()->SetTitle("#theta_{Ch}-#theta_{0} [cm]"); histo_1->GetXaxis()->SetTitleSize(0.05); diff --git a/reco/detectors/rich/qa/CbmRichGeoTestOpt.cxx b/reco/detectors/rich/qa/CbmRichGeoTestOpt.cxx index 3f78795ef08514192717c3c617a5f0414df7768f..17e5dbc736b02319b0a75e9f97bd960cbbd8ddda 100644 --- a/reco/detectors/rich/qa/CbmRichGeoTestOpt.cxx +++ b/reco/detectors/rich/qa/CbmRichGeoTestOpt.cxx @@ -78,7 +78,7 @@ pair<double, double> CbmRichGeoTestOpt::H1MeanRms(CbmRichGeoTestOptFileEnum file TFile* file = new TFile(path.c_str(), "READ"); if (file == nullptr) return make_pair(0., 0.); - TH1D* hist = (TH1D*) file->Get(histName.c_str()); + TH1D* hist = file->Get<TH1D>(histName.c_str()); if (hist == nullptr) return make_pair(0., 0.); double mean = hist->GetMean(); double rms = hist->GetRMS(); @@ -104,7 +104,7 @@ pair<double, double> CbmRichGeoTestOpt::H2ProjYMeanRms(CbmRichGeoTestOptFileEnum TFile* file = new TFile(path.c_str(), "READ"); if (file == nullptr) return make_pair(0., 0.); - TH2D* hist = (TH2D*) file->Get(histName.c_str()); + TH2D* hist = file->Get<TH2D>(histName.c_str()); if (hist == nullptr) return make_pair(0., 0.); TH1D* py = hist->ProjectionY((histName + to_string(iFile) + "_py").c_str()); double mean = py->GetMean(); @@ -130,7 +130,7 @@ double CbmRichGeoTestOpt::HEntries(CbmRichGeoTestOptFileEnum fileEnum, int iFile TFile* file = new TFile(path.c_str(), "READ"); if (file == nullptr) return 0.; - TH1* hist = (TH1*) file->Get(histName.c_str()); + TH1* hist = file->Get<TH1>(histName.c_str()); if (hist == nullptr) return 0.; double entries = hist->GetEntries(); //hist->Integral(); diff --git a/reco/detectors/trd/pid/CbmTrdElectronsTrainAnn.cxx b/reco/detectors/trd/pid/CbmTrdElectronsTrainAnn.cxx index 0b3fcfda6ee1f71c3fc30d0d7faa19b4bf675f99..b662ac014198b4437d388d7c8f1b43ae301c18a0 100644 --- a/reco/detectors/trd/pid/CbmTrdElectronsTrainAnn.cxx +++ b/reco/detectors/trd/pid/CbmTrdElectronsTrainAnn.cxx @@ -211,8 +211,13 @@ void CbmTrdElectronsTrainAnn::FillElossVectorReal() TDirectory* oldDir = gDirectory; TFile* file = new TFile(fBeamDataFile.c_str(), "READ"); - TH1F* hPion = (TH1F*) file->Get(fBeamDataPiHist.c_str())->Clone(); - TH1F* hElectron = (TH1F*) file->Get(fBeamDataElHist.c_str())->Clone(); + LOG_IF(fatal, !file) << "Could not open file " << fBeamDataFile; + + TH1F* hPion = static_cast<TH1F*>(file->Get<TH1F>(fBeamDataPiHist.c_str())->Clone()); + LOG_IF(fatal, !hPion) << "Histogram " << fBeamDataPiHist << " not found in file " << fBeamDataFile; + + TH1F* hElectron = static_cast<TH1F*>(file->Get<TH1F>(fBeamDataElHist.c_str())->Clone()); + LOG_IF(fatal, !hElectron) << "Histogram " << fBeamDataElHist << " not found in file " << fBeamDataFile; double scaleX = fhEloss[0]->GetXaxis()->GetBinUpEdge(fhEloss[0]->GetNbinsX()) / hPion->GetXaxis()->GetBinUpEdge(hPion->GetNbinsX()); diff --git a/reco/detectors/trd/pid/CbmTrdSetTracksPidLike.cxx b/reco/detectors/trd/pid/CbmTrdSetTracksPidLike.cxx index b7022fdac5e1d7088b4fa139218a834a705edc15..201d5ba6c137bdef84a55f0448506dec17bd32e5 100644 --- a/reco/detectors/trd/pid/CbmTrdSetTracksPidLike.cxx +++ b/reco/detectors/trd/pid/CbmTrdSetTracksPidLike.cxx @@ -75,11 +75,11 @@ Bool_t CbmTrdSetTracksPidLike::ReadData() // Open ROOT file with the histograms TFile* histFile = new TFile(fFileName, "READ"); if (!histFile || !histFile->IsOpen()) { - Error("ReadData", "Could not open input file: %s", fFileName.Data()); + LOG(error) << "Could not open input file: " << fFileName; return kFALSE; } else { - Info("ReadData", "input file %s opened", fFileName.Data()); + LOG(info) << "Input file " << fFileName << " open"; } gROOT->cd(); @@ -93,9 +93,9 @@ Bool_t CbmTrdSetTracksPidLike::ReadData() "MC_muon_p_eloss"}; inArr = new TObjArray(histnames.size()); for (size_t i = 0; i < histnames.size(); i++) { - h[i] = (TH2D*) histFile->Get(histnames[i]); + h[i] = histFile->Get<TH2D>(histnames[i]); if (!h[i]) { - Info("ReadData", "no input histogram %s", histnames[i].Data()); + LOG(info) << "No input histogram " << histnames[i].Data(); continue; } @@ -119,9 +119,9 @@ Bool_t CbmTrdSetTracksPidLike::ReadData() "MC_muon_eloss"}; inArr = new TObjArray(histnames.size()); for (size_t i = 0; i < histnames.size(); i++) { - h[i] = (TH2D*) histFile->Get(histnames[i]); + h[i] = histFile->Get<TH2D>(histnames[i]); if (!h[i]) { - Info("ReadData", "no input histogram %s", histnames[i].Data()); + LOG(info) << "No input histogram " << histnames[i].Data(); continue; } @@ -141,10 +141,10 @@ Bool_t CbmTrdSetTracksPidLike::ReadData() "ELE_proton_p_eloss", "ELE_muon_p_eloss"}; inArr = new TObjArray(histnames.size()); for (size_t i = 0; i < histnames.size(); i++) { - h[i] = (TH2D*) histFile->Get(histnames[i]); + h[i] = histFile->Get<TH2D>(histnames[i]); h[i]->SetNameTitle(histnames[i], histnames[i]); if (!h[i]) { - Info("ReadData", "no input histogram %s", histnames[i].Data()); + LOG(info) << "No input histogram " << histnames[i].Data(); continue; } @@ -168,9 +168,9 @@ Bool_t CbmTrdSetTracksPidLike::ReadData() "ELE_muon_eloss"}; inArr = new TObjArray(histnames.size()); for (size_t i = 0; i < histnames.size(); i++) { - h[i] = (TH2D*) histFile->Get(histnames[i]); + h[i] = histFile->Get<TH2D>(histnames[i]); if (!h[i]) { - Info("ReadData", "no input histogram %s", histnames[i].Data()); + LOG(info) << "No input histogram " << histnames[i].Data(); continue; } @@ -191,7 +191,7 @@ Bool_t CbmTrdSetTracksPidLike::ReadData() TH1* hist = (TH1*) inArr->At(i)->Clone(); TString name = hist->GetTitle(); - if (hist->GetEntries() < 1000) Info("ReadData", "input histogram is almost empty for %s", name.Data()); + LOG_IF(info, hist->GetEntries() < 1000) << "Input histogram is almost empty for" << name.Data(); // check particles if (name.Contains("electron")) particle = CbmTrdSetTracksPidLike::kElectron; @@ -207,7 +207,7 @@ Bool_t CbmTrdSetTracksPidLike::ReadData() continue; // add to hist array - Info("ReadData", "particle histogram %s added to array at %d", name.Data(), particle); + LOG(info) << "Particle histogram " << name.Data() << " added to array at " << particle; fHistdEdx->AddAt(hist, particle); } diff --git a/reco/detectors/trd/qa/CbmTrdHitDensityQa.cxx b/reco/detectors/trd/qa/CbmTrdHitDensityQa.cxx index 6a10ce15d63dd432189c4e9b7b9210b72515b2ed..581d94d51bc2c2e75bdefad90448b43b0c427401 100644 --- a/reco/detectors/trd/qa/CbmTrdHitDensityQa.cxx +++ b/reco/detectors/trd/qa/CbmTrdHitDensityQa.cxx @@ -414,7 +414,7 @@ void CbmTrdHitDensityQa::Finish() tempFile = new TFile(newpath, "recreate"); gDirectory->pwd(); - if (fPlotResults) fEventCounter = (TH1I*) tempFile->Get("fEventCounter"); + if (fPlotResults) fEventCounter = tempFile->Get<TH1I>("fEventCounter"); else fEventCounter->Write("", TObject::kOverwrite); if (!gDirectory->Cd("TrdHitDensityQa")) gDirectory->mkdir("TrdHitDensityQa"); @@ -429,18 +429,18 @@ void CbmTrdHitDensityQa::Finish() //cout << histName << endl; if (fPlotResults) { if (fRatioTwoFiles) { - fModuleHitMapIt->second = - (TH2I*) tempFileNumerator->Get("TrdHitDensityQa/Module/" + histName)->Clone(histName + "_numerator"); + fModuleHitMapIt->second = static_cast<TH2I*>( + tempFileNumerator->Get<TH2I>("TrdHitDensityQa/Module/" + histName)->Clone(histName + "_numerator")); // if (NULL == fModuleHitMapIt->second) // LOG(error) << "CbmTrdHitRateFastQa:: data/result_Numerator.root " << histName.Data() << " not found"; fModuleHitMapIt->second->Scale(100); // // fModuleHitMapIt->second->Scale(2); - fModuleHitMapIt->second->Divide( - (TH2I*) tempFileDenominator->Get("TrdHitDensityQa/Module/" + histName)->Clone(histName + "_denominator")); + fModuleHitMapIt->second->Divide(static_cast<TH2I*>( + tempFileDenominator->Get<TH2I>("TrdHitDensityQa/Module/" + histName)->Clone(histName + "_denominator"))); // fModuleHitMapIt->second->Divide( - // (TH2I*)tempFileNumerator->Get("TrdHitDensityQa/Module/" + histName)->Clone(histName+"_numerator"), - // (TH2I*)tempFileDenominator->Get("TrdHitDensityQa/Module/" + histName)->Clone(histName+"_denominator"), + // tempFileNumerator->Get<TH2I>("TrdHitDensityQa/Module/" + histName)->Clone(histName+"_numerator"), + // tempFileDenominator->Get<TH2I>("TrdHitDensityQa/Module/" + histName)->Clone(histName+"_denominator"), // 1.,1.); // need to be in the kHz range, therefore 100 * 1000 // 1000.,1.); // need to be in the kHz range, therefore 100 * 1000 @@ -451,7 +451,7 @@ void CbmTrdHitDensityQa::Finish() // LOG(error) << "CbmTrdHitRateFastQa:: data/result_Denominator.root " << histName.Data() << " not found"; } else - fModuleHitMapIt->second = (TH2I*) tempFile->Get("TrdHitDensityQa/Module/" + histName); + fModuleHitMapIt->second = tempFile->Get<TH2I>("TrdHitDensityQa/Module/" + histName); } else fModuleHitMapIt->second->Write("", TObject::kOverwrite); diff --git a/reco/detectors/trd/qa/CbmTrdOccupancyQa.cxx b/reco/detectors/trd/qa/CbmTrdOccupancyQa.cxx index 5f887f33cbe1da2076f11ca22cc56d716f85f986..e81a220037da7fb265b57091ff8826308cb90460 100644 --- a/reco/detectors/trd/qa/CbmTrdOccupancyQa.cxx +++ b/reco/detectors/trd/qa/CbmTrdOccupancyQa.cxx @@ -191,7 +191,7 @@ void CbmTrdOccupancyQa::Exec(Option_t*) fLayerDummy = new TH2I("LayerDummy","",1200,-600,600,1000,-500,500); fLayerDummy->SetXTitle("x-coordinate [cm]"); fLayerDummy->SetYTitle("y-coordinate [cm]"); - //fDigiChargeSpectrum = (TH1I*)outFile->Get("DigiChargeSpectrum"); + //fDigiChargeSpectrum = outFile->Get<TH1I>("DigiChargeSpectrum"); //if (!fDigiChargeSpectrum) fDigiChargeSpectrum = new TH1I("DigiChargeSpectrum","DigiChargeSpectrum",1e6,0,1e-3); */ @@ -221,7 +221,7 @@ void CbmTrdOccupancyQa::Exec(Option_t*) Int_t nCols = fModuleInfo->GetNofColumns(); if (fModuleOccupancyMap.find(moduleAddress) == fModuleOccupancyMap.end()) { title.Form("Module_%i", moduleAddress); - //fModuleOccupancyMap[moduleAddress] = (TH2F*)outFile->Get(title); + //fModuleOccupancyMap[moduleAddress] = outFile->Get<TH2F>(title); //if (!fModuleOccupancyMap[moduleAddress]) fModuleOccupancyMap[moduleAddress] = new TH2I(title, title, nCols, -0.5, nCols - 0.5, nRows, -0.5, nRows - 0.5); @@ -281,7 +281,7 @@ void CbmTrdOccupancyQa::Exec(Option_t*) digiCounter++; if (fModuleOccupancyMap.find(moduleAddress) == fModuleOccupancyMap.end()) { title.Form("Module_%i", moduleAddress); - //fModuleOccupancyMap[moduleAddress] = (TH2F*)outFile->Get(title); + //fModuleOccupancyMap[moduleAddress] = outFile->Get<TH2F>(title); //if (!fModuleOccupancyMap[moduleAddress]) fModuleOccupancyMap[moduleAddress] = new TH2I(title, title, nCols, -0.5, nCols - 0.5, nRows, -0.5, nRows - 0.5); @@ -411,7 +411,7 @@ void CbmTrdOccupancyQa::SwitchToMergedFile() std::cout << histName << std::endl; ; fModuleOccupancyMap[fModuleOccupancyMapIt->first] = - (TH2I*) Target->Get("TrdOccupancy/Module/" + histName)->Clone(histName + "_result"); + static_cast<TH2I*>(Target->Get<TH2I>("TrdOccupancy/Module/" + histName)->Clone(histName + "_result")); } } else { diff --git a/reco/detectors/trd/rawToDigiMethods/CbmTrdRawToDigiLookUpCorrR.cxx b/reco/detectors/trd/rawToDigiMethods/CbmTrdRawToDigiLookUpCorrR.cxx index 119dfef09bd50c203d256525a4e9ecec032e6c52..73a5277f8d3cfc85119446a7e084df7ddc102dec 100644 --- a/reco/detectors/trd/rawToDigiMethods/CbmTrdRawToDigiLookUpCorrR.cxx +++ b/reco/detectors/trd/rawToDigiMethods/CbmTrdRawToDigiLookUpCorrR.cxx @@ -97,20 +97,19 @@ void CbmTrdRawToDigiLookUpCorrR::loadLookUpTables(std::string infile) TFile file(infile.data(), "READ"); if (file.IsOpen()) { std::string hname = Form("Timeshift_Map_Fst%d_Snd%d", fFirstLookUpSamplePos, fSecondLookUpSamplePos); - TH2* hTimeshiftMap = (TH2*) file.Get(hname.data()); - if (!hTimeshiftMap) - LOG(fatal) << "CbmTrdRawToDigiLookUpCorrR::loadLookUpTables: Look up mode that reqiures Timeshift Map " - "histogram requested, but the map " - << hname << " was not found in the given file(" << infile << ")!"; + TH2* hTimeshiftMap = file.Get<TH2>(hname.data()); + LOG_IF(fatal, !hTimeshiftMap) + << "CbmTrdRawToDigiLookUpCorrR::loadLookUpTables: Look up mode that reqiures Timeshift Map " + "histogram requested, but the map " + << hname << " was not found in the given file(" << infile << ")!"; hname = Form("MaxAdc_Map_Fst%d_Snd%d", fFirstLookUpSamplePos, fSecondLookUpSamplePos); - TH2* hMaxAdcMap = (TH2*) file.Get(hname.data()); - if (!hMaxAdcMap) - LOG(fatal) << "CbmTrdRawToDigiLookUpCorrR::loadLookUpTables: Look up mode that reqiures MaxAdc Map " - "histogram requested, but the map " - << hname << " was not found in the given file(" << infile << ")!"; - - // TH2* hMaxAdcMap = (TH2*) file.Get("MAX ADC"); - // TH2* hAsymMap = (TH2*) file.Get("ASYM MAP"); + TH2* hMaxAdcMap = file.Get<TH2>(hname.data()); + LOG_IF(fatal, !hMaxAdcMap) << "CbmTrdRawToDigiLookUpCorrR::loadLookUpTables: Look up mode that reqiures MaxAdc Map " + "histogram requested, but the map " + << hname << " was not found in the given file(" << infile << ")!"; + + // TH2* hMaxAdcMap = file.Get<TH2>("MAX ADC"); + // TH2* hAsymMap = file.Get<TH2>("ASYM MAP"); if (hMaxAdcMap && hTimeshiftMap) { auto h = hMaxAdcMap; diff --git a/reco/littrack/cbm/qa/clustering/CbmLitClusteringQa.cxx b/reco/littrack/cbm/qa/clustering/CbmLitClusteringQa.cxx index e8c0712daa0ca268877ea207f531910ec46e7f57..1e24d7b801837aac789f8535eff1c16556ac2669 100644 --- a/reco/littrack/cbm/qa/clustering/CbmLitClusteringQa.cxx +++ b/reco/littrack/cbm/qa/clustering/CbmLitClusteringQa.cxx @@ -155,7 +155,9 @@ void CbmLitClusteringQa::InitMuchGeoScheme(const string& digiFileName) TDirectory* oldDir = gDirectory; TFile* file = new TFile(digiFileName.c_str()); - TObjArray* stations = (TObjArray*) file->Get("stations"); + LOG_IF(fatal, !file) << "Could not open file " << digiFileName; + TObjArray* stations = file->Get<TObjArray>("stations"); + LOG_IF(fatal, !stations) << "TObjArray stations could not be read from file " << digiFileName; file->Close(); file->Delete(); diff --git a/reco/littrack/cbm/qa/fit/CbmLitFitQaReport.cxx b/reco/littrack/cbm/qa/fit/CbmLitFitQaReport.cxx index 3626969141b55353bdf358088a953a7813018c9c..7efacd7824198c52d3451b2e1f1eb4de52437642 100644 --- a/reco/littrack/cbm/qa/fit/CbmLitFitQaReport.cxx +++ b/reco/littrack/cbm/qa/fit/CbmLitFitQaReport.cxx @@ -224,7 +224,7 @@ void CbmLitFitQaReport::DrawTrackParamsAtVertex() TCanvas* canvas3 = CreateCanvas("fit_qa_momentum_momres_mom_sigma", "fit_qa_momentum_momres_mom_sigma", 600, 600); canvas3->cd(1); HM()->H2("htf_MomRes_Mom")->FitSlicesY(); - TH1* momslice = (TH1*) gDirectory->Get("htf_MomRes_Mom_2"); + TH1* momslice = gDirectory->Get<TH1>("htf_MomRes_Mom_2"); momslice->GetXaxis()->SetTitle("P [GeV/c]"); momslice->GetYaxis()->SetTitle("dP/P, #sigma [%]"); momslice->SetMinimum(0.); diff --git a/reco/littrack/cbm/qa/fit/CbmLitFitQaStudyReport.cxx b/reco/littrack/cbm/qa/fit/CbmLitFitQaStudyReport.cxx index f2c87201bc86fe7686e53bc6297b8dbb4548ab47..da50c972824a6a04ab600775105a6fb927366a9d 100644 --- a/reco/littrack/cbm/qa/fit/CbmLitFitQaStudyReport.cxx +++ b/reco/littrack/cbm/qa/fit/CbmLitFitQaStudyReport.cxx @@ -76,7 +76,7 @@ void CbmLitFitQaStudyReport::DrawTrackParamsAtVertex() vector<TH1*> histos2(nofStudies); for (Int_t iStudy = 0; iStudy < nofStudies; iStudy++) { HM()[iStudy]->H2("htf_MomRes_Mom")->FitSlicesY(); - histos2[iStudy] = (TH1*) gDirectory->Get("htf_MomRes_Mom_2"); + histos2[iStudy] = gDirectory->Get<TH1>("htf_MomRes_Mom_2"); histos2[iStudy]->SetName(string("htf_MomRes_Mom_2_" + NumberToString<Int_t>(iStudy)).c_str()); histos2[iStudy]->GetXaxis()->SetTitle("P [GeV/c]"); histos2[iStudy]->GetYaxis()->SetTitle("dP/P, #sigma [%]"); diff --git a/reco/littrack/cbm/qa/tof/CbmLitTofQa.cxx b/reco/littrack/cbm/qa/tof/CbmLitTofQa.cxx index ad38be67bad491e5fe0b86e76aecde0c5147b403..384abe0583c5100eda4ac709b2bf89ef17d87e3b 100644 --- a/reco/littrack/cbm/qa/tof/CbmLitTofQa.cxx +++ b/reco/littrack/cbm/qa/tof/CbmLitTofQa.cxx @@ -371,8 +371,8 @@ void CbmLitTofQa::ProcessTofTracks() void CbmLitTofQa::FitHistograms() { fHM->H2("hmp_Tof_RecoMCID_Pion_m2p")->FitSlicesY(); - TH1* meanHist = (TH1*) gDirectory->Get("hmp_Tof_RecoMCID_Pion_m2p_1"); // mean - TH1* sigmaHist = (TH1*) gDirectory->Get("hmp_Tof_RecoMCID_Pion_m2p_2"); // sigma + TH1* meanHist = gDirectory->Get<TH1>("hmp_Tof_RecoMCID_Pion_m2p_1"); // mean + TH1* sigmaHist = gDirectory->Get<TH1>("hmp_Tof_RecoMCID_Pion_m2p_2"); // sigma Int_t nofBins = meanHist->GetNbinsX(); for (Int_t iBin = 0; iBin <= nofBins; iBin++) { Double_t mean = meanHist->GetBinContent(iBin); diff --git a/reco/littrack/cbm/qa/tof/CbmLitTofQaReport.cxx b/reco/littrack/cbm/qa/tof/CbmLitTofQaReport.cxx index 97107bb61e8e7f0bebc2e7c2434bff44dca23fc9..b935275e1e41cd0fe89a8d50160b1026af6158b8 100644 --- a/reco/littrack/cbm/qa/tof/CbmLitTofQaReport.cxx +++ b/reco/littrack/cbm/qa/tof/CbmLitTofQaReport.cxx @@ -80,8 +80,8 @@ void CbmLitTofQaReport::FitHistograms() TH2* hist = HM()->H2(histName); DrawH2(hist); hist->FitSlicesY(); - TH1* meanHist = (TH1*) gDirectory->Get(string(histName + "_1").c_str()); // mean - TH1* sigmaHist = (TH1*) gDirectory->Get(string(histName + "_2").c_str()); // sigma + TH1* meanHist = gDirectory->Get<TH1>(string(histName + "_1").c_str()); // mean + TH1* sigmaHist = gDirectory->Get<TH1>(string(histName + "_2").c_str()); // sigma Int_t nofBins = meanHist->GetNbinsX(); TGraph* upGraph = new TGraph(nofBins); upGraph->GetXaxis()->SetRangeUser(meanHist->GetXaxis()->GetXmin(), meanHist->GetXaxis()->GetXmax()); diff --git a/reco/littrack/clustering/CbmMuchClustering.cxx b/reco/littrack/clustering/CbmMuchClustering.cxx index fd17c6d56f6be58fb9d5cf1d5c39e7550257469f..85dbb424191669b4ed5405eda80cc2089d465bed 100644 --- a/reco/littrack/clustering/CbmMuchClustering.cxx +++ b/reco/littrack/clustering/CbmMuchClustering.cxx @@ -87,7 +87,9 @@ InitStatus CbmMuchClustering::Init() TDirectory* oldDir = gDirectory; TFile* file = new TFile(fDigiFile); - TObjArray* stations = (TObjArray*) file->Get("stations"); + LOG_IF(fatal, !file) << "Could not open file " << fDigiFile; + TObjArray* stations = file->Get<TObjArray>("stations"); + LOG_IF(fatal, !stations) << "TObjArray stations could not be read from file " << fDigiFile; file->Close(); file->Delete(); diff --git a/reco/tracking/lx/GenNoiseElectrons/GenNoiseElectrons.cxx b/reco/tracking/lx/GenNoiseElectrons/GenNoiseElectrons.cxx index effed12b3632e699a31cd962022df007487111ed..4876ad8df406062bdf35800c10d295ec41893ef3 100644 --- a/reco/tracking/lx/GenNoiseElectrons/GenNoiseElectrons.cxx +++ b/reco/tracking/lx/GenNoiseElectrons/GenNoiseElectrons.cxx @@ -55,9 +55,9 @@ static Double_t GetRMS(const char* name) TFile* f = new TFile(fileName); if (!f->IsZombie()) { - TH1F* h = static_cast<TH1F*>(f->Get(name)); + TH1F* h = f->Get<TH1F>(name); - if (0 != h) result = h->GetRMS(); + if (h) result = h->GetRMS(); } delete f; diff --git a/reco/tracking/lx/Simple/Lx.cxx b/reco/tracking/lx/Simple/Lx.cxx index 0f50f34f1206bd4e8f55c202371b1227e21c7002..3552695ba98f2851388cb4420a10bdc4f5076483 100644 --- a/reco/tracking/lx/Simple/Lx.cxx +++ b/reco/tracking/lx/Simple/Lx.cxx @@ -302,9 +302,11 @@ static bool GetHistoRMS(const char* histoNameBase, Int_t histoNumber, scaltype& else sprintf(name, "%s_%d", histoNameBase, histoNumber); - TH1F* h = static_cast<TH1F*>(f->Get(name)); - retVal = h->GetRMS(); - result = true; + TH1F* h = f->Get<TH1F>(name); + if (h) { + retVal = h->GetRMS(); + result = true; + } } delete f; @@ -336,9 +338,11 @@ static bool GetHistoCOV(const char* histoNameBase, Int_t histoNumber, Int_t axis if (!f->IsZombie()) { sprintf(name, "%s_%d", histoNameBase, histoNumber); - TH2F* h = static_cast<TH2F*>(f->Get(name)); - retVal = h->GetCovariance(axis1, axis2); - result = true; + TH2F* h = f->Get<TH2F>(name); + if (h) { + retVal = h->GetCovariance(axis1, axis2); + result = true; + } } delete f; diff --git a/reco/tracking/lx/Simple/LxTrackAna.cxx b/reco/tracking/lx/Simple/LxTrackAna.cxx index beb053896f51abddcf9abc8b799622dddb7725b4..81f398a331fea72679ef1be5ac8bf7cd05746135 100644 --- a/reco/tracking/lx/Simple/LxTrackAna.cxx +++ b/reco/tracking/lx/Simple/LxTrackAna.cxx @@ -393,7 +393,7 @@ void LxTrackAna::FinishTask() if (buildBgrInvMass) { if (joinData) { TFile fh("tracks_tree.root"); - superEventTracks = static_cast<TTree*>(fh.Get("SuperEventTracks")); + superEventTracks = fh.Get<TTree>("SuperEventTracks"); //LxSimpleTrack st(0, 0, 0, 0, 0, 0, 0, 0); //superEventTracks->SetBranchAddress("tracks", &st.px); CbmStsTrack* st = new CbmStsTrack; diff --git a/reco/tracking/lx/TBBinned/LxTBTrdTask.cxx b/reco/tracking/lx/TBBinned/LxTBTrdTask.cxx index 687debf678d1559ba299f3fcde0ce9ccdde77b94..962d7be78e8e8c07e7656b274398a73b9542497a 100644 --- a/reco/tracking/lx/TBBinned/LxTBTrdTask.cxx +++ b/reco/tracking/lx/TBBinned/LxTBTrdTask.cxx @@ -151,7 +151,7 @@ static bool GetHistoRMS(const char* name, Double_t& retVal) TFile* f = new TFile(fileName); if (!f->IsZombie()) { - TH1F* h = static_cast<TH1F*>(f->Get(name)); + TH1F* h = f->Get<TH1F>(name); retVal = h->GetRMS(); result = true; } diff --git a/reco/tracking/lxTriplet/Lx.cxx b/reco/tracking/lxTriplet/Lx.cxx index b21d91bbfd71068bf6cb9c8e62535a5acee3a57e..21e965a69f38dd18f9a0d6a4d212a138eea25705 100644 --- a/reco/tracking/lxTriplet/Lx.cxx +++ b/reco/tracking/lxTriplet/Lx.cxx @@ -154,7 +154,7 @@ static bool GetHistoRMS(const char* histoNameBase, Int_t histoNumber, Double_t& if (!f->IsZombie()) { sprintf(name, "%s_%d", histoNameBase, histoNumber); - TH1F* h = static_cast<TH1F*>(f->Get(name)); + TH1F* h = f->Get<TH1F>(name); retVal = h->GetRMS(); result = true; } @@ -184,7 +184,7 @@ static bool GetHistoCOV(const char* histoNameBase, Int_t histoNumber, Int_t axis if (!f->IsZombie()) { sprintf(name, "%s_%d", histoNameBase, histoNumber); - TH2F* h = static_cast<TH2F*>(f->Get(name)); + TH2F* h = f->Get<TH2F>(name); retVal = h->GetCovariance(axis1, axis2); result = true; } diff --git a/reco/tracking/lxTriplet/LxTrackAna.cxx b/reco/tracking/lxTriplet/LxTrackAna.cxx index fbe322f9a1add1c116439e4de8e8d9f44effdf96..56985b10b38c4c5a07ca37df8f98f1cc0b0f7381 100644 --- a/reco/tracking/lxTriplet/LxTrackAna.cxx +++ b/reco/tracking/lxTriplet/LxTrackAna.cxx @@ -371,7 +371,7 @@ void LxTrackAnaTriplet::FinishTask() if (buildBgrInvMass) { if (joinData) { TFile fh("tracks_tree.root"); - superEventTracks = static_cast<TTree*>(fh.Get("SuperEventTracks")); + superEventTracks = fh.Get<TTree>("SuperEventTracks"); //LxSimpleTrack st(0, 0, 0, 0, 0, 0, 0, 0); //superEventTracks->SetBranchAddress("tracks", &st.px); CbmStsTrack* st = new CbmStsTrack; diff --git a/reco/tracking/lxTriplet/LxTrackAnaSegments.cxx b/reco/tracking/lxTriplet/LxTrackAnaSegments.cxx index f3197e7e2741559fcf3c1eff7bbc71377d6d18e9..bc1ed46592bce407cbbd080fb99b8c83c1da0907 100644 --- a/reco/tracking/lxTriplet/LxTrackAnaSegments.cxx +++ b/reco/tracking/lxTriplet/LxTrackAnaSegments.cxx @@ -79,7 +79,7 @@ static bool GetHistoRMS(const char* histoNameBase, Int_t histoNumber, Double_t& if (!f->IsZombie()) { sprintf(name, "%s_%d", histoNameBase, histoNumber); - TH1F* h = static_cast<TH1F*>(f->Get(name)); + TH1F* h = f->Get<TH1F>(name); retVal = h->GetRMS(); result = true; } diff --git a/sim/detectors/much/CbmMuchDigitizeGem.cxx b/sim/detectors/much/CbmMuchDigitizeGem.cxx index e65794e91de8b94fc88ce99804f10c935dda67e6..069def350e8999936d361a0bb5cff711921af21b 100644 --- a/sim/detectors/much/CbmMuchDigitizeGem.cxx +++ b/sim/detectors/much/CbmMuchDigitizeGem.cxx @@ -381,8 +381,9 @@ InitStatus CbmMuchDigitizeGem::Init() TFile* oldFile = gFile; TDirectory* oldDir = gDirectory; TFile* file = new TFile(fDigiFile); - if (!file->IsOpen()) LOG(fatal) << fName << ": parameter file " << fDigiFile << " does not exist!"; - TObjArray* stations = (TObjArray*) file->Get("stations"); + LOG_IF(fatal, !file->IsOpen()) << fName << ": parameter file " << fDigiFile << " does not exist!"; + TObjArray* stations = file->Get<TObjArray>("stations"); + LOG_IF(fatal, !stations) << "No TObjArray stations found in file " << fDigiFile; file->Close(); file->Delete(); /// Restore old global file and folder pointer to avoid messing with FairRoot diff --git a/sim/detectors/trd/CbmTrdModuleSimR.cxx b/sim/detectors/trd/CbmTrdModuleSimR.cxx index b0adf877df99fff4cb95fc842285ac90212246aa..dd86d07ae4b15da95572eb0b90fba5efc7096bf3 100644 --- a/sim/detectors/trd/CbmTrdModuleSimR.cxx +++ b/sim/detectors/trd/CbmTrdModuleSimR.cxx @@ -98,7 +98,9 @@ CbmTrdModuleSimR::CbmTrdModuleSimR(Int_t mod, Int_t ly, Int_t rot) TString dir = getenv("VMCWORKDIR"); TString filename = dir + "/parameters/trd/FeatureExtractionLookup.root"; TFile* f = new TFile(filename, "OPEN"); - fDriftTime = (TH2D*) f->Get("Drift"); + LOG_IF(fatal, !f->IsOpen()) << "parameter file " << filename << " does not exist!"; + fDriftTime = f->Get<TH2D>("Drift"); + LOG_IF(fatal, !fDriftTime) << "No histogram Drift founfd in file " << filename; fDriftTime->SetDirectory(0); f->Close(); diff --git a/sim/detectors/trd/CbmTrdRawToDigiR.cxx b/sim/detectors/trd/CbmTrdRawToDigiR.cxx index d041e2f7db62f1d4eacc3d43192255f1e96cb60b..6aaa07f7f021c419624a8a420f5409ddb4bc4f2e 100644 --- a/sim/detectors/trd/CbmTrdRawToDigiR.cxx +++ b/sim/detectors/trd/CbmTrdRawToDigiR.cxx @@ -353,8 +353,10 @@ void CbmTrdRawToDigiR::ReadMaps(std::string file) { if (fLookUp == 3) { TFile f(file.data(), "OPEN"); + LOG_IF(fatal, !f.IsOpen()) << "parameter file " << file << " does not exist!"; TProfile2D* h; - h = (TProfile2D*) f.Get("MAX ADC"); + h = f.Get<TProfile2D>("MAX ADC"); + LOG_IF(fatal, !h) << "No histogram MAX ADC found in file " << file; for (Int_t x = 1; x <= h->GetNbinsX(); x++) { for (Int_t y = 1; y <= h->GetNbinsY(); y++) { fElookupSmall[h->GetXaxis()->GetBinCenter(x)][h->GetYaxis()->GetBinCenter(y)] = h->GetBinContent(x, y); @@ -364,7 +366,8 @@ void CbmTrdRawToDigiR::ReadMaps(std::string file) h->GetBinContent(x, y)); } } - h = (TProfile2D*) f.Get("ASYM MAP"); + h = f.Get<TProfile2D>("ASYM MAP"); + LOG_IF(fatal, !h) << "No histogram ASYM MAP found in file " << file; for (Int_t x = 1; x <= h->GetNbinsX(); x++) { for (Int_t y = 1; y <= h->GetNbinsY(); y++) { fElookupA[h->GetXaxis()->GetBinCenter(x)][h->GetYaxis()->GetBinCenter(y)] = h->GetBinContent(x, y); @@ -378,8 +381,10 @@ void CbmTrdRawToDigiR::ReadMaps(std::string file) } if (fLookUp == 4) { TFile f(file.data(), "OPEN"); + LOG_IF(fatal, !f.IsOpen()) << "parameter file " << file << " does not exist!"; TProfile2D* h; - h = (TProfile2D*) f.Get("MAX ADC"); + h = f.Get<TProfile2D>("MAX ADC"); + LOG_IF(fatal, !h) << "No histogram MAX ADC found in file " << file; for (Int_t x = 1; x <= h->GetNbinsX(); x++) { for (Int_t y = 1; y <= h->GetNbinsY(); y++) { fElookupSmall[h->GetXaxis()->GetBinCenter(x)][h->GetYaxis()->GetBinCenter(y)] = h->GetBinContent(x, y); @@ -389,7 +394,8 @@ void CbmTrdRawToDigiR::ReadMaps(std::string file) h->GetBinContent(x, y)); } } - h = (TProfile2D*) f.Get("ASYM MAP"); + h = f.Get<TProfile2D>("ASYM MAP"); + LOG_IF(fatal, !h) << "No histogram ASYM MAP found in file " << file; for (Int_t x = 1; x <= h->GetNbinsX(); x++) { for (Int_t y = 1; y <= h->GetNbinsY(); y++) { fElookupA[h->GetXaxis()->GetBinCenter(x)][h->GetYaxis()->GetBinCenter(y)] = h->GetBinContent(x, y); diff --git a/sim/response/base/CbmDigitization.cxx b/sim/response/base/CbmDigitization.cxx index 5ed24c626ee793f9483d2882fe2771bb92861344..e8f6038d9c8d1cd804e7bc87cadc2a2f5479a44b 100644 --- a/sim/response/base/CbmDigitization.cxx +++ b/sim/response/base/CbmDigitization.cxx @@ -125,7 +125,7 @@ Int_t CbmDigitization::CheckInput() assert(input); TFile* file = input->GetChain()->GetFile(); assert(file); - TTree* tree = dynamic_cast<TTree*>(file->Get("cbmsim")); + TTree* tree = file->Get<TTree>("cbmsim"); assert(tree); FairMCEventHeader* header = new FairMCEventHeader(); tree->SetBranchAddress("MCEventHeader.", &header); diff --git a/sim/response/base/CbmDigitizationSource.cxx b/sim/response/base/CbmDigitizationSource.cxx index 791fdfc64ddaa757eb6b04897a0514c3b8cbad0f..362a59e4345103fd84a375eceef4dca1b1036500 100644 --- a/sim/response/base/CbmDigitizationSource.cxx +++ b/sim/response/base/CbmDigitizationSource.cxx @@ -230,7 +230,8 @@ Bool_t CbmDigitizationSource::Init() // Get folder from first input file and register it to FairRootManager CbmMCInput* input = fInputSets.front()->GetFirstInput().second; TFile* file = input->GetChain()->GetFile(); - TFolder* folder = dynamic_cast<TFolder*>(file->Get("cbmroot")); + assert(file); + TFolder* folder = file->Get<TFolder>("cbmroot"); assert(folder); gROOT->GetListOfBrowsables()->Add(folder); fListOfFolders->Add(folder); diff --git a/sim/response/base/CbmMCInput.cxx b/sim/response/base/CbmMCInput.cxx index 8335fc0957e89f0b70a2c5bfb291a0f8ade1e7b4..8fdc70bb78d25dc3359337f7b45017006ac1f3ba 100644 --- a/sim/response/base/CbmMCInput.cxx +++ b/sim/response/base/CbmMCInput.cxx @@ -90,7 +90,7 @@ UInt_t CbmMCInput::ReadBranches() { fBranches.clear(); - TList* listFile = dynamic_cast<TList*>(fChain->GetFile()->Get("BranchList")); + TList* listFile = fChain->GetFile()->Get<TList>("BranchList"); assert(listFile); TObjString* branchName = nullptr; for (Int_t entry = 0; entry < listFile->GetEntries(); entry++) { diff --git a/sim/transport/generators/CbmUnigenGenerator.cxx b/sim/transport/generators/CbmUnigenGenerator.cxx index c537325db59e1a24f0eec478c5c8b4feb627eeda..6be11ca78e347220ab9fa1909466195326233cc9 100644 --- a/sim/transport/generators/CbmUnigenGenerator.cxx +++ b/sim/transport/generators/CbmUnigenGenerator.cxx @@ -156,7 +156,7 @@ Bool_t CbmUnigenGenerator::Init() LOG(info) << GetName() << ": Open input file " << fFileName; // --- Get and print run description - URun* run = dynamic_cast<URun*>(fFile->Get("run")); + URun* run = fFile->Get<URun>("run"); if (run == nullptr) { LOG(error) << GetName() << ": No run description in input file!"; fFile->Close(); @@ -179,7 +179,7 @@ Bool_t CbmUnigenGenerator::Init() << " beta " << fBetaCM << ", gamma " << fGammaCM; // --- Get input tree and connect event object to its branch - fTree = dynamic_cast<TTree*>(fFile->Get("events")); + fTree = fFile->Get<TTree>("events"); if (fTree == nullptr) { LOG(error) << GetName() << ": No event tree in input file!"; fFile->Close();