]>
Commit | Line | Data |
---|---|---|
70da6c5a | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | // | |
16 | // The analysis task: | |
17 | // study displaced electrons from beauty and charm | |
18 | // with cut on impact parameters in various pT bins | |
19 | // | |
20 | // | |
21 | // Authors: | |
22 | // Hongyan Yang <hongyan@physi.uni-heidelberg.de> | |
faee3b18 | 23 | // Carlo Bombonati <Carlo.Bombonati@cern.ch> |
70da6c5a | 24 | // |
25 | ||
26 | #include <TChain.h> | |
27 | #include <TFile.h> | |
28 | #include <TH1F.h> | |
29 | #include <TH1I.h> | |
30 | #include "AliLog.h" | |
31 | ||
32 | #include <TList.h> | |
33 | #include <TMath.h> | |
34 | #include <TObjArray.h> | |
35 | #include <TParticle.h> | |
36 | #include <TString.h> | |
70da6c5a | 37 | #include <TCanvas.h> |
38 | ||
39 | #include "AliCFManager.h" | |
40 | #include "AliMCEvent.h" | |
41 | #include "AliMCEventHandler.h" | |
faee3b18 | 42 | #include "AliMCParticle.h" |
43 | #include "AliStack.h" | |
44 | ||
70da6c5a | 45 | #include "AliESDEvent.h" |
46 | #include "AliESDInputHandler.h" | |
47 | #include "AliESDtrack.h" | |
faee3b18 | 48 | #include "AliESDpid.h" |
70da6c5a | 49 | |
faee3b18 | 50 | #include "AliAnalysisManager.h" |
70da6c5a | 51 | |
52 | #include "AliHFEpid.h" | |
53 | #include "AliHFEcuts.h" | |
faee3b18 | 54 | #include "AliHFEtools.h" |
70da6c5a | 55 | #include "AliHFEdisplacedElectrons.h" |
70da6c5a | 56 | #include "AliAnalysisTaskDisplacedElectrons.h" |
57 | ||
58 | ||
59 | //____________________________________________________________ | |
60 | AliAnalysisTaskDisplacedElectrons::AliAnalysisTaskDisplacedElectrons(): | |
61 | AliAnalysisTaskSE("Task for displaced electron study") | |
faee3b18 | 62 | , fDeDebugLevel(0) |
63 | , fNminITSCluster(0) | |
64 | , fNminPrimVtxContrib(0) | |
65 | , fDePIDdetectors("") | |
66 | , fDePIDstrategy(0) | |
67 | , fDePlugins(0) | |
68 | , fDeCuts(0x0) | |
69 | , fDeDefaultPID(0x0) | |
70 | , fDePID(0x0) | |
71 | , fDeCFM(0x0) | |
70da6c5a | 72 | , fDisplacedElectrons(0x0) |
faee3b18 | 73 | , fDeNEvents(0x0) |
74 | , fElectronsMcPt(0x0) | |
75 | , fElectronsEsdPt(0x0) | |
76 | , fElectronsDataPt(0x0) | |
77 | , fDeCorrection(0x0) | |
78 | , fDeQA(0x0) | |
70da6c5a | 79 | , fHistDisplacedElectrons(0x0) |
80 | { | |
81 | // | |
82 | // Dummy constructor | |
83 | // | |
84 | DefineInput(0, TChain::Class()); | |
faee3b18 | 85 | DefineOutput(1, TList::Class()); // displacedElectron |
86 | DefineOutput(2, TList::Class()); // correction framework | |
87 | DefineOutput(3, TList::Class()); // QA | |
70da6c5a | 88 | |
70da6c5a | 89 | // Initialize pid |
faee3b18 | 90 | |
91 | fDeDefaultPID = new AliESDpid; | |
69ac0e6f | 92 | fDePID = new AliHFEpid; |
70da6c5a | 93 | |
94 | ||
95 | } | |
96 | ||
97 | //____________________________________________________________ | |
98 | AliAnalysisTaskDisplacedElectrons::AliAnalysisTaskDisplacedElectrons(const char * name): | |
99 | AliAnalysisTaskSE(name) | |
faee3b18 | 100 | , fDeDebugLevel(0) |
101 | , fNminITSCluster(0) | |
102 | , fNminPrimVtxContrib(0) | |
103 | , fDePIDdetectors("") | |
104 | , fDePIDstrategy(0) | |
105 | , fDePlugins(0) | |
106 | , fDeCuts(0x0) | |
107 | , fDeDefaultPID(0x0) | |
108 | , fDePID(0x0) | |
109 | , fDeCFM(0x0) | |
70da6c5a | 110 | , fDisplacedElectrons(0x0) |
faee3b18 | 111 | , fDeNEvents(0x0) |
112 | , fElectronsMcPt(0x0) | |
113 | , fElectronsEsdPt(0x0) | |
114 | , fElectronsDataPt(0x0) | |
115 | , fDeCorrection(0x0) | |
116 | , fDeQA(0x0) | |
70da6c5a | 117 | , fHistDisplacedElectrons(0x0) |
118 | { | |
119 | // | |
120 | // Default constructor | |
121 | // | |
122 | DefineInput(0, TChain::Class()); | |
70da6c5a | 123 | DefineOutput(1, TList::Class()); |
faee3b18 | 124 | DefineOutput(2, TList::Class()); |
125 | DefineOutput(3, TList::Class()); | |
126 | ||
127 | // Initialize pid | |
128 | fDeDefaultPID = new AliESDpid; | |
69ac0e6f | 129 | fDePID = new AliHFEpid; |
70da6c5a | 130 | |
70da6c5a | 131 | } |
132 | ||
133 | //____________________________________________________________ | |
134 | AliAnalysisTaskDisplacedElectrons::AliAnalysisTaskDisplacedElectrons(const AliAnalysisTaskDisplacedElectrons &ref): | |
135 | AliAnalysisTaskSE(ref) | |
faee3b18 | 136 | , fDeDebugLevel(ref.fDeDebugLevel) |
137 | , fNminITSCluster(ref.fNminITSCluster) | |
138 | , fNminPrimVtxContrib(ref.fNminPrimVtxContrib) | |
139 | , fDePIDdetectors(ref.fDePIDdetectors) | |
140 | , fDePIDstrategy(ref.fDePIDstrategy) | |
141 | , fDePlugins(ref.fDePlugins) | |
142 | , fDeCuts(ref.fDeCuts) | |
143 | , fDeDefaultPID(ref.fDeDefaultPID) | |
144 | , fDePID(ref.fDePID) | |
145 | , fDeCFM(ref.fDeCFM) | |
70da6c5a | 146 | , fDisplacedElectrons(ref.fDisplacedElectrons) |
faee3b18 | 147 | , fDeNEvents(ref.fDeNEvents) |
148 | , fElectronsMcPt(ref.fElectronsMcPt) | |
149 | , fElectronsEsdPt(ref.fElectronsEsdPt) | |
150 | , fElectronsDataPt(ref.fElectronsDataPt) | |
151 | , fDeCorrection(ref.fDeCorrection) | |
152 | , fDeQA(ref.fDeQA) | |
70da6c5a | 153 | , fHistDisplacedElectrons(ref.fHistDisplacedElectrons) |
154 | { | |
155 | // | |
156 | // Copy Constructor | |
157 | // | |
158 | } | |
159 | ||
160 | //____________________________________________________________ | |
161 | AliAnalysisTaskDisplacedElectrons &AliAnalysisTaskDisplacedElectrons::operator=(const AliAnalysisTaskDisplacedElectrons &ref){ | |
162 | // | |
163 | // Assignment operator | |
164 | // | |
165 | if(this == &ref) return *this; | |
166 | AliAnalysisTask::operator=(ref); | |
faee3b18 | 167 | fDeDebugLevel = ref.fDeDebugLevel; |
168 | fNminITSCluster = ref.fNminITSCluster; | |
169 | fNminPrimVtxContrib = ref.fNminPrimVtxContrib; | |
170 | fDePIDdetectors = ref.fDePIDdetectors; | |
171 | fDePIDstrategy = ref.fDePIDstrategy; | |
172 | fDePlugins = ref.fDePlugins; | |
173 | fDeDefaultPID = ref.fDeDefaultPID; | |
174 | fDePID = ref.fDePID; | |
175 | fDeCuts = ref.fDeCuts; | |
176 | fDeCFM = ref.fDeCFM; | |
70da6c5a | 177 | fDisplacedElectrons = ref.fDisplacedElectrons; |
faee3b18 | 178 | fDeNEvents = ref.fDeNEvents; |
179 | fElectronsMcPt = ref.fElectronsMcPt; | |
180 | fElectronsEsdPt = ref.fElectronsEsdPt; | |
181 | fElectronsDataPt = ref.fElectronsDataPt; | |
182 | fDeCorrection = ref.fDeCorrection; | |
183 | fDeQA = ref.fDeQA; | |
70da6c5a | 184 | fHistDisplacedElectrons = ref.fHistDisplacedElectrons; |
185 | ||
186 | return *this; | |
187 | } | |
188 | ||
189 | //____________________________________________________________ | |
190 | AliAnalysisTaskDisplacedElectrons::~AliAnalysisTaskDisplacedElectrons(){ | |
191 | // | |
192 | // Destructor | |
193 | // | |
194 | ||
faee3b18 | 195 | if(fDeDefaultPID) delete fDeDefaultPID; |
196 | if(fDePID) delete fDePID; | |
197 | if(fDeCFM) delete fDeCFM; | |
198 | if(fDisplacedElectrons) delete fDisplacedElectrons; | |
199 | ||
200 | if(fDeNEvents) delete fDeNEvents; | |
201 | if(fElectronsMcPt) delete fElectronsMcPt; | |
202 | if(fElectronsEsdPt) delete fElectronsEsdPt; | |
203 | if(fElectronsDataPt) delete fElectronsDataPt; | |
204 | if(fDeCorrection){ | |
205 | fDeCorrection->Clear(); | |
206 | delete fDeCorrection; | |
70da6c5a | 207 | } |
faee3b18 | 208 | if(fDeQA){ |
209 | fDeQA->Clear(); | |
210 | delete fDeQA; | |
70da6c5a | 211 | } |
70da6c5a | 212 | if(fHistDisplacedElectrons){ |
213 | fHistDisplacedElectrons->Clear(); | |
214 | delete fHistDisplacedElectrons; | |
215 | } | |
70da6c5a | 216 | } |
217 | ||
218 | //____________________________________________________________ | |
219 | void AliAnalysisTaskDisplacedElectrons::UserCreateOutputObjects(){ | |
220 | // create output objects | |
faee3b18 | 221 | // fDeNEvents |
70da6c5a | 222 | // MC and Data containers |
223 | ||
faee3b18 | 224 | |
225 | if(!fDeQA) fDeQA = new TList; | |
226 | fDeQA->SetName("variousQAhistograms"); | |
227 | ||
228 | fDeNEvents = new TH1I("nDeEvents", "Number of Events in the DE Analysis", 2, 0, 2); | |
70da6c5a | 229 | const Int_t nBins = 14; |
230 | const Float_t ptBins[nBins] = {0.0,0.5,1.0,1.5,2.0,2.5,3.0,4.0,5.0,7.0,9.0,12.0,16.0,20.0}; | |
faee3b18 | 231 | fElectronsMcPt = new TH1F("mcElectronPt", "MC: p_{T} distribution of identified electrons (mcpid);p_{T} (GeV/c);Counts;", nBins-1, ptBins); |
232 | fElectronsEsdPt = new TH1F("esdElectronPt", "ESD: p_{T} distribution of identified electrons (hfepid);p_{T} (GeV/c);Counts;", nBins-1, ptBins); | |
233 | fElectronsDataPt = new TH1F("dataElectronPt", "DATA: p_{T} distribution of identified electrons (hfepid);p_{T} (GeV/c);Counts;", nBins-1, ptBins); | |
234 | ||
235 | fDeQA->AddAt(fDeNEvents,0); | |
236 | if(HasMCData()){ | |
237 | fDeQA->AddAt(fElectronsMcPt, 1); | |
238 | fDeQA->AddAt(fElectronsEsdPt, 2); | |
239 | } | |
240 | else | |
241 | fDeQA->AddAt(fElectronsDataPt, 1); | |
242 | ||
70da6c5a | 243 | // Initialize correction Framework and Cuts |
faee3b18 | 244 | fDeCFM = new AliCFManager; |
70da6c5a | 245 | MakeEventContainer(); |
246 | MakeParticleContainer(); | |
247 | ||
faee3b18 | 248 | if(!fDeCorrection) fDeCorrection = new TList(); |
249 | fDeCorrection->SetName("deCorrections"); | |
250 | fDeCorrection->AddAt(fDeCFM->GetEventContainer(), 0); | |
251 | fDeCorrection->AddAt(fDeCFM->GetParticleContainer(), 1); | |
252 | fDeCorrection->Print(); | |
253 | ||
254 | for(Int_t istep = 0; istep < fDeCFM->GetEventContainer()->GetNStep(); istep++) | |
255 | fDeCFM->SetEventCutsList(istep, 0x0); | |
256 | for(Int_t istep = 0; istep < fDeCFM->GetParticleContainer()->GetNStep(); istep++) | |
257 | fDeCFM->SetParticleCutsList(istep, 0x0); | |
258 | ||
259 | if(!fDeCuts){ | |
70da6c5a | 260 | AliWarning("Cuts not available. Default cuts will be used"); |
faee3b18 | 261 | fDeCuts = new AliHFEcuts; |
262 | fDeCuts->CreateStandardCuts(); | |
70da6c5a | 263 | } |
264 | ||
faee3b18 | 265 | fDeCuts->Initialize(fDeCFM); |
70da6c5a | 266 | |
faee3b18 | 267 | if(GetPlugin(kDePidQA)){ |
268 | AliInfo("PID QA switched on"); | |
269 | // fPID->SetDebugLevel(2); | |
270 | fDePID->SetQAOn(); | |
271 | fDeQA->Add(fDePID->GetQAhistograms()); | |
272 | } | |
273 | ||
274 | fDePID->SetHasMCData(HasMCData()); | |
275 | if(!fDePIDdetectors.Length() && ! fDePIDstrategy) AddPIDdetector("TPC"); | |
276 | if(fDePIDstrategy) | |
277 | fDePID->InitializePID(Form("Strategy%d", fDePIDstrategy)); | |
70da6c5a | 278 | else |
faee3b18 | 279 | fDePID->InitializePID(fDePIDdetectors.Data()); // Only restrictions to TPC allowed |
280 | ||
70da6c5a | 281 | // displaced electron study---------------------------------- |
282 | if(GetPlugin(kDisplacedElectrons)){ | |
283 | ||
284 | fDisplacedElectrons = new AliHFEdisplacedElectrons; | |
faee3b18 | 285 | fDisplacedElectrons->SetDebugLevel(fDeDebugLevel); |
70da6c5a | 286 | fDisplacedElectrons->SetHasMCData(HasMCData()); |
faee3b18 | 287 | fDisplacedElectrons->SetMinPrimVtxContrib(fNminPrimVtxContrib); |
288 | fDisplacedElectrons->SetNitsCluster(fNminITSCluster); | |
289 | ||
70da6c5a | 290 | if(!fHistDisplacedElectrons) fHistDisplacedElectrons = new TList(); |
70da6c5a | 291 | fDisplacedElectrons->CreateOutputs(fHistDisplacedElectrons); |
70da6c5a | 292 | } |
faee3b18 | 293 | |
70da6c5a | 294 | } |
295 | ||
296 | ||
297 | ||
298 | //____________________________________________________________ | |
299 | void AliAnalysisTaskDisplacedElectrons::UserExec(Option_t *){ | |
300 | // | |
301 | // Run the analysis | |
302 | // | |
303 | ||
faee3b18 | 304 | if(fDeDebugLevel>=10) AliInfo("analyse single event"); |
305 | ||
306 | if(!fInputEvent){ | |
307 | AliError("Reconstructed Event not available"); | |
70da6c5a | 308 | return; |
70da6c5a | 309 | } |
310 | ||
faee3b18 | 311 | // |
312 | AliESDInputHandler *inH = dynamic_cast<AliESDInputHandler *>(fInputHandler); | |
70da6c5a | 313 | |
69ac0e6f | 314 | if(!inH){ |
315 | AliError("AliESDInputHandler dynamic cast failed!"); | |
316 | return; | |
70da6c5a | 317 | } |
faee3b18 | 318 | |
319 | // from now on, only ESD are analyzed | |
320 | // using HFE pid, using HFE cuts | |
321 | // using CORRFW | |
322 | ||
323 | AliESDpid *workingPID = inH->GetESDpid(); | |
324 | if(workingPID){ | |
325 | AliDebug(1, "Using ESD PID from the input handler"); | |
326 | fDePID->SetESDpid(workingPID); | |
327 | } else { | |
328 | AliDebug(1, "Using default ESD PID"); | |
329 | fDePID->SetESDpid(AliHFEtools::GetDefaultPID(HasMCData())); | |
330 | } | |
331 | ||
332 | if(!fDeCuts){ | |
70da6c5a | 333 | AliError("HFE cuts not available"); |
334 | return; | |
335 | } | |
faee3b18 | 336 | |
69ac0e6f | 337 | // ---- CHOICE OF ANALYSIS ---- |
338 | if(HasMCData()){ | |
faee3b18 | 339 | // Protect against missing MC trees |
340 | AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler *>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); | |
69ac0e6f | 341 | if(!mcH){ |
342 | AliError("MC handler cuts not available"); | |
343 | return; | |
344 | } | |
345 | ||
faee3b18 | 346 | if(!mcH->InitOk()) return; |
347 | if(!mcH->TreeK()) return; | |
69ac0e6f | 348 | if(!mcH->TreeTR()) return; |
349 | ||
faee3b18 | 350 | AliDebug(4, Form("MC Event: %p", fMCEvent)); |
351 | if(!fMCEvent){ | |
352 | AliError("No MC Event, but MC Data required"); | |
353 | return; | |
354 | } | |
69ac0e6f | 355 | |
356 | ProcessMC(); // PURE MC | |
357 | ||
358 | if(IsESDanalysis()) ProcessESD(); // ESD WITH MC | |
359 | ||
360 | }else if(IsESDanalysis()) ProcessData(); // PURE ESD | |
faee3b18 | 361 | |
faee3b18 | 362 | |
363 | fDeNEvents->Fill(1); | |
364 | PostData(1, fHistDisplacedElectrons); | |
365 | PostData(2, fDeCorrection); | |
366 | PostData(3, fDeQA); | |
367 | ||
368 | } | |
369 | ||
370 | //____________________________________________________________ | |
371 | void AliAnalysisTaskDisplacedElectrons::ProcessMC(){ | |
372 | // | |
69ac0e6f | 373 | // handle pure MC analysis |
faee3b18 | 374 | // |
375 | ||
376 | Int_t nMCelectrons = 0; | |
377 | AliESDEvent *fESD = dynamic_cast<AliESDEvent *>(fInputEvent); | |
69ac0e6f | 378 | if(!fESD){ |
379 | AliError("ESD event not available"); | |
380 | return; | |
381 | } | |
faee3b18 | 382 | |
383 | Double_t mcContainer[4]; // container for the output in THnSparse | |
384 | memset(mcContainer, 0, sizeof(Double_t) * 4); | |
385 | ||
386 | fDeCFM->SetMCEventInfo(fMCEvent); | |
387 | ||
388 | Double_t nContributor = 0; | |
389 | const AliVVertex *mcPrimVtx = fMCEvent->GetPrimaryVertex(); | |
390 | if(mcPrimVtx) nContributor = mcPrimVtx->GetNContributors(); | |
391 | ||
392 | // | |
393 | // cut at MC event level | |
394 | // | |
395 | ||
396 | if(!fDeCFM->CheckEventCuts(AliHFEcuts::kEventStepGenerated, fMCEvent)) return; | |
397 | if(GetPlugin(kCorrection)) fDeCFM->GetEventContainer()->Fill(&nContributor,AliHFEcuts::kEventStepGenerated); | |
398 | ||
399 | AliStack *stack = 0x0; | |
400 | ||
401 | if(!fMCEvent->Stack())return; | |
402 | stack = fMCEvent->Stack(); | |
403 | Int_t nTracks = stack->GetNtrack(); | |
404 | ||
405 | AliMCParticle *mcTrack = 0x0; | |
406 | ||
407 | for(Int_t itrack = 0; itrack<nTracks; itrack++){ | |
408 | if(!(stack->Particle(itrack))) continue; | |
69ac0e6f | 409 | if(mcTrack) mcTrack = 0x0; |
410 | mcTrack = dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(itrack)); | |
411 | if(!mcTrack) continue; | |
faee3b18 | 412 | //TParticle *mcPart = stack->Particle(itrack); |
413 | ||
414 | mcContainer[0] = mcTrack->Pt(); | |
415 | mcContainer[1] = mcTrack->Eta(); | |
416 | mcContainer[2] = mcTrack->Phi(); | |
417 | mcContainer[3] = mcTrack->Charge(); | |
418 | ||
419 | ||
420 | ||
421 | if (!stack->IsPhysicalPrimary(mcTrack->GetLabel())) continue; | |
422 | // no cut but require primary | |
423 | if(GetPlugin(kCorrection))fDeCFM->GetParticleContainer()->Fill(mcContainer, 0); | |
424 | ||
425 | // all pions for reference | |
426 | if(TMath::Abs(mcTrack->Particle()->GetPdgCode())==AliHFEdisplacedElectrons::kPDGpion && GetPlugin(kCorrection)) | |
427 | fDeCFM->GetParticleContainer()->Fill(mcContainer, 1); | |
428 | ||
429 | // cut for signal: all MC electrons | |
430 | if(TMath::Abs(mcTrack->Particle()->GetPdgCode())==AliHFEdisplacedElectrons::kPDGelectron && GetPlugin(kCorrection)) | |
431 | fDeCFM->GetParticleContainer()->Fill(mcContainer, 2); | |
432 | ||
433 | // cut at track level kinematics: pt and eta | |
434 | if(TMath::Abs(mcContainer[1])>=0.8 || mcContainer[0]>20 || mcContainer[0]<0.1) continue; | |
435 | ||
436 | if(TMath::Abs(mcTrack->Particle()->GetPdgCode())==AliHFEdisplacedElectrons::kPDGelectron){ | |
437 | nMCelectrons++; | |
438 | fElectronsMcPt->Fill(mcContainer[0]); | |
439 | } | |
440 | ||
441 | if(GetPlugin(kCorrection))fDeCFM->GetParticleContainer()->Fill(mcContainer, 3); | |
442 | ||
443 | ||
444 | // fill MC THnSparse | |
445 | fDisplacedElectrons->FillMcOutput(fESD, fMCEvent, mcTrack); | |
446 | ||
447 | } // mc track loop | |
448 | ||
449 | if(fDeDebugLevel>=10) printf("there are %d electrons in this MC event", nMCelectrons); | |
450 | ||
451 | } | |
452 | ||
453 | //____________________________________________________________ | |
454 | void AliAnalysisTaskDisplacedElectrons::ProcessESD(){ | |
455 | ||
69ac0e6f | 456 | // this is to handle ESD tracks with MC information |
faee3b18 | 457 | // MC pid is only used when HFE pid is implemented, for comparison |
458 | // corrections are taken into account | |
70da6c5a | 459 | |
460 | // process data: ESD tracks with MC information | |
70da6c5a | 461 | |
faee3b18 | 462 | Double_t esdContainer[4]; // container for the output in THnSparse |
463 | memset(esdContainer, 0, sizeof(Double_t) * 4); | |
464 | AliESDEvent *fESD = dynamic_cast<AliESDEvent *>(fInputEvent); | |
69ac0e6f | 465 | if(!fESD){ |
466 | AliError("No ESD event available"); | |
467 | return; | |
468 | } | |
faee3b18 | 469 | |
470 | fDeCFM->SetRecEventInfo(fESD); | |
471 | Double_t nContrib = fESD->GetPrimaryVertex()->GetNContributors(); | |
472 | ||
70da6c5a | 473 | Bool_t alreadyseen = kFALSE; |
474 | LabelContainer cont(fESD->GetNumberOfTracks()); | |
70da6c5a | 475 | |
69ac0e6f | 476 | Int_t nHFEelectrons = 0; |
70da6c5a | 477 | AliESDtrack *track = 0x0; |
faee3b18 | 478 | AliStack *stack = 0x0; |
70da6c5a | 479 | |
69ac0e6f | 480 | if(!(stack = fMCEvent->Stack())) return; |
faee3b18 | 481 | |
482 | // | |
483 | // cut at ESD event level | |
484 | // | |
485 | if(!fDeCFM->CheckEventCuts(AliHFEcuts::kEventStepReconstructed, fESD)) return; | |
486 | if(GetPlugin(kCorrection)) fDeCFM->GetEventContainer()->Fill(&nContrib, AliHFEcuts::kEventStepReconstructed); | |
487 | ||
70da6c5a | 488 | for(Int_t itrack = 0; itrack < fESD->GetNumberOfTracks(); itrack++){ |
489 | track = fESD->GetTrack(itrack); | |
490 | ||
70da6c5a | 491 | if(GetPlugin(kDisplacedElectrons)) { |
70da6c5a | 492 | |
faee3b18 | 493 | esdContainer[0] = track->Pt(); |
494 | esdContainer[1] = track->Eta(); | |
495 | esdContainer[2] = track->Phi(); | |
496 | esdContainer[3] = track->Charge(); | |
70da6c5a | 497 | |
faee3b18 | 498 | // before any cut |
499 | alreadyseen = cont.Find(TMath::Abs(track->GetLabel())); | |
500 | cont.Append(TMath::Abs(track->GetLabel())); // check double counting | |
501 | if(alreadyseen) continue; // avoid double counting | |
502 | if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(esdContainer, 1+AliHFEcuts::kStepRecNoCut); | |
70da6c5a | 503 | |
faee3b18 | 504 | // 1st track cut |
505 | // RecKine: ITSTPC cuts : ITS & TPC refit, covmatrix: (2, 2, 0.5, 0.5, 2); min_tpccls: 50, chi2_tpccls: 3.5 | |
506 | if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepRecKineITSTPC, track)) continue; | |
507 | if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(esdContainer, 1+AliHFEcuts::kStepRecKineITSTPC); | |
70da6c5a | 508 | |
faee3b18 | 509 | // 2nd track cut |
70da6c5a | 510 | // RecPrim: cut on track quality : DCA to vertex max: 3cm and 10cm; reject kink daughters |
faee3b18 | 511 | if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepRecPrim, track)) continue; |
512 | if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(esdContainer, 1+AliHFEcuts::kStepRecPrim); | |
70da6c5a | 513 | |
faee3b18 | 514 | // 3rd track cut |
70da6c5a | 515 | // HFEcuts: ITS layers cuts: ITS pixel layer: kFirst, kSecond, kBoth, kNone or kAny |
faee3b18 | 516 | if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepHFEcutsITS, track)) continue; |
517 | if(GetPlugin(kCorrection))fDeCFM->GetParticleContainer()->Fill(esdContainer, 1+AliHFEcuts::kStepHFEcutsITS); | |
518 | ||
519 | /* | |
520 | // 4th track cut | |
521 | // TRD: number of tracklets in TRD | |
522 | if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTRD, track)) continue; | |
523 | if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(esdContainer, 1+AliHFEcuts::kStepHFEcutsTRD); | |
524 | */ | |
70da6c5a | 525 | |
faee3b18 | 526 | // 5th track cut |
527 | // track accepted, do PID | |
528 | // --> only electron candidate will be processed | |
70da6c5a | 529 | AliHFEpidObject hfetrack; |
530 | hfetrack.fAnalysisType = AliHFEpidObject::kESDanalysis; | |
531 | hfetrack.fRecTrack = track; | |
faee3b18 | 532 | // if(HasMCData())hfetrack.fMCtrack = mctrack; |
70da6c5a | 533 | |
faee3b18 | 534 | if(!fDePID->IsSelected(&hfetrack)) continue; |
faee3b18 | 535 | else if(fDeDebugLevel>=10) |
536 | AliInfo("ESD info: this particle is identified as electron by HFEpid method \n"); | |
537 | if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(esdContainer, 1+AliHFEcuts::kStepPID); | |
70da6c5a | 538 | |
faee3b18 | 539 | // Fill Containers |
540 | nHFEelectrons++; | |
541 | fElectronsEsdPt->Fill(esdContainer[0]); | |
542 | fDisplacedElectrons->FillEsdOutput(fESD, track, stack); | |
543 | ||
544 | } // displaced electron analysis on ESD with MC plugin | |
70da6c5a | 545 | } // track loop |
faee3b18 | 546 | |
547 | if(fDeDebugLevel>=10) printf("there are %d HFE electrons in this ESD event", nHFEelectrons); | |
548 | ||
549 | } | |
70da6c5a | 550 | |
70da6c5a | 551 | |
552 | ||
faee3b18 | 553 | //____________________________________________________________ |
554 | void AliAnalysisTaskDisplacedElectrons::ProcessData(){ | |
555 | ||
556 | // this is a track loop over real data | |
557 | // no MC information at all | |
558 | // HFE pid is used | |
559 | ||
560 | AliESDEvent *fESD = dynamic_cast<AliESDEvent *>(fInputEvent); | |
69ac0e6f | 561 | if(!fESD){ |
562 | AliError("No ESD event available"); | |
563 | return; | |
564 | } | |
faee3b18 | 565 | |
566 | Double_t dataContainer[4]; // container for the output in THnSparse | |
567 | memset(dataContainer, 0, sizeof(Double_t) * 4); | |
70da6c5a | 568 | |
faee3b18 | 569 | Bool_t alreadyseen = kFALSE; |
570 | LabelContainer cont(fESD->GetNumberOfTracks()); | |
70da6c5a | 571 | |
70da6c5a | 572 | |
faee3b18 | 573 | AliESDtrack *track = 0x0; |
574 | Int_t nHFEelectrons= 0; | |
70da6c5a | 575 | |
faee3b18 | 576 | fDeCFM->SetRecEventInfo(fESD); |
577 | Double_t nContrib = fESD->GetPrimaryVertex()->GetNContributors(); | |
578 | if(!fDeCFM->CheckEventCuts(AliHFEcuts::kEventStepReconstructed, fESD)) return; | |
579 | if(GetPlugin(kCorrection)) fDeCFM->GetEventContainer()->Fill(&nContrib, AliHFEcuts::kEventStepReconstructed); | |
580 | ||
581 | ||
582 | for(Int_t itrack = 0; itrack < fESD->GetNumberOfTracks(); itrack++){ | |
583 | track = fESD->GetTrack(itrack); | |
584 | ||
585 | if(GetPlugin(kDisplacedElectrons)) { | |
70da6c5a | 586 | |
faee3b18 | 587 | dataContainer[0] = track->Pt(); |
588 | dataContainer[1] = track->Eta(); | |
589 | dataContainer[2] = track->Phi(); | |
590 | dataContainer[3] = track->Charge(); | |
591 | ||
592 | alreadyseen = cont.Find(TMath::Abs(track->GetLabel())); // double counted track | |
593 | cont.Append(TMath::Abs(track->GetLabel())); | |
594 | if(alreadyseen) continue; // avoid double counting | |
595 | if(GetPlugin(kCorrection))fDeCFM->GetParticleContainer()->Fill(&dataContainer[4], | |
596 | 1+AliHFEcuts::kStepRecNoCut + AliHFEcuts::kNcutStepsESDtrack); | |
70da6c5a | 597 | |
faee3b18 | 598 | // 1st track cut |
599 | // RecKine: ITSTPC cuts : ITS & TPC refit, covmatrix: (2, 2, 0.5, 0.5, 2); min_tpccls: 50, chi2_tpccls: 3.5 | |
600 | if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepRecKineITSTPC, track)) continue; | |
601 | if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(&dataContainer[4], | |
602 | 1+AliHFEcuts::kStepRecKineITSTPC + AliHFEcuts::kNcutStepsESDtrack); | |
70da6c5a | 603 | |
faee3b18 | 604 | // 2nd track cut |
605 | // RecPrim: cut on track quality : DCA to vertex max: 3cm and 10cm; reject kink daughters | |
606 | if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepRecPrim, track)) continue; | |
607 | if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(&dataContainer[4], | |
608 | 1+AliHFEcuts::kStepRecPrim + AliHFEcuts::kNcutStepsESDtrack); | |
609 | ||
610 | // 3rd track cut | |
611 | // HFEcuts: ITS layers cuts: ITS pixel layer: kFirst, kSecond, kBoth, kNone or kAny | |
612 | if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepHFEcutsITS, track)) continue; | |
613 | if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(&dataContainer[4], | |
614 | 1+AliHFEcuts::kStepHFEcutsITS + AliHFEcuts::kNcutStepsESDtrack); | |
70da6c5a | 615 | |
faee3b18 | 616 | /* |
617 | // 4th track cut | |
618 | // TRD: number of tracklets in TRD0 | |
619 | if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTRD, track)) continue; | |
620 | if(GetPlugin(kCorrection)) if(HasMCData())fDeCFM->GetParticleContainer()->Fill(&dataContainer[4], | |
621 | 1+AliHFEcuts::kStepHFEcutsTRD + AliHFEcuts::kNcutStepsESDtrack); | |
622 | */ | |
623 | ||
624 | ||
625 | // 5th track cut | |
626 | // track accepted, do PID --> only electron candidate will be processed | |
70da6c5a | 627 | |
faee3b18 | 628 | AliHFEpidObject hfetrack; |
629 | hfetrack.fAnalysisType = AliHFEpidObject::kESDanalysis; | |
630 | hfetrack.fRecTrack = track; | |
631 | // if(HasMCData())hfetrack.fMCtrack = mctrack; | |
632 | ||
633 | if(!fDePID->IsSelected(&hfetrack)) continue; | |
634 | else if(fDeDebugLevel>=10) | |
635 | AliInfo("ESD info: this particle is identified as electron by HFEpid method \n"); | |
636 | if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(dataContainer, 1+AliHFEcuts::kStepPID + AliHFEcuts::kNcutStepsESDtrack); | |
637 | ||
638 | nHFEelectrons++; | |
639 | fElectronsDataPt->Fill(dataContainer[0]); | |
640 | fDisplacedElectrons->FillDataOutput(fESD, track); | |
641 | } // analyze displaced electrons plugin switched on | |
642 | } // track loop | |
70da6c5a | 643 | |
faee3b18 | 644 | if(fDeDebugLevel>=10) printf("there are %d HFE electrons in this DATA event", nHFEelectrons); |
645 | } | |
70da6c5a | 646 | |
647 | ||
faee3b18 | 648 | //____________________________________________________________ |
649 | void AliAnalysisTaskDisplacedElectrons::Terminate(Option_t *){ | |
650 | // | |
651 | // Terminate not implemented at the moment | |
652 | // | |
653 | ||
654 | fHistDisplacedElectrons = dynamic_cast<TList *>(GetOutputData(1)); | |
655 | fDeCorrection = dynamic_cast<TList *>(GetOutputData(2)); | |
656 | fDeQA = dynamic_cast<TList *>(GetOutputData(3)); | |
657 | if(!fDeCorrection) AliError("correction list not available\n"); | |
658 | if(!fHistDisplacedElectrons) AliError("de list not available\n"); | |
659 | if(!fDeQA) AliError("qa list is not available\n"); | |
660 | ||
661 | fHistDisplacedElectrons->Print(); | |
662 | fDeCorrection->Print(); | |
663 | fDeQA->Print(); | |
70da6c5a | 664 | |
faee3b18 | 665 | AliInfo("analysis done!\n"); |
666 | ||
667 | } | |
70da6c5a | 668 | |
669 | //____________________________________________________________ | |
670 | void AliAnalysisTaskDisplacedElectrons::PrintStatus() const { | |
671 | ||
672 | // | |
673 | // Print Analysis status | |
674 | // | |
faee3b18 | 675 | printf("\n"); |
676 | printf("\t Analysis Settings\n\t========================================\n"); | |
677 | printf("\t running over %s\n", HasMCData()?"MC data":"pp collision data"); | |
678 | printf("\t displaced electrons' analysis is %s\n", GetPlugin(kDisplacedElectrons)?"ON":"OFF"); | |
679 | printf("\t correction container is %s\n", GetPlugin(kCorrection)?"ON":"OFF"); | |
680 | printf("\t hfe pid qa is %s\n", GetPlugin(kDePidQA)?"ON":"OFF"); | |
681 | printf("\t post processing is %s\n", GetPlugin(kPostProcess)?"ON":"OFF"); | |
682 | printf("\t cuts: %s\n", (fDeCuts != NULL) ? "YES" : "NO"); | |
70da6c5a | 683 | printf("\t "); |
684 | printf("\n"); | |
685 | } | |
686 | ||
687 | //__________________________________________ | |
688 | void AliAnalysisTaskDisplacedElectrons::SwitchOnPlugin(Int_t plug){ | |
689 | // | |
690 | // Switch on Plugin | |
691 | // Available: | |
692 | // - analyze impact parameter | |
693 | // - Post Processing | |
694 | ||
695 | switch(plug) | |
696 | { | |
697 | case kDisplacedElectrons: | |
faee3b18 | 698 | SETBIT(fDePlugins, plug); |
70da6c5a | 699 | break; |
700 | case kCorrection: | |
faee3b18 | 701 | SETBIT(fDePlugins, plug); |
702 | break; | |
703 | case kDePidQA: | |
704 | SETBIT(fDePlugins, plug); | |
705 | break; | |
706 | case kPostProcess: | |
707 | SETBIT(fDePlugins, plug); | |
70da6c5a | 708 | break; |
709 | default: | |
710 | AliError("Unknown Plugin"); | |
711 | }; | |
712 | } | |
713 | ||
70da6c5a | 714 | //____________________________________________________________ |
715 | void AliAnalysisTaskDisplacedElectrons::MakeParticleContainer(){ | |
716 | // | |
faee3b18 | 717 | // Create the particle container for the correction framework manager and |
718 | // link it | |
70da6c5a | 719 | // |
faee3b18 | 720 | const Int_t kNvar = 4; |
721 | //number of variables on the grid:pt,eta, phi, charge | |
722 | const Double_t kPtbound[2] = {0.1, 10.}; | |
723 | const Double_t kEtabound[2] = {-0.8, 0.8}; | |
724 | const Double_t kPhibound[2] = {0., 2. * TMath::Pi()}; | |
70da6c5a | 725 | |
726 | //arrays for the number of bins in each dimension | |
727 | Int_t iBin[kNvar]; | |
faee3b18 | 728 | iBin[0] = 40; // bins in pt |
729 | iBin[1] = 8; // bins in eta | |
70da6c5a | 730 | iBin[2] = 18; // bins in phi |
731 | iBin[3] = 2; // bins in charge | |
faee3b18 | 732 | |
70da6c5a | 733 | //arrays for lower bounds : |
734 | Double_t* binEdges[kNvar]; | |
faee3b18 | 735 | binEdges[0] = AliHFEtools::MakeLogarithmicBinning(iBin[0], kPtbound[0], kPtbound[1]); |
736 | binEdges[1] = AliHFEtools::MakeLinearBinning(iBin[1], kEtabound[0], kEtabound[1]); | |
737 | binEdges[2] = AliHFEtools::MakeLinearBinning(iBin[2], kPhibound[0], kPhibound[1]); | |
738 | binEdges[3] = AliHFEtools::MakeLinearBinning(iBin[3], -1.1, 1.1); // Numeric precision | |
739 | ||
740 | //------------------------------------------------ | |
741 | // one "container" for MC+ESD+Data | |
742 | //----------pure MC track------------------------- | |
743 | // 0: MC generated | |
744 | // 1: MC pion total ---- be careful!!!! | |
745 | // 2: MC electrons total | |
746 | // 3: MC electrons in acceptance | |
747 | //-------ESD track with MC info------------------- | |
748 | // 4: ESD track with MC: no cut | |
749 | // 5: ESD track with MC: cut on kine its tpc | |
750 | // 6: ESD track with MC: rec prim | |
751 | // 7: ESD track with MC: hfe cuts its | |
752 | // 8: ESD track with MC: hfe cuts trd | |
753 | // 9: ESD track with MC: hfe pid | |
754 | //-----------data track--------------------------- | |
755 | // 10: DATA track wo MC: no cut | |
756 | // 11: DATA track wo MC: cut on kine its tpc | |
757 | // 12: DATA track wo MC: rec prim | |
758 | // 13: DATA track wo MC: hfe cuts its | |
759 | // 14: DATA track wo MC: hfe cuts trd | |
760 | // 15: DATA track wo MC: hfe pid | |
761 | //------------------------------------------------ | |
762 | ||
763 | AliCFContainer* container = new AliCFContainer("deTrackContainer", "Container for tracks", | |
764 | (1 + AliHFEcuts::kNcutStepsTrack + AliHFEcuts::kNcutStepsESDtrack), kNvar, iBin); | |
765 | ||
70da6c5a | 766 | //setting the bin limits |
faee3b18 | 767 | for(Int_t ivar = 0; ivar < kNvar; ivar++){ |
70da6c5a | 768 | container -> SetBinLimits(ivar, binEdges[ivar]); |
70da6c5a | 769 | } |
faee3b18 | 770 | fDeCFM->SetParticleContainer(container); |
70da6c5a | 771 | } |
772 | ||
faee3b18 | 773 | |
70da6c5a | 774 | //____________________________________________________________ |
775 | void AliAnalysisTaskDisplacedElectrons::MakeEventContainer(){ | |
776 | // | |
777 | // Create the event container for the correction framework and link it | |
778 | // | |
faee3b18 | 779 | |
780 | // event container | |
781 | // 0: MC event | |
782 | // 1: ESD event | |
783 | ||
70da6c5a | 784 | const Int_t kNvar = 1; // number of variables on the grid: number of tracks per event |
785 | const Double_t kNTrackBound[2] = {-0.5, 200.5}; | |
786 | const Int_t kNBins = 201; | |
787 | ||
faee3b18 | 788 | AliCFContainer *evCont = new AliCFContainer("deEventContainer", "Container for DE events", AliHFEcuts::kNcutStepsEvent, kNvar, &kNBins); |
70da6c5a | 789 | |
790 | Double_t trackBins[kNBins]; | |
791 | for(Int_t ibin = 0; ibin < kNBins; ibin++) trackBins[ibin] = kNTrackBound[0] + static_cast<Double_t>(ibin); | |
792 | evCont->SetBinLimits(0,trackBins); | |
793 | ||
faee3b18 | 794 | fDeCFM->SetEventContainer(evCont); |
70da6c5a | 795 | |
796 | } | |
797 | ||
798 | ||
799 | ||
800 | //__________________________________________________________ | |
801 | void AliAnalysisTaskDisplacedElectrons::AddPIDdetector(TString detector){ | |
802 | // | |
803 | // Adding PID detector to the task | |
804 | // | |
faee3b18 | 805 | if(!fDePIDdetectors.Length()) |
806 | fDePIDdetectors = detector; | |
70da6c5a | 807 | else |
faee3b18 | 808 | fDePIDdetectors += ":" + detector; |
70da6c5a | 809 | } |
810 | ||
811 | ||
812 | ||
813 | //____________________________________________________________ | |
814 | AliAnalysisTaskDisplacedElectrons::LabelContainer::LabelContainer(Int_t capacity): | |
815 | fContainer(NULL), | |
816 | fBegin(NULL), | |
817 | fEnd(NULL), | |
818 | fLast(NULL), | |
819 | fCurrent(NULL) | |
820 | { | |
821 | // | |
822 | // Default constructor | |
823 | // | |
824 | fContainer = new Int_t[capacity]; | |
825 | fBegin = &fContainer[0]; | |
826 | fEnd = &fContainer[capacity - 1]; | |
827 | fLast = fCurrent = fBegin; | |
828 | } | |
829 | ||
830 | //____________________________________________________________ | |
831 | Bool_t AliAnalysisTaskDisplacedElectrons::LabelContainer::Append(Int_t label){ | |
832 | // | |
833 | // Add Label to the container | |
834 | // | |
835 | if(fLast > fEnd) return kFALSE; | |
836 | *fLast++ = label; | |
837 | return kTRUE; | |
838 | } | |
839 | ||
840 | //____________________________________________________________ | |
841 | Bool_t AliAnalysisTaskDisplacedElectrons::LabelContainer::Find(Int_t label) const { | |
842 | // | |
843 | // Find track in the list of labels | |
844 | // | |
845 | for(Int_t *entry = fBegin; entry <= fLast; entry++) | |
846 | if(*entry == label) return kTRUE; | |
847 | return kFALSE; | |
848 | } | |
849 | ||
850 | //____________________________________________________________ | |
faee3b18 | 851 | Int_t AliAnalysisTaskDisplacedElectrons::LabelContainer::Next() { |
70da6c5a | 852 | // |
853 | // Mimic iterator | |
854 | // | |
855 | if(fCurrent > fLast) return -1; | |
856 | return *fCurrent++; | |
857 | } |