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