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 "AliAnalysisManager.h"
47 #include "AliAODHandler.h"
48 #include "AliAODEvent.h"
49 #include "AliAODRecoDecay.h"
50 #include "AliAODRecoDecayHF.h"
51 #include "AliAODRecoDecayHF2Prong.h"
52 #include "AliAODRecoDecayHF3Prong.h"
53 #include "AliAODRecoDecayHF4Prong.h"
54 #include "AliAODRecoCascadeHF.h"
55 #include "AliAODMCParticle.h"
56 #include "AliAODMCHeader.h"
57 #include "AliESDtrack.h"
59 #include "THnSparse.h"
61 #include "AliESDtrackCuts.h"
62 #include "AliRDHFCuts.h"
63 #include "AliRDHFCutsD0toKpi.h"
64 #include "AliRDHFCutsDplustoKpipi.h"
65 #include "AliRDHFCutsDStartoKpipi.h"
66 #include "AliRDHFCutsDstoKKpi.h"
67 #include "AliRDHFCutsLctopKpi.h"
68 #include "AliRDHFCutsD0toKpipipi.h"
69 #include "AliCFVertexingHF2Prong.h"
70 #include "AliCFVertexingHF3Prong.h"
71 #include "AliCFVertexingHFCascade.h"
72 #include "AliCFVertexingHF.h"
73 #include "AliAnalysisDataSlot.h"
74 #include "AliAnalysisDataContainer.h"
76 //__________________________________________________________________________
77 AliCFTaskVertexingHF::AliCFTaskVertexingHF() :
80 fHistEventsProcessed(0x0),
88 fCountRecoITSClusters(0),
93 fFillFromGenerated(kFALSE),
95 fAcceptanceUnf(kTRUE),
103 fCentralitySelection(kTRUE),
105 fRejectIfNoQuark(kTRUE),
106 fUseMCVertex(kFALSE),
109 fConfiguration(kCheetah), // by default, setting the fast configuration
116 //___________________________________________________________________________
117 AliCFTaskVertexingHF::AliCFTaskVertexingHF(const Char_t* name, AliRDHFCuts* cuts, TF1* func) :
118 AliAnalysisTaskSE(name),
120 fHistEventsProcessed(0x0),
128 fCountRecoITSClusters(0),
133 fFillFromGenerated(kFALSE),
134 fOriginDselection(0),
135 fAcceptanceUnf(kTRUE),
143 fCentralitySelection(kTRUE),
145 fRejectIfNoQuark(kTRUE),
146 fUseMCVertex(kFALSE),
149 fConfiguration(kCheetah), // by default, setting the fast configuration
153 // Constructor. Initialization of Inputs and Outputs
156 DefineInput(0) and DefineOutput(0)
157 are taken care of by AliAnalysisTaskSE constructor
159 DefineOutput(1,TH1I::Class());
160 DefineOutput(2,AliCFContainer::Class());
161 DefineOutput(3,THnSparseD::Class());
162 DefineOutput(4,AliRDHFCuts::Class());
167 //___________________________________________________________________________
168 AliCFTaskVertexingHF& AliCFTaskVertexingHF::operator=(const AliCFTaskVertexingHF& c)
171 // Assignment operator
174 AliAnalysisTaskSE::operator=(c) ;
175 fCFManager = c.fCFManager;
176 fHistEventsProcessed = c.fHistEventsProcessed;
178 fFuncWeight = c.fFuncWeight;
183 //___________________________________________________________________________
184 AliCFTaskVertexingHF::AliCFTaskVertexingHF(const AliCFTaskVertexingHF& c) :
185 AliAnalysisTaskSE(c),
186 fCFManager(c.fCFManager),
187 fHistEventsProcessed(c.fHistEventsProcessed),
188 fCorrelation(c.fCorrelation),
189 fCountMC(c.fCountMC),
190 fCountAcc(c.fCountAcc),
191 fCountVertex(c.fCountVertex),
192 fCountRefit(c.fCountRefit),
193 fCountReco(c.fCountReco),
194 fCountRecoAcc(c.fCountRecoAcc),
195 fCountRecoITSClusters(c.fCountRecoITSClusters),
196 fCountRecoPPR(c.fCountRecoPPR),
197 fCountRecoPID(c.fCountRecoPID),
199 fDecayChannel(c.fDecayChannel),
200 fFillFromGenerated(c.fFillFromGenerated),
201 fOriginDselection(c.fOriginDselection),
202 fAcceptanceUnf(c.fAcceptanceUnf),
204 fUseWeight(c.fUseWeight),
207 fPartName(c.fPartName),
208 fDauNames(c.fDauNames),
210 fCentralitySelection(c.fCentralitySelection),
211 fFakeSelection(c.fFakeSelection),
212 fRejectIfNoQuark(c.fRejectIfNoQuark),
213 fUseMCVertex(c.fUseMCVertex),
214 fDsOption(c.fDsOption),
215 fGenDsOption(c.fGenDsOption),
216 fConfiguration(c.fConfiguration),
217 fFuncWeight(c.fFuncWeight)
224 //___________________________________________________________________________
225 AliCFTaskVertexingHF::~AliCFTaskVertexingHF()
230 if (fCFManager) delete fCFManager ;
231 if (fHistEventsProcessed) delete fHistEventsProcessed ;
232 if (fCorrelation) delete fCorrelation ;
233 if (fCuts) delete fCuts;
234 if (fFuncWeight) delete fFuncWeight;
237 //_________________________________________________________________________-
238 void AliCFTaskVertexingHF::Init()
244 if (fDebug>1) printf("AliCFTaskVertexingHF::Init()");
245 AliRDHFCuts *copyfCuts = 0x0;
247 AliFatal("No cuts defined - Exiting...");
251 switch (fDecayChannel){
253 copyfCuts = new AliRDHFCutsD0toKpi(*(static_cast<AliRDHFCutsD0toKpi*>(fCuts)));
254 switch (fConfiguration) {
255 case kSnail: // slow configuration: all variables in
258 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
267 copyfCuts = new AliRDHFCutsDStartoKpipi(*(static_cast<AliRDHFCutsDStartoKpipi*>(fCuts)));
268 switch (fConfiguration) {
269 case kSnail: // slow configuration: all variables in
272 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
281 copyfCuts = new AliRDHFCutsDplustoKpipi(*(static_cast<AliRDHFCutsDplustoKpipi*>(fCuts)));
282 switch (fConfiguration) {
283 case kSnail: // slow configuration: all variables in
286 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
295 copyfCuts = new AliRDHFCutsLctopKpi(*(static_cast<AliRDHFCutsLctopKpi*>(fCuts)));
296 switch (fConfiguration) {
297 case kSnail: // slow configuration: all variables in
300 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
309 copyfCuts = new AliRDHFCutsDstoKKpi(*(static_cast<AliRDHFCutsDstoKKpi*>(fCuts)));
310 switch (fConfiguration) {
311 case kSnail: // slow configuration: all variables in
314 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
323 copyfCuts = new AliRDHFCutsD0toKpipipi(*(static_cast<AliRDHFCutsD0toKpipipi*>(fCuts)));
324 switch (fConfiguration) {
325 case kSnail: // slow configuration: all variables in
328 case kCheetah:// fast configuration: only pt_candidate, y, phi, ct, fake, z_vtx, centrality, multiplicity will be filled
333 fDauNames="K+pi+pi+pi";
337 AliFatal("The decay channel MUST be defined according to AliCFVertexing::DecayChannel - Exiting...");
341 const char* nameoutput=GetOutputSlot(4)->GetContainer()->GetName();
343 copyfCuts->SetName(nameoutput);
346 PostData(4, copyfCuts);
349 AliFatal("Failing initializing AliRDHFCuts object - Exiting...");
355 //_________________________________________________
356 void AliCFTaskVertexingHF::UserExec(Option_t *)
359 // Main loop function
362 PostData(1,fHistEventsProcessed) ;
363 PostData(2,fCFManager->GetParticleContainer()) ;
364 PostData(3,fCorrelation) ;
366 if (fFillFromGenerated){
367 AliWarning("Flag to fill container with generated value ON ---> dca, d0pi, d0K, d0xd0, cosPointingAngle will be set as dummy!");
371 Error("UserExec","NO EVENT FOUND!");
375 AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
377 TClonesArray *arrayBranch=0;
379 if(!aodEvent && AODEvent() && IsStandardAOD()) {
380 // In case there is an AOD handler writing a standard AOD, use the AOD
381 // event in memory rather than the input (ESD) event.
382 aodEvent = dynamic_cast<AliAODEvent*> (AODEvent());
383 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
384 // have to taken from the AOD event hold by the AliAODExtension
385 AliAODHandler* aodHandler = (AliAODHandler*)
386 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
387 if(aodHandler->GetExtensions()) {
388 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
389 AliAODEvent *aodFromExt = ext->GetAOD();
391 switch (fDecayChannel){
393 arrayBranch=(TClonesArray*)aodFromExt->GetList()->FindObject("D0toKpi");
397 arrayBranch=(TClonesArray*)aodFromExt->GetList()->FindObject("Dstar");
403 arrayBranch=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong");
407 arrayBranch=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm4Prong");
416 switch (fDecayChannel){
418 arrayBranch=(TClonesArray*)aodEvent->GetList()->FindObject("D0toKpi");
422 arrayBranch=(TClonesArray*)aodEvent->GetList()->FindObject("Dstar");
428 arrayBranch=(TClonesArray*)aodEvent->GetList()->FindObject("Charm3Prong");
432 arrayBranch=(TClonesArray*)aodEvent->GetList()->FindObject("Charm4Prong");
440 AliAODVertex *aodVtx = (AliAODVertex*)aodEvent->GetPrimaryVertex();
444 AliError("Could not find array of HF vertices");
450 fCFManager->SetRecEventInfo(aodEvent);
451 fCFManager->SetMCEventInfo(aodEvent);
453 //******** DEFINE number of variables of the container***** for now set at 13, in the future in the config macro.
455 //loop on the MC event
457 TClonesArray* mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
459 AliError("Could not find Monte-Carlo in AOD");
464 Int_t icountReco = 0;
465 Int_t icountVertex = 0;
466 Int_t icountRefit = 0;
467 Int_t icountRecoAcc = 0;
468 Int_t icountRecoITSClusters = 0;
469 Int_t icountRecoPPR = 0;
470 Int_t icountRecoPID = 0;
473 AliAODMCHeader *mcHeader = dynamic_cast<AliAODMCHeader*>(aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
475 AliError("Could not find MC Header in AOD");
479 Double_t* containerInput = new Double_t[fNvar];
480 Double_t* containerInputMC = new Double_t[fNvar];
483 AliCFVertexingHF* cfVtxHF=0x0;
484 switch (fDecayChannel){
486 cfVtxHF = new AliCFVertexingHF2Prong(mcArray, fOriginDselection);
490 cfVtxHF = new AliCFVertexingHFCascade(mcArray, fOriginDselection);
496 cfVtxHF = new AliCFVertexingHF3Prong(mcArray, fOriginDselection, fDecayChannel);
497 if(fDecayChannel==33){
498 cfVtxHF->SetGeneratedDsOption(fGenDsOption);
503 //cfVtxHF = new AliCFVertexingHF4Prong(mcArray, originDselection); // not there yet
510 AliError("No AliCFVertexingHF initialized");
511 delete[] containerInput;
512 delete[] containerInputMC;
516 Double_t zPrimVertex = aodVtx ->GetZ();
517 Double_t zMCVertex = mcHeader->GetVtxZ();
518 if (TMath::Abs(zMCVertex) > fCuts->GetMaxVtxZ()){
519 AliDebug(3,Form("z coordinate of MC vertex = %f, it was required to be within [-%f, +%f], skipping event", zMCVertex, fCuts->GetMaxVtxZ(), fCuts->GetMaxVtxZ()));
520 delete[] containerInput;
521 delete[] containerInputMC;
525 AliESDtrackCuts** trackCuts = new AliESDtrackCuts*[cfVtxHF->GetNProngs()];
526 if (fDecayChannel == 21){
527 // for the D*, setting the third element of the array of the track cuts to those for the soft pion
528 for (Int_t iProng = 0; iProng<cfVtxHF->GetNProngs()-1; iProng++){
529 trackCuts[iProng]=fCuts->GetTrackCuts();
531 trackCuts[2] = fCuts->GetTrackCutsSoftPi();
534 for (Int_t iProng = 0; iProng<cfVtxHF->GetNProngs(); iProng++){
535 trackCuts[iProng]=fCuts->GetTrackCuts();
539 //General settings: vertex, feed down and fill reco container with generated values.
540 cfVtxHF->SetRecoPrimVertex(zPrimVertex);
541 cfVtxHF->SetMCPrimaryVertex(zMCVertex);
542 cfVtxHF->SetFillFromGenerated(fFillFromGenerated);
543 cfVtxHF->SetNVar(fNvar);
544 cfVtxHF->SetFakeSelection(fFakeSelection);
545 cfVtxHF->SetRejectCandidateIfNotFromQuark(fRejectIfNoQuark);
546 cfVtxHF->SetConfiguration(fConfiguration);
548 // switch-off the trigger class selection (doesn't work for MC)
549 fCuts->SetTriggerClass("");
551 // MC vertex, to be used, in case, for pp
552 if (fUseMCVertex) fCuts->SetUseMCVertex();
554 if (fCentralitySelection){ // keep only the requested centrality
555 if(fCuts->IsEventSelectedInCentrality(aodEvent)!=0) {
556 delete[] containerInput;
557 delete[] containerInputMC;
561 } else { // keep all centralities
562 fCuts->SetMinCentrality(0.);
563 fCuts->SetMaxCentrality(100.);
566 Float_t centValue = fCuts->GetCentrality(aodEvent);
567 cfVtxHF->SetCentralityValue(centValue);
569 // number of tracklets - multiplicity estimator
570 Double_t multiplicity = (Double_t)(aodEvent->GetTracklets()->GetNumberOfTracklets()); // casted to double because the CF is filled with doubles
571 cfVtxHF->SetMultiplicity(multiplicity);
573 for (Int_t iPart=0; iPart<mcArray->GetEntriesFast(); iPart++) {
574 AliAODMCParticle* mcPart = dynamic_cast<AliAODMCParticle*>(mcArray->At(iPart));
576 AliError("Failed casting particle from MC array!, Skipping particle");
579 // check the MC-level cuts, must be the desidered particle
580 if (!fCFManager->CheckParticleCuts(0, mcPart)) {
581 continue; // 0 stands for MC level
583 cfVtxHF->SetMCCandidateParam(iPart);
586 cquarks += cfVtxHF->MCcquarkCounting(mcPart);
588 if (!(cfVtxHF->SetLabelArray())){
589 AliDebug(2,Form("Impossible to set the label array (decaychannel = %d)",fDecayChannel));
593 //check the candiate family at MC level
594 if (!(cfVtxHF->CheckMCPartFamily(mcPart, mcArray))) {
595 AliDebug(2,Form("Check on the family wrong!!! (decaychannel = %d)",fDecayChannel));
599 AliDebug(2,Form("Check on the family OK!!! (decaychannel = %d)",fDecayChannel));
602 //Fill the MC container
603 Bool_t mcContainerFilled = cfVtxHF -> FillMCContainer(containerInputMC);
604 if (mcContainerFilled) {
606 if (fFuncWeight){ // using user-defined function
607 AliDebug(2,"Using function");
608 fWeight = fFuncWeight->Eval(containerInputMC[0]);
611 AliDebug(2,"Using FONLL");
612 fWeight = GetWeight(containerInputMC[0]);
614 AliDebug(2,Form("pt = %f, weight = %f",containerInputMC[0], fWeight));
616 if (!fCuts->IsInFiducialAcceptance(containerInputMC[0],containerInputMC[1])) continue;
617 //MC Limited Acceptance
618 if (TMath::Abs(containerInputMC[1]) < 0.5) {
619 fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepGeneratedLimAcc, fWeight);
620 AliDebug(3,"MC Lim Acc container filled\n");
624 fCFManager->GetParticleContainer()->Fill(containerInputMC, kStepGenerated, fWeight);
626 AliDebug(3,"MC cointainer filled \n");
629 // check the MC-Acceptance level cuts
630 // since standard CF functions are not applicable, using Kine Cuts on daughters
631 Bool_t mcAccepStep = cfVtxHF-> MCAcceptanceStep();
633 fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepAcceptance, fWeight);
634 AliDebug(3,"MC acceptance cut passed\n");
638 if (fCuts->IsEventSelected(aodEvent)){
639 // filling the container if the vertex is ok
640 fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepVertex, fWeight) ;
641 AliDebug(3,"Vertex cut passed and container filled\n");
644 //mc Refit requirement
645 Bool_t mcRefitStep = cfVtxHF->MCRefitStep(aodEvent, &trackCuts[0]);
647 fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepRefit, fWeight);
648 AliDebug(3,"MC Refit cut passed and container filled\n");
652 AliDebug(3,"MC Refit cut not passed\n");
657 AliDebug (3, "MC vertex step not passed\n");
662 AliDebug (3, "MC in acceptance step not passed\n");
667 AliDebug (3, "MC container not filled\n");
671 if (cquarks<2) AliDebug(2,Form("Event with %d c-quarks", cquarks));
672 AliDebug(2,Form("Found %i MC particles that are %s!!",icountMC,fPartName.Data()));
673 AliDebug(2,Form("Found %i MC particles that are %s and satisfy Acc cuts!!",icountAcc,fPartName.Data()));
674 AliDebug(2,Form("Found %i MC particles that are %s and satisfy Vertex cuts!!",icountVertex,fPartName.Data()));
675 AliDebug(2,Form("Found %i MC particles that are %s and satisfy Refit cuts!!",icountRefit,fPartName.Data()));
677 // Now go to rec level
678 fCountMC += icountMC;
679 fCountAcc += icountAcc;
680 fCountVertex+= icountVertex;
681 fCountRefit+= icountRefit;
683 AliDebug(2,Form("Found %d vertices for decay channel %d",arrayBranch->GetEntriesFast(),fDecayChannel));
685 for(Int_t iCandid = 0; iCandid<arrayBranch->GetEntriesFast();iCandid++){
686 AliAODRecoDecayHF* charmCandidate=0x0;
687 switch (fDecayChannel){
689 charmCandidate = (AliAODRecoDecayHF2Prong*)arrayBranch->At(iCandid);
693 charmCandidate = (AliAODRecoCascadeHF*)arrayBranch->At(iCandid);
699 charmCandidate = (AliAODRecoDecayHF3Prong*)arrayBranch->At(iCandid);
703 charmCandidate = (AliAODRecoDecayHF4Prong*)arrayBranch->At(iCandid);
710 Bool_t unsetvtx=kFALSE;
711 if(!charmCandidate->GetOwnPrimaryVtx()) {
712 charmCandidate->SetOwnPrimaryVtx(aodVtx); // needed to compute all variables
716 Bool_t signAssociation = cfVtxHF->SetRecoCandidateParam((AliAODRecoDecayHF*)charmCandidate);
717 if (!signAssociation){
718 charmCandidate = 0x0;
722 Int_t isPartOrAntipart = cfVtxHF->CheckReflexion(fSign);
723 if (isPartOrAntipart == 0){
724 AliDebug(2, Form("The candidate pdg code doesn't match the requirement set in the task (fSign = %d)",fSign));
729 Bool_t recoContFilled = cfVtxHF->FillRecoContainer(containerInput);
732 // weight according to pt
734 if (fFuncWeight){ // using user-defined function
735 AliDebug(2, "Using function");
736 fWeight = fFuncWeight->Eval(containerInput[0]);
739 AliDebug(2, "Using FONLL");
740 fWeight = GetWeight(containerInput[0]);
742 AliDebug(2, Form("pt = %f, weight = %f",containerInput[0], fWeight));
745 if (!fCuts->IsInFiducialAcceptance(containerInput[0],containerInput[1])) continue;
748 Bool_t recoStep = cfVtxHF->RecoStep();
749 Bool_t vtxCheck = fCuts->IsEventSelected(aodEvent);
751 if (recoStep && recoContFilled && vtxCheck){
752 fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructed, fWeight) ;
754 AliDebug(3,"Reco step passed and container filled\n");
756 //Reco in the acceptance -- take care of UNFOLDING!!!!
757 Bool_t recoAcceptanceStep = cfVtxHF->RecoAcceptStep(&trackCuts[0]);
758 if (recoAcceptanceStep) {
759 fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoAcceptance, fWeight) ;
761 AliDebug(3,"Reco acceptance cut passed and container filled\n");
764 Double_t fill[4]; //fill response matrix
765 Bool_t bUnfolding = cfVtxHF -> FillUnfoldingMatrix(fill);
766 if (bUnfolding) fCorrelation->Fill(fill);
769 //Number of ITS cluster requirements
770 Int_t recoITSnCluster = fCuts->IsSelected(charmCandidate, AliRDHFCuts::kTracks);
771 if (recoITSnCluster){
772 fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoITSClusters, fWeight) ;
773 icountRecoITSClusters++;
774 AliDebug(3,"Reco n ITS cluster cut passed and container filled\n");
776 Bool_t iscutsusingpid = fCuts->GetIsUsePID();
777 Int_t recoAnalysisCuts = -1, recoPidSelection = -1;
778 fCuts->SetUsePID(kFALSE);
779 recoAnalysisCuts = fCuts->IsSelected(charmCandidate, AliRDHFCuts::kCandidate, aodEvent);
781 if (fDecayChannel==33){ // Ds case, where more possibilities are considered
782 Bool_t keepDs=ProcessDs(recoAnalysisCuts);
783 if(keepDs) recoAnalysisCuts=3;
787 fCuts->SetUsePID(iscutsusingpid); //restoring usage of the PID from the cuts object
788 if (recoAnalysisCuts == 3 || recoAnalysisCuts == isPartOrAntipart){
789 fCFManager->GetParticleContainer()->Fill(containerInput, kStepRecoPPR, fWeight);
791 AliDebug(3,"Reco Analysis cuts passed and container filled \n");
793 //recoPidSelection = fCuts->IsSelected(charmCandidate, AliRDHFCuts::kPID);
794 //if((fCuts->CombineSelectionLevels(3,recoAnalysisCuts,recoPidSelection)==isPartOrAntipart)||(fCuts->CombineSelectionLevels(3,recoAnalysisCuts,recoPidSelection)==3)){
795 recoPidSelection = fCuts->IsSelected(charmCandidate, AliRDHFCuts::kCandidate, aodEvent);
797 if (fDecayChannel==33){ // Ds case, where more possibilities are considered
798 Bool_t keepDs=ProcessDs(recoPidSelection);
799 if(keepDs) recoPidSelection=3;
802 if (recoPidSelection == 3 || recoPidSelection == isPartOrAntipart){
803 fCFManager->GetParticleContainer()->Fill(containerInput, kStepRecoPID, fWeight);
805 AliDebug(3,"Reco PID cuts passed and container filled \n");
807 Double_t fill[4]; //fill response matrix
808 Bool_t bUnfolding = cfVtxHF -> FillUnfoldingMatrix(fill);
809 if (bUnfolding) fCorrelation->Fill(fill);
813 AliDebug(3, "Analysis Cuts step not passed \n");
818 AliDebug(3, "PID selection not passed \n");
823 AliDebug(3, "Number of ITS cluster step not passed\n");
828 AliDebug(3, "Reco acceptance step not passed\n");
833 AliDebug(3, "Reco step not passed\n");
838 if(unsetvtx) charmCandidate->UnsetOwnPrimaryVtx();
839 } // end loop on candidate
841 fCountReco+= icountReco;
842 fCountRecoAcc+= icountRecoAcc;
843 fCountRecoITSClusters+= icountRecoITSClusters;
844 fCountRecoPPR+= icountRecoPPR;
845 fCountRecoPID+= icountRecoPID;
847 fHistEventsProcessed->Fill(0);
849 delete[] containerInput;
850 delete[] containerInputMC;
853 // for (Int_t i=0; i<cfVtxHF->GetNProngs(); i++){
854 // delete [] trackCuts[i];
862 //___________________________________________________________________________
863 void AliCFTaskVertexingHF::Terminate(Option_t*)
865 // The Terminate() function is the last function to be called during
866 // a query. It always runs on the client, it can be used to present
867 // the results graphically or save the results to file.
869 AliAnalysisTaskSE::Terminate();
871 AliInfo(Form("Found %i MC particles that are %s in MC, in %d events",fCountMC,fPartName.Data(),fEvents));
872 AliInfo(Form("Found %i MC particles that are %s in MC and satisfy Acc cuts, in %d events",fCountAcc,fPartName.Data(),fEvents));
873 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));
874 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));
875 AliInfo(Form("Found %i reco %s that are decaying in %s, in %d events",fCountReco,fPartName.Data(),fDauNames.Data(),fEvents));
876 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));
877 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));
878 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));
879 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));
881 // draw some example plots....
882 AliCFContainer *cont= dynamic_cast<AliCFContainer*> (GetOutputData(2));
884 printf("CONTAINER NOT FOUND\n");
887 // projecting the containers to obtain histograms
888 // first argument = variable, second argument = step
890 TH1D** h = new TH1D*[3];
891 if (fConfiguration == kSnail){
892 //h = new TH1D[3][12];
893 for (Int_t ih = 0; ih<3; ih++){
894 h[ih] = new TH1D[12];
896 for(Int_t iC=1;iC<12; iC++){
898 h[0][iC] = *(cont->ShowProjection(iC,0));
899 // MC-Acceptance level
900 h[1][iC] = *(cont->ShowProjection(iC,1));
902 h[2][iC] = *(cont->ShowProjection(iC,4));
906 //h = new TH1D[3][12];
907 for (Int_t ih = 0; ih<3; ih++){
910 for(Int_t iC=0;iC<8; iC++){
912 h[0][iC] = *(cont->ShowProjection(iC,0));
913 // MC-Acceptance level
914 h[1][iC] = *(cont->ShowProjection(iC,1));
916 h[2][iC] = *(cont->ShowProjection(iC,4));
920 Int_t nvarToPlot = 0;
921 if (fConfiguration == kSnail){
923 titles = new TString[nvarToPlot];
924 if(fDecayChannel==31){
925 titles[0]="pT_Dplus (GeV/c)";
926 titles[1]="rapidity";
927 titles[2]="phi (rad)";
928 titles[3]="cT (#mum)";
929 titles[4]="cosPointingAngle";
930 titles[5]="pT_1 (GeV/c)";
931 titles[6]="pT_2 (GeV/c)";
932 titles[7]="pT_3 (GeV/c)";
933 titles[8]="d0_1 (#mum)";
934 titles[9]="d0_2 (#mum)";
935 titles[10]="d0_3 (#mum)";
936 titles[11]="zVertex (cm)";
938 titles[0]="pT_D0 (GeV/c)";
939 titles[1]="rapidity";
940 titles[2]="cosThetaStar";
941 titles[3]="pT_pi (GeV/c)";
942 titles[4]="pT_K (Gev/c)";
943 titles[5]="cT (#mum)";
944 titles[6]="dca (#mum)";
945 titles[7]="d0_pi (#mum)";
946 titles[8]="d0_K (#mum)";
947 titles[9]="d0xd0 (#mum^2)";
948 titles[10]="cosPointingAngle";
949 titles[11]="phi (rad)";
955 titles = new TString[nvarToPlot];
956 titles[0]="pT_candidate (GeV/c)";
957 titles[1]="rapidity";
958 titles[2]="cT (#mum)";
961 titles[5]="centrality";
963 titles[7]="multiplicity";
966 Int_t markers[12]={20,24,21,25,27,28,
968 Int_t colors[3]={2,8,4};
969 for(Int_t iC=0;iC<nvarToPlot; iC++){
970 for(Int_t iStep=0;iStep<3;iStep++){
971 h[iStep][iC].SetTitle(titles[iC].Data());
972 h[iStep][iC].GetXaxis()->SetTitle(titles[iC].Data());
973 Double_t maxh=h[iStep][iC].GetMaximum();
974 h[iStep][iC].GetYaxis()->SetRangeUser(0,maxh*1.2);
975 h[iStep][iC].SetMarkerStyle(markers[iC]);
976 h[iStep][iC].SetMarkerColor(colors[iStep]);
980 gStyle->SetCanvasColor(0);
981 gStyle->SetFrameFillColor(0);
982 gStyle->SetTitleFillColor(0);
983 gStyle->SetStatColor(0);
985 // drawing in 2 separate canvas for a matter of clearity
986 TCanvas * c1 =new TCanvas(Form("c1New_%d",fDecayChannel),"Vars 0, 1, 2, 3",1100,1200);
989 for(Int_t iVar=0; iVar<4; iVar++){
991 h[0][iVar].DrawCopy("p");
993 h[1][iVar].DrawCopy("p");
995 h[2][iVar].DrawCopy("p");
998 TCanvas * c2 =new TCanvas(Form("c2New_%d",fDecayChannel),"Vars 4, 5, 6, 7",1100,1200);
1001 for(Int_t iVar=4; iVar<8; iVar++){
1003 h[0][iVar].DrawCopy("p");
1005 h[1][iVar].DrawCopy("p");
1007 h[2][iVar].DrawCopy("p");
1010 if (fConfiguration == kSnail){
1011 TCanvas * c3 =new TCanvas(Form("c3New_%d",fDecayChannel),"Vars 8, 9, 10, 11",1100,1200);
1014 for(Int_t iVar=8; iVar<12; iVar++){
1016 h[0][iVar].DrawCopy("p");
1018 h[1][iVar].DrawCopy("p");
1020 h[2][iVar].DrawCopy("p");
1025 THnSparseD* hcorr = dynamic_cast<THnSparseD*> (GetOutputData(3));
1027 TH2D* corr1 =hcorr->Projection(0,2);
1028 TH2D* corr2 = hcorr->Projection(1,3);
1030 TCanvas * c7 =new TCanvas(Form("c7New_%d",fDecayChannel),"",800,400);
1033 corr1->DrawCopy("text");
1035 corr2->DrawCopy("text");
1037 TFile* file_projection = new TFile("CFtaskHFprojectionNew.root","RECREATE");
1041 for(Int_t iC=0;iC<nvarToPlot; iC++){
1042 for(Int_t iStep=0;iStep<3;iStep++){
1043 h[iStep][iC].Write(Form("Step%d_%s",iStep,titles[iC].Data()));
1046 file_projection->Close();
1047 for (Int_t ih = 0; ih<3; ih++) delete [] h[ih];
1053 //___________________________________________________________________________
1054 void AliCFTaskVertexingHF::UserCreateOutputObjects()
1056 //HERE ONE CAN CREATE OUTPUT OBJECTS, IN PARTICULAR IF THE OBJECT PARAMETERS DON'T NEED
1057 //TO BE SET BEFORE THE EXECUTION OF THE TASK
1059 Info("UserCreateOutputObjects","CreateOutputObjects of task %s\n", GetName());
1063 fHistEventsProcessed = new TH1I("CFHFchist0","",1,0,1) ;
1065 PostData(1,fHistEventsProcessed) ;
1066 PostData(2,fCFManager->GetParticleContainer()) ;
1067 PostData(3,fCorrelation) ;
1072 //_________________________________________________________________________
1073 Double_t AliCFTaskVertexingHF::GetWeight(Float_t pt)
1076 // calculating the weight to fill the container
1080 // p0 = 1.63297e-01 --> 0.322643
1086 // p0 = 1.85906e-01 --> 0.36609
1091 Double_t func1[4] = {0.322643,2.96275,2.30301,2.5};
1092 Double_t func2[4] = {0.36609,1.94635,1.40463,2.5};
1094 Double_t dndpt_func1 = dNdptFit(pt,func1);
1095 Double_t dndpt_func2 = dNdptFit(pt,func2);
1096 AliDebug(2,Form("pt = %f, FONLL = %f, Pythia = %f, ratio = %f",pt,dndpt_func1,dndpt_func2,dndpt_func1/dndpt_func2));
1097 return dndpt_func1/dndpt_func2;
1100 //__________________________________________________________________________________________________
1101 Double_t AliCFTaskVertexingHF::dNdptFit(Float_t pt, Double_t* par)
1104 // calculating dNdpt
1107 Double_t denom = TMath::Power((pt/par[1]), par[3] );
1108 Double_t dNdpt = par[0]*pt/TMath::Power(1.+denom, par[2]);
1114 //__________________________________________________________________________________________________
1115 Bool_t AliCFTaskVertexingHF::ProcessDs(Int_t recoAnalysisCuts) const{
1116 // processes output of Ds is selected
1118 if(recoAnalysisCuts > 0){
1119 Int_t isKKpi=recoAnalysisCuts&1;
1120 Int_t ispiKK=recoAnalysisCuts&2;
1121 Int_t isPhiKKpi=recoAnalysisCuts&4;
1122 Int_t isPhipiKK=recoAnalysisCuts&8;
1123 Int_t isK0starKKpi=recoAnalysisCuts&16;
1124 Int_t isK0starpiKK=recoAnalysisCuts&32;
1126 if(isKKpi && isPhiKKpi) keep=kTRUE;
1127 if(ispiKK && isPhipiKK) keep=kTRUE;
1129 else if(fDsOption==2){
1130 if(isKKpi && isK0starKKpi) keep=kTRUE;
1131 if(ispiKK && isK0starpiKK) keep=kTRUE;
1133 else if(fDsOption==3)keep=kTRUE;