9 #include "TLorentzVector.h"
11 #include "AliAnalysisTask.h"
12 #include "AliAnalysisManager.h"
14 #include "AliGenEventHeader.h"
15 #include "AliESDEvent.h"
16 #include "AliESDInputHandler.h"
17 #include "AliMCEventHandler.h"
18 #include "AliMCEvent.h"
20 #include "AliVertexerTracks.h"
21 #include "AliESDVertex.h"
23 #include "AliProtonQAAnalysis.h"
24 #include "AliAnalysisTaskProtonsQA.h"
26 // Analysis task used for the QA of the (anti)proton analysis
27 // Author: Panos Cristakoglou
29 ClassImp(AliAnalysisTaskProtonsQA)
31 //________________________________________________________________________
32 AliAnalysisTaskProtonsQA::AliAnalysisTaskProtonsQA()
33 : AliAnalysisTask(), fESD(0), fMC(0),
34 fList0(0), fList1(0), fList2(0), fList3(0),
35 fList4(0), fList5(0), fList6(0), fList7(0),
37 fTriggerMode(kMB2), fProtonAnalysisMode(kTPC),
38 fVxMax(0), fVyMax(0), fVzMax(0) {
42 //________________________________________________________________________
43 AliAnalysisTaskProtonsQA::AliAnalysisTaskProtonsQA(const char *name)
44 : AliAnalysisTask(name, ""), fESD(0), fMC(0),
45 fList0(0), fList1(0), fList2(0), fList3(0),
46 fList4(0), fList5(0), fList6(0), fList7(0),
48 fTriggerMode(kMB2), fProtonAnalysisMode(kTPC),
49 fVxMax(0), fVyMax(0), fVzMax(0) {
52 // Define input and output slots here
53 // Input slot #0 works with a TChain
54 DefineInput(0, TChain::Class());
55 // Output slot #0 writes into a TList container
56 DefineOutput(0, TList::Class());
57 DefineOutput(1, TList::Class());
58 DefineOutput(2, TList::Class());
59 DefineOutput(3, TList::Class());
60 DefineOutput(4, TList::Class());
61 DefineOutput(5, TList::Class());
62 DefineOutput(6, TList::Class());
63 DefineOutput(7, TList::Class());
66 //________________________________________________________________________
67 void AliAnalysisTaskProtonsQA::ConnectInputData(Option_t *) {
68 // Connect ESD or AOD here
71 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
73 Printf("ERROR: Could not read chain from input slot 0");
75 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
78 Printf("ERROR: Could not get ESDInputHandler");
80 fESD = esdH->GetEvent();
83 AliMCEventHandler* mcH = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
85 Printf("ERROR: Could not retrieve MC event handler");
92 //________________________________________________________________________
93 void AliAnalysisTaskProtonsQA::CreateOutputObjects() {
97 Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
99 //proton analysis object
100 fProtonQAAnalysis = new AliProtonQAAnalysis();
101 fProtonQAAnalysis->SetEtaMode(); //in case you want eta-Pt instead of y-Pt
102 fProtonQAAnalysis->SetRunMCAnalysis();
103 fProtonQAAnalysis->SetRunEfficiencyAnalysis(kFALSE); //kTRUE if the cuts should be used in the reco and pid efficiencies
104 //fProtonQAAnalysis->SetMCProcessId(13);//4: weak decay - 13: hadronic interaction
105 //fProtonQAAnalysis->SetMotherParticlePDGCode(3122);//3122: Lambda
107 //Use of TPConly tracks
108 if(fProtonAnalysisMode == kTPC) {
109 //fProtonQAAnalysis->SetQAYPtBins(20, -1.0, 1.0, 28, 0.1, 1.5); //TPC only
110 fProtonQAAnalysis->SetQAYPtBins(10, -0.5, 0.5, 16, 0.5, 0.9); //TPC only
111 fProtonQAAnalysis->UseTPCOnly();
112 //fProtonQAAnalysis->SetTPCpid();
113 fProtonQAAnalysis->SetMinTPCClusters(100);
114 fProtonQAAnalysis->SetMaxChi2PerTPCCluster(2.2);
115 fProtonQAAnalysis->SetMaxCov11(0.5);
116 fProtonQAAnalysis->SetMaxCov22(0.5);
117 fProtonQAAnalysis->SetMaxCov33(0.5);
118 fProtonQAAnalysis->SetMaxCov44(0.5);
119 fProtonQAAnalysis->SetMaxCov55(0.5);
120 fProtonQAAnalysis->SetMaxSigmaToVertexTPC(2.0);
121 //fProtonQAAnalysis->SetMaxDCAXYTPC(1.5);
122 //fProtonQAAnalysis->SetMaxDCAZTPC(1.5);
124 //Use of HybridTPC tracks
125 else if(fProtonAnalysisMode == kHybrid) {
126 fProtonQAAnalysis->SetQAYPtBins(10, -0.5, 0.5, 16, 0.5, 0.9); //HybridTPC
127 fProtonQAAnalysis->UseHybridTPC();
128 fProtonQAAnalysis->SetTPCpid();
129 fProtonQAAnalysis->SetMinTPCClusters(110);
130 fProtonQAAnalysis->SetMaxChi2PerTPCCluster(2.2);
131 fProtonQAAnalysis->SetMaxCov11(0.5);
132 fProtonQAAnalysis->SetMaxCov22(0.5);
133 fProtonQAAnalysis->SetMaxCov33(0.5);
134 fProtonQAAnalysis->SetMaxCov44(0.5);
135 fProtonQAAnalysis->SetMaxCov55(0.5);
136 fProtonQAAnalysis->SetMaxSigmaToVertex(2.0);
137 /*fProtonQAAnalysis->SetMaxDCAXY(1.5);
138 fProtonQAAnalysis->SetMaxDCAZ(1.5);*/
139 //fProtonQAAnalysis->SetPointOnITSLayer6();
140 //fProtonQAAnalysis->SetPointOnITSLayer5();
141 //fProtonQAAnalysis->SetPointOnITSLayer4();
142 //fProtonQAAnalysis->SetPointOnITSLayer3();
143 //fProtonQAAnalysis->SetPointOnITSLayer2();
144 //fProtonQAAnalysis->SetPointOnITSLayer1();
145 //fProtonQAAnalysis->SetMinITSClusters(4);
148 else if(fProtonAnalysisMode == kGlobal) {
149 fProtonQAAnalysis->SetQAYPtBins(20, -1.0, 1.0, 48, 0.3, 1.5); //combined tracking
150 fProtonQAAnalysis->SetMinTPCClusters(110);
151 fProtonQAAnalysis->SetMaxChi2PerTPCCluster(2.2);
152 fProtonQAAnalysis->SetMaxCov11(0.5);
153 fProtonQAAnalysis->SetMaxCov22(0.5);
154 fProtonQAAnalysis->SetMaxCov33(0.5);
155 fProtonQAAnalysis->SetMaxCov44(0.5);
156 fProtonQAAnalysis->SetMaxCov55(0.5);
157 fProtonQAAnalysis->SetMaxSigmaToVertex(2.0);
158 //fProtonQAAnalysis->SetMaxDCAXY(2.0);
159 //fProtonQAAnalysis->SetMaxDCAZ(2.0);
160 fProtonQAAnalysis->SetTPCRefit();
161 fProtonQAAnalysis->SetPointOnITSLayer1();
162 fProtonQAAnalysis->SetPointOnITSLayer2();
163 //fProtonQAAnalysis->SetPointOnITSLayer3();
164 //fProtonQAAnalysis->SetPointOnITSLayer4();
165 fProtonQAAnalysis->SetPointOnITSLayer5();
166 fProtonQAAnalysis->SetPointOnITSLayer6();
167 fProtonQAAnalysis->SetMinITSClusters(5);
168 fProtonQAAnalysis->SetITSRefit();
169 fProtonQAAnalysis->SetESDpid();
172 fProtonQAAnalysis->SetPriorProbabilities(partFrac);
174 fList0 = new TList();
175 fList0 = fProtonQAAnalysis->GetGlobalQAList();
177 fList1 = new TList();
178 fList1 = fProtonQAAnalysis->GetPDGList();
180 fList2 = new TList();
181 fList2 = fProtonQAAnalysis->GetMCProcessesList();
183 fList3 = new TList();
184 fList3 = fProtonQAAnalysis->GetAcceptedCutList();
186 fList4 = new TList();
187 fList4 = fProtonQAAnalysis->GetRejectedCutList();
189 fList5 = new TList();
190 fList5 = fProtonQAAnalysis->GetAcceptedDCAList();
192 fList6 = new TList();
193 fList6 = fProtonQAAnalysis->GetEfficiencyQAList();
195 fList7 = new TList();
196 fList7 = fProtonQAAnalysis->GetVertexQAList();
199 //________________________________________________________________________
200 void AliAnalysisTaskProtonsQA::Exec(Option_t *) {
202 // Called for each event
205 Printf("ERROR: fESD not available");
210 Printf("ERROR: Could not retrieve MC event");
214 AliGenEventHeader *header = fMC->GenEventHeader();
216 Printf("ERROR: Could not retrieve the header");
220 AliStack* stack = fMC->Stack();
222 Printf("ERROR: Could not retrieve the stack");
226 if(IsEventTriggered(fESD,fTriggerMode)) {
227 fProtonQAAnalysis->RunVertexQA(header,
230 const AliESDVertex *vertex = GetVertex(fESD,fProtonAnalysisMode,
231 fVxMax,fVyMax,fVzMax);
233 fProtonQAAnalysis->RunQAAnalysis(stack, fESD, vertex);
234 fProtonQAAnalysis->RunMCAnalysis(stack);
235 fProtonQAAnalysis->RunEfficiencyAnalysis(stack, fESD, vertex);
250 //________________________________________________________________________
251 void AliAnalysisTaskProtonsQA::Terminate(Option_t *) {
252 // Draw result to the screen
253 // Called once at the end of the query
255 fList0 = dynamic_cast<TList*> (GetOutputData(0));
257 Printf("ERROR: fList0 not available");
260 fList1 = dynamic_cast<TList*> (GetOutputData(1));
262 Printf("ERROR: fList1 not available");
265 fList2 = dynamic_cast<TList*> (GetOutputData(2));
267 Printf("ERROR: fList2 not available");
270 fList3 = dynamic_cast<TList*> (GetOutputData(3));
272 Printf("ERROR: fList3 not available");
275 fList4 = dynamic_cast<TList*> (GetOutputData(4));
277 Printf("ERROR: fList4 not available");
280 fList5 = dynamic_cast<TList*> (GetOutputData(5));
282 Printf("ERROR: fList5 not available");
287 //________________________________________________________________________
288 Bool_t AliAnalysisTaskProtonsQA::IsEventTriggered(const AliESDEvent *esd,
289 TriggerMode trigger) {
290 // check if the event was triggered
291 ULong64_t triggerMask = esd->GetTriggerMask();
293 // definitions from p-p.cfg
294 ULong64_t spdFO = (1 << 14);
295 ULong64_t v0left = (1 << 11);
296 ULong64_t v0right = (1 << 12);
300 if (triggerMask & spdFO || ((triggerMask & v0left) || (triggerMask & v0right)))
305 if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right)))
310 if (triggerMask & spdFO)
319 //________________________________________________________________________
320 const AliESDVertex* AliAnalysisTaskProtonsQA::GetVertex(AliESDEvent* esd,
325 // Get the vertex from the ESD and returns it if the vertex is valid
326 // Second argument decides which vertex is used (this selects
327 // also the quality criteria that are applied)
328 const AliESDVertex* vertex = 0;
330 vertex = esd->GetPrimaryVertexSPD();
331 else if(mode == kTPC){
332 Double_t kBz = esd->GetMagneticField();
333 AliVertexerTracks vertexer(kBz);
334 vertexer.SetTPCMode();
335 AliESDVertex *vTPC = vertexer.FindPrimaryVertex(esd);
336 esd->SetPrimaryVertexTPC(vTPC);
337 for (Int_t i=0; i<esd->GetNumberOfTracks(); i++) {
338 AliESDtrack *t = esd->GetTrack(i);
339 t->RelateToVertexTPC(vTPC, kBz, kVeryBig);
342 vertex = esd->GetPrimaryVertexTPC();
344 else if(mode == kGlobal)
345 vertex = esd->GetPrimaryVertex();
347 Printf("GetVertex: ERROR: Invalid second argument %d", mode);
349 if(!vertex) return 0;
351 // check Ncontributors
352 if(vertex->GetNContributors() <= 0) return 0;
355 Double_t zRes = vertex->GetZRes();
356 if(zRes == 0) return 0;
359 if(TMath::Abs(vertex->GetXv()) > gVxMax) return 0;
360 if(TMath::Abs(vertex->GetYv()) > gVyMax) return 0;
361 if(TMath::Abs(vertex->GetZv()) > gVzMax) return 0;