1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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
19 //////////////////////////////////////////////////////////////////////////////
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 "AliAODHandler.h"
29 #include "AliAnalysisTask.h"
32 #include <Riostream.h>
34 #include <TGridResult.h>
35 #include <TFileMerger.h>
42 #include <TEntryList.h>
44 //______________________________________________________________________________
45 AliAnalysisGoodies::AliAnalysisGoodies() :
48 fESDTreeName("esdTree"),
53 TString token = gSystem->Getenv("GRID_TOKEN") ;
56 TGrid::Connect("alien://");
58 AliInfo("You are not connected to the GRID") ;
59 // Make the analysis manager
60 fAmgr = new AliAnalysisManager("Goodies Manager", "Analysis manager created by AliAnalysisGoodies") ;
63 //______________________________________________________________________________
64 AliAnalysisGoodies::AliAnalysisGoodies(const AliAnalysisGoodies& ag) :
71 fESDTreeName = ag.fESDTreeName ;
72 TString token = gSystem->Getenv("GRID_TOKEN") ;
75 TGrid::Connect("alien://");
77 AliInfo("You are not connected to the GRID") ;
79 // Make the analysis manager
80 fAmgr = new AliAnalysisManager("Goodies Manager", "Analysis manager created by AliAnalysisGoodies") ;
83 //______________________________________________________________________________
84 AliAnalysisGoodies& AliAnalysisGoodies::operator=(const AliAnalysisGoodies& ag)
86 // Assignment operator
93 //______________________________________________________________________________
94 void AliAnalysisGoodies::Help() const
96 AliInfo("Analysis utilities:\n") ;
97 printf(" *** Alien2Local : copy files ESD files listed in an xml collection from AliEn catalog to local storage and creates a local xml collection \n") ;
98 printf(" usage: Alien2Local(in, out)\n") ;
99 printf(" in: a xml esd collection file name \n") ;
100 printf(" ou: the local directory where to save the esd root files \n") ;
101 printf(" *** Make : makes esd collection from tags \n") ;
102 printf(" usage: Make(tags, esds)\n") ;
103 printf(" tags: is either a tag root file or an xml tag collection \n") ;
104 printf(" esds: is an esd collection \n") ;
105 printf(" *** Merge : merges files listed in a xml collection \n") ;
106 printf(" usage Merge(collection, outputDile)\n") ;
107 printf(" collection: is a xml collection \n") ;
108 printf(" *** Process : process the events with an Analysis Task \n") ;
109 printf(" usage: Process(esdFile, tagCuts) \n") ;
110 printf(" esdFile: can be a root file with the ESD Tree ( ex: esd?AliESDs.root) \n") ;
111 printf(" or a root file with the Tag Tree ( ex: tag?Run100.Event0_100.ESD.tag.root) \n") ;
112 printf(" or a local or alien xml file with the ESD collection ( ex: esd?esdCollection.xml) \n") ;
113 printf(" or a local or alien xml file with the TAG collection ( ex: tag?tagCollection.xml) \n") ;
114 printf(" or a TChain of esd TTrees \n") ;
115 printf(" tagCuts: is the AliEventTagCuts (needed only for tag? cases \n") ;
116 printf(" *** Register: register files already stored in a MSS into the AliEn catalog\n") ;
117 printf(" usage: Register(lfndir, pfndir, pfnFileName) \n") ;
118 printf(" lfndir : AliEn directory ( ex: /alice/data/2006/LHC06c/PHOS_TestBeam/\n") ;
119 printf(" pfndir : MSS directory ( ex: /castor/cern.ch/alice/testbeam/phos/2006 \n") ;
120 printf(" file : text file with a list of the file names to be registered\n ") ;
124 //______________________________________________________________________
125 Bool_t AliAnalysisGoodies::Alien2Local(const TString collectionNameIn, const TString localDir)
127 // copy files ESD files listed in an xml collection from AliEn catalog to local storage and creates a local xml collection
128 // usage: Alien2Local(in, out)
129 // in: a xml esd collection file name
130 // ou: the local directory where to save the esd root files
137 AliXMLCollection * collectionIn = AliXMLCollection::Open(collectionNameIn) ;
138 collectionIn->Reset() ;
140 AliXMLCollection * collectionOu = new AliXMLCollection() ;
141 TString collectionNameOu(collectionIn->GetCollectionName()) ;
142 collectionNameOu.Append("Local") ;
143 collectionOu->SetCollectionName(collectionNameOu) ;
144 collectionOu->WriteHeader() ;
146 const char* ocwd = gSystem->WorkingDirectory();
149 while ( collectionIn->Next() ) {
150 gSystem->ChangeDirectory(localDir) ;
151 TString fileTURL = collectionIn->GetTURL("") ;
153 TString tempo(fileTURL) ;
154 tempo.Remove(tempo.Last('/'), tempo.Length()) ;
155 TString evtsNumber = tempo(tempo.Last('/')+1, tempo.Length())+"/";
156 tempo.Remove(tempo.Last('/'), tempo.Length()) ;
157 TString runNumber = tempo(tempo.Last('/')+1, tempo.Length())+"/" ;
158 TString dir = localDir + runNumber ;
161 sprintf(line, ".! mkdir -p %s", dir.Data()) ;
162 gROOT->ProcessLine(line) ;
163 printf("***************************%s\n", line) ;
164 TEntryList * list = collectionIn->GetEventList("") ;
166 list = new TEntryList() ;
168 TString filename = tempo(tempo.Last('/')+1, tempo.Length()) ;
170 AliInfo(Form("Copying %s to %s\n", fileTURL.Data(), dir.Data())) ;
171 collectionOu->WriteBody(counter, collectionIn->GetGUID(""), collectionIn->GetLFN(""), dir, list) ;
173 TFile::Cp(fileTURL, dir) ;
175 collectionOu->Export() ;
176 gSystem->ChangeDirectory(ocwd) ;
187 //______________________________________________________________________
188 AliAnalysisDataContainer * AliAnalysisGoodies::ConnectInput(AliAnalysisTask * task, TClass * classin, UShort_t index)
190 // connect a task to the input
192 if ( ! fAmgr->GetTask(task->GetName()) )
193 fAmgr->AddTask(task) ;
195 AliFatal(Form("Task %s already exists", task->GetName())) ;
197 AliAnalysisDataContainer * taskInput = 0x0 ;
198 if ( fAmgr->GetInputs() )
199 taskInput = dynamic_cast<AliAnalysisDataContainer *>(fAmgr->GetInputs()->FindObject(Form("InputContainer_%s_%d", task->GetName(), index))) ;
201 taskInput = fAmgr->CreateContainer(Form("InputContainer_%s_%d", task->GetName(), index), classin, AliAnalysisManager::kInputContainer) ;
202 fAmgr->ConnectInput (task, index, taskInput);
205 AliFatal(Form("Input %s already exists", taskInput->GetName())) ;
210 //______________________________________________________________________
211 void AliAnalysisGoodies::ConnectInput(AliAnalysisTask * task, AliAnalysisDataContainer * taskInput, UShort_t index)
213 // connect a task to the input
215 if ( ! fAmgr->GetTask(task->GetName()) )
216 fAmgr->AddTask(task) ;
218 AliFatal(Form("Task %s already exists", task->GetName())) ;
220 fAmgr->ConnectInput (task, index, taskInput);
223 //______________________________________________________________________
224 AliAnalysisDataContainer * AliAnalysisGoodies::ConnectOuput(AliAnalysisTask * task, TClass * classou, UShort_t index, TString opt )
226 // connect a task to the output
231 if ( fAmgr->GetOutputEventHandler() == 0x0) {
232 AliAODHandler * aodHandler = new AliAODHandler() ;
233 aodHandler->SetOutputFileName(Form("%s_0.root",task->GetName())) ;
234 fAmgr->SetOutputEventHandler(aodHandler) ;
236 sprintf(filename, "default") ;
239 sprintf(filename, "%s_%d.root",task->GetName(), index) ;
241 AliAnalysisDataContainer * taskOuput = 0x0 ;
242 if ( fAmgr->GetOutputs() )
243 taskOuput = dynamic_cast<AliAnalysisDataContainer *>(fAmgr->GetOutputs()->FindObject(Form("OutputContainer_%s_%d", task->GetName(), index))) ;
245 taskOuput = fAmgr->CreateContainer(Form("OutputContainer_%s_%d", task->GetName(), index), classou, AliAnalysisManager::kOutputContainer, filename) ;
246 fAmgr->ConnectOutput(task, index, taskOuput);
251 //______________________________________________________________________
252 void AliAnalysisGoodies::ConnectOuput(AliAnalysisTask * task, AliAnalysisDataContainer * taskOuput, UShort_t index)
254 // connect a task to the output
256 fAmgr->ConnectInput (task, index, taskOuput);
259 //______________________________________________________________________
260 Bool_t AliAnalysisGoodies::Make(AliRunTagCuts *runCuts, AliLHCTagCuts *lhcCuts, AliDetectorTagCuts *detCuts, AliEventTagCuts *evtCuts, const char * in, const char * out) const
262 // makes esd collection from tags
263 // usage Make(tags, esds)
264 // tags: is either a tag root file or an xml tag collection
265 // esds: is an esd collection
269 if ( !evtCuts && !runCuts ) {
270 AliError("No Tag cuts provided") ;
275 if ( file.Contains(".root") )
276 rv = MakeEsdCollectionFromTagFile(runCuts, lhcCuts, detCuts, evtCuts, file.Data(), out) ;
277 else if ( file.Contains(".xml") )
278 rv = MakeEsdCollectionFromTagCollection(runCuts, lhcCuts, detCuts, evtCuts, file.Data(), out) ;
280 AliError(Form("%s is not a valid file format", in)) ;
287 //______________________________________________________________________
288 Bool_t AliAnalysisGoodies::MakeEsdCollectionFromTagFile(AliRunTagCuts *runCuts, AliLHCTagCuts *lhcCuts, AliDetectorTagCuts *detCuts, AliEventTagCuts *evtCuts, const char * in, const char * out) const
290 // Makes an esd collection from a root tag file
292 // Open the file collection
293 printf("*** Create Collection ***\n");
294 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
295 printf("*** file = |%s| \n",in);
297 AliTagAnalysis * tagAna = new AliTagAnalysis();
298 rv = tagAna->AddTagsFile(in);
302 tagAna->CreateXMLCollection(out, runCuts, lhcCuts, detCuts, evtCuts) ;
308 //______________________________________________________________________
309 Bool_t AliAnalysisGoodies::MakeEsdCollectionFromTagCollection(AliRunTagCuts *runCuts, AliLHCTagCuts *lhcCuts, AliDetectorTagCuts *detCuts, AliEventTagCuts *evtCuts, const char * in, const char * out) const
311 // Makes an esd collection from a xml tag collection
313 // Open the file collection
314 printf("*** Create Collection ***\n");
315 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
316 printf("*** Coll = |%s| \n",in);
320 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)",in));
321 TGridResult* result = collection->GetGridResult("", 0, 0);
322 AliTagAnalysis * tagAna = new AliTagAnalysis();
323 tagAna->ChainGridTags(result);
325 tagAna->CreateXMLCollection(out, runCuts, lhcCuts, detCuts, evtCuts) ;
333 //______________________________________________________________________
334 Bool_t AliAnalysisGoodies::MakeEsdCollectionFromTagCollection(const char * runCuts, const char *lhcCuts, const char *detCuts, const char * evtCuts, const char * in, const char * out) const
336 // Makes an esd collection from a xml tag collection
340 // Open the file collection
341 printf("*** Create Collection ***\n");
342 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
343 printf("*** Coll = |%s| \n",in);
347 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)",in));
348 TGridResult* result = collection->GetGridResult("", 0, 0);
349 AliTagAnalysis * tagAna = new AliTagAnalysis();
350 tagAna->ChainGridTags(result);
352 tagAna->CreateXMLCollection(out, runCuts, lhcCuts, detCuts, evtCuts) ;
360 //______________________________________________________________________
361 Bool_t AliAnalysisGoodies::Merge(const char * collectionFile, const char * subFile, const char * outFile)
363 // merges files listed in a xml collection
364 // usage Merge(collection, outputFile))
365 // collection: is a xml collection
369 if ( strstr(collectionFile, ".xml") == 0 ) {
370 AliError("Input collection file must be an \".xml\" file\n") ;
376 // Open the file collection
377 printf("*** Create Collection ***\n");
378 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
379 printf("*** Coll = |%s| \n",collectionFile);
383 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)",collectionFile));
384 TGridResult* result = collection->GetGridResult("", 0, 0);
390 TString tempo(collectionFile) ;
392 tempo.ReplaceAll(".xml", subFile) ;
394 tempo.ReplaceAll(".xml", "_Merged.root") ;
395 outFile = tempo.Data() ;
397 merger.OutputFile(outFile) ;
399 while ( (turl = result->GetKey(index, "turl")) ) {
402 sprintf(file, "%s#%s", turl, subFile) ;
404 sprintf(file, "%s", turl) ;
406 printf("%s\n", file) ;
407 merger.AddFile(file) ;
414 AliInfo(Form("Files merged into %s\n", outFile)) ;
425 //______________________________________________________________________
426 Bool_t AliAnalysisGoodies::Process(TChain * chain)
428 // process events starting from a chain of esd Trees
432 rv = ProcessChain(chain) ;
440 //______________________________________________________________________
441 Bool_t AliAnalysisGoodies::Process(const char * inFile)
443 // process the events with an Analysis Task
444 // usage Process(esdFile)
445 // esdFile: is of the form opt?file_lfn
447 AliRunTagCuts * runCuts = 0x0 ;
448 AliLHCTagCuts * lhcCuts = 0x0 ;
449 AliDetectorTagCuts * detCuts = 0x0 ;
450 AliEventTagCuts * evtCuts = 0x0 ;
452 rv = Process(inFile, runCuts, lhcCuts, detCuts, evtCuts) ;
457 //______________________________________________________________________
458 Bool_t AliAnalysisGoodies::Process(const char * inFile, AliRunTagCuts *runCuts, AliLHCTagCuts *lhcCuts, AliDetectorTagCuts *detCuts, AliEventTagCuts * evtCuts )
460 // process the events with an Analysis Task
461 // usage Process(esdFile, runtagCuts, evtTagCuts)
462 // esdFile: is of the form opt?file_lfn
468 TString file(inFile) ;
469 if ( file.Contains("esd?") && file.Contains(".root") ) {
470 file.ReplaceAll("esd?", "") ;
471 rv = ProcessEsdFile(file.Data()) ;
473 } else if ( file.Contains("esd?") && file.Contains(".xml") ) {
474 file.ReplaceAll("esd?", "") ;
475 rv = ProcessEsdXmlCollection(file.Data()) ;
477 } else if (file.Contains("tag?") && file.Contains(".root") ) {
478 file.ReplaceAll("tag?", "") ;
479 rv = ProcessTagFile(file.Data(), runCuts, lhcCuts, detCuts, evtCuts) ;
481 } else if (file.Contains("tag?") && file.Contains(".xml") ) {
482 file.ReplaceAll("tag?", "") ;
483 rv = ProcessTagXmlCollection(file.Data(), runCuts, lhcCuts, detCuts, evtCuts) ;
486 AliError(Form("%s is not a valid file format", inFile)) ;
496 //______________________________________________________________________
497 Bool_t AliAnalysisGoodies::Process(const char * inFile, const char * runCuts, const char * lhcCuts, const char * detCuts, const char * evtCuts)
499 // process the events with an Analysis Task
500 // usage Process(esdFile, runtagCuts, evtTagCuts)
501 // esdFile: is of the form opt?file_lfn
507 TString file(inFile) ;
508 if ( file.Contains("esd?") && file.Contains(".root") ) {
509 file.ReplaceAll("esd?", "") ;
510 rv = ProcessEsdFile(file.Data()) ;
512 } else if ( file.Contains("esd?") && file.Contains(".xml") ) {
513 file.ReplaceAll("esd?", "") ;
514 rv = ProcessEsdXmlCollection(file.Data()) ;
516 } else if (file.Contains("tag?") && file.Contains(".root") ) {
517 file.ReplaceAll("tag?", "") ;
518 rv = ProcessTagFile(file.Data(), runCuts, lhcCuts, detCuts, evtCuts) ;
520 } else if (file.Contains("tag?") && file.Contains(".xml") ) {
521 file.ReplaceAll("tag?", "") ;
522 rv = ProcessTagXmlCollection(file.Data(), runCuts, lhcCuts, detCuts, evtCuts) ;
525 AliError(Form("%s is not a valid file format", inFile)) ;
535 //______________________________________________________________________
536 Bool_t AliAnalysisGoodies::ProcessChain(TChain * chain) const
543 if (fAmgr->InitAnalysis()) {
544 fAmgr->PrintStatus();
545 fAmgr->StartAnalysis("local",chain);
552 //______________________________________________________________________
553 Bool_t AliAnalysisGoodies::ProcessEsdFile(const char * esdFile) const
555 // process the events in a single ESD file with an Analysis Task
556 // usage ProcessLocalEsdFile(esdFile)
557 // esdFile: is the root file (local or in alien) with the ESD Tree ( ex: AliESDs.root)
561 printf("*** Process ***\n");
562 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
563 printf("*** Coll = |%s| \n",esdFile);
565 // Makes the ESD chain
566 printf("*** Getting the Chain ***\n");
567 TChain* analysisChain = new TChain(fESDTreeName) ;
568 analysisChain->AddFile(esdFile);
570 // Process the events
571 rv = ProcessChain(analysisChain) ;
576 //______________________________________________________________________
577 Bool_t AliAnalysisGoodies::ProcessTagFile(const char * tagFile, AliRunTagCuts *runCuts, AliLHCTagCuts *lhcCuts, AliDetectorTagCuts *detCuts, AliEventTagCuts *evtCuts) const
579 // process the events in a single Tag file with an Analysis Task
580 // usage ProcessLocalEsdFile(tagFile)
581 // tagFile: is the root file (local or in alien) with the Tag Tree (ex: Run102.Event0_100.ESD.tag.root)
585 if ( !evtCuts && !runCuts ) {
586 AliError("No Tag cuts provided") ;
590 printf("*** Process ***\n");
591 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
592 printf("*** Coll = |%s| \n",tagFile);
594 AliTagAnalysis * tagAna = new AliTagAnalysis();
595 rv = tagAna->AddTagsFile(tagFile);
599 // Query the tag file and make the analysis chain
600 TChain * analysisChain = new TChain(fESDTreeName) ;
601 analysisChain = tagAna->QueryTags(runCuts, lhcCuts, detCuts, evtCuts);
603 // Process the events
604 rv = ProcessChain(analysisChain) ;
609 //______________________________________________________________________
610 Bool_t AliAnalysisGoodies::ProcessTagFile(const char * tagFile, const char * runCuts, const char * lhcCuts, const char * detCuts, const char * evtCuts) const
612 // process the events in a single Tag file with an Analysis Task
613 // usage ProcessLocalEsdFile(tagFile)
614 // tagFile: is the root file (local or in alien) with the Tag Tree (ex: Run102.Event0_100.ESD.tag.root)
619 if ( !evtCuts && !runCuts ) {
620 AliError("No Tag cuts provided") ;
624 printf("*** Process ***\n");
625 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
626 printf("*** Coll = |%s| \n",tagFile);
628 AliTagAnalysis * tagAna = new AliTagAnalysis();
629 rv = tagAna->AddTagsFile(tagFile);
633 // Query the tag file and make the analysis chain
634 TChain * analysisChain = new TChain(fESDTreeName) ;
635 analysisChain = tagAna->QueryTags(runCuts, lhcCuts, detCuts, evtCuts);
637 // Process the events
638 rv = ProcessChain(analysisChain) ;
643 //______________________________________________________________________
644 Bool_t AliAnalysisGoodies::ProcessEsdXmlCollection(const char * xmlFile) const
646 // process the events in a xml ESD collection with an Analysis Task
647 // usage ProcessLocalEsdFile(xmlFile)
648 // xmlFile: is the local xml file with the ESD collection ( ex: esdCollection.xml)
652 printf("*** Process ***\n");
653 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
654 printf("*** Coll = |%s| \n",xmlFile);
657 //AliXMLCollection * collection = AliXMLCollection::Open(xmlFile,0) ;
658 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)", xmlFile));
660 AliError(Form("%s not found", xmlFile)) ;
664 TGridResult* result = collection->GetGridResult("",0 ,0);
665 TList* analysisfilelist = result->GetFileInfoList();
667 // Makes the ESD chain
668 printf("*** Getting the Chain ***\n");
669 TChain* analysisChain = new TChain(fESDTreeName);
670 analysisChain->AddFileInfoList(analysisfilelist);
672 // Process the events
673 rv = ProcessChain(analysisChain) ;
683 //______________________________________________________________________
684 Bool_t AliAnalysisGoodies::ProcessTagXmlCollection(const char * xmlFile, AliRunTagCuts *runCuts, AliLHCTagCuts *lhcCuts, AliDetectorTagCuts *detCuts, AliEventTagCuts * evtCuts) const
686 // process the events in a xml ESD collection with an Analysis Task
687 // usage ProcessLocalEsdFile(xmlFile)
688 // xmlFile: is the local xml file with the tag collection ( ex: tagCollection.xml)
692 if ( !evtCuts && !runCuts ) {
693 AliError("No Tag cuts provided") ;
697 printf("*** Process ***\n");
698 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
699 printf("*** Coll = |%s| \n",xmlFile);
701 // check if file is local or alien
702 if ( gSystem->AccessPathName(xmlFile) )
703 TGrid::Connect("alien://");
707 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)",xmlFile));
709 AliError(Form("%s not found", xmlFile)) ;
713 TGridResult* result = collection->GetGridResult("", 0, 0);
714 AliTagAnalysis * tagAna = new AliTagAnalysis();
715 tagAna->ChainGridTags(result);
717 // Query the tag file and make the analysis chain
718 TChain * analysisChain = new TChain(fESDTreeName) ;
719 analysisChain = tagAna->QueryTags(runCuts, lhcCuts, detCuts, evtCuts);
721 // Process the events
722 rv = ProcessChain(analysisChain) ;
730 //______________________________________________________________________
731 Bool_t AliAnalysisGoodies::ProcessTagXmlCollection(const char * xmlFile, const char * runCuts, const char * lhcCuts, const char * detCuts, const char * evtCuts) const
733 // process the events in a xml ESD collection with an Analysis Task
734 // usage ProcessLocalEsdFile(xmlFile)
735 // xmlFile: is the local xml file with the tag collection ( ex: tagCollection.xml)
739 if ( !evtCuts && !runCuts ) {
740 AliError("No Tag cuts provided") ;
744 printf("*** Process ***\n");
745 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
746 printf("*** Coll = |%s| \n",xmlFile);
750 // check if file is local or alien
751 if ( gSystem->AccessPathName(xmlFile) )
752 TGrid::Connect("alien://");
754 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)",xmlFile));
756 AliError(Form("%s not found", xmlFile)) ;
760 TGridResult* result = collection->GetGridResult("", 0, 0);
761 AliTagAnalysis * tagAna = new AliTagAnalysis();
762 tagAna->ChainGridTags(result);
764 // Query the tag file and make the analysis chain
765 TChain * analysisChain = new TChain(fESDTreeName) ;
766 analysisChain = tagAna->QueryTags(runCuts, lhcCuts, detCuts, evtCuts);
768 // Process the events
769 rv = ProcessChain(analysisChain) ;
777 //______________________________________________________________________
778 Bool_t AliAnalysisGoodies::Register( const char * lfndir, const char * pfndir, const char * file)
780 // register files already stored in a MSS into the AliEn catalog
781 // usage: Register(lfndir, pfndir, pfnFileName)
782 // lfndir : AliEn directory ( ex: /alice/data/2006/LHC06c/PHOS_TestBeam/ )
783 // pfndir : MSS directory ( ex: /castor/cern.ch/alice/testbeam/phos/2006 )
784 // file : text file with a list of the file names to be registered
792 AliError(Form("Cannot open file %s\n", file)) ;
796 TGrid::Connect("alien://");
798 char fileName[1024] ;
806 sprintf(lfn, "%s/%s", lfndir, fileName) ;
810 sprintf(pfn, "castor://Alice::CERN::Castor2/%s/%s", pfndir, fileName) ;
812 printf("Register %s as %s\n", pfn, lfn) ;
814 gGrid->Register(lfn, pfn) ;