Go to the documentation of this file.
8 #ifndef CBMHISTMANAGER_H_
9 #define CBMHISTMANAGER_H_
12 #include <RtypesCore.h>
22 #include <TProfile2D.h>
24 #include <FairLogger.h>
58 void Add(
const std::string& name, TNamed*
object) {
60 std::map<std::string, TNamed*>::iterator it =
fMap.find(name);
61 if (it !=
fMap.end()) {
62 LOG(warn) <<
"CbmHistManager::Add Object with name:" << name
63 <<
" was already added. Set new object.";
66 std::pair<std::string, TNamed*> newpair = std::make_pair(name,
object);
82 const std::string& title,
86 T*
h =
new T(name.c_str(), title.c_str(), nofBins, minBin, maxBin);
105 const std::string& title,
112 T*
h =
new T(name.c_str(),
141 const std::string& title,
151 T*
h =
new T(name.c_str(),
170 TH1*
H1(
const std::string& name)
const {
171 if (
fMap.count(name) == 0) {
172 LOG(error) <<
"CbmHistManager::H1(name): name=" << name;
174 assert(
fMap.count(name) != 0);
175 return dynamic_cast<TH1*
>(
fMap.find(name)->second);
183 std::vector<TH1*>
H1Vector(
const std::string& pattern)
const;
190 TH2*
H2(
const std::string& name)
const {
191 if (
fMap.count(name) == 0) {
192 LOG(error) <<
"CbmHistManager::H2(name): name=" << name;
194 assert(
fMap.count(name) != 0);
195 return dynamic_cast<TH2*
>(
fMap.find(name)->second);
203 std::vector<TH2*>
H2Vector(
const std::string& pattern)
const;
210 TH3*
H3(
const std::string& name)
const {
211 if (
fMap.count(name) == 0) {
212 LOG(error) <<
"CbmHistManager::H3(name): name=" << name;
214 assert(
fMap.count(name) != 0);
215 return dynamic_cast<TH3*
>(
fMap.find(name)->second);
223 TGraph*
G1(
const std::string& name)
const {
224 if (
fMap.count(name) == 0) {
225 LOG(error) <<
"CbmHistManager::G1(name): name=" << name;
227 assert(
fMap.count(name) != 0);
228 return dynamic_cast<TGraph*
>(
fMap.find(name)->second);
236 std::vector<TGraph*>
G1Vector(
const std::string& pattern)
const;
243 TGraph2D*
G2(
const std::string& name)
const {
244 if (
fMap.count(name) == 0) {
245 LOG(error) <<
"CbmHistManager::G2(name): name=" << name;
247 assert(
fMap.count(name) != 0);
248 return dynamic_cast<TGraph2D*
>(
fMap.find(name)->second);
256 std::vector<TGraph2D*>
G2Vector(
const std::string& pattern)
const;
263 TProfile*
P1(
const std::string& name)
const {
264 if (
fMap.count(name) == 0) {
265 LOG(error) <<
"CbmHistManager::P1(name): name=" << name;
267 assert(
fMap.count(name) != 0);
268 return dynamic_cast<TProfile*
>(
fMap.find(name)->second);
276 std::vector<TProfile*>
P1Vector(
const std::string& pattern)
const;
283 TProfile2D*
P2(
const std::string& name)
const {
284 if (
fMap.count(name) == 0) {
285 LOG(error) <<
"CbmHistManager::P2(name): name=" << name;
287 assert(
fMap.count(name) != 0);
288 return dynamic_cast<TProfile2D*
>(
fMap.find(name)->second);
296 std::vector<TProfile2D*>
P2Vector(
const std::string& pattern)
const;
303 Bool_t
Exists(
const std::string& name)
const {
304 return (
fMap.count(name) == 0) ? false :
true;
331 void Clear(Option_t*);
362 void Scale(
const std::string& histName, Double_t scale);
388 void Rebin(
const std::string& histName, Int_t ngroup);
422 const std::string& title,
432 const std::string& options =
"png,eps");
438 std::map<std::string, TNamed*>
void Clear(Option_t *)
Clear memory. Remove all histograms.
TProfile * P1(const std::string &name) const
Return pointer to TProfile.
Bool_t Exists(const std::string &name) const
Check existence of histogram in manager.
std::string ToString() const
Return string representation of class.
void WriteToFile()
Write all histograms to current opened file.
void AddTNamedObject(TObject *obj)
Add TName object to map. Used in ReadFromFile method.
void ShrinkEmptyBinsH2ByPattern(const std::string &pattern)
Shrink empty bins in H2.
void ScaleByPattern(const std::string &pattern, Double_t scale)
Scale histograms which name matches specified pattern.
void Create3(const std::string &name, const std::string &title, Int_t nofBinsX, Double_t minBinX, Double_t maxBinX, Int_t nofBinsY, Double_t minBinY, Double_t maxBinY, Int_t nofBinsZ, Double_t minBinZ, Double_t maxBinZ)
Helper function for creation of 3-dimensional histograms and profiles. Template argument is a real ob...
std::map< std::string, TNamed * > fMap
void ReadFromFile(TFile *file)
Read histograms from file.
std::vector< TProfile2D * > P2Vector(const std::string &pattern) const
Return vector of pointers to TProfile2D.
void Create2(const std::string &name, const std::string &title, Int_t nofBinsX, Double_t minBinX, Double_t maxBinX, Int_t nofBinsY, Double_t minBinY, Double_t maxBinY)
Helper function for creation of 2-dimensional histograms and profiles. Template argument is a real ob...
void ShrinkEmptyBinsH1ByPattern(const std::string &pattern)
Shrink empty bins in H1.
void NormalizeToIntegral(const std::string &histName)
Normalize histogram to integral.
TH2 * H2(const std::string &name) const
Return pointer to TH2 histogram.
void RebinByPattern(const std::string &pattern, Int_t ngroup)
Rebin histograms which name matches specified pattern.
friend std::ostream & operator<<(std::ostream &strm, const CbmHistManager &histManager)
Operator << for convenient output to std::ostream.
TGraph * G1(const std::string &name) const
Return pointer to TGraph.
TH3 * H3(const std::string &name) const
Return pointer to TH3 histogram.
void NormalizeToIntegralByPattern(const std::string &pattern)
Normalize histograms to integral which name matches specified pattern.
std::vector< TGraph2D * > G2Vector(const std::string &pattern) const
Return vector of pointers to TGraph2D.
Data class with information on a STS local track.
std::vector< T > ObjectVector(const std::string &pattern) const
void AddTDirectoryObject(TObject *obj)
Add all TName objects to map in directory. Used in ReadFromFile method.
TGraph2D * G2(const std::string &name) const
Return pointer to TGraph2D.
void Create1(const std::string &name, const std::string &title, Int_t nofBins, Double_t minBin, Double_t maxBin)
Helper function for creation of 1-dimensional histograms and profiles. Template argument is a real ob...
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
std::vector< TProfile * > P1Vector(const std::string &pattern) const
Return vector of pointers to TProfile.
std::vector< TCanvas * > fCanvases
CbmHistManager()
Constructor.
TCanvas * CreateCanvas(const std::string &name, const std::string &title, Int_t width, Int_t height)
Create and draw TCanvas and store pointer to it.
void SaveCanvasToImage(const std::string &outputDir, const std::string &options="png,eps")
Save all stored canvases to images.
void ShrinkEmptyBinsH2(const std::string &histName)
Shrink empty bins in H2.
void Rebin(const std::string &histName, Int_t ngroup)
Rebin histogram.
std::vector< TH1 * > H1Vector(const std::string &pattern) const
Return vector of pointers to TH1 histogram.
virtual ~CbmHistManager()
Destructor.
TProfile2D * P2(const std::string &name) const
Return pointer to TH2 histogram.
std::vector< TGraph * > G1Vector(const std::string &pattern) const
Return vector of pointers to TGraph.
std::vector< TH2 * > H2Vector(const std::string &pattern) const
Return vector of pointers to TH2 histogram.
void ShrinkEmptyBinsH1(const std::string &histName)
Shrink empty bins in H1.
void Scale(const std::string &histName, Double_t scale)
Scale histogram.
void Add(const std::string &name, TNamed *object)
Add new named object to manager.