7 #include "TLorentzVector.h"
9 #include "AliAnalysisTask.h"
10 #include "AliAnalysisManager.h"
12 #include "AliESDEvent.h"
13 #include "AliESDInputHandler.h"
14 #include "AliAODEvent.h"
15 #include "AliAODInputHandler.h"
16 #include "AliMCEventHandler.h"
17 #include "AliMCEvent.h"
20 #include "AliProtonAnalysis.h"
21 #include "AliAnalysisTaskProtons.h"
23 // Analysis task creating a the 2d y-p_t spectrum of p and antip
24 // Author: Panos Cristakoglou
26 ClassImp(AliAnalysisTaskProtons)
28 //________________________________________________________________________
29 AliAnalysisTaskProtons::AliAnalysisTaskProtons()
30 : AliAnalysisTask(), fESD(0), fAOD(0), fMC(0),fAnalysisType("ESD"),
31 fList(0), fAnalysis(0),
32 fElectronFunction(0), fMuonFunction(0),
33 fPionFunction(0), fKaonFunction(0), fProtonFunction(0),
34 fFunctionUsed(kFALSE) {
38 //________________________________________________________________________
39 AliAnalysisTaskProtons::AliAnalysisTaskProtons(const char *name)
40 : AliAnalysisTask(name, ""), fESD(0), fAOD(0), fMC(0), fAnalysisType("ESD"),
41 fList(0), fAnalysis(0),
42 fElectronFunction(0), fMuonFunction(0),
43 fPionFunction(0), fKaonFunction(0), fProtonFunction(0),
44 fFunctionUsed(kFALSE) {
47 // Define input and output slots here
48 // Input slot #0 works with a TChain
49 DefineInput(0, TChain::Class());
50 // Output slot #0 writes into a TList container
51 DefineOutput(0, TList::Class());
54 //________________________________________________________________________
55 void AliAnalysisTaskProtons::ConnectInputData(Option_t *) {
56 // Connect ESD or AOD here
59 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
61 Printf("ERROR: Could not read chain from input slot 0");
63 // Disable all branches and enable only the needed ones
64 // The next two lines are different when data produced as AliESDEvent is read
65 if(fAnalysisType == "ESD") {
66 // In train mode branches can be disabled at the level of ESD handler (M.G.)
67 // tree->SetBranchStatus("*", kFALSE);
68 tree->SetBranchStatus("*Tracks.*", kTRUE);
70 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
73 Printf("ERROR: Could not get ESDInputHandler");
75 fESD = esdH->GetEvent();
77 else if(fAnalysisType == "AOD") {
78 AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
81 Printf("ERROR: Could not get AODInputHandler");
83 fAOD = aodH->GetEvent();
85 else if(fAnalysisType == "MC") {
86 AliMCEventHandler* mcH = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
88 Printf("ERROR: Could not retrieve MC event handler");
94 Printf("Wrong analysis type: Only ESD, AOD and MC types are allowed!");
98 //________________________________________________________________________
99 void AliAnalysisTaskProtons::CreateOutputObjects() {
102 Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
104 fAnalysis = new AliProtonAnalysis();
105 fAnalysis->InitHistograms(10,-1.0,1.0,30,0.1,3.1);
106 if(fAnalysisType == "ESD") {
107 //Use of TPConly tracks
108 fAnalysis->UseTPCOnly();
111 fAnalysis->SetMinTPCClusters(50);
112 fAnalysis->SetMaxChi2PerTPCCluster(3.5);
113 fAnalysis->SetMaxCov11(2.0);
114 fAnalysis->SetMaxCov22(2.0);
115 fAnalysis->SetMaxCov33(0.5);
116 fAnalysis->SetMaxCov44(0.5);
117 fAnalysis->SetMaxCov55(2.0);
118 fAnalysis->SetMaxSigmaToVertex(2.5);
119 fAnalysis->SetTPCRefit();
121 //ITS related cuts - to be used in the case of the analysis of global tracks
122 //fAnalysis->SetMinITSClusters(5);
123 //fAnalysis->SetITSRefit();
126 fAnalysis->SetPriorProbabilityFunctions(fElectronFunction,
132 fAnalysis->SetPriorProbabilities(partFrac);
135 fList->Add(fAnalysis->GetProtonYPtHistogram());
136 fList->Add(fAnalysis->GetAntiProtonYPtHistogram());
139 //________________________________________________________________________
140 void AliAnalysisTaskProtons::Exec(Option_t *) {
142 // Called for each event
144 if(fAnalysisType == "ESD") {
146 Printf("ERROR: fESD not available");
150 Printf("Proton ESD analysis task: There are %d tracks in this event", fESD->GetNumberOfTracks());
151 fAnalysis->Analyze(fESD);
154 else if(fAnalysisType == "AOD") {
156 Printf("ERROR: fAOD not available");
160 Printf("Proton AOD analysis task: There are %d tracks in this event", fAOD->GetNumberOfTracks());
161 fAnalysis->Analyze(fAOD);
164 else if(fAnalysisType == "MC") {
166 Printf("ERROR: Could not retrieve MC event");
170 AliStack* stack = fMC->Stack();
172 Printf("ERROR: Could not retrieve the stack");
175 Printf("Proton MC analysis task: There are %d primaries in this event", stack->GetNprimary());
176 fAnalysis->Analyze(stack);
183 //________________________________________________________________________
184 void AliAnalysisTaskProtons::Terminate(Option_t *) {
185 // Draw result to the screen
186 // Called once at the end of the query
188 fList = dynamic_cast<TList*> (GetOutputData(0));
190 Printf("ERROR: fList not available");
194 TH2F *fHistYPtProtons = (TH2F *)fList->At(0);
195 TH2F *fHistYPtAntiProtons = (TH2F *)fList->At(1);
197 TCanvas *c2 = new TCanvas("c2","p-\bar{p}",200,0,800,400);
198 c2->SetFillColor(10); c2->SetHighLightColor(10); c2->Divide(2,1);
200 c2->cd(1)->SetLeftMargin(0.15); c2->cd(1)->SetBottomMargin(0.15);
201 if (fHistYPtProtons) fHistYPtProtons->DrawCopy("colz");
202 c2->cd(2)->SetLeftMargin(0.15); c2->cd(2)->SetBottomMargin(0.15);
203 if (fHistYPtAntiProtons) fHistYPtAntiProtons->DrawCopy("colz");