]>
Commit | Line | Data |
---|---|---|
dc740de4 | 1 | /* $Id$ */ |
2 | ||
79ab56b9 | 3 | #include "AlidNdEtaCorrectionSelector.h" |
539b6cb4 | 4 | |
5 | #include <TStyle.h> | |
6 | #include <TSystem.h> | |
7 | #include <TCanvas.h> | |
8 | #include <TParticle.h> | |
9 | #include <TParticlePDG.h> | |
10 | ||
745e836a | 11 | #include <TChain.h> |
12 | #include <TSelector.h> | |
45e97e28 | 13 | #include <TFile.h> |
745e836a | 14 | |
539b6cb4 | 15 | #include <AliLog.h> |
79ab56b9 | 16 | #include <AliGenEventHeader.h> |
539b6cb4 | 17 | #include <AliTracker.h> |
745e836a | 18 | #include <AliHeader.h> |
fcf2fb36 | 19 | #include <AliESDVertex.h> |
20 | #include <AliESD.h> | |
21 | #include <AliESDtrack.h> | |
45e97e28 | 22 | #include <AliRunLoader.h> |
23 | #include <AliStack.h> | |
539b6cb4 | 24 | |
37dbb69e | 25 | #include "esdTrackCuts/AliESDtrackCuts.h" |
45e97e28 | 26 | #include "dNdEta/AlidNdEtaCorrection.h" |
27 | #include "AliPWG0Helper.h" | |
539b6cb4 | 28 | |
79ab56b9 | 29 | ClassImp(AlidNdEtaCorrectionSelector) |
539b6cb4 | 30 | |
fcf2fb36 | 31 | AlidNdEtaCorrectionSelector::AlidNdEtaCorrectionSelector() : |
16e24ca3 | 32 | AliSelectorRL(), |
539b6cb4 | 33 | fEsdTrackCuts(0), |
406eb63e | 34 | fdNdEtaCorrection(0), |
35 | fSignMode(0) | |
539b6cb4 | 36 | { |
79ab56b9 | 37 | // |
539b6cb4 | 38 | // Constructor. Initialization of pointers |
79ab56b9 | 39 | // |
539b6cb4 | 40 | } |
41 | ||
79ab56b9 | 42 | AlidNdEtaCorrectionSelector::~AlidNdEtaCorrectionSelector() |
539b6cb4 | 43 | { |
79ab56b9 | 44 | // |
45 | // Destructor | |
46 | // | |
539b6cb4 | 47 | |
48 | // histograms are in the output list and deleted when the output | |
49 | // list is deleted by the TSelector dtor | |
50 | } | |
51 | ||
406eb63e | 52 | Bool_t AlidNdEtaCorrectionSelector::SignOK(Double_t charge) |
53 | { | |
54 | // returns if a particle with this sign should be counted | |
55 | // this is determined by the value of fSignMode, which should have the same sign | |
56 | // as the charge | |
57 | // if fSignMode is 0 all particles are counted | |
58 | ||
59 | if (fSignMode > 0) | |
60 | if (charge < 0) | |
61 | return kFALSE; | |
62 | ||
63 | if (fSignMode < 0) | |
64 | if (charge > 0) | |
65 | return kFALSE; | |
66 | ||
67 | return kTRUE; | |
68 | } | |
69 | ||
79ab56b9 | 70 | void AlidNdEtaCorrectionSelector::Begin(TTree * tree) |
539b6cb4 | 71 | { |
72 | // The Begin() function is called at the start of the query. | |
73 | // When running with PROOF Begin() is only called on the client. | |
74 | // The tree argument is deprecated (on PROOF 0 is passed). | |
75 | ||
16e24ca3 | 76 | AliSelectorRL::Begin(tree); |
406eb63e | 77 | |
78 | TString option = GetOption(); | |
79 | AliInfo(Form("Called with option %s.", option.Data())); | |
80 | ||
81 | if (option.Contains("only-positive")) | |
82 | { | |
83 | AliInfo("Processing only positive particles."); | |
84 | fSignMode = 1; | |
85 | } | |
86 | else if (option.Contains("only-negative")) | |
87 | { | |
88 | AliInfo("Processing only negative particles."); | |
89 | fSignMode = -1; | |
90 | } | |
539b6cb4 | 91 | } |
92 | ||
79ab56b9 | 93 | void AlidNdEtaCorrectionSelector::SlaveBegin(TTree * tree) |
539b6cb4 | 94 | { |
95 | // The SlaveBegin() function is called after the Begin() function. | |
96 | // When running with PROOF SlaveBegin() is called on each slave server. | |
97 | // The tree argument is deprecated (on PROOF 0 is passed). | |
98 | ||
16e24ca3 | 99 | AliSelectorRL::SlaveBegin(tree); |
539b6cb4 | 100 | |
8b3563f4 | 101 | fdNdEtaCorrection = new AlidNdEtaCorrection("dndeta_correction", "dndeta_correction"); |
539b6cb4 | 102 | |
16e24ca3 | 103 | if (fTree) |
104 | fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fTree->GetUserInfo()->FindObject("AliESDtrackCuts")); | |
539b6cb4 | 105 | |
79ab56b9 | 106 | if (!fEsdTrackCuts) |
b8e8168f | 107 | AliDebug(AliLog::kError, "ERROR: Could not read EsdTrackCuts from user info"); |
539b6cb4 | 108 | } |
109 | ||
79ab56b9 | 110 | Bool_t AlidNdEtaCorrectionSelector::Process(Long64_t entry) |
539b6cb4 | 111 | { |
112 | // The Process() function is called for each entry in the tree (or possibly | |
113 | // keyed object in the case of PROOF) to be processed. The entry argument | |
114 | // specifies which entry in the currently loaded tree is to be processed. | |
115 | // It can be passed to either TTree::GetEntry() or TBranch::GetEntry() | |
116 | // to read either all or the required parts of the data. When processing | |
117 | // keyed objects with PROOF, the object is already loaded and is available | |
118 | // via the fObject pointer. | |
119 | // | |
120 | // This function should contain the "body" of the analysis. It can contain | |
121 | // simple or elaborate selection criteria, run algorithms on the data | |
122 | // of the event and typically fill histograms. | |
123 | ||
124 | // WARNING when a selector is used with a TChain, you must use | |
125 | // the pointer to the current TTree to call GetEntry(entry). | |
126 | // The entry is always the local entry number in the current tree. | |
16e24ca3 | 127 | // Assuming that fTree is the pointer to the TChain being processed, |
128 | // use fTree->GetTree()->GetEntry(entry). | |
539b6cb4 | 129 | |
16e24ca3 | 130 | if (AliSelectorRL::Process(entry) == kFALSE) |
539b6cb4 | 131 | return kFALSE; |
132 | ||
b8e8168f | 133 | // check prerequesites |
134 | if (!fESD) | |
135 | { | |
136 | AliDebug(AliLog::kError, "ESD branch not available"); | |
137 | return kFALSE; | |
138 | } | |
139 | ||
dc740de4 | 140 | AliHeader* header = GetHeader(); |
141 | if (!header) | |
b8e8168f | 142 | { |
dc740de4 | 143 | AliDebug(AliLog::kError, "Header not available"); |
b8e8168f | 144 | return kFALSE; |
145 | } | |
146 | ||
d09fb536 | 147 | AliStack* stack = GetStack(); |
45e97e28 | 148 | if (!stack) |
149 | { | |
150 | AliDebug(AliLog::kError, "Stack not available"); | |
151 | return kFALSE; | |
152 | } | |
153 | ||
b8e8168f | 154 | if (!fEsdTrackCuts) |
155 | { | |
156 | AliDebug(AliLog::kError, "fESDTrackCuts not available"); | |
539b6cb4 | 157 | return kFALSE; |
b8e8168f | 158 | } |
539b6cb4 | 159 | |
45e97e28 | 160 | Bool_t vertexReconstructed = AliPWG0Helper::IsVertexReconstructed(fESD); |
745e836a | 161 | |
45e97e28 | 162 | Bool_t eventTriggered = AliPWG0Helper::IsEventTriggered(fESD); |
539b6cb4 | 163 | |
45e97e28 | 164 | fdNdEtaCorrection->IncreaseEventCount(); |
165 | if (eventTriggered) | |
166 | fdNdEtaCorrection->IncreaseTriggeredEventCount(); | |
539b6cb4 | 167 | |
539b6cb4 | 168 | // get the MC vertex |
dc740de4 | 169 | AliGenEventHeader* genHeader = header->GenEventHeader(); |
539b6cb4 | 170 | |
171 | TArrayF vtxMC(3); | |
172 | genHeader->PrimaryVertex(vtxMC); | |
539b6cb4 | 173 | |
539b6cb4 | 174 | // loop over mc particles |
45e97e28 | 175 | Int_t nPrim = stack->GetNprimary(); |
539b6cb4 | 176 | |
45e97e28 | 177 | for (Int_t iMc = 0; iMc < nPrim; ++iMc) |
539b6cb4 | 178 | { |
45e97e28 | 179 | AliDebug(AliLog::kDebug+1, Form("MC Loop: Processing particle %d.", iMc)); |
180 | ||
181 | TParticle* particle = stack->Particle(iMc); | |
539b6cb4 | 182 | |
183 | if (!particle) | |
45e97e28 | 184 | { |
185 | AliDebug(AliLog::kError, Form("UNEXPECTED: particle with label %d not found in stack (mc loop).", iMc)); | |
539b6cb4 | 186 | continue; |
45e97e28 | 187 | } |
539b6cb4 | 188 | |
45e97e28 | 189 | if (AliPWG0Helper::IsPrimaryCharged(particle, nPrim) == kFALSE) |
539b6cb4 | 190 | continue; |
191 | ||
406eb63e | 192 | if (SignOK(particle->GetPDG()->Charge()) == kFALSE) |
193 | continue; | |
194 | ||
745e836a | 195 | Float_t eta = particle->Eta(); |
45e97e28 | 196 | Float_t pt = particle->Pt(); |
197 | ||
198 | if (vertexReconstructed) | |
199 | fdNdEtaCorrection->FillParticle(vtxMC[2], eta, pt); | |
539b6cb4 | 200 | |
45e97e28 | 201 | fdNdEtaCorrection->FillParticleAllEvents(eta, pt); |
202 | if (eventTriggered) | |
203 | fdNdEtaCorrection->FillParticleWhenEventTriggered(eta, pt); | |
204 | }// end of mc particle | |
e8cb44f1 | 205 | |
539b6cb4 | 206 | // ######################################################## |
207 | // loop over esd tracks | |
208 | Int_t nTracks = fESD->GetNumberOfTracks(); | |
45e97e28 | 209 | |
406eb63e | 210 | // count the number of "good" tracks as parameter for vertex reconstruction efficiency |
45e97e28 | 211 | Int_t nGoodTracks = 0; |
539b6cb4 | 212 | for (Int_t t=0; t<nTracks; t++) |
213 | { | |
45e97e28 | 214 | AliDebug(AliLog::kDebug+1, Form("ESD Loop: Processing track %d.", t)); |
215 | ||
539b6cb4 | 216 | AliESDtrack* esdTrack = fESD->GetTrack(t); |
217 | ||
218 | // cut the esd track? | |
219 | if (!fEsdTrackCuts->AcceptTrack(esdTrack)) | |
220 | continue; | |
221 | ||
45e97e28 | 222 | nGoodTracks++; |
223 | ||
224 | // using the properties of the mc particle | |
539b6cb4 | 225 | Int_t label = TMath::Abs(esdTrack->GetLabel()); |
79ab56b9 | 226 | if (label == 0) |
539b6cb4 | 227 | { |
b8e8168f | 228 | AliDebug(AliLog::kWarning, Form("WARNING: cannot find corresponding mc part for track %d.", t)); |
539b6cb4 | 229 | continue; |
230 | } | |
539b6cb4 | 231 | |
45e97e28 | 232 | TParticle* particle = stack->Particle(label); |
233 | if (!particle) | |
234 | { | |
235 | AliDebug(AliLog::kError, Form("UNEXPECTED: particle with label %d not found in stack (track loop).", label)); | |
236 | continue; | |
237 | } | |
539b6cb4 | 238 | |
406eb63e | 239 | if (SignOK(particle->GetPDG()->Charge()) == kFALSE) |
240 | continue; | |
241 | ||
45e97e28 | 242 | if (vertexReconstructed) |
243 | fdNdEtaCorrection->FillParticleWhenMeasuredTrack(vtxMC[2], particle->Eta(), particle->Pt()); | |
539b6cb4 | 244 | } // end of track loop |
245 | ||
1afae8ff | 246 | fdNdEtaCorrection->FillEvent(vtxMC[2], nGoodTracks); |
847489f7 | 247 | if (eventTriggered) |
248 | { | |
1afae8ff | 249 | fdNdEtaCorrection->FillEventWithTrigger(vtxMC[2], nGoodTracks); |
847489f7 | 250 | if (vertexReconstructed) |
1afae8ff | 251 | fdNdEtaCorrection->FillEventWithTriggerWithReconstructedVertex(vtxMC[2], nGoodTracks); |
847489f7 | 252 | } |
45e97e28 | 253 | |
539b6cb4 | 254 | return kTRUE; |
255 | } | |
256 | ||
79ab56b9 | 257 | void AlidNdEtaCorrectionSelector::SlaveTerminate() |
539b6cb4 | 258 | { |
259 | // The SlaveTerminate() function is called after all entries or objects | |
260 | // have been processed. When running with PROOF SlaveTerminate() is called | |
261 | // on each slave server. | |
262 | ||
16e24ca3 | 263 | AliSelectorRL::SlaveTerminate(); |
539b6cb4 | 264 | |
265 | // Add the histograms to the output on each slave server | |
266 | if (!fOutput) | |
267 | { | |
b8e8168f | 268 | AliDebug(AliLog::kError, "ERROR: Output list not initialized"); |
539b6cb4 | 269 | return; |
270 | } | |
79ab56b9 | 271 | |
745e836a | 272 | fOutput->Add(fdNdEtaCorrection); |
539b6cb4 | 273 | } |
274 | ||
79ab56b9 | 275 | void AlidNdEtaCorrectionSelector::Terminate() |
539b6cb4 | 276 | { |
277 | // The Terminate() function is the last function to be called during | |
278 | // a query. It always runs on the client, it can be used to present | |
279 | // the results graphically or save the results to file. | |
280 | ||
16e24ca3 | 281 | AliSelectorRL::Terminate(); |
539b6cb4 | 282 | |
45e97e28 | 283 | fdNdEtaCorrection = dynamic_cast<AlidNdEtaCorrection*> (fOutput->FindObject("dndeta_correction")); |
79ab56b9 | 284 | |
45e97e28 | 285 | fdNdEtaCorrection->Finish(); |
539b6cb4 | 286 | |
406eb63e | 287 | TFile* fout = new TFile(Form("correction_map%s.root", GetOption()), "RECREATE"); |
539b6cb4 | 288 | |
289 | fEsdTrackCuts->SaveHistograms("esd_track_cuts"); | |
45e97e28 | 290 | fdNdEtaCorrection->SaveHistograms(); |
539b6cb4 | 291 | |
292 | fout->Write(); | |
293 | fout->Close(); | |
294 | ||
45e97e28 | 295 | fdNdEtaCorrection->DrawHistograms(); |
539b6cb4 | 296 | } |