]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/AliAnalysisTaskProtonsQA.cxx
Adding the files to be used for the QA of the proton analysis
[u/mrichter/AliRoot.git] / PWG2 / AliAnalysisTaskProtonsQA.cxx
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"
19
20 #include "PWG2spectra/SPECTRA/AliProtonAnalysis.h"
21 #include "AliAnalysisTaskProtonsQA.h"
22
23 // Analysis task used for the QA of the (anti)proton analysis
24 // Author: Panos Cristakoglou
25
26 ClassImp(AliAnalysisTaskProtonsQA)
27
28 //________________________________________________________________________ 
29 AliAnalysisTaskProtonsQA::AliAnalysisTaskProtonsQA()
30   : AliAnalysisTask(), fESD(0), fMC(0),
31     fList(0), fAnalysis(0) {
32     //Dummy constructor
33                                                                                                    
34 }
35
36 //________________________________________________________________________
37 AliAnalysisTaskProtonsQA::AliAnalysisTaskProtonsQA(const char *name) 
38 : AliAnalysisTask(name, ""), fESD(0), fAOD(0), fMC(0), fAnalysisType("ESD"),
39   fList(0), fAnalysis(0), 
40   fElectronFunction(0), fMuonFunction(0),
41   fPionFunction(0), fKaonFunction(0), fProtonFunction(0),
42   fFunctionUsed(kFALSE) { 
43   // Constructor
44
45   // Define input and output slots here
46   // Input slot #0 works with a TChain
47   DefineInput(0, TChain::Class());
48   // Output slot #0 writes into a TList container
49   DefineOutput(0, TList::Class());
50 }
51
52 //________________________________________________________________________
53 void AliAnalysisTaskProtonsQA::ConnectInputData(Option_t *) {
54   // Connect ESD or AOD here
55   // Called once
56
57   TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
58   if (!tree) {
59     Printf("ERROR: Could not read chain from input slot 0");
60   } else {
61     //tree->SetBranchStatus("*", kFALSE);
62     //tree->SetBranchStatus("Tracks.*", kTRUE);
63       
64     AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
65      
66     if (!esdH) {
67       Printf("ERROR: Could not get ESDInputHandler");
68     } else
69       fESD = esdH->GetEvent();
70   }
71
72   AliMCEventHandler* mcH = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
73   if (!mcH) {
74     Printf("ERROR: Could not retrieve MC event handler");
75   }
76   else
77     fMC = mcH->MCEvent();
78 }
79
80 //________________________________________________________________________
81 void AliAnalysisTaskProtonsQA::CreateOutputObjects() {
82   // Create histograms
83   // Called once
84   //Prior probabilities
85   Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
86   
87   //proton analysis object
88   fAnalysis = new AliProtonAnalysis();
89   fAnalysis->SetQAOn();
90
91   //Use of TPConly tracks                                                                                                                                                      
92   fAnalysis->SetQAYPtBins(10, -0.5, 0.5, 12, 0.5, 0.9); //TPC only
93   fAnalysis->UseTPCOnly();
94   fAnalysis->SetMinTPCClusters(50);
95   fAnalysis->SetMaxChi2PerTPCCluster(3.5);
96   fAnalysis->SetMaxCov11(2.0);
97   fAnalysis->SetMaxCov22(2.0);
98   fAnalysis->SetMaxCov33(0.5);
99   fAnalysis->SetMaxCov44(0.5);
100   fAnalysis->SetMaxCov55(2.0);
101   fAnalysis->SetMaxSigmaToVertexTPC(2.5);
102   fAnalysis->SetTPCRefit();
103   fAnalysis->SetTPCpid();
104
105   //Combined tracking
106   /*fAnalysis->SetQAYPtBins(20, -1.0, 1.0, 27, 0.4, 3.1); //combined tracking
107   fAnalysis->SetMinTPCClusters(50);
108   fAnalysis->SetMaxChi2PerTPCCluster(3.5);
109   fAnalysis->SetMaxCov11(2.0);
110   fAnalysis->SetMaxCov22(2.0);
111   fAnalysis->SetMaxCov33(0.5);
112   fAnalysis->SetMaxCov44(0.5);
113   fAnalysis->SetMaxCov55(2.0);
114   fAnalysis->SetMaxSigmaToVertexTPC(2.5);
115   fAnalysis->SetTPCRefit();
116   //ITS related cuts - to be used in the case of the analysis of global tracks                                                                                                
117   fAnalysis->SetMinITSClusters(5);                                                                                                                                          
118   fAnalysis->SetITSRefit();                                                                                                                                                  
119   fAnalysis->SetESDpid();*/
120
121   fAnalysis->SetPriorProbabilities(partFrac);
122
123   fList = new TList();
124   fList = GetGlobalQAList();
125 }
126
127 //________________________________________________________________________
128 void AliAnalysisTaskProtonsQA::Exec(Option_t *) {
129   // Main loop
130   // Called for each event
131   
132   if (!fESD) {
133     Printf("ERROR: fESD not available");
134     return;
135   }
136
137   if (!fMC) {
138     Printf("ERROR: Could not retrieve MC event");
139     return;
140   }
141   
142   AliStack* stack = fMC->Stack();
143   if (!stack) {
144     Printf("ERROR: Could not retrieve the stack");
145     return;
146   }
147   
148   fAnalysis->RunQA(stack, fESD);
149     
150   // Post output data.
151   PostData(0, fList);
152 }      
153
154 //________________________________________________________________________
155 void AliAnalysisTaskProtonsQA::Terminate(Option_t *) {
156   // Draw result to the screen
157   // Called once at the end of the query
158   
159   fList = dynamic_cast<TList*> (GetOutputData(0));
160   if (!fList) {
161     Printf("ERROR: fList not available");
162     return;
163   }
164 }
165
166