]>
Commit | Line | Data |
---|---|---|
00612ffc | 1 | //-------------------------------------------------------------------------- |
2 | // Macro compiled and launch by RunMuonResolution.C for submitting muon Resolution analysis locally or on CAF. | |
3 | // See RunMuonResolution.C for more details | |
4 | // | |
5 | // Author: Philippe Pillot - SUBATECH Nantes | |
6 | //-------------------------------------------------------------------------- | |
7 | ||
8 | #if !defined(__CINT__) || defined(__MAKECINT__) | |
9 | // ROOT includes | |
10 | #include <fstream> | |
11 | #include <TString.h> | |
12 | #include <TStopwatch.h> | |
13 | #include <TMultiGraph.h> | |
14 | #include <TSystem.h> | |
15 | #include <TChain.h> | |
16 | #include <TGraphErrors.h> | |
17 | #include <TProof.h> | |
18 | #include <TList.h> | |
19 | #include <TCanvas.h> | |
20 | #include <TFile.h> | |
21 | #include <TGrid.h> | |
22 | #include <TEnv.h> | |
23 | #include <TROOT.h> | |
24 | #include "TAxis.h" | |
25 | #include "THashList.h" | |
26 | #include <TAlienCollection.h> | |
27 | #include <TGridCollection.h> | |
28 | #include <TGridResult.h> | |
29 | ||
30 | // STEER includes | |
31 | #include "AliLog.h" | |
32 | #include "AliCDBManager.h" | |
33 | #include "AliAnalysisManager.h" | |
34 | #include "AliESDInputHandler.h" | |
35 | #include "AliTagAnalysis.h" | |
36 | #include "AliRunTagCuts.h" | |
37 | #include "AliLHCTagCuts.h" | |
38 | #include "AliDetectorTagCuts.h" | |
39 | #include "AliEventTagCuts.h" | |
40 | #include "AliPhysicsSelectionTask.h" | |
41 | #include "AliPhysicsSelection.h" | |
42 | #include "AliBackgroundSelection.h" | |
4060971a | 43 | #include "AliCentralitySelectionTask.h" |
00612ffc | 44 | #include "AliAnalysisDataContainer.h" |
45 | #include "AliAnalysisTaskMuonResolution.h" | |
46 | ||
47 | // MUON includes | |
48 | #include "AliMpCDB.h" | |
49 | #include "AliMpDetElement.h" | |
50 | #include "AliMpDDLStore.h" | |
51 | #include "AliMUONCalibParamND.h" | |
52 | #include "AliMUON2DMap.h" | |
53 | #include "AliMUONTrackerData.h" | |
54 | #include "AliMUONPainterDataRegistry.h" | |
55 | #include "AliMUONTrackerDataWrapper.h" | |
56 | ||
09233fcd | 57 | #include "AliMuonTrackCuts.h" |
58 | ||
00612ffc | 59 | #include "AddTaskMuonResolution.C" |
60 | ||
61 | #endif | |
62 | ||
63 | enum {kLocal, kInteractif_xml, kInteractif_ESDList, kProof}; | |
09233fcd | 64 | Int_t nDE = 200; |
00612ffc | 65 | |
09233fcd | 66 | Bool_t Resume(Int_t &firstStep, Double_t clusterResNB[10], Double_t clusterResB[10], |
67 | Double_t clusterResNBErr[10], Double_t clusterResBErr[10], | |
68 | Bool_t shiftHalfCh, Double_t halfChShiftNB[20], Double_t halfChShiftB[20], | |
69 | Double_t halfChShiftNBErr[20], Double_t halfChShiftBErr[20], | |
70 | Bool_t shiftDE, Double_t deShiftNB[200], Double_t deShiftB[200], | |
71 | TGraphErrors* clusterResXVsStep[10], TGraphErrors* clusterResYVsStep[10], | |
72 | TGraphErrors* halfChShiftXVsStep[20], TGraphErrors* halfChShiftYVsStep[20]); | |
73 | void LoadAlirootOnProof(TString& aaf, TString rootVersion, TString alirootVersion, TString& extraLibs, Int_t iStep); | |
00612ffc | 74 | AliAnalysisTaskMuonResolution* CreateAnalysisTrain(Int_t mode, Int_t iStep, Bool_t selectPhysics, Bool_t selectTrigger, Bool_t matchTrig, |
75 | Bool_t applyAccCut, Double_t minMomentum, Bool_t correctForSystematics, Int_t extrapMode, | |
09233fcd | 76 | Double_t clusterResNB[10], Double_t clusterResB[10], |
77 | Bool_t shiftHalfCh, Double_t halfChShiftNB[20], Double_t halfChShiftB[20], | |
78 | Bool_t shiftDE, Double_t deShiftNB[200], Double_t deShiftB[200]); | |
00612ffc | 79 | Bool_t GetChamberResolution(Int_t iStep, Double_t clusterResNB[10], Double_t clusterResB[10], |
80 | Double_t clusterResNBErr[10], Double_t clusterResBErr[10]); | |
09233fcd | 81 | Bool_t AddHalfChShift(Int_t iStep, Double_t halfChShiftNB[20], Double_t halfChShiftB[20], Double_t halfChShiftNBErr[20], Double_t halfChShiftBErr[20]); |
82 | Bool_t AddDEShift(Int_t iStep, Double_t deShiftNB[200], Double_t deShiftB[200]); | |
00612ffc | 83 | void AddMCHViews(TFile* file); |
84 | AliMUONTrackerData* ConvertGraph(TGraphErrors& g, const char* name); | |
85 | Int_t GetMode(TString smode, TString input); | |
86 | TChain* CreateChainFromCollection(const char *xmlfile); | |
87 | TChain* CreateChainFromFile(const char *rootfile); | |
88 | TChain* CreateChainFromESDList(const char *esdList); | |
89 | TChain* CreateChain(Int_t mode, TString input); | |
90 | ||
91 | //______________________________________________________________________________ | |
09233fcd | 92 | void MuonResolution(TString smode, TString inputFileName, TString rootVersion, TString alirootVersion, Int_t nSteps, |
93 | Bool_t selectPhysics, Bool_t selectTrigger, Bool_t matchTrig, Bool_t applyAccCut, | |
94 | Double_t minMomentum, Bool_t correctForSystematics, Int_t extrapMode, | |
95 | Bool_t shiftHalfCh, Bool_t shiftDE, Int_t nevents, TString extraLibs) | |
00612ffc | 96 | { |
97 | /// Compute the cluster resolution by studying cluster-track residual, deconvoluting from track resolution | |
98 | ||
99 | // timer start... | |
100 | TStopwatch* localTimer = new TStopwatch; | |
101 | ||
102 | // check parameters | |
103 | nSteps = TMath::Max(nSteps,1); | |
104 | if (extrapMode != 0 && extrapMode != 1) { | |
105 | Error("MuonResolution","incorrect extrapolation mode!"); | |
106 | return; | |
107 | } | |
108 | ||
109 | // Check runing mode | |
110 | Int_t mode = GetMode(smode, inputFileName); | |
111 | if(mode < 0){ | |
112 | Error("MuonResolution","Please provide either an ESD root file, a list of ESDs, a collection of ESDs or a dataset."); | |
113 | return; | |
114 | } | |
115 | ||
00612ffc | 116 | // set starting chamber resolution (if -1 they will be loaded from recoParam in the task) |
09233fcd | 117 | Double_t clusterResNB[10] = {-1., -1., -1., -1., -1., -1., -1., -1., -1., -1.}; |
118 | Double_t clusterResB[10] = {-1., -1., -1., -1., -1., -1., -1., -1., -1., -1.}; | |
119 | Double_t clusterResNBErr[10] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0.}; | |
120 | Double_t clusterResBErr[10] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0.}; | |
121 | Double_t halfChShiftNB[20] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.}; | |
122 | Double_t halfChShiftB[20] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.}; | |
123 | Double_t halfChShiftNBErr[20] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.}; | |
124 | Double_t halfChShiftBErr[20] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.}; | |
125 | Double_t deShiftNB[200]; | |
126 | Double_t deShiftB[200]; | |
127 | for (Int_t i=0; i<200; i++) { | |
128 | deShiftNB[i] = 0.; | |
129 | deShiftB[i] = 0.; | |
130 | } | |
00612ffc | 131 | |
132 | // output graphs | |
133 | TMultiGraph* mgClusterResXVsStep = new TMultiGraph("mgClusterResXVsStep","cluster X-resolution versus step;step;#sigma_{X} (cm)"); | |
134 | TMultiGraph* mgClusterResYVsStep = new TMultiGraph("mgClusterResYVsStep","cluster Y-resolution versus step;step;#sigma_{Y} (cm)"); | |
135 | TGraphErrors* clusterResXVsStep[10]; | |
136 | TGraphErrors* clusterResYVsStep[10]; | |
137 | for (Int_t i = 0; i < 10; i++) { | |
138 | clusterResXVsStep[i] = new TGraphErrors(nSteps+1); | |
139 | clusterResXVsStep[i]->SetName(Form("gResX_ch%d",i+1)); | |
140 | clusterResXVsStep[i]->SetMarkerStyle(kFullDotMedium); | |
141 | clusterResXVsStep[i]->SetMarkerColor(i+1+i/9); | |
142 | mgClusterResXVsStep->Add(clusterResXVsStep[i],"lp"); | |
143 | ||
144 | clusterResYVsStep[i] = new TGraphErrors(nSteps+1); | |
145 | clusterResYVsStep[i]->SetName(Form("gResY_ch%d",i+1)); | |
146 | clusterResYVsStep[i]->SetMarkerStyle(kFullDotMedium); | |
147 | clusterResYVsStep[i]->SetMarkerColor(i+1+i/9); | |
148 | mgClusterResYVsStep->Add(clusterResYVsStep[i],"lp"); | |
149 | } | |
09233fcd | 150 | TMultiGraph* mgHalfChShiftXVsStep = new TMultiGraph("mgHalfChShiftXVsStep","half-chamber displacement in X direction versus step;step;#Delta_{X} (cm)"); |
151 | TMultiGraph* mgHalfChShiftYVsStep = new TMultiGraph("mgHalfChShiftYVsStep","half-chamber displacement in Y direction versus step;step;#Delta_{Y} (cm)"); | |
152 | TGraphErrors* halfChShiftXVsStep[20]; | |
153 | TGraphErrors* halfChShiftYVsStep[20]; | |
154 | for (Int_t i = 0; i < 20; i++) { | |
155 | halfChShiftXVsStep[i] = new TGraphErrors(nSteps+1); | |
156 | halfChShiftXVsStep[i]->SetName(Form("gShiftX_hch%d",i+1)); | |
157 | halfChShiftXVsStep[i]->SetMarkerStyle(kFullDotMedium); | |
158 | halfChShiftXVsStep[i]->SetMarkerColor(i+1+i/9+i/18); | |
159 | mgHalfChShiftXVsStep->Add(halfChShiftXVsStep[i],"lp"); | |
160 | halfChShiftXVsStep[i]->SetPoint(0, 0, halfChShiftNB[i]); | |
161 | halfChShiftXVsStep[i]->SetPointError(0, 0., halfChShiftNBErr[i]); | |
162 | ||
163 | halfChShiftYVsStep[i] = new TGraphErrors(nSteps+1); | |
164 | halfChShiftYVsStep[i]->SetName(Form("gShiftY_hch%d",i+1)); | |
165 | halfChShiftYVsStep[i]->SetMarkerStyle(kFullDotMedium); | |
166 | halfChShiftYVsStep[i]->SetMarkerColor(i+1+i/9+i/18); | |
167 | mgHalfChShiftYVsStep->Add(halfChShiftYVsStep[i],"lp"); | |
168 | halfChShiftYVsStep[i]->SetPoint(0, 0, halfChShiftB[i]); | |
169 | halfChShiftYVsStep[i]->SetPointError(0, 0., halfChShiftBErr[i]); | |
170 | } | |
171 | ||
172 | // check for old output files | |
173 | Int_t firstStep = 0; | |
174 | char remove = '\0'; | |
175 | if (!gSystem->Exec("ls chamberResolution_step*[0-9].root")) { | |
176 | cout<<"Above files already exist in the current directory. [d=delete, r=resume, e=exit] "<<flush; | |
177 | while (remove != 'd' && remove != 'r' && remove != 'e') cin>>remove; | |
178 | if (remove == 'y') gSystem->Exec("rm -f chamberResolution_step*[0-9].root"); | |
179 | else if (remove == 'r' && !Resume(firstStep, clusterResNB, clusterResB, clusterResNBErr, clusterResBErr, | |
180 | shiftHalfCh, halfChShiftNB, halfChShiftB, halfChShiftNBErr, halfChShiftBErr, | |
181 | shiftDE, deShiftNB, deShiftB, clusterResXVsStep, clusterResYVsStep, | |
182 | halfChShiftXVsStep, halfChShiftYVsStep)) return; | |
183 | else if (remove == 'e') return; | |
184 | } | |
185 | ||
186 | // Create input object | |
187 | TObject* inputObj = 0x0; | |
188 | if (mode == kProof) inputObj = new TObjString(inputFileName); | |
189 | else inputObj = CreateChain(mode, inputFileName); | |
190 | if (!inputObj) return; | |
00612ffc | 191 | |
192 | // loop over step | |
09233fcd | 193 | for (Int_t iStep = firstStep; iStep < nSteps; iStep++) { |
00612ffc | 194 | cout<<"step "<<iStep+1<<"/"<<nSteps<<endl; |
195 | ||
196 | // Connect to proof if needed and prepare environment | |
09233fcd | 197 | if (mode == kProof) LoadAlirootOnProof(smode, rootVersion, alirootVersion, extraLibs, iStep-firstStep); |
00612ffc | 198 | |
199 | // create the analysis train | |
09233fcd | 200 | AliAnalysisTaskMuonResolution *muonResolution = CreateAnalysisTrain(mode, iStep, selectPhysics, selectTrigger, |
201 | matchTrig, applyAccCut, minMomentum, correctForSystematics, | |
202 | extrapMode, clusterResNB, clusterResB, shiftHalfCh, | |
203 | halfChShiftNB, halfChShiftB, shiftDE, deShiftNB, deShiftB); | |
00612ffc | 204 | if (!muonResolution) return; |
205 | ||
206 | // start analysis | |
207 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
208 | if (mgr->InitAnalysis()) { | |
209 | mgr->PrintStatus(); | |
09233fcd | 210 | if (mode == kProof) mgr->StartAnalysis("proof", static_cast<TObjString*>(inputObj)->GetName(), nevents); |
00612ffc | 211 | else mgr->StartAnalysis("local", static_cast<TChain*>(inputObj), nevents); |
212 | } | |
213 | ||
214 | // save the summary canvases and mchview display | |
215 | if (muonResolution->GetCanvases()) { | |
216 | TFile* outFile = TFile::Open(Form("chamberResolution_step%d.root", iStep),"UPDATE"); | |
217 | if (outFile && outFile->IsOpen()) { | |
218 | outFile->cd(); | |
219 | muonResolution->GetCanvases()->Write(); | |
220 | AddMCHViews(outFile); | |
221 | outFile->Close(); | |
09233fcd | 222 | delete outFile; |
00612ffc | 223 | } |
224 | } | |
225 | ||
09233fcd | 226 | // fill graphs with starting resolutions from the task at very first step |
00612ffc | 227 | if (iStep == 0) { |
228 | muonResolution->GetStartingResolution(clusterResNB, clusterResB); | |
229 | for (Int_t i = 0; i < 10; i++) { | |
230 | clusterResXVsStep[i]->SetPoint(0, 0, clusterResNB[i]); | |
231 | clusterResXVsStep[i]->SetPointError(0, 0., clusterResNBErr[i]); | |
232 | clusterResYVsStep[i]->SetPoint(0, 0, clusterResB[i]); | |
233 | clusterResYVsStep[i]->SetPointError(0, 0., clusterResBErr[i]); | |
234 | } | |
235 | } | |
236 | ||
237 | // read the chamber resolution from the output file | |
238 | if (!GetChamberResolution(iStep, clusterResNB, clusterResB, clusterResNBErr, clusterResBErr)) return; | |
239 | ||
240 | // fill graphs with computed resolutions | |
241 | for (Int_t i = 0; i < 10; i++) { | |
242 | clusterResXVsStep[i]->SetPoint(iStep+1, iStep+1, clusterResNB[i]); | |
243 | clusterResXVsStep[i]->SetPointError(iStep+1, 0., clusterResNBErr[i]); | |
244 | clusterResYVsStep[i]->SetPoint(iStep+1, iStep+1, clusterResB[i]); | |
245 | clusterResYVsStep[i]->SetPointError(iStep+1, 0., clusterResBErr[i]); | |
246 | } | |
247 | ||
09233fcd | 248 | // get the half-chamber displacements currently used and add the new measurements from the output file |
249 | muonResolution->GetHalfChShift(halfChShiftNB, halfChShiftB); | |
250 | if (!AddHalfChShift(iStep, halfChShiftNB, halfChShiftB, halfChShiftNBErr, halfChShiftBErr)) return; | |
251 | ||
252 | // fill graphs with computed displacements | |
253 | for (Int_t i = 0; i < 20; i++) { | |
254 | halfChShiftXVsStep[i]->SetPoint(iStep+1, iStep+1, halfChShiftNB[i]); | |
255 | halfChShiftXVsStep[i]->SetPointError(iStep+1, 0., halfChShiftNBErr[i]); | |
256 | halfChShiftYVsStep[i]->SetPoint(iStep+1, iStep+1, halfChShiftB[i]); | |
257 | halfChShiftYVsStep[i]->SetPointError(iStep+1, 0., halfChShiftBErr[i]); | |
258 | } | |
259 | ||
260 | // get the DE displacements currently used and add the new measurements from the output file | |
261 | muonResolution->GetDEShift(deShiftNB, deShiftB); | |
262 | if (!AddDEShift(iStep, deShiftNB, deShiftB)) return; | |
263 | ||
00612ffc | 264 | // clean memory |
09233fcd | 265 | mgr->SetAnalysisType(AliAnalysisManager::kLocalAnalysis); // to make sure that all output containers are deleted |
00612ffc | 266 | delete mgr; |
267 | TObject::SetObjectStat(kFALSE); | |
268 | ||
269 | } | |
270 | ||
271 | // copy final results in results.root file | |
272 | gSystem->Exec(Form("cp chamberResolution_step%d.root results.root", nSteps-1)); | |
273 | ||
09233fcd | 274 | // display convergence of cluster resolution |
275 | TCanvas* convergence1 = new TCanvas("convergenceRes","convergence of cluster resolution"); | |
276 | convergence1->Divide(1,2); | |
277 | convergence1->cd(1); | |
00612ffc | 278 | mgClusterResXVsStep->Draw("ap"); |
09233fcd | 279 | convergence1->cd(2); |
00612ffc | 280 | mgClusterResYVsStep->Draw("ap"); |
281 | ||
09233fcd | 282 | // display convergence of half-chamber displacements |
283 | TCanvas* convergence2 = new TCanvas("convergenceShift","convergence of half-chamber displacements"); | |
284 | convergence2->Divide(1,2); | |
285 | convergence2->cd(1); | |
286 | mgHalfChShiftXVsStep->Draw("ap"); | |
287 | convergence2->cd(2); | |
288 | mgHalfChShiftYVsStep->Draw("ap"); | |
289 | ||
00612ffc | 290 | // save convergence plots |
291 | TFile* outFile = TFile::Open("results.root","UPDATE"); | |
292 | if (!outFile || !outFile->IsOpen()) return; | |
293 | outFile->cd(); | |
294 | mgClusterResXVsStep->Write(); | |
295 | mgClusterResYVsStep->Write(); | |
09233fcd | 296 | convergence1->Write(); |
297 | mgHalfChShiftXVsStep->Write(); | |
298 | mgHalfChShiftYVsStep->Write(); | |
299 | convergence2->Write(); | |
00612ffc | 300 | outFile->Close(); |
09233fcd | 301 | delete outFile; |
302 | ||
303 | // print final half-chamber displacements | |
304 | printf("\nhalf-chamber total displacements:\n"); | |
305 | printf(" - non-bending:"); | |
306 | for (Int_t i = 0; i < 20; i++) printf((i==0)?" %6.4f":", %6.4f", halfChShiftNB[i]); | |
307 | printf("\n - bending:"); | |
308 | for (Int_t i = 0; i < 20; i++) printf((i==0)?" %6.4f":", %6.4f", halfChShiftB[i]); | |
309 | printf("\n\n"); | |
310 | ||
311 | // print final DE displacements | |
312 | printf("\nDE total displacements:\n"); | |
313 | printf(" - non-bending:"); | |
314 | for (Int_t i = 0; i < nDE; i++) printf((i==0)?" %6.4f":", %6.4f", deShiftNB[i]); | |
315 | printf("\n - bending:"); | |
316 | for (Int_t i = 0; i < nDE; i++) printf((i==0)?" %6.4f":", %6.4f", deShiftB[i]); | |
317 | printf("\n\n"); | |
00612ffc | 318 | |
319 | // ...timer stop | |
320 | localTimer->Stop(); | |
321 | localTimer->Print(); | |
09233fcd | 322 | delete localTimer; |
00612ffc | 323 | |
324 | } | |
325 | ||
326 | //______________________________________________________________________________ | |
09233fcd | 327 | Bool_t Resume(Int_t &firstStep, Double_t clusterResNB[10], Double_t clusterResB[10], |
328 | Double_t clusterResNBErr[10], Double_t clusterResBErr[10], | |
329 | Bool_t shiftHalfCh, Double_t halfChShiftNB[20], Double_t halfChShiftB[20], | |
330 | Double_t halfChShiftNBErr[20], Double_t halfChShiftBErr[20], | |
331 | Bool_t shiftDE, Double_t deShiftNB[200], Double_t deShiftB[200], | |
332 | TGraphErrors* clusterResXVsStep[10], TGraphErrors* clusterResYVsStep[10], | |
333 | TGraphErrors* halfChShiftXVsStep[20], TGraphErrors* halfChShiftYVsStep[20]) | |
334 | { | |
335 | /// resume analysis from desired step | |
336 | ||
337 | while (kTRUE) { | |
338 | ||
339 | // Get the step to restart from | |
340 | cout<<"From which step (included) you want to resume? [#, e=exit] "<<flush; | |
341 | TString step = ""; | |
342 | do {step.Gets(stdin,kTRUE);} while (!step.IsDigit() && step != "e"); | |
343 | if (step == "e") return kFALSE; | |
344 | firstStep = step.Atoi(); | |
345 | ||
346 | // restart from scratch if requested | |
347 | if (firstStep == 0) { | |
348 | gSystem->Exec("rm -f chamberResolution_step*[0-9].root"); | |
349 | return kTRUE; | |
350 | } | |
351 | ||
352 | // look for results from the previous step | |
353 | if (gSystem->AccessPathName(Form("chamberResolution_step%d.root", firstStep-1))) { | |
354 | cout<<"No result found from the previous step ("<<firstStep-1<<"). Unable to resume from step "<<firstStep<<endl; | |
355 | continue; | |
356 | } | |
357 | ||
358 | // fill graph with starting resolutions | |
359 | for (Int_t i = 0; i < 10; i++) { | |
360 | clusterResXVsStep[i]->SetPoint(0, 0, clusterResNB[i]); | |
361 | clusterResXVsStep[i]->SetPointError(0, 0., clusterResNBErr[i]); | |
362 | clusterResYVsStep[i]->SetPoint(0, 0, clusterResB[i]); | |
363 | clusterResYVsStep[i]->SetPointError(0, 0., clusterResBErr[i]); | |
364 | } | |
365 | ||
366 | // loop over previous steps | |
367 | Bool_t missingInfo = kFALSE; | |
368 | for (Int_t iStep = 0; iStep < firstStep; iStep++) { | |
369 | ||
370 | // read the chamber resolution from the output file | |
371 | if (!GetChamberResolution(iStep, clusterResNB, clusterResB, clusterResNBErr, clusterResBErr) && iStep == firstStep-1) { | |
372 | missingInfo = kTRUE; | |
373 | break; | |
374 | } | |
375 | ||
376 | // fill graphs with computed resolutions | |
377 | for (Int_t i = 0; i < 10; i++) { | |
378 | clusterResXVsStep[i]->SetPoint(iStep+1, iStep+1, clusterResNB[i]); | |
379 | clusterResXVsStep[i]->SetPointError(iStep+1, 0., clusterResNBErr[i]); | |
380 | clusterResYVsStep[i]->SetPoint(iStep+1, iStep+1, clusterResB[i]); | |
381 | clusterResYVsStep[i]->SetPointError(iStep+1, 0., clusterResBErr[i]); | |
382 | } | |
383 | ||
384 | // reset the half-chamber displacements if not used and add the new measurements from the output file | |
385 | if (!shiftHalfCh) for (Int_t i=0; i<20; i++) { | |
386 | halfChShiftNB[i] = 0.; halfChShiftB[i] = 0.; | |
387 | halfChShiftNBErr[i] = 0.; halfChShiftBErr[i] = 0.; | |
388 | } | |
389 | if (!AddHalfChShift(iStep, halfChShiftNB, halfChShiftB, halfChShiftNBErr, halfChShiftBErr) && shiftHalfCh) { | |
390 | missingInfo = kTRUE; | |
391 | break; | |
392 | } | |
393 | ||
394 | // fill graphs with computed displacements | |
395 | for (Int_t i = 0; i < 20; i++) { | |
396 | halfChShiftXVsStep[i]->SetPoint(iStep+1, iStep+1, halfChShiftNB[i]); | |
397 | halfChShiftXVsStep[i]->SetPointError(iStep+1, 0., halfChShiftNBErr[i]); | |
398 | halfChShiftYVsStep[i]->SetPoint(iStep+1, iStep+1, halfChShiftB[i]); | |
399 | halfChShiftYVsStep[i]->SetPointError(iStep+1, 0., halfChShiftBErr[i]); | |
400 | } | |
401 | ||
402 | // add the new measurements of DE displacements from the output file if in use | |
403 | if (shiftDE && !AddDEShift(iStep, deShiftNB, deShiftB)) { | |
404 | missingInfo = kTRUE; | |
405 | break; | |
406 | } | |
407 | ||
408 | } | |
409 | ||
410 | // check if missing important results from previous steps | |
411 | if (missingInfo) continue; | |
412 | ||
413 | // keep previous steps and remove the others | |
414 | gSystem->Exec("mkdir __TMP__"); | |
415 | for (Int_t iStep = 0; iStep < firstStep; iStep++) | |
416 | if (!gSystem->AccessPathName(Form("chamberResolution_step%d.root", iStep))) | |
417 | gSystem->Exec(Form("mv chamberResolution_step%d.root __TMP__", iStep)); | |
418 | gSystem->Exec("rm -f chamberResolution_step*[0-9].root"); | |
419 | gSystem->Exec("mv __TMP__/chamberResolution_step*[0-9].root ."); | |
420 | gSystem->Exec("rm -rf __TMP__"); | |
421 | ||
422 | return kTRUE; | |
423 | } | |
424 | ||
425 | } | |
426 | ||
427 | //______________________________________________________________________________ | |
428 | void LoadAlirootOnProof(TString& aaf, TString rootVersion, TString alirootVersion, TString& extraLibs, Int_t iStep) | |
00612ffc | 429 | { |
430 | /// Load aliroot packages and set environment on Proof | |
431 | ||
432 | // set general environment and close previous session | |
433 | if (iStep == 0) gEnv->SetValue("XSec.GSI.DelegProxy","2"); | |
434 | else gProof->Close("s"); | |
435 | ||
436 | // connect | |
09233fcd | 437 | TString location = (aaf == "caf") ? "alice-caf.cern.ch" : "nansafmaster.in2p3.fr"; //"localhost:1093" |
438 | TString nWorkers = (aaf == "caf") ? "workers=80" : ""; //"workers=3x" | |
439 | TString user = (gSystem->Getenv("alien_API_USER") == NULL) ? "" : Form("%s@",gSystem->Getenv("alien_API_USER")); | |
440 | TProof::Mgr(Form("%s%s",user.Data(), location.Data()))->SetROOTVersion(Form("VO_ALICE@ROOT::%s",rootVersion.Data())); | |
441 | TProof::Open(Form("%s%s/?N",user.Data(), location.Data()), nWorkers.Data()); | |
00612ffc | 442 | if (!gProof) return; |
443 | ||
444 | // set environment and load libraries on workers | |
445 | TList* list = new TList(); | |
446 | list->Add(new TNamed("ALIROOT_MODE", "")); | |
447 | list->Add(new TNamed("ALIROOT_EXTRA_LIBS", extraLibs.Data())); | |
448 | if (!gSystem->AccessPathName("AliAnalysisTaskMuonResolution.cxx")) | |
449 | list->Add(new TNamed("ALIROOT_EXTRA_INCLUDES", "MUON:MUON/mapping")); | |
09233fcd | 450 | gProof->EnablePackage(Form("VO_ALICE@AliRoot::%s",alirootVersion.Data()), list, kTRUE); |
00612ffc | 451 | |
452 | // compile task on workers | |
453 | if (!gSystem->AccessPathName("AliAnalysisTaskMuonResolution.cxx")) | |
454 | gProof->Load("AliAnalysisTaskMuonResolution.cxx++g", kTRUE); | |
455 | ||
456 | } | |
457 | ||
458 | //______________________________________________________________________________ | |
459 | AliAnalysisTaskMuonResolution* CreateAnalysisTrain(Int_t mode, Int_t iStep, Bool_t selectPhysics, Bool_t selectTrigger, Bool_t matchTrig, | |
460 | Bool_t applyAccCut, Double_t minMomentum, Bool_t correctForSystematics, Int_t extrapMode, | |
09233fcd | 461 | Double_t clusterResNB[10], Double_t clusterResB[10], |
462 | Bool_t shiftHalfCh, Double_t halfChShiftNB[20], Double_t halfChShiftB[20], | |
463 | Bool_t shiftDE, Double_t deShiftNB[200], Double_t deShiftB[200]) | |
00612ffc | 464 | { |
465 | /// create the analysis train and configure it | |
466 | ||
467 | // Create the analysis manager | |
468 | AliAnalysisManager *mgr = new AliAnalysisManager("MuonResolutionAnalysis"); | |
09233fcd | 469 | //mgr->SetNSysInfo(100); |
00612ffc | 470 | |
471 | // ESD input handler | |
472 | AliESDInputHandler* esdH = new AliESDInputHandler(); | |
473 | esdH->SetReadFriends(kFALSE); | |
4060971a | 474 | esdH->SetInactiveBranches("*"); |
fe0324de | 475 | esdH->SetActiveBranches("MuonTracks MuonClusters MuonPads AliESDRun. AliESDHeader. AliMultiplicity. AliESDFMD. AliESDVZERO. SPDVertex. PrimaryVertex. AliESDZDC."); |
00612ffc | 476 | mgr->SetInputEventHandler(esdH); |
477 | ||
478 | // event selection | |
479 | if (selectPhysics) { | |
63b6cbd0 | 480 | gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskPhysicsSelection.C"); |
fe0324de | 481 | if (!gROOT->ProcessLineFast("AddTaskPhysicsSelection()")) { |
4060971a | 482 | Error("CreateAnalysisTrain","AliPhysicsSelectionTask not created!"); |
00612ffc | 483 | return 0x0; |
484 | } | |
485 | } | |
486 | ||
4060971a | 487 | // centrality selection |
1c06a186 | 488 | gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskCentrality.C"); |
fe0324de | 489 | if (!gROOT->ProcessLineFast("AddTaskCentrality()")) { |
4060971a | 490 | Error("CreateAnalysisTrain","AliCentralitySelectionTask not created!"); |
491 | return 0x0; | |
492 | } | |
4060971a | 493 | |
00612ffc | 494 | // Muon Resolution analysis |
495 | TString outputFileName = Form("chamberResolution_step%d.root", iStep); | |
496 | AliAnalysisManager::SetCommonFileName(outputFileName.Data()); | |
497 | AliAnalysisTaskMuonResolution *muonResolution = AddTaskMuonResolution(selectPhysics, selectTrigger, matchTrig, applyAccCut, minMomentum, correctForSystematics, extrapMode); | |
498 | if (!muonResolution) { | |
4060971a | 499 | Error("CreateAnalysisTrain","AliAnalysisTaskMuonResolution not created!"); |
00612ffc | 500 | return 0x0; |
501 | } | |
09233fcd | 502 | /*if (mode == kLocal) muonResolution->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); |
503 | else */muonResolution->SetDefaultStorage("raw://"); | |
00612ffc | 504 | if (mode != kProof) muonResolution->ShowProgressBar(); |
505 | muonResolution->PrintClusterRes(kTRUE, kTRUE); | |
506 | muonResolution->SetStartingResolution(clusterResNB, clusterResB); | |
09233fcd | 507 | muonResolution->RemoveMonoCathodClusters(kTRUE, kFALSE); |
4060971a | 508 | // muonResolution->FitResiduals(kFALSE); |
509 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011",""); | |
510 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011", "alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011_Align2"); | |
09233fcd | 511 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011_Align1", "alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011_Align2"); |
512 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/MATFtestCDBVanik"); | |
513 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/MATFtestCDBJavier"); | |
514 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/MATFtestCDBVanik2"); | |
515 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/MATFtestCDBJavier2"); | |
516 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/MATFtestCDBTest"); | |
517 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/MATFtestCDBJavierI"); | |
518 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/MATFtestCDBJavier2St345"); | |
519 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011_Align1", "alien://folder=/alice/cern.ch/user/j/jcastill/MATFtestQuadrant"); | |
520 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/ReAligni00as_x_CDB"); | |
521 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011", "alien://folder=/alice/cern.ch/user/j/jcastill/ReAligni00as_x_CDB"); | |
522 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/ReAligni00asCDB"); | |
523 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011", "alien://folder=/alice/cern.ch/user/j/jcastill/ReAligni00asCDB"); | |
524 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/ReAligni00as_xypxvzyvz_x015y015_CDB"); | |
525 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011", "alien://folder=/alice/cern.ch/user/j/jcastill/ReAligni00as_xypxvzyvz_x015y015_CDB"); | |
526 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/ReAligni00as_xypxvzyvz_x010y015_CDB"); | |
527 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011", "alien://folder=/alice/cern.ch/user/j/jcastill/ReAligni00as_xypxvzyvz_x010y015_CDB"); | |
528 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/ReAligni00as_gc5_x015y015_fix24zIO_CDB"); | |
529 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011", "alien://folder=/alice/cern.ch/user/j/jcastill/ReAligni00as_gc5_x015y015_fix24zIO_CDB"); | |
530 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/MATFtestCDBVanik2St345_B2"); | |
531 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/MATFtestCDBVanik2St345_B3"); | |
532 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/MATFtestCDBQuadrant_B2"); | |
533 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/MATFtestCDBQuadrant_B3"); | |
534 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011", "alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011_Align2bis"); | |
535 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/p/ppillot/OCDB_BON_woConst"); | |
536 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/p/ppillot/OCDB_BON_wConst"); | |
537 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/p/ppillot/OCDB_BON_wConst_v2"); | |
538 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011_Align1", "alien://folder=/alice/cern.ch/user/s/shahoian/CorG4Fresmx05y015"); | |
539 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011_Align1", "alien://folder=/alice/cern.ch/user/s/shahoian/CorG4Gresmx05y015"); | |
540 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011", "alien://folder=/alice/cern.ch/user/s/shahoian/CorG4Gresmx05y015"); | |
541 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011_Align1", "alien://folder=/alice/cern.ch/user/p/ppillot/OCDB_RubenB0"); | |
542 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011_Align1", "alien://folder=/alice/cern.ch/user/j/jcastill/CorG4Fresmx05y015_BOff"); | |
543 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011_Align1", "alien://folder=/alice/cern.ch/user/j/jcastill/CorG4Fresmx05y015"); | |
544 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011_Align1", "alien://folder=/alice/cern.ch/user/j/jcastill/CorG4Gresmx05y015_BOff"); | |
545 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011_Align1", "alien://folder=/alice/cern.ch/user/j/jcastill/CorG4Gresmx05y015"); | |
546 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011_Align1", "alien://folder=/alice/cern.ch/user/j/jcastill/pbpb11wrk/CorG4Fresmx05y015_pp2PbPb"); | |
547 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011_Align1", "alien://folder=/alice/cern.ch/user/j/jcastill/pp11wrk/CorG4Fresmx05y015_pp2pp"); | |
548 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2011_Align1", ""); | |
549 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/pp12wrk/RAi00ab_p1_t1b_CDB"); | |
550 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/pp12wrk/RAi00ab_p1_t2b_CDB"); | |
551 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/pp12wrk/LHC12h_3ce"); | |
552 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/pp12wrk/LHC12h_4cf"); | |
553 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/pp12wrk/LHC12h_5cf"); | |
554 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/pp12wrk/LHC11Boffp2"); | |
555 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/pp12wrk/LHC12h_8dh"); | |
556 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/h/hupereir/CDB/LHC12_ReAlign_0"); | |
557 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/j/jcastill/pp12wrk/LHC12h_8di"); | |
558 | // muonResolution->ReAlign("", "alien://folder=/alice/cern.ch/user/h/hupereir/CDB/LHC12_ReAlign_new_0"); | |
559 | // muonResolution->ReAlign("alien://folder=/alice/cern.ch/user/p/ppillot/OCDB2012", "alien://folder=/alice/cern.ch/user/h/hupereir/CDB/LHC12_ReAlign_new_1"); | |
560 | ||
561 | muonResolution->SetAlignStorage("alien://folder=/alice/simulation/2008/v4-15-Release/Residual"); | |
562 | ||
563 | if (shiftHalfCh) { | |
564 | muonResolution->SetHalfChShift(halfChShiftNB, halfChShiftB); | |
565 | muonResolution->ShiftHalfCh(); | |
566 | muonResolution->PrintHalfChShift(); | |
567 | } | |
568 | if (shiftDE) { | |
569 | muonResolution->SetDEShift(deShiftNB, deShiftB); | |
570 | muonResolution->ShiftDE(); | |
571 | muonResolution->PrintDEShift(); | |
572 | } | |
573 | // muonResolution->ImproveTracks(kTRUE); | |
574 | AliMuonTrackCuts trackCuts("stdCuts", "stdCuts"); | |
575 | trackCuts.SetAllowDefaultParams(); | |
576 | trackCuts.SetIsMC(); | |
577 | trackCuts.SetFilterMask(AliMuonTrackCuts::kMuPdca); | |
578 | muonResolution->SetMuonTrackCuts(trackCuts); | |
00612ffc | 579 | |
580 | return muonResolution; | |
581 | ||
582 | } | |
583 | ||
584 | //______________________________________________________________________________ | |
585 | Bool_t GetChamberResolution(Int_t iStep, Double_t clusterResNB[10], Double_t clusterResB[10], Double_t clusterResNBErr[10], Double_t clusterResBErr[10]) | |
586 | { | |
587 | /// read the chamber resolution from the output file | |
588 | ||
589 | TFile* outFile = TFile::Open(Form("chamberResolution_step%d.root", iStep),"READ"); | |
590 | ||
591 | if (!outFile || !outFile->IsOpen()) { | |
592 | Error("GetChamberResolution","output file does not exist!"); | |
593 | return kFALSE; | |
594 | } | |
595 | ||
596 | TObjArray* summary = static_cast<TObjArray*>(outFile->FindObjectAny("ChamberRes")); | |
597 | TGraphErrors* gCombinedResidualXPerChSigma = (summary) ? static_cast<TGraphErrors*>(summary->FindObject("gCombinedResidualXPerChSigma")) : 0x0; | |
598 | TGraphErrors* gCombinedResidualYPerChSigma = (summary) ? static_cast<TGraphErrors*>(summary->FindObject("gCombinedResidualYPerChSigma")) : 0x0; | |
599 | ||
600 | if (!gCombinedResidualXPerChSigma || !gCombinedResidualYPerChSigma) { | |
601 | Error("GetChamberResolution","resolution graphs do not exist!"); | |
602 | return kFALSE; | |
603 | } | |
604 | ||
605 | Double_t dummy; | |
606 | for (Int_t i = 0; i < 10; i++) { | |
607 | gCombinedResidualXPerChSigma->GetPoint(i, dummy, clusterResNB[i]); | |
608 | gCombinedResidualYPerChSigma->GetPoint(i, dummy, clusterResB[i]); | |
609 | clusterResNBErr[i] = gCombinedResidualXPerChSigma->GetErrorY(i); | |
610 | clusterResBErr[i] = gCombinedResidualYPerChSigma->GetErrorY(i); | |
611 | } | |
612 | ||
613 | outFile->Close(); | |
09233fcd | 614 | //delete outFile; |
615 | ||
616 | return kTRUE; | |
617 | } | |
618 | ||
619 | //______________________________________________________________________________ | |
620 | Bool_t AddHalfChShift(Int_t iStep, Double_t halfChShiftNB[20], Double_t halfChShiftB[20], Double_t halfChShiftNBErr[20], Double_t halfChShiftBErr[20]) | |
621 | { | |
622 | /// read the chamber resolution from the output file | |
623 | ||
624 | TFile* outFile = TFile::Open(Form("chamberResolution_step%d.root", iStep),"READ"); | |
625 | ||
626 | if (!outFile || !outFile->IsOpen()) { | |
627 | Error("AddHalfChShift","output file does not exist!"); | |
628 | return kFALSE; | |
629 | } | |
630 | ||
631 | TObjArray* summary = static_cast<TObjArray*>(outFile->FindObjectAny("ChamberRes")); | |
632 | TGraphErrors* gResidualXPerHalfChMean = (summary) ? static_cast<TGraphErrors*>(summary->FindObject("gResidualXPerHalfChMean_ClusterIn")) : 0x0; | |
633 | TGraphErrors* gResidualYPerHalfChMean = (summary) ? static_cast<TGraphErrors*>(summary->FindObject("gResidualYPerHalfChMean_ClusterIn")) : 0x0; | |
634 | ||
635 | if (!gResidualXPerHalfChMean || !gResidualYPerHalfChMean) { | |
636 | Error("AddHalfChShift","half-chamber shift graphs do not exist!"); | |
637 | return kFALSE; | |
638 | } | |
639 | ||
640 | Double_t dummy, dx, dy; | |
641 | for (Int_t i = 0; i < 20; i++) { | |
642 | gResidualXPerHalfChMean->GetPoint(i, dummy, dx); | |
643 | halfChShiftNB[i] += dx; | |
644 | halfChShiftNBErr[i] = gResidualXPerHalfChMean->GetErrorY(i); | |
645 | gResidualYPerHalfChMean->GetPoint(i, dummy, dy); | |
646 | halfChShiftB[i] += dy; | |
647 | halfChShiftBErr[i] = gResidualYPerHalfChMean->GetErrorY(i); | |
648 | } | |
649 | ||
650 | outFile->Close(); | |
651 | //delete outFile; | |
652 | ||
653 | return kTRUE; | |
654 | } | |
655 | ||
656 | //______________________________________________________________________________ | |
657 | Bool_t AddDEShift(Int_t iStep, Double_t deShiftNB[200], Double_t deShiftB[200]) | |
658 | { | |
659 | /// read the chamber resolution from the output file | |
660 | ||
661 | TFile* outFile = TFile::Open(Form("chamberResolution_step%d.root", iStep),"READ"); | |
662 | ||
663 | if (!outFile || !outFile->IsOpen()) { | |
664 | Error("AddDEShift","output file does not exist!"); | |
665 | return kFALSE; | |
666 | } | |
667 | ||
668 | TObjArray* summary = static_cast<TObjArray*>(outFile->FindObjectAny("ChamberRes")); | |
669 | TGraphErrors* gResidualXPerDEMean = (summary) ? static_cast<TGraphErrors*>(summary->FindObject("gResidualXPerDEMean_ClusterIn")) : 0x0; | |
670 | TGraphErrors* gResidualYPerDEMean = (summary) ? static_cast<TGraphErrors*>(summary->FindObject("gResidualYPerDEMean_ClusterIn")) : 0x0; | |
671 | ||
672 | if (!gResidualXPerDEMean || !gResidualYPerDEMean) { | |
673 | Error("AddDEShift","DE shift graphs do not exist!"); | |
674 | return kFALSE; | |
675 | } | |
676 | ||
677 | Double_t dummy, dx, dy; | |
678 | nDE = gResidualXPerDEMean->GetN(); | |
679 | for (Int_t i = 0; i < nDE; i++) { | |
680 | gResidualXPerDEMean->GetPoint(i, dummy, dx); | |
681 | deShiftNB[i] += dx; | |
682 | gResidualYPerDEMean->GetPoint(i, dummy, dy); | |
683 | deShiftB[i] += dy; | |
684 | } | |
685 | ||
686 | outFile->Close(); | |
687 | //delete outFile; | |
00612ffc | 688 | |
689 | return kTRUE; | |
690 | } | |
691 | ||
692 | //______________________________________________________________________________ | |
693 | void AddMCHViews(TFile* file) | |
694 | { | |
695 | /// Get from the file the graphs containing data per DE, convert them into mchview objects and save them | |
696 | ||
697 | if ( ! AliMpDDLStore::Instance(false) ) | |
698 | { | |
699 | Warning("AddMCHViews","mapping was not loaded. Loading it from $ALICE_ROOT/OCDB"); | |
700 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); | |
701 | AliCDBManager::Instance()->SetRun(999999999); | |
702 | } | |
703 | ||
704 | AliMpCDB::LoadAll(); | |
705 | ||
706 | TObjArray* summary = static_cast<TObjArray*>(file->FindObjectAny("ChamberRes")); | |
707 | if (!summary) { | |
708 | Error("AddMCHViews","resolution graphs do not exist!"); | |
709 | return; | |
710 | } | |
711 | ||
712 | TGraphErrors* g = 0x0; | |
713 | g = static_cast<TGraphErrors*>(summary->FindObject("gCombinedResidualXPerDESigma")); | |
714 | if (g) { | |
715 | file->cd(); | |
09233fcd | 716 | AliMUONTrackerData* data = ConvertGraph(*g, "resoX"); |
717 | data->Write(); | |
718 | delete data; | |
00612ffc | 719 | } |
720 | ||
721 | g = static_cast<TGraphErrors*>(summary->FindObject("gCombinedResidualYPerDESigma")); | |
722 | if (g) { | |
723 | file->cd(); | |
09233fcd | 724 | AliMUONTrackerData* data = ConvertGraph(*g, "resoY"); |
725 | data->Write(); | |
726 | delete data; | |
00612ffc | 727 | } |
728 | ||
729 | g = static_cast<TGraphErrors*>(summary->FindObject("gResidualXPerDEMean_ClusterOut")); | |
730 | if (g) { | |
731 | file->cd(); | |
09233fcd | 732 | AliMUONTrackerData* data = ConvertGraph(*g, "shiftX"); |
733 | data->Write(); | |
734 | delete data; | |
00612ffc | 735 | } |
736 | ||
737 | g = static_cast<TGraphErrors*>(summary->FindObject("gResidualYPerDEMean_ClusterOut")); | |
738 | if (g) { | |
739 | file->cd(); | |
09233fcd | 740 | AliMUONTrackerData* data = ConvertGraph(*g, "shiftY"); |
741 | data->Write(); | |
742 | delete data; | |
00612ffc | 743 | } |
744 | } | |
745 | ||
746 | //______________________________________________________________________________ | |
747 | AliMUONTrackerData* ConvertGraph(TGraphErrors& g, const char* name) | |
748 | { | |
749 | /// Convert graph containing data per DE into mchview object | |
750 | ||
751 | AliMUON2DMap deValues(kFALSE); | |
752 | ||
753 | for ( Int_t i = 0 ; i < g.GetN(); ++i ) | |
754 | { | |
755 | double y = g.GetY()[i]; | |
756 | double ey = g.GetEY()[i]; | |
757 | int detElemId; | |
758 | sscanf(g.GetXaxis()->GetBinLabel(i+1),"%d",&detElemId); | |
759 | ||
760 | AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); | |
761 | ||
762 | AliMUONVCalibParam* param = new AliMUONCalibParamND(5, 1, detElemId, 0); | |
763 | ||
764 | Double_t sumn = 1000.0; | |
765 | Double_t sumw = sumn*y; | |
766 | Double_t sumw2 = (sumn-1)*ey*ey+sumw*sumw/sumn; | |
767 | ||
768 | param->SetValueAsDouble(0,0,sumw); | |
769 | param->SetValueAsDouble(0,1,sumw2); | |
770 | param->SetValueAsDouble(0,2,sumn); | |
771 | param->SetValueAsDouble(0,3,de->NofChannels()); | |
772 | param->SetValueAsDouble(0,4,1); | |
773 | ||
774 | deValues.Add(param); | |
775 | } | |
776 | ||
777 | AliMUONTrackerData* data = new AliMUONTrackerData(name,name,deValues,1); | |
778 | data->SetDimensionName(0,name); | |
779 | ||
780 | return data; | |
781 | } | |
782 | ||
783 | //______________________________________________________________________________ | |
784 | Int_t GetMode(TString smode, TString input) | |
785 | { | |
786 | if (smode == "local") { | |
787 | if ( input.EndsWith(".xml") ) return kInteractif_xml; | |
788 | else if ( input.EndsWith(".txt") ) return kInteractif_ESDList; | |
789 | else if ( input.EndsWith(".root") ) return kLocal; | |
4060971a | 790 | } else if (smode == "caf" || smode == "saf") return kProof; |
00612ffc | 791 | return -1; |
792 | } | |
793 | ||
794 | //______________________________________________________________________________ | |
795 | TChain* CreateChainFromCollection(const char *xmlfile) | |
796 | { | |
797 | // Create a chain from the collection of tags. | |
798 | if (!TGrid::Connect("alien://")) return NULL; | |
799 | ||
800 | TGridCollection* coll = TAlienCollection::Open(xmlfile); | |
801 | if (!coll) { | |
802 | Error("CreateChainFromCollection", "Cannot create the AliEn collection"); | |
803 | return NULL; | |
804 | } | |
805 | ||
806 | TGridResult* tagResult = coll->GetGridResult("",kFALSE,kFALSE); | |
807 | AliTagAnalysis *tagAna = new AliTagAnalysis("ESD"); | |
808 | tagAna->ChainGridTags(tagResult); | |
809 | ||
810 | AliRunTagCuts *runCuts = new AliRunTagCuts(); | |
811 | AliLHCTagCuts *lhcCuts = new AliLHCTagCuts(); | |
812 | AliDetectorTagCuts *detCuts = new AliDetectorTagCuts(); | |
813 | AliEventTagCuts *evCuts = new AliEventTagCuts(); | |
814 | ||
815 | // Check if the cuts configuration file was provided | |
816 | if (!gSystem->AccessPathName("ConfigureCuts.C")) | |
817 | gROOT->ProcessLine(Form(".x ConfigureCuts.C((AliRunTagCuts*)%p, (AliLHCTagCuts*)%p, (AliDetectorTagCuts*)%p," | |
818 | " (AliEventTagCuts*)%p)", runCuts, lhcCuts, detCuts, evCuts)); | |
819 | ||
820 | TChain *chain = tagAna->QueryTags(runCuts, lhcCuts, detCuts, evCuts); | |
821 | if (!chain || !chain->GetNtrees()) return NULL; | |
822 | chain->ls(); | |
823 | return chain; | |
824 | } | |
825 | ||
826 | //______________________________________________________________________________ | |
827 | TChain* CreateChainFromFile(const char *rootfile) | |
828 | { | |
829 | // Create a chain using the root file. | |
830 | TChain* chain = new TChain("esdTree"); | |
831 | chain->Add(rootfile); | |
832 | if (!chain->GetNtrees()) return NULL; | |
833 | chain->ls(); | |
834 | return chain; | |
835 | } | |
836 | ||
837 | //______________________________________________________________________________ | |
838 | TChain* CreateChainFromESDList(const char *esdList) | |
839 | { | |
840 | // Create a chain using tags from the run list. | |
841 | TChain* chain = new TChain("esdTree"); | |
842 | ifstream inFile(esdList); | |
843 | TString inFileName; | |
844 | if (inFile.is_open()) { | |
845 | while (! inFile.eof() ) { | |
846 | inFileName.ReadLine(inFile,kFALSE); | |
847 | if(!inFileName.EndsWith(".root")) continue; | |
848 | chain->Add(inFileName.Data()); | |
849 | } | |
850 | } | |
851 | inFile.close(); | |
852 | if (!chain->GetNtrees()) return NULL; | |
853 | chain->ls(); | |
854 | return chain; | |
855 | } | |
856 | ||
857 | //______________________________________________________________________________ | |
858 | TChain* CreateChain(Int_t mode, TString input) | |
859 | { | |
860 | printf("*******************************\n"); | |
861 | printf("*** Getting the Chain ***\n"); | |
862 | printf("*******************************\n"); | |
863 | if(mode == kInteractif_xml) return CreateChainFromCollection(input.Data()); | |
864 | else if (mode == kInteractif_ESDList) return CreateChainFromESDList(input.Data()); | |
865 | else if (mode == kLocal) return CreateChainFromFile(input.Data()); | |
866 | else return NULL; | |
867 | } | |
868 |