AliPhysics  b0c77bb (b0c77bb)
AddTaskLc2V0bachelor_TMVAApp.C
Go to the documentation of this file.
2 
3 AliAnalysisTaskSELc2V0bachelorTMVAApp* AddTaskLc2V0bachelor_TMVAApp(TString ptBin = "_6_12", TString finname="Lc2V0bachelorCuts.root",
5  Bool_t theMCon=kTRUE,
6  Bool_t fillTree=kFALSE,
7  Bool_t onTheFly=kFALSE,
8  Bool_t keepingOnlyHIJINGbkd=kFALSE,
9  TString suffixName=""){
10 
11  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
12  if (!mgr) {
13  ::Error("AddTaskLc2V0bachelor", "No analysis manager to connect to.");
14  return NULL;
15  }
16 
17  /*
18  TString inputVariablesBDT = "massK0S,tImpParBach,tImpParV0,bachelorPt,combinedProtonProb,DecayLengthK0S*0.497/v0P,cosPAK0S,CosThetaStar,signd0";
19  TObjArray *tokens = inputVariablesBDT.Tokenize(",");
20  tokens->Print();
21  std::vector<std::string> inputNamesVec;
22  for(Int_t i=0; i<tokens->GetEntries(); i++){
23  TString variable = ((TObjString*)(tokens->At(i)))->String();
24  string tmpvar = variable.Data();
25  inputNamesVec.push_back(tmpvar);
26  }
27 
28  IClassifierReader* fBDTReader = new ReadBDT_Default(inputNamesVec);
29  */
30 
31  // cuts are stored in a TFile generated by makeTFile4CutsLc2V0bachelor.C in ./macros/
32  // set there the cuts!!!!!
33  Bool_t stdcuts=kFALSE;
34  TFile* filecuts;
35  if( finname.EqualTo("") ) {
36  stdcuts=kTRUE;
37  } else {
38  filecuts=TFile::Open(finname.Data());
39  if(!filecuts ||(filecuts&& !filecuts->IsOpen())){
40  Printf("Input file not found : check your cut object"); return NULL;
41  }
42  }
43 
44  AliRDHFCutsLctoV0* RDHFCutsLctoV0anal = new AliRDHFCutsLctoV0();
45  if (stdcuts) RDHFCutsLctoV0anal->SetStandardCutsPP2010();
46  else RDHFCutsLctoV0anal = (AliRDHFCutsLctoV0*)filecuts->Get("LctoV0AnalysisCuts");
47  RDHFCutsLctoV0anal->SetName("LctoV0AnalysisCuts");
48  RDHFCutsLctoV0anal->SetMinPtCandidate(ptMin);
49  RDHFCutsLctoV0anal->SetMaxPtCandidate(ptMax);
50  RDHFCutsLctoV0anal->SetUseCentrality(1);
51  RDHFCutsLctoV0anal->SetMinCentrality(0.);
52  RDHFCutsLctoV0anal->SetMaxCentrality(80.);
53 
54  // mm let's see if everything is ok
55  if (!RDHFCutsLctoV0anal) {
56  cout << "Specific AliRDHFCutsLctoV0 not found\n";
57  return NULL;
58  }
59 
60  TString namesTMVAvars = "massK0S,tImpParBach,tImpParV0,bachelorPt,combinedProtonProb,DecayLengthK0S*0.497/v0P,cosPAK0S,CosThetaStar,signd0";
61 
62  //CREATE THE TASK
63  printf("CREATE TASK\n");
64  AliAnalysisTaskSELc2V0bachelorTMVAApp *task = new AliAnalysisTaskSELc2V0bachelorTMVAApp("AliAnalysisTaskSELc2V0bachelorTMVAApp", RDHFCutsLctoV0anal, onTheFly);
65  // task->SetMVReader(fBDTReader);
66  task->SetNamesTMVAVariables(namesTMVAvars);
67  task->SetTMVAlibName("libvertexingHFTMVA.so");
68  task->SetTMVAlibPtBin(ptBin);
69  task->SetFillTree(fillTree);
70  task->SetMC(theMCon);
71  task->SetKeepingOnlyHIJINGBkg(keepingOnlyHIJINGbkd);
72  task->SetK0sAnalysis(kTRUE);
73  task->SetDebugLevel(0);
74  mgr->AddTask(task);
75 
76  // Create and connect containers for input/output
77  //TString outputfile = AliAnalysisManager::GetCommonFileName();
78  //TString outputfile = Form("Lc2K0Sp_tree_pA%s.root", suffixName.Data());
79  TString outputfile = Form("Lc2K0Sp_tree_pA%s%s.root", ptBin.Data(), suffixName.Data());
80  TString output1name="", output2name="", output3name="", output4name="", output5name="", output6name="";
81 
82  output1name = Form("treeList%s", suffixName.Data());
83  output2name = Form("Lc2pK0Scounter%s", suffixName.Data());
84  output3name = Form("Lc2pK0SCuts%s", suffixName.Data());
85  output4name = Form("treeSgn%s", suffixName.Data());
86  output5name = Form("treeBkg%s", suffixName.Data());
87  output6name = Form("listHistoKF%s", suffixName.Data());
88 
89  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
90  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(output1name, TList::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data()); // trees
91  mgr->ConnectOutput(task, 1, coutput1);
92 
93  AliAnalysisDataContainer *coutputLc2 = mgr->CreateContainer(output2name, TList::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data()); //counter
94  mgr->ConnectOutput(task, 2, coutputLc2);
95 
96  AliAnalysisDataContainer *coutputLc3 = mgr->CreateContainer(output3name, TList::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data()); // cuts
97  mgr->ConnectOutput(task, 3, coutputLc3);
98 
99  AliAnalysisDataContainer *coutput4 = mgr->CreateContainer(output4name, TTree::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data()); // trees
100  mgr->ConnectOutput(task, 4, coutput4);
101 
102  AliAnalysisDataContainer *coutput5 = mgr->CreateContainer(output5name, TTree::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data()); // trees
103  mgr->ConnectOutput(task, 5, coutput5);
104 
105  AliAnalysisDataContainer *coutput6 = mgr->CreateContainer(output6name, TList::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data()); // trees
106  mgr->ConnectOutput(task, 6, coutput6);
107 
108  return task;
109 
110 }
virtual void SetStandardCutsPP2010()
void SetUseCentrality(Int_t flag=1)
Double_t ptMin
void SetMaxPtCandidate(Double_t ptCand=1000.)
Definition: AliRDHFCuts.h:222
void SetMinCentrality(Float_t minCentrality=0.)
Definition: AliRDHFCuts.h:52
float Float_t
Definition: External.C:68
void SetMaxCentrality(Float_t maxCentrality=100.)
Definition: AliRDHFCuts.h:53
AliAnalysisTaskSELc2V0bachelorTMVAApp * AddTaskLc2V0bachelor_TMVAApp(TString ptBin="_6_12", TString finname="Lc2V0bachelorCuts.root", Float_t ptMin=0, Float_t ptMax=24, Bool_t theMCon=kTRUE, Bool_t fillTree=kFALSE, Bool_t onTheFly=kFALSE, Bool_t keepingOnlyHIJINGbkd=kFALSE, TString suffixName="")
void SetMinPtCandidate(Double_t ptCand=-1.)
Definition: AliRDHFCuts.h:221
bool Bool_t
Definition: External.C:53
Double_t ptMax