6 #include "TLorentzVector.h"
8 #include "AliAnalysisTask.h"
9 #include "AliAnalysisManager.h"
11 #include "AliESDEvent.h"
12 #include "AliESDInputHandler.h"
14 #include "PWG2spectra/SPECTRA/AliProtonAnalysis.h"
15 #include "AliAnalysisTaskProtons.h"
17 // Analysis task creating a the 2d y-p_t spectrum of p and antip
18 // Author: Panos Cristakoglou
20 ClassImp(AliAnalysisTaskProtons)
22 //________________________________________________________________________
23 AliAnalysisTaskProtons::AliAnalysisTaskProtons(const char *name)
24 : AliAnalysisTask(name, ""), fESD(0), fList(0), fAnalysis(0) {
27 // Define input and output slots here
28 // Input slot #0 works with a TChain
29 DefineInput(0, TChain::Class());
30 // Output slot #0 writes into a TList container
31 DefineOutput(0, TList::Class());
34 //________________________________________________________________________
35 void AliAnalysisTaskProtons::ConnectInputData(Option_t *) {
36 // Connect ESD or AOD here
39 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
41 Printf("ERROR: Could not read chain from input slot 0");
43 // Disable all branches and enable only the needed ones
44 // The next two lines are different when data produced as AliESDEvent is read
45 tree->SetBranchStatus("*", kFALSE);
46 tree->SetBranchStatus("fTracks.*", kTRUE);
48 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
51 Printf("ERROR: Could not get ESDInputHandler");
53 fESD = esdH->GetEvent();
57 //________________________________________________________________________
58 void AliAnalysisTaskProtons::CreateOutputObjects() {
61 Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
63 fAnalysis = new AliProtonAnalysis();
64 fAnalysis->InitHistograms(10,-1.0,1.0,30,0.1,3.1);
65 fAnalysis->SetMinTPCClusters(50);
66 fAnalysis->SetMinITSClusters(1);
67 fAnalysis->SetMaxChi2PerTPCCluster(3.5);
68 fAnalysis->SetMaxCov11(2.0);
69 fAnalysis->SetMaxCov22(2.0);
70 fAnalysis->SetMaxCov33(0.5);
71 fAnalysis->SetMaxCov44(0.5);
72 fAnalysis->SetMaxCov55(2.0);
73 fAnalysis->SetMaxSigmaToVertex(3.);
74 fAnalysis->SetITSRefit();
75 fAnalysis->SetTPCRefit();
76 fAnalysis->SetPriorProbabilities(partFrac);
79 //________________________________________________________________________
80 void AliAnalysisTaskProtons::Exec(Option_t *) {
82 // Called for each event
85 Printf("ERROR: fESD not available");
89 Printf("Task2: There are %d tracks in this event", fESD->GetNumberOfTracks());
90 fAnalysis->Analyze(fESD);
92 fList->Add(fAnalysis->GetProtonYPtHistogram());
93 fList->Add(fAnalysis->GetAntiProtonYPtHistogram());
99 //________________________________________________________________________
100 void AliAnalysisTaskProtons::Terminate(Option_t *) {
101 // Draw result to the screen
102 // Called once at the end of the query
104 fList = dynamic_cast<TList*> (GetOutputData(0));
106 Printf("ERROR: fList not available");
110 TH2F *fHistYPtProtons = (TH2F *)fList->At(0);
111 TH2F *fHistYPtAntiProtons = (TH2F *)fList->At(1);
113 TCanvas *c2 = new TCanvas("c2","p-\bar{p}",200,0,800,400);
114 c2->SetFillColor(10); c2->SetHighLightColor(10); c2->Divide(2,1);
116 c2->cd(1)->SetLeftMargin(0.15); c2->cd(1)->SetBottomMargin(0.15);
117 if (fHistYPtProtons) fHistYPtProtons->DrawCopy("colz");
118 c2->cd(2)->SetLeftMargin(0.15); c2->cd(2)->SetBottomMargin(0.15);
119 if (fHistYPtAntiProtons) fHistYPtAntiProtons->DrawCopy("colz");