SFrame 3.6
|
00001 // Dear emacs, this is -*- c++ -*- 00002 // $Id: SCycleBaseNTuple.h 283 2011-11-14 18:22:40Z krasznaa $ 00003 /*************************************************************************** 00004 * @Project: SFrame - ROOT-based analysis framework for ATLAS 00005 * @Package: Core 00006 * 00007 * @author Stefan Ask <Stefan.Ask@cern.ch> - Manchester 00008 * @author David Berge <David.Berge@cern.ch> - CERN 00009 * @author Johannes Haller <Johannes.Haller@cern.ch> - Hamburg 00010 * @author A. Krasznahorkay <Attila.Krasznahorkay@cern.ch> - CERN/Debrecen 00011 * 00012 ***************************************************************************/ 00013 00014 #ifndef SFRAME_CORE_SCycleBaseNTuple_H 00015 #define SFRAME_CORE_SCycleBaseNTuple_H 00016 00017 // STL include(s): 00018 #include <vector> 00019 #include <map> 00020 #include <string> 00021 #include <list> 00022 00023 // Local include(s): 00024 #include "ISCycleBaseConfig.h" 00025 #include "ISCycleBaseNTuple.h" 00026 #include "SCycleBaseBase.h" 00027 #include "SError.h" 00028 00029 // Forward declaration(s): 00030 class TTree; 00031 class TFile; 00032 class TBranch; 00033 class SInputData; 00034 00047 class SCycleBaseNTuple : public virtual ISCycleBaseConfig, 00048 public virtual ISCycleBaseNTuple, 00049 public virtual SCycleBaseBase { 00050 00051 public: 00053 SCycleBaseNTuple(); 00055 virtual ~SCycleBaseNTuple(); 00056 00058 virtual void SetNTupleOutput( TList* output ); 00060 virtual TList* GetNTupleOutput() const; 00061 00063 template< typename T > 00064 bool ConnectVariable( const char* treeName, const char* branchName, 00065 T& variable ) throw ( SError ); 00067 template< typename T, size_t size > 00068 bool ConnectVariable( const char* treeName, const char* branchName, 00069 T ( &variable )[ size ] ) throw( SError ); 00071 template< typename T > 00072 bool ConnectVariable( const char* treeName, const char* branchName, 00073 T*& variable ) throw( SError ); 00074 00076 template< class T > 00077 TBranch* DeclareVariable( T& obj, const char* name, 00078 const char* treeName = 0 ) throw( SError ); 00079 00081 virtual TTree* GetMetadataTree( const char* name ) const throw( SError ); 00083 virtual TTree* GetInputMetadataTree( const char* name ) const throw( SError ); 00085 virtual TTree* GetOutputMetadataTree( const char* name ) const throw( SError ); 00087 virtual TTree* GetInputTree( const char* treeName ) const throw( SError ); 00089 virtual TTree* GetOutputTree( const char* treeName ) const throw( SError ); 00090 00091 protected: 00093 // // 00094 // Functions called by the framework: // 00095 // // 00097 00099 void CreateOutputTrees( const SInputData& id, 00100 std::vector< TTree* >& outTrees, 00101 TFile* outputFile = 0 ) throw( SError ); 00103 void SaveOutputTrees( TDirectory* output ) throw( SError ); 00105 void LoadInputTrees( const SInputData& id, TTree* main_tree, 00106 TFile*& inputFile ) throw( SError ); 00108 void GetEvent( Long64_t entry ) throw( SError ); 00110 Double_t CalculateWeight( const SInputData& inputData, Long64_t entry ); 00112 void ClearCachedTrees(); 00113 00114 private: 00115 static const char* RootType( const char* typeid_type ) throw( SError ); 00116 static const char* TypeidType( const char* root_type ) throw( SError ); 00117 void RegisterInputBranch( TBranch* br ) throw( SError ); 00118 void DeleteInputVariables(); 00119 TDirectory* MakeSubDirectory( const TString& path, TDirectory* dir ) const throw( SError ); 00120 00121 // 00122 // These are the objects used to handle the input and output data: 00123 // 00124 std::vector< TTree* > m_inputTrees; // List of input TTree pointers 00125 std::vector< TBranch* > m_inputBranches; // vector of input branch pointers 00126 // registered for the current cycle 00127 std::list< TObject* > m_inputVarPointers; // Pointers storing the input objects 00128 // created by ConnectVariable(...) 00129 00131 std::vector< TTree* > m_outputTrees; 00133 std::vector< TTree* > m_metaInputTrees; 00135 std::vector< TTree* > m_metaOutputTrees; 00136 00137 // We have to keep the pointers to the output variables defined by the user. 00138 // ROOT keeps track of the objects by storing pointers to pointers to the 00139 // objects. Since the user probably wants to use the output objects directly 00140 // and not through pointers, the base class has to take care of this 00141 // pointer issue by itself... 00142 std::list< void* > m_outputVarPointers; 00143 00144 TList* m_output; 00145 00146 #ifndef DOXYGEN_IGNORE 00147 ClassDef( SCycleBaseNTuple, 0 ); 00148 #endif // DOXYGEN_IGNORE 00149 00150 }; // class SCycleBaseNTuple 00151 00152 // Don't include the templated function(s) when we're generating 00153 // a dictionary: 00154 #ifndef __CINT__ 00155 #include "SCycleBaseNTuple.icc" 00156 #endif 00157 00158 #endif // SFRAME_CORE_SCycleBaseNTuple_H