AliPhysics  63e47e1 (63e47e1)
AddTaskLc2V0bachpA_TMVA.C
Go to the documentation of this file.
2  Bool_t theMCon=kTRUE,
3  Bool_t onTheFly=kFALSE,
4  Bool_t keepingOnlyHIJINGbkd=kFALSE,
5  TString suffixName="",
7  TString estimatorFilename = "", Double_t refMult = 27.99){
8 
9  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
10  if (!mgr) {
11  ::Error("AddTaskLc2V0bachelor", "No analysis manager to connect to.");
12  return NULL;
13  }
14 
15  // cuts are stored in a TFile generated by makeTFile4CutsLc2V0bachelor.C in ./macros/
16  // set there the cuts!!!!!
17  Bool_t stdcuts=kFALSE;
18  TFile* filecuts;
19  if( finname.EqualTo("") ) {
20  stdcuts=kTRUE;
21  } else {
22  filecuts=TFile::Open(finname.Data());
23  if(!filecuts ||(filecuts&& !filecuts->IsOpen())){
24  AliFatal("Input file not found : check your cut object");
25  }
26  }
27 
28  AliRDHFCutsLctoV0* RDHFCutsLctoV0anal = new AliRDHFCutsLctoV0();
29  if (stdcuts) RDHFCutsLctoV0anal->SetStandardCutsPP2010();
30  else RDHFCutsLctoV0anal = (AliRDHFCutsLctoV0*)filecuts->Get("LctoV0AnalysisCuts");
31  RDHFCutsLctoV0anal->SetName("LctoV0AnalysisCuts");
32  RDHFCutsLctoV0anal->SetMinPtCandidate(-1.);
33  RDHFCutsLctoV0anal->SetMaxPtCandidate(10000.);
34 
35 
36  // mm let's see if everything is ok
37  if (!RDHFCutsLctoV0anal) {
38  cout << "Specific AliRDHFCutsLctoV0 not found\n";
39  return;
40  }
41 
42 
43  //CREATE THE TASK
44  printf("CREATE TASK\n");
45  AliAnalysisTaskSELc2V0bachelorTMVA *task = new AliAnalysisTaskSELc2V0bachelorTMVA("AliAnalysisTaskSELc2V0bachelorTMVA", RDHFCutsLctoV0anal, onTheFly);
46 
47  task->SetMC(theMCon);
48  task->SetKeepingKeepingOnlyHIJINGBkg(keepingOnlyHIJINGbkd);
49  task->SetK0sAnalysis(kTRUE);
50  task->SetDebugLevel(0);
51  task->SetAnalysisType(system);
52 
53  // attempt to load histogram for multiplicity vs zvtx correction
54 
55  if (estimatorFilename.EqualTo("")) {//Warn if undefined
56  printf("Warning: Estimator file not defined, correction of Ntrk will not be performed!\n");}
57  else { //Load file if defined
58  TFile *fileEstimator = TFile::Open(estimatorFilename.Data());
59  if (!fileEstimator) {
60  AliFatal("File with multiplicity estimator not found! Please check the filepath and retry.\n");
61  return;
62  }
63  task->SetReferenceMultiplicity(refMult);
64  const Char_t* profilebasename="SPDmult10";
65 
66  switch (system) {
67  case AliAnalysisTaskSELc2V0bachelorTMVA::kpPb2013: //LHC13b & LHC13c
68  task->SetIspA(kTRUE);
69  const Char_t* periodNames[2] = {"LHC13b", "LHC13c"};
70  TProfile* multEstimatorAvg[2];
71  for (Int_t ip = 0; ip < 2; ip++) {
72  cout << "Trying to get " << Form("%s_%s",profilebasename,periodNames[ip]) << endl;
73  multEstimatorAvg[ip] = (TProfile*)(fileEstimator->Get(Form("%s_%s",profilebasename,periodNames[ip]))->Clone(Form("%s_%s_clone",profilebasename,periodNames[ip])));
74  if (!multEstimatorAvg[ip]) { // mult estimator not found
75  AliFatal(Form("Multiplicity estimator for %s not found! Please check that your estimator file contains %s_%s",periodNames[ip],profilebasename,periodNames[ip]));
76  return;
77  }
78  }
79  task->SetMultVsZProfileLHC13b(multEstimatorAvg[0]);
80  task->SetMultVsZProfileLHC13c(multEstimatorAvg[1]);
81  break;
82 
83  case AliAnalysisTaskSELc2V0bachelorTMVA::kpPb2016: //LHC16q & LHC16t
84  task->SetIspA(kTRUE);
85  const Char_t* periodNames[4] = {"LHC16q_265499to265525_265309to265387","LHC16q_265435","LHC16q_265388to265427","LHC16t_267163to267166"};
86  TProfile* multEstimatorAvg[4];
87  for (Int_t ip = 0; ip < 4; ip++) {
88  cout << "Trying to get " << Form("%s_%s",profilebasename,periodNames[ip]) << endl;
89  multEstimatorAvg[ip] = (TProfile*)(fileEstimator->Get(Form("%s_%s",profilebasename,periodNames[ip]))->Clone(Form("%s_%s_clone",profilebasename,periodNames[ip])));
90  if (!multEstimatorAvg[ip]) { // mult estimator not found
91  AliFatal(Form("Multiplicity estimator for %s not found! Please check that your estimator file contains %s_%s",periodNames[ip],profilebasename,periodNames[ip]));
92  return;
93  }
94  }
95  task->SetMultVsZProfileLHC16qt1stBunch(multEstimatorAvg[0]);
96  task->SetMultVsZProfileLHC16qt2ndBunch(multEstimatorAvg[1]);
97  task->SetMultVsZProfileLHC16qt3rdBunch(multEstimatorAvg[2]);
98  task->SetMultVsZProfileLHC16qt4thBunch(multEstimatorAvg[3]);
99  break;
101  task->SetIspA(kFALSE);
102  const Char_t* periodNames[3] = {"LHC16j","LHC16k","LHC16l"};
103  TProfile* multEstimatorAvg[3];
104  for (Int_t ip = 0; ip < 3; ip++) {
105  cout << "Trying to get " << Form("%s_%s",profilebasename,periodNames[ip]) << endl;
106  multEstimatorAvg[ip] = (TProfile*)(fileEstimator->Get(Form("%s_%s",profilebasename,periodNames[ip]))->Clone(Form("%s_%s_clone",profilebasename,periodNames[ip])));
107  if (!multEstimatorAvg[ip]) { // mult estimator not found
108  AliFatal(Form("Multiplicity estimator for %s not found! Please check that your estimator file contains %s_%s",periodNames[ip],profilebasename,periodNames[ip]));
109  return;
110  }
111  }
112  task->SetMultVsZProfileLHC16j(multEstimatorAvg[0]);
113  task->SetMultVsZProfileLHC16k(multEstimatorAvg[1]);
114  task->SetMultVsZProfileLHC16l(multEstimatorAvg[2]);
115  break;
117  task->SetIspA(kFALSE);
118  const Char_t* periodNames[4] = {"LHC10b","LHC10c","LHC10d","LHC10e"};
119  TProfile* multEstimatorAvg[4];
120  for (Int_t ip = 0; ip < 4; ip++) {
121  cout << "Trying to get " << Form("%s_%s",profilebasename,periodNames[ip]) << endl;
122  multEstimatorAvg[ip] = (TProfile*)(fileEstimator->Get(Form("%s_%s",profilebasename,periodNames[ip]))->Clone(Form("%s_%s_clone",profilebasename,periodNames[ip])));
123  if (!multEstimatorAvg[ip]) { // mult estimator not found
124  AliFatal(Form("Multiplicity estimator for %s not found! Please check that your estimator file contains %s_%s",periodNames[ip],profilebasename,periodNames[ip]));
125  return;
126  }
127  }
128  task->SetMultVsZProfileLHC10b(multEstimatorAvg[0]);
129  task->SetMultVsZProfileLHC10c(multEstimatorAvg[1]);
130  task->SetMultVsZProfileLHC10d(multEstimatorAvg[2]);
131  task->SetMultVsZProfileLHC10e(multEstimatorAvg[3]);
132  break;
133  default:
134  AliFatal("Multiplicity profiles specified but analysis mode incorrect. Please check collision system and retry.");
135  return;
136  }
137 
138  }
139 
140  mgr->AddTask(task);
141 
142  // Create and connect containers for input/output
143  //TString outputfile = AliAnalysisManager::GetCommonFileName();
144  TString outputfile = Form("Lc2K0Sp_tree_pA%s.root", suffixName.Data());
145  TString output1name="", output2name="", output3name="", output4name="", output5name="", output6name="", output7name="", output8name="", output9name="";
146 
147  output1name = Form("treeList%s", suffixName.Data());
148  output2name = Form("listCounters%s", suffixName.Data());
149  output3name = Form("Lc2pK0SCuts%s", suffixName.Data());
150  output4name = Form("treeSgn%s", suffixName.Data());
151  output5name = Form("treeBkg%s", suffixName.Data());
152  output6name = Form("listHistoKF%s", suffixName.Data());
153  output7name = Form("weights%s", suffixName.Data());
154  output8name = Form("multhists%s", suffixName.Data());
155  output9name = Form("listProfiles", suffixName.Data());
156 
157  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
158  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(output1name, TList::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data()); // trees
159  mgr->ConnectOutput(task, 1, coutput1);
160 
161  AliAnalysisDataContainer *coutputLc2 = mgr->CreateContainer(output2name,TList::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data()); //counter
162  mgr->ConnectOutput(task, 2, coutputLc2);
163 
164  AliAnalysisDataContainer *coutputLc3 = mgr->CreateContainer(output3name, TList::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data()); // cuts
165  mgr->ConnectOutput(task, 3, coutputLc3);
166 
167  AliAnalysisDataContainer *coutput4 = mgr->CreateContainer(output4name, TTree::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data()); // trees
168  mgr->ConnectOutput(task, 4, coutput4);
169 
170  AliAnalysisDataContainer *coutput5 = mgr->CreateContainer(output5name, TTree::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data()); // trees
171  mgr->ConnectOutput(task, 5, coutput5);
172 
173  AliAnalysisDataContainer *coutput6 = mgr->CreateContainer(output6name, TList::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data()); // trees
174  mgr->ConnectOutput(task, 6, coutput6);
175 
176  AliAnalysisDataContainer *coutput7 = mgr->CreateContainer(output7name, TList::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data()); // weights
177  mgr->ConnectOutput(task, 7, coutput7);
178 
179  AliAnalysisDataContainer *coutput8 = mgr->CreateContainer(output8name, TList::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data()); //multiplicity-based histograms (zvtx dist, etc)
180  mgr->ConnectOutput(task, 8, coutput8);
181 
182  AliAnalysisDataContainer *coutput9 = mgr->CreateContainer(output9name, TList::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data()); //input multiplicity profiles
183  mgr->ConnectOutput(task, 9, coutput9);
184 
185  return task;
186 
187 }
double Double_t
Definition: External.C:58
virtual void SetStandardCutsPP2010()
char Char_t
Definition: External.C:18
void SetMaxPtCandidate(Double_t ptCand=1000.)
Definition: AliRDHFCuts.h:221
int Int_t
Definition: External.C:63
enum for setting analysis system/year (for loading profile histograms for multiplicity correction) ...
void SetMinPtCandidate(Double_t ptCand=-1.)
Definition: AliRDHFCuts.h:220
bool Bool_t
Definition: External.C:53
AliAnalysisTaskSELc2V0bachelorTMVA * AddTaskLc2V0bachpA_TMVA(TString finname="Lc2V0bachelorCuts.root", Bool_t theMCon=kTRUE, Bool_t onTheFly=kFALSE, Bool_t keepingOnlyHIJINGbkd=kFALSE, TString suffixName="", Int_t system=AliAnalysisTaskSELc2V0bachelorTMVA::kpPb2013, TString estimatorFilename="", Double_t refMult=27.99)