SFrame 3.6
|
00001 // Dear emacs, this is -*- c++ -*- 00002 // $Id: SInputData.h 331 2012-11-20 17:12:44Z 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_SInputData_H 00015 #define SFRAME_CORE_SInputData_H 00016 00017 // STL include(s): 00018 #include <vector> 00019 #include <map> 00020 00021 // ROOT include(s): 00022 #include <TObject.h> 00023 #include <TNamed.h> 00024 00025 // Local include(s): 00026 #include "SGeneratorCut.h" 00027 #include "SLogger.h" 00028 #include "SError.h" 00029 00030 // Forward declaration(s): 00031 class TFileCollection; 00032 class TFileInfo; 00033 class TDirectory; 00034 class TDSet; 00035 00045 class SDataSet : public TObject { 00046 00047 public: 00049 SDataSet( const TString& n = "", Double_t l = 1.0 ) 00050 : name( n ), lumi( l ), events( 0 ) {} 00051 00053 SDataSet& operator= ( const SDataSet& parent ); 00055 Bool_t operator== ( const SDataSet& rh ) const; 00057 Bool_t operator!= ( const SDataSet& rh ) const; 00058 00060 00063 TString name; 00065 00070 Double_t lumi; 00072 00078 Long64_t events; 00079 00080 #ifndef DOXYGEN_IGNORE 00081 ClassDef( SDataSet, 1 ); 00082 #endif // DOXYGEN_IGNORE 00083 00084 }; // class SDataSet 00085 00094 class SFile : public TObject { 00095 00096 public: 00098 SFile() 00099 : file( "" ), lumi( -1 ), events( 0 ){} 00101 SFile( const TString& f ) 00102 : file( f ), lumi( -1 ), events( 0 ){} 00104 SFile( const TString& f, Double_t l ) 00105 : file( f ), lumi( l ), events( 0 ){} 00106 00108 SFile& operator= ( const SFile& parent ); 00110 Bool_t operator== ( const SFile& rh ) const; 00112 Bool_t operator!= ( const SFile& rh ) const; 00113 00115 00118 TString file; 00120 00125 Double_t lumi; 00127 00133 Long64_t events; 00134 00135 #ifndef DOXYGEN_IGNORE 00136 ClassDef( SFile, 1 ); 00137 #endif // DOXYGEN_IGNORE 00138 00139 }; // class SFile 00140 00151 class STree : public TObject { 00152 00153 public: 00155 STree( const TString& name = "", Int_t typ = 0 ) 00156 : treeName( name ), type( typ ) {} 00157 00159 STree& operator= ( const STree& parent ); 00161 Bool_t operator== ( const STree& rh ) const; 00163 Bool_t operator!= ( const STree& rh ) const; 00164 00166 00172 TString treeName; 00173 00174 static const Int_t INPUT_TREE; 00175 static const Int_t OUTPUT_TREE; 00176 static const Int_t EVENT_TREE; 00177 00179 00184 Int_t type; 00185 00186 #ifndef DOXYGEN_IGNORE 00187 ClassDef( STree, 1 ); 00188 #endif // DOXYGEN_IGNORE 00189 00190 }; // class STree 00191 00202 class SInputData : public TNamed { 00203 00204 public: 00206 SInputData( const char* name = "SInputData" ); 00208 virtual ~SInputData(); 00209 00211 void SetType ( const TString& type ) { m_type = type; } 00213 void SetVersion ( const TString& version ) { m_version = version; } 00215 void SetTotalLumi ( Double_t lumi ) { m_totalLumiGiven = lumi; } 00217 void SetNEventsMax ( Long64_t nevents ) { m_neventsmax = nevents; } 00219 void SetNEventsSkip ( Long64_t nevents ) { m_neventsskip = nevents; } 00220 00222 void SetCacheable( Bool_t flag = kTRUE ) { m_cacheable = flag; } 00224 Bool_t GetCacheable() const { return m_cacheable; } 00225 00227 void SetSkipValid( Bool_t flag = kTRUE ) { m_skipValid = flag; } 00229 Bool_t GetSkipValid() const { return m_skipValid; } 00230 00232 void SetEventTreeEntry( Long64_t entry ) { m_entry = entry; } 00234 Long64_t GetEventTreeEntry() const { return m_entry; } 00235 00237 void AddGenCut ( const SGeneratorCut& gencuts ) { m_gencuts.push_back( gencuts ); } 00239 void AddSFileIn( const SFile& sfile ); 00241 void AddTree ( Int_t type, const STree& stree ); 00243 void AddDataSet( const SDataSet& dset ); 00244 00246 void AddEvents ( Long64_t events ) { m_eventsTotal += events; } 00247 00249 void ValidateInput( const char* pserver = 0 ) throw( SError ); 00250 00252 const TString& GetType() const { return m_type; } 00254 const TString& GetVersion() const { return m_version; } 00256 const std::vector< SGeneratorCut >& GetSGeneratorCuts() const { return m_gencuts; } 00258 const std::vector< SFile >& GetSFileIn() const { return m_sfileIn; } 00260 std::vector< SFile >& GetSFileIn() { return m_sfileIn; } 00262 const std::vector< STree >* GetTrees( Int_t type ) const; 00264 const std::map< Int_t, std::vector< STree > >& GetTrees() const { return m_trees; } 00266 const std::vector< SDataSet >& GetDataSets() const { return m_dataSets; } 00267 00269 Bool_t HasInputTrees() const; 00270 00272 TDSet* GetDSet() const; 00273 00275 Double_t GetTotalLumi() const; 00277 Double_t GetScaledLumi() const; 00279 Long64_t GetEventsTotal() const { return m_eventsTotal; } 00281 Long64_t GetNEventsMax() const { return m_neventsmax; } 00283 Long64_t GetNEventsSkip() const { return m_neventsskip; } 00284 00286 SInputData& operator= ( const SInputData& parent ); 00288 Bool_t operator== ( const SInputData& rh ) const; 00290 Bool_t operator!= ( const SInputData& rh ) const; 00291 00293 void Print( const Option_t* opt = 0 ) const; 00294 00296 TString GetStringConfig() const; 00297 00298 private: 00299 void ValidateInputFiles() throw( SError ); 00300 void ValidateInputDataSets( const char* pserver ) throw( SError ); 00301 Bool_t LoadInfoOnFile( std::vector< SFile >::iterator& file_itr, 00302 TFileCollection* filecoll ); 00303 TFileInfo* AccessFileInfo( std::vector< SFile >::iterator& file_itr, 00304 TFileCollection* filecoll ); 00305 TDSet* MakeDataSet() throw( SError ); 00306 TDSet* AccessDataSet( TDirectory* dir ); 00307 00308 TString m_type; 00309 TString m_version; 00310 Double_t m_totalLumiGiven; 00311 std::vector< SGeneratorCut > m_gencuts; 00312 std::vector< SFile > m_sfileIn; 00313 std::map< Int_t, std::vector< STree > > m_trees; 00314 std::vector< SDataSet > m_dataSets; 00315 Double_t m_totalLumiSum; 00316 Long64_t m_eventsTotal; 00317 Long64_t m_neventsmax; 00318 Long64_t m_neventsskip; 00319 Bool_t m_cacheable; 00320 Bool_t m_skipValid; 00321 Long64_t m_entry; 00322 00323 TDSet* m_dset; 00324 00325 mutable SLogger m_logger; 00326 00327 #ifndef DOXYGEN_IGNORE 00328 ClassDef( SInputData, 1 ); 00329 #endif // DOXYGEN_IGNORE 00330 00331 }; // class SInputData 00332 00333 #endif // SFRAME_CORE_SInputData_H