New version of task for prompt charm fraction analysis (A. Rossi)
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AddTaskCharmFraction.C
index 64db31a880c8d3c873a45b248b3feb0775701d19..f106e0a64e7b946ee98ccbd4c5794e3a219d3d6e 100644 (file)
@@ -1,14 +1,4 @@
-AliAnalysisTaskCharmFraction* AddTaskCharmFraction(
-         const char* fileout="d0D0.root",
-        Bool_t sideband=kFALSE,
-        Bool_t setD0usecuts=kTRUE,
-        Bool_t setcheckMC=kTRUE,
-        Bool_t setcheckMC_prompt=kTRUE,
-        Bool_t setcheckMC_fromB=kFALSE,
-        Bool_t setcheckMC_D0=kTRUE,
-        Bool_t setcheckMC_2prongs=kTRUE,
-        Bool_t setSkipD0star=kFALSE,
-        Bool_t setStudyPureBack=kFALSE)
+AliAnalysisTaskSECharmFraction* AddTaskCharmFraction(const char* fileout="d0D0.root",Int_t switchMC[5])
 {  
   //
   // Configuration macro for the task to analyze the fraction of prompt charm
@@ -16,6 +6,15 @@ AliAnalysisTaskCharmFraction* AddTaskCharmFraction(
   // andrea.rossi@ts.infn.it
   //
   //==========================================================================
+
+  //######## !!! THE SWITCH FOR MC ANALYSIS IS NOT IMPLEMENTED YET!!! ##########à
+  switchMC[0]=1;
+  switchMC[1]=1;
+  switchMC[2]=1;
+  switchMC[3]=1;
+  switchMC[4]=1;
+  Int_t last=0;
+
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   if (!mgr) {
     ::Error("AddTaskCharmFraction", "No analysis manager to connect to.");
@@ -26,13 +25,12 @@ AliAnalysisTaskCharmFraction* AddTaskCharmFraction(
   str.ReplaceAll(".root","");
   str.Prepend("_");
 
-  AliAnalysisTaskCharmFraction *hfTask;
-  if(!sideband) {
-    hfTask = new AliAnalysisTaskCharmFraction("CharmFraction",10);
-  } else {
-    hfTask= new AliAnalysisTaskCharmFraction("CharmFractionSideB",10);
-    hfTask->SetSideBands(-2.);
-  }
+  AliAnalysisTaskSECharmFraction *hfTask;
+  hfTask = new AliAnalysisTaskSECharmFraction("AliAnalysisTaskSECharmFraction");
+    
+
+  /*  ############### HERE THE POSSIBILITY TO SWITCH ON/OFF THE TLISTS AND MC SELECTION WILL BE SET #########à
 
   hfTask->SetUseCuts(setD0usecuts);
   hfTask->SetCheckMC(setcheckMC);
@@ -41,286 +39,191 @@ AliAnalysisTaskCharmFraction* AddTaskCharmFraction(
   hfTask->SetCheckMC_prompt(setcheckMC_prompt);
   hfTask->SetCheckMC_fromB(setcheckMC_fromB);
   hfTask->SetCheckMC_fromDstar(setSkipD0star);
-  hfTask->SetStudyPureBackground(setStudyPureBack);
+  hfTask->SetStudyPureBackground(setStudyPureBack);*/
   //  hfTask->SetSideBands(0);
   //  hfTask->SetDebugLevel(2);
   mgr->AddTask(hfTask);
  
-  //Now the same for sidebands
-  /*AliAnalysisTaskCharmFraction *hfTaskSideB 
-
-  
-  hfTaskSideB->SetUseCuts(fD0usecuts);
-  hfTaskSideB->SetCheckMC(fcheckMC);
-  hfTaskSideB->SetCheckMC_D0(fcheckMC_D0);
-  hfTaskSideB->SetCheckMC_2prongs(fcheckMC_2prongs);
-  hfTaskSideB->SetCheckMC_prompt(fcheckMC_prompt);
-  hfTaskSideB->SetCheckMC_fromB(fcheckMC_fromB);
-  hfTaskSideB->SetCheckMC_fromDstar(fSkipD0star);
-  hfTaskSideB->SetStudyPureBackground(fStudyPureBack);
-
-  //  hfTaskSideB->SetDebugLevel(2);
-  mgr->AddTask(hfTaskSideB);
-  */
  
-
+  
   // Create containers for input/output
-  AliAnalysisDataContainer *cinput =   mgr->GetCommonInputContainer();//mgr->CreateContainer("cinput",TChain::Class(),AliAnalysisManager::kInputContainer);
+  AliAnalysisDataContainer *cinput =   mgr->GetCommonInputContainer();
+  //mgr->CreateContainer("cinput",TChain::Class(),AliAnalysisManager::kInputContainer);
   mgr->ConnectInput(hfTask,0,cinput);
-  //  mgr->ConnectInput(hfTaskSideB,0,cinput);
+  
 
   //Now container for general properties histograms
-  containername="coutputCptd0d0";
+  containername="coutputNentries";
   containername.Append(str.Data());
-  AliAnalysisDataContainer *coutputCptd0d0 = mgr->CreateContainer(containername.Data(),TH2::Class(),
+  AliAnalysisDataContainer *coutputNentries = mgr->CreateContainer(containername.Data(),TH1F::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
                                                           fileout);
-  mgr->ConnectOutput(hfTask,0,coutputCptd0d0);
+  
+  mgr->ConnectOutput(hfTask,1,coutputNentries);
 
-  containername="coutputSecVtxXY";
+  containername="coutputSignalType";
   containername.Append(str.Data());
-  AliAnalysisDataContainer *coutputSecVtxXY = mgr->CreateContainer(containername.Data(),TH2::Class(),
+  AliAnalysisDataContainer *coutputSignalType = mgr->CreateContainer(containername.Data(),TH1F::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
                                                           fileout);
-  mgr->ConnectOutput(hfTask,1,coutputSecVtxXY);
+  
+  mgr->ConnectOutput(hfTask,2,coutputSignalType);
 
 
-  containername="coutputd0d0";
+  containername="coutputSignalType_LsCuts";
   containername.Append(str.Data());
-  AliAnalysisDataContainer *coutputd0d0 = mgr->CreateContainer(containername.Data(),TH1::Class(),
+  AliAnalysisDataContainer *coutputSignalType_LsCuts = mgr->CreateContainer(containername.Data(),TH1F::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
                                                           fileout);
-  mgr->ConnectOutput(hfTask,2,coutputd0d0);
+  
+  mgr->ConnectOutput(hfTask,3,coutputSignalType_LsCuts);
 
-  containername="coutputCpt";
+
+ containername="coutputSignalType_TghCuts";
   containername.Append(str.Data());
-  AliAnalysisDataContainer *coutputCpt = mgr->CreateContainer(containername.Data(),TH1::Class(),
+  AliAnalysisDataContainer *coutputSignalType_TghCuts = mgr->CreateContainer(containername.Data(),TH1F::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
                                                           fileout);
-  mgr->ConnectOutput(hfTask,3,coutputCpt);
+  
+  mgr->ConnectOutput(hfTask,4,coutputSignalType_TghCuts);
 
-  containername="coutputSecVtxZ";
+  // Now container for TLists 
+  last=5;
+  //##########  NO CUTS TLISTS CONTAINER ##############à
+  containername="coutput_nc_sign";
   containername.Append(str.Data());
-  AliAnalysisDataContainer *coutputSecVtxZ = mgr->CreateContainer(containername.Data(),TH1::Class(),
+  AliAnalysisDataContainer *coutput_nc_sign = mgr->CreateContainer(containername.Data(),TList::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
                                                           fileout);
-  mgr->ConnectOutput(hfTask,4,coutputSecVtxZ);
+  mgr->ConnectOutput(hfTask,last,coutput_nc_sign);
+  last++;
 
-  containername="coutputSecVtxX";
+
+  containername="coutput_nc_back";
   containername.Append(str.Data());
-  AliAnalysisDataContainer *coutputSecVtxX = mgr->CreateContainer(containername.Data(),TH1::Class(),
+  AliAnalysisDataContainer *coutput_nc_back = mgr->CreateContainer(containername.Data(),TList::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
                                                           fileout);
-  mgr->ConnectOutput(hfTask,5,coutputSecVtxX);
+  mgr->ConnectOutput(hfTask,last,coutput_nc_back);
+  last++;
 
-  containername="coutputSecVtxY";
+  containername="coutput_nc_fromB";
   containername.Append(str.Data());
-  AliAnalysisDataContainer *coutputSecVtxY = mgr->CreateContainer(containername.Data(),TH1::Class(),
+  AliAnalysisDataContainer *coutput_nc_fromB = mgr->CreateContainer(containername.Data(),TList::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
                                                           fileout);
-  mgr->ConnectOutput(hfTask,6,coutputSecVtxY);
+  mgr->ConnectOutput(hfTask,last,coutput_nc_fromB);
+  last++;
+
 
-  containername="coutputSecVtxPhi";
+  containername="coutput_nc_fromDstar";
   containername.Append(str.Data());
AliAnalysisDataContainer *coutputSecVtxPhi = mgr->CreateContainer(containername.Data(),TH1::Class(),
 AliAnalysisDataContainer *coutput_nc_fromDstar = mgr->CreateContainer(containername.Data(),TList::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
                                                           fileout);
-  mgr->ConnectOutput(hfTask,7,coutputSecVtxPhi);
+  mgr->ConnectOutput(hfTask,last,coutput_nc_fromDstar);
+  last++;
 
 
-  //Now container for d0D0  
-  AliAnalysisDataContainer **coutput=new AliAnalysisDataContainer*[10];
-  containername="coutputAll";
+  containername="coutput_nc_other";
   containername.Append(str.Data());
-  AliAnalysisDataContainer *coutputAll = mgr->CreateContainer(containername.Data(),TH1::Class(),
+  AliAnalysisDataContainer *coutput_nc_other = mgr->CreateContainer(containername.Data(),TList::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
                                                           fileout);
+  mgr->ConnectOutput(hfTask,last,coutput_nc_other);
+  last++;
 
 
-  TString name="coutput";
-  for(Int_t j=0;j<10;j++){
-    containername=name;
-    containername+=j;
-    containername.Append(str.Data());
-    coutput[j] = mgr->CreateContainer(containername.Data(),TH1::Class(),
-                                     AliAnalysisManager::kOutputContainer, 
-                                     fileout);
-    
-    mgr->ConnectOutput(hfTask,j+8,coutput[j]);
-  }
-  mgr->ConnectOutput(hfTask,18,coutputAll);
-  //Now container for MC d0D0  
-  AliAnalysisDataContainer **coutputMC=new AliAnalysisDataContainer*[10];
-  containername="coutputAllMC";
+  //######### LOOSE CUTS TLISTS CONTAINER #############
+  containername="coutput_ls_sign";
   containername.Append(str.Data());
-  AliAnalysisDataContainer *coutputAllMC = mgr->CreateContainer(containername.Data(),TH1::Class(),
+  AliAnalysisDataContainer *coutput_ls_sign = mgr->CreateContainer(containername.Data(),TList::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
                                                           fileout);
+  mgr->ConnectOutput(hfTask,last,coutput_ls_sign);
+  last++;
 
 
-  name="coutputMC";
-  for(Int_t j=0;j<10;j++){
-    containername=name;
-    containername+=j;
-    containername.Append(str.Data());
-    coutputMC[j] = mgr->CreateContainer(containername.Data(),TH1::Class(),
-                                     AliAnalysisManager::kOutputContainer, 
-                                     fileout);
-    
-    mgr->ConnectOutput(hfTask,j+19,coutputMC[j]);
-  }
-  mgr->ConnectOutput(hfTask,29,coutputAllMC);
-
-  //Now container for histo with d0 with respect to True Vtx
-  AliAnalysisDataContainer **coutputd0VtxTrue=new AliAnalysisDataContainer*[10];
-  containername="coutputd0VtxTrueAll";
+  containername="coutput_ls_back";
   containername.Append(str.Data());
-  AliAnalysisDataContainer *coutputd0VtxTrueAll = mgr->CreateContainer(containername.Data(),TH1::Class(),
+  AliAnalysisDataContainer *coutput_ls_back = mgr->CreateContainer(containername.Data(),TList::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
                                                           fileout);
+  mgr->ConnectOutput(hfTask,last,coutput_ls_back);
+  last++;
 
-
-  name="coutputd0VtxTrue";
-  for(Int_t j=0;j<10;j++){
-    containername=name;
-    containername+=j;
-    containername.Append(str.Data());
-    coutputd0VtxTrue[j] = mgr->CreateContainer(containername.Data(),TH1::Class(),
-                                     AliAnalysisManager::kOutputContainer, 
-                                     fileout);
-    
-    mgr->ConnectOutput(hfTask,j+30,coutputd0VtxTrue[j]);
-  }
-  mgr->ConnectOutput(hfTask,40,coutputd0VtxTrueAll);
-  //INV MASS
-  containername="coutputD0InvMassAll";
-  containername.Append(str.Data());
-  AliAnalysisDataContainer *coutputD0InvMassAll = mgr->CreateContainer(containername.Data(),TH1::Class(),
-                                                                      AliAnalysisManager::kOutputContainer, 
-                                                                      fileout);
-  mgr->ConnectOutput(hfTask,41,coutputD0InvMassAll);
-  containername="coutputD0MCInvMassAll";
+  containername="coutput_ls_fromB";
   containername.Append(str.Data());
-  AliAnalysisDataContainer *coutputD0MCInvMassAll = mgr->CreateContainer(containername.Data(),TH1::Class(),
-                                                                        AliAnalysisManager::kOutputContainer, 
-                                                                        fileout);
-  mgr->ConnectOutput(hfTask,42,coutputD0MCInvMassAll);
-  
- ////////
- //NOW THE SAME FOR SIDE BANDS
- /*
- //Now container for general properties histograms
-
- AliAnalysisDataContainer *coutputSBCptd0d0 = mgr->CreateContainer("coutputSBCptd0d0",TH2::Class(),
-                                                                  AliAnalysisManager::kOutputContainer, 
-                                                          "d0D0SideB.root");
- mgr->ConnectOutput(hfTaskSideB,0,coutputSBCptd0d0);
-
-  AliAnalysisDataContainer *coutputSBSecVtxXY = mgr->CreateContainer("coutputSBSecVtxXY",TH2::Class(),
+  AliAnalysisDataContainer *coutput_ls_fromB = mgr->CreateContainer(containername.Data(),TList::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
-                                                          "d0D0SideB.root");
-  mgr->ConnectOutput(hfTaskSideB,1,coutputSBSecVtxXY);
+                                                          fileout);
+  mgr->ConnectOutput(hfTask,last,coutput_ls_fromB);
+  last++;
 
 
-  AliAnalysisDataContainer *coutputSBd0d0 = mgr->CreateContainer("coutputSBd0d0",TH1::Class(),
+  containername="coutput_ls_fromDstar";
+  containername.Append(str.Data());
+  AliAnalysisDataContainer *coutput_ls_fromDstar = mgr->CreateContainer(containername.Data(),TList::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
-                                                          "d0D0SideB.root");
-  mgr->ConnectOutput(hfTaskSideB,2,coutputSBd0d0);
+                                                          fileout);
+  mgr->ConnectOutput(hfTask,last,coutput_ls_fromDstar);
+  last++;
 
-  AliAnalysisDataContainer *coutputSBCpt = mgr->CreateContainer("coutputSBCpt",TH1::Class(),
-                                                          AliAnalysisManager::kOutputContainer, 
-                                                          "d0D0SideB.root");
-  mgr->ConnectOutput(hfTaskSideB,3,coutputSBCpt);
 
-  AliAnalysisDataContainer *coutputSBSecVtxZ = mgr->CreateContainer("coutputSBSecVtxZ",TH1::Class(),
+  containername="coutput_ls_other";
+  containername.Append(str.Data());
+  AliAnalysisDataContainer *coutput_ls_other = mgr->CreateContainer(containername.Data(),TList::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
-                                                          "d0D0SideB.root");
-  mgr->ConnectOutput(hfTaskSideB,4,coutputSBSecVtxZ);
+                                                          fileout);
+  mgr->ConnectOutput(hfTask,last,coutput_ls_other);
+  last++;
 
-  AliAnalysisDataContainer *coutputSBSecVtxX = mgr->CreateContainer("coutputSBSecVtxX",TH1::Class(),
-                                                          AliAnalysisManager::kOutputContainer, 
-                                                          "d0D0SideB.root");
-  mgr->ConnectOutput(hfTaskSideB,5,coutputSBSecVtxX);
 
-  AliAnalysisDataContainer *coutputSBSecVtxY = mgr->CreateContainer("coutputSBSecVtxY",TH1::Class(),
-                                                          AliAnalysisManager::kOutputContainer, 
-                                                          "d0D0SideB.root");
-  mgr->ConnectOutput(hfTaskSideB,6,coutputSBSecVtxY);
 
- AliAnalysisDataContainer *coutputSBSecVtxPhi = mgr->CreateContainer("coutputSBSecVtxPhi",TH1::Class(),
+  //######### TIGHT CUTS TLISTS CONTAINER #############
+    containername="coutput_tgh_sign";
+  containername.Append(str.Data());
+  AliAnalysisDataContainer *coutput_tgh_sign = mgr->CreateContainer(containername.Data(),TList::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
-                                                          "d0D0SideB.root");
-  mgr->ConnectOutput(hfTaskSideB,7,coutputSBSecVtxPhi);
+                                                          fileout);
+  mgr->ConnectOutput(hfTask,last,coutput_tgh_sign);
+  last++;
 
 
-  //Now container for d0D0SideB  
-  AliAnalysisDataContainer **coutputSB=new AliAnalysisDataContainer*[10];
-  AliAnalysisDataContainer *coutputSBAll = mgr->CreateContainer("coutputSBAll",TH1::Class(),
+  containername="coutput_tgh_back";
+  containername.Append(str.Data());
+  AliAnalysisDataContainer *coutput_tgh_back = mgr->CreateContainer(containername.Data(),TList::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
-                                                          "d0D0SideB.root");
-
+                                                          fileout);
+  mgr->ConnectOutput(hfTask,last,coutput_tgh_back);
+  last++;
 
-  TString name="coutputSB",strname;
-  for(Int_t j=0;j<10;j++){
-    strname=name;
-    strname+=j;
-    coutputSB[j] = mgr->CreateContainer(strname.Data(),TH1::Class(),
-                                     AliAnalysisManager::kOutputContainer, 
-                                     "d0D0SideB.root");
-    
-    mgr->ConnectOutput(hfTaskSideB,j+8,coutputSB[j]);
-  }
-  mgr->ConnectOutput(hfTaskSideB,18,coutputSBAll);
-  //Now container for MC d0D0SideB  
-  AliAnalysisDataContainer **coutputSBMC=new AliAnalysisDataContainer*[10];
-  AliAnalysisDataContainer *coutputSBAllMC = mgr->CreateContainer("coutputSBAllMC",TH1::Class(),
+  containername="coutput_tgh_fromB";
+  containername.Append(str.Data());
+  AliAnalysisDataContainer *coutput_tgh_fromB = mgr->CreateContainer(containername.Data(),TList::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
-                                                          "d0D0SideB.root");
+                                                          fileout);
+  mgr->ConnectOutput(hfTask,last,coutput_tgh_fromB);
+  last++;
 
 
-  name="coutputSBMC";
-  for(Int_t j=0;j<10;j++){
-    strname=name;
-    strname+=j;
-    coutputSBMC[j] = mgr->CreateContainer(strname.Data(),TH1::Class(),
-                                     AliAnalysisManager::kOutputContainer, 
-                                     "d0D0SideB.root");
-    
-    mgr->ConnectOutput(hfTaskSideB,j+19,coutputSBMC[j]);
-  }
-  mgr->ConnectOutput(hfTaskSideB,29,coutputSBAllMC);
-
-  //Now container for histo with d0 with respect to True Vtx
-  AliAnalysisDataContainer **coutputSBd0VtxTrue=new AliAnalysisDataContainer*[10];
-  AliAnalysisDataContainer *coutputSBd0VtxTrueAll = mgr->CreateContainer("coutputSBd0VtxTrueAll",TH1::Class(),
+  containername="coutput_tgh_fromDstar";
+  containername.Append(str.Data());
+  AliAnalysisDataContainer *coutput_tgh_fromDstar = mgr->CreateContainer(containername.Data(),TList::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
-                                                          "d0D0SideB.root");
-
+                                                          fileout);
+  mgr->ConnectOutput(hfTask,last,coutput_tgh_fromDstar);
+  last++;
 
-  name="coutputSBd0VtxTrue";
-  for(Int_t j=0;j<10;j++){
-    strname=name;
-    strname+=j;
-    coutputSBd0VtxTrue[j] = mgr->CreateContainer(strname.Data(),TH1::Class(),
-                                     AliAnalysisManager::kOutputContainer, 
-                                     "d0D0SideB.root");
-    
-    mgr->ConnectOutput(hfTaskSideB,j+30,coutputSBd0VtxTrue[j]);
-  }
-  mgr->ConnectOutput(hfTaskSideB,40,coutputSBd0VtxTrueAll);
 
-//INV MASS
- AliAnalysisDataContainer *coutputSBD0InvMassAll = mgr->CreateContainer("coutputSBD0InvMassAll",TH1::Class(),
+  containername="coutput_tgh_other";
+  containername.Append(str.Data());
+  AliAnalysisDataContainer *coutput_tgh_other = mgr->CreateContainer(containername.Data(),TList::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
-                                                          "d0D0SideB.root");
- mgr->ConnectOutput(hfTaskSideB,41,coutputSBD0InvMassAll);
-
- AliAnalysisDataContainer *coutputSBD0MCInvMassAll = mgr->CreateContainer("coutputSBD0MCInvMassAll",TH1::Class(),
-                                                                     AliAnalysisManager::kOutputContainer, 
-                                                          "d0D0SideB.root");
- mgr->ConnectOutput(hfTaskSideB,42,coutputSBD0MCInvMassAll);
+                                                          fileout);
+  mgr->ConnectOutput(hfTask,last,coutput_tgh_other);
+  
 
- */
 
   return hfTask;
 }