]>
Commit | Line | Data |
---|---|---|
9c42dfd2 | 1 | /******************************************** |
2 | Macro to launch TOF QA task on ESDs data | |
3 | ||
4 | Author: fbellini@cern.ch | |
5 | Last update: 18 october 2012 | |
6 | *********************************************/ | |
7 | class AliAnalysisGrid; | |
8 | TString analysisMode = "grid"; // "local" or "grid" - needs to be "grid" for plugin test mode | |
9 | Bool_t useAlienPlugin=kTRUE; //use kFALSE for local analysis | |
10 | ||
11 | //input dataset | |
12 | Int_t runList[2]={186084,186162}; | |
13 | Int_t runNmin=0; | |
14 | Int_t runNmax=2; | |
15 | Int_t year = 2012; | |
16 | TString prod = "LHC12d"; | |
17 | TString myRecPass="cpass1"; | |
18 | TString myQAfileSuffix="_Barrel"; | |
19 | Bool_t isMC = kFALSE; | |
20 | TString gridUser="fbellini"; | |
21 | Int_t gridNtestFiles = 1; | |
22 | ||
23 | TString prefix="_"; | |
24 | ||
25 | //do not change! to be set by SetupIO() | |
26 | TString myGridDataDir=""; | |
27 | TString myDataPattern=""; | |
28 | TString myWorkDir; | |
29 | TString myOutDir; | |
30 | TString myJDLname; | |
31 | TString myExecutableName; | |
32 | TString myMacroName; | |
33 | ||
34 | //---------------------------------------------------------------------- | |
35 | void SetupIO(TString filesPrefix = "") | |
36 | { | |
37 | //Setup I/O paths and file names | |
38 | myGridDataDir = "/alice"; | |
39 | ||
40 | myWorkDir = "QA_pp2012"; | |
41 | myOutDir = Form("%s", prod.Data()) ; | |
42 | myJDLname = Form("job_Run%s", myWorkDir.Data()); | |
43 | myExecutableName = Form("Run%s", myWorkDir.Data()); | |
44 | myMacroName = Form("Run%s", myWorkDir.Data()); | |
45 | ||
46 | if (isMC) myDataPattern="*AliESDs.root"; | |
47 | else myDataPattern=Form("%s/*AliESDs%s.root",myRecPass.Data(),myQAfileSuffix.Data()); | |
48 | myOutDir.Append(Form("_%s",myRecPass.Data())); | |
49 | myJDLname.Append(Form("_%s",myRecPass.Data())); | |
50 | myExecutableName.Append(Form("_%s",myRecPass.Data())); | |
51 | myMacroName.Append(Form("_%s",myRecPass.Data())); | |
52 | ||
53 | if (isMC) { | |
54 | myGridDataDir.Append("/sim"); | |
55 | myWorkDir.Append("_MC"); | |
56 | myJDLname.Append("_MC"); | |
57 | myExecutableName.Append("_MC"); | |
58 | myMacroName.Append("_MC"); | |
59 | } else { | |
60 | myGridDataDir.Append(Form("/data/%i",year)); | |
61 | } | |
62 | myGridDataDir.Append(Form("/%s",prod.Data())); | |
63 | myOutDir.Append(filesPrefix.Data()); | |
64 | myExecutableName.Append(Form("%s.sh",filesPrefix.Data())); | |
65 | myMacroName.Append(Form("%s.C",filesPrefix.Data())); | |
66 | myJDLname.Append(Form("_run%i-%i%s.jdl",runNmin,runNmax,filesPrefix.Data())); | |
67 | ||
68 | Printf("========================================= Setup I/O:"); | |
69 | Printf("myGridDataDir = %s", myGridDataDir.Data()); | |
70 | Printf("myDataPattern = %s", myDataPattern.Data()); | |
71 | Printf("myWorkDir = %s", myWorkDir.Data()); | |
72 | Printf("myOutDir = %s", myOutDir.Data()); | |
73 | Printf("myJDLname = %s", myJDLname.Data()); | |
74 | Printf("myExecutableName = %s", myExecutableName.Data()); | |
75 | Printf("myMacroName = %s", myMacroName.Data()); | |
76 | Printf("=======================================================\n"); | |
77 | } | |
78 | //---------------------------------------------------------------------- | |
79 | void SetGridUser(TString username){ | |
80 | if (username) | |
81 | gridUser = username.Data(); | |
82 | return; | |
83 | } | |
84 | //---------------------------------------------------------------------- | |
85 | void SetGridNtestFiles(Int_t nfiles = 1){ | |
86 | if (nfiles<1) gridNtestFiles=1; | |
87 | else gridNtestFiles = nfiles; | |
88 | return; | |
89 | } | |
90 | //---------------------------------------------------------------------- | |
91 | void LoadLibraries() | |
92 | { | |
93 | gSystem->SetIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TRD -I$ALICE_ROOT/PWGPP -I$ALICE_ROOT/PWGPP/TRD"); | |
94 | gSystem->Load("libANALYSIS"); | |
95 | gSystem->Load("libANALYSISalice"); | |
96 | gSystem->Load("libCORRFW"); | |
97 | gSystem->Load("libTENDER"); | |
98 | gSystem->Load("libPWGPP.so"); | |
99 | } | |
100 | //---------------------------------------------------------------------- | |
101 | void RunAnalysisTOFqaGrid(TString pluginmode="test", Int_t ntestfiles = 10, TString filesPrefix = "", TString gridUser="fbellini") | |
102 | { | |
103 | LoadLibraries(); | |
104 | SetGridUser(gridUser.Data()); | |
105 | SetGridNtestFiles(ntestfiles); | |
106 | SetupIO(filesPrefix.Data()); | |
107 | if(analysisMode=="grid") { | |
108 | TGrid::Connect("alien://"); | |
109 | } | |
110 | ||
111 | Long64_t nentries=100000, firstentry=0; | |
112 | Bool_t readMC = kFALSE; | |
113 | ||
114 | if(useAlienPlugin) { | |
115 | AliAnalysisGrid *alienHandler = CreateAlienHandler(pluginmode); | |
116 | if(!alienHandler) return; | |
117 | } | |
118 | ||
119 | // Prepare input chain | |
120 | TChain *chainESD = 0; | |
121 | if(!useAlienPlugin) { | |
122 | chainESD=new TChain("esdTree"); | |
123 | chainESD->Add("AliESDs.root"); //used to test locally - modify with local path files | |
124 | } | |
125 | ||
126 | AliAnalysisManager *mgr = new AliAnalysisManager("My Manager","My Manager"); | |
127 | mgr->SetDebugLevel(1); | |
128 | if(useAlienPlugin) mgr->SetGridHandler(alienHandler); | |
129 | AliInputEventHandler *esdH = new AliESDInputHandler(); | |
130 | mgr->SetInputEventHandler(esdH); | |
131 | ||
132 | //------------------------------------------------------------------- | |
133 | //------------------------------------------------------------------- | |
134 | // Analysis tasks (wagons of the train) | |
135 | // | |
136 | TString taskName; | |
137 | ||
138 | //Wagon for physics event selection | |
139 | gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); | |
140 | AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(); | |
141 | AliPhysicsSelection* physSel = physSelTask->GetPhysicsSelection(); | |
142 | if (isMC)physSelTask->GetPhysicsSelection()->SetAnalyzeMC(); | |
143 | //physSel->AddBackgroundIdentification(new AliBackgroundSelection()); | |
144 | ||
145 | gROOT->LoadMacro("$ALICE_ROOT/PWGPP/TOF/AddTaskTOFQA.C"); | |
146 | AliAnalysisTaskTOFqa *TOFqa = (AliAnalysisTaskTOFqa*) AddTaskTOFQA(kTRUE); | |
147 | ||
148 | if(readMC) { | |
149 | AliMCEventHandler *mcH = new AliMCEventHandler(); | |
150 | mgr->SetMCtruthEventHandler(mcH); | |
151 | } | |
152 | // | |
153 | // Run the analysis | |
154 | // | |
155 | if(chainESD) printf("CHAIN HAS %d ENTRIES\n",(Int_t)chainESD->GetEntries()); | |
156 | ||
157 | if(!mgr->InitAnalysis()) return; | |
158 | mgr->PrintStatus(); | |
159 | if(analysisMode=="grid" && !useAlienPlugin) analysisMode="local"; | |
160 | mgr->StartAnalysis(analysisMode.Data(),chainESD,nentries,firstentry); | |
161 | ||
162 | return; | |
163 | } | |
164 | ||
165 | //_____________________________________________________________________________ | |
166 | AliAnalysisGrid* CreateAlienHandler(TString pluginmode="full") | |
167 | { | |
168 | ||
169 | AliAnalysisAlien *plugin = new AliAnalysisAlien(); | |
170 | // Set the run mode (can be "full", "test", "offline", "submit" or "terminate") | |
171 | plugin->SetRunMode(pluginmode.Data()); | |
172 | plugin->SetUser(gridUser.Data()); //MODIFICA | |
173 | plugin->SetNtestFiles(gridNtestFiles); | |
174 | // Set versions of used packages | |
175 | plugin->SetAPIVersion("V1.1x"); | |
176 | plugin->SetROOTVersion("v5-34-02"); //MODIFICA | |
177 | plugin->SetAliROOTVersion("v5-03-70-AN"); //MODIFICA | |
178 | //Set user grid output dir | |
179 | plugin->SetGridWorkingDir(myWorkDir.Data()); | |
180 | plugin->SetGridOutputDir(myOutDir.Data()); | |
181 | plugin->SetCheckCopy(kTRUE); | |
182 | plugin->SetGridDataDir(myGridDataDir.Data()); | |
183 | plugin->SetDataPattern(myDataPattern.Data()); | |
184 | if (!isMC) plugin->SetRunPrefix("000"); | |
185 | for (Int_t irun=runNmin;irun<runNmax;irun++){ | |
186 | plugin->AddRunNumber((Int_t )runList[irun]); | |
187 | } | |
188 | plugin->SetOutputToRunNo(1); | |
189 | plugin->SetNrunsPerMaster(1); | |
190 | plugin->SetExecutableCommand("aliroot -b -q"); | |
191 | plugin->SetOutputToRunNo(1); | |
192 | plugin->SetNrunsPerMaster(1); | |
193 | ||
194 | plugin->AddIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TRD -I$ALICE_ROOT/PWGPP -I$ALICE_ROOT/PWGPP/TRD"); | |
195 | plugin->SetAdditionalLibs("libANALYSIS.so libANALYSISalice.so libCORRFW.so libTENDER.so libPWGPP.so ");//libTRDbase.so libTRDrec.so | |
196 | plugin->SetDefaultOutputs(kTRUE); | |
197 | plugin->SetAnalysisMacro("AnalysisTOFqaSigned.C"); //MODIFICA se vuoi | |
198 | plugin->SetExecutable("analysisTOFqaSigned.sh"); //MODIFICA se vuoi | |
199 | plugin->SetSplitMaxInputFileNumber(50); | |
200 | plugin->SetMaxInitFailed(15); | |
201 | plugin->SetTTL(80000); | |
202 | plugin->SetInputFormat("xml-single"); | |
203 | plugin->SetJDLName("TaskAnalysisTOFqaSigned.jdl"); //MODIFICA se vuoi | |
204 | plugin->SetSplitMode("se"); | |
205 | return plugin; | |
206 | } | |
207 | ||
208 | //----------------------------------------------------------------------------- | |
209 | TChain *CreateESDChain(TString esdpath=".",Int_t ifirst=-1,Int_t ilast=-1) | |
210 | { | |
211 | TChain *chainESD = new TChain("esdTree"); | |
212 | if(ifirst<0) { | |
213 | chainESD->Add("AliESDs.root"); | |
214 | } else { | |
215 | for(Int_t i=ifirst; i<=ilast; i++) { | |
216 | TString esdfile=esdpath; esdfile+=i; esdfile.Append("/AliESDs.root"); | |
217 | chainESD->Add(esdfile.Data()); | |
218 | } | |
219 | } | |
220 | ||
221 | return chainESD; | |
222 | } |