]>
Commit | Line | Data |
---|---|---|
dc740de4 | 1 | /* $Id$ */ |
2 | ||
3 | #include "AlidNdEtaAnalysisESDSelector.h" | |
4 | ||
5 | #include <TStyle.h> | |
6 | #include <TSystem.h> | |
7 | #include <TCanvas.h> | |
8 | #include <TVector3.h> | |
7029240a | 9 | #include <TChain.h> |
16e24ca3 | 10 | #include <TFile.h> |
9e952c39 | 11 | #include <TH1F.h> |
dc740de4 | 12 | |
13 | #include <AliLog.h> | |
fcf2fb36 | 14 | #include <AliESDVertex.h> |
15 | #include <AliESD.h> | |
dc740de4 | 16 | |
17 | #include "esdTrackCuts/AliESDtrackCuts.h" | |
16e24ca3 | 18 | #include "dNdEta/dNdEtaAnalysis.h" |
45e97e28 | 19 | #include "AliPWG0Helper.h" |
dc740de4 | 20 | |
74fd10b3 | 21 | #include "AliGenEventHeader.h" |
22 | #include "AliHeader.h" | |
23 | #include "AliStack.h" | |
24 | #include "TParticle.h" | |
25 | ||
dc740de4 | 26 | ClassImp(AlidNdEtaAnalysisESDSelector) |
27 | ||
28 | AlidNdEtaAnalysisESDSelector::AlidNdEtaAnalysisESDSelector() : | |
74fd10b3 | 29 | AliSelectorRL(), |
1afae8ff | 30 | fdNdEtaAnalysis(0), |
9e952c39 | 31 | fMult(0), |
74fd10b3 | 32 | fEsdTrackCuts(0) |
33 | { | |
dc740de4 | 34 | // |
35 | // Constructor. Initialization of pointers | |
36 | // | |
16e24ca3 | 37 | |
0ab29cfa | 38 | AliLog::SetClassDebugLevel("AlidNdEtaAnalysisESDSelector", AliLog::kDebug); |
dc740de4 | 39 | } |
40 | ||
41 | AlidNdEtaAnalysisESDSelector::~AlidNdEtaAnalysisESDSelector() | |
42 | { | |
43 | // | |
44 | // Destructor | |
45 | // | |
46 | ||
47 | // histograms are in the output list and deleted when the output | |
48 | // list is deleted by the TSelector dtor | |
49 | } | |
50 | ||
0ab29cfa | 51 | void AlidNdEtaAnalysisESDSelector::Begin(TTree* tree) |
dc740de4 | 52 | { |
0ab29cfa | 53 | // Begin function |
dc740de4 | 54 | |
0ab29cfa | 55 | ReadUserObjects(tree); |
56 | } | |
dc740de4 | 57 | |
0ab29cfa | 58 | void AlidNdEtaAnalysisESDSelector::ReadUserObjects(TTree* tree) |
59 | { | |
60 | // read the user objects, called from slavebegin and begin | |
dc740de4 | 61 | |
16e24ca3 | 62 | if (!fEsdTrackCuts && fInput) |
63 | fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fInput->FindObject("AliESDtrackCuts")); | |
64 | ||
1afae8ff | 65 | if (!fEsdTrackCuts && tree) |
66 | fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (tree->GetUserInfo()->FindObject("AliESDtrackCuts")); | |
67 | ||
16e24ca3 | 68 | if (!fEsdTrackCuts) |
69 | AliDebug(AliLog::kError, "ERROR: Could not read EsdTrackCuts from input list."); | |
0ab29cfa | 70 | } |
1afae8ff | 71 | |
0ab29cfa | 72 | void AlidNdEtaAnalysisESDSelector::SlaveBegin(TTree* tree) |
73 | { | |
74 | // The SlaveBegin() function is called after the Begin() function. | |
75 | // When running with PROOF SlaveBegin() is called on each slave server. | |
76 | // The tree argument is deprecated (on PROOF 0 is passed). | |
77 | ||
74fd10b3 | 78 | AliSelectorRL::SlaveBegin(tree); |
0ab29cfa | 79 | |
80 | ReadUserObjects(tree); | |
1afae8ff | 81 | |
16e24ca3 | 82 | fdNdEtaAnalysis = new dNdEtaAnalysis("dndeta", "dndeta"); |
9e952c39 | 83 | fMult = new TH1F("fMult", "fMult;Ntracks;Count", 201, -0.5, 200.5); |
16e24ca3 | 84 | } |
85 | ||
86 | void AlidNdEtaAnalysisESDSelector::Init(TTree* tree) | |
87 | { | |
88 | // read the user objects | |
89 | ||
74fd10b3 | 90 | AliSelectorRL::Init(tree); |
5c495d37 | 91 | |
92 | // Enable only the needed branches | |
93 | if (tree) | |
94 | { | |
95 | tree->SetBranchStatus("*", 0); | |
96 | tree->SetBranchStatus("fTriggerMask", 1); | |
97 | tree->SetBranchStatus("fSPDVertex*", 1); | |
74fd10b3 | 98 | tree->SetBranchStatus("fTracks.fLabel", 1); |
5c495d37 | 99 | |
100 | AliESDtrackCuts::EnableNeededBranches(tree); | |
101 | } | |
dc740de4 | 102 | } |
103 | ||
104 | Bool_t AlidNdEtaAnalysisESDSelector::Process(Long64_t entry) | |
105 | { | |
74fd10b3 | 106 | // loop over all events |
dc740de4 | 107 | |
74fd10b3 | 108 | if (AliSelectorRL::Process(entry) == kFALSE) |
dc740de4 | 109 | return kFALSE; |
110 | ||
111 | // Check prerequisites | |
112 | if (!fESD) | |
113 | { | |
114 | AliDebug(AliLog::kError, "ESD branch not available"); | |
115 | return kFALSE; | |
116 | } | |
117 | ||
118 | if (!fEsdTrackCuts) | |
119 | { | |
120 | AliDebug(AliLog::kError, "fESDTrackCuts not available"); | |
121 | return kFALSE; | |
122 | } | |
123 | ||
847489f7 | 124 | if (AliPWG0Helper::IsEventTriggered(fESD) == kFALSE) |
5c495d37 | 125 | { |
126 | AliDebug(AliLog::kDebug+1, Form("Skipping event %d because it was not triggered", (Int_t) entry)); | |
847489f7 | 127 | return kTRUE; |
5c495d37 | 128 | } |
847489f7 | 129 | |
45e97e28 | 130 | if (AliPWG0Helper::IsVertexReconstructed(fESD) == kFALSE) |
5c495d37 | 131 | { |
132 | AliDebug(AliLog::kDebug+1, Form("Skipping event %d because its vertex was not reconstructed", (Int_t) entry)); | |
dc740de4 | 133 | return kTRUE; |
5c495d37 | 134 | } |
dc740de4 | 135 | |
74fd10b3 | 136 | AliHeader* header = GetHeader(); |
137 | if (!header) | |
138 | { | |
139 | AliDebug(AliLog::kError, "Header not available"); | |
140 | return kFALSE; | |
141 | } | |
142 | ||
143 | AliStack* stack = GetStack(); | |
144 | if (!stack) | |
145 | { | |
146 | AliDebug(AliLog::kError, "Stack not available"); | |
147 | return kFALSE; | |
148 | } | |
149 | ||
150 | // get the MC vertex | |
151 | AliGenEventHeader* genHeader = header->GenEventHeader(); | |
152 | ||
153 | TArrayF vtxMC(3); | |
154 | genHeader->PrimaryVertex(vtxMC); | |
155 | ||
45e97e28 | 156 | // ######################################################## |
74fd10b3 | 157 | // get the ESD vertex |
45e97e28 | 158 | const AliESDVertex* vtxESD = fESD->GetVertex(); |
dc740de4 | 159 | Double_t vtx[3]; |
160 | vtxESD->GetXYZ(vtx); | |
161 | ||
0448e811 | 162 | //vtx[2] = vtxMC[2]; |
9e952c39 | 163 | //vtx[2] -= 2.951034e-03 + 6.859620e-04 * vtxMC[2]; |
74fd10b3 | 164 | |
45e97e28 | 165 | // get number of "good" tracks |
166 | TObjArray* list = fEsdTrackCuts->GetAcceptedTracks(fESD); | |
167 | Int_t nGoodTracks = list->GetEntries(); | |
168 | ||
74fd10b3 | 169 | // FAKE test! |
170 | //Int_t nContributors = vtxESD->GetNContributors(); | |
1afae8ff | 171 | |
dc740de4 | 172 | // loop over esd tracks |
45e97e28 | 173 | for (Int_t t=0; t<nGoodTracks; t++) |
dc740de4 | 174 | { |
45e97e28 | 175 | AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (list->At(t)); |
dc740de4 | 176 | if (!esdTrack) |
177 | { | |
178 | AliDebug(AliLog::kError, Form("ERROR: Could not retrieve track %d.", t)); | |
179 | continue; | |
180 | } | |
181 | ||
74fd10b3 | 182 | Int_t label = TMath::Abs(esdTrack->GetLabel()); |
183 | ||
74fd10b3 | 184 | TParticle* particle = stack->Particle(label); |
185 | if (!particle) | |
186 | { | |
187 | AliDebug(AliLog::kError, Form("ERROR: Could not retrieve particle %d.", esdTrack->GetLabel())); | |
188 | continue; | |
189 | } | |
190 | ||
dc740de4 | 191 | Double_t p[3]; |
38233af1 | 192 | esdTrack->GetConstrainedPxPyPz(p); // ### TODO should be okay because we have a vertex, however GetInnerPxPyPy / GetOuterPxPyPy also exist |
dc740de4 | 193 | TVector3 vector(p); |
194 | ||
195 | Float_t theta = vector.Theta(); | |
196 | Float_t eta = -TMath::Log(TMath::Tan(theta/2.)); | |
45e97e28 | 197 | Float_t pt = vector.Pt(); |
198 | ||
74fd10b3 | 199 | //eta = particle->Eta(); |
200 | //pt = particle->Pt(); | |
45e97e28 | 201 | |
74fd10b3 | 202 | fdNdEtaAnalysis->FillTrack(vtx[2], eta, pt); |
dc740de4 | 203 | } // end of track loop |
204 | ||
45e97e28 | 205 | delete list; |
206 | list = 0; | |
207 | ||
dc740de4 | 208 | // for event count per vertex |
74fd10b3 | 209 | fdNdEtaAnalysis->FillEvent(vtx[2], nGoodTracks); |
9e952c39 | 210 | fMult->Fill(nGoodTracks); |
dc740de4 | 211 | |
212 | return kTRUE; | |
213 | } | |
214 | ||
16e24ca3 | 215 | void AlidNdEtaAnalysisESDSelector::SlaveTerminate() |
216 | { | |
217 | // The SlaveTerminate() function is called after all entries or objects | |
218 | // have been processed. When running with PROOF SlaveTerminate() is called | |
219 | // on each slave server. | |
220 | ||
74fd10b3 | 221 | AliSelectorRL::SlaveTerminate(); |
16e24ca3 | 222 | |
223 | // Add the histograms to the output on each slave server | |
224 | if (!fOutput) | |
225 | { | |
226 | AliDebug(AliLog::kError, Form("ERROR: Output list not initialized.")); | |
227 | return; | |
228 | } | |
229 | ||
38233af1 | 230 | // Add the objects to the output list and set them to 0, so that the destructor does not delete them. |
231 | ||
16e24ca3 | 232 | fOutput->Add(fdNdEtaAnalysis); |
9e952c39 | 233 | fOutput->Add(fMult); |
234 | ||
38233af1 | 235 | fdNdEtaAnalysis = 0; |
16e24ca3 | 236 | } |
237 | ||
238 | void AlidNdEtaAnalysisESDSelector::Terminate() | |
dc740de4 | 239 | { |
16e24ca3 | 240 | // The Terminate() function is the last function to be called during |
241 | // a query. It always runs on the client, it can be used to present | |
242 | // the results graphically or save the results to file. | |
243 | ||
74fd10b3 | 244 | AliSelectorRL::Terminate(); |
16e24ca3 | 245 | |
246 | fdNdEtaAnalysis = dynamic_cast<dNdEtaAnalysis*> (fOutput->FindObject("dndeta")); | |
9e952c39 | 247 | fMult = dynamic_cast<TH1F*> (fOutput->FindObject("fMult")); |
16e24ca3 | 248 | |
74fd10b3 | 249 | if (!fdNdEtaAnalysis) |
16e24ca3 | 250 | { |
74fd10b3 | 251 | AliDebug(AliLog::kError, "ERROR: Histograms not available"); |
16e24ca3 | 252 | return; |
253 | } | |
254 | ||
74fd10b3 | 255 | TFile* fout = new TFile("analysis_esd_raw.root", "RECREATE"); |
16e24ca3 | 256 | |
257 | if (fdNdEtaAnalysis) | |
258 | fdNdEtaAnalysis->SaveHistograms(); | |
dc740de4 | 259 | |
260 | if (fEsdTrackCuts) | |
261 | fEsdTrackCuts->SaveHistograms("esd_tracks_cuts"); | |
16e24ca3 | 262 | |
9e952c39 | 263 | if (fMult) |
264 | fMult->Write(); | |
265 | ||
16e24ca3 | 266 | fout->Write(); |
267 | fout->Close(); | |
dc740de4 | 268 | } |