New class for normalization studies (Giacomo)
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / macros / AddTaskDplus.C
1 AliAnalysisTaskSEDplus *AddTaskDplus(TString filename="./DplustoKpipiCuts.root",Bool_t storeNtuple=kFALSE,
2                                      Bool_t readMC=kFALSE)
3 {
4   //                                                                                                                                    
5   // Test macro for the AliAnalysisTaskSE for D+ candidates 
6
7   //Invariant mass histogram and                                                 
8   // association with MC truth (using MC info in AOD)                                                                                   
9   //  R. Bala, bala@to.infn.it                                                                                                                                  
10   // Get the pointer to the existing analysis manager via the static access method.                                                     
11   //==============================================================================                                                      
12   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
13   if (!mgr) {
14     ::Error("AddTaskDplus", "No analysis manager to connect to.");
15     return NULL;
16   }
17
18   TFile* filecuts=new TFile(filename.Data());
19   if(!filecuts->IsOpen()){
20     cout<<"Input file not found: exit"<<endl;
21     return;
22   }
23   
24   
25   //Analysis Task
26
27   
28    AliRDHFCutsDplustoKpipi* analysiscuts=new AliRDHFCutsDplustoKpipi();
29   analysiscuts = (AliRDHFCutsDplustoKpipi*)filecuts->Get("AnalysisCuts");
30
31   AliRDHFCutsDplustoKpipi* prodcuts=new AliRDHFCutsDplustoKpipi();
32   prodcuts = (AliRDHFCutsDplustoKpipi*)filecuts->Get("ProdCuts");
33   
34   //AliRDHFCutsDplustoKpipi *prodcuts = (AliRDHFCutsDplustoKpipi*)fileCuts->Get("ProdCuts");
35   //AliRDHFCutsDplustoKpipi *analysiscuts = (AliRDHFCutsDplustoKpipi*)fileCuts->Get("AnalysisCuts");
36
37   
38   AliAnalysisTaskSEDplus *dplusTask = new AliAnalysisTaskSEDplus("DplusAnalysis",analysiscuts,prodcuts,storeNtuple);
39   dplusTask->SetReadMC(readMC);
40   dplusTask->SetDoLikeSign(kTRUE);
41   //  dplusTask->SetUseTPCpid(kTRUE);
42   //dplusTask->SetUseTOFpid(kTRUE);
43   dplusTask->SetDebugLevel(0);
44   dplusTask->SetMassLimits(0.2);
45   mgr->AddTask(dplusTask);
46   
47   // Create containers for input/output 
48   
49   AliAnalysisDataContainer *cinputDplus = mgr->CreateContainer("cinputDplus",TChain::Class(),
50                                                                AliAnalysisManager::kInputContainer);
51   TString outputfile = AliAnalysisManager::GetCommonFileName();
52   outputfile += ":PWG3_D2H_InvMassDplus";
53   
54   AliAnalysisDataContainer *coutputDplusCuts = mgr->CreateContainer("coutputDplusCuts",TList::Class(),
55                                                                     AliAnalysisManager::kOutputContainer,
56                                                                     outputfile.Data());
57   
58   AliAnalysisDataContainer *coutputDplus = mgr->CreateContainer("coutputDplus",TList::Class(),
59                                                                 AliAnalysisManager::kOutputContainer,
60                                                                 outputfile.Data());
61   AliAnalysisDataContainer *coutputDplusNorm = mgr->CreateContainer("coutputDplusNorm",AliNormalizationCounter::Class(),
62                                                                 AliAnalysisManager::kOutputContainer,
63                                                                 outputfile.Data());
64   
65   if(storeNtuple){
66     AliAnalysisDataContainer *coutputDplus2 = mgr->CreateContainer("coutputDplus2",TNtuple::Class(),
67                                                                    AliAnalysisManager::kOutputContainer,
68                                                                    "InvMassDplus_nt1.root");
69     
70     coutputDplus2->SetSpecialOutput();
71   }
72   mgr->ConnectInput(dplusTask,0,mgr->GetCommonInputContainer());
73   
74   mgr->ConnectOutput(dplusTask,1,coutputDplus);
75   
76   mgr->ConnectOutput(dplusTask,2,coutputDplusCuts);
77
78   mgr->ConnectOutput(dplusTask,3,coutputDplusNorm);  
79   if(storeNtuple){
80     mgr->ConnectOutput(dplusTask,4,coutputDplus2);
81   }
82   return dplusTask;
83 }