14 #include <TCollection.h>
15 #include <TDirectory.h>
16 #include <TDirectoryFile.h>
17 #include <TGenericClassInfo.h>
27 #include <TProfile2D.h>
29 #include <boost/regex.hpp>
47 public std::binary_function<const TNamed*, const TNamed*, Bool_t> {
49 Bool_t
operator()(
const TNamed* object1,
const TNamed* object2)
const {
50 return string(object1->GetName()) > string(object2->GetName());
63 const boost::regex e(pattern);
64 map<string, TNamed*>::const_iterator it;
65 for (it =
fMap.begin(); it !=
fMap.end(); it++) {
66 if (boost::regex_match(it->first, e)) {
67 T ObjectPointer =
dynamic_cast<T
>(it->second);
68 if (ObjectPointer !=
nullptr) objects.push_back(ObjectPointer);
71 }
catch (exception& ex) {
72 LOG(info) <<
"Exception in CbmHistManager::ObjectVector: " << ex.what();
80 return ObjectVector<TH1*>(pattern);
84 return ObjectVector<TH2*>(pattern);
88 return ObjectVector<TGraph*>(pattern);
92 return ObjectVector<TGraph2D*>(pattern);
96 return ObjectVector<TProfile*>(pattern);
100 return ObjectVector<TProfile2D*>(pattern);
104 map<string, TNamed*>::iterator it;
105 for (it =
fMap.begin(); it !=
fMap.end(); it++) {
111 assert(file !=
nullptr);
112 LOG(info) <<
"CbmHistManager::ReadFromFile";
113 TDirectory* dir = gDirectory;
114 TIter nextkey(dir->GetListOfKeys());
116 while ((key = (TKey*) nextkey())) {
117 TObject* obj = key->ReadObj();
124 if (obj->IsA()->InheritsFrom(TH1::Class())
125 || obj->IsA()->InheritsFrom(TGraph::Class())
126 || obj->IsA()->InheritsFrom(TGraph2D::Class())) {
127 TNamed*
h = (TNamed*) obj;
129 Add(
string(
h->GetName()),
h);
134 if (obj->IsA()->InheritsFrom(TDirectoryFile::Class())) {
135 TDirectoryFile* fileDir = (TDirectoryFile*) obj;
136 TIter nextkey(fileDir->GetListOfKeys());
138 while ((key2 = (TKey*) nextkey())) {
139 TObject* obj2 = key2->ReadObj();
147 map<string, TNamed*>::iterator it;
148 for (it =
fMap.begin(); it !=
fMap.end(); it++) {
155 TH1* hist =
H1(histName);
156 Int_t nofBins = hist->GetNbinsX();
159 Bool_t isSet =
false;
160 for (Int_t iBin = 1; iBin <= nofBins; iBin++) {
161 Double_t content = hist->GetBinContent(iBin);
163 minShrinkBin =
std::min(iBin, minShrinkBin);
164 maxShrinkBin =
std::max(iBin, maxShrinkBin);
169 hist->GetXaxis()->SetRange(minShrinkBin, maxShrinkBin);
175 vector<TH1*> effHistos =
H1Vector(pattern);
176 Int_t nofEffHistos = effHistos.size();
177 for (Int_t iHist = 0; iHist < nofEffHistos; iHist++) {
183 TH1* hist =
H2(histName);
184 Int_t nofBinsX = hist->GetNbinsX();
185 Int_t nofBinsY = hist->GetNbinsY();
190 Bool_t isSet =
false;
191 for (Int_t iBinX = 1; iBinX <= nofBinsX; iBinX++) {
192 for (Int_t iBinY = 1; iBinY <= nofBinsY; iBinY++) {
193 Double_t content = hist->GetBinContent(iBinX, iBinY);
195 minShrinkBinX =
std::min(iBinX, minShrinkBinX);
196 maxShrinkBinX =
std::max(iBinX, maxShrinkBinX);
197 minShrinkBinY =
std::min(iBinY, minShrinkBinY);
198 maxShrinkBinY =
std::max(iBinY, maxShrinkBinY);
204 hist->GetXaxis()->SetRange(minShrinkBinX, maxShrinkBinX);
205 hist->GetYaxis()->SetRange(minShrinkBinY, maxShrinkBinY);
210 vector<TH1*> effHistos =
H1Vector(pattern);
211 Int_t nofEffHistos = effHistos.size();
212 for (Int_t iHist = 0; iHist < nofEffHistos; iHist++) {
218 H1(histName)->Scale(scale);
222 vector<TH1*> effHistos =
H1Vector(pattern);
223 Int_t nofEffHistos = effHistos.size();
224 for (Int_t iHist = 0; iHist < nofEffHistos; iHist++) {
225 Scale(effHistos[iHist]->GetName(), scale);
230 TH1* hist =
H1(histName);
231 hist->Scale(1. / hist->Integral());
235 vector<TH1*> effHistos =
H1Vector(pattern);
236 Int_t nofEffHistos = effHistos.size();
237 for (Int_t iHist = 0; iHist < nofEffHistos; iHist++) {
243 TH1* hist =
H1(histName);
246 hist->Scale(1. / (Double_t) ngroup);
251 vector<TH1*> effHistos =
H1Vector(pattern);
252 Int_t nofEffHistos = effHistos.size();
253 for (Int_t iHist = 0; iHist < nofEffHistos; iHist++) {
254 Rebin(effHistos[iHist]->GetName(), ngroup);
259 string str =
"CbmHistManager list of histograms:\n";
260 map<string, TNamed*>::const_iterator it;
261 for (it =
fMap.begin(); it !=
fMap.end(); it++) {
262 str += it->first +
"\n";
268 const std::string& title,
271 TCanvas* c =
new TCanvas(name.c_str(), title.c_str(), width, height);
277 const std::string& options) {