Cascade analysis code moved in Cascades folder
[u/mrichter/AliRoot.git] / PWGLF / STRANGENESS / Cascades / macros / runProofCascadePbPb.C
CommitLineData
fba64b41 1void runProofCascadePbPb(
2 TString proofCluster = "mnicassi@alice-caf.cern.ch",//kiaf.sdfarm.kr", //skaf.saske.sk"
3 TString alirootVer = "VO_ALICE@AliRoot::v5-30-01-AN",
4 TString rootVer = "VO_ALICE@ROOT::v5-30-06-1",
5 TString dataset = "/alice/sim/LHC11f5_000139514",
6 TString outFileMC = "CascadePerformance.root",
7 TString outFileData = "CascadeAna.root",
8 Bool_t runperformancetask= kTRUE,
9 Bool_t useMC = kTRUE,
10 Bool_t dataonalien = kFALSE,
11 Float_t centrlowlim = 0.,
12 Float_t centruplim = 90.,
13 TString centrest = "V0M",
14 Float_t vtxlim = 10.,
15 Bool_t kextrasel = kFALSE,
16 Bool_t acccut = kFALSE,
17 Bool_t krelaunchvertexers= kFALSE,
18 Int_t nEvents = 1.0*1e7,
19 Int_t nEventsSkip = 0) {
f9a6cab5 20
21 gEnv->SetValue("XSec.GSI.DelegProxy","2");
22
23 TString alirootMode = ""; // STEERBase,ESD,AOD,ANALYSIS,ANALYSISalice (default aliroot mode)
24 TString extraLibs;
25 TList *list = new TList();
26 alirootMode="ALIROOT";
fba64b41 27 extraLibs+= "ANALYSIS:OADB:ANALYSISalice:CORRFW";
f9a6cab5 28 // sets $ALIROOT_MODE on each worker to let proof to know to run in special mode
29 list->Add(new TNamed("ALIROOT_MODE", alirootMode.Data()));
30 list->Add(new TNamed("ALIROOT_EXTRA_LIBS", extraLibs.Data()));
31 if (dataonalien) list->Add(new TNamed("ALIROOT_ENABLE_ALIEN", "1"));
32
33 // REM: same version of AliRoot on client!
34 TProof::Mgr(proofCluster.Data())->SetROOTVersion(rootVer.Data()); //If not using the default version, do it the first time only
35 TProof::Open(proofCluster.Data());
fba64b41 36
f9a6cab5 37 // enable n workers per machine
38// TProof::Open(proofCluster.Data(),"workers=nx")
39 // enable less workers
40// TProof::Open(proofCluster.Data(),"workers=20"); //For performance reasons, try to avoid it.
41 if (!gProof) {
42 Error("runProof.C","Connection to AF failed.");
43 return;
44 }
fba64b41 45
f9a6cab5 46 gProof->EnablePackage(alirootVer.Data(), list);
47
fba64b41 48
f9a6cab5 49 Analysis(dataset.Data(), outFileMC, outFileData,
50 useMC, nEvents, nEventsSkip,
51 centrlowlim, centruplim, centrest,
fba64b41 52 vtxlim, kextrasel,
53 runperformancetask, acccut, krelaunchvertexers);
f9a6cab5 54
55}
56
57//________________________________________________________________________
58void Analysis(TString dataset, TString outFileMC, TString outFileData,
59 Bool_t useMC, Int_t nEvents, Int_t nEventsSkip,
60 Float_t centrlowlim, Float_t centruplim, TString centrest,
fba64b41 61 Float_t vtxlim,
62 Bool_t kextrasel, Bool_t runperformancetask, Bool_t acccut, Bool_t krelaunchvertexers) {
63
f9a6cab5 64
65 TString format = GetFormatFromDataSet(dataset);
66
67 // ALICE stuff
fba64b41 68 // create manager
f9a6cab5 69 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
70 if (!mgr) mgr = new AliAnalysisManager("Test train");
71
fba64b41 72 InputHandlerSetup(format,runperformancetask);
f9a6cab5 73
74 // compile analysis task
75 if (runperformancetask) gProof->Load("AliAnalysisTaskCheckPerformanceCascadePbPb.cxx++");
76 else gProof->Load("AliAnalysisTaskCheckCascadePbPb.cxx++");
77
fba64b41 78 cout<<"Format"<<format.Data()<<endl;
d08623be 79
fba64b41 80 if (!format.CompareTo("ESD")) {
d08623be 81 // physics selection
82 gROOT->ProcessLine(".L $ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
83 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(useMC);
84
85 // centrality selection
fba64b41 86 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
87 AliCentralitySelectionTask *taskCentr = AddTaskCentrality();
88 if (useMC) {
89 taskCentr->SetMCInput();
90 taskCentr->DontUseCleaning(); // for injected MC
91 }
92 }
93
94
95 // add PID response task
96 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
97 AliAnalysisTaskPIDResponse *pidTask = AddTaskPIDResponse(useMC);
f9a6cab5 98
99 // create task
100 if (runperformancetask) {
101 AliAnalysisTaskCheckPerformanceCascadePbPb *task = new AliAnalysisTaskCheckPerformanceCascadePbPb("AliAnalysisTaskCheckPerformanceCascadePbPb");
fba64b41 102 task->SetApplyAccCut (acccut);
103 task->SetRejectEventPileUp(kFALSE);
104
f9a6cab5 105 } else {
106 AliAnalysisTaskCheckCascadePbPb *task = new AliAnalysisTaskCheckCascadePbPb("AliAnalysisTaskCheckCascadePbPb");
f9a6cab5 107 }
108
f9a6cab5 109 task->SetAnalysisType (format);
fba64b41 110 task->SetRelaunchV0CascVertexers (krelaunchvertexers);
f9a6cab5 111 task->SetQualityCutZprimVtxPos (kTRUE); // selects vertices in +-10cm
112 task->SetQualityCutNoTPConlyPrimVtx (kTRUE); // retains only events with tracking + SPD vertex
113 task->SetQualityCutTPCrefit (kTRUE); // requires TPC refit flag to be true to select a track
114 task->SetQualityCut80TPCcls (kTRUE); // rejects tracks that have less than 80 clusters in the TPC
115 task->SetExtraSelections (kextrasel); // used to add other selection cuts
fba64b41 116 task->SetCentralityLowLim (centrlowlim); // setting centrality selection variables
f9a6cab5 117 task->SetCentralityUpLim (centruplim);
118 task->SetCentralityEst (centrest);
119 task->SetVertexRange (vtxlim);
120
f9a6cab5 121 // create output container
fba64b41 122 if (runperformancetask) AliAnalysisDataContainer *output = mgr->CreateContainer("clist", TList::Class(), AliAnalysisManager::kOutputContainer, outFileMC);
123 else AliAnalysisDataContainer *output = mgr->CreateContainer("clist", TList::Class(), AliAnalysisManager::kOutputContainer, outFileData);
f9a6cab5 124
125 // add task to the manager
126 mgr->AddTask(task);
127
fba64b41 128 task->SelectCollisionCandidates();
129
f9a6cab5 130 // connect input and output
131 mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
132 mgr->ConnectOutput(task, 1, output);
133
134 // run analysis
135 mgr->InitAnalysis();
136 // process dataset
137 mgr->StartAnalysis("proof", dataset.Data(), nEvents, nEventsSkip); // single dataset
fba64b41 138 //mgr->StartAnalysis("proof","/alice/sim/LHC11f5_000139514|/alice/sim/LHC11f5_000139517",nEvents, nEventsSkip); // multiple dataset
f9a6cab5 139
140}
141
142//________________________________________________________________________
143TString GetFormatFromDataSet(TString dataset) {
144
145// Info("runProof.C","Detecting format from dataset (may take while, depends on network connection)...");
146 TString dsTreeName;
147 if (dataset.Contains("#")) {
148 Info("runProof.C",Form("Detecting format from dataset name '%s' ...",dataset.Data()));
149 dsTreeName=dataset(dataset.Last('#'),dataset.Length());
150 } else {
151 Info("runProof.C",Form("Detecting format from dataset '%s' (may take while, depends on network connection) ...",dataset.Data()));
152 TFileCollection *ds = gProof->GetDataSet(dataset.Data());
153 if (!ds) {
154 Error(Form("Dataset %s doesn't exist on proof cluster!!!!",dataset.Data()));
155 return "";
156 }
157 dsTreeName = ds->GetDefaultTreeName();
158 }
159
160 if (dsTreeName.Contains("esdTree")) {
161 Info("runProof.C","ESD input format detected ...");
162 return "ESD";
163 } else if (dsTreeName.Contains("aodTree")) {
164 Info("runProof.C","AOD input format detected ...");
165 return "AOD";
166 } else {
167 Error("runProof.C",Form("Tree %s is not supported !!!",dsTreeName.Data()));
168 Error("runProof.C",Form("Maybe set your DS to %s#esdTree or %s#aodTree",dataset.Data(),dataset.Data()));
169 }
170
171 return "";
172}
173
174//________________________________________________________________________
175Bool_t InputHandlerSetup(TString format = "esd", Bool_t useKine = kTRUE) {
176 format.ToLower();
177
178 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
179
180 AliAnalysisDataContainer *cin = mgr->GetCommonInputContainer();
181
182 if (cin) return;
183
184 if (!format.CompareTo("esd")) {
185 AliESDInputHandler *esdInputHandler = dynamic_cast<AliESDInputHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
186
187 if (!esdInputHandler) {
188 Info("CustomAnalysisTaskInputSetup", "Creating esdInputHandler ...");
189 esdInputHandler = new AliESDInputHandler();
190 mgr->SetInputEventHandler(esdInputHandler);
191 }
192
193 if (useKine) {
194 AliMCEventHandler* mcInputHandler = dynamic_cast<AliMCEventHandler*>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
195
196 if (!mcInputHandler) {
197 Info("CustomAnalysisTaskInputSetup", "Creating mcInputHandler ...");
198 AliMCEventHandler* mcInputHandler = new AliMCEventHandler();
199 mgr->SetMCtruthEventHandler(mcInputHandler);
200 }
201 }
f9a6cab5 202 } else if (!format.CompareTo("aod")) {
203 AliAODInputHandler *aodInputHandler = dynamic_cast<AliAODInputHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
204
205 if (!aodInputHandler) {
206 Info("CustomAnalysisTaskInputSetup", "Creating aodInputHandler ...");
207 aodInputHandler = new AliAODInputHandler();
208 mgr->SetInputEventHandler(aodInputHandler);
209 }
210 } else {
211 AliWarning("Wrong input format!!! Only ESD and AOD are supported. Skipping Task ...");
212 return kFALSE;
213 }
214
fba64b41 215 return kTRUE;
216}