Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TSimpleAnalysis.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/treeplayer:$Id$
0002 // Author: Luca Giommi   22/08/16
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2016, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TSimpleAnalysis
0013 #define ROOT_TSimpleAnalysis
0014 
0015 //////////////////////////////////////////////////////////////////////////
0016 //                                                                      //
0017 // TSimpleAnalysis                                                      //
0018 //                                                                      //
0019 // A TSimpleAnalysis object creates histograms from a TChain. These     //
0020 // histograms are stored to an output file. The histogrammed            //
0021 // (TTreeFormula) expressions, their cuts, the input and output files   //
0022 // are configured through a simple config file that allows comments     //
0023 // starting with '#'.                                                   //
0024 //                                                                      //
0025 //////////////////////////////////////////////////////////////////////////
0026 
0027 
0028 #include <string>
0029 #include <fstream>
0030 #include <vector>
0031 #include <map>
0032 
0033 class TSimpleAnalysis {
0034 
0035 private:
0036    std::string              fConfigFile; ///< Name of the configuration file
0037    std::vector<std::string> fInputFiles; ///< .root input files
0038    std::string              fOutputFile; ///< Output file in which are stored the histograms
0039    std::string              fTreeName;   ///< Name of the input tree
0040    std::ifstream            fIn;         ///< Stream for the input file
0041 
0042    /// The map contains in the first part the names of the histograms written in the output file, in the
0043    /// second part the pair of what is shown in the histograms and the cut applied on the variables
0044    std::map<std::string, std::pair<std::string, std::string>> fHists;
0045 
0046    /// The elements of the enumeration refer to the different types of elements
0047    /// that are in the input file
0048    enum EReadingWhat {
0049       kReadingOutput,     ///< Reading the name of the output file
0050       kReadingTreeName,   ///< Reading the name of the tree
0051       kReadingInput,      ///< Reading the name of the .root input files
0052       kReadingExpressions ///< Reading the expressions
0053    };
0054 
0055    std::string HandleExpressionConfig(const std::string& line);
0056    std::string GetLine(int& numbLine);
0057    bool HandleInputFileNameConfig(const std::string& line);
0058    bool SetTreeName();
0059 
0060 
0061 public:
0062    TSimpleAnalysis(const std::string& file): fConfigFile (file) {}
0063    TSimpleAnalysis(const std::string& output, const std::vector<std::string>& inputFiles,
0064                    const std::vector<std::string>& expressions, const std::string& treeName);
0065    bool Run();
0066    bool Configure();
0067 
0068 };
0069 
0070 bool RunSimpleAnalysis(const char* configurationFile);
0071 
0072 #endif