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