Added commet to explain AliAODTrack::fType, AliAODTrack::XAtDCA(), YAtDCA(), ZAtDCA...
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisAlien.h
CommitLineData
c57f56b7 1#ifndef ALIANALYSISALIEN_H
2#define ALIANALYSISALIEN_H
3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6// Author: Mihaela Gheata, 01/09/2008
7
8//==============================================================================
9// AliAnalysisAlien - AliEn utility class. Provides interface for creating
10// a personalized JDL, finding and creating a dataset.
11//==============================================================================
12
13#ifndef ALIANALYSISGRID_H
14#include "AliAnalysisGrid.h"
15#endif
16
17#ifndef ROOT_TString
18#include <TString.h>
19#endif
20
149d288c 21#ifndef ROOT_TMath
22#include <TMath.h>
23#endif
24
28ce6c9c 25#ifndef ROOT_TMap
26#include <TMap.h>
27#endif
28
105631b5 29class AliAnalysisManager;
77f34eae 30class AliAnalysisTaskCfg;
c57f56b7 31class TGridJDL;
32
33class AliAnalysisAlien : public AliAnalysisGrid {
34
35public:
36
37 AliAnalysisAlien();
38 AliAnalysisAlien(const char *name);
39 virtual ~AliAnalysisAlien();
40 AliAnalysisAlien(const AliAnalysisAlien& other);
41 AliAnalysisAlien& operator=(const AliAnalysisAlien& other);
42// Setters
37d21c01 43 virtual void AddAdditionalLibrary(const char *name);
f965131e 44 virtual void AddIncludePath(const char *path);
c57f56b7 45 virtual void AddRunNumber(Int_t run);
ee75cfc3 46 virtual void AddRunNumber(const char *run);
98690895 47 virtual void AddRunList(const char *runList);
c57f56b7 48 virtual void AddDataFile(const char *lfn);
648174cf 49 virtual void AddExternalPackage(const char *name);
c57f56b7 50 virtual void SetExecutable(const char *name="analysis.sh") {fExecutable = name;}
e6e4d2ff 51 const char *GetExecutable() const {return fExecutable;}
0a1c1f7f 52 virtual void SetExecutableCommand(const char *command="root -b -q") {fExecutableCommand = command;}
e6e4d2ff 53 const char *GetExecutableCommand() const {return fExecutableCommand;}
c57f56b7 54 virtual void SetArguments(const char *name="") {fArguments = name;}
e6e4d2ff 55 const char *GetArguments() const {return fArguments;}
631c0b05 56 virtual void SetExecutableArgs(const char *name="") {fExecutableArgs = name;}
e6e4d2ff 57 const char *GetExecutableArgs() const {return fExecutableArgs;}
c57f56b7 58 virtual void SetAnalysisMacro(const char *name="myAnalysis.C") {fAnalysisMacro = name;}
e6e4d2ff 59 const char *GetAnalysisMacro() const {return fAnalysisMacro;}
c57f56b7 60 virtual void SetAnalysisSource(const char *name="myAnalysisClass.cxx") {fAnalysisSource = name;}
e6e4d2ff 61 const char *GetAnalysisSource() const {return fAnalysisSource;}
d3b18c4c 62 virtual void SetValidationScript(const char *name="validation.sh") {fValidationScript = name;}
e6e4d2ff 63 const char *GetValidationScript() const {return fValidationScript;}
c57f56b7 64 virtual void SetAdditionalLibs(const char *list) {fAdditionalLibs = list;}
e6e4d2ff 65 const char *GetAdditionalLibs() const {return fAdditionalLibs;}
d5c6455a 66 virtual void SetAdditionalRootLibs(const char *list) {fAdditionalRootLibs = list;}
e6e4d2ff 67 const char *GetAdditionalRootLibs() const {return fAdditionalRootLibs;}
c57f56b7 68 virtual void SetPrice(Int_t price=1) {fPrice = price;}
e6e4d2ff 69 Int_t GetPrice() const {return fPrice;}
a8739e8a 70 virtual void SetRunRange(Int_t min, Int_t max) {fRunRange[0] = min; fRunRange[1] = max;}
e6e4d2ff 71 void GetRunRange(Int_t &min, Int_t &max) {min = fRunRange[0]; max = fRunRange[1];}
c6cb3634 72 virtual void SetJobTag(const char *tag="") {fJobTag = tag;}
e6e4d2ff 73 const char *GetJobTag() const {return fJobTag;}
319593fb 74 virtual void SetNrunsPerMaster(Int_t nruns=1) {fNrunsPerMaster = nruns;}
e6e4d2ff 75 Int_t GetNrunsPerMaster() const {return fNrunsPerMaster;}
16a4353c 76 virtual void SetMaxMergeFiles(Int_t nfiles) {fMaxMergeFiles = nfiles;}
e6e4d2ff 77 Int_t GetMaxMergeFiles() const {return fMaxMergeFiles;}
b3e07543 78 virtual void SetMaxMergeStages(Int_t nstages) {fMaxMergeStages = nstages;}
e6e4d2ff 79 Int_t GetMaxMergeStages() const {return fMaxMergeStages;}
c57f56b7 80 virtual void SetSplitMode(const char *type="se") {fSplitMode = type;}
e6e4d2ff 81 const char *GetSplitMode() const {return fSplitMode;}
c57f56b7 82 virtual void SetSplitMaxInputFileNumber(Int_t nfiles=100) {fSplitMaxInputFileNumber = nfiles;}
e6e4d2ff 83 Int_t GetSplitMaxInputFileNumber() const {return fSplitMaxInputFileNumber;}
149d288c 84 virtual void SetAPIVersion(const char *version) {fAPIVersion = version;}
e6e4d2ff 85 const char *GetAPIVersion() const {return fAPIVersion;}
149d288c 86 virtual void SetROOTVersion(const char *version) {fROOTVersion = version;}
e6e4d2ff 87 const char *GetROOTVersion() const {return fROOTVersion;}
149d288c 88 virtual void SetAliROOTVersion(const char *version) {fAliROOTVersion=version;}
e6e4d2ff 89 const char *GetAliROOTVersion() const {return fAliROOTVersion;}
c57f56b7 90 virtual void SetUser(const char *user) {fUser = user;}
e6e4d2ff 91 const char *GetUser() const {return fUser;}
c57f56b7 92 virtual void SetTTL(Int_t ttl=30000) {fTTL = ttl;}
e6e4d2ff 93 Int_t GetTTL() const {return fTTL;}
c57f56b7 94 virtual void SetGridWorkingDir(const char *name="workdir") {fGridWorkingDir = name;}
e6e4d2ff 95 const char *GetGridWorkingDir() const {return fGridWorkingDir;}
c57f56b7 96 virtual void SetGridDataDir(const char *name) {fGridDataDir = name;}
e6e4d2ff 97 const char *GetGridDataDir() const {return fGridDataDir;}
b098b6ab 98 void SetGeneratorLibs(const char *libs) {fGeneratorLibs = libs;}
e6e4d2ff 99 const char *GetGeneratorLibs() const {return fGeneratorLibs;}
c57f56b7 100 virtual void SetDataPattern(const char *pattern="*AliESDs.root") {fDataPattern = pattern;}
e6e4d2ff 101 const char *GetDataPattern() const {return fDataPattern;}
a41b2882 102 virtual void SetFriendChainName(const char *name="", const char *libnames="");
e6e4d2ff 103 const char *GetFriendChainName() const {return fFriendChainName;}
bb885a9e 104 virtual void SetDefaultOutputs(Bool_t flag);
c57f56b7 105 virtual void SetGridOutputDir(const char *name="output") {fGridOutputDir = name;}
e6e4d2ff 106 const char *GetGridOutputDir() const {return fGridOutputDir;}
149d288c 107 virtual void SetOutputArchive(const char *list="log_archive.zip:std*@disk=1 root_archive.zip:*.root@disk=2");
e6e4d2ff 108 const char *GetOutputArchive() const {return fOutputArchive;}
149d288c 109 virtual void SetOutputFiles(const char *list);
e6e4d2ff 110 const char *GetOutputFiles() const {return fOutputFiles;}
cd11251e 111 virtual void SetOutputToRunNo(Int_t mode=1) {fOutputToRunNo = mode;}
e6e4d2ff 112 Int_t GetOutputToRunNoMode() const {return fOutputToRunNo;}
c57f56b7 113 virtual void SetInputFormat(const char *format="xml-single") {fInputFormat = format;}
e6e4d2ff 114 const char *GetInputFormat() const {return fInputFormat;}
c57f56b7 115 virtual void SetMaxInitFailed(Int_t nfail=5) {fMaxInitFailed = nfail;}
e6e4d2ff 116 Int_t GetMaxInitFailed() const {return fMaxInitFailed;}
d3b18c4c 117 virtual void SetTerminateFiles(const char *list) {fTerminateFiles = list;}
e6e4d2ff 118 const char *GetTerminateFiles() const {return fTerminateFiles;}
9afaa53e 119 virtual void SetMergeExcludes(const char *list) {fMergeExcludes = list; fMergeExcludes.ReplaceAll(",", " "); }
e6e4d2ff 120 const char *GetMergeExcludes() const {return fMergeExcludes;}
0f389141 121 virtual void SetMergeViaJDL(Bool_t on=kTRUE) {fMergeViaJDL = on ? 1 : 0;}
e6e4d2ff 122 Bool_t IsMergeViaJDL() const {return fMergeViaJDL;}
f47d5cb4 123 virtual void SetMergeDirName(const char *name) {fMergeDirName = name;}
e6e4d2ff 124 const char *GetMergeDirName() const {return fMergeDirName;}
c57f56b7 125 virtual void SetMasterResubmitThreshold(Int_t percentage) {fMasterResubmitThreshold = percentage;}
e6e4d2ff 126 Int_t GetMasterResubmitThreshold() const {return fMasterResubmitThreshold;}
715da79c 127 void SetMCLoop(Bool_t flag=kTRUE) {fMCLoop = flag;}
bb885a9e 128 virtual void SetNtestFiles(Int_t nfiles) {fNtestFiles = nfiles;}
e6e4d2ff 129 Int_t GetNtestFiles() const {return fNtestFiles;}
149d288c 130 virtual void SetNumberOfReplicas(Int_t ncopies) {fNreplicas = TMath::Min(ncopies,4);}
e6e4d2ff 131 Int_t GetNumberOfReplicas() const {return fNreplicas;}
c57f56b7 132 virtual void SetJDLName(const char *name="analysis.jdl") {fJDLName = name;}
e6e4d2ff 133 const char *GetJDLName() const {return fJDLName;}
a3e84053 134 virtual void SetProductionMode(Int_t mode=1) {fProductionMode = mode;}
e6e4d2ff 135 Int_t GetProductionMode() const {return fProductionMode;}
9afaa53e 136 virtual void SetRegisterExcludes(const char *list) {fRegisterExcludes = list; fRegisterExcludes.ReplaceAll(",", " "); }
e6e4d2ff 137 const char *GetRegisterExcludes() const {return fRegisterExcludes;}
74013535 138 virtual void SetRunPrefix(const char *prefix);
e6e4d2ff 139 const char *GetRunPrefix() const {return fRunPrefix;}
648174cf 140 virtual void SetOutputSingleFolder(const char *folder) {fOutputSingle = folder; fSplitMode="file"; fSplitMaxInputFileNumber=1;}
e6e4d2ff 141 const char *GetOutputSingleFolder() const {return fOutputSingle;}
0f389141 142 virtual void SetFastReadOption(Bool_t on=kTRUE) {fFastReadOption = on ? 1 : 0;}
e6e4d2ff 143 Bool_t IsFastReadOption() const {return fFastReadOption;}
0f389141 144 virtual void SetOverwriteMode(Bool_t on=kTRUE) {fOverwriteMode = on ? 1 : 0;}
e6e4d2ff 145 Bool_t IsOverwriteMode() const {return fOverwriteMode;}
d88e4159 146 virtual void SetDropToShell(Bool_t drop=true) {fDropToShell = drop;}
e6e4d2ff 147 Bool_t IsDropToShell() const {return fDropToShell;}
780ec36d 148 virtual void SetTreeName(const char *name) {fTreeName = name;}
e6e4d2ff 149 const char *GetTreeName() const {return fTreeName;}
c57f56b7 150
e6e4d2ff 151 TGridJDL *GetGridJDL() const {return fGridJDL;}
152 TGridJDL *GetMergingJDL() const {return fMergingJDL;}
715da79c 153 Int_t GetNMCevents() const {return fNMCevents;}
154 Int_t GetNMCjobs() const {return fNMCjobs;}
155 void SetNMCevents(Int_t nevents) {fNMCevents = nevents;}
156 void SetNMCjobs(Int_t njobs) {fNMCjobs = njobs;}
c57f56b7 157//Utilities
77f34eae 158 void AddModule(AliAnalysisTaskCfg *module);
159 void AddModules(TObjArray *list);
3e40fd4c 160 AliAnalysisManager *CreateAnalysisManager(const char *name, const char *filename="");
77f34eae 161 Int_t GetNmodules() const;
162 AliAnalysisTaskCfg *GetModule(const char *name);
163 Bool_t LoadModules();
a41b2882 164 Bool_t LoadFriendLibs() const;
21ca8e59 165 Bool_t GenerateTest(const char *name, const char *modname="");
139fe6ba 166 Bool_t GenerateTrain(const char *name);
c57f56b7 167 virtual Bool_t CreateDataset(const char *pattern);
4a8b667c 168 Int_t CopyLocalDataset(const char *griddir, const char *pattern, Int_t nfiles, const char *output="data.txt", const char *archivefile="", const char *outputdir="data");
c57f56b7 169 virtual Bool_t CreateJDL();
4e5c5506 170 virtual void EnablePackage(const char *package);
923e2ca5 171 static Bool_t DirectoryExists(const char *lfn);
5513444a 172 static Bool_t FileExists(const char *lfn);
a03be957 173 static const char *GetJobStatus(Int_t jobidstart, Int_t lastid, Int_t &nrunning, Int_t &nwaiting, Int_t &nerror, Int_t &ndone);
f790bc1b 174 const char *GetListOfFiles(const char *type);
b3e07543 175 Bool_t CheckMergedFiles(const char *filename, const char *aliendir, Int_t nperchunk, const char *jdl="");
105631b5 176 static AliAnalysisManager *LoadAnalysisManager(const char *fname);
ec5acdce 177 static Bool_t MergeInfo(const char *output, const char *collection);
b3e07543 178 static Bool_t MergeOutput(const char *output, const char *basedir, Int_t nmaxmerge, Int_t stage=0);
c57f56b7 179 virtual Bool_t MergeOutputs();
16a4353c 180 virtual void Print(Option_t *option="") const;
715da79c 181 static Long64_t RunMacroAndExtractLibs(const char* macro, const char *args, TString &libs);
5513444a 182 virtual Bool_t StartAnalysis(Long64_t nentries=123456789, Long64_t firstentry=0);
0f389141 183 static Bool_t SetupPar(const char *package);
a03be957 184 virtual Bool_t Submit();
185 virtual Bool_t SubmitMerging();
7c2cd90a 186 static Int_t SubmitSingleJob(const char *query);
c57f56b7 187 virtual void WriteAnalysisFile();
188 virtual void WriteAnalysisMacro();
0f389141 189 virtual void WriteMergingMacro();
190 virtual void WriteMergeExecutable();
c57f56b7 191 virtual void WriteExecutable();
5513444a 192 virtual Bool_t WriteJDL(Bool_t copy);
193 virtual void WriteProductionFile(const char *filename) const;
0f389141 194 virtual void WriteValidationScript(Bool_t merge=kFALSE);
c57f56b7 195
3bdcb562 196// PROOF mode
197 virtual void SetProofCluster(const char *cluster) {fProofCluster = cluster;}
198 virtual void SetProofDataSet(const char *dataset) {fProofDataSet = dataset;}
e6e4d2ff 199 virtual const char *GetProofDataSet() const {return fProofDataSet;}
28ce6c9c 200 virtual void SetProofParameter(const char *pname, const char *value);
201 const char *GetProofParameter(const char *pname) const;
3bdcb562 202 virtual void SetProofReset(Int_t mode) {fProofReset = mode;}
203 virtual void SetNproofWorkers(Int_t nworkers) {fNproofWorkers = nworkers;}
27734f0e 204 virtual void SetNproofWorkersPerSlave(Int_t nworkers) {fNproofWorkersPerSlave = nworkers;}
874de7ea 205 virtual void SetRootVersionForProof(const char *version);
3bdcb562 206 virtual void SetAliRootMode(const char *mode) {fAliRootMode = mode;}
d88e4159 207 virtual void SetProofProcessOpt(const char *proofOpt="") {fProofProcessOpt = proofOpt;}
208 virtual TString GetProofProcessOpt() {return fProofProcessOpt;}
3bdcb562 209 // .txt file containing the list of files to be chained in test mode
210 virtual void SetFileForTestMode(const char *filename) {fFileForTestMode = filename;}
e6e4d2ff 211 const char *GetFileForTestMode() const {return fFileForTestMode;}
3bdcb562 212 virtual TChain *GetChainForTestMode(const char *treeName) const;
0ad3ea1f 213 virtual const TString& GetGridJobIDs() const { return fGridJobIDs; }
214 virtual const TString& GetGridStages() const { return fGridStages; }
c57f56b7 215protected:
216 void CdWork();
217 Bool_t CheckInputData();
218 void CheckDataType(const char *lfn, Bool_t &is_collection, Bool_t &is_xml, Bool_t &use_tags);
219 virtual Bool_t Connect();
220 virtual void SetDefaults();
a03be957 221 Bool_t SubmitNext();
c57f56b7 222
c57f56b7 223 Bool_t IsCollection(const char *lfn) const;
715da79c 224 Bool_t IsMCLoop() const {return fMCLoop;}
fe2d7fc2 225 virtual Bool_t IsSingleOutput() const;
c57f56b7 226 Bool_t IsUsingTags() const {return TObject::TestBit(AliAnalysisGrid::kUseTags);}
77f34eae 227 Bool_t LoadModule(AliAnalysisTaskCfg *mod);
228 Bool_t CheckDependencies();
b5ae4fe0 229 Bool_t CheckFileCopy(const char *alienpath);
c57f56b7 230
231private:
232 TGridJDL *fGridJDL; //! JDL maker
0f389141 233 TGridJDL *fMergingJDL; //! JDL maker
c57f56b7 234 Int_t fPrice; // Grid price for the job;
235 Int_t fTTL; // Time to live.
236 Int_t fSplitMaxInputFileNumber; // Maximum number of files to be processed per subjob
237 Int_t fMaxInitFailed; // Maximum initial consecutive subjobs accepted to fail
238 Int_t fMasterResubmitThreshold; // Failed jobs will be resubmitted until this DONE ratio
bb885a9e 239 Int_t fNtestFiles; // Number of files used in the testing case
a8739e8a 240 Int_t fRunRange[2]; // Run range
319593fb 241 Int_t fNrunsPerMaster; // Number of runs per masterjob
16a4353c 242 Int_t fMaxMergeFiles; // Maximum number of files to be merged in one chunk
b3e07543 243 Int_t fMaxMergeStages; // Maximum number of merging stages
d2a409b2 244 Int_t fNsubmitted; // Number of jobs submitted
a3e84053 245 Int_t fProductionMode; // Production mode (0-off, 1-on)
cd11251e 246 Int_t fOutputToRunNo; // Use run number as output directory
0f389141 247 Int_t fMergeViaJDL; // Enable merging via automatic JDL
248 Int_t fFastReadOption; // Use xrootd tweaks to reduce timeouts in file access
249 Int_t fOverwriteMode; // Overwrite existing files if any
149d288c 250 Int_t fNreplicas; // Number of replicas for the output files
3bdcb562 251 Int_t fNproofWorkers; // Number of workers in proof mode
27734f0e 252 Int_t fNproofWorkersPerSlave; // Max number of workers per slave in proof mode
3bdcb562 253 Int_t fProofReset; // Proof reset mode: 0=no reset, 1=soft, 2=hard
715da79c 254 Int_t fNMCevents; // Number of MC events in MC loop mode
255 Int_t fNMCjobs; // Number of MC jobs in MC loop mode
c57f56b7 256 TString fRunNumbers; // List of runs to be processed
257 TString fExecutable; // Executable script for AliEn job
0a1c1f7f 258 TString fExecutableCommand; // Command(s) to be executed in the executable script
c57f56b7 259 TString fArguments; // Arguments for the executable script
631c0b05 260 TString fExecutableArgs; // arguments added to the executable script after the analysis macro
c57f56b7 261 TString fAnalysisMacro; // Root macro steering the analysis
262 TString fAnalysisSource; // User analysis implementation (.cxx) file(s)
d3b18c4c 263 TString fValidationScript; // Name of the validation script
d5c6455a 264 TString fAdditionalRootLibs; // List (separated by blacs) of additional libraries needed for/before analysis libs/par file compilation
265 TString fAdditionalLibs; // List (separated by blacs) of additional libraries needed for the analysis loaded AFTER all par files
715da79c 266 TString fGeneratorLibs; // Extra libraries needed by the generator
c57f56b7 267 TString fSplitMode; // Job split mode
268 TString fAPIVersion; // API version
269 TString fROOTVersion; // ROOT version
270 TString fAliROOTVersion; // AliROOT version
648174cf 271 TString fExternalPackages; // External packages
c57f56b7 272 TString fUser; // AliEn user name
273 TString fGridWorkingDir; // AliEn directory containing the input packages
274 TString fGridDataDir; // AliEn data production directory
275 TString fDataPattern; // Data pattern for 'find' command
276 TString fGridOutputDir; // AliEn directory (wrt work dir) where the output should be written
277 TString fOutputArchive; // List of output archives separated by blancs
278 TString fOutputFiles; // List of output files separated by blancs
279 TString fInputFormat; // Input format (xml-single)
280 TString fDatasetName; // Dataset xml file to be created
281 TString fJDLName; // JDL file to be generated
d3b18c4c 282 TString fTerminateFiles; // List of output files produced during Terminate
bb885a9e 283 TString fMergeExcludes; // List of output files excluded from merging
37d21c01 284 TString fRegisterExcludes; // List of liles not to be registered/merged
f965131e 285 TString fIncludePath; // Include path
bb885a9e 286 TString fCloseSE; // Preffered storage element. Taken from alien_CLOSE_SE environment.
0df6ccf2 287 TString fFriendChainName; // File name to construct friend chain (for AOD)
c6cb3634 288 TString fJobTag; // Job tag
648174cf 289 TString fOutputSingle; // Directory name for the output when split is per file
5fce53f4 290 TString fRunPrefix; // Run prefix to be applied to run numbers
3bdcb562 291 TString fProofCluster; // Proof cluster name
292 TString fProofDataSet; // Proof dataset to be used
293 TString fFileForTestMode; // .txt file for the chain to be used in PROOF test mode
3bdcb562 294 TString fAliRootMode; // AliRoot mode among the list supported by the proof cluster
d88e4159 295 TString fProofProcessOpt; // Option passed to proof process
f47d5cb4 296 TString fMergeDirName; // Name of the directory that should be added to the output directory
c57f56b7 297 TObjArray *fInputFiles; // List of input files to be processed by the job
4e5c5506 298 TObjArray *fPackages; // List of packages to be used
77f34eae 299 TObjArray *fModules; // List of AliAnalysisTaskCfg modules
28ce6c9c 300 TMap fProofParam; // Key-value pairs for proof mode
d88e4159 301 Bool_t fDropToShell; // If true, execute aliensh on start
715da79c 302 Bool_t fMCLoop; // MC loop flag
0ad3ea1f 303 TString fGridJobIDs; // List of last committed jobs
304 TString fGridStages; // List of last committed jobs
a41b2882 305 TString fFriendLibs; // List of libs (separated by blacs) needed for friends processing
780ec36d 306 TString fTreeName; // Name of the tree to be analyzed
0ad3ea1f 307
715da79c 308 ClassDef(AliAnalysisAlien, 26) // Class providing some AliEn utilities
c57f56b7 309};
310#endif