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