]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/RESONANCES/macros/train_old/AddRsnEventComputations.C
PWG2/SPECTRA -> PWGLF/SPECTRA migration
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / macros / train_old / AddRsnEventComputations.C
1 //
2 // Configuration script for monitor task with 2010 runs
3 //
4 // It contains a class definition where the cuts for each object
5 // are defined separately, functions are initialized and so on.
6 // This is used in the main function (named after the file name),
7 // which is called by the 'AddTask' function.
8 //
9
10 #if !defined(__CINT__) || defined(__MAKECINT__)
11
12    #include "TString.h"
13    #include "AliAnalysisManager.h"
14    #include "AliRsnValue.h"
15    #include "AliRsnFunction.h"
16    #include "AliRsnCutValue.h"
17    #include "AliRsnCutPrimaryVertex.h"
18    #include "AliRsnAnalysisTask.h"
19
20 #endif
21
22 Bool_t AddRsnEventComputations(Bool_t isMC, const char *options = "", const char *taskName = "RSNtask")
23 {
24    // ==================================================================================================================
25    // == PRELIMINARY OPERATIONS ========================================================================================
26    // ==================================================================================================================
27    
28    // retrieve task from manager, using its name
29    AliAnalysisManager *mgr  = AliAnalysisManager::GetAnalysisManager();
30    AliRsnAnalysisTask *task = (AliRsnAnalysisTask*)mgr->GetTask(taskName);
31    if (!task) {
32       Error("RsnConfigMonitor", "Task not found");
33       return kFALSE;
34    }
35    
36    TString opt(options);
37    opt.ToUpper();
38    opt.ReplaceAll(" ", "");
39    
40    Bool_t central    = opt.Contains("CENT");
41    Bool_t peripheral = opt.Contains("PERI");
42    
43    // ==================================================================================================================
44    // == EVENT CUTS ====================================================================================================
45    // ==================================================================================================================
46
47    // event cuts are added directly to a cutSet in the task
48    // we create all and then add thos which are needed
49    
50    // primary vertex:
51    // - 2nd argument --> |Vz| range
52    // - 3rd argument --> minimum required number of contributors
53    // - 4th argument --> tells if TPC stand-alone vertexes must be accepted
54    // we switch on the check for pileup
55    AliRsnCutPrimaryVertex *cutVertex = new AliRsnCutPrimaryVertex("cutVertex", 10.0, 0, kFALSE);
56    cutVertex->SetCheckPileUp(kTRUE);
57       
58    // centrality:
59    // - 2nd      argument --> one of the centrality evaluation methods
60    // - 3rd, 4th argument --> centrality ranges in percentile (0-10 for central, 60-70 for peripheral)
61    AliRsnCutValue *cutCentrality = 0x0;
62    if (central) 
63       cutCentrality = new AliRsnCutValue("cutCentral", AliRsnValue::kEventCentralityV0,  0.0, 10.0);
64    else if (peripheral)
65       cutCentrality = new AliRsnCutValue("cutPeripheral", AliRsnValue::kEventCentralityV0, 60.0, 70.0);
66    
67    // primary vertex is always used
68    task->GetEventCuts()->AddCut(cutVertex);
69    
70    // set cut scheme as AND of primary vertex and centrality, if initialized
71    if (cutCentrality) {
72       task->GetEventCuts()->AddCut(cutCentrality);
73       task->GetEventCuts()->SetCutScheme(Form("%s & %s", cutVertex->GetName(), cutCentrality->GetName()));
74    } else {
75       task->GetEventCuts()->SetCutScheme(cutVertex->GetName());
76    }
77    ::Info("AddEventStuff", "Scheme for event cuts: %s", task->GetEventCuts()->GetCutScheme().Data());
78    
79    // ==================================================================================================================
80    // == EVENT FUNCTIONS ===============================================================================================
81    // ==================================================================================================================
82
83    // we want to add an AliRsnFunction to compute multiplicity distribution
84    // it is needed in order to know how many events we have in each multiplicity bin
85    
86    // axes
87    AliRsnValue *axisEvMultSPD = new AliRsnValue("MultSPD", AliRsnValue::kEventMultSPD, 0.0, 150.0, 1.0);
88    AliRsnValue *axisEvMultMC  = new AliRsnValue("MultMC" , AliRsnValue::kEventMultMC , 0.0, 150.0, 1.0);
89
90    // create function and add axis
91    AliRsnFunction *fcnEv = new AliRsnFunction;
92    if (!fcnEv->AddAxis(axisEvMultSPD)) return kFALSE;
93    if (isMC && !fcnEv->AddAxis(axisEvMultMC)) return kFALSE;
94
95    // add functions to pairs
96    task->GetInfo()->AddEventFunction(fcnEv);
97    
98    return kTRUE;
99 }