]>
Commit | Line | Data |
---|---|---|
0ab648ea | 1 | #include "TStyle.h" |
734d2c12 | 2 | #include "TChain.h" |
3 | #include "TTree.h" | |
df01f00b | 4 | #include "TString.h" |
734d2c12 | 5 | #include "TList.h" |
0ab648ea | 6 | #include "TFile.h" |
734d2c12 | 7 | #include "TH2F.h" |
8 | #include "TCanvas.h" | |
734d2c12 | 9 | |
10 | #include "AliAnalysisTask.h" | |
11 | #include "AliAnalysisManager.h" | |
12 | ||
13 | #include "AliESDEvent.h" | |
14 | #include "AliESDInputHandler.h" | |
b620b667 | 15 | #include "AliAODEvent.h" |
16 | #include "AliAODInputHandler.h" | |
e4358d7f | 17 | #include "AliMCEventHandler.h" |
18 | #include "AliMCEvent.h" | |
19 | #include "AliStack.h" | |
6667f3a7 | 20 | #include "AliESDVertex.h" |
734d2c12 | 21 | |
5ae0977e | 22 | #include "AliProtonAnalysis.h" |
0ab648ea | 23 | #include "AliProtonAnalysisBase.h" |
734d2c12 | 24 | #include "AliAnalysisTaskProtons.h" |
25 | ||
73aba974 | 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 | //----------------------------------------------------------------- | |
734d2c12 | 31 | |
32 | ClassImp(AliAnalysisTaskProtons) | |
0ab648ea | 33 | |
df01f00b | 34 | //________________________________________________________________________ |
35 | AliAnalysisTaskProtons::AliAnalysisTaskProtons() | |
0ab648ea | 36 | : AliAnalysisTask(), fESD(0), fAOD(0), fMC(0), |
37 | fList(0), fProtonAnalysis(0) { | |
db10bcb0 | 38 | //Dummy constructor |
0ab648ea | 39 | |
db10bcb0 | 40 | } |
41 | ||
734d2c12 | 42 | //________________________________________________________________________ |
43 | AliAnalysisTaskProtons::AliAnalysisTaskProtons(const char *name) | |
0ab648ea | 44 | : AliAnalysisTask(name, ""), fESD(0), fAOD(0), fMC(0), |
45 | fList(0), fProtonAnalysis(0) { | |
734d2c12 | 46 | // Constructor |
0ab648ea | 47 | |
734d2c12 | 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()); | |
53 | } | |
54 | ||
55 | //________________________________________________________________________ | |
56 | void AliAnalysisTaskProtons::ConnectInputData(Option_t *) { | |
57 | // Connect ESD or AOD here | |
58 | // Called once | |
0ab648ea | 59 | TString gAnalysisLevel = dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetAnalysisLevel(); |
734d2c12 | 60 | |
61 | TTree* tree = dynamic_cast<TTree*> (GetInputData(0)); | |
62 | if (!tree) { | |
63 | Printf("ERROR: Could not read chain from input slot 0"); | |
64 | } else { | |
0ab648ea | 65 | if(gAnalysisLevel == "ESD") { |
df01f00b | 66 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); |
67 | ||
b620b667 | 68 | if (!esdH) { |
69 | Printf("ERROR: Could not get ESDInputHandler"); | |
70 | } else | |
71 | fESD = esdH->GetEvent(); | |
72 | } | |
0ab648ea | 73 | else if(gAnalysisLevel == "AOD") { |
df01f00b | 74 | AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); |
75 | ||
76 | if (!aodH) { | |
77 | Printf("ERROR: Could not get AODInputHandler"); | |
78 | } else | |
79 | fAOD = aodH->GetEvent(); | |
b620b667 | 80 | } |
0ab648ea | 81 | else if(gAnalysisLevel == "MC") { |
df01f00b | 82 | AliMCEventHandler* mcH = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); |
83 | if (!mcH) { | |
84 | Printf("ERROR: Could not retrieve MC event handler"); | |
85 | } | |
86 | else | |
87 | fMC = mcH->MCEvent(); | |
e4358d7f | 88 | } |
df01f00b | 89 | else |
e4358d7f | 90 | Printf("Wrong analysis type: Only ESD, AOD and MC types are allowed!"); |
734d2c12 | 91 | } |
92 | } | |
93 | ||
94 | //________________________________________________________________________ | |
95 | void AliAnalysisTaskProtons::CreateOutputObjects() { | |
0ab648ea | 96 | // Create output objects |
734d2c12 | 97 | // Called once |
738619fd | 98 | fList = new TList(); |
6667f3a7 | 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()); | |
734d2c12 | 104 | } |
105 | ||
106 | //________________________________________________________________________ | |
107 | void AliAnalysisTaskProtons::Exec(Option_t *) { | |
108 | // Main loop | |
109 | // Called for each event | |
0ab648ea | 110 | TString gAnalysisLevel = dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetAnalysisLevel(); |
734d2c12 | 111 | |
0ab648ea | 112 | if(gAnalysisLevel == "ESD") { |
b620b667 | 113 | if (!fESD) { |
114 | Printf("ERROR: fESD not available"); | |
115 | return; | |
116 | } | |
df01f00b | 117 | |
0ab648ea | 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()); | |
6667f3a7 | 120 | if(vertex) { |
10cd755c | 121 | AliDebug(1,Form("Proton ESD analysis task: There are %d tracks in this event",fESD->GetNumberOfTracks())); |
122 | //Printf("Proton ESD analysis task: There are %d tracks in this event", fESD->GetNumberOfTracks()); | |
6667f3a7 | 123 | fProtonAnalysis->Analyze(fESD,vertex); |
124 | }//reconstructed vertex | |
125 | }//triggered event | |
df01f00b | 126 | }//ESD analysis |
127 | ||
0ab648ea | 128 | else if(gAnalysisLevel == "AOD") { |
b620b667 | 129 | if (!fAOD) { |
130 | Printf("ERROR: fAOD not available"); | |
131 | return; | |
132 | } | |
10cd755c | 133 | AliDebug(1,Form("Proton AOD analysis task: There are %d tracks in this event", fAOD->GetNumberOfTracks())); |
134 | //Printf("Proton AOD analysis task: There are %d tracks in this event", fAOD->GetNumberOfTracks()); | |
6667f3a7 | 135 | fProtonAnalysis->Analyze(fAOD); |
0ab648ea | 136 | }//AOD analysis |
df01f00b | 137 | |
0ab648ea | 138 | else if(gAnalysisLevel == "MC") { |
e4358d7f | 139 | if (!fMC) { |
140 | Printf("ERROR: Could not retrieve MC event"); | |
141 | return; | |
142 | } | |
df01f00b | 143 | |
e4358d7f | 144 | AliStack* stack = fMC->Stack(); |
145 | if (!stack) { | |
146 | Printf("ERROR: Could not retrieve the stack"); | |
147 | return; | |
148 | } | |
10cd755c | 149 | AliDebug(1,Form("Proton MC analysis task: There are %d primaries in this event", stack->GetNprimary())); |
150 | //Printf("Proton MC analysis task: There are %d primaries in this event", stack->GetNprimary()); | |
da8c4c1c | 151 | fProtonAnalysis->Analyze(stack,kFALSE);//kTRUE in case of inclusive measurement |
df01f00b | 152 | }//MC analysis |
734d2c12 | 153 | |
154 | // Post output data. | |
155 | PostData(0, fList); | |
156 | } | |
157 | ||
158 | //________________________________________________________________________ | |
159 | void AliAnalysisTaskProtons::Terminate(Option_t *) { | |
160 | // Draw result to the screen | |
161 | // Called once at the end of the query | |
0ab648ea | 162 | gStyle->SetPalette(1,0); |
163 | ||
734d2c12 | 164 | fList = dynamic_cast<TList*> (GetOutputData(0)); |
165 | if (!fList) { | |
166 | Printf("ERROR: fList not available"); | |
167 | return; | |
168 | } | |
169 | ||
170 | TH2F *fHistYPtProtons = (TH2F *)fList->At(0); | |
171 | TH2F *fHistYPtAntiProtons = (TH2F *)fList->At(1); | |
172 | ||
df01f00b | 173 | TCanvas *c1 = new TCanvas("c1","p-\bar{p}",200,0,800,400); |
174 | c1->SetFillColor(10); c1->SetHighLightColor(10); c1->Divide(2,1); | |
734d2c12 | 175 | |
df01f00b | 176 | c1->cd(1)->SetLeftMargin(0.15); c1->cd(1)->SetBottomMargin(0.15); |
734d2c12 | 177 | if (fHistYPtProtons) fHistYPtProtons->DrawCopy("colz"); |
df01f00b | 178 | c1->cd(2)->SetLeftMargin(0.15); c1->cd(2)->SetBottomMargin(0.15); |
734d2c12 | 179 | if (fHistYPtAntiProtons) fHistYPtAntiProtons->DrawCopy("colz"); |
6667f3a7 | 180 | |
0ab648ea | 181 | TCanvas *c2 = dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetListOfCuts(); |
182 | TFile *flocal = TFile::Open("ListOfCuts.root","recreate"); | |
183 | c2->Write(); | |
184 | flocal->Close(); | |
6667f3a7 | 185 | } |
186 |