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