]>
Commit | Line | Data |
---|---|---|
42270c4c | 1 | #include "Riostream.h" |
0ab648ea | 2 | #include "TStyle.h" |
734d2c12 | 3 | #include "TChain.h" |
4 | #include "TTree.h" | |
df01f00b | 5 | #include "TString.h" |
734d2c12 | 6 | #include "TList.h" |
0ab648ea | 7 | #include "TFile.h" |
734d2c12 | 8 | #include "TH2F.h" |
3c669e09 | 9 | #include "TH1F.h" |
734d2c12 | 10 | #include "TCanvas.h" |
734d2c12 | 11 | |
12 | #include "AliAnalysisTask.h" | |
13 | #include "AliAnalysisManager.h" | |
14 | ||
15 | #include "AliESDEvent.h" | |
16 | #include "AliESDInputHandler.h" | |
b620b667 | 17 | #include "AliAODEvent.h" |
18 | #include "AliAODInputHandler.h" | |
e4358d7f | 19 | #include "AliMCEventHandler.h" |
20 | #include "AliMCEvent.h" | |
21 | #include "AliStack.h" | |
6667f3a7 | 22 | #include "AliESDVertex.h" |
734d2c12 | 23 | |
5ae0977e | 24 | #include "AliProtonAnalysis.h" |
0ab648ea | 25 | #include "AliProtonAnalysisBase.h" |
734d2c12 | 26 | #include "AliAnalysisTaskProtons.h" |
27 | ||
73aba974 | 28 | //----------------------------------------------------------------- |
29 | // AliAnalysisTakProtons class | |
30 | // This is the task to run the \bar{p}/p analysis | |
31 | // Origin: Panos Christakoglou | Panos.Christakoglou@cern.ch | |
32 | //----------------------------------------------------------------- | |
734d2c12 | 33 | |
34 | ClassImp(AliAnalysisTaskProtons) | |
0ab648ea | 35 | |
df01f00b | 36 | //________________________________________________________________________ |
37 | AliAnalysisTaskProtons::AliAnalysisTaskProtons() | |
0ab648ea | 38 | : AliAnalysisTask(), fESD(0), fAOD(0), fMC(0), |
3c669e09 | 39 | fListAnalysis(0), fListQA(0), fHistEventStats(0), |
0894be86 | 40 | fProtonAnalysis(0) {//, fCutCanvas(0) { |
db10bcb0 | 41 | //Dummy constructor |
0ab648ea | 42 | |
db10bcb0 | 43 | } |
44 | ||
734d2c12 | 45 | //________________________________________________________________________ |
46 | AliAnalysisTaskProtons::AliAnalysisTaskProtons(const char *name) | |
0ab648ea | 47 | : AliAnalysisTask(name, ""), fESD(0), fAOD(0), fMC(0), |
3c669e09 | 48 | fListAnalysis(0), fListQA(0), fHistEventStats(0), |
0894be86 | 49 | fProtonAnalysis(0) {//, fCutCanvas(0) { |
734d2c12 | 50 | // Constructor |
0ab648ea | 51 | |
734d2c12 | 52 | // Define input and output slots here |
53 | // Input slot #0 works with a TChain | |
54 | DefineInput(0, TChain::Class()); | |
55 | // Output slot #0 writes into a TList container | |
56 | DefineOutput(0, TList::Class()); | |
735cc63d | 57 | DefineOutput(1, TList::Class()); |
c6909683 | 58 | DefineOutput(2, TCanvas::Class()); |
734d2c12 | 59 | } |
60 | ||
61 | //________________________________________________________________________ | |
62 | void AliAnalysisTaskProtons::ConnectInputData(Option_t *) { | |
63 | // Connect ESD or AOD here | |
64 | // Called once | |
0ab648ea | 65 | TString gAnalysisLevel = dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetAnalysisLevel(); |
734d2c12 | 66 | |
67 | TTree* tree = dynamic_cast<TTree*> (GetInputData(0)); | |
68 | if (!tree) { | |
69 | Printf("ERROR: Could not read chain from input slot 0"); | |
70 | } else { | |
0ab648ea | 71 | if(gAnalysisLevel == "ESD") { |
df01f00b | 72 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); |
73 | ||
b620b667 | 74 | if (!esdH) { |
75 | Printf("ERROR: Could not get ESDInputHandler"); | |
76 | } else | |
77 | fESD = esdH->GetEvent(); | |
78 | } | |
0ab648ea | 79 | else if(gAnalysisLevel == "AOD") { |
df01f00b | 80 | AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); |
81 | ||
82 | if (!aodH) { | |
83 | Printf("ERROR: Could not get AODInputHandler"); | |
84 | } else | |
85 | fAOD = aodH->GetEvent(); | |
b620b667 | 86 | } |
0ab648ea | 87 | else if(gAnalysisLevel == "MC") { |
df01f00b | 88 | AliMCEventHandler* mcH = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); |
89 | if (!mcH) { | |
90 | Printf("ERROR: Could not retrieve MC event handler"); | |
91 | } | |
92 | else | |
93 | fMC = mcH->MCEvent(); | |
e4358d7f | 94 | } |
df01f00b | 95 | else |
e4358d7f | 96 | Printf("Wrong analysis type: Only ESD, AOD and MC types are allowed!"); |
734d2c12 | 97 | } |
98 | } | |
99 | ||
100 | //________________________________________________________________________ | |
101 | void AliAnalysisTaskProtons::CreateOutputObjects() { | |
0ab648ea | 102 | // Create output objects |
734d2c12 | 103 | // Called once |
d7a38708 | 104 | TString gCutName[5] = {"Total","Triggered","Offline trigger", |
105 | "Vertex","Analyzed"}; | |
3c669e09 | 106 | fHistEventStats = new TH1F("fHistEventStats", |
107 | "Event statistics;;N_{events}", | |
f203beb9 | 108 | 5,0.5,5.5); |
109 | for(Int_t i = 1; i <= 5; i++) | |
d7a38708 | 110 | fHistEventStats->GetXaxis()->SetBinLabel(i,gCutName[i-1].Data()); |
3c669e09 | 111 | |
735cc63d | 112 | fListAnalysis = new TList(); |
113 | fListAnalysis->Add(fProtonAnalysis->GetProtonYPtHistogram()); | |
114 | fListAnalysis->Add(fProtonAnalysis->GetAntiProtonYPtHistogram()); | |
115 | fListAnalysis->Add(fProtonAnalysis->GetEventHistogram()); | |
116 | fListAnalysis->Add(fProtonAnalysis->GetProtonContainer()); | |
117 | fListAnalysis->Add(fProtonAnalysis->GetAntiProtonContainer()); | |
3c669e09 | 118 | fListAnalysis->Add(fHistEventStats); |
735cc63d | 119 | |
2f6dae44 | 120 | if(dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->IsQARun()) { |
121 | fListQA = new TList(); | |
122 | fListQA->SetName("fListQA"); | |
123 | fListQA->Add(fProtonAnalysis->GetQAList()); | |
124 | fListQA->Add(dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetVertexQAList()); | |
125 | } | |
c6909683 | 126 | |
0894be86 | 127 | //fCutCanvas = dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetListOfCuts(); |
734d2c12 | 128 | } |
129 | ||
130 | //________________________________________________________________________ | |
131 | void AliAnalysisTaskProtons::Exec(Option_t *) { | |
132 | // Main loop | |
133 | // Called for each event | |
0ab648ea | 134 | TString gAnalysisLevel = dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetAnalysisLevel(); |
734d2c12 | 135 | |
0ab648ea | 136 | if(gAnalysisLevel == "ESD") { |
b620b667 | 137 | if (!fESD) { |
138 | Printf("ERROR: fESD not available"); | |
139 | return; | |
140 | } | |
3c669e09 | 141 | |
142 | fHistEventStats->Fill(1); | |
1fd2c71b | 143 | if(dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->IsOnlineTriggerUsed()) { |
144 | //online trigger | |
145 | if(dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->IsEventTriggered(fESD,dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetTriggerMode())) { | |
146 | fHistEventStats->Fill(2); | |
147 | AliDebug(1,Form("Fired trigger class: %s",fESD->GetFiredTriggerClasses().Data())); | |
148 | ||
149 | //offline trigger | |
150 | if(dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->IsOfflineTriggerUsed()) { | |
151 | AliPhysicsSelection *gPhysicselection = dynamic_cast<AliPhysicsSelection *>(dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetPhysicsSelectionObject()); | |
152 | if(gPhysicselection->IsCollisionCandidate(fESD)) { | |
153 | fHistEventStats->Fill(3); | |
154 | AliDebug(1,Form("Fired trigger class: %s",fESD->GetFiredTriggerClasses().Data())); | |
155 | //Reconstructed vertex | |
156 | 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()); | |
157 | fHistEventStats->Fill(4); | |
158 | if(vertex) { | |
159 | AliDebug(1,Form("Proton ESD analysis task: There are %d tracks in this event",fESD->GetNumberOfTracks())); | |
160 | fProtonAnalysis->Analyze(fESD,vertex); | |
161 | fHistEventStats->Fill(5); | |
162 | }//reconstructed vertex | |
163 | }//offline trigger | |
164 | }//usage of the offline trigger | |
165 | else { | |
166 | fHistEventStats->Fill(3); | |
167 | AliDebug(1,Form("Fired trigger class: %s",fESD->GetFiredTriggerClasses().Data())); | |
168 | //Reconstructed vertex | |
169 | 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()); | |
170 | fHistEventStats->Fill(4); | |
171 | if(vertex) { | |
172 | AliDebug(1,Form("Proton ESD analysis task: There are %d tracks in this event",fESD->GetNumberOfTracks())); | |
173 | fProtonAnalysis->Analyze(fESD,vertex); | |
174 | fHistEventStats->Fill(5); | |
175 | }//reconstructed vertex | |
176 | }//offline trigger not used | |
177 | }//triggered event - online | |
178 | }//online trigger used | |
179 | else { | |
3c669e09 | 180 | fHistEventStats->Fill(2); |
42270c4c | 181 | AliDebug(1,Form("Fired trigger class: %s",fESD->GetFiredTriggerClasses().Data())); |
1fd2c71b | 182 | |
f203beb9 | 183 | //offline trigger |
184 | if(dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->IsOfflineTriggerUsed()) { | |
185 | AliPhysicsSelection *gPhysicselection = dynamic_cast<AliPhysicsSelection *>(dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetPhysicsSelectionObject()); | |
186 | if(gPhysicselection->IsCollisionCandidate(fESD)) { | |
187 | fHistEventStats->Fill(3); | |
188 | AliDebug(1,Form("Fired trigger class: %s",fESD->GetFiredTriggerClasses().Data())); | |
189 | //Reconstructed vertex | |
190 | 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()); | |
191 | fHistEventStats->Fill(4); | |
192 | if(vertex) { | |
193 | AliDebug(1,Form("Proton ESD analysis task: There are %d tracks in this event",fESD->GetNumberOfTracks())); | |
194 | fProtonAnalysis->Analyze(fESD,vertex); | |
195 | fHistEventStats->Fill(5); | |
196 | }//reconstructed vertex | |
197 | }//offline trigger | |
198 | }//usage of the offline trigger | |
1fd2c71b | 199 | else { |
200 | fHistEventStats->Fill(3); | |
201 | AliDebug(1,Form("Fired trigger class: %s",fESD->GetFiredTriggerClasses().Data())); | |
202 | //Reconstructed vertex | |
203 | 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()); | |
204 | fHistEventStats->Fill(4); | |
205 | if(vertex) { | |
206 | AliDebug(1,Form("Proton ESD analysis task: There are %d tracks in this event",fESD->GetNumberOfTracks())); | |
207 | fProtonAnalysis->Analyze(fESD,vertex); | |
208 | fHistEventStats->Fill(5); | |
209 | }//reconstructed vertex | |
210 | }//offline trigger not used | |
211 | }//online trigger not used | |
df01f00b | 212 | }//ESD analysis |
213 | ||
0ab648ea | 214 | else if(gAnalysisLevel == "AOD") { |
b620b667 | 215 | if (!fAOD) { |
216 | Printf("ERROR: fAOD not available"); | |
217 | return; | |
218 | } | |
10cd755c | 219 | AliDebug(1,Form("Proton AOD analysis task: There are %d tracks in this event", fAOD->GetNumberOfTracks())); |
220 | //Printf("Proton AOD analysis task: There are %d tracks in this event", fAOD->GetNumberOfTracks()); | |
6667f3a7 | 221 | fProtonAnalysis->Analyze(fAOD); |
0ab648ea | 222 | }//AOD analysis |
df01f00b | 223 | |
0ab648ea | 224 | else if(gAnalysisLevel == "MC") { |
e4358d7f | 225 | if (!fMC) { |
226 | Printf("ERROR: Could not retrieve MC event"); | |
227 | return; | |
228 | } | |
df01f00b | 229 | |
e4358d7f | 230 | AliStack* stack = fMC->Stack(); |
231 | if (!stack) { | |
232 | Printf("ERROR: Could not retrieve the stack"); | |
233 | return; | |
234 | } | |
10cd755c | 235 | AliDebug(1,Form("Proton MC analysis task: There are %d primaries in this event", stack->GetNprimary())); |
236 | //Printf("Proton MC analysis task: There are %d primaries in this event", stack->GetNprimary()); | |
da8c4c1c | 237 | fProtonAnalysis->Analyze(stack,kFALSE);//kTRUE in case of inclusive measurement |
df01f00b | 238 | }//MC analysis |
734d2c12 | 239 | |
240 | // Post output data. | |
735cc63d | 241 | PostData(0, fListAnalysis); |
2f6dae44 | 242 | if(dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->IsQARun()) |
243 | PostData(1, fListQA); | |
0894be86 | 244 | //PostData(2, fCutCanvas); |
734d2c12 | 245 | } |
246 | ||
247 | //________________________________________________________________________ | |
248 | void AliAnalysisTaskProtons::Terminate(Option_t *) { | |
249 | // Draw result to the screen | |
250 | // Called once at the end of the query | |
0ab648ea | 251 | gStyle->SetPalette(1,0); |
252 | ||
735cc63d | 253 | fListAnalysis = dynamic_cast<TList*> (GetOutputData(0)); |
254 | if (!fListAnalysis) { | |
255 | Printf("ERROR: fListAnalysis not available"); | |
734d2c12 | 256 | return; |
257 | } | |
258 | ||
735cc63d | 259 | TH2F *fHistYPtProtons = (TH2F *)fListAnalysis->At(0); |
260 | TH2F *fHistYPtAntiProtons = (TH2F *)fListAnalysis->At(1); | |
734d2c12 | 261 | |
df01f00b | 262 | TCanvas *c1 = new TCanvas("c1","p-\bar{p}",200,0,800,400); |
263 | c1->SetFillColor(10); c1->SetHighLightColor(10); c1->Divide(2,1); | |
734d2c12 | 264 | |
df01f00b | 265 | c1->cd(1)->SetLeftMargin(0.15); c1->cd(1)->SetBottomMargin(0.15); |
734d2c12 | 266 | if (fHistYPtProtons) fHistYPtProtons->DrawCopy("colz"); |
df01f00b | 267 | c1->cd(2)->SetLeftMargin(0.15); c1->cd(2)->SetBottomMargin(0.15); |
734d2c12 | 268 | if (fHistYPtAntiProtons) fHistYPtAntiProtons->DrawCopy("colz"); |
6667f3a7 | 269 | |
c6909683 | 270 | /*TCanvas *c2 = dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetListOfCuts(); |
0ab648ea | 271 | TFile *flocal = TFile::Open("ListOfCuts.root","recreate"); |
272 | c2->Write(); | |
c6909683 | 273 | flocal->Close();*/ |
6667f3a7 | 274 | } |
275 |