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>
41 #include <TEntryList.h>
43 //______________________________________________________________________________
44 AliAnalysisGoodies::AliAnalysisGoodies() :
47 fESDTreeName("esdTree"),
52 TString token = gSystem->Getenv("GRID_TOKEN") ;
55 TGrid::Connect("alien://");
57 AliInfo("You are not connected to the GRID") ;
58 // Make the analysis manager
59 fAmgr = new AliAnalysisManager("Goodies Manager", "Analysis manager created by AliAnalysisGoodies") ;
62 //______________________________________________________________________________
63 AliAnalysisGoodies::AliAnalysisGoodies(const AliAnalysisGoodies& ag) :
70 fESDTreeName = ag.fESDTreeName ;
71 TString token = gSystem->Getenv("GRID_TOKEN") ;
74 TGrid::Connect("alien://");
76 AliInfo("You are not connected to the GRID") ;
78 // Make the analysis manager
79 fAmgr = new AliAnalysisManager("Goodies Manager", "Analysis manager created by AliAnalysisGoodies") ;
82 //______________________________________________________________________________
83 AliAnalysisGoodies& AliAnalysisGoodies::operator=(const AliAnalysisGoodies& ag)
85 // Assignment operator
92 //______________________________________________________________________________
93 void AliAnalysisGoodies::Help() const
95 AliInfo("Analysis utilities:\n") ;
96 printf(" *** Alien2Local : copy files ESD files listed in an xml collection from AliEn catalog to local storage and creates a local xml collection \n") ;
97 printf(" usage: Alien2Local(in, out)\n") ;
98 printf(" in: a xml esd collection file name \n") ;
99 printf(" ou: the local directory where to save the esd root files \n") ;
100 printf(" *** Make : makes esd collection from tags \n") ;
101 printf(" usage: Make(tags, esds)\n") ;
102 printf(" tags: is either a tag root file or an xml tag collection \n") ;
103 printf(" esds: is an esd collection \n") ;
104 printf(" *** Merge : merges files listed in a xml collection \n") ;
105 printf(" usage Merge(collection, outputDile)\n") ;
106 printf(" collection: is a xml collection \n") ;
107 printf(" *** Process : process the events with an Analysis Task \n") ;
108 printf(" usage: Process(esdFile, tagCuts) \n") ;
109 printf(" esdFile: can be a root file with the ESD Tree ( ex: esd?AliESDs.root) \n") ;
110 printf(" or a root file with the Tag Tree ( ex: tag?Run100.Event0_100.ESD.tag.root) \n") ;
111 printf(" or a local or alien xml file with the ESD collection ( ex: esd?esdCollection.xml) \n") ;
112 printf(" or a local or alien xml file with the TAG collection ( ex: tag?tagCollection.xml) \n") ;
113 printf(" or a TChain of esd TTrees \n") ;
114 printf(" tagCuts: is the AliEventTagCuts (needed only for tag? cases \n") ;
115 printf(" *** Register: register files already stored in a MSS into the AliEn catalog\n") ;
116 printf(" usage: Register(lfndir, pfndir, pfnFileName) \n") ;
117 printf(" lfndir : AliEn directory ( ex: /alice/data/2006/LHC06c/PHOS_TestBeam/\n") ;
118 printf(" pfndir : MSS directory ( ex: /castor/cern.ch/alice/testbeam/phos/2006 \n") ;
119 printf(" file : text file with a list of the file names to be registered\n ") ;
123 //______________________________________________________________________
124 Bool_t AliAnalysisGoodies::Alien2Local(const TString collectionNameIn, const TString localDir)
126 // copy files ESD files listed in an xml collection from AliEn catalog to local storage and creates a local xml collection
127 // usage: Alien2Local(in, out)
128 // in: a xml esd collection file name
129 // ou: the local directory where to save the esd root files
136 AliXMLCollection * collectionIn = AliXMLCollection::Open(collectionNameIn) ;
137 collectionIn->Reset() ;
139 AliXMLCollection * collectionOu = new AliXMLCollection() ;
140 TString collectionNameOu(collectionIn->GetCollectionName()) ;
141 collectionNameOu.Append("Local") ;
142 collectionOu->SetCollectionName(collectionNameOu) ;
143 collectionOu->WriteHeader() ;
147 const char* ocwd = gSystem->WorkingDirectory();
150 while ( collectionIn->Next() ) {
151 gSystem->ChangeDirectory(localDir) ;
152 TString fileTURL = collectionIn->GetTURL("") ;
154 TString tempo(fileTURL) ;
155 tempo.Remove(tempo.Last('/'), tempo.Length()) ;
156 TString evtsNumber = tempo(tempo.Last('/')+1, tempo.Length())+"/";
157 tempo.Remove(tempo.Last('/'), tempo.Length()) ;
158 TString runNumber = tempo(tempo.Last('/')+1, tempo.Length())+"/" ;
159 TString dir = localDir + runNumber ;
162 sprintf(line, ".! mkdir -p %s", dir.Data()) ;
163 gROOT->ProcessLine(line) ;
164 printf("***************************%s\n", line) ;
165 TEntryList * list = collectionIn->GetEventList("") ;
167 list = new TEntryList() ;
169 TString filename = tempo(tempo.Last('/')+1, tempo.Length()) ;
171 AliInfo(Form("Copying %s to %s\n", fileTURL.Data(), dir.Data())) ;
172 collectionOu->WriteBody(counter, collectionIn->GetGUID(""), collectionIn->GetLFN(""), dir, list) ;
174 merger.Cp(fileTURL, dir) ;
176 collectionOu->Export() ;
177 gSystem->ChangeDirectory(ocwd) ;
188 //______________________________________________________________________
189 AliAnalysisDataContainer * AliAnalysisGoodies::ConnectInput(AliAnalysisTask * task, TClass * classin, UShort_t index)
191 // connect a task to the input
193 if ( ! fAmgr->GetTask(task->GetName()) )
194 fAmgr->AddTask(task) ;
196 AliFatal(Form("Task %s already exists", task->GetName())) ;
198 AliAnalysisDataContainer * taskInput = 0x0 ;
199 if ( fAmgr->GetInputs() )
200 taskInput = dynamic_cast<AliAnalysisDataContainer *>(fAmgr->GetInputs()->FindObject(Form("InputContainer_%s_%d", task->GetName(), index))) ;
202 taskInput = fAmgr->CreateContainer(Form("InputContainer_%s_%d", task->GetName(), index), classin, AliAnalysisManager::kInputContainer) ;
203 fAmgr->ConnectInput (task, index, taskInput);
206 AliFatal(Form("Input %s already exists", taskInput->GetName())) ;
211 //______________________________________________________________________
212 void AliAnalysisGoodies::ConnectInput(AliAnalysisTask * task, AliAnalysisDataContainer * taskInput, UShort_t index)
214 // connect a task to the input
216 if ( ! fAmgr->GetTask(task->GetName()) )
217 fAmgr->AddTask(task) ;
219 AliFatal(Form("Task %s already exists", task->GetName())) ;
221 fAmgr->ConnectInput (task, index, taskInput);
224 //______________________________________________________________________
225 AliAnalysisDataContainer * AliAnalysisGoodies::ConnectOuput(AliAnalysisTask * task, TClass * classou, UShort_t index, TString opt )
227 // connect a task to the output
232 if ( fAmgr->GetEventHandler() == 0x0) {
233 AliAODHandler * aodHandler = new AliAODHandler() ;
234 aodHandler->SetOutputFileName(Form("%s_0.root",task->GetName())) ;
235 fAmgr->SetEventHandler(aodHandler) ;
237 sprintf(filename, "default") ;
240 sprintf(filename, "%s_%d.root",task->GetName(), index) ;
242 AliAnalysisDataContainer * taskOuput = 0x0 ;
243 if ( fAmgr->GetOutputs() )
244 taskOuput = dynamic_cast<AliAnalysisDataContainer *>(fAmgr->GetOutputs()->FindObject(Form("OutputContainer_%s_%d", task->GetName(), index))) ;
246 taskOuput = fAmgr->CreateContainer(Form("OutputContainer_%s_%d", task->GetName(), index), classou, AliAnalysisManager::kOutputContainer, filename) ;
247 fAmgr->ConnectOutput(task, index, taskOuput);
252 //______________________________________________________________________
253 void AliAnalysisGoodies::ConnectOuput(AliAnalysisTask * task, AliAnalysisDataContainer * taskOuput, UShort_t index)
255 // connect a task to the output
257 fAmgr->ConnectInput (task, index, taskOuput);
260 //______________________________________________________________________
261 Bool_t AliAnalysisGoodies::Make(AliRunTagCuts *runCuts, AliLHCTagCuts *lhcCuts, AliDetectorTagCuts *detCuts, AliEventTagCuts *evtCuts, const char * in, const char * out) const
263 // makes esd collection from tags
264 // usage Make(tags, esds)
265 // tags: is either a tag root file or an xml tag collection
266 // esds: is an esd collection
270 if ( !evtCuts && !runCuts ) {
271 AliError("No Tag cuts provided") ;
276 if ( file.Contains(".root") )
277 rv = MakeEsdCollectionFromTagFile(runCuts, lhcCuts, detCuts, evtCuts, file.Data(), out) ;
278 else if ( file.Contains(".xml") )
279 rv = MakeEsdCollectionFromTagCollection(runCuts, lhcCuts, detCuts, evtCuts, file.Data(), out) ;
281 AliError(Form("%s is not a valid file format", in)) ;
288 //______________________________________________________________________
289 Bool_t AliAnalysisGoodies::MakeEsdCollectionFromTagFile(AliRunTagCuts *runCuts, AliLHCTagCuts *lhcCuts, AliDetectorTagCuts *detCuts, AliEventTagCuts *evtCuts, const char * in, const char * out) const
291 // Makes an esd collection from a root tag file
293 // Open the file collection
294 printf("*** Create Collection ***\n");
295 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
296 printf("*** file = |%s| \n",in);
298 AliTagAnalysis * tagAna = new AliTagAnalysis();
299 rv = tagAna->AddTagsFile(in);
303 tagAna->CreateXMLCollection(out, runCuts, lhcCuts, detCuts, evtCuts) ;
309 //______________________________________________________________________
310 Bool_t AliAnalysisGoodies::MakeEsdCollectionFromTagCollection(AliRunTagCuts *runCuts, AliLHCTagCuts *lhcCuts, AliDetectorTagCuts *detCuts, AliEventTagCuts *evtCuts, const char * in, const char * out) const
312 // Makes an esd collection from a xml tag collection
314 // Open the file collection
315 printf("*** Create Collection ***\n");
316 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
317 printf("*** Coll = |%s| \n",in);
321 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)",in));
322 TGridResult* result = collection->GetGridResult("", 0, 0);
323 AliTagAnalysis * tagAna = new AliTagAnalysis();
324 tagAna->ChainGridTags(result);
326 tagAna->CreateXMLCollection(out, runCuts, lhcCuts, detCuts, evtCuts) ;
334 //______________________________________________________________________
335 Bool_t AliAnalysisGoodies::MakeEsdCollectionFromTagCollection(const char * runCuts, const char *lhcCuts, const char *detCuts, const char * evtCuts, const char * in, const char * out) const
337 // Makes an esd collection from a xml tag collection
341 // Open the file collection
342 printf("*** Create Collection ***\n");
343 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
344 printf("*** Coll = |%s| \n",in);
348 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)",in));
349 TGridResult* result = collection->GetGridResult("", 0, 0);
350 AliTagAnalysis * tagAna = new AliTagAnalysis();
351 tagAna->ChainGridTags(result);
353 tagAna->CreateXMLCollection(out, runCuts, lhcCuts, detCuts, evtCuts) ;
361 //______________________________________________________________________
362 Bool_t AliAnalysisGoodies::Merge(const char * collectionFile, const char * subFile, const char * outFile)
364 // merges files listed in a xml collection
365 // usage Merge(collection, outputFile))
366 // collection: is a xml collection
370 if ( strstr(collectionFile, ".xml") == 0 ) {
371 AliError("Input collection file must be an \".xml\" file\n") ;
377 // Open the file collection
378 printf("*** Create Collection ***\n");
379 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
380 printf("*** Coll = |%s| \n",collectionFile);
384 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)",collectionFile));
385 TGridResult* result = collection->GetGridResult("", 0, 0);
391 TString tempo(collectionFile) ;
393 tempo.ReplaceAll(".xml", subFile) ;
395 tempo.ReplaceAll(".xml", "_Merged.root") ;
396 outFile = tempo.Data() ;
398 merger.OutputFile(outFile) ;
400 while ( (turl = result->GetKey(index, "turl")) ) {
403 sprintf(file, "%s#%s", turl, subFile) ;
405 sprintf(file, "%s", turl) ;
407 printf("%s\n", file) ;
408 merger.AddFile(file) ;
415 AliInfo(Form("Files merged into %s\n", outFile)) ;
426 //______________________________________________________________________
427 Bool_t AliAnalysisGoodies::Process(TChain * chain)
429 // process events starting from a chain of esd Trees
433 rv = ProcessChain(chain) ;
441 //______________________________________________________________________
442 Bool_t AliAnalysisGoodies::Process(const char * inFile)
444 // process the events with an Analysis Task
445 // usage Process(esdFile)
446 // esdFile: is of the form opt?file_lfn
448 AliRunTagCuts * runCuts = 0x0 ;
449 AliLHCTagCuts * lhcCuts = 0x0 ;
450 AliDetectorTagCuts * detCuts = 0x0 ;
451 AliEventTagCuts * evtCuts = 0x0 ;
453 rv = Process(inFile, runCuts, lhcCuts, detCuts, evtCuts) ;
458 //______________________________________________________________________
459 Bool_t AliAnalysisGoodies::Process(const char * inFile, AliRunTagCuts *runCuts, AliLHCTagCuts *lhcCuts, AliDetectorTagCuts *detCuts, AliEventTagCuts * evtCuts )
461 // process the events with an Analysis Task
462 // usage Process(esdFile, runtagCuts, evtTagCuts)
463 // esdFile: is of the form opt?file_lfn
469 TString file(inFile) ;
470 if ( file.Contains("esd?") && file.Contains(".root") ) {
471 file.ReplaceAll("esd?", "") ;
472 rv = ProcessEsdFile(file.Data()) ;
474 } else if ( file.Contains("esd?") && file.Contains(".xml") ) {
475 file.ReplaceAll("esd?", "") ;
476 rv = ProcessEsdXmlCollection(file.Data()) ;
478 } else if (file.Contains("tag?") && file.Contains(".root") ) {
479 file.ReplaceAll("tag?", "") ;
480 rv = ProcessTagFile(file.Data(), runCuts, lhcCuts, detCuts, evtCuts) ;
482 } else if (file.Contains("tag?") && file.Contains(".xml") ) {
483 file.ReplaceAll("tag?", "") ;
484 rv = ProcessTagXmlCollection(file.Data(), runCuts, lhcCuts, detCuts, evtCuts) ;
487 AliError(Form("%s is not a valid file format", inFile)) ;
497 //______________________________________________________________________
498 Bool_t AliAnalysisGoodies::Process(const char * inFile, const char * runCuts, const char * lhcCuts, const char * detCuts, const char * evtCuts)
500 // process the events with an Analysis Task
501 // usage Process(esdFile, runtagCuts, evtTagCuts)
502 // esdFile: is of the form opt?file_lfn
508 TString file(inFile) ;
509 if ( file.Contains("esd?") && file.Contains(".root") ) {
510 file.ReplaceAll("esd?", "") ;
511 rv = ProcessEsdFile(file.Data()) ;
513 } else if ( file.Contains("esd?") && file.Contains(".xml") ) {
514 file.ReplaceAll("esd?", "") ;
515 rv = ProcessEsdXmlCollection(file.Data()) ;
517 } else if (file.Contains("tag?") && file.Contains(".root") ) {
518 file.ReplaceAll("tag?", "") ;
519 rv = ProcessTagFile(file.Data(), runCuts, lhcCuts, detCuts, evtCuts) ;
521 } else if (file.Contains("tag?") && file.Contains(".xml") ) {
522 file.ReplaceAll("tag?", "") ;
523 rv = ProcessTagXmlCollection(file.Data(), runCuts, lhcCuts, detCuts, evtCuts) ;
526 AliError(Form("%s is not a valid file format", inFile)) ;
536 //______________________________________________________________________
537 Bool_t AliAnalysisGoodies::ProcessChain(TChain * chain) const
544 if (fAmgr->InitAnalysis()) {
545 fAmgr->PrintStatus();
546 fAmgr->StartAnalysis("local",chain);
553 //______________________________________________________________________
554 Bool_t AliAnalysisGoodies::ProcessEsdFile(const char * esdFile) const
556 // process the events in a single ESD file with an Analysis Task
557 // usage ProcessLocalEsdFile(esdFile)
558 // esdFile: is the root file (local or in alien) with the ESD Tree ( ex: AliESDs.root)
562 printf("*** Process ***\n");
563 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
564 printf("*** Coll = |%s| \n",esdFile);
566 // Makes the ESD chain
567 printf("*** Getting the Chain ***\n");
568 TChain* analysisChain = new TChain(fESDTreeName) ;
569 analysisChain->AddFile(esdFile);
571 // Process the events
572 rv = ProcessChain(analysisChain) ;
577 //______________________________________________________________________
578 Bool_t AliAnalysisGoodies::ProcessTagFile(const char * tagFile, AliRunTagCuts *runCuts, AliLHCTagCuts *lhcCuts, AliDetectorTagCuts *detCuts, AliEventTagCuts *evtCuts) const
580 // process the events in a single Tag file with an Analysis Task
581 // usage ProcessLocalEsdFile(tagFile)
582 // tagFile: is the root file (local or in alien) with the Tag Tree (ex: Run102.Event0_100.ESD.tag.root)
586 if ( !evtCuts && !runCuts ) {
587 AliError("No Tag cuts provided") ;
591 printf("*** Process ***\n");
592 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
593 printf("*** Coll = |%s| \n",tagFile);
595 AliTagAnalysis * tagAna = new AliTagAnalysis();
596 rv = tagAna->AddTagsFile(tagFile);
600 // Query the tag file and make the analysis chain
601 TChain * analysisChain = new TChain(fESDTreeName) ;
602 analysisChain = tagAna->QueryTags(runCuts, lhcCuts, detCuts, evtCuts);
604 // Process the events
605 rv = ProcessChain(analysisChain) ;
610 //______________________________________________________________________
611 Bool_t AliAnalysisGoodies::ProcessTagFile(const char * tagFile, const char * runCuts, const char * lhcCuts, const char * detCuts, const char * evtCuts) const
613 // process the events in a single Tag file with an Analysis Task
614 // usage ProcessLocalEsdFile(tagFile)
615 // tagFile: is the root file (local or in alien) with the Tag Tree (ex: Run102.Event0_100.ESD.tag.root)
620 if ( !evtCuts && !runCuts ) {
621 AliError("No Tag cuts provided") ;
625 printf("*** Process ***\n");
626 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
627 printf("*** Coll = |%s| \n",tagFile);
629 AliTagAnalysis * tagAna = new AliTagAnalysis();
630 rv = tagAna->AddTagsFile(tagFile);
634 // Query the tag file and make the analysis chain
635 TChain * analysisChain = new TChain(fESDTreeName) ;
636 analysisChain = tagAna->QueryTags(runCuts, lhcCuts, detCuts, evtCuts);
638 // Process the events
639 rv = ProcessChain(analysisChain) ;
644 //______________________________________________________________________
645 Bool_t AliAnalysisGoodies::ProcessEsdXmlCollection(const char * xmlFile) const
647 // process the events in a xml ESD collection with an Analysis Task
648 // usage ProcessLocalEsdFile(xmlFile)
649 // xmlFile: is the local xml file with the ESD collection ( ex: esdCollection.xml)
653 printf("*** Process ***\n");
654 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
655 printf("*** Coll = |%s| \n",xmlFile);
658 //AliXMLCollection * collection = AliXMLCollection::Open(xmlFile,0) ;
659 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)", xmlFile));
661 AliError(Form("%s not found", xmlFile)) ;
665 TGridResult* result = collection->GetGridResult("",0 ,0);
666 TList* analysisfilelist = result->GetFileInfoList();
668 // Makes the ESD chain
669 printf("*** Getting the Chain ***\n");
670 TChain* analysisChain = new TChain(fESDTreeName);
671 analysisChain->AddFileInfoList(analysisfilelist);
673 // Process the events
674 rv = ProcessChain(analysisChain) ;
684 //______________________________________________________________________
685 Bool_t AliAnalysisGoodies::ProcessTagXmlCollection(const char * xmlFile, AliRunTagCuts *runCuts, AliLHCTagCuts *lhcCuts, AliDetectorTagCuts *detCuts, AliEventTagCuts * evtCuts) const
687 // process the events in a xml ESD collection with an Analysis Task
688 // usage ProcessLocalEsdFile(xmlFile)
689 // xmlFile: is the local xml file with the tag collection ( ex: tagCollection.xml)
693 if ( !evtCuts && !runCuts ) {
694 AliError("No Tag cuts provided") ;
698 printf("*** Process ***\n");
699 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
700 printf("*** Coll = |%s| \n",xmlFile);
702 // check if file is local or alien
703 if ( gSystem->AccessPathName(xmlFile) )
704 TGrid::Connect("alien://");
708 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)",xmlFile));
710 AliError(Form("%s not found", xmlFile)) ;
714 TGridResult* result = collection->GetGridResult("", 0, 0);
715 AliTagAnalysis * tagAna = new AliTagAnalysis();
716 tagAna->ChainGridTags(result);
718 // Query the tag file and make the analysis chain
719 TChain * analysisChain = new TChain(fESDTreeName) ;
720 analysisChain = tagAna->QueryTags(runCuts, lhcCuts, detCuts, evtCuts);
722 // Process the events
723 rv = ProcessChain(analysisChain) ;
731 //______________________________________________________________________
732 Bool_t AliAnalysisGoodies::ProcessTagXmlCollection(const char * xmlFile, const char * runCuts, const char * lhcCuts, const char * detCuts, const char * evtCuts) const
734 // process the events in a xml ESD collection with an Analysis Task
735 // usage ProcessLocalEsdFile(xmlFile)
736 // xmlFile: is the local xml file with the tag collection ( ex: tagCollection.xml)
740 if ( !evtCuts && !runCuts ) {
741 AliError("No Tag cuts provided") ;
745 printf("*** Process ***\n");
746 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
747 printf("*** Coll = |%s| \n",xmlFile);
751 // check if file is local or alien
752 if ( gSystem->AccessPathName(xmlFile) )
753 TGrid::Connect("alien://");
755 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)",xmlFile));
757 AliError(Form("%s not found", xmlFile)) ;
761 TGridResult* result = collection->GetGridResult("", 0, 0);
762 AliTagAnalysis * tagAna = new AliTagAnalysis();
763 tagAna->ChainGridTags(result);
765 // Query the tag file and make the analysis chain
766 TChain * analysisChain = new TChain(fESDTreeName) ;
767 analysisChain = tagAna->QueryTags(runCuts, lhcCuts, detCuts, evtCuts);
769 // Process the events
770 rv = ProcessChain(analysisChain) ;
778 //______________________________________________________________________
779 Bool_t AliAnalysisGoodies::Register( const char * lfndir, const char * pfndir, const char * file)
781 // register files already stored in a MSS into the AliEn catalog
782 // usage: Register(lfndir, pfndir, pfnFileName)
783 // lfndir : AliEn directory ( ex: /alice/data/2006/LHC06c/PHOS_TestBeam/ )
784 // pfndir : MSS directory ( ex: /castor/cern.ch/alice/testbeam/phos/2006 )
785 // file : text file with a list of the file names to be registered
793 AliError(Form("Cannot open file %s\n", file)) ;
797 TGrid::Connect("alien://");
799 char fileName[1024] ;
807 sprintf(lfn, "%s/%s", lfndir, fileName) ;
811 sprintf(pfn, "castor://Alice::CERN::Castor2/%s/%s", pfndir, fileName) ;
813 printf("Register %s as %s\n", pfn, lfn) ;
815 gGrid->Register(lfn, pfn) ;