10 #include "AliAnalysisTask.h"
11 #include "AliAnalysisManager.h"
13 #include "AliESDEvent.h"
14 #include "AliESDInputHandler.h"
15 #include "AliAODEvent.h"
16 #include "AliAODInputHandler.h"
17 #include "AliMCEventHandler.h"
18 #include "AliMCEvent.h"
20 #include "AliESDVertex.h"
22 #include "AliProtonAnalysis.h"
23 #include "AliProtonAnalysisBase.h"
24 #include "AliAnalysisTaskProtons.h"
26 //-----------------------------------------------------------------
27 // AliAnalysisTakProtons class
28 // This is the task to run the \bar{p}/p analysis
29 // Origin: Panos Christakoglou | Panos.Christakoglou@cern.ch
30 //-----------------------------------------------------------------
32 ClassImp(AliAnalysisTaskProtons)
34 //________________________________________________________________________
35 AliAnalysisTaskProtons::AliAnalysisTaskProtons()
36 : AliAnalysisTask(), fESD(0), fAOD(0), fMC(0),
37 fList(0), fProtonAnalysis(0) {
42 //________________________________________________________________________
43 AliAnalysisTaskProtons::AliAnalysisTaskProtons(const char *name)
44 : AliAnalysisTask(name, ""), fESD(0), fAOD(0), fMC(0),
45 fList(0), fProtonAnalysis(0) {
48 // Define input and output slots here
49 // Input slot #0 works with a TChain
50 DefineInput(0, TChain::Class());
51 // Output slot #0 writes into a TList container
52 DefineOutput(0, TList::Class());
55 //________________________________________________________________________
56 void AliAnalysisTaskProtons::ConnectInputData(Option_t *) {
57 // Connect ESD or AOD here
59 TString gAnalysisLevel = dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetAnalysisLevel();
61 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
63 Printf("ERROR: Could not read chain from input slot 0");
65 if(gAnalysisLevel == "ESD") {
66 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
69 Printf("ERROR: Could not get ESDInputHandler");
71 fESD = esdH->GetEvent();
73 else if(gAnalysisLevel == "AOD") {
74 AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
77 Printf("ERROR: Could not get AODInputHandler");
79 fAOD = aodH->GetEvent();
81 else if(gAnalysisLevel == "MC") {
82 AliMCEventHandler* mcH = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
84 Printf("ERROR: Could not retrieve MC event handler");
90 Printf("Wrong analysis type: Only ESD, AOD and MC types are allowed!");
94 //________________________________________________________________________
95 void AliAnalysisTaskProtons::CreateOutputObjects() {
96 // Create output objects
99 fList->Add(fProtonAnalysis->GetProtonYPtHistogram());
100 fList->Add(fProtonAnalysis->GetAntiProtonYPtHistogram());
101 fList->Add(fProtonAnalysis->GetEventHistogram());
102 fList->Add(fProtonAnalysis->GetProtonContainer());
103 fList->Add(fProtonAnalysis->GetAntiProtonContainer());
106 //________________________________________________________________________
107 void AliAnalysisTaskProtons::Exec(Option_t *) {
109 // Called for each event
110 TString gAnalysisLevel = dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetAnalysisLevel();
112 if(gAnalysisLevel == "ESD") {
114 Printf("ERROR: fESD not available");
118 if(dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->IsEventTriggered(fESD,dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetTriggerMode())) {
119 const AliESDVertex *vertex = dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetVertex(fESD,dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetAnalysisMode(),dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetVxMax(),dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetVyMax(),dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetVzMax());
121 Printf("Proton ESD analysis task: There are %d tracks in this event", fESD->GetNumberOfTracks());
122 fProtonAnalysis->Analyze(fESD,vertex);
123 }//reconstructed vertex
127 else if(gAnalysisLevel == "AOD") {
129 Printf("ERROR: fAOD not available");
133 Printf("Proton AOD analysis task: There are %d tracks in this event", fAOD->GetNumberOfTracks());
134 fProtonAnalysis->Analyze(fAOD);
137 else if(gAnalysisLevel == "MC") {
139 Printf("ERROR: Could not retrieve MC event");
143 AliStack* stack = fMC->Stack();
145 Printf("ERROR: Could not retrieve the stack");
148 Printf("Proton MC analysis task: There are %d primaries in this event", stack->GetNprimary());
149 fProtonAnalysis->Analyze(stack,kFALSE);//kTRUE in case of inclusive measurement
156 //________________________________________________________________________
157 void AliAnalysisTaskProtons::Terminate(Option_t *) {
158 // Draw result to the screen
159 // Called once at the end of the query
160 gStyle->SetPalette(1,0);
162 fList = dynamic_cast<TList*> (GetOutputData(0));
164 Printf("ERROR: fList not available");
168 TH2F *fHistYPtProtons = (TH2F *)fList->At(0);
169 TH2F *fHistYPtAntiProtons = (TH2F *)fList->At(1);
171 TCanvas *c1 = new TCanvas("c1","p-\bar{p}",200,0,800,400);
172 c1->SetFillColor(10); c1->SetHighLightColor(10); c1->Divide(2,1);
174 c1->cd(1)->SetLeftMargin(0.15); c1->cd(1)->SetBottomMargin(0.15);
175 if (fHistYPtProtons) fHistYPtProtons->DrawCopy("colz");
176 c1->cd(2)->SetLeftMargin(0.15); c1->cd(2)->SetBottomMargin(0.15);
177 if (fHistYPtAntiProtons) fHistYPtAntiProtons->DrawCopy("colz");
179 TCanvas *c2 = dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetListOfCuts();
180 TFile *flocal = TFile::Open("ListOfCuts.root","recreate");