]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/RESONANCES/macros/mini/AddAnalysisTaskTOFKStar.C
bda0a7014f163199f9106b35645ba3b93c7e15d3
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / macros / mini / AddAnalysisTaskTOFKStar.C
1 //
2 // General macro to configure the RSN analysis task.
3 // It calls all configs desired by the user, by means
4 // of the boolean switches defined in the first lines.
5 // ---
6 // Inputs:
7 //  1) flag to know if running on MC or data
8 //  2) path where all configs are stored
9 // ---
10 // Returns:
11 //  kTRUE  --> initialization successful
12 //  kFALSE --> initialization failed (some config gave errors)
13 //
14 // Author: fbellini@cern.ch
15 // Created on 06/08/2012
16
17 AliRsnMiniAnalysisTask * AddAnalysisTaskTOFKStar
18 (
19    Bool_t      isMC,
20    Bool_t      isPP,
21    const char *path,
22    Int_t       aodFilterBit = 5,
23    AliRsnCutSetDaughterParticle::ERsnDaughterCutSet cutPiCandidate = AliRsnCutSetDaughterParticle::kTOFpidKstarPbPb2010,
24    AliRsnCutSetDaughterParticle::ERsnDaughterCutSet cutKaCandidate = AliRsnCutSetDaughterParticle::kTOFpidKstarPbPb2010,
25    Float_t     nsigmaPi = 2.0,
26    Float_t     nsigmaKa = 2.0,
27    Bool_t      enableMonitor = kTRUE,
28    Bool_t      IsMcTrueOnly = kFALSE,
29    Int_t       nmix = 0,
30    Float_t     maxDiffVzMix = 1.0,
31    Float_t     maxDiffMultMix = 10.0,
32    Float_t     maxDiffAngleMixDeg = 20.0,
33    Int_t       aodN = 0,
34    TString     outNameSuffix = ""
35 )
36 {  
37   //
38   // -- INITIALIZATION ----------------------------------------------------------------------------
39   // retrieve analysis manager
40   //
41
42   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
43    if (!mgr) {
44       ::Error("AddAnalysisTaskTOFKStarPbPb", "No analysis manager to connect to.");
45       return NULL;
46    } 
47
48    // create the task and configure 
49    TString taskName = Form("TOFKStar%s%s_%i%i", (isPP? "pp" : "PbPb"), (isMC ? "MC" : "Data"), (Int_t)cutPiCandidate,(Int_t)cutKaCandidate );
50    AliRsnMiniAnalysisTask *task = new AliRsnMiniAnalysisTask(taskName.Data(), isMC);
51    if (!isMC && !isPP){
52      Printf(Form("========== SETTING USE CENTRALITY PATCH AOD049 : %s", (aodN==49)? "yes" : "no"));
53      task->SetUseCentralityPatch(aodN==49);
54    }
55    if (isPP) 
56      task->UseMultiplicity("QUALITY");
57    else
58      task->UseCentrality("V0M");   
59    // set event mixing options
60    task->UseContinuousMix();
61    //task->UseBinnedMix();
62    task->SetNMix(nmix);
63    task->SetMaxDiffVz(maxDiffVzMix);
64    task->SetMaxDiffMult(maxDiffMultMix);
65    if (!isPP) task->SetMaxDiffAngle(maxDiffAngleMixDeg*TMath::DegToRad()); //set angle diff in rad
66    ::Info("AddAnalysisTaskTOFKStar", Form("Event mixing configuration: \n events to mix = %i \n max diff. vtxZ = cm %5.3f \n max diff multi = %5.3f \n max diff EP angle = %5.3f deg", nmix, maxDiffVzMix, maxDiffMultMix, (isPP ? 0.0 : maxDiffAngleMixDeg)));
67    
68    mgr->AddTask(task);
69    
70    //
71    // -- EVENT CUTS (same for all configs) ---------------------------------------------------------
72    //  
73    // cut on primary vertex:
74    // - 2nd argument --> |Vz| range
75    // - 3rd argument --> minimum required number of contributors
76    // - 4th argument --> tells if TPC stand-alone vertexes must be accepted
77    AliRsnCutPrimaryVertex *cutVertex = new AliRsnCutPrimaryVertex("cutVertex", 10.0, 0, kFALSE);
78    if (isPP) cutVertex->SetCheckPileUp(kTRUE);   // set the check for pileup
79    
80    // define and fill cut set for event cut
81    AliRsnCutSet *eventCuts = new AliRsnCutSet("eventCuts", AliRsnTarget::kEvent);
82    eventCuts->AddCut(cutVertex);
83    eventCuts->SetCutScheme(cutVertex->GetName());
84    // set cuts in task
85    task->SetEventCuts(eventCuts);
86    
87    //
88    // -- EVENT-ONLY COMPUTATIONS -------------------------------------------------------------------
89    //   
90    //vertex
91    Int_t vtxID = task->CreateValue(AliRsnMiniValue::kVz, kFALSE);
92    AliRsnMiniOutput *outVtx = task->CreateOutput("eventVtx", "HIST", "EVENT");
93    outVtx->AddAxis(vtxID, 400, -20.0, 20.0);
94    
95    //multiplicity or centrality
96    Int_t multID = task->CreateValue(AliRsnMiniValue::kMult, kFALSE);
97    AliRsnMiniOutput *outMult = task->CreateOutput("eventMult", "HIST", "EVENT");
98    if (isPP) 
99      outMult->AddAxis(multID, 400, 0.0, 400.0);
100    else
101      outMult->AddAxis(multID, 100, 0.0, 100.0);
102    
103    //event plane (only for PbPb)
104    Int_t planeID = task->CreateValue(AliRsnMiniValue::kPlaneAngle, kFALSE);
105    AliRsnMiniOutput *outPlane = task->CreateOutput("eventPlane", "HIST", "EVENT");
106    if (!isPP)
107      outPlane->AddAxis(planeID, 180, 0.0, TMath::Pi());
108    
109    //
110    // -- PAIR CUTS (common to all resonances) ------------------------------------------------------
111    //
112    AliRsnCutMiniPair *cutY = new AliRsnCutMiniPair("cutRapidity", AliRsnCutMiniPair::kRapidityRange);
113    cutY->SetRangeD(-0.5, 0.5);
114    
115    AliRsnCutSet *cutsPair = new AliRsnCutSet("pairCuts", AliRsnTarget::kMother);
116    cutsPair->AddCut(cutY);
117    cutsPair->SetCutScheme(cutY->GetName());
118    
119    //
120    // -- CONFIG ANALYSIS --------------------------------------------------------------------------
121    gROOT->LoadMacro(Form("%s/ConfigTOFanalysisKStar.C", path));
122    if (isMC) {
123      if (((Int_t)cutPiCandidate<4) && ((Int_t)cutKaCandidate<4))
124        Printf("========================== MC analysis - no PID used for efficiency estimation");
125      else 
126        Printf("========================== MC analysis - PID cuts used");
127    } else 
128      Printf("========================== DATA analysis - PID cuts used");
129    if (!ConfigTOFanalysisKStar(task, isMC, isPP, "", cutsPair, aodFilterBit, cutPiCandidate, cutKaCandidate, nsigmaPi, nsigmaKa, enableMonitor, isMC&IsMcTrueOnly, aodN)) return 0x0;
130    
131    //
132    // -- CONTAINERS --------------------------------------------------------------------------------
133    //
134    TString outputFileName = AliAnalysisManager::GetCommonFileName();
135    //  outputFileName += ":Rsn";
136    Printf("AddAnalysisTaskTOFKStarPbPb - Set OutputFileName : \n %s\n", outputFileName.Data() );
137
138    AliAnalysisDataContainer *output = mgr->CreateContainer(Form("RsnOut_%s",outNameSuffix.Data()), 
139                                                            TList::Class(), 
140                                                            AliAnalysisManager::kOutputContainer, 
141                                                            outputFileName);
142    mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
143    mgr->ConnectOutput(task, 1, output);
144    
145    return task;
146 }