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);
236 fProtonQAAnalysis->RunEfficiencyAnalysis(fMC, fESD, vertex);
251 //________________________________________________________________________
252 void AliAnalysisTaskProtonsQA::Terminate(Option_t *) {
253 // Draw result to the screen
254 // Called once at the end of the query
256 fList0 = dynamic_cast<TList*> (GetOutputData(0));
258 Printf("ERROR: fList0 not available");
261 fList1 = dynamic_cast<TList*> (GetOutputData(1));
263 Printf("ERROR: fList1 not available");
266 fList2 = dynamic_cast<TList*> (GetOutputData(2));
268 Printf("ERROR: fList2 not available");
271 fList3 = dynamic_cast<TList*> (GetOutputData(3));
273 Printf("ERROR: fList3 not available");
276 fList4 = dynamic_cast<TList*> (GetOutputData(4));
278 Printf("ERROR: fList4 not available");
281 fList5 = dynamic_cast<TList*> (GetOutputData(5));
283 Printf("ERROR: fList5 not available");
288 //________________________________________________________________________
289 Bool_t AliAnalysisTaskProtonsQA::IsEventTriggered(const AliESDEvent *esd,
290 TriggerMode trigger) {
291 // check if the event was triggered
292 ULong64_t triggerMask = esd->GetTriggerMask();
294 // definitions from p-p.cfg
295 ULong64_t spdFO = (1 << 14);
296 ULong64_t v0left = (1 << 11);
297 ULong64_t v0right = (1 << 12);
301 if (triggerMask & spdFO || ((triggerMask & v0left) || (triggerMask & v0right)))
306 if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right)))
311 if (triggerMask & spdFO)
320 //________________________________________________________________________
321 const AliESDVertex* AliAnalysisTaskProtonsQA::GetVertex(AliESDEvent* esd,
326 // Get the vertex from the ESD and returns it if the vertex is valid
327 // Second argument decides which vertex is used (this selects
328 // also the quality criteria that are applied)
329 const AliESDVertex* vertex = 0;
331 vertex = esd->GetPrimaryVertexSPD();
332 else if(mode == kTPC){
333 Double_t kBz = esd->GetMagneticField();
334 AliVertexerTracks vertexer(kBz);
335 vertexer.SetTPCMode();
336 AliESDVertex *vTPC = vertexer.FindPrimaryVertex(esd);
337 esd->SetPrimaryVertexTPC(vTPC);
338 for (Int_t i=0; i<esd->GetNumberOfTracks(); i++) {
339 AliESDtrack *t = esd->GetTrack(i);
340 t->RelateToVertexTPC(vTPC, kBz, kVeryBig);
343 vertex = esd->GetPrimaryVertexTPC();
345 else if(mode == kGlobal)
346 vertex = esd->GetPrimaryVertex();
348 Printf("GetVertex: ERROR: Invalid second argument %d", mode);
350 if(!vertex) return 0;
352 // check Ncontributors
353 if(vertex->GetNContributors() <= 0) return 0;
356 Double_t zRes = vertex->GetZRes();
357 if(zRes == 0) return 0;
360 if(TMath::Abs(vertex->GetXv()) > gVxMax) return 0;
361 if(TMath::Abs(vertex->GetYv()) > gVyMax) return 0;
362 if(TMath::Abs(vertex->GetZv()) > gVzMax) return 0;