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