9 #include "TLorentzVector.h"
11 #include "AliAnalysisTask.h"
12 #include "AliAnalysisManager.h"
14 #include "AliESDEvent.h"
15 #include "AliESDInputHandler.h"
16 #include "AliMCEventHandler.h"
17 #include "AliMCEvent.h"
19 #include "AliVertexerTracks.h"
20 #include "AliESDVertex.h"
22 #include "AliProtonQAAnalysis.h"
23 #include "AliAnalysisTaskProtonsQA.h"
25 // Analysis task used for the QA of the (anti)proton analysis
26 // Author: Panos Cristakoglou
28 ClassImp(AliAnalysisTaskProtonsQA)
30 //________________________________________________________________________
31 AliAnalysisTaskProtonsQA::AliAnalysisTaskProtonsQA()
32 : AliAnalysisTask(), fESD(0), fMC(0),
33 fList0(0), fList1(0), fList2(0), fList3(0), fList4(0), fList5(0),
35 fTriggerMode(kMB2), fProtonAnalysisMode(kTPC),
36 fVxMax(0), fVyMax(0), fVzMax(0) {
40 //________________________________________________________________________
41 AliAnalysisTaskProtonsQA::AliAnalysisTaskProtonsQA(const char *name)
42 : AliAnalysisTask(name, ""), fESD(0), fMC(0),
43 fList0(0), fList1(0), fList2(0), fList3(0), fList4(0), fList5(0),
45 fTriggerMode(kMB2), fProtonAnalysisMode(kTPC),
46 fVxMax(0), fVyMax(0), fVzMax(0) {
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());
54 DefineOutput(1, TList::Class());
55 DefineOutput(2, TList::Class());
56 DefineOutput(3, TList::Class());
57 DefineOutput(4, TList::Class());
58 DefineOutput(5, TList::Class());
61 //________________________________________________________________________
62 void AliAnalysisTaskProtonsQA::ConnectInputData(Option_t *) {
63 // Connect ESD or AOD here
66 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
68 Printf("ERROR: Could not read chain from input slot 0");
70 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
73 Printf("ERROR: Could not get ESDInputHandler");
75 fESD = esdH->GetEvent();
78 AliMCEventHandler* mcH = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
80 Printf("ERROR: Could not retrieve MC event handler");
86 //________________________________________________________________________
87 void AliAnalysisTaskProtonsQA::CreateOutputObjects() {
91 Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
93 //proton analysis object
94 fProtonQAAnalysis = new AliProtonQAAnalysis();
95 fProtonQAAnalysis->SetEtaMode(); //in case you want eta-Pt instead of y-Pt
96 fProtonQAAnalysis->SetRunMCAnalysis();
97 fProtonQAAnalysis->SetRunEfficiencyAnalysis(kFALSE); //kTRUE if the cuts should be used in the reco and pid efficiencies
98 //fProtonQAAnalysis->SetMCProcessId(13);//4: weak decay - 13: hadronic interaction
99 //fProtonQAAnalysis->SetMotherParticlePDGCode(3122);//3122: Lambda
101 //Use of TPConly tracks
102 if(fProtonAnalysisMode == kTPC) {
103 //fProtonQAAnalysis->SetQAYPtBins(20, -1.0, 1.0, 28, 0.1, 1.5); //TPC only
104 fProtonQAAnalysis->SetQAYPtBins(10, -0.5, 0.5, 16, 0.5, 0.9); //TPC only
105 fProtonQAAnalysis->UseTPCOnly();
106 //fProtonQAAnalysis->SetTPCpid();
107 fProtonQAAnalysis->SetMinTPCClusters(100);
108 fProtonQAAnalysis->SetMaxChi2PerTPCCluster(2.2);
109 fProtonQAAnalysis->SetMaxCov11(0.5);
110 fProtonQAAnalysis->SetMaxCov22(0.5);
111 fProtonQAAnalysis->SetMaxCov33(0.5);
112 fProtonQAAnalysis->SetMaxCov44(0.5);
113 fProtonQAAnalysis->SetMaxCov55(0.5);
114 fProtonQAAnalysis->SetMaxSigmaToVertexTPC(2.0);
115 //fProtonQAAnalysis->SetMaxDCAXYTPC(1.5);
116 //fProtonQAAnalysis->SetMaxDCAZTPC(1.5);
118 //Use of HybridTPC tracks
119 else if(fProtonAnalysisMode == kHybrid) {
120 fProtonQAAnalysis->SetQAYPtBins(10, -0.5, 0.5, 16, 0.5, 0.9); //HybridTPC
121 fProtonQAAnalysis->UseHybridTPC();
122 fProtonQAAnalysis->SetTPCpid();
123 fProtonQAAnalysis->SetMinTPCClusters(110);
124 fProtonQAAnalysis->SetMaxChi2PerTPCCluster(2.2);
125 fProtonQAAnalysis->SetMaxCov11(0.5);
126 fProtonQAAnalysis->SetMaxCov22(0.5);
127 fProtonQAAnalysis->SetMaxCov33(0.5);
128 fProtonQAAnalysis->SetMaxCov44(0.5);
129 fProtonQAAnalysis->SetMaxCov55(0.5);
130 fProtonQAAnalysis->SetMaxSigmaToVertex(2.0);
131 /*fProtonQAAnalysis->SetMaxDCAXY(1.5);
132 fProtonQAAnalysis->SetMaxDCAZ(1.5);*/
133 //fProtonQAAnalysis->SetPointOnITSLayer6();
134 //fProtonQAAnalysis->SetPointOnITSLayer5();
135 //fProtonQAAnalysis->SetPointOnITSLayer4();
136 //fProtonQAAnalysis->SetPointOnITSLayer3();
137 //fProtonQAAnalysis->SetPointOnITSLayer2();
138 //fProtonQAAnalysis->SetPointOnITSLayer1();
139 //fProtonQAAnalysis->SetMinITSClusters(4);
142 else if(fProtonAnalysisMode == kGlobal) {
143 fProtonQAAnalysis->SetQAYPtBins(20, -1.0, 1.0, 48, 0.3, 1.5); //combined tracking
144 fProtonQAAnalysis->SetMinTPCClusters(110);
145 fProtonQAAnalysis->SetMaxChi2PerTPCCluster(2.2);
146 fProtonQAAnalysis->SetMaxCov11(0.5);
147 fProtonQAAnalysis->SetMaxCov22(0.5);
148 fProtonQAAnalysis->SetMaxCov33(0.5);
149 fProtonQAAnalysis->SetMaxCov44(0.5);
150 fProtonQAAnalysis->SetMaxCov55(0.5);
151 fProtonQAAnalysis->SetMaxSigmaToVertex(2.0);
152 //fProtonQAAnalysis->SetMaxDCAXY(2.0);
153 //fProtonQAAnalysis->SetMaxDCAZ(2.0);
154 fProtonQAAnalysis->SetTPCRefit();
155 fProtonQAAnalysis->SetPointOnITSLayer1();
156 fProtonQAAnalysis->SetPointOnITSLayer2();
157 //fProtonQAAnalysis->SetPointOnITSLayer3();
158 //fProtonQAAnalysis->SetPointOnITSLayer4();
159 fProtonQAAnalysis->SetPointOnITSLayer5();
160 fProtonQAAnalysis->SetPointOnITSLayer6();
161 fProtonQAAnalysis->SetMinITSClusters(5);
162 fProtonQAAnalysis->SetITSRefit();
163 fProtonQAAnalysis->SetESDpid();
166 fProtonQAAnalysis->SetPriorProbabilities(partFrac);
168 fList0 = new TList();
169 fList0 = fProtonQAAnalysis->GetGlobalQAList();
171 fList1 = new TList();
172 fList1 = fProtonQAAnalysis->GetPDGList();
174 fList2 = new TList();
175 fList2 = fProtonQAAnalysis->GetMCProcessesList();
177 fList3 = new TList();
178 fList3 = fProtonQAAnalysis->GetAcceptedCutList();
180 fList4 = new TList();
181 fList4 = fProtonQAAnalysis->GetAcceptedDCAList();
183 fList5 = new TList();
184 fList5 = fProtonQAAnalysis->GetEfficiencyQAList();
187 //________________________________________________________________________
188 void AliAnalysisTaskProtonsQA::Exec(Option_t *) {
190 // Called for each event
193 Printf("ERROR: fESD not available");
198 Printf("ERROR: Could not retrieve MC event");
202 AliStack* stack = fMC->Stack();
204 Printf("ERROR: Could not retrieve the stack");
208 if(IsEventTriggered(fESD,fTriggerMode)) {
209 const AliESDVertex *vertex = GetVertex(fESD,fProtonAnalysisMode,
210 fVxMax,fVyMax,fVzMax);
212 fProtonQAAnalysis->RunQAAnalysis(stack, fESD, vertex);
213 fProtonQAAnalysis->RunMCAnalysis(stack);
214 fProtonQAAnalysis->RunEfficiencyAnalysis(stack, fESD, vertex);
227 //________________________________________________________________________
228 void AliAnalysisTaskProtonsQA::Terminate(Option_t *) {
229 // Draw result to the screen
230 // Called once at the end of the query
232 fList0 = dynamic_cast<TList*> (GetOutputData(0));
234 Printf("ERROR: fList0 not available");
237 fList1 = dynamic_cast<TList*> (GetOutputData(1));
239 Printf("ERROR: fList1 not available");
242 fList2 = dynamic_cast<TList*> (GetOutputData(2));
244 Printf("ERROR: fList2 not available");
247 fList3 = dynamic_cast<TList*> (GetOutputData(3));
249 Printf("ERROR: fList3 not available");
252 fList4 = dynamic_cast<TList*> (GetOutputData(4));
254 Printf("ERROR: fList4 not available");
257 fList5 = dynamic_cast<TList*> (GetOutputData(5));
259 Printf("ERROR: fList5 not available");
264 //________________________________________________________________________
265 Bool_t AliAnalysisTaskProtonsQA::IsEventTriggered(const AliESDEvent *esd,
266 TriggerMode trigger) {
267 // check if the event was triggered
268 ULong64_t triggerMask = esd->GetTriggerMask();
270 // definitions from p-p.cfg
271 ULong64_t spdFO = (1 << 14);
272 ULong64_t v0left = (1 << 11);
273 ULong64_t v0right = (1 << 12);
277 if (triggerMask & spdFO || ((triggerMask & v0left) || (triggerMask & v0right)))
282 if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right)))
287 if (triggerMask & spdFO)
296 //________________________________________________________________________
297 const AliESDVertex* AliAnalysisTaskProtonsQA::GetVertex(AliESDEvent* esd,
302 // Get the vertex from the ESD and returns it if the vertex is valid
303 // Second argument decides which vertex is used (this selects
304 // also the quality criteria that are applied)
305 const AliESDVertex* vertex = 0;
307 vertex = esd->GetPrimaryVertexSPD();
308 else if(mode == kTPC){
309 Double_t kBz = esd->GetMagneticField();
310 AliVertexerTracks vertexer(kBz);
311 vertexer.SetTPCMode();
312 AliESDVertex *vTPC = vertexer.FindPrimaryVertex(esd);
313 esd->SetPrimaryVertexTPC(vTPC);
314 for (Int_t i=0; i<esd->GetNumberOfTracks(); i++) {
315 AliESDtrack *t = esd->GetTrack(i);
316 t->RelateToVertexTPC(vTPC, kBz, kVeryBig);
319 vertex = esd->GetPrimaryVertexTPC();
321 else if(mode == kGlobal)
322 vertex = esd->GetPrimaryVertex();
324 Printf("GetVertex: ERROR: Invalid second argument %d", mode);
326 if(!vertex) return 0;
328 // check Ncontributors
329 if(vertex->GetNContributors() <= 0) return 0;
332 Double_t zRes = vertex->GetZRes();
333 if(zRes == 0) return 0;
336 if(TMath::Abs(vertex->GetXv()) > gVxMax) return 0;
337 if(TMath::Abs(vertex->GetYv()) > gVyMax) return 0;
338 if(TMath::Abs(vertex->GetZv()) > gVzMax) return 0;