- updates for AN67
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / macrosJPSI / AddTask_jbook_JPsi.C
CommitLineData
ef0426e6 1AliAnalysisTask *AddTask_jbook_JPsi(TString prod="", Bool_t gridconf=kFALSE) {
8c06b662 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 }
d6aec652 8
8c06b662 9 //Do we have an MC handler?
2d7910f3 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;
2d7910f3 15
8c06b662 16 //Do we have an AOD handler?
17 Bool_t isAOD=(mgr->GetInputEventHandler()->IsA()==AliAODInputHandler::Class() ? kTRUE : kFALSE);
94c26f30 18
d6aec652 19 // set AOD debug levels
20 if(isAOD) {
21 mgr->AddClassDebug("AliAODTrack", AliLog::kFatal);
ef0426e6 22 mgr->AddClassDebug("AliAODpidUtil", AliLog::kInfo);
d6aec652 23 }
ef0426e6 24
8c06b662 25 //set config file name
94c26f30 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
8c06b662 38
8c06b662 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);
94c26f30 44
8c06b662 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
ef0426e6 51 for (Int_t i=0; i<6; ++i) { //nDie defined in config file
2d7910f3 52 AliDielectron *jpsi=ConfigJpsi_jb_PbPb(i,list);
8c06b662 53 if (jpsi ) task->AddDielectron(jpsi);
ef0426e6 54 if (jpsi ) printf("add: %s\n",jpsi->GetName());
8c06b662 55 }
94c26f30 56
8c06b662 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
8c06b662 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}