new dielectron tasks from Remi
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / macrosLMEE / AddTask_Remi_LMEEPbPb2011AOD_SemiCent1.C
1 AliAnalysisTask *AddTask_Remi_LMEEPbPb2011AODSemiCent1(Char_t* outputFileName="LMEEoutput.root", Bool_t runAll=kFALSE,Bool_t setMC=kFALSE,Bool_t getFromAlien=kFALSE, Bool_t PIDbaseline=kFALSE, Bool_t rejOnly=kTRUE) {
2
3   Bool_t bESDANA=kFALSE; //Autodetect via InputHandler
4   //get the current analysis manager
5   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
6   if (!mgr) {
7         Error("AddTask_Remi_LMEEPbPb2011", "No analysis manager found.");
8         return 0;
9   }
10
11
12 //  create task and add it to the manager
13 //      gSystem->AddIncludePath("$ALICE_ROOT/PWGDQ/dielectron/macrosLMEE");
14
15
16   TString configBasePath("$TRAIN_ROOT/cbaumann_dielectron/");
17   TString trainRoot=gSystem->Getenv("TRAIN_ROOT");
18   //  if (trainRoot.IsNull()) configBasePath= "/home/tanizaki/nfs/LMee_Deflection/";
19   if (trainRoot.IsNull()) configBasePath= "$ALICE_ROOT/PWGDQ/dielectron/macrosLMEE/";
20
21
22   if (getFromAlien &&
23       (!gSystem->Exec("alien_cp alien:///alice/cern.ch/user/c/cbaumann/PWGDQ/dielectron/macrosLMEE/ConfigRemiLMEEPbPb2011AOD.C .")) &&
24       (!gSystem->Exec("alien_cp alien:///alice/cern.ch/user/c/cbaumann/PWGDQ/dielectron/macrosLMEE/LMEECutLibRemi.C ."))
25       ) {
26     configBasePath=Form("%s/",gSystem->pwd());
27   }
28
29
30   TString configFile("ConfigRemiLMEEPbPb2011AOD.C");
31   TString configLMEECutLib("LMEECutLibRemi.C");
32
33   TString configFilePath(configBasePath+configFile);
34   TString configLMEECutLibPath(configBasePath+configLMEECutLib);
35
36   //AOD Usage currently tested with separate task, to be merged
37   if (mgr->GetInputEventHandler()->IsA()==AliAODInputHandler::Class()){
38         ::Info("AddTaskLMEEPbPb2011", "no dedicated AOD configuration");
39   }
40   else if (mgr->GetInputEventHandler()->IsA()==AliESDInputHandler::Class()){
41         ::Info("AddTaskLMEEPbPb2011AOD","switching on ESD specific code");
42         bESDANA=kTRUE;
43   }
44
45
46   //Do we have an MC handler?
47   Bool_t hasMC=setMC;
48   if (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()!=0x0)
49         hasMC=kTRUE;
50
51
52
53   if (!gROOT->GetListOfGlobalFunctions()->FindObject(configLMEECutLib.Data()))
54         gROOT->LoadMacro(configLMEECutLibPath.Data());
55   if (!gROOT->GetListOfGlobalFunctions()->FindObject(configFile.Data()))
56         gROOT->LoadMacro(configFilePath.Data());
57
58
59   LMEECutLibRemi* cutlib = new LMEECutLibRemi();
60   AliAnalysisTaskMultiDielectron *task=new AliAnalysisTaskMultiDielectron("MultiDiEData");
61   if (!hasMC) task->UsePhysicsSelection();
62   task->SetTriggerMask(AliVEvent::kMB+AliVEvent::kCentral+AliVEvent::kSemiCentral);
63 //  task->SelectCollisionCandidates(AliVEvent::kMB+AliVEvent::kCentral+AliVEvent::kSemiCentral);
64 //  task->SetRejectPileup();
65   task->SelectCollisionCandidates(AliVEvent::kAny);  
66   task->SetEventFilter(cutlib->GetEventCuts(LMEECutLibRemi::kPbPb2011TPCandTOF)); //
67
68   //load dielectron configuration file
69
70   //add dielectron analysis with different cuts to the task
71
72   AliDielectron *lowmass2=ConfigRemiLMEEPbPb2011AOD(2,hasMC,bESDANA);
73   task->AddDielectron(lowmass2);
74   printf("add: %s\n",lowmass2->GetName());
75
76
77   mgr->AddTask(task);
78
79   //create output container
80   AliAnalysisDataContainer *coutput1 =
81         mgr->CreateContainer("Remi_LMEEPbPb2011_tree",
82                 TTree::Class(),
83                 AliAnalysisManager::kExchangeContainer,
84                 outputFileName);
85
86   AliAnalysisDataContainer *cOutputHist1 =
87         mgr->CreateContainer("Remi_LMEEPbPb2011_out",
88                 TList::Class(),
89                 AliAnalysisManager::kOutputContainer,
90                 outputFileName);
91
92   AliAnalysisDataContainer *cOutputHist2 =
93         mgr->CreateContainer("Remi_LMEEPbPb2011_CF",
94                 TList::Class(),
95                 AliAnalysisManager::kOutputContainer,
96                 outputFileName);
97
98   AliAnalysisDataContainer *cOutputHist3 =
99         mgr->CreateContainer("Remi_EventStatPbPb2011",
100                 TH1D::Class(),
101                 AliAnalysisManager::kOutputContainer,
102                 outputFileName);
103
104
105   mgr->ConnectInput(task,  0, mgr->GetCommonInputContainer());
106   mgr->ConnectOutput(task, 0, coutput1 );
107   mgr->ConnectOutput(task, 1, cOutputHist1);
108   mgr->ConnectOutput(task, 2, cOutputHist2);
109   mgr->ConnectOutput(task, 3, cOutputHist3);
110
111   return task;
112 }