]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/AliAnalysisGoodies.cxx
+ Modifications of the standard tracking algorithm:
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisGoodies.cxx
CommitLineData
b86ddfbb 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15//_________________________________________________________________________
16// Various utilities usefull for analysis
17//
18//*-- Yves Schutz
19//////////////////////////////////////////////////////////////////////////////
20
21#include "AliAnalysisDataContainer.h"
22#include "AliTagAnalysis.h"
23#include "AliEventTagCuts.h"
24#include "AliRunTagCuts.h"
25#include "AliXMLCollection.h"
26#include "AliAnalysisGoodies.h"
27#include "AliAnalysisManager.h"
28#include "AliAnalysisTask.h"
29 //#include "AliPhotonAnalysisTask.h"
30#include "AliLog.h"
31
32#include <Riostream.h>
33#include <TAlienCollection.h>
34#include <TChain.h>
35#include <TFileMerger.h>
36#include <TGrid.h>
37#include <TROOT.h>
38#include <TSystem.h>
39
40
41//______________________________________________________________________________
42AliAnalysisGoodies::AliAnalysisGoodies() :
43 fESDTreeName("esdTree"),
44 fnumberOfTasks(0),
45 fTaskList(0),
46 fTaskInType(0),
47 fTaskOuType(0)
48{
49 fTimer.Reset() ;
50
51 TString token = gSystem->Getenv("GRID_TOKEN") ;
52
53 if ( token == "OK" )
54 TGrid::Connect("alien://");
55 else
56 AliInfo("You are not connected to the GRID") ;
57}
58
59//______________________________________________________________________________
60void AliAnalysisGoodies::Help() const
61{
62 AliInfo("Analysis utilities:\n") ;
63 printf(" *** Copy : copy files ESD files listed in an xml collection from AliEn catalog to local storage and creates a local xml collection \n") ;
64 printf(" usage: Copy(in, out)\n") ;
65 printf(" in: a xml esd collection file name \n") ;
66 printf(" ou: the local directory where to save the esd root files \n") ;
67 printf(" *** Make : makes esd collection from tags \n") ;
68 printf(" usage: Make(tags, esds)\n") ;
69 printf(" tags: is either a tag root file or an xml tag collection \n") ;
70 printf(" esds: is an esd collection \n") ;
71 printf(" *** Merge : merges files listed in a xml collection \n") ;
72 printf(" usage Merge(collection, outputDile)\n") ;
73 printf(" collection: is a xml collection \n") ;
74 printf(" *** Process : process the events with an Analysis Task \n") ;
75 printf(" usage: Process(esdFile, tagCuts) \n") ;
76 printf(" esdFile: can be a root file with the ESD Tree ( ex: esd?AliESDs.root) \n") ;
77 printf(" or a root file with the Tag Tree ( ex: tag?Run100.Event0_100.ESD.tag.root) \n") ;
78 printf(" or a local or alien xml file with the ESD collection ( ex: esd?esdCollection.xml) \n") ;
79 printf(" or a local or alien xml file with the TAG collection ( ex: tag?tagCollection.xml) \n") ;
80 printf(" or a TChain of esd TTrees \n") ;
81 printf(" tagCuts: is the AliEventTagCuts (needed only for tag? cases \n") ;
82 printf(" *** Register: register files already stored in a MSS into the AliEn catalog\n") ;
83 printf(" usage: Register(lfndir, pfndir, pfnFileName) \n") ;
84 printf(" lfndir : AliEn directory ( ex: /alice/data/2006/LHC06c/PHOS_TestBeam/\n") ;
85 printf(" pfndir : MSS directory ( ex: /castor/cern.ch/alice/testbeam/phos/2006 \n") ;
86 printf(" file : text file with a list of the file names to be registered\n ") ;
87
88}
89
90//______________________________________________________________________
91const Bool_t AliAnalysisGoodies::Alien2Local(const TString collectionNameIn, const TString localDir)
92{
93 // copy files ESD files listed in an xml collection from AliEn catalog to local storage and creates a local xml collection
94 // usage: Alien2Local(in, out)
95 // in: a xml esd collection file name
96 // ou: the local directory where to save the esd root files
97
98 Bool_t rv = kTRUE ;
99
100 fTimer.Start() ;
101
102 AliXMLCollection * collectionIn = AliXMLCollection::Open(collectionNameIn) ;
103 collectionIn->Reset() ;
104
105 AliXMLCollection * collectionOu = new AliXMLCollection() ;
106 TString collectionNameOu(collectionIn->GetCollectionName()) ;
107 collectionNameOu.Append("Local") ;
108 collectionOu->SetCollectionName(collectionNameOu) ;
109 collectionOu->WriteHeader() ;
110
111 TFileMerger merger ;
112
113 const char* ocwd = gSystem->WorkingDirectory();
114
115 Int_t counter = 0 ;
116 while ( collectionIn->Next() ) {
117 gSystem->ChangeDirectory(localDir) ;
118 TString fileTURL = collectionIn->GetTURL("") ;
119
120 TString tempo(fileTURL) ;
121 tempo.Remove(tempo.Last('/'), tempo.Length()) ;
122 TString evtsNumber = tempo(tempo.Last('/')+1, tempo.Length())+"/";
123 tempo.Remove(tempo.Last('/'), tempo.Length()) ;
124 TString runNumber = tempo(tempo.Last('/')+1, tempo.Length())+"/" ;
125 TString dir = localDir + runNumber ;
126 gSystem->MakeDirectory(dir) ;
127 gSystem->ChangeDirectory(dir) ;
128 dir += evtsNumber + "/";
129 gSystem->MakeDirectory(dir) ;
130 gSystem->ChangeDirectory(dir) ;
131 dir += collectionIn->GetCollectionName() ;
132 TEntryList * list = collectionIn->GetEventList("") ;
133
134 collectionOu->WriteBody(counter, collectionIn->GetGUID(""), collectionIn->GetLFN(""), collectionIn->GetTURL(""), list) ;
135 counter++ ;
136 printf("Copying %s to %s\n", fileTURL.Data(), dir.Data()) ;
137 merger.Cp(fileTURL, dir) ;
138 }
139 collectionOu->Export() ;
140 gSystem->ChangeDirectory(ocwd) ;
141
142 fTimer.Stop();
143 fTimer.Print();
144
145 return rv ;
146}
147
148//______________________________________________________________________
149const Bool_t AliAnalysisGoodies::Make(AliRunTagCuts *runCuts, AliEventTagCuts *evtCuts, const char * in, const char * out) const
150{
151 // makes esd collection from tags
152 // usage Make(tags, esds)
153 // tags: is either a tag root file or an xml tag collection
154 // esds: is an esd collection
155
156 Bool_t rv = kTRUE ;
157
158 if ( !evtCuts && !runCuts ) {
159 AliError("No Tag cuts provided") ;
160 return kFALSE ;
161 }
162
163 TString file(in) ;
164 if ( file.Contains(".root") )
165 rv = MakeEsdCollectionFromTagFile(runCuts, evtCuts, file.Data(), out) ;
166 else if ( file.Contains(".xml") )
167 rv = MakeEsdCollectionFromTagCollection(runCuts, evtCuts, file.Data(), out) ;
168 else {
169 AliError(Form("%s is not a valid file format", in)) ;
170 rv = kFALSE ;
171 }
172
173 return rv ;
174}
175
176//______________________________________________________________________
177const Bool_t AliAnalysisGoodies::MakeEsdCollectionFromTagFile(AliRunTagCuts *runCuts, AliEventTagCuts *evtCuts, const char * in, const char * out) const
178{
179 // Makes an esd collection from a root tag file
180 Bool_t rv = kTRUE ;
181 // Open the file collection
182 printf("*** Create Collection ***\n");
183 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
184 printf("*** file = |%s| \n",in);
185
186 AliTagAnalysis * tagAna = new AliTagAnalysis();
187 rv = tagAna->AddTagsFile(in);
188 if ( ! rv )
189 return rv ;
190
191 tagAna->CreateXMLCollection(out, runCuts, evtCuts) ;
192
193 return rv ;
194
195}
196
197//______________________________________________________________________
198const Bool_t AliAnalysisGoodies::MakeEsdCollectionFromTagCollection(AliRunTagCuts * runCuts, AliEventTagCuts * evtCuts, const char * in, const char * out) const
199{
200 // Makes an esd collection from a xml tag collection
201 Bool_t rv = kTRUE ;
202 // Open the file collection
203 printf("*** Create Collection ***\n");
204 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
205 printf("*** Coll = |%s| \n",in);
206
207 TAlienCollection * collection = TAlienCollection::Open(in);
208 TGridResult* result = collection->GetGridResult("");
209 AliTagAnalysis * tagAna = new AliTagAnalysis();
210 tagAna->ChainGridTags(result);
211
212 tagAna->CreateXMLCollection(out, runCuts, evtCuts) ;
213
214 return rv ;
215}
216
217//______________________________________________________________________
218const Bool_t AliAnalysisGoodies::MakeEsdCollectionFromTagCollection(const char * runCuts, const char * evtCuts, const char * in, const char * out) const
219{
220 // Makes an esd collection from a xml tag collection
221
222 Bool_t rv = kTRUE ;
223
224 // Open the file collection
225 printf("*** Create Collection ***\n");
226 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
227 printf("*** Coll = |%s| \n",in);
228
229 TAlienCollection * collection = TAlienCollection::Open(in);
230 TGridResult* result = collection->GetGridResult("");
231 AliTagAnalysis * tagAna = new AliTagAnalysis();
232 tagAna->ChainGridTags(result);
233
234 tagAna->CreateXMLCollection(out, runCuts, evtCuts) ;
235
236 return rv ;
237}
238
239//______________________________________________________________________
240const Bool_t AliAnalysisGoodies::Merge(const char * collectionFile, const char * subFile, const char * outFile)
241{
242 // merges files listed in a xml collection
243 // usage Merge(collection, outputFile))
244 // collection: is a xml collection
245
246 Bool_t rv = kFALSE ;
247
248 if ( strstr(collectionFile, ".xml") == 0 ) {
249 AliError("Input collection file must be an \".xml\" file\n") ;
250 return kFALSE ;
251 }
252
253 fTimer.Start() ;
254
255 // Open the file collection
256 printf("*** Create Collection ***\n");
257 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
258 printf("*** Coll = |%s| \n",collectionFile);
259
260 TAlienCollection * collection = TAlienCollection::Open(collectionFile);
261 TGridResult* result = collection->GetGridResult("");
262
263 Int_t index = 0 ;
264 const char * turl ;
265 TFileMerger merger ;
266 if (!outFile) {
267 TString tempo(collectionFile) ;
268 if ( subFile)
269 tempo.ReplaceAll(".xml", subFile) ;
270 else
271 tempo.ReplaceAll(".xml", "_Merged.root") ;
272 outFile = tempo.Data() ;
273 }
274 merger.OutputFile(outFile) ;
275
276 while ( (turl = result->GetKey(index, "turl")) ) {
277 char file[2048] ;
278 if ( subFile )
279 sprintf(file, "%s#%s", turl, subFile) ;
280 else
281 sprintf(file, "%s", turl) ;
282
283 printf("%s\n", file) ;
284 merger.AddFile(file) ;
285 index++ ;
286 }
287
288 if (index)
289 merger.Merge() ;
290
291 AliInfo(Form("Files merged into %s\n", outFile)) ;
292
293 fTimer.Stop();
294 fTimer.Print();
295
296 return rv ;
297}
298
299//______________________________________________________________________
300const Bool_t AliAnalysisGoodies::Process(TChain * chain)
301{
302 // process events starting from a chain of esd Trees
303 Bool_t rv = kFALSE ;
304
305 fTimer.Start() ;
306
307 rv = ProcessChain(chain) ;
308
309 fTimer.Stop();
310 fTimer.Print();
311
312 return rv ;
313}
314
315//______________________________________________________________________
316const Bool_t AliAnalysisGoodies::Process(const char * inFile)
317{
318 // process the events with an Analysis Task
319 // usage Process(esdFile)
320 // esdFile: is of the form opt?file_lfn
321 Bool_t rv = kFALSE ;
322 AliRunTagCuts * runCuts = 0x0 ;
323 AliEventTagCuts * evtCuts = 0x0 ;
324
325 rv = Process(inFile, runCuts, evtCuts) ;
326
327 return rv ;
328}
329
330//______________________________________________________________________
331const Bool_t AliAnalysisGoodies::Process(const char * inFile, AliRunTagCuts *runCuts, AliEventTagCuts * evtCuts )
332{
333 // process the events with an Analysis Task
334 // usage Process(esdFile, runtagCuts, evtTagCuts)
335 // esdFile: is of the form opt?file_lfn
336
337 Bool_t rv = kFALSE ;
338
339 fTimer.Start() ;
340
341 TString file(inFile) ;
342 if ( file.Contains("esd?") && file.Contains(".root") ) {
343 file.ReplaceAll("esd?", "") ;
344 rv = ProcessEsdFile(file.Data()) ;
345
346 } else if ( file.Contains("esd?") && file.Contains(".xml") ) {
347 file.ReplaceAll("esd?", "") ;
348 rv = ProcessEsdXmlCollection(file.Data()) ;
349
350 } else if (file.Contains("tag?") && file.Contains(".root") ) {
351 file.ReplaceAll("tag?", "") ;
352 rv = ProcessTagFile(file.Data(), runCuts, evtCuts) ;
353
354 } else if (file.Contains("tag?") && file.Contains(".xml") ) {
355 file.ReplaceAll("tag?", "") ;
356 rv = ProcessTagXmlCollection(file.Data(), runCuts, evtCuts) ;
357
358 } else {
359 AliError(Form("%s is not a valid file format", inFile)) ;
360 rv = kFALSE ;
361 }
362
363 fTimer.Stop();
364 fTimer.Print();
365
366 return rv ;
367}
368
369//______________________________________________________________________
370const Bool_t AliAnalysisGoodies::Process(const char * inFile, const char * runCuts, const char * evtCuts)
371{
372 // process the events with an Analysis Task
373 // usage Process(esdFile, runtagCuts, evtTagCuts)
374 // esdFile: is of the form opt?file_lfn
375
376 Bool_t rv = kFALSE ;
377
378 fTimer.Start() ;
379
380 TString file(inFile) ;
381 if ( file.Contains("esd?") && file.Contains(".root") ) {
382 file.ReplaceAll("esd?", "") ;
383 rv = ProcessEsdFile(file.Data()) ;
384
385 } else if ( file.Contains("esd?") && file.Contains(".xml") ) {
386 file.ReplaceAll("esd?", "") ;
387 rv = ProcessEsdXmlCollection(file.Data()) ;
388
389 } else if (file.Contains("tag?") && file.Contains(".root") ) {
390 file.ReplaceAll("tag?", "") ;
391 rv = ProcessTagFile(file.Data(), runCuts, evtCuts) ;
392
393 } else if (file.Contains("tag?") && file.Contains(".xml") ) {
394 file.ReplaceAll("tag?", "") ;
395 rv = ProcessTagXmlCollection(file.Data(), runCuts, evtCuts) ;
396
397 } else {
398 AliError(Form("%s is not a valid file format", inFile)) ;
399 rv = kFALSE ;
400 }
401
402 fTimer.Stop();
403 fTimer.Print();
404
405 return rv ;
406}
407
408//______________________________________________________________________
409const Bool_t AliAnalysisGoodies::ProcessChain(TChain * chain) const
410{
411 // Procees a TChain.
412
413 Bool_t rv = kTRUE ;
414
415 if (! fTaskList ) {
416 AliError("No tasks defined") ;
417 return kFALSE ;
418 }
419
420 // Make the analysis manager
421 AliAnalysisManager * mgr = new AliAnalysisManager() ;
422
423 // Make tasks
424 // The top input must be common to all top tasks
425 TClass * classIn = fTaskInType[0] ;
426 AliAnalysisDataContainer * taskInput = mgr->CreateContainer("Input Container", classIn, AliAnalysisManager::kInputContainer) ;
427 Int_t index ;
428 for (index = 0; index < fnumberOfTasks; index++) {
429 AliAnalysisTask * task = fTaskList[index] ;
430 mgr->AddTask(task) ;
431
432 // Create containers for input/output
433 TClass * classOu = fTaskOuType[index] ;
434 AliAnalysisDataContainer * taskOutput = mgr->CreateContainer("Output Container", classOu, AliAnalysisManager::kOutputContainer) ;
435 mgr->ConnectInput (task, 0, taskInput);
436 mgr->ConnectOutput(task, 0, taskOutput);
437 }
438
439 // Open data
440 taskInput->SetData(chain);
441
442 if (mgr->InitAnalysis()) {
443 mgr->PrintStatus();
444 chain->Process(mgr);
445 } else
446 rv = kFALSE ;
447
448 return rv ;
449}
450
451//______________________________________________________________________
452const Bool_t AliAnalysisGoodies::ProcessEsdFile(const char * esdFile) const
453{
454 // process the events in a single ESD file with an Analysis Task
455 // usage ProcessLocalEsdFile(esdFile)
456 // esdFile: is the root file (local or in alien) with the ESD Tree ( ex: AliESDs.root)
457
458 Bool_t rv = kTRUE ;
459
460 printf("*** Process ***\n");
461 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
462 printf("*** Coll = |%s| \n",esdFile);
463
464 // Makes the ESD chain
465 printf("*** Getting the Chain ***\n");
466 TChain* analysisChain = new TChain(fESDTreeName) ;
467 analysisChain->AddFile(esdFile);
468
469 // Process the events
470 rv = ProcessChain(analysisChain) ;
471
472 return rv;
473}
474
475//______________________________________________________________________
476const Bool_t AliAnalysisGoodies::ProcessTagFile(const char * tagFile, AliRunTagCuts *runCuts, AliEventTagCuts *evtCuts) const
477{
478 // process the events in a single Tag file with an Analysis Task
479 // usage ProcessLocalEsdFile(tagFile)
480 // tagFile: is the root file (local or in alien) with the Tag Tree (ex: Run102.Event0_100.ESD.tag.root)
481
482 Bool_t rv = kTRUE ;
483
484 if ( !evtCuts && !runCuts ) {
485 AliError("No Tag cuts provided") ;
486 return kFALSE ;
487 }
488
489 printf("*** Process ***\n");
490 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
491 printf("*** Coll = |%s| \n",tagFile);
492
493 AliTagAnalysis * tagAna = new AliTagAnalysis();
494 rv = tagAna->AddTagsFile(tagFile);
495 if ( ! rv )
496 return rv ;
497
498 // Query the tag file and make the analysis chain
499 TChain * analysisChain = new TChain(fESDTreeName) ;
500 analysisChain = tagAna->QueryTags(runCuts, evtCuts);
501
502 // Process the events
503 rv = ProcessChain(analysisChain) ;
504
505 return rv;
506}
507
508//______________________________________________________________________
509const Bool_t AliAnalysisGoodies::ProcessTagFile(const char * tagFile, const char * runCuts, const char * evtCuts) const
510{
511 // process the events in a single Tag file with an Analysis Task
512 // usage ProcessLocalEsdFile(tagFile)
513 // tagFile: is the root file (local or in alien) with the Tag Tree (ex: Run102.Event0_100.ESD.tag.root)
514
515 Bool_t rv = kTRUE ;
516
517
518 if ( !evtCuts && !runCuts ) {
519 AliError("No Tag cuts provided") ;
520 return kFALSE ;
521 }
522
523 printf("*** Process ***\n");
524 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
525 printf("*** Coll = |%s| \n",tagFile);
526
527 AliTagAnalysis * tagAna = new AliTagAnalysis();
528 rv = tagAna->AddTagsFile(tagFile);
529 if ( ! rv )
530 return rv ;
531
532 // Query the tag file and make the analysis chain
533 TChain * analysisChain = new TChain(fESDTreeName) ;
534 analysisChain = tagAna->QueryTags(runCuts, evtCuts);
535
536 // Process the events
537 rv = ProcessChain(analysisChain) ;
538
539 return rv;
540}
541
542//______________________________________________________________________
543const Bool_t AliAnalysisGoodies::ProcessEsdXmlCollection(const char * xmlFile) const
544{
545 // process the events in a xml ESD collection with an Analysis Task
546 // usage ProcessLocalEsdFile(xmlFile)
547 // xmlFile: is the local xml file with the ESD collection ( ex: esdCollection.xml)
548
549 Bool_t rv = kTRUE ;
550
551 printf("*** Process ***\n");
552 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
553 printf("*** Coll = |%s| \n",xmlFile);
554
555 TAlienCollection * collection = TAlienCollection::Open(xmlFile) ;
556 if (! collection) {
557 AliError(Form("%s not found", xmlFile)) ;
558 return kFALSE ;
559 }
560
561 TGridResult* result = collection->GetGridResult("");
562 TList* analysisfilelist = result->GetFileInfoList();
563
564 // Makes the ESD chain
565 printf("*** Getting the Chain ***\n");
566 TChain* analysisChain = new TChain(fESDTreeName);
567 analysisChain->AddFileInfoList(analysisfilelist);
568
569 // Process the events
570 rv = ProcessChain(analysisChain) ;
571
572 return rv ;
573}
574
575//______________________________________________________________________
576const Bool_t AliAnalysisGoodies::ProcessTagXmlCollection(const char * xmlFile, AliRunTagCuts *runCuts, AliEventTagCuts * evtCuts) const
577{
578 // process the events in a xml ESD collection with an Analysis Task
579 // usage ProcessLocalEsdFile(xmlFile)
580 // xmlFile: is the local xml file with the tag collection ( ex: tagCollection.xml)
581
582 Bool_t rv = kTRUE ;
583
584 if ( !evtCuts && !runCuts ) {
585 AliError("No Tag cuts provided") ;
586 return kFALSE ;
587 }
588
589 printf("*** Process ***\n");
590 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
591 printf("*** Coll = |%s| \n",xmlFile);
592
593 // check if file is local or alien
594 if ( gSystem->AccessPathName(xmlFile) )
595 TGrid::Connect("alien://");
596
597 TAlienCollection * collection = TAlienCollection::Open(xmlFile) ;
598 if (! collection) {
599 AliError(Form("%s not found", xmlFile)) ;
600 return kFALSE ;
601 }
602
603 TGridResult* result = collection->GetGridResult("");
604 AliTagAnalysis * tagAna = new AliTagAnalysis();
605 tagAna->ChainGridTags(result);
606
607 // Query the tag file and make the analysis chain
608 TChain * analysisChain = new TChain(fESDTreeName) ;
609 analysisChain = tagAna->QueryTags(runCuts, evtCuts);
610
611 // Process the events
612 rv = ProcessChain(analysisChain) ;
613
614 return rv ;
615}
616
617//______________________________________________________________________
618const Bool_t AliAnalysisGoodies::ProcessTagXmlCollection(const char * xmlFile, const char * runCuts, const char * evtCuts) const
619{
620 // process the events in a xml ESD collection with an Analysis Task
621 // usage ProcessLocalEsdFile(xmlFile)
622 // xmlFile: is the local xml file with the tag collection ( ex: tagCollection.xml)
623
624 Bool_t rv = kTRUE ;
625
626 if ( !evtCuts && !runCuts ) {
627 AliError("No Tag cuts provided") ;
628 return kFALSE ;
629 }
630
631 printf("*** Process ***\n");
632 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
633 printf("*** Coll = |%s| \n",xmlFile);
634
635 // check if file is local or alien
636 if ( gSystem->AccessPathName(xmlFile) )
637 TGrid::Connect("alien://");
638
639 TAlienCollection * collection = TAlienCollection::Open(xmlFile) ;
640 if (! collection) {
641 AliError(Form("%s not found", xmlFile)) ;
642 return kFALSE ;
643 }
644
645 TGridResult* result = collection->GetGridResult("");
646 AliTagAnalysis * tagAna = new AliTagAnalysis();
647 tagAna->ChainGridTags(result);
648
649 // Query the tag file and make the analysis chain
650 TChain * analysisChain = new TChain(fESDTreeName) ;
651 analysisChain = tagAna->QueryTags(runCuts, evtCuts);
652
653 // Process the events
654 rv = ProcessChain(analysisChain) ;
655
656 return rv ;
657}
658
659//______________________________________________________________________
660const Bool_t AliAnalysisGoodies::Register( const char * lfndir, const char * pfndir, const char * file)
661{
662 // register files already stored in a MSS into the AliEn catalog
663 // usage: Register(lfndir, pfndir, pfnFileName)
664 // lfndir : AliEn directory ( ex: /alice/data/2006/LHC06c/PHOS_TestBeam/ )
665 // pfndir : MSS directory ( ex: /castor/cern.ch/alice/testbeam/phos/2006 )
666 // file : text file with a list of the file names to be registered
667
668 Bool_t rv = kTRUE ;
669 fTimer.Start() ;
670
671 ifstream in;
672 in.open(file);
673 if ( in.bad() ) {
674 AliError(Form("Cannot open file %s\n", file)) ;
675 return kFALSE ;
676 }
677
678 TGrid::Connect("alien://");
679
680 char fileName[1024] ;
681
682 while (1) {
683 in >> fileName ;
684 if (!in.good())
685 break;
686 char lfn[1024] ;
687
688 sprintf(lfn, "%s/%s", lfndir, fileName) ;
689
690 char pfn[1024] ;
691
692 sprintf(pfn, "castor://Alice::CERN::Castor2/%s/%s", pfndir, fileName) ;
693
694 printf("Register %s as %s\n", pfn, lfn) ;
695
696 gGrid->Register(lfn, pfn) ;
697 }
698
699 fTimer.Stop();
700 fTimer.Print();
701
702 return rv;
703}
704
705//______________________________________________________________________
706void AliAnalysisGoodies::SetTasks(Int_t nb, AliAnalysisTask ** taskList, TClass ** inputType, TClass ** outputType)
707{
708 // define a task with its output and input type
709
710
711 fnumberOfTasks= nb;
712 fTaskList = taskList ;
713 fTaskInType = inputType ;
714 fTaskOuType = outputType ;
715}