Updated ITS alignment data filter (run with alien plugin)
[u/mrichter/AliRoot.git] / PWG1 / macros / RunAnalysisITS.C
CommitLineData
76bd0732 1class AliAnalysisGrid;
2
3void RunAnalysisITS() {
4 //
5 // Macro to analyze ESDs from raw data reconstruction
6 // A.Dainese, andrea.dainese@pd.infn.it
7 //
8
9 gSystem->SetIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TPC -I$ALICE_ROOT/CONTAINERS -I$ALICE_ROOT/STEER -I$ALICE_ROOT/TRD -I$ALICE_ROOT/macros -I$ALICE_ROOT/ANALYSIS -g");
10
11 //
12 TString analysisMode = "grid"; // "local", "grid", or "proof" (not yet)
13
14 Long64_t nentries=1000000000000000,firstentry=0;
15 Bool_t useAlienPlugin=kTRUE;
16 TString pluginmode="full";
17 TString loadMacroPath="./";
18 Bool_t readHLT=kFALSE;
19 //
20
21 if(analysisMode=="grid") {
22 // Connect to AliEn
23 TGrid::Connect("alien://");
24 } else if(analysisMode=="proof") {
25 // Connect to the PROOF cluster
26 printf("PROOF mode not yet functional..\n");
27 return;
28 TProof::Open("alicecaf");
29 //TProof::Reset("alicecaf");
30 }
31
32 // Load analysis libraries
33 gSystem->Load("libANALYSIS.so");
34 gSystem->Load("libANALYSISalice.so");
35
36 // Create Alien plugin, if requested
37 if(useAlienPlugin) {
38 AliAnalysisGrid *alienHandler = CreateAlienHandler(pluginmode);
39 if(!alienHandler) return;
40 }
41
42 TChain *chainESD = 0;
43 if(!useAlienPlugin) {
44 // Prepare input chain
45 chainESD = CreateESDChain("/home/dainesea/alignData/RAWdata_CosmicsSum09/RecoSPD/chunk.",13,13);
46 }
47
48 // Create the analysis manager
49 AliAnalysisManager *mgr = new AliAnalysisManager("My Manager","My Manager");
50 // Enable debug printouts
51 mgr->SetDebugLevel(10);
52 // Connect plug-in to the analysis manager
53 if(useAlienPlugin) mgr->SetGridHandler(alienHandler);
54
55 // Add ESD handler
56 AliESDInputHandler *esdH = new AliESDInputHandler();
57 if(readHLT) esdH->SetReadHLT();
58 mgr->SetInputEventHandler(esdH);
59 //-------------------------------------------------------------------
60
61
62 //-------------------------------------------------------------------
63 // Analysis tasks (wagons of the train)
64 //
65 TString taskName;
66
67 gROOT->LoadMacro("AliAlignmentDataFilterITS.cxx++g");
68 taskName="AddTaskAlignmentDataFilterITS.C";
69 taskName.Prepend(loadMacroPath.Data());
70 gROOT->LoadMacro(taskName.Data());
71 AliAlignmentDataFilterITS *itsTask = AddTaskAlignmentDataFilterITS();
72 /*
73 gROOT->LoadMacro("AliTrackMatchingTPCITSCosmics.cxx++g");
74 taskName="AddTaskTrackMatchingTPCITS.C";
75 taskName.Prepend(loadMacroPath.Data());
76 gROOT->LoadMacro(taskName.Data());
77 AliTrackMatchingTPCITSCosmics *tpcitsTask = AddTaskTrackMatchingTPCITS();
78 if(readHLT) tpcitsTask->SetReadHLTESD(kTRUE);
79 */
80 //
81 // Run the analysis
82 //
83 if(chainESD) printf("CHAIN HAS %d ENTRIES\n",(Int_t)chainESD->GetEntries());
84
85 if(!mgr->InitAnalysis()) return;
86 mgr->PrintStatus();
87 if(analysisMode=="grid" && !useAlienPlugin) analysisMode="local";
88 mgr->StartAnalysis(analysisMode.Data(),chainESD,nentries,firstentry);
89
90 return;
91}
92//_____________________________________________________________________________
93//
94AliAnalysisGrid* CreateAlienHandler(TString pluginmode="test")
95{
96 // Check if user has a valid token, otherwise make one. This has limitations.
97 // One can always follow the standard procedure of calling alien-token-init then
98 // source /tmp/gclient_env_$UID in the current shell.
99 if (!AliAnalysisGrid::CreateToken()) return NULL;
100 AliAnalysisAlien *plugin = new AliAnalysisAlien();
101 // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
102 plugin->SetRunMode(pluginmode.Data());
103 plugin->SetUser("dainesea");
104 plugin->SetNtestFiles(1);
105 // Set versions of used packages
106 plugin->SetAPIVersion("V2.4");
107 plugin->SetROOTVersion("v5-24-00");
108 plugin->SetAliROOTVersion("v4-18-06-AN");
109 // Declare input data to be processed.
110 // Method 1: Create automatically XML collections using alien 'find' command.
111 // Define production directory LFN
112 //plugin->SetGridDataDir("/alice/data/2009/LHC09c/000080015/ESDs/");
113 //plugin->SetGridDataDir("/alice/cern.ch/user/s/sitta/output/000088361/");
114 // Set data search pattern
115 //plugin->SetDataPattern("AliESDs.root");
116 //plugin->SetDataPattern("ESD.tag.root");
117 // Method 2: Declare existing data files (raw collections, xml collections, root file)
118 // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
119 // XML collections added via this method can be combined with the first method if
120 // the content is compatible (using or not tags)
121 // e.g.: find -z -x 80015 /alice/data/2009/LHC09c/000080015/ESDs/ ESD.tag.root > 80015.xml
122 //plugin->AddDataFile("79876.xml");
123 plugin->AddDataFile("80015.xml");
124 //plugin->AddDataFile("80261.xml");
125 // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
126 // Define alien work directory where all files will be copied. Relative to alien $HOME.
127 plugin->SetGridWorkingDir("analysisITS");
128 // Declare alien output directory. Relative to working directory.
129 plugin->SetGridOutputDir("output"); // In this case will be $HOME/work/output
130 // Declare the analysis source files names separated by blancs. To be compiled runtime
131 // using ACLiC on the worker nodes.
132 plugin->SetAnalysisSource("AliAlignmentDataFilterITS.cxx");
133 //plugin->SetAnalysisSource("AliTrackMatchingTPCITSCosmics.cxx");
134 // Declare all libraries (other than the default ones for the framework. These will be
135 // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
136 //plugin->SetAdditionalLibs("AliAlignmentDataFilterITS.h AliAlignmentDataFilterITS.cxx libProof.so libRAWDatabase.so libRAWDatarec.so libCDB.so libSTEER.so libITSbase.so libITSrec.so");
137 plugin->SetAdditionalLibs("AliAlignmentDataFilterITS.h AliAlignmentDataFilterITS.cxx AliTrackMatchingTPCITSCosmics.h AliTrackMatchingTPCITSCosmics.cxx libProof.so libRAWDatabase.so libRAWDatarec.so libCDB.so libSTEER.so libITSbase.so libITSrec.so");
138 plugin->AddIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TPC -I$ALICE_ROOT/CONTAINERS -I$ALICE_ROOT/STEER -I$ALICE_ROOT/TRD -I$ALICE_ROOT/macros -I$ALICE_ROOT/ANALYSIS -g");
139 // Declare the output file names separated by blancs.
140 // (can be like: file.root or file.root@ALICE::Niham::File)
141 plugin->SetDefaultOutputs(kTRUE);
142 // Optionally define the files to be archived.
143 // plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:*.root@ALICE::NIHAM::File");
144 plugin->SetOutputArchive("log_archive.zip:stdout,stderr");
145 // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
146 plugin->SetAnalysisMacro("AnalysisITS.C");
147 // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
148 plugin->SetSplitMaxInputFileNumber(10);
149 // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
150 //plugin->SetMaxInitFailed(5);
151 // Optionally resubmit threshold.
152 //plugin->SetMasterResubmitThreshold(90);
153 // Optionally set time to live (default 30000 sec)
154 //plugin->SetTTL(20000);
155 // Optionally set input format (default xml-single)
156 plugin->SetInputFormat("xml-single");
157 // Optionally modify the name of the generated JDL (default analysis.jdl)
158 plugin->SetJDLName("TaskAnalysisITS.jdl");
159 // Optionally modify job price (default 1)
160 //plugin->SetPrice(1);
161 // Optionally modify split mode (default 'se')
162 plugin->SetSplitMode("se");
163 // Optionally set the preferred SE
164 plugin->SetPreferedSE("ALICE::CNAF::SE");
165
166 return plugin;
167}
168//-----------------------------------------------------------------------------
169TChain *CreateESDChain(TString esdpath=".",Int_t ifirst=-1,Int_t ilast=-1) {
170
171
172 TChain *chainESD = new TChain("esdTree");
173
174 if(ifirst<0) {
175 chainESD->Add("AliESDs.root");
176 } else {
177 for(Int_t i=ifirst; i<=ilast; i++) {
178 TString esdfile=esdpath; esdfile+=i; esdfile.Append("/AliESDs.root");
179 chainESD->Add(esdfile.Data());
180 }
181 }
182
183 return chainESD;
184}