]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGPP/macros/runAnalysisTaskITSTPCalignment.C
dont process if detector container not present in the qa file to avoid overwriting...
[u/mrichter/AliRoot.git] / PWGPP / macros / runAnalysisTaskITSTPCalignment.C
1 void runAnalysisTaskITSTPCalignment()
2 {
3   TStopwatch timer;
4   timer.Start();
5
6   //runProof("/ITS/dainesea/run104070#esdTree");
7   //runProof("/ITS/dainesea/run104070_newTPCalign#esdTree");
8   //runProof("/ALIREC/aliprod/run104671#esdTree");
9   //runProof("/ITS/dainesea/run104070_newTPCcalib#esdTree");
10   //runProof("/COMMON/COMMON/LHC09d9a_0.9TeV_0.5T#esdTree");
11   //runLocal("find /data/alice3/mikolaj/runs_pp/pass1/ -name AliESDs.root","tree");
12   //runLocal("find /data/alice3/mikolaj/ITSmisal -path */0.001/* -name AliESDs.root","tree");
13   //runLocal("find /data/alice3/mikolaj/TPCfullmisalignmentB0 -name AliESDs.root","tree");
14   //runLocal("find /data/alice3/mikolaj/TPCfullmisalignmentB5/ -name AliESDs.root -path \"*187824*\" ","tree");
15   //runLocal("find /data/alice3/mikolaj/TPCfullmisalignmentB5/ -name AliESDs.root","tree");
16   runLocal("fileList");
17   //runAlienPlugin("terminate");
18
19   timer.Stop();
20   timer.Print();
21 }
22
23 //______________________________________________________________________________
24 void runLocal(TString inputFile = "fileList", TString options="")
25 {
26
27   TString outputFilename = "outputITSTPCalignment.root";
28
29   gSystem->Load("libCore");
30   gSystem->Load("libTree");
31   gSystem->Load("libGeom");
32   gSystem->Load("libVMC");
33   gSystem->Load("libXMLIO");
34   gSystem->Load("libPhysics");
35   gSystem->Load("libXMLParser");
36   gSystem->Load("libProof");
37   gSystem->Load("libMinuit");
38   gSystem->Load("libSTEERBase");
39   gSystem->Load("libCDB");
40   gSystem->Load("libRAWDatabase");
41   gSystem->Load("libRAWDatarec");
42   gSystem->Load("libESD");
43   gSystem->Load("libAOD");
44   gSystem->Load("libSTEER");
45   gSystem->Load("libANALYSIS");
46   gSystem->Load("libANALYSISalice");
47   gSystem->Load("libSTAT");
48   gSystem->Load("libTPCbase");
49   gSystem->Load("libTPCrec");
50   gSystem->Load("libITSbase");
51   gSystem->Load("libITSrec");
52   gSystem->Load("libTRDbase");
53   gSystem->Load("libTRDrec");
54   gSystem->Load("libVZERObase");
55   gSystem->Load("libVZEROrec");
56   gSystem->Load("libHMPIDbase");
57   gSystem->Load("libTENDER");
58   gSystem->Load("libTENDERSupplies");
59   gSystem->Load("libPWGPP");
60
61   gSystem->AddIncludePath("-I$ALICE_ROOT/include");
62   //gROOT->LoadMacro("AliRelAlignerKalman.cxx++");
63   //gROOT->LoadMacro("AliRelAlignerKalmanArray.cxx++g");
64   //gROOT->LoadMacro("AliAnalysisTaskITSTPCalignment.cxx++g");
65   gROOT->LoadMacro("AddTaskITSTPCalignment.C");
66
67   gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
68   TChain* chain = CreateESDChain(inputFile,100000);
69
70   // analysis manager
71   AliAnalysisManager *mgr = new AliAnalysisManager("ITSTPCalignmentAnalysisManager");
72
73   // input handlers
74   AliESDInputHandler* esdH = new AliESDInputHandler();
75   esdH->SetReadFriends(kTRUE);
76   esdH->SetInactiveBranches("Calo FMD");
77   mgr->SetInputEventHandler(esdH);
78   
79   //AliMCEventHandler* MCH = new AliMCEventHandler();
80   //mgr->SetMCtruthEventHandler(MCH);
81
82   //add the task
83   AliAnalysisTaskITSTPCalignment *task = AddTaskITSTPCalignment();
84
85   //start analysis
86   if (!mgr->InitAnalysis()) return;
87   mgr->PrintStatus();
88
89   mgr->StartAnalysis("local",chain);
90 }
91
92 //______________________________________________________________________________
93 void runProof(const char* dataset, TString options="" )
94 {
95
96   TString outputFilename = "outputITSTPCalignment.root";
97
98   printf("****** Connect to PROOF *******\n");
99   gEnv->SetValue("XSec.GSI.DelegProxy","2");
100   TProof::Open("mkrzewic@alicecaf.cern.ch");
101   //gProof->SetParallel();
102   gProof->ClearPackages();
103
104   // Enable the Analysis Package
105   gProof->UploadPackage("STEERBase.par");
106   gProof->EnablePackage("STEERBase");
107   gProof->UploadPackage("ESD.par");
108   gProof->EnablePackage("ESD");
109   gProof->UploadPackage("AOD.par");
110   gProof->EnablePackage("AOD");
111   gProof->UploadPackage("ANALYSIS.par");
112   gProof->EnablePackage("ANALYSIS");
113   gProof->UploadPackage("ANALYSISalice.par");
114   gProof->EnablePackage("ANALYSISalice");
115   gProof->UploadPackage("CORRFW.par");
116   gProof->EnablePackage("CORRFW");
117
118   //gProof->UploadPackage("/afs/cern.ch/alice/caf/sw/ALICE/PARs/v4-18-12-AN/AF-v4-18-12-AN");
119   //gProof->EnablePackage("/afs/cern.ch/alice/caf/sw/ALICE/PARs/v4-18-12-AN/AF-v4-18-12-AN");
120
121   gProof->Load("AliRelAlignerKalman.cxx++g");
122   gProof->Load("AliRelAlignerKalmanArray.cxx++g");
123   gProof->Load("AliAnalysisTaskITSTPCalignment.cxx++g");
124   gProof->Load("AddTaskITSTPCalignment.C");
125
126   // analysis manager
127   AliAnalysisManager *mgr = new AliAnalysisManager("ITSTPCalignmentAnalysisManager");
128
129   // input handlers
130   AliVEventHandler* esdH = new AliESDInputHandler();
131   ((AliESDInputHandler*)esdH)->SetReadFriends(kTRUE);
132   mgr->SetInputEventHandler(esdH);
133
134   //add the task
135   AliAnalysisTaskITSTPCalignment *task = AddTaskITSTPCalignment();
136
137   //start analysis
138   if (!mgr->InitAnalysis()) return;
139   mgr->PrintStatus();
140
141   mgr->StartAnalysis("proof",dataset,10000,0);
142 }
143
144 //______________________________________________________________________________
145 void runAlienPlugin(const char* pluginmode="full")
146 {
147   //must be configured in CreateAlienHandler.C file
148
149   TString outputFilename = "outputITSTPCalignment.root";
150
151   // Load common libraries
152   gSystem->Load("libCore");
153   gSystem->Load("libTree");
154   gSystem->Load("libGeom");
155   gSystem->Load("libVMC");
156   gSystem->Load("libXMLIO");
157   gSystem->Load("libPhysics");
158   gSystem->Load("libXMLParser");
159   gSystem->Load("libProof");
160   gSystem->Load("libMinuit");
161   gSystem->Load("libSTEERBase");
162   gSystem->Load("libCDB");
163   gSystem->Load("libRAWDatabase");
164   gSystem->Load("libRAWDatarec");
165   gSystem->Load("libESD");
166   gSystem->Load("libAOD");
167   gSystem->Load("libSTEER");
168   gSystem->Load("libANALYSIS");
169   gSystem->Load("libANALYSISalice");
170   gSystem->Load("libSTAT");
171   gSystem->Load("libTPCbase");
172   gSystem->Load("libTPCrec");
173   gSystem->Load("libITSbase");
174   gSystem->Load("libITSrec");
175   gSystem->Load("libTRDbase");
176   gSystem->Load("libTRDrec");
177   gSystem->Load("libVZERObase");
178   gSystem->Load("libVZEROrec");
179   gSystem->Load("libHMPIDbase");
180   gSystem->Load("libTENDER");
181   gSystem->Load("libTENDERSupplies");
182   gSystem->Load("libPWGPP");
183
184   // Use AliRoot includes to compile our task
185   gSystem->AddIncludePath("-I$ALICE_ROOT/include");
186
187   /////////////////////////////////////////////////////////////////////////////////////////////
188   /////////////////////////////////////////////////////////////////////////////////////////////
189   /////////////////////////////////////////////////////////////////////////////////////////////
190   // Create and configure the alien handler plugin
191   // Check if user has a valid token, otherwise make one. This has limitations.
192   // One can always follow the standard procedure of calling alien-token-init then
193   //   source /tmp/gclient_env_$UID in the current shell.
194   if (!AliAnalysisGrid::CreateToken()) return NULL;
195   AliAnalysisAlien *plugin = new AliAnalysisAlien();
196   // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
197   plugin->SetRunMode(pluginmode);
198   // Set versions of used packages
199   plugin->SetAPIVersion("V1.1x");
200   plugin->SetROOTVersion("v5-26-00b-4");
201   plugin->SetAliROOTVersion("v4-19-11-AN");
202   // Declare input data to be processed.
203   // Method 1: Create automatically XML collections using alien 'find' command.
204   // Define production directory LFN
205   plugin->SetGridDataDir("/alice/data/2010/LHC10b");
206   // Set data search pattern
207   plugin->SetDataPattern("*/pass1/*AliESDs.root");
208   // ...then add run numbers to be considered
209   plugin->SetRunPrefix("000");
210   plugin->AddRunNumber(117222);
211   plugin->AddRunNumber(117220);
212   plugin->AddRunNumber(117112);
213   plugin->AddRunNumber(117099);
214   plugin->AddRunNumber(117048);
215   plugin->AddRunNumber(117048);
216   plugin->AddRunNumber(116288);
217   plugin->AddRunNumber(115322);
218   plugin->AddRunNumber(114931);
219   //plugin->AddRunNumber(117051);
220   //plugin->SetRunRange(117029,117121);
221   // Method 2: Declare existing data files (raw collections, xml collections, root file)
222   // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
223   // XML collections added via this method can be combined with the first method if
224   // the content is compatible (using or not tags)
225   //   plugin->AddDataFile("/alice/cern.ch/user/m/mkrzewic/pp2009pass2.xml");
226   //   plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
227   // Define alien work directory where all files will be copied. Relative to alien $HOME.
228   plugin->SetGridWorkingDir("analysisGridLHC10bPass1_3runs");
229   // Declare alien output directory. Relative to working directory.
230   plugin->SetGridOutputDir("output"); // In this case will be $HOME/work/output
231   // Declare the analysis source files names separated by blancs. To be compiled runtime
232   // using ACLiC on the worker nodes.
233   plugin->SetAnalysisSource("AliRelAlignerKalman.cxx AliRelAlignerKalmanArray.cxx AliAnalysisTaskITSTPCalignment.cxx");
234   // Declare all libraries (other than the default ones for the framework. These will be
235   // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
236   plugin->SetAdditionalLibs("AliRelAlignerKalman.h AliRelAlignerKalman.cxx AliRelAlignerKalmanArray.h AliRelAlignerKalmanArray.cxx AliAnalysisTaskITSTPCalignment.h AliAnalysisTaskITSTPCalignment.cxx");// AddTaskITSTPCalignment.C");
237   // Declare the output file names separated by blancs.
238   // (can be like: file.root or file.root@ALICE::Niham::File)
239   plugin->SetOutputFiles("outputITSTPCalignment.root");
240   // Optionally define the files to be archived.
241   //   plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:*.root@ALICE::NIHAM::File");
242   plugin->SetOutputArchive("log_archive.zip:stdout,stderr");
243   // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
244   plugin->SetAnalysisMacro("AnalysisITSTPCalignmentGenerated.C");
245   // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
246   plugin->SetSplitMaxInputFileNumber(20);
247   // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
248   plugin->SetMaxInitFailed(5);
249   // Optionally resubmit threshold.
250   plugin->SetMasterResubmitThreshold(90);
251   // Optionally set time to live (default 30000 sec)
252   plugin->SetTTL(100000);
253   // Optionally set input format (default xml-single)
254   plugin->SetInputFormat("xml-single");
255   // Optionally modify the name of the generated JDL (default analysis.jdl)
256   plugin->SetJDLName("taskITSTPCalignment.jdl");
257   // Optionally modify job price (default 1)
258   plugin->SetPrice(1);
259   // Optionally modify split mode (default 'se')
260   plugin->SetSplitMode("se");
261   /////////////////////////////////////////////////////////////////////////////////////////////
262   /////////////////////////////////////////////////////////////////////////////////////////////
263   /////////////////////////////////////////////////////////////////////////////////////////////
264
265   // analysis manager
266   AliAnalysisManager *mgr = new AliAnalysisManager("ITSTPCalignmentAnalysisManager");
267
268   // input handlers
269   mgr->SetGridHandler(plugin);
270
271   //input handler
272   AliESDInputHandler* esdH = new AliESDInputHandler();
273   esdH->SetInactiveBranches("Calo FMD");
274   esdH->SetReadFriends(kTRUE);
275   mgr->SetInputEventHandler(esdH);
276
277   gROOT->LoadMacro("AddTaskITSTPCalignment.C");
278
279   //add the task
280   AliAnalysisTaskITSTPCalignment *task = AddTaskITSTPCalignment();
281
282   //mgr->SetDebugLevel(2);
283
284   if (!mgr->InitAnalysis()) return;
285   mgr->PrintStatus();
286   mgr->StartAnalysis("grid");
287 }
288
289 //______________________________________________________________________________
290 Int_t setupPar(const char* pararchivename)
291 {
292   ///////////////////
293   // Setup PAR File//
294   ///////////////////
295   if (pararchivename)
296   {
297     char processline[1024];
298     sprintf(processline,".! tar xvzf %s.par",pararchivename);
299     gROOT->ProcessLine(processline);
300     const char* ocwd = gSystem->WorkingDirectory();
301     gSystem->ChangeDirectory(pararchivename);
302
303     // check for BUILD.sh and execute
304     if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh"))
305     {
306       printf("*******************************\n");
307       printf("*** Building PAR archive    ***\n");
308       printf("*******************************\n");
309
310       if (gSystem->Exec("PROOF-INF/BUILD.sh"))
311       {
312         Error("runAnalysis","Cannot Build the PAR Archive! - Abort!");
313         return -1;
314       }
315     }
316     // check for SETUP.C and execute
317     if (!gSystem->AccessPathName("PROOF-INF/SETUP.C"))
318     {
319       printf("*******************************\n");
320       printf("*** Setup PAR archive       ***\n");
321       printf("*******************************\n");
322       gROOT->Macro("PROOF-INF/SETUP.C");
323     }
324
325     gSystem->ChangeDirectory("../");
326   }
327   return 1;
328 }
329
330