]>
Commit | Line | Data |
---|---|---|
d08133e6 | 1 | /************************************************************************** |
2 | * Author: Panos Christakoglou. * | |
3 | * Contributors are mentioned in the code where appropriate. * | |
4 | * * | |
5 | * Permission to use, copy, modify and distribute this software and its * | |
6 | * documentation strictly for non-commercial purposes is hereby granted * | |
7 | * without fee, provided that the above copyright notice appears in all * | |
8 | * copies and that both the copyright notice and this permission notice * | |
9 | * appear in the supporting documentation. The authors make no claims * | |
10 | * about the suitability of this software for any purpose. It is * | |
11 | * provided "as is" without express or implied warranty. * | |
12 | **************************************************************************/ | |
13 | ||
14 | /* $Id$ */ | |
15 | ||
16 | //----------------------------------------------------------------- | |
17 | // AliTagAnalysis class | |
18 | // This is the class to deal with the tag analysis | |
19 | // Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch | |
20 | //----------------------------------------------------------------- | |
21 | ||
22 | //ROOT | |
cd305eb1 | 23 | #include <Riostream.h> |
d08133e6 | 24 | #include <TSystem.h> |
25 | #include <TChain.h> | |
26 | #include <TFile.h> | |
27 | #include <TEventList.h> | |
28 | #include <TEntryList.h> | |
29 | #include <TTreeFormula.h> | |
30 | ||
31 | //ROOT-AliEn | |
32 | #include <TGridResult.h> | |
33 | ||
34 | #include "AliLog.h" | |
35 | ||
36 | #include "AliRunTag.h" | |
37 | #include "AliEventTag.h" | |
38 | #include "AliTagAnalysis.h" | |
39 | #include "AliEventTagCuts.h" | |
2ec6a1d3 | 40 | #include "AliDetectorTagCuts.h" |
41 | #include "AliLHCTagCuts.h" | |
d08133e6 | 42 | #include "AliRunTagCuts.h" |
43 | #include "AliXMLCollection.h" | |
44 | ||
45 | class TTree; | |
46 | ||
47 | ClassImp(AliTagAnalysis) | |
48 | ||
49 | //___________________________________________________________________________ | |
50 | AliTagAnalysis::AliTagAnalysis(): | |
51 | TObject(), | |
52 | ftagresult(0x0), | |
53 | fTagDirName(), | |
6cfbb923 | 54 | fChain(0x0), |
cd305eb1 | 55 | fAnalysisType(), |
56 | fGlobalList(0) { | |
d08133e6 | 57 | //Default constructor for a AliTagAnalysis |
58 | } | |
59 | ||
6cfbb923 | 60 | //___________________________________________________________________________ |
61 | AliTagAnalysis::AliTagAnalysis(const char* type): | |
62 | TObject(), | |
63 | ftagresult(0x0), | |
64 | fTagDirName(), | |
65 | fChain(0x0), | |
cd305eb1 | 66 | fAnalysisType(type), |
67 | fGlobalList(0) { | |
6cfbb923 | 68 | //constructor for a AliTagAnalysis |
69 | } | |
70 | ||
d08133e6 | 71 | //___________________________________________________________________________ |
72 | AliTagAnalysis::~AliTagAnalysis() { | |
cd305eb1 | 73 | //Default destructor for a AliTagAnalysis |
74 | if(ftagresult) delete ftagresult; | |
75 | if(fChain) delete fChain; | |
76 | if(fGlobalList) delete fGlobalList; | |
d08133e6 | 77 | } |
78 | ||
79 | //___________________________________________________________________________ | |
80 | Bool_t AliTagAnalysis::AddTagsFile(const char *alienUrl) { | |
d08133e6 | 81 | // Add a single tags file to the chain |
82 | ||
83 | Bool_t rv = kTRUE ; | |
84 | ||
85 | if (! fChain) fChain = new TChain("T"); | |
86 | ||
87 | TFile *f = TFile::Open(alienUrl,"READ"); | |
88 | fChain->Add(alienUrl); | |
89 | AliInfo(Form("Chained tag files: %d ",fChain->GetEntries())); | |
90 | delete f; | |
91 | ||
92 | if (fChain->GetEntries() == 0 ) | |
93 | rv = kFALSE ; | |
94 | ||
95 | return rv ; | |
96 | } | |
97 | ||
98 | //___________________________________________________________________________ | |
99 | void AliTagAnalysis::ChainLocalTags(const char *dirname) { | |
100 | //Searches the entries of the provided direcory | |
101 | //Chains the tags that are stored locally | |
102 | fTagDirName = dirname; | |
103 | TString fTagFilename; | |
104 | ||
105 | if (! fChain) fChain = new TChain("T"); | |
6cfbb923 | 106 | const char * tagPattern = 0x0; |
107 | if(fAnalysisType == "ESD") tagPattern = "ESD.tag.root"; | |
108 | else if(fAnalysisType == "AOD") tagPattern = "AOD.tag.root"; | |
109 | else AliFatal("Only ESD and AOD type is implemented!!!"); | |
110 | ||
d08133e6 | 111 | // Open the working directory |
112 | void * dirp = gSystem->OpenDirectory(fTagDirName); | |
113 | const char * name = 0x0; | |
114 | // Add all files matching *pattern* to the chain | |
115 | while((name = gSystem->GetDirEntry(dirp))) { | |
116 | if (strstr(name,tagPattern)) { | |
117 | fTagFilename = fTagDirName; | |
118 | fTagFilename += "/"; | |
119 | fTagFilename += name; | |
120 | ||
121 | fChain->Add(fTagFilename); | |
122 | }//pattern check | |
123 | }//directory loop | |
124 | AliInfo(Form("Chained tag files: %d ",fChain->GetEntries())); | |
125 | } | |
126 | ||
127 | ||
128 | //___________________________________________________________________________ | |
727d922c | 129 | TChain * AliTagAnalysis::ChainGridTags(TGridResult *res) { |
d08133e6 | 130 | //Loops overs the entries of the TGridResult |
131 | //Chains the tags that are stored in the GRID | |
132 | ftagresult = res; | |
133 | Int_t nEntries = ftagresult->GetEntries(); | |
134 | ||
135 | if (! fChain) fChain = new TChain("T"); | |
136 | ||
137 | TString gridname = "alien://"; | |
138 | TString alienUrl; | |
139 | ||
140 | for(Int_t i = 0; i < nEntries; i++) { | |
141 | alienUrl = ftagresult->GetKey(i,"turl"); | |
142 | fChain->Add(alienUrl); | |
727d922c | 143 | }//grid result loop |
144 | return fChain; | |
d08133e6 | 145 | } |
146 | ||
147 | ||
148 | //___________________________________________________________________________ | |
cd305eb1 | 149 | TChain *AliTagAnalysis::QueryTags(AliRunTagCuts *runTagCuts, |
150 | AliLHCTagCuts *lhcTagCuts, | |
151 | AliDetectorTagCuts *detTagCuts, | |
152 | AliEventTagCuts *evTagCuts) { | |
d08133e6 | 153 | //Queries the tag chain using the defined |
154 | //event tag cuts from the AliEventTagCuts object | |
155 | //and returns a TChain along with the associated TEventList | |
156 | AliInfo(Form("Querying the tags........")); | |
b97856f9 | 157 | |
6cfbb923 | 158 | TString fAliceFile; |
159 | if(fAnalysisType == "ESD") fAliceFile = "esdTree"; | |
160 | else if(fAnalysisType == "AOD") fAliceFile = "aodTree"; | |
161 | else AliFatal("Only ESD and AOD type is implemented!!!"); | |
b97856f9 | 162 | |
d08133e6 | 163 | //ESD file chain |
b97856f9 | 164 | TChain *fESDchain = new TChain(fAliceFile.Data()); |
165 | //global entry list | |
cd305eb1 | 166 | fGlobalList = new TEntryList(); |
d08133e6 | 167 | |
168 | //Defining tag objects | |
5a561fa0 | 169 | AliRunTag *tag = new AliRunTag; |
170 | AliEventTag *evTag = new AliEventTag; | |
d08133e6 | 171 | fChain->SetBranchAddress("AliTAG",&tag); |
172 | ||
173 | TString guid = 0; | |
174 | TString turl = 0; | |
175 | TString path = 0; | |
176 | ||
177 | Int_t iAccepted = 0; | |
178 | for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++) { | |
179 | fChain->GetEntry(iTagFiles); | |
2ec6a1d3 | 180 | if(runTagCuts->IsAccepted(tag)) { |
181 | if(lhcTagCuts->IsAccepted(tag->GetLHCTag())) { | |
182 | if(detTagCuts->IsAccepted(tag->GetDetectorTags())) { | |
183 | TEntryList *fLocalList = new TEntryList(); | |
184 | Int_t iEvents = tag->GetNEvents(); | |
185 | const TClonesArray *tagList = tag->GetEventTags(); | |
186 | for(Int_t i = 0; i < iEvents; i++) { | |
187 | evTag = (AliEventTag *) tagList->At(i); | |
188 | guid = evTag->GetGUID(); | |
189 | turl = evTag->GetTURL(); | |
190 | path = evTag->GetPath(); | |
191 | fLocalList->SetTreeName(fAliceFile.Data()); | |
c51c9b0e | 192 | if(turl!="") fLocalList->SetFileName(turl.Data()); |
193 | else fLocalList->SetFileName(path.Data()); | |
2ec6a1d3 | 194 | if(evTagCuts->IsAccepted(evTag)) fLocalList->Enter(i); |
195 | }//event loop | |
2ec6a1d3 | 196 | if(path != "") fESDchain->AddFile(path); |
197 | else if(turl != "") fESDchain->AddFile(turl); | |
198 | fGlobalList->Add(fLocalList); | |
199 | iAccepted += fLocalList->GetN(); | |
200 | }//detector tag cuts | |
201 | }//lhc tag cuts | |
d08133e6 | 202 | }//run tags cut |
5a561fa0 | 203 | tag->Clear(); |
d08133e6 | 204 | }//tag file loop |
b97856f9 | 205 | AliInfo(Form("Accepted events: %d",iAccepted)); |
206 | fESDchain->SetEntryList(fGlobalList,"ne"); | |
d08133e6 | 207 | |
208 | return fESDchain; | |
209 | } | |
210 | ||
211 | //___________________________________________________________________________ | |
cd305eb1 | 212 | TChain *AliTagAnalysis::QueryTags(const char *fRunCut, |
213 | const char *fLHCCut, | |
214 | const char *fDetectorCut, | |
215 | const char *fEventCut) { | |
d08133e6 | 216 | //Queries the tag chain using the defined |
217 | //event tag cuts from the AliEventTagCuts object | |
218 | //and returns a TChain along with the associated TEventList | |
219 | AliInfo(Form("Querying the tags........")); | |
220 | ||
6cfbb923 | 221 | TString fAliceFile; |
222 | if(fAnalysisType == "ESD") fAliceFile = "esdTree"; | |
223 | else if(fAnalysisType == "AOD") fAliceFile = "aodTree"; | |
224 | else AliFatal("Only ESD and AOD type is implemented!!!"); | |
b97856f9 | 225 | |
226 | //ESD file chain | |
227 | TChain *fESDchain = new TChain(fAliceFile.Data()); | |
228 | //global entry list | |
cd305eb1 | 229 | fGlobalList = new TEntryList(); |
d08133e6 | 230 | |
231 | //Defining tag objects | |
232 | AliRunTag *tag = new AliRunTag; | |
233 | AliEventTag *evTag = new AliEventTag; | |
234 | fChain->SetBranchAddress("AliTAG",&tag); | |
235 | ||
236 | TString guid = 0; | |
237 | TString turl = 0; | |
238 | TString path = 0; | |
239 | ||
240 | TTreeFormula *fRunFormula = new TTreeFormula("fRun",fRunCut,fChain); | |
2ec6a1d3 | 241 | TTreeFormula *fLHCFormula = new TTreeFormula("fLHC",fLHCCut,fChain); |
242 | TTreeFormula *fDetectorFormula = new TTreeFormula("fDetector",fDetectorCut,fChain); | |
243 | TTreeFormula *fEventFormula = new TTreeFormula("fEvent",fEventCut,fChain); | |
d08133e6 | 244 | |
245 | Int_t current = -1; | |
246 | Int_t iAccepted = 0; | |
cd305eb1 | 247 | for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++) { |
d08133e6 | 248 | fChain->GetEntry(iTagFiles); |
249 | if (current != fChain->GetTreeNumber()) { | |
250 | fRunFormula->UpdateFormulaLeaves(); | |
2ec6a1d3 | 251 | fLHCFormula->UpdateFormulaLeaves(); |
252 | fDetectorFormula->UpdateFormulaLeaves(); | |
d08133e6 | 253 | fEventFormula->UpdateFormulaLeaves(); |
254 | current = fChain->GetTreeNumber(); | |
255 | } | |
256 | if(fRunFormula->EvalInstance(iTagFiles) == 1) { | |
2ec6a1d3 | 257 | if(fLHCFormula->EvalInstance(iTagFiles) == 1) { |
258 | if(fDetectorFormula->EvalInstance(iTagFiles) == 1) { | |
259 | TEntryList *fLocalList = new TEntryList(); | |
260 | Int_t iEvents = fEventFormula->GetNdata(); | |
261 | const TClonesArray *tagList = tag->GetEventTags(); | |
262 | for(Int_t i = 0; i < iEvents; i++) { | |
263 | evTag = (AliEventTag *) tagList->At(i); | |
264 | guid = evTag->GetGUID(); | |
265 | turl = evTag->GetTURL(); | |
266 | path = evTag->GetPath(); | |
267 | fLocalList->SetTreeName(fAliceFile.Data()); | |
268 | fLocalList->SetFileName(turl.Data()); | |
269 | if(fEventFormula->EvalInstance(i) == 1) fLocalList->Enter(i); | |
270 | }//event loop | |
271 | iAccepted += fLocalList->GetN(); | |
272 | ||
273 | if(path != "") fESDchain->AddFile(path); | |
274 | else if(turl != "") fESDchain->AddFile(turl); | |
275 | fGlobalList->Add(fLocalList); | |
276 | iAccepted += fLocalList->GetN(); | |
277 | }//detector tag cuts | |
278 | }//lhc tag cuts | |
d08133e6 | 279 | }//run tag cut |
280 | }//tag file loop | |
b97856f9 | 281 | AliInfo(Form("Accepted events: %d",iAccepted)); |
282 | fESDchain->SetEntryList(fGlobalList,"ne"); | |
d08133e6 | 283 | |
284 | return fESDchain; | |
285 | } | |
286 | ||
287 | //___________________________________________________________________________ | |
cd305eb1 | 288 | Bool_t AliTagAnalysis::CreateXMLCollection(const char* name, |
289 | AliRunTagCuts *runTagCuts, | |
290 | AliLHCTagCuts *lhcTagCuts, | |
291 | AliDetectorTagCuts *detTagCuts, | |
292 | AliEventTagCuts *evTagCuts) { | |
d08133e6 | 293 | //Queries the tag chain using the defined |
294 | //event tag cuts from the AliEventTagCuts object | |
295 | //and returns a XML collection | |
296 | AliInfo(Form("Creating the collection........")); | |
297 | ||
298 | AliXMLCollection *collection = new AliXMLCollection(); | |
299 | collection->SetCollectionName(name); | |
300 | collection->WriteHeader(); | |
301 | ||
d08133e6 | 302 | TString guid = 0x0; |
303 | TString turl = 0x0; | |
304 | TString lfn = 0x0; | |
305 | ||
306 | //Defining tag objects | |
307 | AliRunTag *tag = new AliRunTag; | |
308 | AliEventTag *evTag = new AliEventTag; | |
309 | fChain->SetBranchAddress("AliTAG",&tag); | |
310 | ||
311 | for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++) { | |
312 | //Event list | |
313 | TEntryList *fList = new TEntryList(); | |
314 | fChain->GetEntry(iTagFiles); | |
2ec6a1d3 | 315 | if(runTagCuts->IsAccepted(tag)) { |
316 | if(lhcTagCuts->IsAccepted(tag->GetLHCTag())) { | |
317 | if(detTagCuts->IsAccepted(tag->GetDetectorTags())) { | |
318 | Int_t iEvents = tag->GetNEvents(); | |
319 | const TClonesArray *tagList = tag->GetEventTags(); | |
320 | for(Int_t i = 0; i < iEvents; i++) { | |
321 | evTag = (AliEventTag *) tagList->At(i); | |
322 | guid = evTag->GetGUID(); | |
323 | turl = evTag->GetTURL(); | |
324 | lfn = turl(8,turl.Length()); | |
325 | if(evTagCuts->IsAccepted(evTag)) fList->Enter(i); | |
326 | }//event loop | |
327 | collection->WriteBody(iTagFiles+1,guid,lfn,turl,fList); | |
328 | }//detector tag cuts | |
329 | }//lhc tag cuts | |
d08133e6 | 330 | }//run tag cuts |
5a561fa0 | 331 | tag->Clear(); |
d08133e6 | 332 | }//tag file loop |
333 | collection->Export(); | |
334 | ||
335 | return kTRUE; | |
336 | } | |
337 | ||
338 | //___________________________________________________________________________ | |
cd305eb1 | 339 | Bool_t AliTagAnalysis::CreateXMLCollection(const char* name, |
340 | const char *fRunCut, | |
341 | const char *fLHCCut, | |
342 | const char *fDetectorCut, | |
343 | const char *fEventCut) { | |
d08133e6 | 344 | //Queries the tag chain using the defined |
345 | //event tag cuts from the AliEventTagCuts object | |
346 | //and returns a XML collection | |
347 | AliInfo(Form("Creating the collection........")); | |
348 | ||
349 | AliXMLCollection *collection = new AliXMLCollection(); | |
350 | collection->SetCollectionName(name); | |
351 | collection->WriteHeader(); | |
352 | ||
353 | TString guid = 0x0; | |
354 | TString turl = 0x0; | |
355 | TString lfn = 0x0; | |
356 | ||
357 | //Defining tag objects | |
358 | AliRunTag *tag = new AliRunTag; | |
359 | AliEventTag *evTag = new AliEventTag; | |
360 | fChain->SetBranchAddress("AliTAG",&tag); | |
361 | ||
362 | TTreeFormula *fRunFormula = new TTreeFormula("fRun",fRunCut,fChain); | |
2ec6a1d3 | 363 | TTreeFormula *fLHCFormula = new TTreeFormula("fLHC",fLHCCut,fChain); |
364 | TTreeFormula *fDetectorFormula = new TTreeFormula("fDetector",fDetectorCut,fChain); | |
d08133e6 | 365 | TTreeFormula *fEventFormula = new TTreeFormula("fEvent",fEventCut,fChain); |
366 | ||
367 | Int_t current = -1; | |
368 | for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++) { | |
369 | //Event list | |
370 | TEntryList *fList = new TEntryList(); | |
371 | fChain->GetEntry(iTagFiles); | |
372 | if (current != fChain->GetTreeNumber()) { | |
373 | fRunFormula->UpdateFormulaLeaves(); | |
2ec6a1d3 | 374 | fLHCFormula->UpdateFormulaLeaves(); |
375 | fDetectorFormula->UpdateFormulaLeaves(); | |
d08133e6 | 376 | fEventFormula->UpdateFormulaLeaves(); |
377 | current = fChain->GetTreeNumber(); | |
378 | } | |
379 | if(fRunFormula->EvalInstance(iTagFiles) == 1) { | |
2ec6a1d3 | 380 | if(fLHCFormula->EvalInstance(iTagFiles) == 1) { |
381 | if(fDetectorFormula->EvalInstance(iTagFiles) == 1) { | |
382 | Int_t iEvents = fEventFormula->GetNdata(); | |
383 | const TClonesArray *tagList = tag->GetEventTags(); | |
384 | for(Int_t i = 0; i < iEvents; i++) { | |
385 | evTag = (AliEventTag *) tagList->At(i); | |
386 | guid = evTag->GetGUID(); | |
387 | turl = evTag->GetTURL(); | |
388 | lfn = turl(8,turl.Length()); | |
389 | if(fEventFormula->EvalInstance(i) == 1) fList->Enter(i); | |
390 | }//event loop | |
391 | collection->WriteBody(iTagFiles+1,guid,lfn,turl,fList); | |
392 | }//detector tag cuts | |
393 | }//lhc tag cuts | |
d08133e6 | 394 | }//run tag cuts |
395 | }//tag file loop | |
396 | collection->Export(); | |
397 | ||
398 | return kTRUE; | |
399 | } | |
400 | ||
cd305eb1 | 401 | //___________________________________________________________________________ |
402 | Bool_t AliTagAnalysis::CreateAsciiCollection(const char* name, | |
403 | AliRunTagCuts *runTagCuts, | |
404 | AliLHCTagCuts *lhcTagCuts, | |
405 | AliDetectorTagCuts *detTagCuts, | |
406 | AliEventTagCuts *evTagCuts) { | |
407 | //Queries the tag chain using the defined | |
408 | //event tag cuts from the AliEventTagCuts object | |
409 | //and returns a XML collection | |
410 | AliInfo(Form("Creating the collection........")); | |
411 | ||
412 | ofstream fout; | |
413 | fout.open(name); | |
414 | ||
415 | TString guid = 0x0; | |
416 | TString turl = 0x0; | |
417 | TString lfn = 0x0; | |
418 | ||
419 | TString line0 = 0; | |
420 | ||
421 | //Defining tag objects | |
422 | AliRunTag *tag = new AliRunTag; | |
423 | AliEventTag *evTag = new AliEventTag; | |
424 | fChain->SetBranchAddress("AliTAG",&tag); | |
425 | ||
426 | for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++) { | |
427 | //Event list | |
428 | TEntryList *fList = new TEntryList(); | |
429 | fChain->GetEntry(iTagFiles); | |
430 | if(runTagCuts->IsAccepted(tag)) { | |
431 | if(lhcTagCuts->IsAccepted(tag->GetLHCTag())) { | |
432 | if(detTagCuts->IsAccepted(tag->GetDetectorTags())) { | |
433 | Int_t iEvents = tag->GetNEvents(); | |
434 | const TClonesArray *tagList = tag->GetEventTags(); | |
435 | for(Int_t i = 0; i < iEvents; i++) { | |
436 | evTag = (AliEventTag *) tagList->At(i); | |
437 | guid = evTag->GetGUID(); | |
438 | turl = evTag->GetTURL(); | |
439 | lfn = turl(8,turl.Length()); | |
440 | if(evTagCuts->IsAccepted(evTag)) fList->Enter(i); | |
441 | }//event loop | |
442 | line0 = guid; line0 += " "; line0 += turl; line0 += " "; | |
443 | for(Int_t i = 0; i < fList->GetN(); i++) { | |
444 | line0 += fList->GetEntry(i); | |
445 | line0 += " "; | |
446 | } | |
447 | fout<<line0<<"\n"; | |
448 | }//detector tag cuts | |
449 | }//lhc tag cuts | |
450 | }//run tag cuts | |
451 | tag->Clear(); | |
452 | }//tag file loop | |
453 | ||
454 | fout.close(); | |
455 | ||
456 | return kTRUE; | |
457 | } | |
458 | ||
459 | //___________________________________________________________________________ | |
460 | Bool_t AliTagAnalysis::CreateAsciiCollection(const char* name, | |
461 | const char *fRunCut, | |
462 | const char *fLHCCut, | |
463 | const char *fDetectorCut, | |
464 | const char *fEventCut) { | |
465 | //Queries the tag chain using the defined | |
466 | //event tag cuts from the AliEventTagCuts object | |
467 | //and returns a XML collection | |
468 | AliInfo(Form("Creating the collection........")); | |
469 | ||
470 | ofstream fout; | |
471 | fout.open(name); | |
472 | ||
473 | TString guid = 0x0; | |
474 | TString turl = 0x0; | |
475 | TString lfn = 0x0; | |
476 | ||
477 | TString line0 = 0; | |
478 | ||
479 | //Defining tag objects | |
480 | AliRunTag *tag = new AliRunTag; | |
481 | AliEventTag *evTag = new AliEventTag; | |
482 | fChain->SetBranchAddress("AliTAG",&tag); | |
483 | ||
484 | TTreeFormula *fRunFormula = new TTreeFormula("fRun",fRunCut,fChain); | |
485 | TTreeFormula *fLHCFormula = new TTreeFormula("fLHC",fLHCCut,fChain); | |
486 | TTreeFormula *fDetectorFormula = new TTreeFormula("fDetector",fDetectorCut,fChain); | |
487 | TTreeFormula *fEventFormula = new TTreeFormula("fEvent",fEventCut,fChain); | |
488 | ||
489 | Int_t current = -1; | |
490 | for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++) { | |
491 | //Event list | |
492 | TEntryList *fList = new TEntryList(); | |
493 | fChain->GetEntry(iTagFiles); | |
494 | if (current != fChain->GetTreeNumber()) { | |
495 | fRunFormula->UpdateFormulaLeaves(); | |
496 | fLHCFormula->UpdateFormulaLeaves(); | |
497 | fDetectorFormula->UpdateFormulaLeaves(); | |
498 | fEventFormula->UpdateFormulaLeaves(); | |
499 | current = fChain->GetTreeNumber(); | |
500 | } | |
501 | if(fRunFormula->EvalInstance(iTagFiles) == 1) { | |
502 | if(fLHCFormula->EvalInstance(iTagFiles) == 1) { | |
503 | if(fDetectorFormula->EvalInstance(iTagFiles) == 1) { | |
504 | Int_t iEvents = fEventFormula->GetNdata(); | |
505 | const TClonesArray *tagList = tag->GetEventTags(); | |
506 | for(Int_t i = 0; i < iEvents; i++) { | |
507 | evTag = (AliEventTag *) tagList->At(i); | |
508 | guid = evTag->GetGUID(); | |
509 | turl = evTag->GetTURL(); | |
510 | lfn = turl(8,turl.Length()); | |
511 | if(fEventFormula->EvalInstance(i) == 1) fList->Enter(i); | |
512 | }//event loop | |
513 | line0 = guid; line0 += " "; line0 += turl; line0 += " "; | |
514 | for(Int_t i = 0; i < fList->GetN(); i++) { | |
515 | line0 += fList->GetEntry(i); | |
516 | line0 += " "; | |
517 | } | |
518 | fout<<line0<<"\n"; | |
519 | }//detector tag cuts | |
520 | }//lhc tag cuts | |
521 | }//run tag cuts | |
522 | }//tag file loop | |
523 | ||
524 | fout.close(); | |
525 | ||
526 | return kTRUE; | |
527 | } | |
528 | ||
d08133e6 | 529 | //___________________________________________________________________________ |
530 | TChain *AliTagAnalysis::GetInputChain(const char* system, const char *wn) { | |
531 | //returns the chain+event list - used in batch sessions | |
532 | // this function will be removed once the new root | |
533 | // improvements are committed | |
534 | TString fsystem = system; | |
535 | Int_t iAccepted = 0; | |
6cfbb923 | 536 | |
88fb0edc | 537 | TChain *fAnalysisChain = 0; |
538 | if(fAnalysisType == "ESD") fAnalysisChain = new TChain("esdTree"); | |
539 | else if(fAnalysisType == "AOD") fAnalysisChain = new TChain("aodTree"); | |
6cfbb923 | 540 | else AliFatal("Only ESD and AOD type is implemented!!!"); |
541 | ||
d08133e6 | 542 | //Event list |
543 | TEventList *fEventList = new TEventList(); | |
544 | AliXMLCollection *collection = AliXMLCollection::Open(wn); | |
545 | ||
546 | collection->Reset(); | |
547 | while (collection->Next()) { | |
548 | AliInfo(Form("Adding: %s",collection->GetTURL(""))); | |
6cfbb923 | 549 | fAnalysisChain->Add(collection->GetTURL("")); |
d08133e6 | 550 | TEntryList *list = (TEntryList *)collection->GetEventList(""); |
551 | for(Int_t i = 0; i < list->GetN(); i++) fEventList->Enter(iAccepted+list->GetEntry(i)); | |
552 | ||
553 | if(fsystem == "pp") iAccepted += 100; | |
554 | else if(fsystem == "PbPb") iAccepted += 1; | |
555 | } | |
556 | ||
6cfbb923 | 557 | fAnalysisChain->SetEventList(fEventList); |
d08133e6 | 558 | |
559 | AliInfo(Form("Number of selected events: %d",fEventList->GetN())); | |
560 | ||
6cfbb923 | 561 | return fAnalysisChain; |
d08133e6 | 562 | } |
563 | ||
564 | //___________________________________________________________________________ | |
cd305eb1 | 565 | TChain *AliTagAnalysis::GetChainFromCollection(const char* collectionname, |
566 | const char* treename) { | |
d08133e6 | 567 | //returns the TChain+TEntryList object- used in batch sessions |
568 | TString fAliceFile = treename; | |
569 | Int_t iAccepted = 0; | |
88fb0edc | 570 | TChain *fAnalysisChain = 0; |
571 | if(fAliceFile == "esdTree") fAnalysisChain = new TChain("esdTree"); | |
572 | else if(fAliceFile == "aodTree") fAnalysisChain = new TChain("aodTree"); | |
d08133e6 | 573 | else AliFatal("Inconsistent tree name - use esdTree or aodTree!"); |
6cfbb923 | 574 | |
d08133e6 | 575 | //Event list |
cd305eb1 | 576 | fGlobalList = new TEntryList(); |
d08133e6 | 577 | AliXMLCollection *collection = AliXMLCollection::Open(collectionname); |
578 | ||
579 | collection->Reset(); | |
580 | while (collection->Next()) { | |
581 | AliInfo(Form("Adding: %s",collection->GetTURL(""))); | |
582 | fAnalysisChain->Add(collection->GetTURL("")); | |
583 | TEntryList *list = (TEntryList *)collection->GetEventList(""); | |
584 | list->SetTreeName(fAliceFile.Data()); | |
585 | list->SetFileName(collection->GetTURL("")); | |
586 | fGlobalList->Add(list); | |
587 | iAccepted += list->GetN(); | |
588 | } | |
589 | ||
590 | fAnalysisChain->SetEntryList(fGlobalList,"ne"); | |
591 | ||
592 | AliInfo(Form("Number of selected events: %d",iAccepted)); | |
593 | ||
594 | return fAnalysisChain; | |
595 | } |