]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG1/macros/RunPerformanceTask.C
Updates (Jacek)
[u/mrichter/AliRoot.git] / PWG1 / macros / RunPerformanceTask.C
1 // Macro to run TPC performance
2
3 /*
4   //1. Run locally e.g.
5
6   gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/LoadMyLibs.C");
7
8   gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
9   TChain* chain = CreateESDChain("esd_v4-16-Rev-08-grid.txt", 10, 0);
10   chain->Lookup();
11
12   gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/RunPerformanceTask.C");
13   RunPerformanceTask(chain, kTRUE, kFALSE);
14
15   //2. Run on PROOF Lite e.g.
16
17   TProof::Open(""); 
18
19   gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/ProofEnableAliRoot.C");
20   ProofEnableAliRoot("/u/jacek/alice/AliRoot/HEAD/");
21
22   gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
23   TChain* chain = CreateESDChain("esd_v4-16-Rev-08-grid.txt", 500, 0);
24   //TChain* chain = CreateESDChain("esd_TRUNK_flat_ideal_geom.txt", 50, 0);
25   chain->Lookup();
26
27   gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/RunPerformanceTask.C");
28   RunPerformanceTask(chain, kTRUE, kTRUE); 
29
30
31   //3. Run only on static PROOF at GSI e.g.
32
33   TProof::Reset("jacek@lxgrid5.gsi.de");
34   TProofMgr * proofmgr = TProof::Mgr("jacek@lxgrid5.gsi.de");
35   proofmgr->SetROOTVersion("523-02");
36   TProof * proof = proofmgr->CreateSession();
37   proof->SetParameter("PROOF_MaxSlavesPerNode", (Long_t)10000);
38
39   gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/ProofEnableAliRoot.C");
40   ProofEnableAliRoot("/u/jacek/alice/AliRoot/HEAD/");
41
42   gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
43   TChain* chain = CreateESDChain("esd_v4-16-Rev-08-grid.txt", 200, 0);
44   chain->Lookup();
45
46   gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/RunPerformanceTask.C");
47   RunPerformanceTask(chain, kTRUE, kTRUE); 
48
49   //4. Make final spectra and store them in the
50   // output folder and generate control pictures e.g.
51
52   TFile f("TPC.Performance.root");
53   AliPerformanceRes * compObjRes = (AliPerformanceRes*)coutput->FindObject("AliPerformanceResTPCInner");
54   compObjRes->Analyse();
55   compObjRes->GetAnalysisFolder()->ls("*");
56   compObjRes->PrintHisto(kTRUE,"PerformanceResTPCInnerQA.ps");
57   TFile fout("AnalysedResTPCInner.root","recreate");
58   compObjRes->GetAnalysisFolder()->Write();
59   fout.Close();
60   f.Close();
61
62
63 */
64
65 //_____________________________________________________________________________
66 void RunPerformanceTask(TChain *chain, Bool_t bUseMCInfo=kTRUE, Bool_t bProof=kTRUE)
67 {
68   if(!chain) 
69   {
70     AliDebug(AliLog::kError, "ERROR: No input chain available");
71     return;
72   }
73
74   // set Proof
75   if(bProof) { 
76
77     /*
78     // ONLY FOR GSI
79     TProof::Reset("jacek@lxgrid5.gsi.de");
80     TProofMgr * proofmgr = TProof::Mgr("jacek@lxgrid5.gsi.de");
81     proofmgr->SetROOTVersion("523-02");
82     TProof * proof = proofmgr->CreateSession();
83     proof->SetParameter("PROOF_MaxSlavesPerNode", (Long_t)10000);
84     */
85
86     /*
87     //cout << "*** START PROOF Lite SESSION ***" << endl;
88     TProof::Open(""); 
89     gROOT->LoadMacro("ProofEnableAliRoot.C");
90     ProofEnableAliRoot("/u/jacek/alice/AliRoot/HEAD/");
91     */
92
93   }
94   // set magnetic field
95   TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 2, 1., 1., 10., AliMagF::k5kG));
96
97   //
98   // Create global cuts objects 
99   //
100
101   // Create ESD track reconstruction cuts
102   AliRecInfoCuts *pRecInfoCuts = new AliRecInfoCuts(); 
103   if(pRecInfoCuts) {
104     pRecInfoCuts->SetMaxDCAToVertexXY(3.0);
105     pRecInfoCuts->SetMaxDCAToVertexZ(3.0);
106     pRecInfoCuts->SetMinNClustersTPC(50);
107     pRecInfoCuts->SetMinNClustersITS(2);
108     pRecInfoCuts->SetHistogramsOn(kFALSE); 
109   } else {
110     AliDebug(AliLog::kError, "ERROR: Cannot create AliRecInfoCuts object");
111   }
112
113   // Create MC track reconstruction cuts
114   AliMCInfoCuts  *pMCInfoCuts = new AliMCInfoCuts();
115   if(pMCInfoCuts) {
116     pMCInfoCuts->SetMinTrackLength(70);
117   } else {
118     AliDebug(AliLog::kError, "ERROR: Cannot AliMCInfoCuts object");
119   }
120
121   //
122   // Create performance objects and set cuts 
123   //
124   const Int_t kTPC = 0; const Int_t kTPCITS = 1; const Int_t kConstrained = 2; const Int_t kTPCInner = 3;
125
126   //
127   // Resolution
128   //
129   AliPerformanceRes *pCompRes0 = new AliPerformanceRes("AliPerformanceRes","AliPerformanceRes",kTPC,kFALSE); 
130   if(!pCompRes0) {
131     AliDebug(AliLog::kError, "ERROR: Cannot create AliPerformanceRes object");
132   }
133   pCompRes0->SetAliRecInfoCuts(pRecInfoCuts);
134   pCompRes0->SetAliMCInfoCuts(pMCInfoCuts);
135
136   AliPerformanceRes *pCompRes3 = new AliPerformanceRes("AliPerformanceResTPCInner","AliPerformanceResTPCInner",kTPCInner,kFALSE); 
137   if(!pCompRes3) {
138     AliDebug(AliLog::kError, "ERROR: Cannot create AliPerformanceResInnerTPC object");
139   }
140   pCompRes3->SetAliRecInfoCuts(pRecInfoCuts);
141   pCompRes3->SetAliMCInfoCuts(pMCInfoCuts);
142   //
143   // Efficiency
144   //
145   AliPerformanceEff *pCompEff0 = new AliPerformanceEff("AliPerformanceEff","AliPerformanceEff",kTPC,kFALSE); 
146   if(!pCompEff0) {
147     AliDebug(AliLog::kError, "ERROR: Cannot create AliPerformanceEff object");
148   }
149   pCompEff0->SetAliRecInfoCuts(pRecInfoCuts);
150   pCompEff0->SetAliMCInfoCuts(pMCInfoCuts);
151   //
152   // dEdx
153   //
154   AliPerformanceDEdx *pCompDEdx3 = new AliPerformanceDEdx("AliPerformanceDEdxTPCInner","AliPerformanceDEdxTPCInner",kTPCInner,kFALSE); 
155   if(!pCompDEdx3) {
156     AliDebug(AliLog::kError, "ERROR: Cannot create AliPerformanceDEdxTPCInner object");
157   }
158   pCompDEdx3->SetAliRecInfoCuts(pRecInfoCuts);
159   pCompDEdx3->SetAliMCInfoCuts(pMCInfoCuts);
160   //
161   // DCA
162   //
163   AliPerformanceDCA *pCompDCA0 = new AliPerformanceDCA("AliPerformanceDCA","AliPerformanceDCA",kTPC,kFALSE); 
164   if(!pCompDCA0) {
165     AliDebug(AliLog::kError, "ERROR: Cannot create AliPerformanceDCA object");
166   }
167   pCompDCA0->SetAliRecInfoCuts(pRecInfoCuts);
168   pCompDCA0->SetAliMCInfoCuts(pMCInfoCuts);
169   //
170   // TPC performance
171   //
172   AliPerformanceTPC *pCompTPC0 = new AliPerformanceTPC("AliPerformanceTPC","AliPerformanceTPC",kTPC,kFALSE); 
173   if(!pCompTPC0) {
174     AliDebug(AliLog::kError, "ERROR: Cannot create AliPerformanceTPC object");
175   }
176   pCompTPC0->SetAliRecInfoCuts(pRecInfoCuts);
177   pCompTPC0->SetAliMCInfoCuts(pMCInfoCuts);
178  
179   // Swtich off all AliInfo (too much output!!!)
180   AliLog::SetGlobalLogLevel(AliLog::kError);
181
182   // Create the analysis manager
183   AliAnalysisManager *mgr = new AliAnalysisManager;
184
185   // Create task
186   AliPerformanceTask *task = new AliPerformanceTask("Performance","TPC Performance");
187   if (bUseMCInfo) task->SetUseMCInfo(kTRUE);
188   task->AddPerformanceObject( pCompRes0 );
189   task->AddPerformanceObject( pCompRes3 );
190   task->AddPerformanceObject( pCompEff0 );
191   task->AddPerformanceObject( pCompDEdx3 );
192   task->AddPerformanceObject( pCompDCA0 );
193   task->AddPerformanceObject( pCompTPC0 );
194
195   // Add task
196   mgr->AddTask(task);
197
198   // Add ESD handler
199   AliESDInputHandler* esdH = new AliESDInputHandler;
200   //esdH->SetInactiveBranches("*");
201   mgr->SetInputEventHandler(esdH);
202
203   if(bUseMCInfo) {
204   // Enable MC event handler
205     AliMCEventHandler* handler = new AliMCEventHandler;
206     //handler->SetReadTR(kFALSE);
207     handler->SetReadTR(kTRUE);
208     mgr->SetMCtruthEventHandler(handler);
209   }
210
211   // Create input chain
212   //gROOT->LoadMacro("CreateESDChain.C");
213   //TChain* chain = CreateESDChain(fileList, NumberOfFiles, fromFile);
214   //if(!chain) {
215   //  printf("ERROR: chain cannot be created\n");
216   //  return;
217   //}
218
219   // Create containers for input
220   //AliAnalysisDataContainer *cinput = mgr->CreateContainer("cchain", TChain::Class(), AliAnalysisManager::kInputContainer);
221   AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
222   mgr->ConnectInput(task, 0, cinput);
223
224   // Create containers for output
225   AliAnalysisDataContainer *coutput = mgr->CreateContainer("coutput", TList::Class(), AliAnalysisManager::kOutputContainer, Form("TPC.%s.root", task->GetName()));
226   mgr->ConnectOutput(task, 0, coutput);
227
228   // Enable debug printouts
229   mgr->SetDebugLevel(0);
230
231   if (!mgr->InitAnalysis())
232     return;
233
234   mgr->PrintStatus();
235
236   if(bProof) mgr->StartAnalysis("proof",chain);
237   else mgr->StartAnalysis("local",chain);
238 }
239