]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGHF/vertexingHF/AliCFTaskVertexingHF.cxx
Lc->K0sp cut object updates
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / AliCFTaskVertexingHF.cxx
CommitLineData
379592af 1/**************************************************************************
2 * Copyright(c) 1998-2009, 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//-----------------------------------------------------------------------
17// Class for HF corrections as a function of many variables
18// 6 Steps introduced: MC, MC Acc, Reco, Reco Acc, Reco Acc + ITS Cl,
19// Reco Acc + ITS Cl + PPR cuts
20// 12 variables used: pt, y, cosThetaStar, ptPi, ptK, ct,
21// dca, d0Pi, d0K, d0Pixd0K, cosPointingAngle, phi
22//
23//-----------------------------------------------------------------------
24// Author : C. Zampolli, CERN
25// D. Caffarri, Univ & INFN Padova caffarri@pd.infn.it
26//-----------------------------------------------------------------------
27//-----------------------------------------------------------------------
28// Base class for HF Unfolding (pt and eta)
29// correlation matrix filled at Acceptance and PPR level
30// Author: A.Grelli , Utrecht - agrelli@uu.nl
31//-----------------------------------------------------------------------
32#include <TCanvas.h>
33#include <TParticle.h>
34#include <TDatabasePDG.h>
35#include <TH1I.h>
36#include <TStyle.h>
37#include <TFile.h>
5b37c6e5 38#include <TF1.h>
379592af 39
40#include "AliCFTaskVertexingHF.h"
41#include "AliStack.h"
42#include "AliMCEvent.h"
43#include "AliCFManager.h"
44#include "AliCFContainer.h"
45#include "AliLog.h"
46#include "AliAnalysisManager.h"
47#include "AliAODHandler.h"
48#include "AliAODEvent.h"
49#include "AliAODRecoDecay.h"
50#include "AliAODRecoDecayHF.h"
51#include "AliAODRecoDecayHF2Prong.h"
f2703bd2 52#include "AliAODRecoDecayHF3Prong.h"
53#include "AliAODRecoDecayHF4Prong.h"
54#include "AliAODRecoCascadeHF.h"
379592af 55#include "AliAODMCParticle.h"
56#include "AliAODMCHeader.h"
57#include "AliESDtrack.h"
58#include "TChain.h"
59#include "THnSparse.h"
60#include "TH2D.h"
61#include "AliESDtrackCuts.h"
f2703bd2 62#include "AliRDHFCuts.h"
379592af 63#include "AliRDHFCutsD0toKpi.h"
f2703bd2 64#include "AliRDHFCutsDplustoKpipi.h"
65#include "AliRDHFCutsDStartoKpipi.h"
66#include "AliRDHFCutsDstoKKpi.h"
67#include "AliRDHFCutsLctopKpi.h"
68#include "AliRDHFCutsD0toKpipipi.h"
379592af 69#include "AliCFVertexingHF2Prong.h"
4e600f58 70#include "AliCFVertexingHF3Prong.h"
367e9aa3 71#include "AliCFVertexingHFCascade.h"
379592af 72#include "AliCFVertexingHF.h"
afb24c40 73#include "AliVertexingHFUtils.h"
f2703bd2 74#include "AliAnalysisDataSlot.h"
75#include "AliAnalysisDataContainer.h"
379592af 76
77//__________________________________________________________________________
78AliCFTaskVertexingHF::AliCFTaskVertexingHF() :
f2703bd2 79 AliAnalysisTaskSE(),
f2703bd2 80 fCFManager(0x0),
81 fHistEventsProcessed(0x0),
82 fCorrelation(0x0),
83 fCountMC(0),
84 fCountAcc(0),
85 fCountVertex(0),
86 fCountRefit(0),
87 fCountReco(0),
88 fCountRecoAcc(0),
89 fCountRecoITSClusters(0),
90 fCountRecoPPR(0),
91 fCountRecoPID(0),
92 fEvents(0),
93 fDecayChannel(0),
94 fFillFromGenerated(kFALSE),
95 fOriginDselection(0),
96 fAcceptanceUnf(kTRUE),
97 fCuts(0),
98 fUseWeight(kFALSE),
99 fWeight(1.),
17bf1a34 100 fUseFlatPtWeight(kFALSE),
101 fUseZWeight(kFALSE),
afb24c40 102 fUseNchWeight(kFALSE),
31da6b05 103 fNvar(0),
104 fPartName(""),
3ee5eb83 105 fDauNames(""),
b7af2639 106 fSign(2),
fbec9fa9 107 fCentralitySelection(kTRUE),
0ada222f 108 fFakeSelection(0),
109 fRejectIfNoQuark(kTRUE),
6c62cb59 110 fUseMCVertex(kFALSE),
ec5288c3 111 fDsOption(1),
c83eda41 112 fGenDsOption(3),
5b37c6e5 113 fConfiguration(kCheetah), // by default, setting the fast configuration
afb24c40 114 fFuncWeight(0x0),
115 fHistoMeasNch(0x0),
fdd5a897 116 fHistoMCNch(0x0),
117 fResonantDecay(0)
379592af 118{
119 //
120 //Default ctor
121 //
122}
123//___________________________________________________________________________
5b37c6e5 124AliCFTaskVertexingHF::AliCFTaskVertexingHF(const Char_t* name, AliRDHFCuts* cuts, TF1* func) :
f2703bd2 125 AliAnalysisTaskSE(name),
f2703bd2 126 fCFManager(0x0),
127 fHistEventsProcessed(0x0),
128 fCorrelation(0x0),
129 fCountMC(0),
130 fCountAcc(0),
131 fCountVertex(0),
132 fCountRefit(0),
133 fCountReco(0),
134 fCountRecoAcc(0),
135 fCountRecoITSClusters(0),
136 fCountRecoPPR(0),
137 fCountRecoPID(0),
138 fEvents(0),
139 fDecayChannel(0),
140 fFillFromGenerated(kFALSE),
141 fOriginDselection(0),
142 fAcceptanceUnf(kTRUE),
143 fCuts(cuts),
144 fUseWeight(kFALSE),
145 fWeight(1.),
17bf1a34 146 fUseFlatPtWeight(kFALSE),
147 fUseZWeight(kFALSE),
afb24c40 148 fUseNchWeight(kFALSE),
31da6b05 149 fNvar(0),
150 fPartName(""),
3ee5eb83 151 fDauNames(""),
b7af2639 152 fSign(2),
fbec9fa9 153 fCentralitySelection(kTRUE),
0ada222f 154 fFakeSelection(0),
155 fRejectIfNoQuark(kTRUE),
6c62cb59 156 fUseMCVertex(kFALSE),
ec5288c3 157 fDsOption(1),
c83eda41 158 fGenDsOption(3),
5b37c6e5 159 fConfiguration(kCheetah), // by default, setting the fast configuration
afb24c40 160 fFuncWeight(func),
161 fHistoMeasNch(0x0),
fdd5a897 162 fHistoMCNch(0x0),
163 fResonantDecay(0)
379592af 164{
165 //
166 // Constructor. Initialization of Inputs and Outputs
167 //
379592af 168 /*
f2703bd2 169 DefineInput(0) and DefineOutput(0)
170 are taken care of by AliAnalysisTaskSE constructor
171 */
379592af 172 DefineOutput(1,TH1I::Class());
173 DefineOutput(2,AliCFContainer::Class());
174 DefineOutput(3,THnSparseD::Class());
f2703bd2 175 DefineOutput(4,AliRDHFCuts::Class());
379592af 176
177 fCuts->PrintAll();
178}
179
180//___________________________________________________________________________
181AliCFTaskVertexingHF& AliCFTaskVertexingHF::operator=(const AliCFTaskVertexingHF& c)
182{
183 //
184 // Assignment operator
185 //
186 if (this!=&c) {
187 AliAnalysisTaskSE::operator=(c) ;
379592af 188 fCFManager = c.fCFManager;
189 fHistEventsProcessed = c.fHistEventsProcessed;
190 fCuts = c.fCuts;
5b37c6e5 191 fFuncWeight = c.fFuncWeight;
afb24c40 192 fHistoMeasNch = c.fHistoMeasNch;
193 fHistoMCNch = c.fHistoMCNch;
379592af 194 }
195 return *this;
196}
197
198//___________________________________________________________________________
199AliCFTaskVertexingHF::AliCFTaskVertexingHF(const AliCFTaskVertexingHF& c) :
f2703bd2 200 AliAnalysisTaskSE(c),
f2703bd2 201 fCFManager(c.fCFManager),
202 fHistEventsProcessed(c.fHistEventsProcessed),
203 fCorrelation(c.fCorrelation),
204 fCountMC(c.fCountMC),
205 fCountAcc(c.fCountAcc),
206 fCountVertex(c.fCountVertex),
207 fCountRefit(c.fCountRefit),
208 fCountReco(c.fCountReco),
209 fCountRecoAcc(c.fCountRecoAcc),
210 fCountRecoITSClusters(c.fCountRecoITSClusters),
211 fCountRecoPPR(c.fCountRecoPPR),
212 fCountRecoPID(c.fCountRecoPID),
213 fEvents(c.fEvents),
214 fDecayChannel(c.fDecayChannel),
215 fFillFromGenerated(c.fFillFromGenerated),
216 fOriginDselection(c.fOriginDselection),
217 fAcceptanceUnf(c.fAcceptanceUnf),
218 fCuts(c.fCuts),
219 fUseWeight(c.fUseWeight),
220 fWeight(c.fWeight),
17bf1a34 221 fUseFlatPtWeight(c.fUseFlatPtWeight),
222 fUseZWeight(c.fUseZWeight),
afb24c40 223 fUseNchWeight(c.fUseNchWeight),
31da6b05 224 fNvar(c.fNvar),
225 fPartName(c.fPartName),
3ee5eb83 226 fDauNames(c.fDauNames),
b7af2639 227 fSign(c.fSign),
fbec9fa9 228 fCentralitySelection(c.fCentralitySelection),
0ada222f 229 fFakeSelection(c.fFakeSelection),
230 fRejectIfNoQuark(c.fRejectIfNoQuark),
6c62cb59 231 fUseMCVertex(c.fUseMCVertex),
ec5288c3 232 fDsOption(c.fDsOption),
c83eda41 233 fGenDsOption(c.fGenDsOption),
5b37c6e5 234 fConfiguration(c.fConfiguration),
afb24c40 235 fFuncWeight(c.fFuncWeight),
236 fHistoMeasNch(c.fHistoMeasNch),
fdd5a897 237 fHistoMCNch(c.fHistoMCNch),
238 fResonantDecay(c.fResonantDecay)
379592af 239{
240 //
241 // Copy Constructor
242 //
243}
244
245//___________________________________________________________________________
f2703bd2 246AliCFTaskVertexingHF::~AliCFTaskVertexingHF()
247{
379592af 248 //
249 //destructor
250 //
251 if (fCFManager) delete fCFManager ;
252 if (fHistEventsProcessed) delete fHistEventsProcessed ;
f2703bd2 253 if (fCorrelation) delete fCorrelation ;
379592af 254 if (fCuts) delete fCuts;
afb24c40 255 if (fFuncWeight) delete fFuncWeight;
256 if (fHistoMeasNch) delete fHistoMeasNch;
257 if (fHistoMCNch) delete fHistoMCNch;
379592af 258}
259
f2703bd2 260//_________________________________________________________________________-
261void AliCFTaskVertexingHF::Init()
262{
263 //
264 // Initialization
265 //
266
267 if (fDebug>1) printf("AliCFTaskVertexingHF::Init()");
17bf1a34 268 if(fUseWeight && fUseZWeight) { AliFatal("Can not use at the same time pt and z-vtx weights, please choose"); return; }
afb24c40 269 if(fUseWeight && fUseNchWeight) { AliFatal("Can not use at the same time pt and Nch weights, please choose"); return; }
270 if(fUseNchWeight && !fHistoMCNch) { AliFatal("Need to pass the MC Nch distribution to use Nch weights"); return; }
271 if(fUseNchWeight) CreateMeasuredNchHisto();
272
f2703bd2 273 AliRDHFCuts *copyfCuts = 0x0;
8a983038 274 if (!fCuts){
275 AliFatal("No cuts defined - Exiting...");
276 return;
277 }
278
f2703bd2 279 switch (fDecayChannel){
280 case 2:{
314ec0fe 281 copyfCuts = new AliRDHFCutsD0toKpi(*(static_cast<AliRDHFCutsD0toKpi*>(fCuts)));
ec5288c3 282 switch (fConfiguration) {
283 case kSnail: // slow configuration: all variables in
284 fNvar = 16;
285 break;
286 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
287 fNvar = 8;
288 break;
289 }
31da6b05 290 fPartName="D0";
291 fDauNames="K+pi";
f2703bd2 292 break;
293 }
294 case 21:{
314ec0fe 295 copyfCuts = new AliRDHFCutsDStartoKpipi(*(static_cast<AliRDHFCutsDStartoKpipi*>(fCuts)));
ec5288c3 296 switch (fConfiguration) {
297 case kSnail: // slow configuration: all variables in
298 fNvar = 16;
299 break;
300 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
301 fNvar = 8;
302 break;
303 }
31da6b05 304 fPartName="Dstar";
305 fDauNames="K+pi+pi";
f2703bd2 306 break;
307 }
308 case 31:{
314ec0fe 309 copyfCuts = new AliRDHFCutsDplustoKpipi(*(static_cast<AliRDHFCutsDplustoKpipi*>(fCuts)));
ec5288c3 310 switch (fConfiguration) {
311 case kSnail: // slow configuration: all variables in
312 fNvar = 14;
313 break;
314 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
315 fNvar = 8;
316 break;
317 }
31da6b05 318 fPartName="Dplus";
319 fDauNames="K+pi+pi";
f2703bd2 320 break;
321 }
322 case 32:{
314ec0fe 323 copyfCuts = new AliRDHFCutsLctopKpi(*(static_cast<AliRDHFCutsLctopKpi*>(fCuts)));
ec5288c3 324 switch (fConfiguration) {
325 case kSnail: // slow configuration: all variables in
326 fNvar = 18;
327 break;
328 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
329 fNvar = 8;
330 break;
331 }
31da6b05 332 fPartName="Lambdac";
333 fDauNames="p+K+pi";
f2703bd2 334 break;
335 }
336 case 33:{
314ec0fe 337 copyfCuts = new AliRDHFCutsDstoKKpi(*(static_cast<AliRDHFCutsDstoKKpi*>(fCuts)));
ec5288c3 338 switch (fConfiguration) {
339 case kSnail: // slow configuration: all variables in
340 fNvar = 14;
341 break;
342 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
343 fNvar = 8;
344 break;
345 }
31da6b05 346 fPartName="Ds";
347 fDauNames="K+K+pi";
f2703bd2 348 break;
349 }
350 case 4:{
314ec0fe 351 copyfCuts = new AliRDHFCutsD0toKpipipi(*(static_cast<AliRDHFCutsD0toKpipipi*>(fCuts)));
ec5288c3 352 switch (fConfiguration) {
353 case kSnail: // slow configuration: all variables in
354 fNvar = 16;
355 break;
356 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
357 fNvar = 8;
358 break;
359 }
31da6b05 360 fPartName="D0";
361 fDauNames="K+pi+pi+pi";
f2703bd2 362 break;
363 }
364 default:
365 AliFatal("The decay channel MUST be defined according to AliCFVertexing::DecayChannel - Exiting...");
366 break;
367 }
368
369 const char* nameoutput=GetOutputSlot(4)->GetContainer()->GetName();
8a983038 370 if (copyfCuts){
371 copyfCuts->SetName(nameoutput);
372
373 //Post the data
374 PostData(4, copyfCuts);
375 }
376 else{
377 AliFatal("Failing initializing AliRDHFCuts object - Exiting...");
378 }
f2703bd2 379
380 return;
381}
382
379592af 383//_________________________________________________
384void AliCFTaskVertexingHF::UserExec(Option_t *)
385{
379592af 386 //
387 // Main loop function
388 //
389
390 PostData(1,fHistEventsProcessed) ;
391 PostData(2,fCFManager->GetParticleContainer()) ;
0e355b7f 392 PostData(3,fCorrelation) ;
b7af2639 393
379592af 394 if (fFillFromGenerated){
395 AliWarning("Flag to fill container with generated value ON ---> dca, d0pi, d0K, d0xd0, cosPointingAngle will be set as dummy!");
396 }
397
398 if (!fInputEvent) {
399 Error("UserExec","NO EVENT FOUND!");
400 return;
401 }
402
403 AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
404
f2703bd2 405 TClonesArray *arrayBranch=0;
379592af 406
407 if(!aodEvent && AODEvent() && IsStandardAOD()) {
f2703bd2 408 // In case there is an AOD handler writing a standard AOD, use the AOD
409 // event in memory rather than the input (ESD) event.
410 aodEvent = dynamic_cast<AliAODEvent*> (AODEvent());
411 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
412 // have to taken from the AOD event hold by the AliAODExtension
413 AliAODHandler* aodHandler = (AliAODHandler*)
414 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
415 if(aodHandler->GetExtensions()) {
416 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
417 AliAODEvent *aodFromExt = ext->GetAOD();
418
419 switch (fDecayChannel){
420 case 2:{
421 arrayBranch=(TClonesArray*)aodFromExt->GetList()->FindObject("D0toKpi");
422 break;
423 }
424 case 21:{
425 arrayBranch=(TClonesArray*)aodFromExt->GetList()->FindObject("Dstar");
426 break;
427 }
428 case 31:
429 case 32:
430 case 33:{
431 arrayBranch=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong");
432 break;
433 }
434 case 4:{
435 arrayBranch=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm4Prong");
436 break;
437 }
438 default:
439 break;
440 }
441 }
442 }
443 else {
444 switch (fDecayChannel){
445 case 2:{
446 arrayBranch=(TClonesArray*)aodEvent->GetList()->FindObject("D0toKpi");
447 break;
448 }
449 case 21:{
450 arrayBranch=(TClonesArray*)aodEvent->GetList()->FindObject("Dstar");
451 break;
452 }
453 case 31:
454 case 32:
455 case 33:{
456 arrayBranch=(TClonesArray*)aodEvent->GetList()->FindObject("Charm3Prong");
457 break;
458 }
459 case 4:{
460 arrayBranch=(TClonesArray*)aodEvent->GetList()->FindObject("Charm4Prong");
461 break;
462 }
463 default:
464 break;
465 }
379592af 466 }
ec5288c3 467
379592af 468 AliAODVertex *aodVtx = (AliAODVertex*)aodEvent->GetPrimaryVertex();
469 if (!aodVtx) return;
f2703bd2 470
471 if (!arrayBranch) {
472 AliError("Could not find array of HF vertices");
473 return;
379592af 474 }
475
476 fEvents++;
6e2e4f50 477
379592af 478 fCFManager->SetRecEventInfo(aodEvent);
479 fCFManager->SetMCEventInfo(aodEvent);
480
379592af 481 //******** DEFINE number of variables of the container***** for now set at 13, in the future in the config macro.
379592af 482
379592af 483 //loop on the MC event
484
485 TClonesArray* mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
486 if (!mcArray) {
487 AliError("Could not find Monte-Carlo in AOD");
488 return;
489 }
490 Int_t icountMC = 0;
491 Int_t icountAcc = 0;
492 Int_t icountReco = 0;
493 Int_t icountVertex = 0;
494 Int_t icountRefit = 0;
495 Int_t icountRecoAcc = 0;
496 Int_t icountRecoITSClusters = 0;
497 Int_t icountRecoPPR = 0;
498 Int_t icountRecoPID = 0;
379592af 499 Int_t cquarks = 0;
f2703bd2 500
379592af 501 AliAODMCHeader *mcHeader = dynamic_cast<AliAODMCHeader*>(aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
502 if (!mcHeader) {
503 AliError("Could not find MC Header in AOD");
504 return;
505 }
e11ae259 506
507 Double_t* containerInput = new Double_t[fNvar];
508 Double_t* containerInputMC = new Double_t[fNvar];
509
f2703bd2 510
511 AliCFVertexingHF* cfVtxHF=0x0;
512 switch (fDecayChannel){
513 case 2:{
367e9aa3 514 cfVtxHF = new AliCFVertexingHF2Prong(mcArray, fOriginDselection);
515 break;
f2703bd2 516 }
517 case 21:{
367e9aa3 518 cfVtxHF = new AliCFVertexingHFCascade(mcArray, fOriginDselection);
519 break;
f2703bd2 520 }
521 case 31:
fdd5a897 522// case 32:
f2703bd2 523 case 33:{
4e600f58 524 cfVtxHF = new AliCFVertexingHF3Prong(mcArray, fOriginDselection, fDecayChannel);
c83eda41 525 if(fDecayChannel==33){
fdd5a897 526 ((AliCFVertexingHF3Prong*)cfVtxHF)->SetGeneratedDsOption(fGenDsOption);
c83eda41 527 }
f2703bd2 528 break;
529 }
fdd5a897 530 case 32:{
531 cfVtxHF = new AliCFVertexingHF3Prong(mcArray, fOriginDselection, fDecayChannel,fResonantDecay);
532 }
f2703bd2 533 case 4:{
534 //cfVtxHF = new AliCFVertexingHF4Prong(mcArray, originDselection); // not there yet
535 break;
536 }
537 default:
538 break;
539 }
8a983038 540 if (!cfVtxHF){
541 AliError("No AliCFVertexingHF initialized");
d49092e3 542 delete[] containerInput;
543 delete[] containerInputMC;
8a983038 544 return;
545 }
f2703bd2 546
379592af 547 Double_t zPrimVertex = aodVtx ->GetZ();
548 Double_t zMCVertex = mcHeader->GetVtxZ();
17bf1a34 549 Int_t runnumber = aodEvent->GetRunNumber();
afb24c40 550 fWeight=1.;
551 if(fUseZWeight) fWeight *= GetZWeight(zMCVertex,runnumber);
552 if(fUseNchWeight){
553 Int_t nChargedMCPhysicalPrimary=AliVertexingHFUtils::GetGeneratedPhysicalPrimariesInEtaRange(mcArray,-1.0,1.0);
554 fWeight *= GetNchWeight(nChargedMCPhysicalPrimary);
555 AliDebug(2,Form("Using Nch weights, Mult=%d Weight=%f\n",nChargedMCPhysicalPrimary,fWeight));
556 }
17bf1a34 557
751b8274 558 if (TMath::Abs(zMCVertex) > fCuts->GetMaxVtxZ()){
559 AliDebug(3,Form("z coordinate of MC vertex = %f, it was required to be within [-%f, +%f], skipping event", zMCVertex, fCuts->GetMaxVtxZ(), fCuts->GetMaxVtxZ()));
3655ecf2 560 delete[] containerInput;
561 delete[] containerInputMC;
751b8274 562 return;
563 }
564
2bf2e62b 565 AliESDtrackCuts** trackCuts = new AliESDtrackCuts*[cfVtxHF->GetNProngs()];
566 if (fDecayChannel == 21){
567 // for the D*, setting the third element of the array of the track cuts to those for the soft pion
568 for (Int_t iProng = 0; iProng<cfVtxHF->GetNProngs()-1; iProng++){
569 trackCuts[iProng]=fCuts->GetTrackCuts();
570 }
367e9aa3 571 trackCuts[2] = fCuts->GetTrackCutsSoftPi();
2bf2e62b 572 }
573 else {
574 for (Int_t iProng = 0; iProng<cfVtxHF->GetNProngs(); iProng++){
575 trackCuts[iProng]=fCuts->GetTrackCuts();
576 }
577 }
578
379592af 579 //General settings: vertex, feed down and fill reco container with generated values.
580 cfVtxHF->SetRecoPrimVertex(zPrimVertex);
581 cfVtxHF->SetMCPrimaryVertex(zMCVertex);
582 cfVtxHF->SetFillFromGenerated(fFillFromGenerated);
b7af2639 583 cfVtxHF->SetNVar(fNvar);
fbec9fa9 584 cfVtxHF->SetFakeSelection(fFakeSelection);
0ada222f 585 cfVtxHF->SetRejectCandidateIfNotFromQuark(fRejectIfNoQuark);
ec5288c3 586 cfVtxHF->SetConfiguration(fConfiguration);
b7af2639 587
af548a24 588 // switch-off the trigger class selection (doesn't work for MC)
589 fCuts->SetTriggerClass("");
590
0ada222f 591 // MC vertex, to be used, in case, for pp
592 if (fUseMCVertex) fCuts->SetUseMCVertex();
af548a24 593
72156e2e 594 if (fCentralitySelection){ // keep only the requested centrality
661d6c29 595 if(fCuts->IsEventSelectedInCentrality(aodEvent)!=0) {
596 delete[] containerInput;
597 delete[] containerInputMC;
598 delete [] trackCuts;
599 return;
600 }
72156e2e 601 } else { // keep all centralities
602 fCuts->SetMinCentrality(0.);
603 fCuts->SetMaxCentrality(100.);
8b1b055d 604 }
605
b7af2639 606 Float_t centValue = fCuts->GetCentrality(aodEvent);
607 cfVtxHF->SetCentralityValue(centValue);
f2703bd2 608
ec5288c3 609 // number of tracklets - multiplicity estimator
610 Double_t multiplicity = (Double_t)(aodEvent->GetTracklets()->GetNumberOfTracklets()); // casted to double because the CF is filled with doubles
611 cfVtxHF->SetMultiplicity(multiplicity);
612
379592af 613 for (Int_t iPart=0; iPart<mcArray->GetEntriesFast(); iPart++) {
b7af2639 614 AliAODMCParticle* mcPart = dynamic_cast<AliAODMCParticle*>(mcArray->At(iPart));
615 if (!mcPart){
616 AliError("Failed casting particle from MC array!, Skipping particle");
617 continue;
618 }
619 // check the MC-level cuts, must be the desidered particle
620 if (!fCFManager->CheckParticleCuts(0, mcPart)) {
621 continue; // 0 stands for MC level
622 }
623 cfVtxHF->SetMCCandidateParam(iPart);
624
625 //counting c quarks
626 cquarks += cfVtxHF->MCcquarkCounting(mcPart);
627
628 if (!(cfVtxHF->SetLabelArray())){
629 AliDebug(2,Form("Impossible to set the label array (decaychannel = %d)",fDecayChannel));
630 continue;
631 }
2bf2e62b 632
b7af2639 633 //check the candiate family at MC level
634 if (!(cfVtxHF->CheckMCPartFamily(mcPart, mcArray))) {
635 AliDebug(2,Form("Check on the family wrong!!! (decaychannel = %d)",fDecayChannel));
636 continue;
637 }
f2703bd2 638 else{
6e2e4f50 639 AliDebug(2,Form("Check on the family OK!!! (decaychannel = %d)",fDecayChannel));
f2703bd2 640 }
641
642 //Fill the MC container
643 Bool_t mcContainerFilled = cfVtxHF -> FillMCContainer(containerInputMC);
f2703bd2 644 if (mcContainerFilled) {
5b37c6e5 645 if (fUseWeight){
646 if (fFuncWeight){ // using user-defined function
647 AliDebug(2,"Using function");
648 fWeight = fFuncWeight->Eval(containerInputMC[0]);
649 }
650 else{ // using FONLL
651 AliDebug(2,"Using FONLL");
652 fWeight = GetWeight(containerInputMC[0]);
653 }
654 AliDebug(2,Form("pt = %f, weight = %f",containerInputMC[0], fWeight));
655 }
f2703bd2 656 if (!fCuts->IsInFiducialAcceptance(containerInputMC[0],containerInputMC[1])) continue;
657 //MC Limited Acceptance
658 if (TMath::Abs(containerInputMC[1]) < 0.5) {
659 fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepGeneratedLimAcc, fWeight);
660 AliDebug(3,"MC Lim Acc container filled\n");
661 }
662
663 //MC
664 fCFManager->GetParticleContainer()->Fill(containerInputMC, kStepGenerated, fWeight);
665 icountMC++;
666 AliDebug(3,"MC cointainer filled \n");
667
668 // MC in acceptance
669 // check the MC-Acceptance level cuts
670 // since standard CF functions are not applicable, using Kine Cuts on daughters
671 Bool_t mcAccepStep = cfVtxHF-> MCAcceptanceStep();
672 if (mcAccepStep){
673 fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepAcceptance, fWeight);
674 AliDebug(3,"MC acceptance cut passed\n");
675 icountAcc++;
676
677 //MC Vertex step
678 if (fCuts->IsEventSelected(aodEvent)){
679 // filling the container if the vertex is ok
680 fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepVertex, fWeight) ;
681 AliDebug(3,"Vertex cut passed and container filled\n");
682 icountVertex++;
683
684 //mc Refit requirement
2bf2e62b 685 Bool_t mcRefitStep = cfVtxHF->MCRefitStep(aodEvent, &trackCuts[0]);
f2703bd2 686 if (mcRefitStep){
687 fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepRefit, fWeight);
688 AliDebug(3,"MC Refit cut passed and container filled\n");
689 icountRefit++;
690 }
691 else{
692 AliDebug(3,"MC Refit cut not passed\n");
693 continue;
694 }
695 }
696 else{
379592af 697 AliDebug (3, "MC vertex step not passed\n");
698 continue;
f2703bd2 699 }
700 }
701 else{
702 AliDebug (3, "MC in acceptance step not passed\n");
703 continue;
704 }
705 }
706 else {
707 AliDebug (3, "MC container not filled\n");
379592af 708 }
709 }
f2703bd2 710
711 if (cquarks<2) AliDebug(2,Form("Event with %d c-quarks", cquarks));
31da6b05 712 AliDebug(2,Form("Found %i MC particles that are %s!!",icountMC,fPartName.Data()));
713 AliDebug(2,Form("Found %i MC particles that are %s and satisfy Acc cuts!!",icountAcc,fPartName.Data()));
714 AliDebug(2,Form("Found %i MC particles that are %s and satisfy Vertex cuts!!",icountVertex,fPartName.Data()));
715 AliDebug(2,Form("Found %i MC particles that are %s and satisfy Refit cuts!!",icountRefit,fPartName.Data()));
f2703bd2 716
379592af 717 // Now go to rec level
718 fCountMC += icountMC;
719 fCountAcc += icountAcc;
720 fCountVertex+= icountVertex;
721 fCountRefit+= icountRefit;
f2703bd2 722
6e2e4f50 723 AliDebug(2,Form("Found %d vertices for decay channel %d",arrayBranch->GetEntriesFast(),fDecayChannel));
379592af 724
f2703bd2 725 for(Int_t iCandid = 0; iCandid<arrayBranch->GetEntriesFast();iCandid++){
f2703bd2 726 AliAODRecoDecayHF* charmCandidate=0x0;
727 switch (fDecayChannel){
728 case 2:{
729 charmCandidate = (AliAODRecoDecayHF2Prong*)arrayBranch->At(iCandid);
730 break;
731 }
732 case 21:{
733 charmCandidate = (AliAODRecoCascadeHF*)arrayBranch->At(iCandid);
734 break;
735 }
736 case 31:
737 case 32:
738 case 33:{
739 charmCandidate = (AliAODRecoDecayHF3Prong*)arrayBranch->At(iCandid);
740 break;
741 }
742 case 4:{
743 charmCandidate = (AliAODRecoDecayHF4Prong*)arrayBranch->At(iCandid);
744 break;
745 }
746 default:
747 break;
748 }
749
379592af 750 Bool_t unsetvtx=kFALSE;
f2703bd2 751 if(!charmCandidate->GetOwnPrimaryVtx()) {
752 charmCandidate->SetOwnPrimaryVtx(aodVtx); // needed to compute all variables
379592af 753 unsetvtx=kTRUE;
754 }
f2703bd2 755
756 Bool_t signAssociation = cfVtxHF->SetRecoCandidateParam((AliAODRecoDecayHF*)charmCandidate);
379592af 757 if (!signAssociation){
f2703bd2 758 charmCandidate = 0x0;
379592af 759 continue;
760 }
3ee5eb83 761
762 Int_t isPartOrAntipart = cfVtxHF->CheckReflexion(fSign);
763 if (isPartOrAntipart == 0){
764 AliDebug(2, Form("The candidate pdg code doesn't match the requirement set in the task (fSign = %d)",fSign));
765 continue;
766 }
767
6694a2a8 768
379592af 769 Bool_t recoContFilled = cfVtxHF->FillRecoContainer(containerInput);
770 if (recoContFilled){
6694a2a8 771
772 // weight according to pt
5b37c6e5 773 if (fUseWeight){
774 if (fFuncWeight){ // using user-defined function
775 AliDebug(2, "Using function");
776 fWeight = fFuncWeight->Eval(containerInput[0]);
777 }
778 else{ // using FONLL
779 AliDebug(2, "Using FONLL");
780 fWeight = GetWeight(containerInput[0]);
781 }
782 AliDebug(2, Form("pt = %f, weight = %f",containerInput[0], fWeight));
783 }
6694a2a8 784
379592af 785 if (!fCuts->IsInFiducialAcceptance(containerInput[0],containerInput[1])) continue;
f2703bd2 786
379592af 787 //Reco Step
788 Bool_t recoStep = cfVtxHF->RecoStep();
789 Bool_t vtxCheck = fCuts->IsEventSelected(aodEvent);
f2703bd2 790
379592af 791 if (recoStep && recoContFilled && vtxCheck){
f2703bd2 792 fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructed, fWeight) ;
379592af 793 icountReco++;
f2703bd2 794 AliDebug(3,"Reco step passed and container filled\n");
795
379592af 796 //Reco in the acceptance -- take care of UNFOLDING!!!!
2bf2e62b 797 Bool_t recoAcceptanceStep = cfVtxHF->RecoAcceptStep(&trackCuts[0]);
379592af 798 if (recoAcceptanceStep) {
f2703bd2 799 fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoAcceptance, fWeight) ;
379592af 800 icountRecoAcc++;
f2703bd2 801 AliDebug(3,"Reco acceptance cut passed and container filled\n");
802
379592af 803 if(fAcceptanceUnf){
804 Double_t fill[4]; //fill response matrix
805 Bool_t bUnfolding = cfVtxHF -> FillUnfoldingMatrix(fill);
806 if (bUnfolding) fCorrelation->Fill(fill);
f2703bd2 807 }
808
379592af 809 //Number of ITS cluster requirements
f2703bd2 810 Int_t recoITSnCluster = fCuts->IsSelected(charmCandidate, AliRDHFCuts::kTracks);
379592af 811 if (recoITSnCluster){
f2703bd2 812 fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoITSClusters, fWeight) ;
379592af 813 icountRecoITSClusters++;
f2703bd2 814 AliDebug(3,"Reco n ITS cluster cut passed and container filled\n");
815
816 Bool_t iscutsusingpid = fCuts->GetIsUsePID();
817 Int_t recoAnalysisCuts = -1, recoPidSelection = -1;
818 fCuts->SetUsePID(kFALSE);
819 recoAnalysisCuts = fCuts->IsSelected(charmCandidate, AliRDHFCuts::kCandidate, aodEvent);
820
6c62cb59 821 if (fDecayChannel==33){ // Ds case, where more possibilities are considered
822 Bool_t keepDs=ProcessDs(recoAnalysisCuts);
823 if(keepDs) recoAnalysisCuts=3;
f2703bd2 824 }
6c62cb59 825
379592af 826
f2703bd2 827 fCuts->SetUsePID(iscutsusingpid); //restoring usage of the PID from the cuts object
fdd5a897 828 Bool_t tempAn=(recoAnalysisCuts == 3 || recoAnalysisCuts == isPartOrAntipart);
829 if (fDecayChannel == 32) tempAn=(recoAnalysisCuts >0 || recoAnalysisCuts == isPartOrAntipart);
830
831 if (tempAn){
f2703bd2 832 fCFManager->GetParticleContainer()->Fill(containerInput, kStepRecoPPR, fWeight);
833 icountRecoPPR++;
834 AliDebug(3,"Reco Analysis cuts passed and container filled \n");
835 //pid selection
836 //recoPidSelection = fCuts->IsSelected(charmCandidate, AliRDHFCuts::kPID);
837 //if((fCuts->CombineSelectionLevels(3,recoAnalysisCuts,recoPidSelection)==isPartOrAntipart)||(fCuts->CombineSelectionLevels(3,recoAnalysisCuts,recoPidSelection)==3)){
838 recoPidSelection = fCuts->IsSelected(charmCandidate, AliRDHFCuts::kCandidate, aodEvent);
6c62cb59 839
840 if (fDecayChannel==33){ // Ds case, where more possibilities are considered
841 Bool_t keepDs=ProcessDs(recoPidSelection);
842 if(keepDs) recoPidSelection=3;
843 }
fdd5a897 844 Bool_t tempPid=(recoPidSelection == 3 || recoPidSelection == isPartOrAntipart);
845 if (fDecayChannel == 32) tempPid=(recoPidSelection >0 || recoPidSelection == isPartOrAntipart);
6c62cb59 846
fdd5a897 847 if (tempPid){
f2703bd2 848 fCFManager->GetParticleContainer()->Fill(containerInput, kStepRecoPID, fWeight);
849 icountRecoPID++;
850 AliDebug(3,"Reco PID cuts passed and container filled \n");
851 if(!fAcceptanceUnf){
852 Double_t fill[4]; //fill response matrix
853 Bool_t bUnfolding = cfVtxHF -> FillUnfoldingMatrix(fill);
854 if (bUnfolding) fCorrelation->Fill(fill);
855 }
856 }
857 else {
858 AliDebug(3, "Analysis Cuts step not passed \n");
859 continue;
860 }
379592af 861 }
862 else {
f2703bd2 863 AliDebug(3, "PID selection not passed \n");
864 continue;
379592af 865 }
866 }
867 else{
f2703bd2 868 AliDebug(3, "Number of ITS cluster step not passed\n");
869 continue;
379592af 870 }
871 }
872 else{
f2703bd2 873 AliDebug(3, "Reco acceptance step not passed\n");
874 continue;
379592af 875 }
876 }
877 else {
f2703bd2 878 AliDebug(3, "Reco step not passed\n");
879 continue;
379592af 880 }
881 }
882
f2703bd2 883 if(unsetvtx) charmCandidate->UnsetOwnPrimaryVtx();
884 } // end loop on candidate
885
379592af 886 fCountReco+= icountReco;
887 fCountRecoAcc+= icountRecoAcc;
888 fCountRecoITSClusters+= icountRecoITSClusters;
889 fCountRecoPPR+= icountRecoPPR;
890 fCountRecoPID+= icountRecoPID;
891
892 fHistEventsProcessed->Fill(0);
f2703bd2 893
894 delete[] containerInput;
f2703bd2 895 delete[] containerInputMC;
f2703bd2 896 delete cfVtxHF;
2bf2e62b 897 if (trackCuts){
898 // for (Int_t i=0; i<cfVtxHF->GetNProngs(); i++){
899 // delete [] trackCuts[i];
900 // }
901 delete [] trackCuts;
902 }
ec5288c3 903
904
379592af 905}
906
907//___________________________________________________________________________
908void AliCFTaskVertexingHF::Terminate(Option_t*)
909{
910 // The Terminate() function is the last function to be called during
911 // a query. It always runs on the client, it can be used to present
912 // the results graphically or save the results to file.
913
914 AliAnalysisTaskSE::Terminate();
31da6b05 915
916 AliInfo(Form("Found %i MC particles that are %s in MC, in %d events",fCountMC,fPartName.Data(),fEvents));
917 AliInfo(Form("Found %i MC particles that are %s in MC and satisfy Acc cuts, in %d events",fCountAcc,fPartName.Data(),fEvents));
918 AliInfo(Form("Found %i MC particles that are %s in MC and satisfy Acc cuts, and satisfy Vertex requirement in %d events",fCountVertex,fPartName.Data(),fEvents));
919 AliInfo(Form("Found %i MC particles that are %s in MC and satisfy Acc cuts, and satisfy ITS+TPC refit requirementin %d events",fCountRefit,fPartName.Data(),fEvents));
920 AliInfo(Form("Found %i reco %s that are decaying in %s, in %d events",fCountReco,fPartName.Data(),fDauNames.Data(),fEvents));
921 AliInfo(Form("Among the above, found %i reco %s that are decaying in %s and are in the requested acceptance, in %d events",fCountRecoAcc,fPartName.Data(),fDauNames.Data(),fEvents));
922 AliInfo(Form("Among the above, found %i reco %s that are decaying in %s and have at least 5 clusters in ITS, in %d events",fCountRecoITSClusters,fPartName.Data(),fDauNames.Data(),fEvents));
923 AliInfo(Form("Among the above, found %i reco %s that are decaying in %s and satisfy PPR cuts, in %d events",fCountRecoPPR,fPartName.Data(),fDauNames.Data(),fEvents));
924 AliInfo(Form("Among the above, found %i reco %s that are decaying in %s and satisfy PPR+PID cuts, in %d events",fCountRecoPID,fPartName.Data(),fDauNames.Data(),fEvents));
379592af 925
926 // draw some example plots....
ec5288c3 927 AliCFContainer *cont= dynamic_cast<AliCFContainer*> (GetOutputData(2));
379592af 928 if(!cont) {
929 printf("CONTAINER NOT FOUND\n");
930 return;
931 }
932 // projecting the containers to obtain histograms
933 // first argument = variable, second argument = step
ec5288c3 934
935 TH1D** h = new TH1D*[3];
936 if (fConfiguration == kSnail){
937 //h = new TH1D[3][12];
938 for (Int_t ih = 0; ih<3; ih++){
939 h[ih] = new TH1D[12];
940 }
941 for(Int_t iC=1;iC<12; iC++){
942 // MC-level
943 h[0][iC] = *(cont->ShowProjection(iC,0));
944 // MC-Acceptance level
945 h[1][iC] = *(cont->ShowProjection(iC,1));
946 // Reco-level
947 h[2][iC] = *(cont->ShowProjection(iC,4));
948 }
31da6b05 949 }
ec5288c3 950 else{
951 //h = new TH1D[3][12];
952 for (Int_t ih = 0; ih<3; ih++){
953 h[ih] = new TH1D[8];
954 }
955 for(Int_t iC=0;iC<8; iC++){
956 // MC-level
957 h[0][iC] = *(cont->ShowProjection(iC,0));
958 // MC-Acceptance level
959 h[1][iC] = *(cont->ShowProjection(iC,1));
960 // Reco-level
961 h[2][iC] = *(cont->ShowProjection(iC,4));
962 }
963 }
ec5288c3 964 TString* titles;
965 Int_t nvarToPlot = 0;
966 if (fConfiguration == kSnail){
967 nvarToPlot = 12;
968 titles = new TString[nvarToPlot];
969 if(fDecayChannel==31){
970 titles[0]="pT_Dplus (GeV/c)";
971 titles[1]="rapidity";
972 titles[2]="phi (rad)";
973 titles[3]="cT (#mum)";
974 titles[4]="cosPointingAngle";
975 titles[5]="pT_1 (GeV/c)";
976 titles[6]="pT_2 (GeV/c)";
977 titles[7]="pT_3 (GeV/c)";
978 titles[8]="d0_1 (#mum)";
979 titles[9]="d0_2 (#mum)";
980 titles[10]="d0_3 (#mum)";
981 titles[11]="zVertex (cm)";
982 }else{
983 titles[0]="pT_D0 (GeV/c)";
984 titles[1]="rapidity";
985 titles[2]="cosThetaStar";
986 titles[3]="pT_pi (GeV/c)";
987 titles[4]="pT_K (Gev/c)";
988 titles[5]="cT (#mum)";
989 titles[6]="dca (#mum)";
990 titles[7]="d0_pi (#mum)";
991 titles[8]="d0_K (#mum)";
992 titles[9]="d0xd0 (#mum^2)";
993 titles[10]="cosPointingAngle";
994 titles[11]="phi (rad)";
995
996 }
997 }
998 else{
999 nvarToPlot = 8;
1000 titles = new TString[nvarToPlot];
1001 titles[0]="pT_candidate (GeV/c)";
1002 titles[1]="rapidity";
1003 titles[2]="cT (#mum)";
1004 titles[3]="phi";
1005 titles[4]="z_{vtx}";
1006 titles[5]="centrality";
1007 titles[6]="fake";
1008 titles[7]="multiplicity";
31da6b05 1009 }
ec5288c3 1010
31da6b05 1011 Int_t markers[12]={20,24,21,25,27,28,
1012 20,24,21,25,27,28};
1013 Int_t colors[3]={2,8,4};
ec5288c3 1014 for(Int_t iC=0;iC<nvarToPlot; iC++){
1015 for(Int_t iStep=0;iStep<3;iStep++){
1016 h[iStep][iC].SetTitle(titles[iC].Data());
1017 h[iStep][iC].GetXaxis()->SetTitle(titles[iC].Data());
1018 Double_t maxh=h[iStep][iC].GetMaximum();
1019 h[iStep][iC].GetYaxis()->SetRangeUser(0,maxh*1.2);
1020 h[iStep][iC].SetMarkerStyle(markers[iC]);
1021 h[iStep][iC].SetMarkerColor(colors[iStep]);
1022 }
31da6b05 1023 }
379592af 1024
1025 gStyle->SetCanvasColor(0);
1026 gStyle->SetFrameFillColor(0);
1027 gStyle->SetTitleFillColor(0);
1028 gStyle->SetStatColor(0);
1029
1030 // drawing in 2 separate canvas for a matter of clearity
ec5288c3 1031 TCanvas * c1 =new TCanvas(Form("c1New_%d",fDecayChannel),"Vars 0, 1, 2, 3",1100,1200);
1032 c1->Divide(3,4);
31da6b05 1033 Int_t iPad=1;
ec5288c3 1034 for(Int_t iVar=0; iVar<4; iVar++){
1035 c1->cd(iPad++);
5b37c6e5 1036 h[0][iVar].DrawCopy("p");
ec5288c3 1037 c1->cd(iPad++);
5b37c6e5 1038 h[1][iVar].DrawCopy("p");
ec5288c3 1039 c1->cd(iPad++);
5b37c6e5 1040 h[2][iVar].DrawCopy("p");
31da6b05 1041 }
379592af 1042
ec5288c3 1043 TCanvas * c2 =new TCanvas(Form("c2New_%d",fDecayChannel),"Vars 4, 5, 6, 7",1100,1200);
1044 c2->Divide(3,4);
31da6b05 1045 iPad=1;
ec5288c3 1046 for(Int_t iVar=4; iVar<8; iVar++){
1047 c2->cd(iPad++);
5b37c6e5 1048 h[0][iVar].DrawCopy("p");
ec5288c3 1049 c2->cd(iPad++);
5b37c6e5 1050 h[1][iVar].DrawCopy("p");
ec5288c3 1051 c2->cd(iPad++);
5b37c6e5 1052 h[2][iVar].DrawCopy("p");
31da6b05 1053 }
1054
ec5288c3 1055 if (fConfiguration == kSnail){
1056 TCanvas * c3 =new TCanvas(Form("c3New_%d",fDecayChannel),"Vars 8, 9, 10, 11",1100,1200);
1057 c3->Divide(3,4);
1058 iPad=1;
1059 for(Int_t iVar=8; iVar<12; iVar++){
1060 c3->cd(iPad++);
5b37c6e5 1061 h[0][iVar].DrawCopy("p");
ec5288c3 1062 c3->cd(iPad++);
5b37c6e5 1063 h[1][iVar].DrawCopy("p");
ec5288c3 1064 c3->cd(iPad++);
5b37c6e5 1065 h[2][iVar].DrawCopy("p");
ec5288c3 1066 }
31da6b05 1067 }
1068
4e0af875 1069 /*
379592af 1070 THnSparseD* hcorr = dynamic_cast<THnSparseD*> (GetOutputData(3));
1071
1072 TH2D* corr1 =hcorr->Projection(0,2);
1073 TH2D* corr2 = hcorr->Projection(1,3);
1074
ec5288c3 1075 TCanvas * c7 =new TCanvas(Form("c7New_%d",fDecayChannel),"",800,400);
379592af 1076 c7->Divide(2,1);
1077 c7->cd(1);
5b37c6e5 1078 corr1->DrawCopy("text");
379592af 1079 c7->cd(2);
5b37c6e5 1080 corr2->DrawCopy("text");
4e0af875 1081 */
379592af 1082 TFile* file_projection = new TFile("CFtaskHFprojectionNew.root","RECREATE");
1083
4e0af875 1084 // corr1->Write();
1085 // corr2->Write();
1086
ec5288c3 1087 for(Int_t iC=0;iC<nvarToPlot; iC++){
1088 for(Int_t iStep=0;iStep<3;iStep++){
1089 h[iStep][iC].Write(Form("Step%d_%s",iStep,titles[iC].Data()));
1090 }
31da6b05 1091 }
379592af 1092 file_projection->Close();
5b37c6e5 1093 for (Int_t ih = 0; ih<3; ih++) delete [] h[ih];
dc818294 1094 delete [] h;
6299d56c 1095
379592af 1096
379592af 1097}
1098
1099//___________________________________________________________________________
f2703bd2 1100void AliCFTaskVertexingHF::UserCreateOutputObjects()
1101{
379592af 1102 //HERE ONE CAN CREATE OUTPUT OBJECTS, IN PARTICULAR IF THE OBJECT PARAMETERS DON'T NEED
1103 //TO BE SET BEFORE THE EXECUTION OF THE TASK
1104 //
1105 Info("UserCreateOutputObjects","CreateOutputObjects of task %s\n", GetName());
1106
1107 //slot #1
1108 OpenFile(1);
b74f664f 1109 const char* nameoutput=GetOutputSlot(1)->GetContainer()->GetName();
1110 fHistEventsProcessed = new TH1I(nameoutput,"",1,0,1) ;
0e355b7f 1111
1112 PostData(1,fHistEventsProcessed) ;
1113 PostData(2,fCFManager->GetParticleContainer()) ;
1114 PostData(3,fCorrelation) ;
1115
379592af 1116}
1117
f2703bd2 1118
1119//_________________________________________________________________________
1120Double_t AliCFTaskVertexingHF::GetWeight(Float_t pt)
1121{
1122 //
1123 // calculating the weight to fill the container
1124 //
1125
1126 // FNOLL central:
1127 // p0 = 1.63297e-01 --> 0.322643
1128 // p1 = 2.96275e+00
1129 // p2 = 2.30301e+00
1130 // p3 = 2.50000e+00
1131
1132 // PYTHIA
1133 // p0 = 1.85906e-01 --> 0.36609
1134 // p1 = 1.94635e+00
1135 // p2 = 1.40463e+00
1136 // p3 = 2.50000e+00
1137
1138 Double_t func1[4] = {0.322643,2.96275,2.30301,2.5};
1139 Double_t func2[4] = {0.36609,1.94635,1.40463,2.5};
1140
1141 Double_t dndpt_func1 = dNdptFit(pt,func1);
17bf1a34 1142 if(fUseFlatPtWeight) dndpt_func1 = 1./30.;
f2703bd2 1143 Double_t dndpt_func2 = dNdptFit(pt,func2);
1144 AliDebug(2,Form("pt = %f, FONLL = %f, Pythia = %f, ratio = %f",pt,dndpt_func1,dndpt_func2,dndpt_func1/dndpt_func2));
1145 return dndpt_func1/dndpt_func2;
1146}
1147
1148//__________________________________________________________________________________________________
1149Double_t AliCFTaskVertexingHF::dNdptFit(Float_t pt, Double_t* par)
1150{
1151 //
1152 // calculating dNdpt
1153 //
1154
1155 Double_t denom = TMath::Power((pt/par[1]), par[3] );
1156 Double_t dNdpt = par[0]*pt/TMath::Power(1.+denom, par[2]);
1157
1158 return dNdpt;
1159}
6c62cb59 1160
17bf1a34 1161//__________________________________________________________________________________________________
1162Double_t AliCFTaskVertexingHF::GetZWeight(Float_t z, Int_t runnumber){
1163 //
1164 // calculating the z-vtx weight for the given run range
1165 //
1166
1167 if(runnumber>146824 || runnumber<146803) return 1.0;
1168
1169 Double_t func1[3] = {1.0, -0.5, 6.5 };
1170 Double_t func2[3] = {1.0, -0.5, 5.5 };
1171
1172 Double_t dzFunc1 = DodzFit(z,func1);
1173 Double_t dzFunc2 = DodzFit(z,func2);
1174
1175 return dzFunc1/dzFunc2;
1176}
1177
1178//__________________________________________________________________________________________________
1179Double_t AliCFTaskVertexingHF::DodzFit(Float_t z, Double_t* par) {
1180
1181 //
1182 // Gaussian z-vtx shape
1183 //
1184 //gaussian = [0]/TMath::Sqrt(2.*TMath::Pi())/[2]*exp[-(x-[1])*(x-[1])/(2*[2]*[2])]
1185
1186 Double_t value = par[0]/TMath::Sqrt(2.*TMath::Pi())/par[2]*TMath::Exp(-(z-par[1])*(z-par[1])/2./par[2]/par[2]);
1187
1188 return value;
1189}
6c62cb59 1190//__________________________________________________________________________________________________
afb24c40 1191Double_t AliCFTaskVertexingHF::GetNchWeight(Int_t nch){
1192 //
1193 // calculates the Nch weight using the measured and generateed Nch distributions
1194 //
1195 if(nch<=0) return 0.;
1196 Double_t pMeas=fHistoMeasNch->GetBinContent(fHistoMeasNch->FindBin(nch));
1197 Double_t pMC=fHistoMCNch->GetBinContent(fHistoMCNch->FindBin(nch));
1198 return pMeas/pMC;
1199}
1200//__________________________________________________________________________________________________
1201void AliCFTaskVertexingHF::CreateMeasuredNchHisto(){
1202 // creates historgam with measured multiplcity distribution in pp 7 TeV collisions (from Eur. Phys. J. C (2010) 68: 345–354)
1203 Double_t nchbins[66]={0.50,1.50,2.50,3.50,4.50,5.50,6.50,7.50,8.50,9.50,
1204 10.50,11.50,12.50,13.50,14.50,15.50,16.50,17.50,18.50,19.50,
1205 20.50,21.50,22.50,23.50,24.50,25.50,26.50,27.50,28.50,29.50,
1206 30.50,31.50,32.50,33.50,34.50,35.50,36.50,37.50,38.50,39.50,
1207 40.50,41.50,42.50,43.50,44.50,45.50,46.50,47.50,48.50,49.50,
1208 50.50,51.50,52.50,53.50,54.50,55.50,56.50,57.50,58.50,59.50,
1209 60.50,62.50,64.50,66.50,68.50,70.50};
1210 Double_t pch[65]={0.062011,0.072943,0.070771,0.067245,0.062834,0.057383,0.051499,0.04591,0.041109,0.036954,
1211 0.03359,0.030729,0.028539,0.026575,0.024653,0.0229,0.021325,0.019768,0.018561,0.017187,
1212 0.01604,0.014836,0.013726,0.012576,0.011481,0.010393,0.009502,0.008776,0.008024,0.007452,
1213 0.006851,0.006428,0.00594,0.005515,0.005102,0.00469,0.004162,0.003811,0.003389,0.003071,
1214 0.002708,0.002422,0.002184,0.001968,0.00186,0.00165,0.001577,0.001387,0.001254,0.001118,
1215 0.001037,0.000942,0.000823,0.000736,0.000654,0.000579,0.000512,0.00049,0.00045,0.000355,
1216 0.000296,0.000265,0.000193,0.00016,0.000126};
1217
1218 if(fHistoMeasNch) delete fHistoMeasNch;
1219 fHistoMeasNch=new TH1F("hMeaseNch","",65,nchbins);
1220 for(Int_t i=0; i<65; i++){
1221 fHistoMeasNch->SetBinContent(i+1,pch[i]);
1222 fHistoMeasNch->SetBinError(i+1,0.);
1223 }
1224}
1225
6c62cb59 1226Bool_t AliCFTaskVertexingHF::ProcessDs(Int_t recoAnalysisCuts) const{
1227 // processes output of Ds is selected
1228 Bool_t keep=kFALSE;
1229 if(recoAnalysisCuts > 0){
1230 Int_t isKKpi=recoAnalysisCuts&1;
1231 Int_t ispiKK=recoAnalysisCuts&2;
1232 Int_t isPhiKKpi=recoAnalysisCuts&4;
1233 Int_t isPhipiKK=recoAnalysisCuts&8;
1234 Int_t isK0starKKpi=recoAnalysisCuts&16;
1235 Int_t isK0starpiKK=recoAnalysisCuts&32;
1236 if(fDsOption==1){
1237 if(isKKpi && isPhiKKpi) keep=kTRUE;
1238 if(ispiKK && isPhipiKK) keep=kTRUE;
1239 }
1240 else if(fDsOption==2){
1241 if(isKKpi && isK0starKKpi) keep=kTRUE;
1242 if(ispiKK && isK0starpiKK) keep=kTRUE;
1243 }
1244 else if(fDsOption==3)keep=kTRUE;
1245 }
1246 return keep;
1247}