]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/AliAnalysisTaskProtonsQA.cxx
Minor changes in the macros
[u/mrichter/AliRoot.git] / PWG2 / AliAnalysisTaskProtonsQA.cxx
CommitLineData
7b59a00b 1#include "TChain.h"
2#include "TTree.h"
3#include "TString.h"
4#include "TList.h"
5#include "TH2F.h"
6#include "TH1I.h"
7#include "TF1.h"
8#include "TCanvas.h"
9#include "TLorentzVector.h"
10
11#include "AliAnalysisTask.h"
12#include "AliAnalysisManager.h"
13
14#include "AliESDEvent.h"
15#include "AliESDInputHandler.h"
16#include "AliMCEventHandler.h"
17#include "AliMCEvent.h"
18#include "AliStack.h"
5429dd65 19#include "AliVertexerTracks.h"
20#include "AliESDVertex.h"
7b59a00b 21
5ae0977e 22#include "AliProtonQAAnalysis.h"
7b59a00b 23#include "AliAnalysisTaskProtonsQA.h"
24
25// Analysis task used for the QA of the (anti)proton analysis
26// Author: Panos Cristakoglou
27
28ClassImp(AliAnalysisTaskProtonsQA)
5429dd65 29
7b59a00b 30//________________________________________________________________________
31AliAnalysisTaskProtonsQA::AliAnalysisTaskProtonsQA()
32 : AliAnalysisTask(), fESD(0), fMC(0),
9c0b9f24 33 fList0(0), fList1(0), fList2(0), fList3(0), fList4(0), fList5(0),
5429dd65 34 fProtonQAAnalysis(0),
35 fTriggerMode(kMB2), fProtonAnalysisMode(kTPC),
36 fVxMax(0), fVyMax(0), fVzMax(0) {
37 //Dummy constructor
7b59a00b 38}
39
40//________________________________________________________________________
41AliAnalysisTaskProtonsQA::AliAnalysisTaskProtonsQA(const char *name)
5429dd65 42 : AliAnalysisTask(name, ""), fESD(0), fMC(0),
43 fList0(0), fList1(0), fList2(0), fList3(0), fList4(0), fList5(0),
44 fProtonQAAnalysis(0),
45 fTriggerMode(kMB2), fProtonAnalysisMode(kTPC),
46 fVxMax(0), fVyMax(0), fVzMax(0) {
7b59a00b 47 // Constructor
5429dd65 48
7b59a00b 49 // Define input and output slots here
50 // Input slot #0 works with a TChain
51 DefineInput(0, TChain::Class());
52 // Output slot #0 writes into a TList container
53 DefineOutput(0, TList::Class());
d4733690 54 DefineOutput(1, TList::Class());
55 DefineOutput(2, TList::Class());
5b8133c7 56 DefineOutput(3, TList::Class());
57 DefineOutput(4, TList::Class());
9c0b9f24 58 DefineOutput(5, TList::Class());
7b59a00b 59}
60
61//________________________________________________________________________
62void AliAnalysisTaskProtonsQA::ConnectInputData(Option_t *) {
63 // Connect ESD or AOD here
64 // Called once
65
66 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
67 if (!tree) {
68 Printf("ERROR: Could not read chain from input slot 0");
69 } else {
7b59a00b 70 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
71
72 if (!esdH) {
73 Printf("ERROR: Could not get ESDInputHandler");
74 } else
75 fESD = esdH->GetEvent();
76 }
77
78 AliMCEventHandler* mcH = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
79 if (!mcH) {
80 Printf("ERROR: Could not retrieve MC event handler");
81 }
82 else
83 fMC = mcH->MCEvent();
84}
85
86//________________________________________________________________________
87void AliAnalysisTaskProtonsQA::CreateOutputObjects() {
88 // Create histograms
89 // Called once
90 //Prior probabilities
91 Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
92
93 //proton analysis object
5429dd65 94 fProtonQAAnalysis = new AliProtonQAAnalysis();
95 fProtonQAAnalysis->SetRunMCAnalysis();
96 fProtonQAAnalysis->SetRunEfficiencyAnalysis(kTRUE,kFALSE); //kTRUE,kTRUE for eta-pT efficiencies and if the cuts should be used in the reco and pid efficiencies
97 //fProtonQAAnalysis->SetMCProcessId(13);//4: weak decay - 13: hadronic interaction
98 //fProtonQAAnalysis->SetMotherParticlePDGCode(3122);//3122: Lambda
7b59a00b 99
3a954fe7 100 //Use of TPConly tracks
5429dd65 101 if(fProtonAnalysisMode == kTPC) {
3e23254a 102 //fProtonQAAnalysis->SetQAYPtBins(20, -1.0, 1.0, 28, 0.1, 1.5); //TPC only
6667f3a7 103 fProtonQAAnalysis->SetQAYPtBins(10, -0.5, 0.5, 16, 0.5, 0.9); //TPC only
5429dd65 104 fProtonQAAnalysis->UseTPCOnly();
105 //fProtonQAAnalysis->SetTPCpid();
106 fProtonQAAnalysis->SetMinTPCClusters(100);
107 fProtonQAAnalysis->SetMaxChi2PerTPCCluster(2.2);
108 fProtonQAAnalysis->SetMaxCov11(0.5);
109 fProtonQAAnalysis->SetMaxCov22(0.5);
110 fProtonQAAnalysis->SetMaxCov33(0.5);
111 fProtonQAAnalysis->SetMaxCov44(0.5);
112 fProtonQAAnalysis->SetMaxCov55(0.5);
113 fProtonQAAnalysis->SetMaxSigmaToVertexTPC(2.0);
114 //fProtonQAAnalysis->SetMaxDCAXYTPC(1.5);
115 //fProtonQAAnalysis->SetMaxDCAZTPC(1.5);
116 }
0326e385 117 //Use of HybridTPC tracks
5429dd65 118 else if(fProtonAnalysisMode == kHybrid) {
6667f3a7 119 fProtonQAAnalysis->SetQAYPtBins(10, -0.5, 0.5, 16, 0.5, 0.9); //HybridTPC
5429dd65 120 fProtonQAAnalysis->UseHybridTPC();
121 fProtonQAAnalysis->SetTPCpid();
122 fProtonQAAnalysis->SetMinTPCClusters(110);
123 fProtonQAAnalysis->SetMaxChi2PerTPCCluster(2.2);
124 fProtonQAAnalysis->SetMaxCov11(0.5);
125 fProtonQAAnalysis->SetMaxCov22(0.5);
126 fProtonQAAnalysis->SetMaxCov33(0.5);
127 fProtonQAAnalysis->SetMaxCov44(0.5);
128 fProtonQAAnalysis->SetMaxCov55(0.5);
129 fProtonQAAnalysis->SetMaxSigmaToVertex(2.0);
130 /*fProtonQAAnalysis->SetMaxDCAXY(1.5);
131 fProtonQAAnalysis->SetMaxDCAZ(1.5);*/
3e23254a 132 //fProtonQAAnalysis->SetPointOnITSLayer6();
133 //fProtonQAAnalysis->SetPointOnITSLayer5();
134 //fProtonQAAnalysis->SetPointOnITSLayer4();
135 //fProtonQAAnalysis->SetPointOnITSLayer3();
136 //fProtonQAAnalysis->SetPointOnITSLayer2();
137 //fProtonQAAnalysis->SetPointOnITSLayer1();
138 //fProtonQAAnalysis->SetMinITSClusters(5);
5429dd65 139 }
7b59a00b 140 //Combined tracking
5429dd65 141 else if(fProtonAnalysisMode == kGlobal) {
3e23254a 142 fProtonQAAnalysis->SetQAYPtBins(20, -1.0, 1.0, 28, 0.1, 1.5); //combined tracking
5429dd65 143 fProtonQAAnalysis->SetMinTPCClusters(110);
144 fProtonQAAnalysis->SetMaxChi2PerTPCCluster(2.2);
145 fProtonQAAnalysis->SetMaxCov11(0.5);
146 fProtonQAAnalysis->SetMaxCov22(0.5);
147 fProtonQAAnalysis->SetMaxCov33(0.5);
148 fProtonQAAnalysis->SetMaxCov44(0.5);
149 fProtonQAAnalysis->SetMaxCov55(0.5);
150 fProtonQAAnalysis->SetMaxSigmaToVertex(2.0);
151 //fProtonQAAnalysis->SetMaxDCAXY(2.0);
152 //fProtonQAAnalysis->SetMaxDCAZ(2.0);
153 fProtonQAAnalysis->SetTPCRefit();
154 fProtonQAAnalysis->SetPointOnITSLayer1();
155 fProtonQAAnalysis->SetPointOnITSLayer2();
156 //fProtonQAAnalysis->SetPointOnITSLayer3();
157 //fProtonQAAnalysis->SetPointOnITSLayer4();
158 fProtonQAAnalysis->SetPointOnITSLayer5();
159 fProtonQAAnalysis->SetPointOnITSLayer6();
160 fProtonQAAnalysis->SetMinITSClusters(5);
161 fProtonQAAnalysis->SetITSRefit();
162 fProtonQAAnalysis->SetESDpid();
163 }
7b59a00b 164
5429dd65 165 fProtonQAAnalysis->SetPriorProbabilities(partFrac);
166
d4733690 167 fList0 = new TList();
5429dd65 168 fList0 = fProtonQAAnalysis->GetGlobalQAList();
d4733690 169
170 fList1 = new TList();
5429dd65 171 fList1 = fProtonQAAnalysis->GetPDGList();
d4733690 172
173 fList2 = new TList();
5429dd65 174 fList2 = fProtonQAAnalysis->GetMCProcessesList();
5b8133c7 175
176 fList3 = new TList();
5429dd65 177 fList3 = fProtonQAAnalysis->GetAcceptedCutList();
5b8133c7 178
179 fList4 = new TList();
5429dd65 180 fList4 = fProtonQAAnalysis->GetAcceptedDCAList();
9c0b9f24 181
182 fList5 = new TList();
5429dd65 183 fList5 = fProtonQAAnalysis->GetEfficiencyQAList();
7b59a00b 184}
185
186//________________________________________________________________________
187void AliAnalysisTaskProtonsQA::Exec(Option_t *) {
188 // Main loop
189 // Called for each event
190
191 if (!fESD) {
192 Printf("ERROR: fESD not available");
193 return;
194 }
5429dd65 195
7b59a00b 196 if (!fMC) {
197 Printf("ERROR: Could not retrieve MC event");
198 return;
199 }
200
201 AliStack* stack = fMC->Stack();
202 if (!stack) {
203 Printf("ERROR: Could not retrieve the stack");
204 return;
205 }
206
5429dd65 207 if(IsEventTriggered(fESD,fTriggerMode)) {
208 const AliESDVertex *vertex = GetVertex(fESD,fProtonAnalysisMode,
209 fVxMax,fVyMax,fVzMax);
210 if(vertex) {
6667f3a7 211 fProtonQAAnalysis->RunQAAnalysis(stack, fESD, vertex);
5429dd65 212 fProtonQAAnalysis->RunMCAnalysis(stack);
6667f3a7 213 fProtonQAAnalysis->RunEfficiencyAnalysis(stack, fESD, vertex);
5429dd65 214 }//accepted vertex
215 }//triggered event
216
7b59a00b 217 // Post output data.
d4733690 218 PostData(0, fList0);
219 PostData(1, fList1);
220 PostData(2, fList2);
5b8133c7 221 PostData(3, fList3);
222 PostData(4, fList4);
9c0b9f24 223 PostData(5, fList5);
7b59a00b 224}
225
226//________________________________________________________________________
227void AliAnalysisTaskProtonsQA::Terminate(Option_t *) {
228 // Draw result to the screen
229 // Called once at the end of the query
230
d4733690 231 fList0 = dynamic_cast<TList*> (GetOutputData(0));
232 if (!fList0) {
5429dd65 233 Printf("ERROR: fList0 not available");
234 return;
235 }
236 fList1 = dynamic_cast<TList*> (GetOutputData(1));
237 if (!fList1) {
238 Printf("ERROR: fList1 not available");
239 return;
240 }
241 fList2 = dynamic_cast<TList*> (GetOutputData(2));
242 if (!fList2) {
243 Printf("ERROR: fList2 not available");
244 return;
245 }
246 fList3 = dynamic_cast<TList*> (GetOutputData(3));
247 if (!fList3) {
248 Printf("ERROR: fList3 not available");
249 return;
250 }
251 fList4 = dynamic_cast<TList*> (GetOutputData(4));
252 if (!fList4) {
253 Printf("ERROR: fList4 not available");
7b59a00b 254 return;
255 }
5429dd65 256 fList5 = dynamic_cast<TList*> (GetOutputData(5));
257 if (!fList5) {
258 Printf("ERROR: fList5 not available");
259 return;
260 }
261}
262
263//________________________________________________________________________
264Bool_t AliAnalysisTaskProtonsQA::IsEventTriggered(const AliESDEvent *esd,
265 TriggerMode trigger) {
266 // check if the event was triggered
267 ULong64_t triggerMask = esd->GetTriggerMask();
268
269 // definitions from p-p.cfg
270 ULong64_t spdFO = (1 << 14);
271 ULong64_t v0left = (1 << 11);
272 ULong64_t v0right = (1 << 12);
273
274 switch (trigger) {
275 case kMB1: {
276 if (triggerMask & spdFO || ((triggerMask & v0left) || (triggerMask & v0right)))
277 return kTRUE;
278 break;
279 }
280 case kMB2: {
281 if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right)))
282 return kTRUE;
283 break;
284 }
285 case kSPDFASTOR: {
286 if (triggerMask & spdFO)
287 return kTRUE;
288 break;
289 }
290 }//switch
291
292 return kFALSE;
7b59a00b 293}
294
5429dd65 295//________________________________________________________________________
296const AliESDVertex* AliAnalysisTaskProtonsQA::GetVertex(AliESDEvent* esd,
297 AnalysisMode mode,
298 Double_t gVxMax,
299 Double_t gVyMax,
300 Double_t gVzMax) {
301 // Get the vertex from the ESD and returns it if the vertex is valid
302 // Second argument decides which vertex is used (this selects
303 // also the quality criteria that are applied)
304 const AliESDVertex* vertex = 0;
305 if(mode == kHybrid)
306 vertex = esd->GetPrimaryVertexSPD();
307 else if(mode == kTPC){
308 Double_t kBz = esd->GetMagneticField();
309 AliVertexerTracks vertexer(kBz);
310 vertexer.SetTPCMode();
311 AliESDVertex *vTPC = vertexer.FindPrimaryVertex(esd);
312 esd->SetPrimaryVertexTPC(vTPC);
313 for (Int_t i=0; i<esd->GetNumberOfTracks(); i++) {
314 AliESDtrack *t = esd->GetTrack(i);
315 t->RelateToVertexTPC(vTPC, kBz, kVeryBig);
316 }
317 delete vTPC;
318 vertex = esd->GetPrimaryVertexTPC();
319 }
320 else if(mode == kGlobal)
321 vertex = esd->GetPrimaryVertex();
322 else
323 Printf("GetVertex: ERROR: Invalid second argument %d", mode);
324
325 if(!vertex) return 0;
326
327 // check Ncontributors
328 if(vertex->GetNContributors() <= 0) return 0;
329
330 // check resolution
331 Double_t zRes = vertex->GetZRes();
332 if(zRes == 0) return 0;
333
334 //check position
335 if(TMath::Abs(vertex->GetXv()) > gVxMax) return 0;
336 if(TMath::Abs(vertex->GetYv()) > gVyMax) return 0;
337 if(TMath::Abs(vertex->GetZv()) > gVzMax) return 0;
338
339 return vertex;
340}
341
342
343
7b59a00b 344