//  
// Author: Oliver Maria Kind <mailto: kind@mail.desy.de>
// Update: $Id: AtlTask.h,v 1.21 2017/08/08 11:35:16 kaphle Exp $
// Copyright: 2009 (C) Oliver Maria Kind
//
#ifndef ATLAS_AtlTask
#define ATLAS_AtlTask
#include <fstream>
#ifndef ROOT_TTask
#include <TTask.h>
#endif

class TObjString;
class TString;
class TList;
class TSystem;

class AtlTask : public TTask {
    
  protected:
    Bool_t       fInteractiveJob;   // Interactive job execution
    Bool_t       fBatchJob;         // Batch job execution
    Bool_t       fNAFBatchJob;      // NAF Batch job execution
    Bool_t       fGridJob;          // Grid job execution
    Bool_t       fLogFile;          // Write output to logfile
    TList       *fInputFiles;       // Input file names
    TList       *fInputEntryLists;  // Input entry lists file names
    TString     *fOutputFileName;   // Name of the output file
    TNamed      *fOutputTreeName;   // Name and title of the output tree (if any)
    Long64_t     fNEvents;          // No. of events to process
    Long64_t     fFirstEntry;       // Skip FirstEntry-1 events
    Bool_t       fIsTest;           // Is test job ?
    TString     *fJobHome;          // Job working directory
    TString     *fLogFilePath;      // Logfile path
    TString     *fRunScript;        // Runscript path
    Char_t       fNode;             // Node on which to run the jpb
    TString     *fTempOutputPath;   // Temporarily output path (must start with "/")
    TString     *fTempLogFilePath;  // Temporarily logfile path
    TString     *fTempOutputFileName; // Temporarily output file name
    
    Bool_t   fBatchNodeAll;         // Submit batch job to all nodes
    Bool_t   fBatchNodeAutomatic;   // Submit batch job to node automatically set
    TString  fBatchNode;            // Node on which to run the job
    
    TString     *fGridRootVersion;  // Root version for Grid submission
    TString     *fGridCmtVersion;   // Cmt version for Grid submission
    TString     *fGridUserName;     // Grid user name
    TString     *fGridSuffix;       // Suffix for grid dataset names

    Int_t    fDebug;                // Debug flag for derived tasks
    Int_t    fDebugBuild;           // Debug flag for derived tasks (during build)

  public:
    AtlTask(const char*name, const char*title);
    virtual ~AtlTask();
    void AddInputFiles(const char* InputFiles);
    void AddInputEntryLists(const char* InputFile);
    void SetOutputFile(const char* OutputFile);
    void SetTempOutputFile(const char* OutputFile);
    void SetTempOutputPath(const char* OutputPath);
    void SetOutputTree(const char* name, const char* title); // *MENU*    
    virtual void CreateJobHome();
    Char_t GetBatchNodeFromPath(const char* path);
    virtual void Exec(Option_t *option = "");
    virtual void ExecInteractiveJob(Option_t *option) = 0;
    virtual void ExecGridJob(Option_t *option) = 0;
    virtual Bool_t ExecBatchJob(Option_t *option) = 0;
    virtual void ExecNAFBatchJob(Option_t *option) = 0;
    virtual void CreateRunScript(Option_t *option = "") = 0;
    virtual void CreateNAFBatchRunScript() = 0;
    virtual void CreateGridRunScript() = 0;
    void CreateRunScriptPath();
    void CreateLogFilePath();
    void CreateOutFilePath();
    void SetJobHome(const char* JobHome); // *MENU*
    virtual Bool_t WriteEnvSetup(std::ofstream & out) const;
    virtual Bool_t SubmitBatchJob();
    virtual void SubmitGridJob();
    virtual void SubmitNAFBatchJob();
    
    void SetBatchNodeAll(Bool_t BatchNodeAll);             // *TOGGLE*
    void SetBatchNodeAutomatic(Bool_t BatchNodeAutomatic); // *TOGGLE*
    void SetBatchNode(const char* BatchNode);              // *MENU*
    virtual void SetInteractiveJob(Bool_t InteractiveJob); // *TOGGLE*
    virtual void SetBatchJob(Bool_t BatchJob);             // *TOGGLE*
    virtual void SetNAFBatchJob(Bool_t NAFBatchJob);       // *TOGGLE*
    virtual void SetGridJob(Bool_t GridJob);               // *TOGGLE*
    void SetGridRootVersion(const char* RootVersion); // *MENU*
    void SetGridCmtVersion(const char* CmtVersion); // *MENU*
    void SetGridUserName(const char* UserName); // *MENU*
    void SetGridSuffix(const char* suffix); // *MENU*
    
