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