AliPhysics  d9e9949 (d9e9949)
AddTaskSignificance.C
Go to the documentation of this file.
1 AliAnalysisTaskSESignificance *AddTaskSignificance(TString filename="cuts4SignifMaximDplus.root",Int_t decCh=0,Bool_t readMC=kFALSE,Int_t flagOPartAntiPart=0,Int_t nofsteps=8,AliAnalysisTaskSESignificance::FeedDownEnum fromcb=AliAnalysisTaskSESignificance::kBoth, TString usercomment = "username", TString cutsobjname="loosecuts")
2 {
3  //
4  // Test macro for the AliAnalysisTaskSE for D meson candidates
5  // Invariant mass histogram and
6  // association with MC truth (using MC info in AOD)
7  // R. Bala, bala@to.infn.it
8  // C. Bianchin, cbianchi@pd.infn.it
9  // Get the pointer to the existing analysis manager via the static access method.
10  //============================================================================
11  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
12  if (!mgr) {
13  ::Error("AddTaskSignificance", "No analysis manager to connect to.");
14  return NULL;
15  }
16 
17  TFile* filecuts=TFile::Open(filename.Data());
18  if(!filecuts ||(filecuts&& !filecuts->IsOpen())){
19  cout<<"Input file not found: exit"<<endl;
20  return;
21  }
22 
23  AliRDHFCuts *analysiscuts=0x0;
24  TString suffix="";
25  TString suffix2="";
26  if(flagOPartAntiPart==1) suffix2="P"; //P=particle, A=antiparticle
27  if(flagOPartAntiPart==-1) suffix2="A";
28  if(fromcb==AliAnalysisTaskSESignificance::kCharmOnly) suffix2+="prompt";
29  if(fromcb==AliAnalysisTaskSESignificance::kBeautyOnly) suffix2+="feeddown";
30 
31 
32  //Analysis cuts
33  switch (decCh){
34  case 0:
35  analysiscuts = (AliRDHFCutsDplustoKpipi*)filecuts->Get(cutsobjname);
36  suffix=Form("Dplus%s",suffix2.Data());
37  break;
38  case 1:
39  analysiscuts = (AliRDHFCutsD0toKpi*)filecuts->Get(cutsobjname);
40  suffix=Form("D0%s",suffix2.Data());
41  break;
42  case 2:
43  analysiscuts = (AliRDHFCutsDStartoKpipi*)filecuts->Get(cutsobjname);
44  suffix=Form("Dstar%s",suffix2.Data());
45  break;
46  case 3:
47  analysiscuts = (AliRDHFCutsDstoKKpi*)filecuts->Get(cutsobjname);
48  suffix=Form("Ds%s",suffix2.Data());
49  break;
50  case 4:
51  analysiscuts = (AliRDHFCutsD0toKpipipi*)filecuts->Get(cutsobjname);
52  suffix=Form("D04%s",suffix2.Data());
53  break;
54  case 5:
55  analysiscuts = (AliRDHFCutsLctopKpi*)filecuts->Get(cutsobjname);
56  suffix=Form("Lc%s",suffix2.Data());
57  break;
58  }
59  //ptbins
60 
61  if(!analysiscuts){
62  cout<<"Specific AliRDHFCuts not found"<<endl;
63  return;
64  }
65 
66  TString centr=Form("%.0f%.0f",analysiscuts->GetMinCentrality(),analysiscuts->GetMaxCentrality());
67  suffix+=centr;
68 
69  const Int_t nptbins=analysiscuts->GetNPtBins();
70  Float_t* ptbins=analysiscuts->GetPtBinLimits();
71 
72  // Analysis task
73  const Int_t npars=analysiscuts->GetNVarsForOpt();//numbers of var for opt
74  Bool_t* varsforopt=analysiscuts->GetVarsForOpt();
75  cout<<"pt bins= "<<nptbins<<" varsforopt= "<<npars<<" nvars= "<<analysiscuts->GetNVars()<<endl;
76  Int_t* nofcells=new Int_t[npars];//={4,4,4,4};
77  Float_t** looses;
78  looses=new Float_t*[npars];
79  Float_t** tights;
80  tights=new Float_t*[npars];
81  TString axisTitle[npars];
82  TString parname="";
83 
84  for (Int_t ivop=0;ivop<npars;ivop++){
85  looses[ivop]=new Float_t[nptbins];
86  tights[ivop]=new Float_t[nptbins];
87  nofcells[ivop]=nofsteps;
88  }
89 
90  Int_t count=0;
91 
92  for (Int_t ip=0;ip<nptbins;ip++){
93  for(Int_t iv=0;iv<analysiscuts->GetNVars();iv++){
94  if(varsforopt[iv]){
95  looses[count][ip]=analysiscuts->GetCutValue(iv,ip);
96  axisTitle[count]=(analysiscuts->GetVarNames())[iv];
97  parname=Form("par%dptbin%d",count,ip);
98  TParameter<float>* par=(TParameter<float>*)filecuts->Get(parname.Data());
99  tights[count][ip]=par->GetVal();
100  count++;
101  }
102  }
103  count=0;
104  }
105 
106  //creation TList of AliMultiDimVector
107  TList *listMDV=new TList();
108  listMDV->SetOwner();
109  listMDV->SetName("listMDV");
110 
111  for (Int_t ip=0;ip<nptbins;ip++){
112  Float_t *loosescut=new Float_t[npars];
113  Float_t *tightscut=new Float_t[npars];
114  for(Int_t i=0;i<npars;i++){
115  loosescut[i]=looses[i][ip];
116  tightscut[i]=tights[i][ip];
117  }
118  Float_t ptbincut[2]={ptbins[ip],ptbins[ip+1]};
119  TString mdvname=Form("multiDimVectorPtBin%d",ip);
120  AliMultiDimVector *mv=new AliMultiDimVector(mdvname.Data(),"MultiDimVector",1,ptbincut,npars,nofcells,loosescut,tightscut,axisTitle);
121  listMDV->Add(mv);
122  }
123 
124  AliAnalysisTaskSESignificance *sigTask = new AliAnalysisTaskSESignificance("SignificanceAnalysis",listMDV,analysiscuts,decCh,AliRDHFCuts::kAll);//AliRDHFCuts::kCandidate
125  sigTask->SetReadMC(readMC);
126  sigTask->SetBFeedDown(fromcb);
127  sigTask->SetDebugLevel(0);
128  sigTask->SetFillWithPartAntiPartBoth(flagOPartAntiPart);
129  sigTask->SetUseSelBit(kTRUE);
130  mgr->AddTask(sigTask);
131 
132  TString contname=Form("cinputSig%s",suffix.Data());
133  // Create containers for input/output
134  AliAnalysisDataContainer *cinputSig = mgr->CreateContainer(contname.Data(),TChain::Class(),AliAnalysisManager::kInputContainer);
135  TString outputfile = AliAnalysisManager::GetCommonFileName();
136  usercomment = "_" + usercomment;
137  TString outputhistos = outputfile += ":PWG3_D2H_Significance";
138  outputhistos += usercomment;
139 
140  contname=Form("coutputSig%s",suffix.Data());
141  contname += usercomment;
142  AliAnalysisDataContainer *coutputSig = mgr->CreateContainer(contname.Data(),TList::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
143  contname=Form("coutputmv%s",suffix.Data());
144  contname += usercomment;
145  AliAnalysisDataContainer *coutputmv = mgr->CreateContainer(contname.Data(),TList::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
146  contname=Form("cloosecuts%s",suffix.Data());
147  contname += usercomment;
148  AliAnalysisDataContainer *coutputcuts = mgr->CreateContainer(contname.Data(),AliRDHFCuts::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
149 
150 
151  mgr->ConnectInput(sigTask,0,mgr->GetCommonInputContainer());
152 
153  mgr->ConnectOutput(sigTask,1,coutputSig);
154 
155  mgr->ConnectOutput(sigTask,2,coutputmv);
156 
157  mgr->ConnectOutput(sigTask,3,coutputcuts);
158 
159  return sigTask;
160 }
161 
162 
Float_t GetMaxCentrality() const
Definition: AliRDHFCuts.h:282
const char * filename
Definition: TestFCM.C:1
Int_t GetNVars() const
Definition: AliRDHFCuts.h:250
TString * GetVarNames() const
Definition: AliRDHFCuts.h:251
Float_t GetCutValue(Int_t iVar, Int_t iPtBin) const
Float_t GetMinCentrality() const
Definition: AliRDHFCuts.h:281
Class for cuts on AOD reconstructed D+->Kpipi.
int Int_t
Definition: External.C:63
float Float_t
Definition: External.C:68
Int_t decCh
Bool_t * GetVarsForOpt() const
Definition: AliRDHFCuts.h:252
Int_t GetNVarsForOpt() const
Definition: AliRDHFCuts.h:253
Float_t * GetPtBinLimits() const
Definition: AliRDHFCuts.h:248
AliAnalysisTaskSESignificance * AddTaskSignificance(TString filename="cuts4SignifMaximDplus.root", Int_t decCh=0, Bool_t readMC=kFALSE, Int_t flagOPartAntiPart=0, Int_t nofsteps=8, AliAnalysisTaskSESignificance::FeedDownEnum fromcb=AliAnalysisTaskSESignificance::kBoth, TString usercomment="username", TString cutsobjname="loosecuts")
Int_t GetNPtBins() const
Definition: AliRDHFCuts.h:249
bool Bool_t
Definition: External.C:53
Int_t nptbins