Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:30

0001 #ifndef GFUTILSGFOVERLAY_H
0002 #define GFUTILSGFOVERLAY_H
0003 
0004 #include "TString.h"
0005 #include "TObjArray.h"
0006 #include <vector>
0007 
0008 //   Author:      Gero Flucke
0009 //   Date:        October 2007
0010 //   last update: $Date: 2012/03/29 08:48:50 $  
0011 //   by:          $Author: flucke $
0012 //
0013 // Class to overlay hists with same names from (several) different files.
0014 // Constructor argument 'fileLegendList' is a comma separated list of files 
0015 // and the legend entry corresponding to it, e.g.
0016 // "file1.root=label1,file2.root=label2,..." 
0017 // Finds recursively all hists in all directories of the first file.
0018 // The hists of one directory are grouped in one layer of the GFHistManager.
0019 //
0020 // Following options are recognised:
0021 // 1)
0022 // If 'option' contains 'norm', the hists are normalised to their number of entries.
0023 // 2)
0024 // If 'option' contains 'skip(XYZ)' or 'skipHist(XYZ)', hists are skipped if their names
0025 // contain 'XYZ', similarly with 'skip(XYZ)' or 'skipDir(XYZ)' for directories.
0026 // Can be given several times.
0027 // 3)
0028 // If 'option' contains 'name(XYZ)' or 'nameHist(XYZ)', hists are skipped if their names
0029 // do NOT contain 'XYZ', similarly with 'name(XYZ)' or 'nameHist(XYZ)' for directories.
0030 // Can be given several times.
0031 // 4)
0032 // If 'option' contains 'sumperdir', for each directory hists created containing
0033 // the means and RMS of all (1D-)hists of that directory and puts these in the following
0034 // 'layer' of the GFHistManager.
0035 // 
0036 // (Lower and upper case are ignored for 'norm', 'skip', 'name' and 'sumperdir'.)
0037 //
0038 // CAVEAT:
0039 // If you want to skip all hists that contain 'Norm' in their name by option 'skip(Norm)',
0040 // this will also lead to the normalisation option being switched on...
0041 
0042 class TFile;
0043 class TDirectory;
0044 class GFHistManager;
0045 class TH1;
0046 
0047 class GFOverlay {
0048  public:
0049   GFOverlay(const char *fileLegendList, Option_t *option = "");
0050   ~GFOverlay();
0051   GFHistManager* GetHistManager() { return fHistMan;}
0052 
0053  private:
0054   TObjArray FindAllBetween(const TString &text, const char *startStr, const char *endStr) const;
0055   TString FindNextBetween(const TString &input, Ssiz_t startInd,
0056               const char *startStr, const char *endStr) const;
0057   bool OpenFilesLegends(const char *fileLegendList);
0058   void Overlay(const TObjArray &dirs, const TObjArray &legends);
0059   bool KeyContainsListMember(const TString &key, const TObjArray &list) const;
0060   TObjArray GetTypeWithNameFromDirs(const TClass *aType, const char *name,
0061                     const TObjArray &dirs) const;
0062   Int_t AddHistsAt(const TObjArray &hists, const TObjArray &legends, Int_t layer,Int_t pos);
0063   void CreateFillMeanRms(const TObjArray &hists, Int_t layer, const char *dirName,
0064              std::vector<TH1*> &meanHists, std::vector<TH1*> &rmsHists) const;
0065   GFHistManager *fHistMan;
0066   Int_t          fLayer;
0067   TObjArray      fFiles;
0068   TObjArray      fLegends;
0069   Bool_t         fNormalise;
0070   Bool_t         fSummaries;
0071   TObjArray      fDirNames;
0072   TObjArray      fSkipDirNames;
0073   TObjArray      fHistNames;
0074   TObjArray      fSkipHistNames;
0075 };
0076 
0077 #endif