]>
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; | |
3a72645a | 92 | fDePID = new AliHFEpid("DEPID"); |
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; | |
3a72645a | 129 | fDePID = new AliHFEpid("DEPID"); |
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; | |
faee3b18 | 199 | if(fDeNEvents) delete fDeNEvents; |
200 | if(fElectronsMcPt) delete fElectronsMcPt; | |
201 | if(fElectronsEsdPt) delete fElectronsEsdPt; | |
202 | if(fElectronsDataPt) delete fElectronsDataPt; | |
203 | if(fDeCorrection){ | |
204 | fDeCorrection->Clear(); | |
205 | delete fDeCorrection; | |
70da6c5a | 206 | } |
faee3b18 | 207 | if(fDeQA){ |
208 | fDeQA->Clear(); | |
209 | delete fDeQA; | |
70da6c5a | 210 | } |
70da6c5a | 211 | if(fHistDisplacedElectrons){ |
212 | fHistDisplacedElectrons->Clear(); | |
213 | delete fHistDisplacedElectrons; | |
214 | } | |
70da6c5a | 215 | } |
216 | ||
217 | //____________________________________________________________ | |
218 | void AliAnalysisTaskDisplacedElectrons::UserCreateOutputObjects(){ | |
219 | // create output objects | |
faee3b18 | 220 | // fDeNEvents |
70da6c5a | 221 | // MC and Data containers |
222 | ||
faee3b18 | 223 | |
224 | if(!fDeQA) fDeQA = new TList; | |
225 | fDeQA->SetName("variousQAhistograms"); | |
226 | ||
227 | fDeNEvents = new TH1I("nDeEvents", "Number of Events in the DE Analysis", 2, 0, 2); | |
70da6c5a | 228 | const Int_t nBins = 14; |
229 | 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 | 230 | fElectronsMcPt = new TH1F("mcElectronPt", "MC: p_{T} distribution of identified electrons (mcpid);p_{T} (GeV/c);Counts;", nBins-1, ptBins); |
231 | fElectronsEsdPt = new TH1F("esdElectronPt", "ESD: p_{T} distribution of identified electrons (hfepid);p_{T} (GeV/c);Counts;", nBins-1, ptBins); | |
232 | fElectronsDataPt = new TH1F("dataElectronPt", "DATA: p_{T} distribution of identified electrons (hfepid);p_{T} (GeV/c);Counts;", nBins-1, ptBins); | |
6555e2ad | 233 | |
faee3b18 | 234 | fDeQA->AddAt(fDeNEvents,0); |
235 | if(HasMCData()){ | |
236 | fDeQA->AddAt(fElectronsMcPt, 1); | |
6555e2ad | 237 | fDeQA->AddAt(fElectronsEsdPt, 2); |
faee3b18 | 238 | } |
6555e2ad | 239 | else{ |
faee3b18 | 240 | fDeQA->AddAt(fElectronsDataPt, 1); |
6555e2ad | 241 | } |
70da6c5a | 242 | // Initialize correction Framework and Cuts |
faee3b18 | 243 | fDeCFM = new AliCFManager; |
70da6c5a | 244 | MakeEventContainer(); |
245 | MakeParticleContainer(); | |
246 | ||
faee3b18 | 247 | if(!fDeCorrection) fDeCorrection = new TList(); |
248 | fDeCorrection->SetName("deCorrections"); | |
249 | fDeCorrection->AddAt(fDeCFM->GetEventContainer(), 0); | |
250 | fDeCorrection->AddAt(fDeCFM->GetParticleContainer(), 1); | |
251 | fDeCorrection->Print(); | |
252 | ||
253 | for(Int_t istep = 0; istep < fDeCFM->GetEventContainer()->GetNStep(); istep++) | |
254 | fDeCFM->SetEventCutsList(istep, 0x0); | |
255 | for(Int_t istep = 0; istep < fDeCFM->GetParticleContainer()->GetNStep(); istep++) | |
256 | fDeCFM->SetParticleCutsList(istep, 0x0); | |
257 | ||
258 | if(!fDeCuts){ | |
70da6c5a | 259 | AliWarning("Cuts not available. Default cuts will be used"); |
faee3b18 | 260 | fDeCuts = new AliHFEcuts; |
261 | fDeCuts->CreateStandardCuts(); | |
70da6c5a | 262 | } |
263 | ||
faee3b18 | 264 | fDeCuts->Initialize(fDeCFM); |
70da6c5a | 265 | |
faee3b18 | 266 | fDePID->SetHasMCData(HasMCData()); |
3a72645a | 267 | fDePID->AddDetector("TPC", 0); |
268 | fDePID->AddDetector("TOF", 1); | |
269 | fDePID->ConfigureTPCrejection(); | |
270 | fDePID->InitializePID(); // Only restrictions to TPC allowed | |
271 | ||
272 | ||
70da6c5a | 273 | // displaced electron study---------------------------------- |
274 | if(GetPlugin(kDisplacedElectrons)){ | |
275 | ||
276 | fDisplacedElectrons = new AliHFEdisplacedElectrons; | |
faee3b18 | 277 | fDisplacedElectrons->SetDebugLevel(fDeDebugLevel); |
70da6c5a | 278 | fDisplacedElectrons->SetHasMCData(HasMCData()); |
faee3b18 | 279 | fDisplacedElectrons->SetMinPrimVtxContrib(fNminPrimVtxContrib); |
280 | fDisplacedElectrons->SetNitsCluster(fNminITSCluster); | |
281 | ||
70da6c5a | 282 | if(!fHistDisplacedElectrons) fHistDisplacedElectrons = new TList(); |
70da6c5a | 283 | fDisplacedElectrons->CreateOutputs(fHistDisplacedElectrons); |
70da6c5a | 284 | } |
faee3b18 | 285 | |
70da6c5a | 286 | } |
287 | ||
288 | ||
289 | ||
290 | //____________________________________________________________ | |
291 | void AliAnalysisTaskDisplacedElectrons::UserExec(Option_t *){ | |
292 | // | |
293 | // Run the analysis | |
294 | // | |
295 | ||
faee3b18 | 296 | if(fDeDebugLevel>=10) AliInfo("analyse single event"); |
297 | ||
298 | if(!fInputEvent){ | |
299 | AliError("Reconstructed Event not available"); | |
70da6c5a | 300 | return; |
70da6c5a | 301 | } |
302 | ||
faee3b18 | 303 | // |
304 | AliESDInputHandler *inH = dynamic_cast<AliESDInputHandler *>(fInputHandler); | |
70da6c5a | 305 | |
69ac0e6f | 306 | if(!inH){ |
307 | AliError("AliESDInputHandler dynamic cast failed!"); | |
308 | return; | |
70da6c5a | 309 | } |
faee3b18 | 310 | |
311 | // from now on, only ESD are analyzed | |
312 | // using HFE pid, using HFE cuts | |
313 | // using CORRFW | |
faee3b18 | 314 | AliESDpid *workingPID = inH->GetESDpid(); |
315 | if(workingPID){ | |
316 | AliDebug(1, "Using ESD PID from the input handler"); | |
3a72645a | 317 | //printf("\n ESD PID\n"); |
faee3b18 | 318 | fDePID->SetESDpid(workingPID); |
319 | } else { | |
320 | AliDebug(1, "Using default ESD PID"); | |
3a72645a | 321 | //printf(" DEFAULT PID!\n\n"); |
faee3b18 | 322 | fDePID->SetESDpid(AliHFEtools::GetDefaultPID(HasMCData())); |
323 | } | |
324 | ||
325 | if(!fDeCuts){ | |
70da6c5a | 326 | AliError("HFE cuts not available"); |
327 | return; | |
328 | } | |
faee3b18 | 329 | |
69ac0e6f | 330 | // ---- CHOICE OF ANALYSIS ---- |
331 | if(HasMCData()){ | |
faee3b18 | 332 | // Protect against missing MC trees |
333 | AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler *>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); | |
69ac0e6f | 334 | if(!mcH){ |
335 | AliError("MC handler cuts not available"); | |
336 | return; | |
337 | } | |
338 | ||
faee3b18 | 339 | if(!mcH->InitOk()) return; |
340 | if(!mcH->TreeK()) return; | |
69ac0e6f | 341 | if(!mcH->TreeTR()) return; |
342 | ||
faee3b18 | 343 | AliDebug(4, Form("MC Event: %p", fMCEvent)); |
344 | if(!fMCEvent){ | |
345 | AliError("No MC Event, but MC Data required"); | |
346 | return; | |
347 | } | |
69ac0e6f | 348 | |
349 | ProcessMC(); // PURE MC | |
350 | ||
351 | if(IsESDanalysis()) ProcessESD(); // ESD WITH MC | |
352 | ||
353 | }else if(IsESDanalysis()) ProcessData(); // PURE ESD | |
faee3b18 | 354 | |
faee3b18 | 355 | |
356 | fDeNEvents->Fill(1); | |
357 | PostData(1, fHistDisplacedElectrons); | |
358 | PostData(2, fDeCorrection); | |
359 | PostData(3, fDeQA); | |
360 | ||
361 | } | |
362 | ||
363 | //____________________________________________________________ | |
364 | void AliAnalysisTaskDisplacedElectrons::ProcessMC(){ | |
365 | // | |
69ac0e6f | 366 | // handle pure MC analysis |
faee3b18 | 367 | // |
368 | ||
369 | Int_t nMCelectrons = 0; | |
370 | AliESDEvent *fESD = dynamic_cast<AliESDEvent *>(fInputEvent); | |
69ac0e6f | 371 | if(!fESD){ |
372 | AliError("ESD event not available"); | |
373 | return; | |
374 | } | |
faee3b18 | 375 | |
376 | Double_t mcContainer[4]; // container for the output in THnSparse | |
377 | memset(mcContainer, 0, sizeof(Double_t) * 4); | |
378 | ||
379 | fDeCFM->SetMCEventInfo(fMCEvent); | |
380 | ||
bf892a6a | 381 | Double_t nContributor[1] = {0}; |
faee3b18 | 382 | const AliVVertex *mcPrimVtx = fMCEvent->GetPrimaryVertex(); |
bf892a6a | 383 | if(mcPrimVtx) nContributor[0] = mcPrimVtx->GetNContributors(); |
faee3b18 | 384 | |
385 | // | |
386 | // cut at MC event level | |
387 | // | |
388 | ||
389 | if(!fDeCFM->CheckEventCuts(AliHFEcuts::kEventStepGenerated, fMCEvent)) return; | |
bf892a6a | 390 | if(GetPlugin(kCorrection)) fDeCFM->GetEventContainer()->Fill(nContributor,AliHFEcuts::kEventStepGenerated); |
faee3b18 | 391 | |
392 | AliStack *stack = 0x0; | |
393 | ||
394 | if(!fMCEvent->Stack())return; | |
395 | stack = fMCEvent->Stack(); | |
396 | Int_t nTracks = stack->GetNtrack(); | |
397 | ||
398 | AliMCParticle *mcTrack = 0x0; | |
399 | ||
400 | for(Int_t itrack = 0; itrack<nTracks; itrack++){ | |
401 | if(!(stack->Particle(itrack))) continue; | |
69ac0e6f | 402 | if(mcTrack) mcTrack = 0x0; |
403 | mcTrack = dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(itrack)); | |
404 | if(!mcTrack) continue; | |
faee3b18 | 405 | //TParticle *mcPart = stack->Particle(itrack); |
406 | ||
407 | mcContainer[0] = mcTrack->Pt(); | |
408 | mcContainer[1] = mcTrack->Eta(); | |
409 | mcContainer[2] = mcTrack->Phi(); | |
410 | mcContainer[3] = mcTrack->Charge(); | |
411 | ||
412 | ||
413 | ||
414 | if (!stack->IsPhysicalPrimary(mcTrack->GetLabel())) continue; | |
415 | // no cut but require primary | |
416 | if(GetPlugin(kCorrection))fDeCFM->GetParticleContainer()->Fill(mcContainer, 0); | |
417 | ||
418 | // all pions for reference | |
419 | if(TMath::Abs(mcTrack->Particle()->GetPdgCode())==AliHFEdisplacedElectrons::kPDGpion && GetPlugin(kCorrection)) | |
420 | fDeCFM->GetParticleContainer()->Fill(mcContainer, 1); | |
421 | ||
422 | // cut for signal: all MC electrons | |
423 | if(TMath::Abs(mcTrack->Particle()->GetPdgCode())==AliHFEdisplacedElectrons::kPDGelectron && GetPlugin(kCorrection)) | |
424 | fDeCFM->GetParticleContainer()->Fill(mcContainer, 2); | |
425 | ||
426 | // cut at track level kinematics: pt and eta | |
427 | if(TMath::Abs(mcContainer[1])>=0.8 || mcContainer[0]>20 || mcContainer[0]<0.1) continue; | |
428 | ||
429 | if(TMath::Abs(mcTrack->Particle()->GetPdgCode())==AliHFEdisplacedElectrons::kPDGelectron){ | |
430 | nMCelectrons++; | |
431 | fElectronsMcPt->Fill(mcContainer[0]); | |
432 | } | |
433 | ||
434 | if(GetPlugin(kCorrection))fDeCFM->GetParticleContainer()->Fill(mcContainer, 3); | |
435 | ||
436 | ||
437 | // fill MC THnSparse | |
438 | fDisplacedElectrons->FillMcOutput(fESD, fMCEvent, mcTrack); | |
439 | ||
440 | } // mc track loop | |
441 | ||
442 | if(fDeDebugLevel>=10) printf("there are %d electrons in this MC event", nMCelectrons); | |
443 | ||
444 | } | |
445 | ||
446 | //____________________________________________________________ | |
447 | void AliAnalysisTaskDisplacedElectrons::ProcessESD(){ | |
448 | ||
69ac0e6f | 449 | // this is to handle ESD tracks with MC information |
faee3b18 | 450 | // MC pid is only used when HFE pid is implemented, for comparison |
451 | // corrections are taken into account | |
70da6c5a | 452 | |
453 | // process data: ESD tracks with MC information | |
70da6c5a | 454 | |
3a72645a | 455 | const Int_t kStepPID = AliHFEcuts::kStepHFEcutsTRD + 1; |
456 | ||
faee3b18 | 457 | Double_t esdContainer[4]; // container for the output in THnSparse |
458 | memset(esdContainer, 0, sizeof(Double_t) * 4); | |
459 | AliESDEvent *fESD = dynamic_cast<AliESDEvent *>(fInputEvent); | |
69ac0e6f | 460 | if(!fESD){ |
461 | AliError("No ESD event available"); | |
462 | return; | |
463 | } | |
faee3b18 | 464 | |
465 | fDeCFM->SetRecEventInfo(fESD); | |
bf892a6a | 466 | Double_t nContrib[1] = {fESD->GetPrimaryVertex()->GetNContributors()}; |
faee3b18 | 467 | |
70da6c5a | 468 | Bool_t alreadyseen = kFALSE; |
6555e2ad | 469 | AliLabelContainer cont(fESD->GetNumberOfTracks()); |
70da6c5a | 470 | |
69ac0e6f | 471 | Int_t nHFEelectrons = 0; |
70da6c5a | 472 | AliESDtrack *track = 0x0; |
faee3b18 | 473 | AliStack *stack = 0x0; |
70da6c5a | 474 | |
69ac0e6f | 475 | if(!(stack = fMCEvent->Stack())) return; |
faee3b18 | 476 | |
477 | // | |
478 | // cut at ESD event level | |
479 | // | |
480 | if(!fDeCFM->CheckEventCuts(AliHFEcuts::kEventStepReconstructed, fESD)) return; | |
bf892a6a | 481 | if(GetPlugin(kCorrection)) fDeCFM->GetEventContainer()->Fill(nContrib, AliHFEcuts::kEventStepReconstructed); |
faee3b18 | 482 | |
70da6c5a | 483 | for(Int_t itrack = 0; itrack < fESD->GetNumberOfTracks(); itrack++){ |
484 | track = fESD->GetTrack(itrack); | |
485 | ||
70da6c5a | 486 | if(GetPlugin(kDisplacedElectrons)) { |
70da6c5a | 487 | |
faee3b18 | 488 | esdContainer[0] = track->Pt(); |
489 | esdContainer[1] = track->Eta(); | |
490 | esdContainer[2] = track->Phi(); | |
491 | esdContainer[3] = track->Charge(); | |
70da6c5a | 492 | |
faee3b18 | 493 | // before any cut |
494 | alreadyseen = cont.Find(TMath::Abs(track->GetLabel())); | |
495 | cont.Append(TMath::Abs(track->GetLabel())); // check double counting | |
496 | if(alreadyseen) continue; // avoid double counting | |
3a72645a | 497 | if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(esdContainer, 1+AliHFEcuts::kStepRecNoCut + AliHFEcuts::kNcutStepsMCTrack); |
70da6c5a | 498 | |
faee3b18 | 499 | // 1st track cut |
500 | // RecKine: ITSTPC cuts : ITS & TPC refit, covmatrix: (2, 2, 0.5, 0.5, 2); min_tpccls: 50, chi2_tpccls: 3.5 | |
3a72645a | 501 | if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepRecKineITSTPC + AliHFEcuts::kNcutStepsMCTrack, track)) continue; |
502 | if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(esdContainer, 1+AliHFEcuts::kStepRecKineITSTPC + AliHFEcuts::kNcutStepsMCTrack); | |
70da6c5a | 503 | |
faee3b18 | 504 | // 2nd track cut |
70da6c5a | 505 | // RecPrim: cut on track quality : DCA to vertex max: 3cm and 10cm; reject kink daughters |
3a72645a | 506 | if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepRecPrim + AliHFEcuts::kNcutStepsMCTrack, track)) continue; |
507 | if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(esdContainer, 1+AliHFEcuts::kStepRecPrim + AliHFEcuts::kNcutStepsMCTrack); | |
70da6c5a | 508 | |
faee3b18 | 509 | // 3rd track cut |
70da6c5a | 510 | // HFEcuts: ITS layers cuts: ITS pixel layer: kFirst, kSecond, kBoth, kNone or kAny |
3a72645a | 511 | if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepHFEcutsITS + AliHFEcuts::kNcutStepsMCTrack, track)) continue; |
512 | if(GetPlugin(kCorrection))fDeCFM->GetParticleContainer()->Fill(esdContainer, 1+AliHFEcuts::kStepHFEcutsITS + AliHFEcuts::kNcutStepsMCTrack); | |
faee3b18 | 513 | |
514 | /* | |
515 | // 4th track cut | |
516 | // TRD: number of tracklets in TRD | |
3a72645a | 517 | if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTRD + AliHFEcuts::kNcutStepsMCTrack, track)) continue; |
518 | if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(esdContainer, 1+AliHFEcuts::kStepHFEcutsTRD + AliHFEcuts::kNcutStepsMCTrack); | |
faee3b18 | 519 | */ |
70da6c5a | 520 | |
faee3b18 | 521 | // 5th track cut |
522 | // track accepted, do PID | |
523 | // --> only electron candidate will be processed | |
70da6c5a | 524 | AliHFEpidObject hfetrack; |
3a72645a | 525 | hfetrack.SetAnalysisType(AliHFEpidObject::kESDanalysis); |
526 | hfetrack.SetRecTrack(track); | |
527 | //if(HasMCData())hfetrack.SetMCTrack(mctrack); | |
70da6c5a | 528 | |
faee3b18 | 529 | if(!fDePID->IsSelected(&hfetrack)) continue; |
faee3b18 | 530 | else if(fDeDebugLevel>=10) |
531 | AliInfo("ESD info: this particle is identified as electron by HFEpid method \n"); | |
3a72645a | 532 | if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(esdContainer, 1+kStepPID + AliHFEcuts::kNcutStepsMCTrack); |
533 | ||
faee3b18 | 534 | // Fill Containers |
535 | nHFEelectrons++; | |
536 | fElectronsEsdPt->Fill(esdContainer[0]); | |
537 | fDisplacedElectrons->FillEsdOutput(fESD, track, stack); | |
538 | ||
539 | } // displaced electron analysis on ESD with MC plugin | |
70da6c5a | 540 | } // track loop |
faee3b18 | 541 | |
542 | if(fDeDebugLevel>=10) printf("there are %d HFE electrons in this ESD event", nHFEelectrons); | |
543 | ||
544 | } | |
70da6c5a | 545 | |
70da6c5a | 546 | |
547 | ||
faee3b18 | 548 | //____________________________________________________________ |
549 | void AliAnalysisTaskDisplacedElectrons::ProcessData(){ | |
550 | ||
551 | // this is a track loop over real data | |
552 | // no MC information at all | |
553 | // HFE pid is used | |
3a72645a | 554 | |
555 | const Int_t kNcutStepsESDtrack = AliHFEcuts::kNcutStepsRecTrack + 1; | |
556 | //const Int_t kNcutStepsTrack = AliHFEcuts::kNcutStepsMCTrack + kNcutStepsESDtrack; | |
557 | const Int_t kStepPID = AliHFEcuts::kStepHFEcutsTRD + 1; | |
faee3b18 | 558 | |
559 | AliESDEvent *fESD = dynamic_cast<AliESDEvent *>(fInputEvent); | |
69ac0e6f | 560 | if(!fESD){ |
561 | AliError("No ESD event available"); | |
562 | return; | |
563 | } | |
faee3b18 | 564 | |
565 | Double_t dataContainer[4]; // container for the output in THnSparse | |
566 | memset(dataContainer, 0, sizeof(Double_t) * 4); | |
70da6c5a | 567 | |
faee3b18 | 568 | Bool_t alreadyseen = kFALSE; |
6555e2ad | 569 | AliLabelContainer cont(fESD->GetNumberOfTracks()); |
70da6c5a | 570 | |
70da6c5a | 571 | |
faee3b18 | 572 | AliESDtrack *track = 0x0; |
573 | Int_t nHFEelectrons= 0; | |
70da6c5a | 574 | |
faee3b18 | 575 | fDeCFM->SetRecEventInfo(fESD); |
bf892a6a | 576 | Double_t nContrib[1] = {fESD->GetPrimaryVertex()->GetNContributors()}; |
faee3b18 | 577 | if(!fDeCFM->CheckEventCuts(AliHFEcuts::kEventStepReconstructed, fESD)) return; |
bf892a6a | 578 | if(GetPlugin(kCorrection)) fDeCFM->GetEventContainer()->Fill(nContrib, AliHFEcuts::kEventStepReconstructed); |
faee3b18 | 579 | |
580 | ||
581 | for(Int_t itrack = 0; itrack < fESD->GetNumberOfTracks(); itrack++){ | |
582 | track = fESD->GetTrack(itrack); | |
583 | ||
584 | if(GetPlugin(kDisplacedElectrons)) { | |
70da6c5a | 585 | |
faee3b18 | 586 | dataContainer[0] = track->Pt(); |
587 | dataContainer[1] = track->Eta(); | |
588 | dataContainer[2] = track->Phi(); | |
589 | dataContainer[3] = track->Charge(); | |
590 | ||
591 | alreadyseen = cont.Find(TMath::Abs(track->GetLabel())); // double counted track | |
592 | cont.Append(TMath::Abs(track->GetLabel())); | |
593 | if(alreadyseen) continue; // avoid double counting | |
594 | if(GetPlugin(kCorrection))fDeCFM->GetParticleContainer()->Fill(&dataContainer[4], | |
3a72645a | 595 | 1+AliHFEcuts::kStepRecNoCut + AliHFEcuts::kNcutStepsMCTrack + kNcutStepsESDtrack); |
70da6c5a | 596 | |
faee3b18 | 597 | // 1st track cut |
598 | // RecKine: ITSTPC cuts : ITS & TPC refit, covmatrix: (2, 2, 0.5, 0.5, 2); min_tpccls: 50, chi2_tpccls: 3.5 | |
3a72645a | 599 | if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepRecKineITSTPC + AliHFEcuts::kNcutStepsMCTrack, track)) continue; |
faee3b18 | 600 | if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(&dataContainer[4], |
3a72645a | 601 | 1+AliHFEcuts::kStepRecKineITSTPC + AliHFEcuts::kNcutStepsMCTrack + kNcutStepsESDtrack); |
70da6c5a | 602 | |
faee3b18 | 603 | // 2nd track cut |
604 | // RecPrim: cut on track quality : DCA to vertex max: 3cm and 10cm; reject kink daughters | |
3a72645a | 605 | if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepRecPrim + AliHFEcuts::kNcutStepsMCTrack, track)) continue; |
faee3b18 | 606 | if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(&dataContainer[4], |
3a72645a | 607 | 1+AliHFEcuts::kStepRecPrim + AliHFEcuts::kNcutStepsMCTrack + kNcutStepsESDtrack); |
faee3b18 | 608 | |
609 | // 3rd track cut | |
610 | // HFEcuts: ITS layers cuts: ITS pixel layer: kFirst, kSecond, kBoth, kNone or kAny | |
611 | if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepHFEcutsITS, track)) continue; | |
612 | if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(&dataContainer[4], | |
3a72645a | 613 | 1+AliHFEcuts::kStepHFEcutsITS + AliHFEcuts::kNcutStepsMCTrack + kNcutStepsESDtrack); |
70da6c5a | 614 | |
faee3b18 | 615 | /* |
616 | // 4th track cut | |
617 | // TRD: number of tracklets in TRD0 | |
3a72645a | 618 | if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTRD + AliHFEcuts::kNcutStepsMCTrack, track)) continue; |
faee3b18 | 619 | if(GetPlugin(kCorrection)) if(HasMCData())fDeCFM->GetParticleContainer()->Fill(&dataContainer[4], |
3a72645a | 620 | 1+AliHFEcuts::kStepHFEcutsTRD + AliHFEcuts::kNcutStepsMCTrack + kNcutStepsESDtrack); |
faee3b18 | 621 | */ |
622 | ||
623 | ||
624 | // 5th track cut | |
625 | // track accepted, do PID --> only electron candidate will be processed | |
70da6c5a | 626 | |
faee3b18 | 627 | AliHFEpidObject hfetrack; |
3a72645a | 628 | hfetrack.SetAnalysisType(AliHFEpidObject::kESDanalysis); |
629 | hfetrack.SetRecTrack(track); | |
faee3b18 | 630 | |
631 | if(!fDePID->IsSelected(&hfetrack)) continue; | |
632 | else if(fDeDebugLevel>=10) | |
633 | AliInfo("ESD info: this particle is identified as electron by HFEpid method \n"); | |
3a72645a | 634 | if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(dataContainer, 1+kStepPID + AliHFEcuts::kNcutStepsMCTrack + kNcutStepsESDtrack); |
faee3b18 | 635 | |
636 | nHFEelectrons++; | |
637 | fElectronsDataPt->Fill(dataContainer[0]); | |
638 | fDisplacedElectrons->FillDataOutput(fESD, track); | |
639 | } // analyze displaced electrons plugin switched on | |
640 | } // track loop | |
70da6c5a | 641 | |
faee3b18 | 642 | if(fDeDebugLevel>=10) printf("there are %d HFE electrons in this DATA event", nHFEelectrons); |
643 | } | |
70da6c5a | 644 | |
645 | ||
faee3b18 | 646 | //____________________________________________________________ |
647 | void AliAnalysisTaskDisplacedElectrons::Terminate(Option_t *){ | |
648 | // | |
649 | // Terminate not implemented at the moment | |
650 | // | |
651 | ||
652 | fHistDisplacedElectrons = dynamic_cast<TList *>(GetOutputData(1)); | |
653 | fDeCorrection = dynamic_cast<TList *>(GetOutputData(2)); | |
654 | fDeQA = dynamic_cast<TList *>(GetOutputData(3)); | |
655 | if(!fDeCorrection) AliError("correction list not available\n"); | |
656 | if(!fHistDisplacedElectrons) AliError("de list not available\n"); | |
657 | if(!fDeQA) AliError("qa list is not available\n"); | |
658 | ||
659 | fHistDisplacedElectrons->Print(); | |
660 | fDeCorrection->Print(); | |
661 | fDeQA->Print(); | |
70da6c5a | 662 | |
faee3b18 | 663 | AliInfo("analysis done!\n"); |
664 | ||
665 | } | |
70da6c5a | 666 | |
667 | //____________________________________________________________ | |
668 | void AliAnalysisTaskDisplacedElectrons::PrintStatus() const { | |
669 | ||
670 | // | |
671 | // Print Analysis status | |
672 | // | |
faee3b18 | 673 | printf("\n"); |
674 | printf("\t Analysis Settings\n\t========================================\n"); | |
675 | printf("\t running over %s\n", HasMCData()?"MC data":"pp collision data"); | |
676 | printf("\t displaced electrons' analysis is %s\n", GetPlugin(kDisplacedElectrons)?"ON":"OFF"); | |
677 | printf("\t correction container is %s\n", GetPlugin(kCorrection)?"ON":"OFF"); | |
678 | printf("\t hfe pid qa is %s\n", GetPlugin(kDePidQA)?"ON":"OFF"); | |
679 | printf("\t post processing is %s\n", GetPlugin(kPostProcess)?"ON":"OFF"); | |
680 | printf("\t cuts: %s\n", (fDeCuts != NULL) ? "YES" : "NO"); | |
70da6c5a | 681 | printf("\t "); |
682 | printf("\n"); | |
683 | } | |
684 | ||
685 | //__________________________________________ | |
686 | void AliAnalysisTaskDisplacedElectrons::SwitchOnPlugin(Int_t plug){ | |
687 | // | |
688 | // Switch on Plugin | |
689 | // Available: | |
690 | // - analyze impact parameter | |
691 | // - Post Processing | |
692 | ||
693 | switch(plug) | |
694 | { | |
695 | case kDisplacedElectrons: | |
faee3b18 | 696 | SETBIT(fDePlugins, plug); |
70da6c5a | 697 | break; |
698 | case kCorrection: | |
faee3b18 | 699 | SETBIT(fDePlugins, plug); |
700 | break; | |
701 | case kDePidQA: | |
702 | SETBIT(fDePlugins, plug); | |
703 | break; | |
704 | case kPostProcess: | |
705 | SETBIT(fDePlugins, plug); | |
70da6c5a | 706 | break; |
707 | default: | |
708 | AliError("Unknown Plugin"); | |
709 | }; | |
710 | } | |
711 | ||
70da6c5a | 712 | //____________________________________________________________ |
713 | void AliAnalysisTaskDisplacedElectrons::MakeParticleContainer(){ | |
714 | // | |
faee3b18 | 715 | // Create the particle container for the correction framework manager and |
716 | // link it | |
70da6c5a | 717 | // |
3a72645a | 718 | const Int_t kNcutStepsESDtrack = AliHFEcuts::kNcutStepsRecTrack + 1; |
719 | const Int_t kNcutStepsTrack = AliHFEcuts::kNcutStepsMCTrack + kNcutStepsESDtrack; | |
720 | ||
faee3b18 | 721 | const Int_t kNvar = 4; |
722 | //number of variables on the grid:pt,eta, phi, charge | |
723 | const Double_t kPtbound[2] = {0.1, 10.}; | |
724 | const Double_t kEtabound[2] = {-0.8, 0.8}; | |
725 | const Double_t kPhibound[2] = {0., 2. * TMath::Pi()}; | |
70da6c5a | 726 | |
727 | //arrays for the number of bins in each dimension | |
728 | Int_t iBin[kNvar]; | |
faee3b18 | 729 | iBin[0] = 40; // bins in pt |
730 | iBin[1] = 8; // bins in eta | |
70da6c5a | 731 | iBin[2] = 18; // bins in phi |
732 | iBin[3] = 2; // bins in charge | |
faee3b18 | 733 | |
70da6c5a | 734 | //arrays for lower bounds : |
735 | Double_t* binEdges[kNvar]; | |
faee3b18 | 736 | binEdges[0] = AliHFEtools::MakeLogarithmicBinning(iBin[0], kPtbound[0], kPtbound[1]); |
737 | binEdges[1] = AliHFEtools::MakeLinearBinning(iBin[1], kEtabound[0], kEtabound[1]); | |
738 | binEdges[2] = AliHFEtools::MakeLinearBinning(iBin[2], kPhibound[0], kPhibound[1]); | |
739 | binEdges[3] = AliHFEtools::MakeLinearBinning(iBin[3], -1.1, 1.1); // Numeric precision | |
740 | ||
741 | //------------------------------------------------ | |
742 | // one "container" for MC+ESD+Data | |
743 | //----------pure MC track------------------------- | |
744 | // 0: MC generated | |
745 | // 1: MC pion total ---- be careful!!!! | |
746 | // 2: MC electrons total | |
747 | // 3: MC electrons in acceptance | |
748 | //-------ESD track with MC info------------------- | |
749 | // 4: ESD track with MC: no cut | |
750 | // 5: ESD track with MC: cut on kine its tpc | |
751 | // 6: ESD track with MC: rec prim | |
752 | // 7: ESD track with MC: hfe cuts its | |
753 | // 8: ESD track with MC: hfe cuts trd | |
754 | // 9: ESD track with MC: hfe pid | |
755 | //-----------data track--------------------------- | |
756 | // 10: DATA track wo MC: no cut | |
757 | // 11: DATA track wo MC: cut on kine its tpc | |
758 | // 12: DATA track wo MC: rec prim | |
759 | // 13: DATA track wo MC: hfe cuts its | |
760 | // 14: DATA track wo MC: hfe cuts trd | |
761 | // 15: DATA track wo MC: hfe pid | |
762 | //------------------------------------------------ | |
763 | ||
764 | AliCFContainer* container = new AliCFContainer("deTrackContainer", "Container for tracks", | |
3a72645a | 765 | (1 + kNcutStepsTrack + kNcutStepsESDtrack), kNvar, iBin); |
faee3b18 | 766 | |
70da6c5a | 767 | //setting the bin limits |
faee3b18 | 768 | for(Int_t ivar = 0; ivar < kNvar; ivar++){ |
70da6c5a | 769 | container -> SetBinLimits(ivar, binEdges[ivar]); |
70da6c5a | 770 | } |
faee3b18 | 771 | fDeCFM->SetParticleContainer(container); |
70da6c5a | 772 | } |
773 | ||
faee3b18 | 774 | |
70da6c5a | 775 | //____________________________________________________________ |
776 | void AliAnalysisTaskDisplacedElectrons::MakeEventContainer(){ | |
777 | // | |
778 | // Create the event container for the correction framework and link it | |
779 | // | |
faee3b18 | 780 | |
781 | // event container | |
782 | // 0: MC event | |
783 | // 1: ESD event | |
784 | ||
70da6c5a | 785 | const Int_t kNvar = 1; // number of variables on the grid: number of tracks per event |
786 | const Double_t kNTrackBound[2] = {-0.5, 200.5}; | |
787 | const Int_t kNBins = 201; | |
788 | ||
faee3b18 | 789 | AliCFContainer *evCont = new AliCFContainer("deEventContainer", "Container for DE events", AliHFEcuts::kNcutStepsEvent, kNvar, &kNBins); |
70da6c5a | 790 | |
791 | Double_t trackBins[kNBins]; | |
792 | for(Int_t ibin = 0; ibin < kNBins; ibin++) trackBins[ibin] = kNTrackBound[0] + static_cast<Double_t>(ibin); | |
793 | evCont->SetBinLimits(0,trackBins); | |
794 | ||
faee3b18 | 795 | fDeCFM->SetEventContainer(evCont); |
70da6c5a | 796 | |
797 | } | |
798 | ||
799 | ||
800 | ||
801 | //__________________________________________________________ | |
802 | void AliAnalysisTaskDisplacedElectrons::AddPIDdetector(TString detector){ | |
803 | // | |
804 | // Adding PID detector to the task | |
805 | // | |
faee3b18 | 806 | if(!fDePIDdetectors.Length()) |
807 | fDePIDdetectors = detector; | |
70da6c5a | 808 | else |
faee3b18 | 809 | fDePIDdetectors += ":" + detector; |
70da6c5a | 810 | } |
811 | ||
812 | ||
813 | ||
814 | //____________________________________________________________ | |
6555e2ad | 815 | AliAnalysisTaskDisplacedElectrons::AliLabelContainer::AliLabelContainer(Int_t capacity): |
70da6c5a | 816 | fContainer(NULL), |
817 | fBegin(NULL), | |
818 | fEnd(NULL), | |
819 | fLast(NULL), | |
820 | fCurrent(NULL) | |
821 | { | |
822 | // | |
823 | // Default constructor | |
824 | // | |
825 | fContainer = new Int_t[capacity]; | |
826 | fBegin = &fContainer[0]; | |
827 | fEnd = &fContainer[capacity - 1]; | |
828 | fLast = fCurrent = fBegin; | |
829 | } | |
830 | ||
831 | //____________________________________________________________ | |
6555e2ad | 832 | Bool_t AliAnalysisTaskDisplacedElectrons::AliLabelContainer::Append(Int_t label){ |
70da6c5a | 833 | // |
834 | // Add Label to the container | |
835 | // | |
836 | if(fLast > fEnd) return kFALSE; | |
837 | *fLast++ = label; | |
838 | return kTRUE; | |
839 | } | |
840 | ||
841 | //____________________________________________________________ | |
6555e2ad | 842 | Bool_t AliAnalysisTaskDisplacedElectrons::AliLabelContainer::Find(Int_t label) const { |
70da6c5a | 843 | // |
844 | // Find track in the list of labels | |
845 | // | |
846 | for(Int_t *entry = fBegin; entry <= fLast; entry++) | |
847 | if(*entry == label) return kTRUE; | |
848 | return kFALSE; | |
849 | } | |
850 | ||
851 | //____________________________________________________________ | |
6555e2ad | 852 | Int_t AliAnalysisTaskDisplacedElectrons::AliLabelContainer::Next() { |
70da6c5a | 853 | // |
854 | // Mimic iterator | |
855 | // | |
856 | if(fCurrent > fLast) return -1; | |
d6d73936 | 857 | fCurrent++; |
6555e2ad | 858 | return *fCurrent; |
70da6c5a | 859 | } |