    static void CopyFolder(TDirectory *SrcDir, TDirectory *DestDir, Float_t scale);

    inline Bool_t GetBatchNodeAll()  { return fBatchNodeAll; }
    inline Bool_t GetBatchNodeAutomatic()   { return fBatchNodeAutomatic; }
    inline Bool_t GetInteractiveJob() { return fInteractiveJob; }
    inline Bool_t GetBatchJob()       { return fBatchJob; }
    inline Bool_t GetNAFBatchJob()    { return fNAFBatchJob; }
    inline Bool_t GetGridJob()        { return fGridJob; }
    inline Bool_t GetLogFile() { return fLogFile; }
    inline virtual void ExecuteTask(Option_t *option = "")
	{ TTask::ExecuteTask(option); } // *MENU*
    inline void SetNEvents(Int_t NEvents) { fNEvents = NEvents; } // *MENU*
    inline void SetFirstEntry(Int_t FirstEntry) { fFirstEntry = FirstEntry; } // *MENU*
    inline void SetLogFile(Bool_t LogFile) { fLogFile = LogFile; } // *TOGGLE*

    inline void SetDebug(Int_t level) { fDebug = level; }
    inline void SetDebugBuild(Int_t level) { fDebugBuild = level; }

    ClassDef(AtlTask,0) // Customised analysis task class
};
#endif

 AtlTask.h:1
 AtlTask.h:2
 AtlTask.h:3
 AtlTask.h:4
 AtlTask.h:5
 AtlTask.h:6
 AtlTask.h:7
 AtlTask.h:8
 AtlTask.h:9
 AtlTask.h:10
 AtlTask.h:11
 AtlTask.h:12
 AtlTask.h:13
 AtlTask.h:14
 AtlTask.h:15
 AtlTask.h:16
 AtlTask.h:17
 AtlTask.h:18
 AtlTask.h:19
 AtlTask.h:20
 AtlTask.h:21
 AtlTask.h:22
 AtlTask.h:23
 AtlTask.h:24
 AtlTask.h:25
 AtlTask.h:26
 AtlTask.h:27
 AtlTask.h:28
 AtlTask.h:29
 AtlTask.h:30
 AtlTask.h:31
 AtlTask.h:32
 AtlTask.h:33
 AtlTask.h:34
 AtlTask.h:35
 AtlTask.h:36
 AtlTask.h:37
 AtlTask.h:38
 AtlTask.h:39
 AtlTask.h:40
 AtlTask.h:41
 AtlTask.h:42
 AtlTask.h:43
 AtlTask.h:44
 AtlTask.h:45
 AtlTask.h:46
 AtlTask.h:47
 AtlTask.h:48
 AtlTask.h:49
 AtlTask.h:50
 AtlTask.h:51
 AtlTask.h:52
 AtlTask.h:53
 AtlTask.h:54
 AtlTask.h:55
 AtlTask.h:56
 AtlTask.h:57
 AtlTask.h:58
 AtlTask.h:59
 AtlTask.h:60
 AtlTask.h:61
 AtlTask.h:62
 AtlTask.h:63
 AtlTask.h:64
 AtlTask.h:65
 AtlTask.h:66
 AtlTask.h:67
 AtlTask.h:68
 AtlTask.h:69
 AtlTask.h:70
 AtlTask.h:71
 AtlTask.h:72
 AtlTask.h:73
 AtlTask.h:74
 AtlTask.h:75
 AtlTask.h:76
 AtlTask.h:77
 AtlTask.h:78
 AtlTask.h:79
 AtlTask.h:80
 AtlTask.h:81
 AtlTask.h:82
 AtlTask.h:83
 AtlTask.h:84
 AtlTask.h:85
 AtlTask.h:86
 AtlTask.h:87
 AtlTask.h:88
 AtlTask.h:89
 AtlTask.h:90
 AtlTask.h:91
 AtlTask.h:92
 AtlTask.h:93
 AtlTask.h:94
 AtlTask.h:95
 AtlTask.h:96
 AtlTask.h:97
 AtlTask.h:98
 AtlTask.h:99
 AtlTask.h:100
 AtlTask.h:101
 AtlTask.h:102
 AtlTask.h:103
 AtlTask.h:104
 AtlTask.h:105
 AtlTask.h:106
 AtlTask.h:107
 AtlTask.h:108
 AtlTask.h:109
 AtlTask.h:110
 AtlTask.h:111
 AtlTask.h:112
 AtlTask.h:113
 AtlTask.h:114