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