]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG0/multPbPb/runTriggerStudy.C
Glauber files for real data (Alberica)
[u/mrichter/AliRoot.git] / PWG0 / multPbPb / runTriggerStudy.C
CommitLineData
9d173aad 1enum { kMyRunModeLocal = 0, kMyRunModeCAF};
2
3TChain * GetAnalysisChain(const char * incollection);
4
5void runTriggerStudy(Char_t* data, Long64_t nev = -1, Long64_t offset = 0, Bool_t debug = kFALSE, Int_t runMode = 0, Bool_t isMC = 0, const char* option = "",Int_t workers = -1)
6{
7 // runMode:
8 //
9 // 0 local
10 // 1 proof
11
12 if (nev < 0)
13 nev = 1234567890;
14
15 InitAndLoadLibs(runMode,workers,debug);
16
17 // Create the analysis manager
18 mgr = new AliAnalysisManager;
19
20 // Add ESD handler
21 AliESDInputHandler* esdH = new AliESDInputHandler;
22 // Do I need any of this?
23 // esdH->SetInactiveBranches("AliESDACORDE FMD ALIESDTZERO ALIESDZDC AliRawDataErrorLogs CaloClusters Cascades EMCALCells EMCALTrigger ESDfriend Kinks AliESDTZERO ALIESDACORDE MuonTracks TrdTracks");
24 mgr->SetInputEventHandler(esdH);
25
26 if(isMC) {
27 AliMCEventHandler* handler = new AliMCEventHandler;
28 handler->SetPreReadMode(AliMCEventHandler::kLmPreRead);
29 mgr->SetMCtruthEventHandler(handler);
30 }
31
32
33 // Parse option strings
34 TString optionStr(option);
35
36 // remove SAVE option if set
37 // This is copied from a macro by Jan. The reason I kept it is that I may want to pass textual options to the new task at some point
38 Bool_t doSave = kFALSE;
39 TString optionStr(option);
40 if (optionStr.Contains("SAVE"))
41 {
42 optionStr = optionStr(0,optionStr.Index("SAVE")) + optionStr(optionStr.Index("SAVE")+4, optionStr.Length());
43 doSave = kTRUE;
44 }
45
46
47
48 // load my task
49 AliAnalysisTaskTriggerStudy *task = new AliAnalysisTaskTriggerStudy("TaskOfflineTrigger");
50 mgr->AddTask(task);
51 // Set I/O
52 AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer();
53 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("cTrigStudy",
54 AliHistoListWrapper::Class(),
55 AliAnalysisManager::kOutputContainer,
56 "Trig_Temp.root");
57 mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
58 mgr->ConnectOutput(task,1,coutput1);
59
60
61
62 task->SetIsMC(isMC);
63
64 if (!mgr->InitAnalysis()) return;
65
66 mgr->PrintStatus();
67
68 if (runMode == kMyRunModeLocal ) {
69 // If running in local mode, create chain of ESD files
70 cout << "RUNNING LOCAL, CHAIN" << endl;
71 TChain * chain = GetAnalysisChain(data);
72 // chain->Print();
73 mgr->StartAnalysis("local",chain,nev);
74 } else if (runMode == kMyRunModeCAF) {
75 mgr->StartAnalysis("proof",TString(data)+"#esdTree",nev);
76 } else {
77 cout << "ERROR: unknown run mode" << endl;
78 }
79
80 if (doSave) MoveOutput(data, "");
81
82
83}
84
85
86void MoveOutput(const char * data, const char * suffix = ""){
87
88 TString path("outTrigger/");
89 path = path + TString(data).Tokenize("/")->Last()->GetName() + suffix;
90
91 TString fileName = "trigger_study.root";
92 gSystem->mkdir(path, kTRUE);
93 gSystem->Rename(fileName, path + "/" + fileName);
94 Printf(">>>>> Moved files to %s", path.Data());
95}
96
97
98
99TChain * GetAnalysisChain(const char * incollection){
100 // Builds a chain of esd files
101 // incollection can be
102 // - a single root file
103 // - an xml collection of files on alien
104 // - a ASCII containing a list of local root files
105 TChain* analysisChain = 0;
106 // chain
107 analysisChain = new TChain("esdTree");
108 if (TString(incollection).Contains(".root")){
109 analysisChain->Add(incollection);
110 }
111 else if (TString(incollection).Contains("xml")){
112 TGrid::Connect("alien://");
113 TAlienCollection * coll = TAlienCollection::Open (incollection);
114 while(coll->Next()){
115 analysisChain->Add(TString("alien://")+coll->GetLFN());
116 }
117 } else {
118 ifstream file_collect(incollection);
119 TString line;
120 while (line.ReadLine(file_collect) ) {
121 analysisChain->Add(line.Data());
122 }
123 }
124 analysisChain->GetListOfFiles()->Print();
125
126 return analysisChain;
127}
128
129
130void InitAndLoadLibs(Int_t runMode=kMyRunModeLocal, Int_t workers=0,Bool_t debug=0) {
131
132 if (runMode == kMyRunModeCAF)
133 {
134 cout << "Init in CAF mode" << endl;
135
136 gEnv->SetValue("XSec.GSI.DelegProxy", "2");
137 TProof::Open("alice-caf.cern.ch", workers>0 ? Form("workers=%d",workers) : "");
138
139 // Enable the needed package
140 gProof->UploadPackage("$ALICE_ROOT/STEERBase");
141 gProof->EnablePackage("$ALICE_ROOT/STEERBase");
142 gProof->UploadPackage("$ALICE_ROOT/ESD");
143 gProof->EnablePackage("$ALICE_ROOT/ESD");
144 gProof->UploadPackage("$ALICE_ROOT/AOD");
145 gProof->EnablePackage("$ALICE_ROOT/AOD");
146 gProof->UploadPackage("$ALICE_ROOT/ANALYSIS");
147 gProof->EnablePackage("$ALICE_ROOT/ANALYSIS");
148 gProof->UploadPackage("$ALICE_ROOT/ANALYSISalice");
149 gProof->EnablePackage("$ALICE_ROOT/ANALYSISalice");
150 gProof->UploadPackage("$ALICE_ROOT/PWG0base");
151 gProof->EnablePackage("$ALICE_ROOT/PWG0base");
152 gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG0/multPb"));
153 gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG1/background"));
154 }
155 else
156 {
157 cout << "Init in Local mode" << endl;
158
159 gSystem->Load("libVMC");
160 gSystem->Load("libTree");
161 gSystem->Load("libSTEERBase");
162 gSystem->Load("libESD");
163 gSystem->Load("libAOD");
164 gSystem->Load("libANALYSIS");
165 gSystem->Load("libANALYSISalice");
166 gSystem->Load("libPWG0base");
167
168 gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG0/multPb"));
169 gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG1/background"));
170 // gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG1/background/"));
171 }
172 // Load helper classes
173 // TODO: replace this by a list of TOBJStrings
174 TString taskName("$ALICE_ROOT/PWG0/multPbPb/AliAnalysisTaskTriggerStudy.cxx+");
175 TString listName("$ALICE_ROOT/PWG1/background/AliHistoListWrapper.cxx+");
176
177 gSystem->ExpandPathName(taskName);
178 gSystem->ExpandPathName(listName);
179
180
181
182 // Create, add task
183 if (runMode == kMyRunModeCAF) {
184 gProof->Load(listName+(debug?"+g":""));
185 gProof->Load(taskName+(debug?"+g":""));
186 } else {
187 gROOT->LoadMacro(listName+(debug?"+g":""));
188 gROOT->LoadMacro(taskName+(debug?"+g":""));
189 }
190
191
192}