Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:08:31

0001 
0002 #ifndef DQM_SiStripCommissioningClients_SiStripTFile_H
0003 #define DQM_SiStripCommissioningClients_SiStripTFile_H
0004 
0005 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
0006 #include "TFile.h"
0007 #include <vector>
0008 #include <string>
0009 #include <map>
0010 
0011 class TDirectory;
0012 class TH1;
0013 
0014 /** 
0015     @class : SiStripTFile 
0016     @author : M.Wingham 
0017 
0018     @brief : Adds functionality to TFile to ease building and
0019     navigation of TFiles containing DQM histograms.
0020 */
0021 class SiStripTFile : public TFile {
0022 public:
0023   // -------------------- Constructors, destructors, typedefs --------------------
0024 
0025   /** Constructor */
0026   SiStripTFile(const char* fname, Option_t* option = "UPDATE", const char* ftitle = "", Int_t compress = 1);
0027 
0028   /** Destructor */
0029   ~SiStripTFile() override;
0030 
0031   /** */
0032   typedef std::vector<TH1*> Histos;
0033 
0034   /** */
0035   typedef std::map<std::string, Histos> HistosMap;
0036 
0037   // -------------------- Public interface --------------------
0038 
0039   /** Formats the commissioning file with the correct "top-level"
0040       directory structure. Inserts string defining commissioning RunType
0041       in sistrip::root_ directory */
0042   TDirectory* setDQMFormat(sistrip::RunType, sistrip::View);
0043 
0044   /** Checks file complies with DQM format requirements. If so,
0045       updates record directory "top-level" directory structure and of
0046       readout view and commissioning RunType. */
0047   TDirectory* readDQMFormat();
0048 
0049   /** Checks to see if the file complies with DQM format
0050       requirements. */
0051   bool queryDQMFormat();
0052 
0053   /** Returns the "top" directory (describing the readout view) */
0054   TDirectory* top();
0055 
0056   /** Returns the dqm directory */
0057   TDirectory* dqmTop();
0058 
0059   /** Returns the sistrip::root_ directory */
0060   TDirectory* sistripTop();
0061 
0062   /** Get Method */
0063   sistrip::RunType& runType();
0064 
0065   /** Get Method */
0066   sistrip::View& View();
0067 
0068   /** Adds the directory paths for the device of given key. Must use dqmFormat() before this method. */
0069   void addDevice(unsigned int key);
0070 
0071   /** Adds a path to the file. Any directories within the path that already exist are not recreated.*/
0072   TDirectory* addPath(const std::string&);
0073 
0074   /** Finds TH1 histograms, iterating through sub-directories. Fills a map, indexed by the histogram path. */
0075   void findHistos(TDirectory*, std::map<std::string, std::vector<TH1*> >*);
0076 
0077   /** Finds histos and sub-dirs found within given directory. Updates
0078       map with found histos, indexed by dir path. */
0079   void dirContent(TDirectory*, std::vector<TDirectory*>*, std::map<std::string, std::vector<TH1*> >*);
0080 
0081 private:
0082   /** RunType */
0083   sistrip::RunType runType_;
0084 
0085   /** Logical view. */
0086   sistrip::View view_;
0087 
0088   /** Readout view directory */
0089   TDirectory* top_;
0090 
0091   /** dqm directory */
0092   TDirectory* dqmTop_;
0093 
0094   /** sistrip::root_ directory */
0095   TDirectory* sistripTop_;
0096 
0097   /** True if dqmFormat() operation has been performed */
0098   bool dqmFormat_;
0099 };
0100 
0101 #endif  // DQM_SiStripCommissioningClients_SiStripTFile_H