CMS 3D CMS Logo

GFOverlay.h
Go to the documentation of this file.
1 #ifndef GFUTILSGFOVERLAY_H
2 #define GFUTILSGFOVERLAY_H
3 
4 #include "TString.h"
5 #include "TObjArray.h"
6 #include <vector>
7 
8 // Author: Gero Flucke
9 // Date: October 2007
10 // last update: $Date: 2012/03/29 08:48:50 $
11 // by: $Author: flucke $
12 //
13 // Class to overlay hists with same names from (several) different files.
14 // Constructor argument 'fileLegendList' is a comma separated list of files
15 // and the legend entry corresponding to it, e.g.
16 // "file1.root=label1,file2.root=label2,..."
17 // Finds recursively all hists in all directories of the first file.
18 // The hists of one directory are grouped in one layer of the GFHistManager.
19 //
20 // Following options are recognised:
21 // 1)
22 // If 'option' contains 'norm', the hists are normalised to their number of entries.
23 // 2)
24 // If 'option' contains 'skip(XYZ)' or 'skipHist(XYZ)', hists are skipped if their names
25 // contain 'XYZ', similarly with 'skip(XYZ)' or 'skipDir(XYZ)' for directories.
26 // Can be given several times.
27 // 3)
28 // If 'option' contains 'name(XYZ)' or 'nameHist(XYZ)', hists are skipped if their names
29 // do NOT contain 'XYZ', similarly with 'name(XYZ)' or 'nameHist(XYZ)' for directories.
30 // Can be given several times.
31 // 4)
32 // If 'option' contains 'sumperdir', for each directory hists created containing
33 // the means and RMS of all (1D-)hists of that directory and puts these in the following
34 // 'layer' of the GFHistManager.
35 //
36 // (Lower and upper case are ignored for 'norm', 'skip', 'name' and 'sumperdir'.)
37 //
38 // CAVEAT:
39 // If you want to skip all hists that contain 'Norm' in their name by option 'skip(Norm)',
40 // this will also lead to the normalisation option being switched on...
41 
42 class TFile;
43 class TDirectory;
44 class GFHistManager;
45 class TH1;
46 
47 class GFOverlay {
48  public:
49  GFOverlay(const char *fileLegendList, Option_t *option = "");
50  ~GFOverlay();
52 
53  private:
54  TObjArray FindAllBetween(const TString &text, const char *startStr, const char *endStr) const;
55  TString FindNextBetween(const TString &input, Ssiz_t startInd,
56  const char *startStr, const char *endStr) const;
57  bool OpenFilesLegends(const char *fileLegendList);
58  void Overlay(const TObjArray &dirs, const TObjArray &legends);
59  bool KeyContainsListMember(const TString &key, const TObjArray &list) const;
60  TObjArray GetTypeWithNameFromDirs(const TClass *aType, const char *name,
61  const TObjArray &dirs) const;
62  Int_t AddHistsAt(const TObjArray &hists, const TObjArray &legends, Int_t layer,Int_t pos);
63  void CreateFillMeanRms(const TObjArray &hists, Int_t layer, const char *dirName,
64  std::vector<TH1*> &meanHists, std::vector<TH1*> &rmsHists) const;
66  Int_t fLayer;
67  TObjArray fFiles;
68  TObjArray fLegends;
69  Bool_t fNormalise;
70  Bool_t fSummaries;
71  TObjArray fDirNames;
72  TObjArray fSkipDirNames;
73  TObjArray fHistNames;
74  TObjArray fSkipHistNames;
75 };
76 
77 #endif
bool KeyContainsListMember(const TString &key, const TObjArray &list) const
TObjArray fHistNames
Definition: GFOverlay.h:73
GFHistManager * GetHistManager()
Definition: GFOverlay.h:51
bool OpenFilesLegends(const char *fileLegendList)
TObjArray fDirNames
Definition: GFOverlay.h:71
TString FindNextBetween(const TString &input, Ssiz_t startInd, const char *startStr, const char *endStr) const
GFOverlay(const char *fileLegendList, Option_t *option="")
GFHistManager * fHistMan
Definition: GFOverlay.h:65
Bool_t fSummaries
Definition: GFOverlay.h:70
void Overlay(const TObjArray &dirs, const TObjArray &legends)
constexpr std::array< uint8_t, layerIndexSize > layer
static std::string const input
Definition: EdmProvDump.cc:47
TObjArray GetTypeWithNameFromDirs(const TClass *aType, const char *name, const TObjArray &dirs) const
void CreateFillMeanRms(const TObjArray &hists, Int_t layer, const char *dirName, std::vector< TH1 *> &meanHists, std::vector< TH1 *> &rmsHists) const
TObjArray fFiles
Definition: GFOverlay.h:67
TObjArray FindAllBetween(const TString &text, const char *startStr, const char *endStr) const
Int_t fLayer
Definition: GFOverlay.h:66
Int_t AddHistsAt(const TObjArray &hists, const TObjArray &legends, Int_t layer, Int_t pos)
TObjArray fSkipHistNames
Definition: GFOverlay.h:74
TObjArray fSkipDirNames
Definition: GFOverlay.h:72
Bool_t fNormalise
Definition: GFOverlay.h:69
TObjArray fLegends
Definition: GFOverlay.h:68