1 /**************************************************************************
2 * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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
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 //-----------------------------------------------------------------------
33 #include <TParticle.h>
34 #include <TDatabasePDG.h>
40 #include "AliCFTaskVertexingHF.h"
42 #include "AliMCEvent.h"
43 #include "AliCFManager.h"
44 #include "AliCFContainer.h"
46 #include "AliInputEventHandler.h"
47 #include "AliAnalysisManager.h"
48 #include "AliAODHandler.h"
49 #include "AliAODEvent.h"
50 #include "AliAODRecoDecay.h"
51 #include "AliAODRecoDecayHF.h"
52 #include "AliAODRecoDecayHF2Prong.h"
53 #include "AliAODRecoDecayHF3Prong.h"
54 #include "AliAODRecoDecayHF4Prong.h"
55 #include "AliAODRecoCascadeHF.h"
56 #include "AliAODMCParticle.h"
57 #include "AliAODMCHeader.h"
58 #include "AliESDtrack.h"
60 #include "THnSparse.h"
62 #include "AliESDtrackCuts.h"
63 #include "AliRDHFCuts.h"
64 #include "AliRDHFCutsD0toKpi.h"
65 #include "AliRDHFCutsDplustoKpipi.h"
66 #include "AliRDHFCutsDStartoKpipi.h"
67 #include "AliRDHFCutsDstoKKpi.h"
68 #include "AliRDHFCutsLctopKpi.h"
69 #include "AliRDHFCutsD0toKpipipi.h"
70 #include "AliRDHFCutsLctoV0.h"
71 #include "AliCFVertexingHF2Prong.h"
72 #include "AliCFVertexingHF3Prong.h"
73 #include "AliCFVertexingHFCascade.h"
74 #include "AliCFVertexingHFLctoV0bachelor.h"
75 #include "AliCFVertexingHF.h"
76 #include "AliVertexingHFUtils.h"
77 #include "AliAnalysisDataSlot.h"
78 #include "AliAnalysisDataContainer.h"
79 #include "AliPIDResponse.h"
81 //__________________________________________________________________________
82 AliCFTaskVertexingHF::AliCFTaskVertexingHF() :
85 fHistEventsProcessed(0x0),
93 fCountRecoITSClusters(0),
98 fFillFromGenerated(kFALSE),
100 fAcceptanceUnf(kTRUE),
104 fUseFlatPtWeight(kFALSE),
106 fUseNchWeight(kFALSE),
107 fUseTrackletsWeight(kFALSE),
112 fCentralitySelection(kTRUE),
114 fRejectIfNoQuark(kTRUE),
115 fUseMCVertex(kFALSE),
118 fConfiguration(kCheetah), // by default, setting the fast configuration
123 fLctoV0bachelorOption(1),
124 fGenLctoV0bachelorOption(0),
125 fUseSelectionBit(kTRUE),
127 fMultiplicityEstimator(kNtrk10),
134 //___________________________________________________________________________
135 AliCFTaskVertexingHF::AliCFTaskVertexingHF(const Char_t* name, AliRDHFCuts* cuts, TF1* func) :
136 AliAnalysisTaskSE(name),
138 fHistEventsProcessed(0x0),
146 fCountRecoITSClusters(0),
151 fFillFromGenerated(kFALSE),
152 fOriginDselection(0),
153 fAcceptanceUnf(kTRUE),
157 fUseFlatPtWeight(kFALSE),
159 fUseNchWeight(kFALSE),
160 fUseTrackletsWeight(kFALSE),
165 fCentralitySelection(kTRUE),
167 fRejectIfNoQuark(kTRUE),
168 fUseMCVertex(kFALSE),
171 fConfiguration(kCheetah), // by default, setting the fast configuration
176 fLctoV0bachelorOption(1),
177 fGenLctoV0bachelorOption(0),
178 fUseSelectionBit(kTRUE),
180 fMultiplicityEstimator(kNtrk10),
184 // Constructor. Initialization of Inputs and Outputs
187 DefineInput(0) and DefineOutput(0)
188 are taken care of by AliAnalysisTaskSE constructor
190 DefineOutput(1,TH1I::Class());
191 DefineOutput(2,AliCFContainer::Class());
192 DefineOutput(3,THnSparseD::Class());
193 DefineOutput(4,AliRDHFCuts::Class());
198 //___________________________________________________________________________
199 AliCFTaskVertexingHF& AliCFTaskVertexingHF::operator=(const AliCFTaskVertexingHF& c)
202 // Assignment operator
205 AliAnalysisTaskSE::operator=(c) ;
206 fCFManager = c.fCFManager;
207 fHistEventsProcessed = c.fHistEventsProcessed;
209 fFuncWeight = c.fFuncWeight;
210 fHistoMeasNch = c.fHistoMeasNch;
211 fHistoMCNch = c.fHistoMCNch;
216 //___________________________________________________________________________
217 AliCFTaskVertexingHF::AliCFTaskVertexingHF(const AliCFTaskVertexingHF& c) :
218 AliAnalysisTaskSE(c),
219 fCFManager(c.fCFManager),
220 fHistEventsProcessed(c.fHistEventsProcessed),
221 fCorrelation(c.fCorrelation),
222 fCountMC(c.fCountMC),
223 fCountAcc(c.fCountAcc),
224 fCountVertex(c.fCountVertex),
225 fCountRefit(c.fCountRefit),
226 fCountReco(c.fCountReco),
227 fCountRecoAcc(c.fCountRecoAcc),
228 fCountRecoITSClusters(c.fCountRecoITSClusters),
229 fCountRecoPPR(c.fCountRecoPPR),
230 fCountRecoPID(c.fCountRecoPID),
232 fDecayChannel(c.fDecayChannel),
233 fFillFromGenerated(c.fFillFromGenerated),
234 fOriginDselection(c.fOriginDselection),
235 fAcceptanceUnf(c.fAcceptanceUnf),
237 fUseWeight(c.fUseWeight),
239 fUseFlatPtWeight(c.fUseFlatPtWeight),
240 fUseZWeight(c.fUseZWeight),
241 fUseNchWeight(c.fUseNchWeight),
242 fUseTrackletsWeight(c.fUseTrackletsWeight),
244 fPartName(c.fPartName),
245 fDauNames(c.fDauNames),
247 fCentralitySelection(c.fCentralitySelection),
248 fFakeSelection(c.fFakeSelection),
249 fRejectIfNoQuark(c.fRejectIfNoQuark),
250 fUseMCVertex(c.fUseMCVertex),
251 fDsOption(c.fDsOption),
252 fGenDsOption(c.fGenDsOption),
253 fConfiguration(c.fConfiguration),
254 fFuncWeight(c.fFuncWeight),
255 fHistoMeasNch(c.fHistoMeasNch),
256 fHistoMCNch(c.fHistoMCNch),
257 fResonantDecay(c.fResonantDecay),
258 fLctoV0bachelorOption(c.fLctoV0bachelorOption),
259 fGenLctoV0bachelorOption(c.fGenLctoV0bachelorOption),
260 fUseSelectionBit(c.fUseSelectionBit),
261 fPDGcode(c.fPDGcode),
262 fMultiplicityEstimator(c.fMultiplicityEstimator),
263 fIsPPData(c.fIsPPData)
270 //___________________________________________________________________________
271 AliCFTaskVertexingHF::~AliCFTaskVertexingHF()
276 if (fCFManager) delete fCFManager ;
277 if (fHistEventsProcessed) delete fHistEventsProcessed ;
278 if (fCorrelation) delete fCorrelation ;
279 if (fCuts) delete fCuts;
280 if (fFuncWeight) delete fFuncWeight;
281 if (fHistoMeasNch) delete fHistoMeasNch;
282 if (fHistoMCNch) delete fHistoMCNch;
285 //_________________________________________________________________________-
286 void AliCFTaskVertexingHF::Init()
292 if (fDebug>1) printf("AliCFTaskVertexingHF::Init()");
293 if(fUseWeight && fUseZWeight) { AliFatal("Can not use at the same time pt and z-vtx weights, please choose"); return; }
294 if(fUseWeight && fUseNchWeight) { AliFatal("Can not use at the same time pt and Nch weights, please choose"); return; }
295 if(fUseNchWeight && !fHistoMCNch) { AliFatal("Need to pass the MC Nch distribution to use Nch weights"); return; }
296 if(fUseNchWeight) CreateMeasuredNchHisto();
298 AliRDHFCuts *copyfCuts = 0x0;
300 AliFatal("No cuts defined - Exiting...");
304 switch (fDecayChannel){
307 copyfCuts = new AliRDHFCutsD0toKpi(*(static_cast<AliRDHFCutsD0toKpi*>(fCuts)));
308 switch (fConfiguration) {
309 case kSnail: // slow configuration: all variables in
312 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
322 copyfCuts = new AliRDHFCutsDStartoKpipi(*(static_cast<AliRDHFCutsDStartoKpipi*>(fCuts)));
323 switch (fConfiguration) {
324 case kSnail: // slow configuration: all variables in
327 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
337 copyfCuts = new AliRDHFCutsLctoV0(*(static_cast<AliRDHFCutsLctoV0*>(fCuts)));
338 switch (fConfiguration) {
339 case kSnail: // slow configuration: all variables in
342 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
347 fDauNames="V0+bachelor";
352 copyfCuts = new AliRDHFCutsDplustoKpipi(*(static_cast<AliRDHFCutsDplustoKpipi*>(fCuts)));
353 switch (fConfiguration) {
354 case kSnail: // slow configuration: all variables in
357 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
367 copyfCuts = new AliRDHFCutsLctopKpi(*(static_cast<AliRDHFCutsLctopKpi*>(fCuts)));
368 switch (fConfiguration) {
369 case kSnail: // slow configuration: all variables in
372 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
382 copyfCuts = new AliRDHFCutsDstoKKpi(*(static_cast<AliRDHFCutsDstoKKpi*>(fCuts)));
383 switch (fConfiguration) {
384 case kSnail: // slow configuration: all variables in
387 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
397 copyfCuts = new AliRDHFCutsD0toKpipipi(*(static_cast<AliRDHFCutsD0toKpipipi*>(fCuts)));
398 switch (fConfiguration) {
399 case kSnail: // slow configuration: all variables in
402 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
407 fDauNames="K+pi+pi+pi";
411 AliFatal("The decay channel MUST be defined according to AliCFVertexing::DecayChannel - Exiting...");
415 const char* nameoutput=GetOutputSlot(4)->GetContainer()->GetName();
417 copyfCuts->SetName(nameoutput);
420 PostData(4, copyfCuts);
423 AliFatal("Failing initializing AliRDHFCuts object - Exiting...");
429 //_________________________________________________
430 void AliCFTaskVertexingHF::UserExec(Option_t *)
433 // Main loop function
436 PostData(1,fHistEventsProcessed) ;
437 PostData(2,fCFManager->GetParticleContainer()) ;
438 PostData(3,fCorrelation) ;
440 if (fFillFromGenerated){
441 AliWarning("Flag to fill container with generated value ON ---> dca, d0pi, d0K, d0xd0, cosPointingAngle will be set as dummy!");
445 Error("UserExec","NO EVENT FOUND!");
449 AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
451 TClonesArray *arrayBranch=0;
453 if(!aodEvent && AODEvent() && IsStandardAOD()) {
454 // In case there is an AOD handler writing a standard AOD, use the AOD
455 // event in memory rather than the input (ESD) event.
456 aodEvent = dynamic_cast<AliAODEvent*> (AODEvent());
457 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
458 // have to taken from the AOD event hold by the AliAODExtension
459 AliAODHandler* aodHandler = (AliAODHandler*)
460 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
461 if(aodHandler->GetExtensions()) {
462 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
463 AliAODEvent *aodFromExt = ext->GetAOD();
465 switch (fDecayChannel){
467 arrayBranch=(TClonesArray*)aodFromExt->GetList()->FindObject("D0toKpi");
471 arrayBranch=(TClonesArray*)aodFromExt->GetList()->FindObject("Dstar");
475 arrayBranch=(TClonesArray*)aodFromExt->GetList()->FindObject("CascadesHF");
481 arrayBranch=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong");
485 arrayBranch=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm4Prong");
494 switch (fDecayChannel){
496 arrayBranch=(TClonesArray*)aodEvent->GetList()->FindObject("D0toKpi");
500 arrayBranch=(TClonesArray*)aodEvent->GetList()->FindObject("Dstar");
504 arrayBranch=(TClonesArray*)aodEvent->GetList()->FindObject("CascadesHF");
510 arrayBranch=(TClonesArray*)aodEvent->GetList()->FindObject("Charm3Prong");
514 arrayBranch=(TClonesArray*)aodEvent->GetList()->FindObject("Charm4Prong");
522 AliAODVertex *aodVtx = (AliAODVertex*)aodEvent->GetPrimaryVertex();
526 AliError("Could not find array of HF vertices");
532 fCFManager->SetRecEventInfo(aodEvent);
533 fCFManager->SetMCEventInfo(aodEvent);
535 //******** DEFINE number of variables of the container***** for now set at 13, in the future in the config macro.
537 //loop on the MC event
539 TClonesArray* mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
541 AliError("Could not find Monte-Carlo in AOD");
546 Int_t icountReco = 0;
547 Int_t icountVertex = 0;
548 Int_t icountRefit = 0;
549 Int_t icountRecoAcc = 0;
550 Int_t icountRecoITSClusters = 0;
551 Int_t icountRecoPPR = 0;
552 Int_t icountRecoPID = 0;
555 AliAODMCHeader *mcHeader = dynamic_cast<AliAODMCHeader*>(aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
557 AliError("Could not find MC Header in AOD");
561 fHistEventsProcessed->Fill(0.5);
563 Double_t* containerInput = new Double_t[fNvar];
564 Double_t* containerInputMC = new Double_t[fNvar];
567 AliCFVertexingHF* cfVtxHF=0x0;
568 switch (fDecayChannel){
570 cfVtxHF = new AliCFVertexingHF2Prong(mcArray, fOriginDselection);
574 cfVtxHF = new AliCFVertexingHFCascade(mcArray, fOriginDselection);
578 cfVtxHF = new AliCFVertexingHFLctoV0bachelor(mcArray, fOriginDselection,fGenLctoV0bachelorOption); // Lc -> K0S+proton
584 cfVtxHF = new AliCFVertexingHF3Prong(mcArray, fOriginDselection, fDecayChannel);
585 if(fDecayChannel==33){
586 ((AliCFVertexingHF3Prong*)cfVtxHF)->SetGeneratedDsOption(fGenDsOption);
591 cfVtxHF = new AliCFVertexingHF3Prong(mcArray, fOriginDselection, fDecayChannel,fResonantDecay);
594 //cfVtxHF = new AliCFVertexingHF4Prong(mcArray, originDselection); // not there yet
601 AliError("No AliCFVertexingHF initialized");
602 delete[] containerInput;
603 delete[] containerInputMC;
607 Double_t zPrimVertex = aodVtx ->GetZ();
608 Double_t zMCVertex = mcHeader->GetVtxZ();
609 Int_t runnumber = aodEvent->GetRunNumber();
611 if(fUseZWeight) fWeight *= GetZWeight(zMCVertex,runnumber);
613 Int_t nChargedMCPhysicalPrimary=AliVertexingHFUtils::GetGeneratedPhysicalPrimariesInEtaRange(mcArray,-1.0,1.0);
614 Int_t nTracklets = AliVertexingHFUtils::GetNumberOfTrackletsInEtaRange(aodEvent,-1.,1.);
615 if(!fUseTrackletsWeight) fWeight *= GetNchWeight(nChargedMCPhysicalPrimary);
616 else fWeight *= GetNchWeight(nTracklets);
617 AliDebug(2,Form("Using Nch weights, Mult=%d Weight=%f\n",nChargedMCPhysicalPrimary,fWeight));
620 if (TMath::Abs(zMCVertex) > fCuts->GetMaxVtxZ()){
621 AliDebug(3,Form("z coordinate of MC vertex = %f, it was required to be within [-%f, +%f], skipping event", zMCVertex, fCuts->GetMaxVtxZ(), fCuts->GetMaxVtxZ()));
622 delete[] containerInput;
623 delete[] containerInputMC;
627 if(aodEvent->GetTriggerMask()==0 &&
628 (runnumber>=195344 && runnumber<=195677)){
629 AliDebug(3,"Event rejected because of null trigger mask");
630 delete[] containerInput;
631 delete[] containerInputMC;
635 AliESDtrackCuts** trackCuts = new AliESDtrackCuts*[cfVtxHF->GetNProngs()];
636 if (fDecayChannel == 21){
637 // for the D*, setting the third element of the array of the track cuts to those for the soft pion
638 for (Int_t iProng = 0; iProng<cfVtxHF->GetNProngs()-1; iProng++){
639 trackCuts[iProng]=fCuts->GetTrackCuts();
641 trackCuts[2] = fCuts->GetTrackCutsSoftPi();
643 else if (fDecayChannel == 22) {
644 // for the Lc->V0+bachelor, setting the second and third elements of the array of the track cuts to those for the V0 daughters
645 trackCuts[0]=fCuts->GetTrackCuts();
646 trackCuts[1]=fCuts->GetTrackCutsV0daughters();
647 trackCuts[2]=fCuts->GetTrackCutsV0daughters();
650 for (Int_t iProng = 0; iProng<cfVtxHF->GetNProngs(); iProng++){
651 trackCuts[iProng]=fCuts->GetTrackCuts();
655 //General settings: vertex, feed down and fill reco container with generated values.
656 cfVtxHF->SetRecoPrimVertex(zPrimVertex);
657 cfVtxHF->SetMCPrimaryVertex(zMCVertex);
658 cfVtxHF->SetFillFromGenerated(fFillFromGenerated);
659 cfVtxHF->SetNVar(fNvar);
660 cfVtxHF->SetFakeSelection(fFakeSelection);
661 cfVtxHF->SetRejectCandidateIfNotFromQuark(fRejectIfNoQuark);
662 cfVtxHF->SetConfiguration(fConfiguration);
664 // switch-off the trigger class selection (doesn't work for MC)
665 fCuts->SetTriggerClass("");
667 // MC vertex, to be used, in case, for pp
668 if (fUseMCVertex) fCuts->SetUseMCVertex();
670 if (fCentralitySelection){ // keep only the requested centrality
671 if(fCuts->IsEventSelectedInCentrality(aodEvent)!=0) {
672 delete[] containerInput;
673 delete[] containerInputMC;
677 } else { // keep all centralities
678 fCuts->SetMinCentrality(0.);
679 fCuts->SetMaxCentrality(100.);
682 Float_t centValue = 0.;
683 if(!fIsPPData) centValue = fCuts->GetCentrality(aodEvent);
684 cfVtxHF->SetCentralityValue(centValue);
686 // number of tracklets - multiplicity estimator
687 Double_t countTr10 = (Double_t)(AliVertexingHFUtils::GetNumberOfTrackletsInEtaRange(aodEvent,-1.,1.)); // casted to double because the CF is filled with doubles
689 Double_t countTr16 = (Double_t)(AliVertexingHFUtils::GetNumberOfTrackletsInEtaRange(aodEvent,-1.6,1.6));
690 Double_t vzeroMult=0;
691 AliAODVZERO *vzeroAOD = (AliAODVZERO*)aodEvent->GetVZEROData();
692 if(vzeroAOD) vzeroMult = vzeroAOD->GetMTotV0A() + vzeroAOD->GetMTotV0C();
694 Double_t multiplicity = countTr10;
695 if(fMultiplicityEstimator==kNtrk10to16) { multiplicity = countTr16 - countTr10; }
696 if(fMultiplicityEstimator==kVZERO) { multiplicity = vzeroMult; }
699 cfVtxHF->SetMultiplicity(multiplicity);
701 // printf("Multiplicity estimator %d, value %2.2f\n",fMultiplicityEstimator,multiplicity);
703 for (Int_t iPart=0; iPart<mcArray->GetEntriesFast(); iPart++) {
704 AliAODMCParticle* mcPart = dynamic_cast<AliAODMCParticle*>(mcArray->At(iPart));
706 AliError("Failed casting particle from MC array!, Skipping particle");
711 cquarks += cfVtxHF->MCcquarkCounting(mcPart);
713 // check the MC-level cuts, must be the desidered particle
714 if (!fCFManager->CheckParticleCuts(0, mcPart)) {
715 AliDebug(2,"Check the MC-level cuts - not desidered particle");
716 continue; // 0 stands for MC level
718 cfVtxHF->SetMCCandidateParam(iPart);
721 if (!(cfVtxHF->SetLabelArray())){
722 AliDebug(2,Form("Impossible to set the label array (decaychannel = %d)",fDecayChannel));
726 //check the candiate family at MC level
727 if (!(cfVtxHF->CheckMCPartFamily(mcPart, mcArray))) {
728 AliDebug(2,Form("Check on the family wrong!!! (decaychannel = %d)",fDecayChannel));
732 AliDebug(2,Form("Check on the family OK!!! (decaychannel = %d)",fDecayChannel));
735 //Fill the MC container
736 Bool_t mcContainerFilled = cfVtxHF -> FillMCContainer(containerInputMC);
737 AliDebug(2,Form("mcContainerFilled = %d)",mcContainerFilled));
738 if (mcContainerFilled) {
740 if (fFuncWeight){ // using user-defined function
741 AliDebug(2,"Using function");
742 fWeight = fFuncWeight->Eval(containerInputMC[0]);
745 AliDebug(2,"Using FONLL");
746 fWeight = GetWeight(containerInputMC[0]);
748 AliDebug(2,Form("pt = %f, weight = %f",containerInputMC[0], fWeight));
750 if (!fCuts->IsInFiducialAcceptance(containerInputMC[0],containerInputMC[1])) continue;
751 //MC Limited Acceptance
752 if (TMath::Abs(containerInputMC[1]) < 0.5) {
753 fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepGeneratedLimAcc, fWeight);
754 AliDebug(3,"MC Lim Acc container filled\n");
758 fCFManager->GetParticleContainer()->Fill(containerInputMC, kStepGenerated, fWeight);
760 AliDebug(3,"MC cointainer filled \n");
763 // check the MC-Acceptance level cuts
764 // since standard CF functions are not applicable, using Kine Cuts on daughters
765 Bool_t mcAccepStep = cfVtxHF-> MCAcceptanceStep();
767 fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepAcceptance, fWeight);
768 AliDebug(3,"MC acceptance cut passed\n");
772 if (fCuts->IsEventSelected(aodEvent)){
773 // filling the container if the vertex is ok
774 fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepVertex, fWeight) ;
775 AliDebug(3,"Vertex cut passed and container filled\n");
778 //mc Refit requirement
779 Bool_t mcRefitStep = cfVtxHF->MCRefitStep(aodEvent, &trackCuts[0]);
781 fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepRefit, fWeight);
782 AliDebug(3,"MC Refit cut passed and container filled\n");
786 AliDebug(3,"MC Refit cut not passed\n");
791 AliDebug (3, "MC vertex step not passed\n");
796 AliDebug (3, "MC in acceptance step not passed\n");
801 AliDebug (3, "MC container not filled\n");
805 if (cquarks<2) AliDebug(2,Form("Event with %d c-quarks", cquarks));
806 AliDebug(2,Form("Found %i MC particles that are %s!!",icountMC,fPartName.Data()));
807 AliDebug(2,Form("Found %i MC particles that are %s and satisfy Acc cuts!!",icountAcc,fPartName.Data()));
808 AliDebug(2,Form("Found %i MC particles that are %s and satisfy Vertex cuts!!",icountVertex,fPartName.Data()));
809 AliDebug(2,Form("Found %i MC particles that are %s and satisfy Refit cuts!!",icountRefit,fPartName.Data()));
811 // Now go to rec level
812 fCountMC += icountMC;
813 fCountAcc += icountAcc;
814 fCountVertex+= icountVertex;
815 fCountRefit+= icountRefit;
817 AliDebug(2,Form("Found %d vertices for decay channel %d",arrayBranch->GetEntriesFast(),fDecayChannel));
819 for(Int_t iCandid = 0; iCandid<arrayBranch->GetEntriesFast();iCandid++){
820 AliAODRecoDecayHF* charmCandidate=0x0;
821 switch (fDecayChannel){
823 charmCandidate = (AliAODRecoDecayHF2Prong*)arrayBranch->At(iCandid);
828 charmCandidate = (AliAODRecoCascadeHF*)arrayBranch->At(iCandid);
834 charmCandidate = (AliAODRecoDecayHF3Prong*)arrayBranch->At(iCandid);
838 charmCandidate = (AliAODRecoDecayHF4Prong*)arrayBranch->At(iCandid);
845 Bool_t unsetvtx=kFALSE;
846 if(!charmCandidate->GetOwnPrimaryVtx()) {
847 charmCandidate->SetOwnPrimaryVtx(aodVtx); // needed to compute all variables
851 Bool_t signAssociation = cfVtxHF->SetRecoCandidateParam((AliAODRecoDecayHF*)charmCandidate);
852 if (!signAssociation){
853 charmCandidate = 0x0;
857 Int_t isPartOrAntipart = cfVtxHF->CheckReflexion(fSign);
858 if (isPartOrAntipart == 0){
859 AliDebug(2, Form("The candidate pdg code doesn't match the requirement set in the task (fSign = %d)",fSign));
863 AliDebug(3,Form("iCandid=%d - signAssociation=%d, isPartOrAntipart=%d",iCandid, signAssociation, isPartOrAntipart));
865 Bool_t recoContFilled = cfVtxHF->FillRecoContainer(containerInput);
868 // weight according to pt
870 if (fFuncWeight){ // using user-defined function
871 AliDebug(2, "Using function");
872 fWeight = fFuncWeight->Eval(containerInput[0]);
875 AliDebug(2, "Using FONLL");
876 fWeight = GetWeight(containerInput[0]);
878 AliDebug(2, Form("pt = %f, weight = %f",containerInput[0], fWeight));
881 if (!fCuts->IsInFiducialAcceptance(containerInput[0],containerInput[1])) continue;
884 Bool_t recoStep = cfVtxHF->RecoStep();
885 Bool_t vtxCheck = fCuts->IsEventSelected(aodEvent);
888 // Selection on the filtering bit
889 Bool_t isBitSelected = kTRUE;
890 if(fDecayChannel==2) {
891 if(fUseSelectionBit && !charmCandidate->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts)) isBitSelected = kFALSE;
892 }else if(fDecayChannel==31){
893 if(fUseSelectionBit && !charmCandidate->HasSelectionBit(AliRDHFCuts::kDplusCuts)) isBitSelected = kFALSE;
894 }else if(fDecayChannel==33){
895 if(fUseSelectionBit && !charmCandidate->HasSelectionBit(AliRDHFCuts::kDsCuts)) isBitSelected = kFALSE;
897 if(!isBitSelected) continue;
901 if (recoStep && recoContFilled && vtxCheck){
902 fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructed, fWeight) ;
904 AliDebug(3,"Reco step passed and container filled\n");
906 //Reco in the acceptance -- take care of UNFOLDING!!!!
907 Bool_t recoAcceptanceStep = cfVtxHF->RecoAcceptStep(&trackCuts[0]);
908 if (recoAcceptanceStep) {
909 fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoAcceptance, fWeight) ;
911 AliDebug(3,"Reco acceptance cut passed and container filled\n");
914 Double_t fill[4]; //fill response matrix
915 Bool_t bUnfolding = cfVtxHF -> FillUnfoldingMatrix(fPDGcode,fill);
916 if (bUnfolding) fCorrelation->Fill(fill);
919 //Number of ITS cluster requirements
920 Int_t recoITSnCluster = fCuts->IsSelected(charmCandidate, AliRDHFCuts::kTracks);
921 if (recoITSnCluster){
922 fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoITSClusters, fWeight) ;
923 icountRecoITSClusters++;
924 AliDebug(3,"Reco n ITS cluster cut passed and container filled\n");
926 Bool_t iscutsusingpid = fCuts->GetIsUsePID();
927 Int_t recoAnalysisCuts = -1, recoPidSelection = -1;
928 fCuts->SetUsePID(kFALSE);
929 recoAnalysisCuts = fCuts->IsSelected(charmCandidate, AliRDHFCuts::kCandidate, aodEvent);
931 if (fDecayChannel==33){ // Ds case, where more possibilities are considered
932 Bool_t keepDs=ProcessDs(recoAnalysisCuts);
933 if(keepDs) recoAnalysisCuts=3;
935 else if (fDecayChannel==22){ // Lc->V0+bachelor case, where more possibilities are considered
936 Bool_t keepLctoV0bachelor=ProcessLctoV0Bachelor(recoAnalysisCuts);
937 if (keepLctoV0bachelor) recoAnalysisCuts=3;
942 fCuts->SetUsePID(iscutsusingpid); //restoring usage of the PID from the cuts object
943 Bool_t tempAn=(recoAnalysisCuts == 3 || recoAnalysisCuts == isPartOrAntipart);
944 if (fDecayChannel == 32) tempAn=(recoAnalysisCuts >0 || recoAnalysisCuts == isPartOrAntipart);
947 fCFManager->GetParticleContainer()->Fill(containerInput, kStepRecoPPR, fWeight);
949 AliDebug(3,"Reco Analysis cuts passed and container filled \n");
951 //recoPidSelection = fCuts->IsSelected(charmCandidate, AliRDHFCuts::kPID);
952 //if((fCuts->CombineSelectionLevels(3,recoAnalysisCuts,recoPidSelection)==isPartOrAntipart)||(fCuts->CombineSelectionLevels(3,recoAnalysisCuts,recoPidSelection)==3)){
953 recoPidSelection = fCuts->IsSelected(charmCandidate, AliRDHFCuts::kCandidate, aodEvent);
955 if (fDecayChannel==33){ // Ds case, where more possibilities are considered
956 Bool_t keepDs=ProcessDs(recoPidSelection);
957 if(keepDs) recoPidSelection=3;
958 } else if (fDecayChannel==22){ // Lc->V0+bachelor case, where more possibilities are considered
959 Bool_t keepLctoV0bachelor=ProcessLctoV0Bachelor(recoPidSelection);
960 if (keepLctoV0bachelor) recoPidSelection=3;
963 Bool_t tempPid=(recoPidSelection == 3 || recoPidSelection == isPartOrAntipart);
964 if (fDecayChannel == 32) tempPid=(recoPidSelection >0 || recoPidSelection == isPartOrAntipart);
967 fCFManager->GetParticleContainer()->Fill(containerInput, kStepRecoPID, fWeight);
969 AliDebug(3,"Reco PID cuts passed and container filled \n");
971 Double_t fill[4]; //fill response matrix
972 Bool_t bUnfolding = cfVtxHF -> FillUnfoldingMatrix(fPDGcode,fill);
973 if (bUnfolding) fCorrelation->Fill(fill);
977 AliDebug(3, "Analysis Cuts step not passed \n");
982 AliDebug(3, "PID selection not passed \n");
987 AliDebug(3, "Number of ITS cluster step not passed\n");
992 AliDebug(3, "Reco acceptance step not passed\n");
997 AliDebug(3, "Reco step not passed\n");
1002 if(unsetvtx) charmCandidate->UnsetOwnPrimaryVtx();
1003 } // end loop on candidate
1005 fCountReco+= icountReco;
1006 fCountRecoAcc+= icountRecoAcc;
1007 fCountRecoITSClusters+= icountRecoITSClusters;
1008 fCountRecoPPR+= icountRecoPPR;
1009 fCountRecoPID+= icountRecoPID;
1011 fHistEventsProcessed->Fill(1.5);
1013 delete[] containerInput;
1014 delete[] containerInputMC;
1017 // for (Int_t i=0; i<cfVtxHF->GetNProngs(); i++){
1018 // delete [] trackCuts[i];
1020 delete [] trackCuts;
1026 //___________________________________________________________________________
1027 void AliCFTaskVertexingHF::Terminate(Option_t*)
1029 // The Terminate() function is the last function to be called during
1030 // a query. It always runs on the client, it can be used to present
1031 // the results graphically or save the results to file.
1033 AliAnalysisTaskSE::Terminate();
1035 AliInfo(Form("Found %i MC particles that are %s in MC, in %d events",fCountMC,fPartName.Data(),fEvents));
1036 AliInfo(Form("Found %i MC particles that are %s in MC and satisfy Acc cuts, in %d events",fCountAcc,fPartName.Data(),fEvents));
1037 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));
1038 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));
1039 AliInfo(Form("Found %i reco %s that are decaying in %s, in %d events",fCountReco,fPartName.Data(),fDauNames.Data(),fEvents));
1040 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));
1041 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));
1042 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));
1043 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));
1045 // draw some example plots....
1046 AliCFContainer *cont= dynamic_cast<AliCFContainer*> (GetOutputData(2));
1048 printf("CONTAINER NOT FOUND\n");
1051 // projecting the containers to obtain histograms
1052 // first argument = variable, second argument = step
1054 TH1D** h = new TH1D*[3];
1055 Int_t nvarToPlot = 0;
1056 if (fConfiguration == kSnail){
1057 //h = new TH1D[3][12];
1058 for (Int_t ih = 0; ih<3; ih++){
1059 if(fDecayChannel==22){
1064 h[ih] = new TH1D[nvarToPlot];
1066 for(Int_t iC=1;iC<nvarToPlot; iC++){
1068 h[0][iC] = *(cont->ShowProjection(iC,0));
1069 // MC-Acceptance level
1070 h[1][iC] = *(cont->ShowProjection(iC,1));
1072 h[2][iC] = *(cont->ShowProjection(iC,4));
1076 //h = new TH1D[3][12];
1078 for (Int_t ih = 0; ih<3; ih++){
1079 h[ih] = new TH1D[nvarToPlot];
1081 for(Int_t iC=0;iC<nvarToPlot; iC++){
1083 h[0][iC] = *(cont->ShowProjection(iC,0));
1084 // MC-Acceptance level
1085 h[1][iC] = *(cont->ShowProjection(iC,1));
1087 h[2][iC] = *(cont->ShowProjection(iC,4));
1091 //Int_t nvarToPlot = 0;
1092 if (fConfiguration == kSnail){
1093 if(fDecayChannel==31){
1095 titles = new TString[nvarToPlot];
1096 titles[0]="pT_Dplus (GeV/c)";
1097 titles[1]="rapidity";
1098 titles[2]="phi (rad)";
1099 titles[3]="cT (#mum)";
1100 titles[4]="cosPointingAngle";
1101 titles[5]="pT_1 (GeV/c)";
1102 titles[6]="pT_2 (GeV/c)";
1103 titles[7]="pT_3 (GeV/c)";
1104 titles[8]="d0_1 (#mum)";
1105 titles[9]="d0_2 (#mum)";
1106 titles[10]="d0_3 (#mum)";
1107 titles[11]="zVertex (cm)";
1108 } else if (fDecayChannel==22) {
1110 titles = new TString[nvarToPlot];
1111 titles[0]="pT_Lc (GeV/c)";
1112 titles[1]="rapidity";
1113 titles[2]="phi (rad)";
1114 titles[3]="cosPAV0";
1115 titles[4]="onTheFlyStatusV0";
1116 titles[5]="centrality";
1118 titles[7]="multiplicity";
1119 titles[8]="pT_bachelor (GeV/c)";
1120 titles[9]="pT_V0pos (GeV/c)";
1121 titles[10]="pT_V0neg (GeV/c)";
1122 titles[11]="invMassV0 (GeV/c2)";
1123 titles[12]="dcaV0 (nSigma)";
1124 titles[13]="c#tauV0 (#mum)";
1125 titles[14]="c#tau (#mum)";
1129 titles = new TString[nvarToPlot];
1130 titles[0]="pT_D0 (GeV/c)";
1131 titles[1]="rapidity";
1132 titles[2]="cosThetaStar";
1133 titles[3]="pT_pi (GeV/c)";
1134 titles[4]="pT_K (Gev/c)";
1135 titles[5]="cT (#mum)";
1136 titles[6]="dca (#mum)";
1137 titles[7]="d0_pi (#mum)";
1138 titles[8]="d0_K (#mum)";
1139 titles[9]="d0xd0 (#mum^2)";
1140 titles[10]="cosPointingAngle";
1141 titles[11]="phi (rad)";
1146 titles = new TString[nvarToPlot];
1147 if (fDecayChannel==22) {
1148 titles[0]="pT_candidate (GeV/c)";
1149 titles[1]="rapidity";
1150 titles[2]="phi (rad)";
1151 titles[3]="cosPAV0";
1152 titles[4]="onTheFlyStatusV0";
1153 titles[5]="centrality";
1155 titles[7]="multiplicity";
1157 titles[0]="pT_candidate (GeV/c)";
1158 titles[1]="rapidity";
1159 titles[2]="cT (#mum)";
1161 titles[4]="z_{vtx}";
1162 titles[5]="centrality";
1164 titles[7]="multiplicity";
1168 Int_t markers[16]={20,24,21,25,27,28,
1171 Int_t colors[3]={2,8,4};
1172 for(Int_t iC=0;iC<nvarToPlot; iC++){
1173 for(Int_t iStep=0;iStep<3;iStep++){
1174 h[iStep][iC].SetTitle(titles[iC].Data());
1175 h[iStep][iC].GetXaxis()->SetTitle(titles[iC].Data());
1176 Double_t maxh=h[iStep][iC].GetMaximum();
1177 h[iStep][iC].GetYaxis()->SetRangeUser(0,maxh*1.2);
1178 h[iStep][iC].SetMarkerStyle(markers[iC]);
1179 h[iStep][iC].SetMarkerColor(colors[iStep]);
1183 gStyle->SetCanvasColor(0);
1184 gStyle->SetFrameFillColor(0);
1185 gStyle->SetTitleFillColor(0);
1186 gStyle->SetStatColor(0);
1188 // drawing in 2 separate canvas for a matter of clearity
1189 TCanvas * c1 =new TCanvas(Form("c1New_%d",fDecayChannel),"Vars 0, 1, 2, 3",1100,1200);
1192 for(Int_t iVar=0; iVar<4; iVar++){
1194 h[0][iVar].DrawCopy("p");
1196 h[1][iVar].DrawCopy("p");
1198 h[2][iVar].DrawCopy("p");
1201 TCanvas * c2 =new TCanvas(Form("c2New_%d",fDecayChannel),"Vars 4, 5, 6, 7",1100,1200);
1204 for(Int_t iVar=4; iVar<8; iVar++){
1206 h[0][iVar].DrawCopy("p");
1208 h[1][iVar].DrawCopy("p");
1210 h[2][iVar].DrawCopy("p");
1213 if (fConfiguration == kSnail){
1214 TCanvas * c3 =new TCanvas(Form("c3New_%d",fDecayChannel),"Vars 8, 9, 10, 11",1100,1200);
1217 for(Int_t iVar=8; iVar<12; iVar++){
1219 h[0][iVar].DrawCopy("p");
1221 h[1][iVar].DrawCopy("p");
1223 h[2][iVar].DrawCopy("p");
1225 if (fDecayChannel==22) {
1226 TCanvas * c4 =new TCanvas(Form("c4New_%d",fDecayChannel),"Vars 12, 13, 14, 15",1100,1200);
1229 for(Int_t iVar=12; iVar<16; iVar++){
1231 h[0][iVar].DrawCopy("p");
1233 h[1][iVar].DrawCopy("p");
1235 h[2][iVar].DrawCopy("p");
1241 THnSparseD* hcorr = dynamic_cast<THnSparseD*> (GetOutputData(3));
1243 TH2D* corr1 = hcorr->Projection(0,2);
1244 TH2D* corr2 = hcorr->Projection(1,3);
1246 TCanvas * c7 =new TCanvas(Form("c7New_%d",fDecayChannel),"",800,400);
1249 corr1->DrawCopy("text");
1251 corr2->DrawCopy("text");
1253 TFile* file_projection = new TFile("CFtaskHFprojectionNew.root","RECREATE");
1258 for(Int_t iC=0;iC<nvarToPlot; iC++){
1259 for(Int_t iStep=0;iStep<3;iStep++){
1260 h[iStep][iC].Write(Form("Step%d_%s",iStep,titles[iC].Data()));
1263 file_projection->Close();
1264 for (Int_t ih = 0; ih<3; ih++) delete [] h[ih];
1270 //___________________________________________________________________________
1271 void AliCFTaskVertexingHF::UserCreateOutputObjects()
1273 //HERE ONE CAN CREATE OUTPUT OBJECTS, IN PARTICULAR IF THE OBJECT PARAMETERS DON'T NEED
1274 //TO BE SET BEFORE THE EXECUTION OF THE TASK
1276 Info("UserCreateOutputObjects","CreateOutputObjects of task %s\n", GetName());
1278 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
1279 AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
1280 AliPIDResponse *localPIDResponse = (AliPIDResponse*)inputHandler->GetPIDResponse();
1282 if (fCuts->GetIsUsePID() && fDecayChannel==22) {
1284 fCuts->GetPidHF()->SetPidResponse(localPIDResponse);
1285 fCuts->GetPidHF()->SetOldPid(kFALSE);
1286 AliRDHFCutsLctoV0* lcv0Cuts=dynamic_cast<AliRDHFCutsLctoV0*>(fCuts);
1288 lcv0Cuts->GetPidV0pos()->SetPidResponse(localPIDResponse);
1289 lcv0Cuts->GetPidV0neg()->SetPidResponse(localPIDResponse);
1290 lcv0Cuts->GetPidV0pos()->SetOldPid(kFALSE);
1291 lcv0Cuts->GetPidV0neg()->SetOldPid(kFALSE);
1297 const char* nameoutput=GetOutputSlot(1)->GetContainer()->GetName();
1298 fHistEventsProcessed = new TH1I(nameoutput,"",2,0,2) ;
1299 fHistEventsProcessed->GetXaxis()->SetBinLabel(1,"Events processed (all)");
1300 fHistEventsProcessed->GetXaxis()->SetBinLabel(2,"Events analyzed (after selection)");
1302 PostData(1,fHistEventsProcessed) ;
1303 PostData(2,fCFManager->GetParticleContainer()) ;
1304 PostData(3,fCorrelation) ;
1309 //_________________________________________________________________________
1310 void AliCFTaskVertexingHF::SetPtWeightsFromFONLL276overLHC12a17a(){
1311 // ad-hoc weight function from ratio of
1312 // pt spectra from FONLL 2.76 TeV and
1313 // pt spectra from MC production LHC12a17a (PYTHIA Perugia0 with pthard bins)
1314 if(fFuncWeight) delete fFuncWeight;
1315 fFuncWeight=new TF1("funcWeight","[0]+[1]*TMath::Exp(-[2]*x)",0.,50.);
1316 fFuncWeight->SetParameter(0,4.63891e-02);
1317 fFuncWeight->SetParameter(1,1.51674e+01);
1318 fFuncWeight->SetParameter(2,4.09941e-01);
1321 //_________________________________________________________________________
1322 void AliCFTaskVertexingHF::SetPtWeightsFromDataPbPb276overLHC12a17a(){
1323 // ad-hoc weight function from ratio of
1324 // D0 pt spectra in PbPb 2011 0-10% centrality and
1325 // pt spectra from MC production LHC12a17a (PYTHIA Perugia0 with pthard bins)
1326 if(fFuncWeight) delete fFuncWeight;
1327 fFuncWeight=new TF1("funcWeight","[0]+[1]/TMath::Power(x,[2])",0.05,50.);
1328 fFuncWeight->SetParameter(0,1.43116e-02);
1329 fFuncWeight->SetParameter(1,4.37758e+02);
1330 fFuncWeight->SetParameter(2,3.08583);
1334 //_________________________________________________________________________
1335 void AliCFTaskVertexingHF::SetPtWeightsFromFONLL276overLHC12a17b(){
1336 // weight function from the ratio of the LHC12a17b MC
1337 // and FONLL calculations for pp data
1338 if(fFuncWeight) delete fFuncWeight;
1339 fFuncWeight=new TF1("funcWeight","([0]*x)/TMath::Power([2],(1+TMath::Power([3],x/[1])))+[4]*TMath::Exp([5]+[6]*x)+[7]*TMath::Exp([8]*x)",0.15,50.);
1340 fFuncWeight->SetParameters(1.92381e+01, 5.05055e+00, 1.05314e+01, 2.5, 1.88214e-03, 3.44871e+00, -9.74325e-02, 1.97671e+00, -3.21278e-01);
1344 //_________________________________________________________________________
1345 void AliCFTaskVertexingHF::SetPtWeightsFromFONLL276andBAMPSoverLHC12a17b(){
1346 // weight function from the ratio of the LHC12a17b MC
1347 // and FONLL calculations for pp data
1348 // corrected by the BAMPS Raa calculation for 30-50% CC
1349 if(fFuncWeight) delete fFuncWeight;
1350 fFuncWeight=new TF1("funcWeight","([0]*x)/TMath::Power([2],(1+TMath::Power([3],x/[1])))+[4]*TMath::Exp([5]+[6]*x)+[7]*TMath::Exp([8]*x)",0.15,50.);
1351 fFuncWeight->SetParameters(6.10443e+00, 1.53487e+00, 1.99474e+00, 2.5, 5.51172e-03, 5.86590e+00, -5.46963e-01, 9.41201e-02, -1.64323e-01);
1355 //_________________________________________________________________________
1356 void AliCFTaskVertexingHF::SetPtWeightsFromFONLL5overLHC13d3(){
1357 // weight function from the ratio of the LHC12a17b MC
1358 // and FONLL calculations for pp data
1359 if(fFuncWeight) delete fFuncWeight;
1360 fFuncWeight=new TF1("funcWeight","([0]*x)/TMath::Power([2],(1+TMath::Power([3],x/[1])))+[4]*TMath::Exp([5]+[6]*x)+[7]*TMath::Exp([8]*x)",0.15,30.);
1361 fFuncWeight->SetParameters(2.94999e+00,3.47032e+00,2.81278e+00,2.5,1.93370e-02,3.86865e+00,-1.54113e-01,8.86944e-02,2.56267e-02);
1365 //_________________________________________________________________________
1366 Double_t AliCFTaskVertexingHF::GetWeight(Float_t pt)
1369 // calculating the weight to fill the container
1373 // p0 = 1.63297e-01 --> 0.322643
1379 // p0 = 1.85906e-01 --> 0.36609
1384 Double_t func1[4] = {0.322643,2.96275,2.30301,2.5};
1385 Double_t func2[4] = {0.36609,1.94635,1.40463,2.5};
1387 Double_t dndpt_func1 = dNdptFit(pt,func1);
1388 if(fUseFlatPtWeight) dndpt_func1 = 1./30.;
1389 Double_t dndpt_func2 = dNdptFit(pt,func2);
1390 AliDebug(2,Form("pt = %f, FONLL = %f, Pythia = %f, ratio = %f",pt,dndpt_func1,dndpt_func2,dndpt_func1/dndpt_func2));
1391 return dndpt_func1/dndpt_func2;
1394 //__________________________________________________________________________________________________
1395 Double_t AliCFTaskVertexingHF::dNdptFit(Float_t pt, Double_t* par)
1398 // calculating dNdpt
1401 Double_t denom = TMath::Power((pt/par[1]), par[3] );
1402 Double_t dNdpt = par[0]*pt/TMath::Power(1.+denom, par[2]);
1407 //__________________________________________________________________________________________________
1408 Double_t AliCFTaskVertexingHF::GetZWeight(Float_t z, Int_t runnumber){
1410 // calculating the z-vtx weight for the given run range
1413 if(runnumber>146824 || runnumber<146803) return 1.0;
1415 Double_t func1[3] = {1.0, -0.5, 6.5 };
1416 Double_t func2[3] = {1.0, -0.5, 5.5 };
1418 Double_t dzFunc1 = DodzFit(z,func1);
1419 Double_t dzFunc2 = DodzFit(z,func2);
1421 return dzFunc1/dzFunc2;
1424 //__________________________________________________________________________________________________
1425 Double_t AliCFTaskVertexingHF::DodzFit(Float_t z, Double_t* par) {
1428 // Gaussian z-vtx shape
1430 //gaussian = [0]/TMath::Sqrt(2.*TMath::Pi())/[2]*exp[-(x-[1])*(x-[1])/(2*[2]*[2])]
1432 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]);
1436 //__________________________________________________________________________________________________
1437 Double_t AliCFTaskVertexingHF::GetNchWeight(Int_t nch){
1439 // calculates the Nch weight using the measured and generateed Nch distributions
1441 if(nch<=0) return 0.;
1442 Double_t pMeas=fHistoMeasNch->GetBinContent(fHistoMeasNch->FindBin(nch));
1443 Double_t pMC=fHistoMCNch->GetBinContent(fHistoMCNch->FindBin(nch));
1444 Double_t weight = pMC>0 ? pMeas/pMC : 0.;
1445 if(fUseTrackletsWeight) weight = pMC;
1448 //__________________________________________________________________________________________________
1449 void AliCFTaskVertexingHF::CreateMeasuredNchHisto(){
1450 // creates historgam with measured multiplcity distribution in pp 7 TeV collisions (from Eur. Phys. J. C (2010) 68: 345–354)
1452 // for Nch > 70 the points were obtained with a double NBD distribution fit
1453 // TF1 *fit1 = new TF1("fit1","[0]*(TMath::Gamma(x+[1])/(TMath::Gamma(x+1)*TMath::Gamma([1])))*(TMath::Power(([2]/[1]),x))*(TMath::Power((1+([2]/[1])),-x-[1]))"); fit1->SetParameter(0,1.);// normalization constant
1454 // fit1->SetParameter(1,1.63); // k parameter
1455 // fit1->SetParameter(2,12.8); // mean multiplicity
1457 Double_t nchbins[82]={0.50,1.50,2.50,3.50,4.50,5.50,6.50,7.50,8.50,9.50,
1458 10.50,11.50,12.50,13.50,14.50,15.50,16.50,17.50,18.50,19.50,
1459 20.50,21.50,22.50,23.50,24.50,25.50,26.50,27.50,28.50,29.50,
1460 30.50,31.50,32.50,33.50,34.50,35.50,36.50,37.50,38.50,39.50,
1461 40.50,41.50,42.50,43.50,44.50,45.50,46.50,47.50,48.50,49.50,
1462 50.50,51.50,52.50,53.50,54.50,55.50,56.50,57.50,58.50,59.50,
1463 60.50,62.50,64.50,66.50,68.50,70.50,72.50,74.50,76.50,78.50,
1464 80.50,82.50,84.50,86.50,88.50,90.50,92.50,94.50,96.50,98.50,
1466 Double_t pch[81]={0.062011,0.072943,0.070771,0.067245,0.062834,0.057383,0.051499,0.04591,0.041109,0.036954,
1467 0.03359,0.030729,0.028539,0.026575,0.024653,0.0229,0.021325,0.019768,0.018561,0.017187,
1468 0.01604,0.014836,0.013726,0.012576,0.011481,0.010393,0.009502,0.008776,0.008024,0.007452,
1469 0.006851,0.006428,0.00594,0.005515,0.005102,0.00469,0.004162,0.003811,0.003389,0.003071,
1470 0.002708,0.002422,0.002184,0.001968,0.00186,0.00165,0.001577,0.001387,0.001254,0.001118,
1471 0.001037,0.000942,0.000823,0.000736,0.000654,0.000579,0.000512,0.00049,0.00045,0.000355,
1472 0.000296,0.000265,0.000193,0.00016,0.000126,0.0000851, 0.0000676,0.0000537,0.0000426, 0.0000338,
1473 0.0000268,0.0000213,0.0000166,0.0000133,0.0000106,0.00000837,0.00000662, 0.00000524,0.00000414, 0.00000327,
1476 if(fHistoMeasNch) delete fHistoMeasNch;
1477 fHistoMeasNch=new TH1F("hMeaseNch","",81,nchbins);
1478 for(Int_t i=0; i<81; i++){
1479 fHistoMeasNch->SetBinContent(i+1,pch[i]);
1480 fHistoMeasNch->SetBinError(i+1,0.);
1484 //__________________________________________________________________________________________________
1485 Bool_t AliCFTaskVertexingHF::ProcessDs(Int_t recoAnalysisCuts) const{
1486 // processes output of Ds is selected
1488 if(recoAnalysisCuts > 0){
1489 Int_t isKKpi=recoAnalysisCuts&1;
1490 Int_t ispiKK=recoAnalysisCuts&2;
1491 Int_t isPhiKKpi=recoAnalysisCuts&4;
1492 Int_t isPhipiKK=recoAnalysisCuts&8;
1493 Int_t isK0starKKpi=recoAnalysisCuts&16;
1494 Int_t isK0starpiKK=recoAnalysisCuts&32;
1496 if(isKKpi && isPhiKKpi) keep=kTRUE;
1497 if(ispiKK && isPhipiKK) keep=kTRUE;
1499 else if(fDsOption==2){
1500 if(isKKpi && isK0starKKpi) keep=kTRUE;
1501 if(ispiKK && isK0starpiKK) keep=kTRUE;
1503 else if(fDsOption==3)keep=kTRUE;
1507 //__________________________________________________________________________________________________
1508 Bool_t AliCFTaskVertexingHF::ProcessLctoV0Bachelor(Int_t recoAnalysisCuts) const{
1509 // processes output of Lc->V0+bnachelor is selected
1511 if(recoAnalysisCuts > 0){
1513 Int_t isK0Sp = recoAnalysisCuts&1;
1514 Int_t isLambdaBarpi = recoAnalysisCuts&2;
1515 Int_t isLambdapi = recoAnalysisCuts&4;
1517 if(fLctoV0bachelorOption==1){
1518 if(isK0Sp) keep=kTRUE;
1520 else if(fLctoV0bachelorOption==2){
1521 if(isLambdaBarpi) keep=kTRUE;
1523 else if(fLctoV0bachelorOption==4){
1524 if(isLambdapi) keep=kTRUE;
1526 else if(fLctoV0bachelorOption==7) {
1527 if (isK0Sp || isLambdaBarpi || isLambdapi) keep=kTRUE;