CbmRoot
Loading...
Searching...
No Matches
CbmStudyReport.cxx
Go to the documentation of this file.
1/* Copyright (C) 2011-2021 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Semen Lebedev, Andrey Lebedev [committer], Florian Uhlig */
4
10#include "CbmStudyReport.h"
11
12#include "CbmHistManager.h" // for CbmHistManager
13
14#include <TDirectory.h> // for TDirectory, gDirectory
15#include <TFile.h> // for TFile, gFile
16
17#include <cassert> // for assert
18#include <fstream> // for string, ofstream, stringstream
19#include <string> // for basic_string
20#include <vector> // for vector
21
22using std::ofstream;
23using std::string;
24using std::stringstream;
25using std::vector;
26
27CbmStudyReport::CbmStudyReport() : CbmReport(), fHM(), fStudyNames() {}
28
30
31void CbmStudyReport::Create(const vector<CbmHistManager*>& histManagers, const vector<string>& studyNames,
32 const string& outputDir)
33{
34 assert(histManagers.size() == studyNames.size());
35 fHM = histManagers;
36 fStudyNames = studyNames;
37 SetOutputDir(outputDir);
39}
40
41void CbmStudyReport::Create(const vector<string>& fileNames, const vector<string>& studyNames, const string& outputDir)
42{
43 assert(fileNames.size() == studyNames.size());
44 Int_t nofStudies = fileNames.size();
45 vector<TFile*> files(nofStudies);
46 fHM.resize(nofStudies);
47
48 TFile* oldFile = gFile;
49 TDirectory* oldDir = gDirectory;
50
51 for (Int_t i = 0; i < nofStudies; i++) {
52 fHM[i] = new CbmHistManager();
53 files[i] = new TFile(fileNames[i].c_str());
54 fHM[i]->ReadFromFile(files[i]);
55 }
56 fStudyNames = studyNames;
57 SetOutputDir(outputDir);
58
60
61 // Do not delete histogram managers and files.
62 // Otherwise histograms disappear from canvases
63 // and are not saved to file.
64 // for (Int_t i = 0; i < nofStudies; i++) {
65 // delete fHM[i];
66 // delete files[i];
67 // }
68 // fHM.clear();
69 // files.clear();
70
71 gFile = oldFile;
72 gDirectory = oldDir;
73}
74
ClassImp(CbmConverterManager)
Histogram manager.
Base class for study reports.
Histogram manager.
Base class for reports.
Definition CbmReport.h:45
void SetOutputDir(const std::string &outputDir)
Definition CbmReport.h:71
void CreateReports()
Create all available report types.
Definition CbmReport.cxx:71
Base class for study reports.
virtual void Create()=0
Inherited from CbmReport. Pure abstract function which is called from public Create() function.
virtual ~CbmStudyReport()
Destructor.
CbmStudyReport()
Constructor.
std::vector< std::string > fStudyNames
std::vector< CbmHistManager * > fHM