]>
Commit | Line | Data |
---|---|---|
352cd18c | 1 | #if !defined(__CINT__) || defined(__MAKECINT__) |
2 | // ROOT includes | |
3 | #include "TFile.h" | |
4 | #include "TGrid.h" | |
5 | #include "TString.h" | |
6 | #include "TObjArray.h" | |
7 | #include "TObjString.h" | |
8 | #include "TSystem.h" | |
9 | #include "TROOT.h" | |
10 | ||
11 | // Aliroot includes | |
12 | #include "AliAnalysisManager.h" | |
13 | #include "AliAnalysisAlien.h" | |
14 | #include "AliESDInputHandler.h" | |
15 | ||
16 | #define COMPILEMACRO | |
17 | ||
18 | #endif | |
19 | ||
20 | ||
21 | //_____________________________________________________________________________ | |
22 | Int_t GetRunNumber(TString filePath) | |
23 | { | |
24 | TObjArray* array = filePath.Tokenize("/"); | |
25 | array->SetOwner(); | |
26 | TString auxString = ""; | |
27 | Int_t runNum = -1; | |
28 | for ( Int_t ientry=0; ientry<array->GetEntries(); ientry++ ) { | |
29 | auxString = array->At(ientry)->GetName(); | |
30 | if ( auxString.Contains("000") ) { | |
31 | runNum = auxString.Atoi(); | |
32 | break; | |
33 | } | |
34 | } | |
35 | delete array; | |
36 | ||
37 | if ( runNum < 0 ) { | |
38 | array = auxString.Tokenize("_"); | |
39 | array->SetOwner(); | |
40 | auxString = array->Last()->GetName(); | |
41 | auxString.ReplaceAll(".root",""); | |
42 | if ( auxString.IsDigit() ) | |
43 | runNum = auxString.Atoi(); | |
44 | delete array; | |
45 | } | |
46 | ||
47 | return runNum; | |
48 | } | |
49 | ||
50 | //_____________________________________________________________________________ | |
51 | void CopyFile(TString inFilename, TString baseOutDir=".", Bool_t makeRunDir=kTRUE, TString changeFilename="") | |
52 | { | |
53 | if ( inFilename.Contains("alien://") && ! gGrid ) | |
54 | TGrid::Connect("alien://"); | |
55 | ||
56 | TObjArray* array = inFilename.Tokenize("/"); | |
57 | array->SetOwner(); | |
58 | TString outFilename = changeFilename.IsNull() ? array->Last()->GetName() : changeFilename.Data(); | |
59 | delete array; | |
60 | ||
61 | if ( makeRunDir ) { | |
62 | Int_t runNumber = GetRunNumber(inFilename); | |
63 | if ( runNumber >= 0 ) { | |
64 | baseOutDir = Form("%s/%i", baseOutDir.Data(), runNumber); | |
65 | if ( gSystem->AccessPathName(baseOutDir.Data()) ) | |
66 | gSystem->mkdir(baseOutDir.Data()); | |
67 | } | |
68 | else printf("Warning: run number not found!\n"); | |
69 | } | |
70 | //outFilename.ReplaceAll(".root", Form("_%i.root", runNumber)); | |
71 | outFilename.Prepend(Form("%s/", baseOutDir.Data())); | |
72 | Bool_t showProgressBar = ! gROOT->IsBatch(); | |
73 | TFile::Cp(inFilename.Data(), outFilename.Data(), showProgressBar); | |
74 | printf("outDir: %s\n", baseOutDir.Data()); | |
75 | printf("outFile: %s\n", outFilename.Data()); | |
76 | } | |
77 | ||
78 | ||
79 | ||
80 | //_____________________________________________________________________________ | |
81 | AliAnalysisAlien* CreateAlienHandler() | |
82 | { | |
83 | AliAnalysisAlien *plugin = new AliAnalysisAlien(); | |
84 | ||
85 | // Set the run mode | |
86 | plugin->SetRunMode("terminate"); | |
87 | ||
88 | // Declare all libraries | |
89 | plugin->SetAdditionalLibs("libCORRFW.so libPWG3base.so libPWG3muon.so"); | |
90 | ||
91 | plugin->SetAdditionalRootLibs("libXMLParser.so libGui.so libProofPlayer.so"); | |
92 | ||
93 | plugin->AddIncludePath("-I."); | |
94 | plugin->AddIncludePath("-I$ALICE_ROOT/PWG3/base"); | |
95 | plugin->AddIncludePath("-I$ALICE_ROOT/PWG3/muon"); | |
96 | ||
97 | return plugin; | |
98 | } | |
99 | ||
100 | ||
101 | //_____________________________________________________________________________ | |
102 | void terminateQA(TString outfilename = "QAresults.root", Bool_t force = kFALSE) | |
103 | { | |
104 | // | |
105 | // Load common libraries | |
106 | // | |
107 | gSystem->Load("libTree"); | |
108 | gSystem->Load("libGeom"); | |
109 | gSystem->Load("libVMC"); | |
110 | gSystem->Load("libPhysics"); | |
111 | gSystem->Load("libProof"); | |
112 | ||
113 | TString libsList = "libANALYSIS.so libOADB.so libANALYSISalice.so libCORRFW.so libPWG3base.so libPWG3muon.so"; | |
114 | ||
115 | TObjArray* libsArray = libsList.Tokenize(" "); | |
116 | libsArray->SetOwner(); | |
117 | TString currLib = ""; | |
118 | for ( Int_t ilib=0; ilib<libsArray->GetEntries(); ilib++ ) { | |
119 | currLib = libsArray->At(ilib)->GetName(); | |
120 | gSystem->Load(currLib.Data()); | |
121 | } | |
122 | ||
123 | AliAnalysisAlien* alienHandler = CreateAlienHandler(); | |
124 | ||
125 | AliAnalysisManager* mgr = new AliAnalysisManager("testAnalysis"); | |
126 | mgr->SetCommonFileName(outfilename.Data()); | |
127 | mgr->SetGridHandler(alienHandler); | |
128 | ||
129 | // Needed to the manager (but not used in terminate mode) | |
130 | AliESDInputHandler* esdH = new AliESDInputHandler(); | |
131 | esdH->SetReadFriends(kFALSE); | |
132 | mgr->SetInputEventHandler(esdH); | |
133 | ||
134 | #ifndef COMPILEMACRO | |
135 | gROOT->LoadMacro("$ALICE_ROOT/PWG3/muon/AddTaskMuonQA.C"); | |
136 | AliAnalysisTaskMuonQA* muonQATask = AddTaskMuonQA(); | |
137 | ||
138 | gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/AddTaskMTRchamberEfficiency.C"); | |
139 | AliAnalysisTaskTrigChEff* trigChEffTask = AddTaskMTRchamberEfficiency(); | |
140 | #endif | |
141 | ||
142 | // Check if terminate was already performed | |
143 | if ( ! force ) { | |
144 | TObject* paramContainer = mgr->GetParamOutputs()->At(0); | |
145 | if ( paramContainer ) { | |
146 | TFile* file = TFile::Open(outfilename); | |
147 | if ( file->FindObjectAny(paramContainer->GetName() ) ) { | |
148 | printf("\nTerminate was already executed!\n"); | |
149 | printf("Nothing to be done\n"); | |
150 | file->Close(); | |
151 | return; | |
152 | } | |
153 | file->Close(); | |
154 | } | |
155 | } | |
156 | ||
157 | ||
158 | if ( ! mgr->InitAnalysis()) { | |
159 | printf("Fatal: Cannot initialize analysis\n"); | |
160 | return; | |
161 | } | |
162 | mgr->PrintStatus(); | |
163 | mgr->StartAnalysis("grid terminate"); | |
164 | } |