- updates for AN67
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / macrosJPSI / AddTask_jbook_JPsi.C
1 AliAnalysisTask *AddTask_jbook_JPsi(TString prod="", Bool_t gridconf=kFALSE) {
2   //get the current analysis manager
3   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
4   if (!mgr) {
5     Error("AddTask_jbook_JPsi", "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/ConfigJpsi_jb_PbPb.C";   // gsi config
31   else if(!gSystem->Exec("alien_cp alien:///alice/cern.ch/user/j/jbook/PWGDQ/dielectron/macrosJPSI/ConfigJpsi_jb_PbPb.C ."))
32     configFile=Form("%s/ConfigJpsi_jb_PbPb.C",gSystem->pwd());                        // alien config
33   else
34     configFile="$ALICE_ROOT/PWGDQ/dielectron/macrosJPSI/ConfigJpsi_jb_PbPb.C"; // aliroot config
35
36   if(!gridconf)
37     configFile="$ALICE_ROOT/PWGDQ/dielectron/macrosJPSI/ConfigJpsi_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="ConfigJpsi_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<6; ++i) { //nDie defined in config file
52     AliDielectron *jpsi=ConfigJpsi_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   //create output container
67   AliAnalysisDataContainer *coutput1 =
68     mgr->CreateContainer("jbook_tree",
69                          TTree::Class(),
70                          AliAnalysisManager::kExchangeContainer,
71                          "jbook_default");
72   
73   AliAnalysisDataContainer *cOutputHist1 =
74     mgr->CreateContainer("jbook_QA",
75                          TList::Class(),
76                          AliAnalysisManager::kOutputContainer,
77                          "jbook.root");
78
79   AliAnalysisDataContainer *cOutputHist2 =
80     mgr->CreateContainer("jbook_CF",
81                          TList::Class(),
82                          AliAnalysisManager::kOutputContainer,
83                          "jbook.root");
84   
85   AliAnalysisDataContainer *cOutputHist3 =
86     mgr->CreateContainer("jbook_EventStat",
87                          TH1D::Class(),
88                          AliAnalysisManager::kOutputContainer,
89                          "jbook.root");
90   
91   mgr->ConnectInput(task,  0, mgr->GetCommonInputContainer());
92   mgr->ConnectOutput(task, 0, coutput1 );
93   mgr->ConnectOutput(task, 1, cOutputHist1);
94   mgr->ConnectOutput(task, 2, cOutputHist2);
95   mgr->ConnectOutput(task, 3, cOutputHist3);
96   
97   return task;
98 }