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