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"),
52 // connects to alien and creates an analysis manager
56 TString token = gSystem->Getenv("GRID_TOKEN") ;
59 TGrid::Connect("alien://");
61 AliInfo("You are not connected to the GRID") ;
62 // Make the analysis manager
63 fAmgr = new AliAnalysisManager("Goodies Manager", "Analysis manager created by AliAnalysisGoodies") ;
66 //______________________________________________________________________________
67 AliAnalysisGoodies::AliAnalysisGoodies(const AliAnalysisGoodies& ag) :
74 // connects to alien and creates an analysis manager
76 fESDTreeName = ag.fESDTreeName ;
77 TString token = gSystem->Getenv("GRID_TOKEN") ;
80 TGrid::Connect("alien://");
82 AliInfo("You are not connected to the GRID") ;
84 // Make the analysis manager
85 fAmgr = new AliAnalysisManager("Goodies Manager", "Analysis manager created by AliAnalysisGoodies") ;
88 //______________________________________________________________________________
89 AliAnalysisGoodies& AliAnalysisGoodies::operator=(const AliAnalysisGoodies& ag)
91 // Assignment operator
98 //______________________________________________________________________________
99 void AliAnalysisGoodies::Help() const
102 // display all available utilities
103 AliInfo("Analysis utilities:\n") ;
104 printf(" *** Alien2Local : copy files ESD files listed in an xml collection from AliEn catalog to local storage and creates a local xml collection \n") ;
105 printf(" usage: Alien2Local(in, out)\n") ;
106 printf(" in: a xml esd collection file name \n") ;
107 printf(" ou: the local directory where to save the esd root files \n") ;
108 printf(" *** Make : makes esd collection from tags \n") ;
109 printf(" usage: Make(tags, esds)\n") ;
110 printf(" tags: is either a tag root file or an xml tag collection \n") ;
111 printf(" esds: is an esd collection \n") ;
112 printf(" *** Merge : merges files listed in a xml collection \n") ;
113 printf(" usage Merge(collection, outputDile)\n") ;
114 printf(" collection: is a xml collection \n") ;
115 printf(" *** Process : process the events with an Analysis Task \n") ;
116 printf(" usage: Process(esdFile, tagCuts) \n") ;
117 printf(" esdFile: can be a root file with the ESD Tree ( ex: esd?AliESDs.root) \n") ;
118 printf(" or a root file with the Tag Tree ( ex: tag?Run100.Event0_100.ESD.tag.root) \n") ;
119 printf(" or a local or alien xml file with the ESD collection ( ex: esd?esdCollection.xml) \n") ;
120 printf(" or a local or alien xml file with the TAG collection ( ex: tag?tagCollection.xml) \n") ;
121 printf(" or a TChain of esd TTrees \n") ;
122 printf(" tagCuts: is the AliEventTagCuts (needed only for tag? cases \n") ;
123 printf(" *** Register: register files already stored in a MSS into the AliEn catalog\n") ;
124 printf(" usage: Register(lfndir, pfndir, pfnFileName) \n") ;
125 printf(" lfndir : AliEn directory ( ex: /alice/data/2006/LHC06c/PHOS_TestBeam/\n") ;
126 printf(" pfndir : MSS directory ( ex: /castor/cern.ch/alice/testbeam/phos/2006 \n") ;
127 printf(" file : text file with a list of the file names to be registered\n ") ;
131 //______________________________________________________________________
132 Bool_t AliAnalysisGoodies::Alien2Local(const TString collectionNameIn, const TString localDir)
134 // copy files ESD files listed in an xml collection from AliEn catalog to local storage and creates a local xml collection
135 // usage: Alien2Local(in, out)
136 // in: a xml esd collection file name
137 // ou: the local directory where to save the esd root files
144 AliXMLCollection * collectionIn = AliXMLCollection::Open(collectionNameIn) ;
145 collectionIn->Reset() ;
147 AliXMLCollection * collectionOu = new AliXMLCollection() ;
148 TString collectionNameOu(collectionIn->GetCollectionName()) ;
149 collectionNameOu.Append("Local") ;
150 collectionOu->SetCollectionName(collectionNameOu) ;
151 collectionOu->WriteHeader() ;
153 const char* ocwd = gSystem->WorkingDirectory();
156 while ( collectionIn->Next() ) {
157 gSystem->ChangeDirectory(localDir) ;
158 TString fileTURL = collectionIn->GetTURL("") ;
160 TString tempo(fileTURL) ;
161 tempo.Remove(tempo.Last('/'), tempo.Length()) ;
162 TString evtsNumber = tempo(tempo.Last('/')+1, tempo.Length())+"/";
163 tempo.Remove(tempo.Last('/'), tempo.Length()) ;
164 TString runNumber = tempo(tempo.Last('/')+1, tempo.Length())+"/" ;
165 TString dir = localDir + runNumber ;
168 sprintf(line, ".! mkdir -p %s", dir.Data()) ;
169 gROOT->ProcessLine(line) ;
170 printf("***************************%s\n", line) ;
171 TEntryList * list = collectionIn->GetEventList("") ;
173 list = new TEntryList() ;
175 TString filename = tempo(tempo.Last('/')+1, tempo.Length()) ;
177 AliInfo(Form("Copying %s to %s\n", fileTURL.Data(), dir.Data())) ;
178 collectionOu->WriteBody(counter, collectionIn->GetGUID(""), collectionIn->GetLFN(""), dir, list) ;
180 TFile::Cp(fileTURL, dir) ;
182 collectionOu->Export() ;
183 gSystem->ChangeDirectory(ocwd) ;
194 //______________________________________________________________________
195 AliAnalysisDataContainer * AliAnalysisGoodies::ConnectInput(AliAnalysisTask * task, TClass * classin, UShort_t index)
197 // connect a task to the input
199 if ( ! fAmgr->GetTask(task->GetName()) )
200 fAmgr->AddTask(task) ;
202 AliFatal(Form("Task %s already exists", task->GetName())) ;
204 AliAnalysisDataContainer * taskInput = 0x0 ;
205 if ( fAmgr->GetInputs() )
206 taskInput = dynamic_cast<AliAnalysisDataContainer *>(fAmgr->GetInputs()->FindObject(Form("InputContainer_%s_%d", task->GetName(), index))) ;
208 taskInput = fAmgr->CreateContainer(Form("InputContainer_%s_%d", task->GetName(), index), classin, AliAnalysisManager::kInputContainer) ;
209 fAmgr->ConnectInput (task, index, taskInput);
212 AliFatal(Form("Input %s already exists", taskInput->GetName())) ;
217 //______________________________________________________________________
218 void AliAnalysisGoodies::ConnectInput(AliAnalysisTask * task, AliAnalysisDataContainer * taskInput, UShort_t index)
220 // connect a task to the input
222 if ( ! fAmgr->GetTask(task->GetName()) )
223 fAmgr->AddTask(task) ;
225 AliFatal(Form("Task %s already exists", task->GetName())) ;
227 fAmgr->ConnectInput (task, index, taskInput);
230 //______________________________________________________________________
231 AliAnalysisDataContainer * AliAnalysisGoodies::ConnectOuput(AliAnalysisTask * task, TClass * classou, UShort_t index, TString opt )
233 // connect a task to the output
238 if ( fAmgr->GetOutputEventHandler() == 0x0) {
239 AliAODHandler * aodHandler = new AliAODHandler() ;
240 aodHandler->SetOutputFileName(Form("%s_0.root",task->GetName())) ;
241 fAmgr->SetOutputEventHandler(aodHandler) ;
243 sprintf(filename, "default") ;
246 sprintf(filename, "%s_%d.root",task->GetName(), index) ;
248 AliAnalysisDataContainer * taskOuput = 0x0 ;
249 if ( fAmgr->GetOutputs() )
250 taskOuput = dynamic_cast<AliAnalysisDataContainer *>(fAmgr->GetOutputs()->FindObject(Form("OutputContainer_%s_%d", task->GetName(), index))) ;
252 taskOuput = fAmgr->CreateContainer(Form("OutputContainer_%s_%d", task->GetName(), index), classou, AliAnalysisManager::kOutputContainer, filename) ;
253 fAmgr->ConnectOutput(task, index, taskOuput);
258 //______________________________________________________________________
259 void AliAnalysisGoodies::ConnectOuput(AliAnalysisTask * task, AliAnalysisDataContainer * taskOuput, UShort_t index)
261 // connect a task to the output
263 fAmgr->ConnectInput (task, index, taskOuput);
266 //______________________________________________________________________
267 Bool_t AliAnalysisGoodies::Make(AliRunTagCuts *runCuts, AliLHCTagCuts *lhcCuts, AliDetectorTagCuts *detCuts, AliEventTagCuts *evtCuts, const char * in, const char * out) const
269 // makes esd collection from tags
270 // usage Make(tags, esds)
271 // tags: is either a tag root file or an xml tag collection
272 // esds: is an esd collection
276 if ( !evtCuts && !runCuts ) {
277 AliError("No Tag cuts provided") ;
282 if ( file.Contains(".root") )
283 rv = MakeEsdCollectionFromTagFile(runCuts, lhcCuts, detCuts, evtCuts, file.Data(), out) ;
284 else if ( file.Contains(".xml") )
285 rv = MakeEsdCollectionFromTagCollection(runCuts, lhcCuts, detCuts, evtCuts, file.Data(), out) ;
287 AliError(Form("%s is not a valid file format", in)) ;
294 //______________________________________________________________________
295 Bool_t AliAnalysisGoodies::MakeEsdCollectionFromTagFile(AliRunTagCuts *runCuts, AliLHCTagCuts *lhcCuts, AliDetectorTagCuts *detCuts, AliEventTagCuts *evtCuts, const char * in, const char * out) const
297 // Makes an esd collection from a root tag file
299 // Open the file collection
300 printf("*** Create Collection ***\n");
301 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
302 printf("*** file = |%s| \n",in);
304 AliTagAnalysis * tagAna = new AliTagAnalysis();
305 rv = tagAna->AddTagsFile(in);
309 tagAna->CreateXMLCollection(out, runCuts, lhcCuts, detCuts, evtCuts) ;
315 //______________________________________________________________________
316 Bool_t AliAnalysisGoodies::MakeEsdCollectionFromTagCollection(AliRunTagCuts *runCuts, AliLHCTagCuts *lhcCuts, AliDetectorTagCuts *detCuts, AliEventTagCuts *evtCuts, const char * in, const char * out) const
318 // Makes an esd collection from a xml tag collection
320 // Open the file collection
321 printf("*** Create Collection ***\n");
322 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
323 printf("*** Coll = |%s| \n",in);
327 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)",in));
328 TGridResult* result = collection->GetGridResult("", 0, 0);
329 AliTagAnalysis * tagAna = new AliTagAnalysis();
330 tagAna->ChainGridTags(result);
332 tagAna->CreateXMLCollection(out, runCuts, lhcCuts, detCuts, evtCuts) ;
340 //______________________________________________________________________
341 Bool_t AliAnalysisGoodies::MakeEsdCollectionFromTagCollection(const char * runCuts, const char *lhcCuts, const char *detCuts, const char * evtCuts, const char * in, const char * out) const
343 // Makes an esd collection from a xml tag collection
347 // Open the file collection
348 printf("*** Create Collection ***\n");
349 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
350 printf("*** Coll = |%s| \n",in);
354 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)",in));
355 TGridResult* result = collection->GetGridResult("", 0, 0);
356 AliTagAnalysis * tagAna = new AliTagAnalysis();
357 tagAna->ChainGridTags(result);
359 tagAna->CreateXMLCollection(out, runCuts, lhcCuts, detCuts, evtCuts) ;
367 //______________________________________________________________________
368 Bool_t AliAnalysisGoodies::Merge(const char * collectionFile, const char * subFile, const char * outFile)
370 // merges files listed in a xml collection
371 // usage Merge(collection, outputFile))
372 // collection: is a xml collection
376 if ( strstr(collectionFile, ".xml") == 0 ) {
377 AliError("Input collection file must be an \".xml\" file\n") ;
383 // Open the file collection
384 printf("*** Create Collection ***\n");
385 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
386 printf("*** Coll = |%s| \n",collectionFile);
390 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)",collectionFile));
391 TGridResult* result = collection->GetGridResult("", 0, 0);
397 TString tempo(collectionFile) ;
399 tempo.ReplaceAll(".xml", subFile) ;
401 tempo.ReplaceAll(".xml", "_Merged.root") ;
402 outFile = tempo.Data() ;
404 merger.OutputFile(outFile) ;
406 while ( (turl = result->GetKey(index, "turl")) ) {
409 sprintf(file, "%s#%s", turl, subFile) ;
411 sprintf(file, "%s", turl) ;
413 printf("%s\n", file) ;
414 merger.AddFile(file) ;
421 AliInfo(Form("Files merged into %s\n", outFile)) ;
432 //______________________________________________________________________
433 Bool_t AliAnalysisGoodies::Process(TChain * chain)
435 // process events starting from a chain of esd Trees
439 rv = ProcessChain(chain) ;
447 //______________________________________________________________________
448 Bool_t AliAnalysisGoodies::Process(const char * inFile)
450 // process the events with an Analysis Task
451 // usage Process(esdFile)
452 // esdFile: is of the form opt?file_lfn
454 AliRunTagCuts * runCuts = 0x0 ;
455 AliLHCTagCuts * lhcCuts = 0x0 ;
456 AliDetectorTagCuts * detCuts = 0x0 ;
457 AliEventTagCuts * evtCuts = 0x0 ;
459 rv = Process(inFile, runCuts, lhcCuts, detCuts, evtCuts) ;
464 //______________________________________________________________________
465 Bool_t AliAnalysisGoodies::Process(const char * inFile, AliRunTagCuts *runCuts, AliLHCTagCuts *lhcCuts, AliDetectorTagCuts *detCuts, AliEventTagCuts * evtCuts )
467 // process the events with an Analysis Task
468 // usage Process(esdFile, runtagCuts, evtTagCuts)
469 // esdFile: is of the form opt?file_lfn
475 TString file(inFile) ;
476 if ( file.Contains("esd?") && file.Contains(".root") ) {
477 file.ReplaceAll("esd?", "") ;
478 rv = ProcessEsdFile(file.Data()) ;
480 } else if ( file.Contains("esd?") && file.Contains(".xml") ) {
481 file.ReplaceAll("esd?", "") ;
482 rv = ProcessEsdXmlCollection(file.Data()) ;
484 } else if (file.Contains("tag?") && file.Contains(".root") ) {
485 file.ReplaceAll("tag?", "") ;
486 rv = ProcessTagFile(file.Data(), runCuts, lhcCuts, detCuts, evtCuts) ;
488 } else if (file.Contains("tag?") && file.Contains(".xml") ) {
489 file.ReplaceAll("tag?", "") ;
490 rv = ProcessTagXmlCollection(file.Data(), runCuts, lhcCuts, detCuts, evtCuts) ;
493 AliError(Form("%s is not a valid file format", inFile)) ;
503 //______________________________________________________________________
504 Bool_t AliAnalysisGoodies::Process(const char * inFile, const char * runCuts, const char * lhcCuts, const char * detCuts, const char * evtCuts)
506 // process the events with an Analysis Task
507 // usage Process(esdFile, runtagCuts, evtTagCuts)
508 // esdFile: is of the form opt?file_lfn
514 TString file(inFile) ;
515 if ( file.Contains("esd?") && file.Contains(".root") ) {
516 file.ReplaceAll("esd?", "") ;
517 rv = ProcessEsdFile(file.Data()) ;
519 } else if ( file.Contains("esd?") && file.Contains(".xml") ) {
520 file.ReplaceAll("esd?", "") ;
521 rv = ProcessEsdXmlCollection(file.Data()) ;
523 } else if (file.Contains("tag?") && file.Contains(".root") ) {
524 file.ReplaceAll("tag?", "") ;
525 rv = ProcessTagFile(file.Data(), runCuts, lhcCuts, detCuts, evtCuts) ;
527 } else if (file.Contains("tag?") && file.Contains(".xml") ) {
528 file.ReplaceAll("tag?", "") ;
529 rv = ProcessTagXmlCollection(file.Data(), runCuts, lhcCuts, detCuts, evtCuts) ;
532 AliError(Form("%s is not a valid file format", inFile)) ;
542 //______________________________________________________________________
543 Bool_t AliAnalysisGoodies::ProcessChain(TChain * chain) const
550 if (fAmgr->InitAnalysis()) {
551 fAmgr->PrintStatus();
552 fAmgr->StartAnalysis("local",chain);
559 //______________________________________________________________________
560 Bool_t AliAnalysisGoodies::ProcessEsdFile(const char * esdFile) const
562 // process the events in a single ESD file with an Analysis Task
563 // usage ProcessLocalEsdFile(esdFile)
564 // esdFile: is the root file (local or in alien) with the ESD Tree ( ex: AliESDs.root)
568 printf("*** Process ***\n");
569 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
570 printf("*** Coll = |%s| \n",esdFile);
572 // Makes the ESD chain
573 printf("*** Getting the Chain ***\n");
574 TChain* analysisChain = new TChain(fESDTreeName) ;
575 analysisChain->AddFile(esdFile);
577 // Process the events
578 rv = ProcessChain(analysisChain) ;
583 //______________________________________________________________________
584 Bool_t AliAnalysisGoodies::ProcessTagFile(const char * tagFile, AliRunTagCuts *runCuts, AliLHCTagCuts *lhcCuts, AliDetectorTagCuts *detCuts, AliEventTagCuts *evtCuts) const
586 // process the events in a single Tag file with an Analysis Task
587 // usage ProcessLocalEsdFile(tagFile)
588 // tagFile: is the root file (local or in alien) with the Tag Tree (ex: Run102.Event0_100.ESD.tag.root)
592 if ( !evtCuts && !runCuts ) {
593 AliError("No Tag cuts provided") ;
597 printf("*** Process ***\n");
598 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
599 printf("*** Coll = |%s| \n",tagFile);
601 AliTagAnalysis * tagAna = new AliTagAnalysis();
602 rv = tagAna->AddTagsFile(tagFile);
606 // Query the tag file and make the analysis chain
607 TChain * analysisChain = new TChain(fESDTreeName) ;
608 analysisChain = tagAna->QueryTags(runCuts, lhcCuts, detCuts, evtCuts);
610 // Process the events
611 rv = ProcessChain(analysisChain) ;
616 //______________________________________________________________________
617 Bool_t AliAnalysisGoodies::ProcessTagFile(const char * tagFile, const char * runCuts, const char * lhcCuts, const char * detCuts, const char * evtCuts) const
619 // process the events in a single Tag file with an Analysis Task
620 // usage ProcessLocalEsdFile(tagFile)
621 // tagFile: is the root file (local or in alien) with the Tag Tree (ex: Run102.Event0_100.ESD.tag.root)
626 if ( !evtCuts && !runCuts ) {
627 AliError("No Tag cuts provided") ;
631 printf("*** Process ***\n");
632 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
633 printf("*** Coll = |%s| \n",tagFile);
635 AliTagAnalysis * tagAna = new AliTagAnalysis();
636 rv = tagAna->AddTagsFile(tagFile);
640 // Query the tag file and make the analysis chain
641 TChain * analysisChain = new TChain(fESDTreeName) ;
642 analysisChain = tagAna->QueryTags(runCuts, lhcCuts, detCuts, evtCuts);
644 // Process the events
645 rv = ProcessChain(analysisChain) ;
650 //______________________________________________________________________
651 Bool_t AliAnalysisGoodies::ProcessEsdXmlCollection(const char * xmlFile) const
653 // process the events in a xml ESD collection with an Analysis Task
654 // usage ProcessLocalEsdFile(xmlFile)
655 // xmlFile: is the local xml file with the ESD collection ( ex: esdCollection.xml)
659 printf("*** Process ***\n");
660 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
661 printf("*** Coll = |%s| \n",xmlFile);
664 //AliXMLCollection * collection = AliXMLCollection::Open(xmlFile,0) ;
665 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)", xmlFile));
667 AliError(Form("%s not found", xmlFile)) ;
671 TGridResult* result = collection->GetGridResult("",0 ,0);
672 TList* analysisfilelist = result->GetFileInfoList();
674 // Makes the ESD chain
675 printf("*** Getting the Chain ***\n");
676 TChain* analysisChain = new TChain(fESDTreeName);
677 analysisChain->AddFileInfoList(analysisfilelist);
679 // Process the events
680 rv = ProcessChain(analysisChain) ;
690 //______________________________________________________________________
691 Bool_t AliAnalysisGoodies::ProcessTagXmlCollection(const char * xmlFile, AliRunTagCuts *runCuts, AliLHCTagCuts *lhcCuts, AliDetectorTagCuts *detCuts, AliEventTagCuts * evtCuts) const
693 // process the events in a xml ESD collection with an Analysis Task
694 // usage ProcessLocalEsdFile(xmlFile)
695 // xmlFile: is the local xml file with the tag collection ( ex: tagCollection.xml)
699 if ( !evtCuts && !runCuts ) {
700 AliError("No Tag cuts provided") ;
704 printf("*** Process ***\n");
705 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
706 printf("*** Coll = |%s| \n",xmlFile);
708 // check if file is local or alien
709 if ( gSystem->AccessPathName(xmlFile) )
710 TGrid::Connect("alien://");
714 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)",xmlFile));
716 AliError(Form("%s not found", xmlFile)) ;
720 TGridResult* result = collection->GetGridResult("", 0, 0);
721 AliTagAnalysis * tagAna = new AliTagAnalysis();
722 tagAna->ChainGridTags(result);
724 // Query the tag file and make the analysis chain
725 TChain * analysisChain = new TChain(fESDTreeName) ;
726 analysisChain = tagAna->QueryTags(runCuts, lhcCuts, detCuts, evtCuts);
728 // Process the events
729 rv = ProcessChain(analysisChain) ;
737 //______________________________________________________________________
738 Bool_t AliAnalysisGoodies::ProcessTagXmlCollection(const char * xmlFile, const char * runCuts, const char * lhcCuts, const char * detCuts, const char * evtCuts) const
740 // process the events in a xml ESD collection with an Analysis Task
741 // usage ProcessLocalEsdFile(xmlFile)
742 // xmlFile: is the local xml file with the tag collection ( ex: tagCollection.xml)
746 if ( !evtCuts && !runCuts ) {
747 AliError("No Tag cuts provided") ;
751 printf("*** Process ***\n");
752 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
753 printf("*** Coll = |%s| \n",xmlFile);
757 // check if file is local or alien
758 if ( gSystem->AccessPathName(xmlFile) )
759 TGrid::Connect("alien://");
761 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)",xmlFile));
763 AliError(Form("%s not found", xmlFile)) ;
767 TGridResult* result = collection->GetGridResult("", 0, 0);
768 AliTagAnalysis * tagAna = new AliTagAnalysis();
769 tagAna->ChainGridTags(result);
771 // Query the tag file and make the analysis chain
772 TChain * analysisChain = new TChain(fESDTreeName) ;
773 analysisChain = tagAna->QueryTags(runCuts, lhcCuts, detCuts, evtCuts);
775 // Process the events
776 rv = ProcessChain(analysisChain) ;
784 //______________________________________________________________________
785 Bool_t AliAnalysisGoodies::Register( const char * lfndir, const char * pfndir, const char * file)
787 // register files already stored in a MSS into the AliEn catalog
788 // usage: Register(lfndir, pfndir, pfnFileName)
789 // lfndir : AliEn directory ( ex: /alice/data/2006/LHC06c/PHOS_TestBeam/ )
790 // pfndir : MSS directory ( ex: /castor/cern.ch/alice/testbeam/phos/2006 )
791 // file : text file with a list of the file names to be registered
799 AliError(Form("Cannot open file %s\n", file)) ;
803 TGrid::Connect("alien://");
805 char fileName[1024] ;
813 sprintf(lfn, "%s/%s", lfndir, fileName) ;
817 sprintf(pfn, "castor://Alice::CERN::Castor2/%s/%s", pfndir, fileName) ;
819 printf("Register %s as %s\n", pfn, lfn) ;
821 gGrid->Register(lfn, pfn) ;