- updates for AN67
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / macrosJPSI / AddTask_jbook_JPsiQA.C
1 AliAnalysisTask *AddTask_jbook_JPsiQA(TString prod="", Bool_t gridconf=kFALSE){
2   //get the current analysis manager
3   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
4   if (!mgr) {
5     Error("AddTask_jbook_JPsiQA", "No analysis manager found.");
6     return 0;
7   }
8
9   //Do we have an MC handler?
10   Bool_t hasMC = kFALSE;
11   TString list = gSystem->Getenv("LIST");
12   if( list.IsNull()) list=prod;
13   if( list.Contains("LHC10h")   || list.Contains("LHC11h")   ) hasMC=kFALSE;
14   if( list.Contains("LHC11a10") || list.Contains("LHC12a17") ) hasMC=kTRUE;
15
16   //Do we have an AOD handler?
17   Bool_t isAOD=(mgr->GetInputEventHandler()->IsA()==AliAODInputHandler::Class() ? kTRUE : kFALSE);
18
19   // set AOD debug levels
20   if(isAOD) {
21     mgr->AddClassDebug("AliAODTrack", AliLog::kFatal);
22     mgr->AddClassDebug("AliAODpidUtil", AliLog::kInfo); 
23   }
24   
25   //set config file name
26   TString configFile("");
27   printf("%s \n",gSystem->pwd());
28   TString trainRoot=gSystem->Getenv("TRAIN_ROOT");
29   if (!trainRoot.IsNull())
30     configFile="$TRAIN_ROOT/jbook_jpsi/ConfigJpsiQA_jb_PbPb.C";   // gsi config
31   else if(!gSystem->Exec("alien_cp alien:///alice/cern.ch/user/j/jbook/PWGDQ/dielectron/macrosJPSI/ConfigJpsiQA_jb_PbPb.C ."))
32     configFile=Form("%s/ConfigJpsiQA_jb_PbPb.C",gSystem->pwd());                        // alien config
33   else
34     configFile="$ALICE_ROOT/PWGDQ/dielectron/macrosJPSI/ConfigJpsiQA_jb_PbPb.C"; // aliroot config
35
36   if(!gridconf)
37     configFile="$ALICE_ROOT/PWGDQ/dielectron/macrosJPSI/ConfigJpsiQA_jb_PbPb.C"; // aliroot config
38
39   //create task and add it to the manager
40   AliAnalysisTaskMultiDielectron *task=new AliAnalysisTaskMultiDielectron("MultiDieData");
41   task->SetTriggerMask(AliVEvent::kMB+AliVEvent::kCentral+AliVEvent::kSemiCentral);
42   if (!hasMC) task->UsePhysicsSelection();
43   mgr->AddTask(task);
44   
45   //load dielectron configuration file
46   TString checkconfig="ConfigJpsiQA_jb_PbPb";
47   if (!gROOT->GetListOfGlobalFunctions()->FindObject(checkconfig.Data()))
48     gROOT->LoadMacro(configFile.Data());
49
50   //add dielectron analysis with different cuts to the task
51   for (Int_t i=0; i<nDie; ++i){ //nDie defined in config file
52     AliDielectron *jpsi=ConfigJpsiQA_jb_PbPb(i,list);
53     if (jpsi ) task->AddDielectron(jpsi);
54     if (jpsi ) printf("add: %s\n",jpsi->GetName());
55   }
56   
57   //Add event filter
58   AliDielectronEventCuts *eventCuts=new AliDielectronEventCuts("eventCuts","Vertex Track && |vtxZ|<10 && ncontrib>0");
59   if (isAOD) eventCuts->SetVertexType(AliDielectronEventCuts::kVtxAny);
60   eventCuts->SetRequireVertex();
61   eventCuts->SetMinVtxContributors(1);
62   eventCuts->SetVertexZ(-10.,10.);
63   eventCuts->SetCentralityRange(0.0,80.0);
64   task->SetEventFilter(eventCuts);
65
66   
67   //create output container
68   AliAnalysisDataContainer *coutput1 =
69     mgr->CreateContainer("jbookQA_tree",
70                          TTree::Class(),
71                          AliAnalysisManager::kExchangeContainer,
72                          "jbook_default");
73   
74   AliAnalysisDataContainer *cOutputHist1 =
75     mgr->CreateContainer("jbookQA",
76                          TList::Class(),
77                          AliAnalysisManager::kOutputContainer,
78                          "jbookQA.root");
79
80   
81   AliAnalysisDataContainer *cOutputHist2 =
82     mgr->CreateContainer("jbookQA_CF",
83                          TList::Class(),
84                          AliAnalysisManager::kOutputContainer,//AliAnalysisManager::kExchangeContainer,
85                          "jbookQA.root");
86     
87   AliAnalysisDataContainer *cOutputHist3 =
88     mgr->CreateContainer("jbookQA_EventStat",
89                          TH1D::Class(),
90                          AliAnalysisManager::kOutputContainer,
91                          "jbookQA.root");
92   
93   mgr->ConnectInput(task,  0, mgr->GetCommonInputContainer());
94   mgr->ConnectOutput(task, 0, coutput1 );
95   mgr->ConnectOutput(task, 1, cOutputHist1);
96   mgr->ConnectOutput(task, 2, cOutputHist2);
97   mgr->ConnectOutput(task, 3, cOutputHist3);
98   
99   return task;
100 }