]>
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), |
735cc63d | 40 | fProtonAnalysis(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), |
49 | fProtonAnalysis(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()); |
734d2c12 | 58 | } |
59 | ||
60 | //________________________________________________________________________ | |
61 | void AliAnalysisTaskProtons::ConnectInputData(Option_t *) { | |
62 | // Connect ESD or AOD here | |
63 | // Called once | |
0ab648ea | 64 | TString gAnalysisLevel = dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetAnalysisLevel(); |
734d2c12 | 65 | |
66 | TTree* tree = dynamic_cast<TTree*> (GetInputData(0)); | |
67 | if (!tree) { | |
68 | Printf("ERROR: Could not read chain from input slot 0"); | |
69 | } else { | |
0ab648ea | 70 | if(gAnalysisLevel == "ESD") { |
df01f00b | 71 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); |
72 | ||
b620b667 | 73 | if (!esdH) { |
74 | Printf("ERROR: Could not get ESDInputHandler"); | |
75 | } else | |
76 | fESD = esdH->GetEvent(); | |
77 | } | |
0ab648ea | 78 | else if(gAnalysisLevel == "AOD") { |
df01f00b | 79 | AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); |
80 | ||
81 | if (!aodH) { | |
82 | Printf("ERROR: Could not get AODInputHandler"); | |
83 | } else | |
84 | fAOD = aodH->GetEvent(); | |
b620b667 | 85 | } |
0ab648ea | 86 | else if(gAnalysisLevel == "MC") { |
df01f00b | 87 | AliMCEventHandler* mcH = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); |
88 | if (!mcH) { | |
89 | Printf("ERROR: Could not retrieve MC event handler"); | |
90 | } | |
91 | else | |
92 | fMC = mcH->MCEvent(); | |
e4358d7f | 93 | } |
df01f00b | 94 | else |
e4358d7f | 95 | Printf("Wrong analysis type: Only ESD, AOD and MC types are allowed!"); |
734d2c12 | 96 | } |
97 | } | |
98 | ||
99 | //________________________________________________________________________ | |
100 | void AliAnalysisTaskProtons::CreateOutputObjects() { | |
0ab648ea | 101 | // Create output objects |
734d2c12 | 102 | // Called once |
f203beb9 | 103 | char *gCutName[5] = {"Total","Triggered","Offline trigger", |
104 | "Vertex","Analyzed"}; | |
3c669e09 | 105 | fHistEventStats = new TH1F("fHistEventStats", |
106 | "Event statistics;;N_{events}", | |
f203beb9 | 107 | 5,0.5,5.5); |
108 | for(Int_t i = 1; i <= 5; i++) | |
3c669e09 | 109 | fHistEventStats->GetXaxis()->SetBinLabel(i,gCutName[i-1]); |
110 | ||
735cc63d | 111 | fListAnalysis = new TList(); |
112 | fListAnalysis->Add(fProtonAnalysis->GetProtonYPtHistogram()); | |
113 | fListAnalysis->Add(fProtonAnalysis->GetAntiProtonYPtHistogram()); | |
114 | fListAnalysis->Add(fProtonAnalysis->GetEventHistogram()); | |
115 | fListAnalysis->Add(fProtonAnalysis->GetProtonContainer()); | |
116 | fListAnalysis->Add(fProtonAnalysis->GetAntiProtonContainer()); | |
3c669e09 | 117 | fListAnalysis->Add(fHistEventStats); |
735cc63d | 118 | |
119 | fListQA = new TList(); | |
120 | fListQA->SetName("fListQA"); | |
121 | fListQA->Add(fProtonAnalysis->GetQAList()); | |
122 | fListQA->Add(dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetVertexQAList()); | |
734d2c12 | 123 | } |
124 | ||
125 | //________________________________________________________________________ | |
126 | void AliAnalysisTaskProtons::Exec(Option_t *) { | |
127 | // Main loop | |
128 | // Called for each event | |
0ab648ea | 129 | TString gAnalysisLevel = dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetAnalysisLevel(); |
734d2c12 | 130 | |
0ab648ea | 131 | if(gAnalysisLevel == "ESD") { |
b620b667 | 132 | if (!fESD) { |
133 | Printf("ERROR: fESD not available"); | |
134 | return; | |
135 | } | |
3c669e09 | 136 | |
137 | fHistEventStats->Fill(1); | |
f203beb9 | 138 | //online trigger |
42270c4c | 139 | if(dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->IsEventTriggered(fESD,dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetTriggerMode())) { |
3c669e09 | 140 | fHistEventStats->Fill(2); |
42270c4c | 141 | AliDebug(1,Form("Fired trigger class: %s",fESD->GetFiredTriggerClasses().Data())); |
f203beb9 | 142 | //offline trigger |
143 | if(dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->IsOfflineTriggerUsed()) { | |
144 | AliPhysicsSelection *gPhysicselection = dynamic_cast<AliPhysicsSelection *>(dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetPhysicsSelectionObject()); | |
145 | if(gPhysicselection->IsCollisionCandidate(fESD)) { | |
146 | fHistEventStats->Fill(3); | |
147 | AliDebug(1,Form("Fired trigger class: %s",fESD->GetFiredTriggerClasses().Data())); | |
148 | //Reconstructed vertex | |
149 | 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()); | |
150 | fHistEventStats->Fill(4); | |
151 | if(vertex) { | |
152 | AliDebug(1,Form("Proton ESD analysis task: There are %d tracks in this event",fESD->GetNumberOfTracks())); | |
153 | fProtonAnalysis->Analyze(fESD,vertex); | |
154 | fHistEventStats->Fill(5); | |
155 | }//reconstructed vertex | |
156 | }//offline trigger | |
157 | }//usage of the offline trigger | |
f203beb9 | 158 | }//triggered event - online |
df01f00b | 159 | }//ESD analysis |
160 | ||
0ab648ea | 161 | else if(gAnalysisLevel == "AOD") { |
b620b667 | 162 | if (!fAOD) { |
163 | Printf("ERROR: fAOD not available"); | |
164 | return; | |
165 | } | |
10cd755c | 166 | AliDebug(1,Form("Proton AOD analysis task: There are %d tracks in this event", fAOD->GetNumberOfTracks())); |
167 | //Printf("Proton AOD analysis task: There are %d tracks in this event", fAOD->GetNumberOfTracks()); | |
6667f3a7 | 168 | fProtonAnalysis->Analyze(fAOD); |
0ab648ea | 169 | }//AOD analysis |
df01f00b | 170 | |
0ab648ea | 171 | else if(gAnalysisLevel == "MC") { |
e4358d7f | 172 | if (!fMC) { |
173 | Printf("ERROR: Could not retrieve MC event"); | |
174 | return; | |
175 | } | |
df01f00b | 176 | |
e4358d7f | 177 | AliStack* stack = fMC->Stack(); |
178 | if (!stack) { | |
179 | Printf("ERROR: Could not retrieve the stack"); | |
180 | return; | |
181 | } | |
10cd755c | 182 | AliDebug(1,Form("Proton MC analysis task: There are %d primaries in this event", stack->GetNprimary())); |
183 | //Printf("Proton MC analysis task: There are %d primaries in this event", stack->GetNprimary()); | |
da8c4c1c | 184 | fProtonAnalysis->Analyze(stack,kFALSE);//kTRUE in case of inclusive measurement |
df01f00b | 185 | }//MC analysis |
734d2c12 | 186 | |
187 | // Post output data. | |
735cc63d | 188 | PostData(0, fListAnalysis); |
189 | PostData(1, fListQA); | |
734d2c12 | 190 | } |
191 | ||
192 | //________________________________________________________________________ | |
193 | void AliAnalysisTaskProtons::Terminate(Option_t *) { | |
194 | // Draw result to the screen | |
195 | // Called once at the end of the query | |
0ab648ea | 196 | gStyle->SetPalette(1,0); |
197 | ||
735cc63d | 198 | fListAnalysis = dynamic_cast<TList*> (GetOutputData(0)); |
199 | if (!fListAnalysis) { | |
200 | Printf("ERROR: fListAnalysis not available"); | |
734d2c12 | 201 | return; |
202 | } | |
203 | ||
735cc63d | 204 | TH2F *fHistYPtProtons = (TH2F *)fListAnalysis->At(0); |
205 | TH2F *fHistYPtAntiProtons = (TH2F *)fListAnalysis->At(1); | |
734d2c12 | 206 | |
df01f00b | 207 | TCanvas *c1 = new TCanvas("c1","p-\bar{p}",200,0,800,400); |
208 | c1->SetFillColor(10); c1->SetHighLightColor(10); c1->Divide(2,1); | |
734d2c12 | 209 | |
df01f00b | 210 | c1->cd(1)->SetLeftMargin(0.15); c1->cd(1)->SetBottomMargin(0.15); |
734d2c12 | 211 | if (fHistYPtProtons) fHistYPtProtons->DrawCopy("colz"); |
df01f00b | 212 | c1->cd(2)->SetLeftMargin(0.15); c1->cd(2)->SetBottomMargin(0.15); |
734d2c12 | 213 | if (fHistYPtAntiProtons) fHistYPtAntiProtons->DrawCopy("colz"); |
6667f3a7 | 214 | |
0ab648ea | 215 | TCanvas *c2 = dynamic_cast<AliProtonAnalysisBase*>(fProtonAnalysis->GetProtonAnalysisBaseObject())->GetListOfCuts(); |
216 | TFile *flocal = TFile::Open("ListOfCuts.root","recreate"); | |
217 | c2->Write(); | |
218 | flocal->Close(); | |
6667f3a7 | 219 | } |
220 |