]>
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) { |
121 | Printf("Proton ESD analysis task: There are %d tracks in this event", fESD->GetNumberOfTracks()); | |
122 | fProtonAnalysis->Analyze(fESD,vertex); | |
123 | }//reconstructed vertex | |
124 | }//triggered event | |
df01f00b | 125 | }//ESD analysis |
126 | ||
0ab648ea | 127 | else if(gAnalysisLevel == "AOD") { |
b620b667 | 128 | if (!fAOD) { |
129 | Printf("ERROR: fAOD not available"); | |
130 | return; | |
131 | } | |
132 | ||
e4358d7f | 133 | Printf("Proton AOD analysis task: There are %d tracks in this event", fAOD->GetNumberOfTracks()); |
6667f3a7 | 134 | fProtonAnalysis->Analyze(fAOD); |
0ab648ea | 135 | }//AOD analysis |
df01f00b | 136 | |
0ab648ea | 137 | else if(gAnalysisLevel == "MC") { |
e4358d7f | 138 | if (!fMC) { |
139 | Printf("ERROR: Could not retrieve MC event"); | |
140 | return; | |
141 | } | |
df01f00b | 142 | |
e4358d7f | 143 | AliStack* stack = fMC->Stack(); |
144 | if (!stack) { | |
145 | Printf("ERROR: Could not retrieve the stack"); | |
146 | return; | |
147 | } | |
148 | Printf("Proton MC analysis task: There are %d primaries in this event", stack->GetNprimary()); | |
da8c4c1c | 149 | fProtonAnalysis->Analyze(stack,kFALSE);//kTRUE in case of inclusive measurement |
df01f00b | 150 | }//MC analysis |
734d2c12 | 151 | |
152 | // Post output data. | |
153 | PostData(0, fList); | |
154 | } | |
155 | ||
156 | //________________________________________________________________________ | |
157 | void AliAnalysisTaskProtons::Terminate(Option_t *) { | |
158 | // Draw result to the screen | |
159 | // Called once at the end of the query | |
0ab648ea | 160 | gStyle->SetPalette(1,0); |
161 | ||
734d2c12 | 162 | fList = dynamic_cast<TList*> (GetOutputData(0)); |
163 | if (!fList) { | |
164 | Printf("ERROR: fList not available"); | |
165 | return; | |
166 | } | |
167 | ||
168 | TH2F *fHistYPtProtons = (TH2F *)fList->At(0); | |
169 | TH2F *fHistYPtAntiProtons = (TH2F *)fList->At(1); | |
170 | ||
df01f00b | 171 | TCanvas *c1 = new TCanvas("c1","p-\bar{p}",200,0,800,400); |
172 | c1->SetFillColor(10); c1->SetHighLightColor(10); c1->Divide(2,1); | |
734d2c12 | 173 | |
df01f00b | 174 | c1->cd(1)->SetLeftMargin(0.15); c1->cd(1)->SetBottomMargin(0.15); |
734d2c12 | 175 | if (fHistYPtProtons) fHistYPtProtons->DrawCopy("colz"); |
df01f00b | 176 | c1->cd(2)->SetLeftMargin(0.15); c1->cd(2)->SetBottomMargin(0.15); |
734d2c12 | 177 | if (fHistYPtAntiProtons) fHistYPtAntiProtons->DrawCopy("colz"); |
6667f3a7 | 178 | |
0ab648ea | 179 | TCanvas *c2 = dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetListOfCuts(); |
180 | TFile *flocal = TFile::Open("ListOfCuts.root","recreate"); | |
181 | c2->Write(); | |
182 | flocal->Close(); | |
6667f3a7 | 183 | } |
184 |