c3e7c7b97d59714244e6fd14a2fb7d02372ee3cd
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / macros / AddRsnAnalysisTask.C
1 //=============================================================================
2 //
3 // *** AliRsnAnalysisTask.C ***
4 //
5 // This macro initialize a complete AnalysisTask object for resonances.
6 // All the possibilities are made available through enumerations,
7 // with the same style of the Config.C file used for simulation.
8 //
9 //=============================================================================
10
11
12
13 static AliRsnAnalysisTaskSEBase::EInputType inputType = AliRsnAnalysisTaskSEBase::kESDMC;
14
15 static Bool_t useAutoHandler = kTRUE;
16 static Int_t  bufferSize     = 3000;
17 static Int_t  pidArraySize   = 2000;
18
19 static const char*       outputFileName = "rsn.root";
20
21 static Bool_t            useRsnTrackCuts = kFALSE;
22 static Double_t          etaRange = 10.0;
23 static Double_t          rsnImpactParam = 3.0;
24 static Double_t          ptMin = 0.0;
25
26 static Bool_t            useESDTrackCuts = kFALSE;
27 static Double_t          cov11 = 2;
28 static Double_t          cov22 = 2;
29 static Double_t          cov33 = 0.5;
30 static Double_t          cov44 = 0.5;
31 static Double_t          cov55 = 2;
32 static Double_t          nSigmaToVertex = 4;
33 static Double_t          dcaToVertex = 3.0;
34 static Double_t          maxChi2PerClusterTPC = 3.5;
35 static Bool_t            requireTPCRefit = kTRUE;
36 static Bool_t            requireSigmaToVertex = kTRUE;
37 static Bool_t            acceptKinkDaughters = kFALSE;
38 static Int_t             minNClustersTPC = 50;
39
40 static Int_t             nMixedEvents = 5;
41
42 Int_t AddRsnAnalysisTask(AliAnalysisManager *mgr)
43 {
44 //
45 // Core method of the macro.
46 // Creates and initialized the analysis task object and inserts it
47 // into the AnalysisManager object passed as argument.
48 //
49
50   // initialize task objects and retrieve managers for PID and reading
51   AliRsnAnalysisSE *task    = new AliRsnAnalysisSE("RsnAnalysisTask", bufferSize);
52   AliRsnReader     *reader  = task->GetReader();
53   AliRsnPID        *pid     = task->GetPID();
54
55   // set the input type
56   task->SetInputType(inputType, mgr, useAutoHandler);
57
58   // define event-mixing cuts
59   AliRsnCut    *cutVz     = new AliRsnCut("cutVz" , "", AliRsnCut::kVzDifference, 0.0, 0.5);
60   AliRsnCut    *cutMult   = new AliRsnCut("cutMult", "", AliRsnCut::kMultiplicityDifference, 0, 10);
61   AliRsnCutSet *cutMixing = new AliRsnCutSet("cutMixing");
62   cutMixing->AddCut(cutVz);
63   cutMixing->AddCut(cutMult);
64   cutMixing->SetCutScheme("cutVz&cutMult");
65   task->SetMixingCut(cutMixing);
66   task->SetMixingNum(nMixedEvents);
67
68   // ESD settings
69   reader->SetCheckSplit(kTRUE);
70   pid->SetPIDArraysSize(pidArraySize);
71   pid->SetPriorProbability(AliRsnPID::kElectron, 0.02);
72   pid->SetPriorProbability(AliRsnPID::kMuon,     0.02);
73   pid->SetPriorProbability(AliRsnPID::kPion,     0.83);
74   pid->SetPriorProbability(AliRsnPID::kKaon,     0.07);
75   pid->SetPriorProbability(AliRsnPID::kProton,   0.06);
76   pid->SetMaxPt(100.0);
77   pid->SetMinProb(0.0);
78
79   // default cuts for ITS+TPC
80   AliESDtrackCuts *esdCuts = reader->GetESDTrackCuts();
81   esdCuts->SetMaxCovDiagonalElements(cov11, cov22, cov33, cov44, cov55);
82   esdCuts->SetRequireSigmaToVertex(requireSigmaToVertex);
83   if (requireSigmaToVertex) esdCuts->SetMaxNsigmaToVertex(nSigmaToVertex);
84   else
85   {
86     esdCuts->SetDCAToVertexZ(dcaToVertex);
87     esdCuts->SetDCAToVertexXY(dcaToVertex);
88   }
89   esdCuts->SetRequireTPCRefit(requireTPCRefit);
90   esdCuts->SetAcceptKingDaughters(acceptKinkDaughters);
91   esdCuts->SetMinNClustersTPC(minNClustersTPC);
92   esdCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
93   reader->SetUseESDTrackCuts(useESDTrackCuts);
94
95   // default cuts from package for tracks
96   AliRsnCut *cutPt = new AliRsnCut("cutPt", "", AliRsnCut::kTransMomentumMC, ptMin, 1000000.0);
97   AliRsnCut *cutEta = new AliRsnCut("cutEtaMC", "", AliRsnCut::kEtaMC, -etaRange, etaRange);
98   AliRsnCut *cutDr = new AliRsnCut("cutDr", "", AliRsnCut::kRadialImpactParam, 0.0, rsnImpactParam);
99   AliRsnCutSet *rsnCuts = reader->GetRsnTrackCuts();
100   rsnCuts->AddCut(cutPt);
101   rsnCuts->AddCut(cutEta);
102   rsnCuts->AddCut(cutDr);
103   rsnCuts->SetCutScheme("cutPt&cutEta&cutDr");
104   reader->SetUseRsnTrackCuts(useRsnTrackCuts);
105
106   // add configs for all impact parameters
107   task->AddPairMgrFromMacro("CreatePairsPhi.C");
108
109   // initialize containers
110   AliAnalysisDataContainer *input = mgr->CreateContainer("in", TChain::Class(), AliAnalysisManager::kInputContainer);
111   AliAnalysisDataContainer *dummy = mgr->CreateContainer("dummy1", TTree::Class(), AliAnalysisManager::kOutputContainer, "default");
112   AliAnalysisDataContainer *out   = mgr->CreateContainer("RSN", TList::Class(), AliAnalysisManager::kOutputContainer, outputFileName);
113
114   // connect containers to AnalysisManager
115   mgr->AddTask(task);
116   mgr->ConnectInput(task, 0, input);
117   mgr->ConnectOutput(task, 0, dummy);
118   mgr->ConnectOutput(task, 1, out);
119 }