AliPhysics  d565ceb (d565ceb)
AddTaskDStarCharmFraction.C
Go to the documentation of this file.
1 AliAnalysisTaskSEDStarCharmFraction *AddTaskDStarCharmFraction(TString cutsFileName, Bool_t readMC = kFALSE, TString suffix = "", Double_t peakSigmaCut = 3., Double_t sidebandSigmaCut = 6., Bool_t singleSideband = kFALSE, Double_t impParMin = 0., TString fileOut = "AnalysisResults.root") {
2  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
3  if (!mgr) {
4  AliFatal("No analysis manager to connect to");
5  return NULL;
6  }
7 
8  Bool_t standardCuts = kFALSE;
9 
10  TFile *cutsFile;
11  if (cutsFileName.EqualTo("")) {
12  standardCuts = kTRUE;
13  }
14  else {
15  cutsFile = TFile::Open(cutsFileName.Data());
16  if (!cutsFile || (cutsFile && !cutsFile->IsOpen())) {
17  AliFatal("Input cut file not found");
18  return NULL;
19  }
20  }
21 
22 
24  if (standardCuts) {
25  cuts = new AliRDHFCutsDStartoKpipi();
26  cuts->SetStandardCutsPP2010();
27  }
28  else {
29  cuts = (AliRDHFCutsDStartoKpipi*) cutsFile->Get("DStartoKpipiCuts");
30  }
31  cuts->SetName("DStartoKpipiCuts");
32 
33  if (!cuts) {
34  AliFatal("Cut object not found");
35  return NULL;
36  }
37 
38  printf("CREATE TASK\n");
39 
40  AliAnalysisTaskSEDStarCharmFraction *task = new AliAnalysisTaskSEDStarCharmFraction("AliAnalysisTaskSEDStarSpectra", cuts);
41  task->SetReadMC(readMC);
42  task->SetSingleSideband(singleSideband);
43  task->SetImpParCut(impParMin);
44 
45  // Legacy: set constant width
46  Int_t nPtBins = cuts->GetNPtBins();
48  Double_t *peakCuts = new Double_t[nPtBins];
49  Double_t *sidebandCuts = new Double_t[nPtBins];
50  Double_t *sidebandWindows = new Double_t[nPtBins];
51 
52  for (Int_t i=0;i<nPtBins;i++) {
53  sigmas[i] = 0.00060;
54  peakCuts[i] = peakSigmaCut*sigmas[i];
55  sidebandCuts[i] = sidebandSigmaCut*sigmas[i]; //sideband selection starts at "sidebandSigmaCut" sigma from PDG mass
56  sidebandWindows[i] = 9.*sigmas[i]; //sideband selection has width of 9 sigma (so stops at sidebandSigmaCut+9 sigma from PDG mass)
57 
58  cout << "peakCuts[" << i << "]=" << peakCuts[i] << endl;
59  }
60 
61  /*Double_t sigma = 0.0005;
62  task->SetPeakCut(3.*sigma);
63  task->SetSidebandCut(6.*sigma);
64  task->SetSidebandWindow(9.*sigma);*/
65 
66  task->SetPeakCut(peakCuts);
67  task->SetSidebandCut(sidebandCuts);
68  task->SetSidebandWindow(sidebandWindows);
69 
70  mgr->AddTask(task);
71 
72  AliAnalysisDataContainer *cInput = mgr->GetCommonInputContainer();
73  mgr->ConnectInput(task, 0, cInput);
74 
75  AliAnalysisDataContainer *cOutputNEvents = mgr->CreateContainer(Form("cNEvents%s", suffix.Data()), TH1D::Class(), AliAnalysisManager::kOutputContainer, fileOut.Data());
76  AliAnalysisDataContainer *cOutputListCandidate = mgr->CreateContainer(Form("cListCandidate%s", suffix.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, fileOut.Data());
77  AliAnalysisDataContainer *cOutputListSignal = mgr->CreateContainer(Form("cListSignal%s", suffix.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, fileOut.Data());
78  AliAnalysisDataContainer *cOutputListSignalPrompt = mgr->CreateContainer(Form("cListSignalPrompt%s", suffix.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, fileOut.Data());
79  AliAnalysisDataContainer *cOutputListSignalFromB = mgr->CreateContainer(Form("cListSignalFromB%s", suffix.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, fileOut.Data());
80  AliAnalysisDataContainer *cOutputListBackground = mgr->CreateContainer(Form("cListBackground%s", suffix.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, fileOut.Data());
81  AliAnalysisDataContainer *cOutputCuts = mgr->CreateContainer(Form("cCuts%s", suffix.Data()), AliRDHFCutsDStartoKpipi::Class(), AliAnalysisManager::kOutputContainer, fileOut.Data());
82  AliAnalysisDataContainer *cOutputNormCount = mgr->CreateContainer(Form("cNormCount%s", suffix.Data()), AliNormalizationCounter::Class(), AliAnalysisManager::kOutputContainer, fileOut.Data());
83  AliAnalysisDataContainer *cOutputTreeCandidate = mgr->CreateContainer(Form("cTreeCandidate%s", suffix.Data()), TTree::Class(), AliAnalysisManager::kOutputContainer, fileOut.Data());
84 
85  mgr->ConnectOutput(task, 1, cOutputNEvents);
86  mgr->ConnectOutput(task, 2, cOutputListCandidate);
87  mgr->ConnectOutput(task, 3, cOutputListSignal);
88  mgr->ConnectOutput(task, 4, cOutputListSignalPrompt);
89  mgr->ConnectOutput(task, 5, cOutputListSignalFromB);
90  mgr->ConnectOutput(task, 6, cOutputListBackground);
91  mgr->ConnectOutput(task, 7, cOutputCuts);
92  mgr->ConnectOutput(task, 8, cOutputNormCount);
93  mgr->ConnectOutput(task, 9, cOutputTreeCandidate);
94 
95  return task;
96 }
AliAnalysisTaskSEDStarCharmFraction * AddTaskDStarCharmFraction(TString cutsFileName, Bool_t readMC=kFALSE, TString suffix="", Double_t peakSigmaCut=3., Double_t sidebandSigmaCut=6., Bool_t singleSideband=kFALSE, Double_t impParMin=0., TString fileOut="AnalysisResults.root")
double Double_t
Definition: External.C:58
const Int_t nPtBins
int Int_t
Definition: External.C:63
Double_t sigmas[nPtBins]
void SetSingleSideband(Bool_t singleSideband=kTRUE)
Int_t GetNPtBins() const
Definition: AliRDHFCuts.h:248
bool Bool_t
Definition: External.C:53