]>
Commit | Line | Data |
---|---|---|
734d2c12 | 1 | #include "TChain.h" |
2 | #include "TTree.h" | |
df01f00b | 3 | #include "TString.h" |
734d2c12 | 4 | #include "TList.h" |
5 | #include "TH2F.h" | |
df01f00b | 6 | #include "TH1I.h" |
aafecd8b | 7 | #include "TF1.h" |
734d2c12 | 8 | #include "TCanvas.h" |
9 | #include "TLorentzVector.h" | |
10 | ||
11 | #include "AliAnalysisTask.h" | |
12 | #include "AliAnalysisManager.h" | |
13 | ||
14 | #include "AliESDEvent.h" | |
15 | #include "AliESDInputHandler.h" | |
b620b667 | 16 | #include "AliAODEvent.h" |
17 | #include "AliAODInputHandler.h" | |
e4358d7f | 18 | #include "AliMCEventHandler.h" |
19 | #include "AliMCEvent.h" | |
20 | #include "AliStack.h" | |
251e4034 | 21 | #include "AliCFContainer.h" |
734d2c12 | 22 | |
df01f00b | 23 | #include "PWG2spectra/SPECTRA/AliProtonAnalysis.h" |
734d2c12 | 24 | #include "AliAnalysisTaskProtons.h" |
25 | ||
26 | // Analysis task creating a the 2d y-p_t spectrum of p and antip | |
27 | // Author: Panos Cristakoglou | |
28 | ||
29 | ClassImp(AliAnalysisTaskProtons) | |
30 | ||
df01f00b | 31 | //________________________________________________________________________ |
32 | AliAnalysisTaskProtons::AliAnalysisTaskProtons() | |
33 | : AliAnalysisTask(), fESD(0), fAOD(0), fMC(0), fAnalysisType("ESD"), | |
34 | fList(0), fAnalysis(0), | |
35 | fElectronFunction(0), fMuonFunction(0), | |
36 | fPionFunction(0), fKaonFunction(0), fProtonFunction(0), | |
37 | fFunctionUsed(kFALSE) { | |
db10bcb0 | 38 | //Dummy constructor |
df01f00b | 39 | |
db10bcb0 | 40 | } |
41 | ||
734d2c12 | 42 | //________________________________________________________________________ |
43 | AliAnalysisTaskProtons::AliAnalysisTaskProtons(const char *name) | |
df01f00b | 44 | : AliAnalysisTask(name, ""), fESD(0), fAOD(0), fMC(0), fAnalysisType("ESD"), |
b620b667 | 45 | fList(0), fAnalysis(0), |
aafecd8b | 46 | fElectronFunction(0), fMuonFunction(0), |
47 | fPionFunction(0), fKaonFunction(0), fProtonFunction(0), | |
48 | fFunctionUsed(kFALSE) { | |
734d2c12 | 49 | // Constructor |
50 | ||
51 | // Define input and output slots here | |
52 | // Input slot #0 works with a TChain | |
53 | DefineInput(0, TChain::Class()); | |
54 | // Output slot #0 writes into a TList container | |
55 | DefineOutput(0, TList::Class()); | |
56 | } | |
57 | ||
58 | //________________________________________________________________________ | |
59 | void AliAnalysisTaskProtons::ConnectInputData(Option_t *) { | |
60 | // Connect ESD or AOD here | |
61 | // Called once | |
62 | ||
63 | TTree* tree = dynamic_cast<TTree*> (GetInputData(0)); | |
64 | if (!tree) { | |
65 | Printf("ERROR: Could not read chain from input slot 0"); | |
66 | } else { | |
b620b667 | 67 | if(fAnalysisType == "ESD") { |
df01f00b | 68 | tree->SetBranchStatus("*", kFALSE); |
69 | tree->SetBranchStatus("Tracks.*", kTRUE); | |
b620b667 | 70 | |
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 | } | |
78 | else if(fAnalysisType == "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 | } |
e4358d7f | 86 | else if(fAnalysisType == "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() { | |
101 | // Create histograms | |
102 | // Called once | |
df01f00b | 103 | //Prior probabilities |
734d2c12 | 104 | Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05}; |
df01f00b | 105 | |
106 | //proton analysis object | |
734d2c12 | 107 | fAnalysis = new AliProtonAnalysis(); |
251e4034 | 108 | fAnalysis->InitAnalysisHistograms(10,-1.0,1.0,26,0.5,3.1); |
df01f00b | 109 | |
b620b667 | 110 | if(fAnalysisType == "ESD") { |
251e4034 | 111 | //Use of TPConly tracks |
e4358d7f | 112 | fAnalysis->UseTPCOnly(); |
113 | ||
df01f00b | 114 | //TPC related cuts |
b620b667 | 115 | fAnalysis->SetMinTPCClusters(50); |
b620b667 | 116 | fAnalysis->SetMaxChi2PerTPCCluster(3.5); |
117 | fAnalysis->SetMaxCov11(2.0); | |
118 | fAnalysis->SetMaxCov22(2.0); | |
119 | fAnalysis->SetMaxCov33(0.5); | |
120 | fAnalysis->SetMaxCov44(0.5); | |
121 | fAnalysis->SetMaxCov55(2.0); | |
e4358d7f | 122 | fAnalysis->SetMaxSigmaToVertex(2.5); |
b620b667 | 123 | fAnalysis->SetTPCRefit(); |
df01f00b | 124 | |
251e4034 | 125 | //ITS related cuts - to be used for the analysis of global tracking |
126 | //fAnalysis->SetMinITSClusters(5); | |
127 | //fAnalysis->SetITSRefit(); | |
b620b667 | 128 | } |
df01f00b | 129 | |
aafecd8b | 130 | if(fFunctionUsed) |
131 | fAnalysis->SetPriorProbabilityFunctions(fElectronFunction, | |
132 | fMuonFunction, | |
133 | fPionFunction, | |
134 | fKaonFunction, | |
135 | fProtonFunction); | |
136 | else | |
137 | fAnalysis->SetPriorProbabilities(partFrac); | |
738619fd | 138 | |
139 | fList = new TList(); | |
df01f00b | 140 | fList->Add(fAnalysis->GetProtonYPtHistogram()); |
141 | fList->Add(fAnalysis->GetAntiProtonYPtHistogram()); | |
142 | fList->Add(fAnalysis->GetEventHistogram()); | |
251e4034 | 143 | fList->Add(fAnalysis->GetProtonContainer()); |
144 | fList->Add(fAnalysis->GetAntiProtonContainer()); | |
734d2c12 | 145 | } |
146 | ||
147 | //________________________________________________________________________ | |
148 | void AliAnalysisTaskProtons::Exec(Option_t *) { | |
149 | // Main loop | |
150 | // Called for each event | |
151 | ||
b620b667 | 152 | if(fAnalysisType == "ESD") { |
153 | if (!fESD) { | |
154 | Printf("ERROR: fESD not available"); | |
155 | return; | |
156 | } | |
df01f00b | 157 | |
e4358d7f | 158 | Printf("Proton ESD analysis task: There are %d tracks in this event", fESD->GetNumberOfTracks()); |
b620b667 | 159 | fAnalysis->Analyze(fESD); |
df01f00b | 160 | }//ESD analysis |
161 | ||
b620b667 | 162 | else if(fAnalysisType == "AOD") { |
163 | if (!fAOD) { | |
164 | Printf("ERROR: fAOD not available"); | |
165 | return; | |
166 | } | |
167 | ||
e4358d7f | 168 | Printf("Proton AOD analysis task: There are %d tracks in this event", fAOD->GetNumberOfTracks()); |
b620b667 | 169 | fAnalysis->Analyze(fAOD); |
df01f00b | 170 | }//AOD analysis |
171 | ||
e4358d7f | 172 | else if(fAnalysisType == "MC") { |
173 | if (!fMC) { | |
174 | Printf("ERROR: Could not retrieve MC event"); | |
175 | return; | |
176 | } | |
df01f00b | 177 | |
e4358d7f | 178 | AliStack* stack = fMC->Stack(); |
179 | if (!stack) { | |
180 | Printf("ERROR: Could not retrieve the stack"); | |
181 | return; | |
182 | } | |
183 | Printf("Proton MC analysis task: There are %d primaries in this event", stack->GetNprimary()); | |
184 | fAnalysis->Analyze(stack); | |
df01f00b | 185 | }//MC analysis |
734d2c12 | 186 | |
187 | // Post output data. | |
188 | PostData(0, fList); | |
189 | } | |
190 | ||
191 | //________________________________________________________________________ | |
192 | void AliAnalysisTaskProtons::Terminate(Option_t *) { | |
193 | // Draw result to the screen | |
194 | // Called once at the end of the query | |
195 | ||
196 | fList = dynamic_cast<TList*> (GetOutputData(0)); | |
197 | if (!fList) { | |
198 | Printf("ERROR: fList not available"); | |
199 | return; | |
200 | } | |
201 | ||
202 | TH2F *fHistYPtProtons = (TH2F *)fList->At(0); | |
203 | TH2F *fHistYPtAntiProtons = (TH2F *)fList->At(1); | |
204 | ||
df01f00b | 205 | TCanvas *c1 = new TCanvas("c1","p-\bar{p}",200,0,800,400); |
206 | c1->SetFillColor(10); c1->SetHighLightColor(10); c1->Divide(2,1); | |
734d2c12 | 207 | |
df01f00b | 208 | c1->cd(1)->SetLeftMargin(0.15); c1->cd(1)->SetBottomMargin(0.15); |
734d2c12 | 209 | if (fHistYPtProtons) fHistYPtProtons->DrawCopy("colz"); |
df01f00b | 210 | c1->cd(2)->SetLeftMargin(0.15); c1->cd(2)->SetBottomMargin(0.15); |
734d2c12 | 211 | if (fHistYPtAntiProtons) fHistYPtAntiProtons->DrawCopy("colz"); |
212 | } | |
213 | ||
214 |