]>
Commit | Line | Data |
---|---|---|
eef42d18 | 1 | enum { kMyRunModeLocal = 0, kMyRunModeCAF, kMyRunModeGRID}; |
9d173aad | 2 | |
3 | TChain * GetAnalysisChain(const char * incollection); | |
4 | ||
eef42d18 | 5 | void runTriggerStudy(Char_t* data, Long64_t nev = -1, Long64_t offset = 0, Bool_t debug = kFALSE, Int_t runMode = 0, Bool_t isMC = 0, Int_t ntrackletsKine = 100, Bool_t rejectBGV0Trigger = kFALSE, const char* option = "", Int_t workers = -1) |
9d173aad | 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 | ||
eef42d18 | 32 | // If we are running on grid, we need the alien handler |
33 | if (runMode == kMyRunModeGRID) { | |
34 | // Create and configure the alien handler plugin | |
35 | gROOT->LoadMacro("CreateAlienHandlerTrigger.C"); | |
36 | AliAnalysisGrid *alienHandler = CreateAlienHandlerTrigger(data,"pass1",isMC); | |
37 | if (!alienHandler) { | |
38 | cout << "Cannot create alien handler" << endl; | |
39 | exit(1); | |
40 | } | |
41 | mgr->SetGridHandler(alienHandler); | |
42 | } | |
9d173aad | 43 | |
bcc49144 | 44 | // Add physics selection |
45 | gROOT->ProcessLine(".L $ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); | |
46 | physicsSelectionTask = AddTaskPhysicsSelection(isMC,0);//FIXME | |
47 | ||
48 | ||
49 | ||
50 | ||
9d173aad | 51 | // Parse option strings |
52 | TString optionStr(option); | |
53 | ||
54 | // remove SAVE option if set | |
55 | // 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 | |
56 | Bool_t doSave = kFALSE; | |
57 | TString optionStr(option); | |
58 | if (optionStr.Contains("SAVE")) | |
59 | { | |
60 | optionStr = optionStr(0,optionStr.Index("SAVE")) + optionStr(optionStr.Index("SAVE")+4, optionStr.Length()); | |
61 | doSave = kTRUE; | |
62 | } | |
63 | ||
64 | ||
65 | ||
66 | // load my task | |
67 | AliAnalysisTaskTriggerStudy *task = new AliAnalysisTaskTriggerStudy("TaskOfflineTrigger"); | |
68 | mgr->AddTask(task); | |
69 | // Set I/O | |
70 | AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer(); | |
71 | AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("cTrigStudy", | |
72 | AliHistoListWrapper::Class(), | |
73 | AliAnalysisManager::kOutputContainer, | |
74 | "Trig_Temp.root"); | |
75 | mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer()); | |
76 | mgr->ConnectOutput(task,1,coutput1); | |
77 | ||
78 | ||
79 | ||
80 | task->SetIsMC(isMC); | |
eef42d18 | 81 | task->SetNTrackletsCutKine(ntrackletsKine); |
82 | task->SetRejectBGWithV0(rejectBGV0Trigger); | |
83 | ||
9d173aad | 84 | if (!mgr->InitAnalysis()) return; |
85 | ||
86 | mgr->PrintStatus(); | |
87 | ||
88 | if (runMode == kMyRunModeLocal ) { | |
89 | // If running in local mode, create chain of ESD files | |
90 | cout << "RUNNING LOCAL, CHAIN" << endl; | |
91 | TChain * chain = GetAnalysisChain(data); | |
92 | // chain->Print(); | |
93 | mgr->StartAnalysis("local",chain,nev); | |
94 | } else if (runMode == kMyRunModeCAF) { | |
95 | mgr->StartAnalysis("proof",TString(data)+"#esdTree",nev); | |
eef42d18 | 96 | } else if (runMode == kMyRunModeGRID) { |
97 | mgr->StartAnalysis("grid"); | |
98 | }else { | |
9d173aad | 99 | cout << "ERROR: unknown run mode" << endl; |
100 | } | |
101 | ||
eef42d18 | 102 | if (doSave) MoveOutput(data, Form("_TrkCut_%d_V0BGCUT_%d",ntrackletsKine,rejectBGV0Trigger)); |
9d173aad | 103 | |
104 | ||
105 | } | |
106 | ||
107 | ||
108 | void MoveOutput(const char * data, const char * suffix = ""){ | |
109 | ||
110 | TString path("outTrigger/"); | |
111 | path = path + TString(data).Tokenize("/")->Last()->GetName() + suffix; | |
112 | ||
113 | TString fileName = "trigger_study.root"; | |
114 | gSystem->mkdir(path, kTRUE); | |
115 | gSystem->Rename(fileName, path + "/" + fileName); | |
116 | Printf(">>>>> Moved files to %s", path.Data()); | |
117 | } | |
118 | ||
119 | ||
120 | ||
121 | TChain * GetAnalysisChain(const char * incollection){ | |
122 | // Builds a chain of esd files | |
123 | // incollection can be | |
124 | // - a single root file | |
125 | // - an xml collection of files on alien | |
126 | // - a ASCII containing a list of local root files | |
127 | TChain* analysisChain = 0; | |
128 | // chain | |
129 | analysisChain = new TChain("esdTree"); | |
130 | if (TString(incollection).Contains(".root")){ | |
131 | analysisChain->Add(incollection); | |
132 | } | |
133 | else if (TString(incollection).Contains("xml")){ | |
134 | TGrid::Connect("alien://"); | |
135 | TAlienCollection * coll = TAlienCollection::Open (incollection); | |
136 | while(coll->Next()){ | |
137 | analysisChain->Add(TString("alien://")+coll->GetLFN()); | |
138 | } | |
139 | } else { | |
140 | ifstream file_collect(incollection); | |
141 | TString line; | |
142 | while (line.ReadLine(file_collect) ) { | |
143 | analysisChain->Add(line.Data()); | |
144 | } | |
145 | } | |
146 | analysisChain->GetListOfFiles()->Print(); | |
147 | ||
148 | return analysisChain; | |
149 | } | |
150 | ||
151 | ||
152 | void InitAndLoadLibs(Int_t runMode=kMyRunModeLocal, Int_t workers=0,Bool_t debug=0) { | |
153 | ||
154 | if (runMode == kMyRunModeCAF) | |
155 | { | |
156 | cout << "Init in CAF mode" << endl; | |
157 | ||
158 | gEnv->SetValue("XSec.GSI.DelegProxy", "2"); | |
bcc49144 | 159 | // TProof::Open("alice-caf.cern.ch", workers>0 ? Form("workers=%d",workers) : ""); |
160 | TProof::Open("skaf.saske.sk", workers>0 ? Form("workers=%d",workers) : ""); | |
9d173aad | 161 | |
162 | // Enable the needed package | |
163 | gProof->UploadPackage("$ALICE_ROOT/STEERBase"); | |
164 | gProof->EnablePackage("$ALICE_ROOT/STEERBase"); | |
165 | gProof->UploadPackage("$ALICE_ROOT/ESD"); | |
166 | gProof->EnablePackage("$ALICE_ROOT/ESD"); | |
167 | gProof->UploadPackage("$ALICE_ROOT/AOD"); | |
168 | gProof->EnablePackage("$ALICE_ROOT/AOD"); | |
169 | gProof->UploadPackage("$ALICE_ROOT/ANALYSIS"); | |
170 | gProof->EnablePackage("$ALICE_ROOT/ANALYSIS"); | |
171 | gProof->UploadPackage("$ALICE_ROOT/ANALYSISalice"); | |
172 | gProof->EnablePackage("$ALICE_ROOT/ANALYSISalice"); | |
173 | gProof->UploadPackage("$ALICE_ROOT/PWG0base"); | |
174 | gProof->EnablePackage("$ALICE_ROOT/PWG0base"); | |
175 | gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG0/multPb")); | |
176 | gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG1/background")); | |
177 | } | |
178 | else | |
179 | { | |
eef42d18 | 180 | cout << "Init in Local or Grid mode" << endl; |
9d173aad | 181 | |
182 | gSystem->Load("libVMC"); | |
183 | gSystem->Load("libTree"); | |
184 | gSystem->Load("libSTEERBase"); | |
185 | gSystem->Load("libESD"); | |
186 | gSystem->Load("libAOD"); | |
187 | gSystem->Load("libANALYSIS"); | |
188 | gSystem->Load("libANALYSISalice"); | |
189 | gSystem->Load("libPWG0base"); | |
190 | ||
191 | gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG0/multPb")); | |
192 | gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG1/background")); | |
193 | // gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG1/background/")); | |
194 | } | |
195 | // Load helper classes | |
196 | // TODO: replace this by a list of TOBJStrings | |
197 | TString taskName("$ALICE_ROOT/PWG0/multPbPb/AliAnalysisTaskTriggerStudy.cxx+"); | |
198 | TString listName("$ALICE_ROOT/PWG1/background/AliHistoListWrapper.cxx+"); | |
199 | ||
200 | gSystem->ExpandPathName(taskName); | |
201 | gSystem->ExpandPathName(listName); | |
202 | ||
203 | ||
204 | ||
205 | // Create, add task | |
206 | if (runMode == kMyRunModeCAF) { | |
207 | gProof->Load(listName+(debug?"+g":"")); | |
208 | gProof->Load(taskName+(debug?"+g":"")); | |
209 | } else { | |
210 | gROOT->LoadMacro(listName+(debug?"+g":"")); | |
211 | gROOT->LoadMacro(taskName+(debug?"+g":"")); | |
212 | } | |
213 | ||
214 | ||
215 | } |