49 fXmlFile = localcollectionfile;
50 fFileGroupList =
new TList();
51 fFileGroupList->SetOwner(
kTRUE);
52 fFileGroupListIter =
new TIter(fFileGroupList);
62 fCollectionName =
"unnamed";
64 if (localcollectionfile != 0) {
121 coll +=
"/aliencollection.";
124 ::Error(
"TAlienCollection::Open",
"Cannot make a local copy of collection with url %s",
134 ::Error(
"TAlienCollection::Open",
"Cannot remove the local copy of the collection %s",
146 const char *turl =
GetTURL(filename);
168 while ((filemap = ((
TMap *) fileiter->
Next()))) {
182 filelist->
Add(filegroup);
212 while ((filemap = ((
TMap *) fileiter->
Next()))) {
221 && ((bname != prev_bname) && (dname == prev_dname)
231 filelist->
Add(filegroup);
236 filegroup =
new TMap();
246 filelist->
Add(filegroup);
300 Error(
"ParseXML",
"cannot find the <alien> tag in %s",
307 Error(
"ParseXML",
"cannot find the <collection> tag in %s",
312 if (xml.
GetAttr(xcollection,
"name")) {
320 Error(
"ParseXML",
"cannot find the <event> tag in %s",
371 if (oevlist && strlen(oevlist->GetName())) {
373 new TEntryList(oturl->GetName(), oguid->GetName());
374 TString stringevlist = oevlist->GetName();
375 TObjArray *evlist = stringevlist.Tokenize(
",");
389 attributes->
Add(
new TObjString(
"seStringlist"), oseStringlist);
391 if (osurl && strlen(osurl->GetName())) {
395 if (osselect && strlen(osselect->GetName())) {
399 if (osonline && strlen(osonline->GetName())) {
404 if (ossexporturl && strlen(ossexporturl->GetName())) {
419 }
while ((xfile = xml.
GetNext(xfile)));
424 if (xml.
GetAttr(xevent,
"comment")) {
432 if (xml.
GetAttr(xevent,
"url")) {
438 if (parsedentries >= maxentries)
440 }
while ((xevent = xml.
GetNext(xevent)));
474 onlinegroups = offlinegroups = onlinefiles = offlinefiles = totalfiles =
475 totalfilesize = onlinefilesize = offlinefilesize = 0;
476 while ((nextgroup = (
TMap *) statuslist->
Next())) {
486 while ((attributes = (
TMap *) nextfile->
Next())) {
516 Info(
"Status",
"=========================================");
517 Info(
"Status",
" Tot. Number of files: %u", totalfiles);
518 Info(
"Status",
" Tot. Size: %0.2f GB",
519 totalfilesize / 1024.0 / 1024.0 / 1024.0);
520 Info(
"Status",
" Number of file groups: %u", gc);
521 Info(
"Status",
"Number of files per group: %u", fc);
522 Info(
"Status",
"-----------------------------------------");
523 Info(
"Status",
"Online (staged [selected]):");
524 Info(
"Status",
" Number of file groups: %u", onlinegroups);
525 Info(
"Status",
" Number of files: %u", onlinefiles);
526 Info(
"Status",
" Size: %0.2f GB",
527 onlinefilesize / 1024.0 / 1024.0 / 1024.0);
528 Info(
"Status",
" Fraction avail: %0.2f %%",
529 100.0 * onlinefilesize / (onlinefilesize + offlinefilesize +
531 Info(
"Status",
"-----------------------------------------");
532 Info(
"Status",
"Offline (to be staged [selected]):");
533 Info(
"Status",
" Number of file groups: %u", offlinegroups);
534 Info(
"Status",
" Number of files: %u", offlinefiles);
535 Info(
"Status",
" Size: %0.2f GB",
536 offlinefilesize / 1024.0 / 1024.0 / 1024.0);
537 Info(
"Status",
" Fraction miss: %0.2f %%",
538 100.0 * offlinefilesize / (onlinefilesize + offlinefilesize +
540 Info(
"Status",
"=========================================\n");
551 if ((!tag) || (!value) || (!tagmap)) {
557 tagmap->
Remove(keyobject);;
573 while ((nextgroup = (
TMap *)
Next())) {
578 if ( ((nstart == -1 ) && (nstop == -1)) ||
579 ((nstart != -1 ) && (cnt >= nstart) && (nstop == -1)) ||
580 ((nstart != -1 ) && (cnt >= nstart) && (nstop != -1) && (cnt <= nstop)) ||
581 ((nstop != -1 ) && (cnt <= nstop) && (nstart == -1))) {
582 while ((attributes = (
TMap *) nextfile->
Next())) {
605 while ((nextgroup = (
TMap *)
Next())) {
610 if ( ((nstart == -1 ) && (nstop == -1)) ||
611 ((nstart != -1 ) && (cnt >= nstart) && (nstop == -1)) ||
612 ((nstart != -1 ) && (cnt >= nstart) && (nstop != -1) && (cnt <= nstop)) ||
613 ((nstop != -1 ) && (cnt <= nstop) && (nstart == -1))) {
614 while ((attributes = (
TMap *) nextfile->
Next())) {
638 while ((nextgroup = (
TMap *)
Next())) {
643 while ((attributes = (
TMap *) nextfile->
Next())) {
665 while ((nextgroup = (
TMap *)
Next())) {
671 while ((attributes = (
TMap *) nextfile->
Next())) {
708 Error(
"GetTURL",
"cannot get TURL of file %s", filename);
725 Error(
"GetSURL",
"cannot get SURL of file %s", filename);
764 if (selected ==
TString(
"1")) {
788 Error(
"GetEntryList",
"cannot get evelist of file %s", filename);
805 Error(
"GetLFN",
"cannot get LFN");
820 return ssize.
Atoll();
824 Error(
"GetSize",
"cannot get size of %s", filename);
837 while ((filemap = (
TMap *)
next())) {
839 Info(
"Print",
"printing element %d", count);
888 result->
Add(attributes);
911 while ((overlapmap = this->
Next())) {
915 while ((comparator->
Next())) {
936 if ((!addcollection)) {
940 addcollection->
Reset();
943 while ((addmap = addcollection->
Next())) {
952 "File group with lfn %s exists already in this collection - skipping",
970 if ((!addcollection)) {
973 addcollection->
Reset();
974 TMap *addmap, *clonemap;
975 while ((addmap = addcollection->
Next())) {
990 while ((filemap =
Next())) {
994 while ((attributes = (
TMap *) nextfile->
Next())) {
1001 Info(
"LookupSUrls",
"Lookup SURL for %s [%u/%u]",
1023 Info(
"LookupSUrls",
"SURL = %s", surl.
Data());
1044 "You have to execute LookupSUrls() before you can stage this collection");
1052 while ((filemap =
Next())) {
1056 while ((attributes = (
TMap *) nextfile->
Next())) {
1068 Info(
"Stage",
"[%05u/%05u] <Staged> : %s", fc,
1073 Error(
"Stage",
"[%05u/%05u] <Failed to stage> : %s",
1086 while ((filemap =
Next())) {
1089 while ((attributes = (
TMap *) nextfile->
Next())) {
1117 Error(
"CheckIfOnline",
1118 "You have to execute LookupSUrls() before you can prepare this collection");
1127 while ((filemap =
Next())) {
1131 while ((attributes = (
TMap *) nextfile->
Next())) {
1144 Info(
"CheckIfOnline",
"[%05u/%05u] <Online> : %s", fc,
1150 Info(
"CheckIfOnline",
"[%05u/%05u]<Offline> : %s", fc,
1184 while ((filemap =
Next())) {
1188 while ((attributes = (
TMap *) nextfile->
Next())) {
1208 while ((filemap =
Next())) {
1212 while ((attributes = (
TMap *) nextfile->
Next())) {
1220 Info(
"CheckIfOnline",
"[%05u/%05u] <Online> : %s", fc,
1226 Info(
"CheckIfOnline",
"[%05u/%05u]<Offline> : %s", fc,
1237 GetValue(attributes->
GetName()))->
1242 GetValue(attributes->
GetName()))->
1247 GetValue(attributes->
GetName()))->
1251 GetValue(attributes->
GetName()))->
1285 if ((exporturl == 0) || (
TString(exporturl) ==
"")) {
1288 "You used the option to store to the collection export url, but this is not defined!");
1292 TUrl expfn(exporturl);
1295 options +=
",filetype=raw";
1297 options =
"filetype=raw";
1302 Error(
"ExportXML",
"Cannot open export URL %s", expfn.
GetUrl());
1306 Bool_t expret =
ExportXML(exportfile, selected, online, name, comment);
1307 exportfile->
Close();
1321 snprintf(outline,4096,
1322 "<?xml version=\"1.0\"?>\n<alien>\n <collection name=\"%s\">\n",
1324 if ((exportfile->
WriteBuffer(outline, strlen(outline)))) {
1325 Error(
"ExportXML",
"Error writing XML to export file");
1326 exportfile->
Close();
1333 filegroups->
Reset();
1335 while ((nextgroup = (
TMap *) filegroups->
Next())) {
1342 while ((attributes = (
TMap *) nextfile->
Next())) {
1351 if ((!selected) || isselected) {
1356 snprintf(outline,4096,
" <event name=\"%d\">\n", groupcnt);
1357 if ((exportfile->
WriteBuffer(outline, strlen(outline)))) {
1358 Error(
"ExportXML",
"Error writing XML to export file");
1359 exportfile->
Close();
1362 while ((attributes = (
TMap *) nextfile->
Next())) {
1370 snprintf(outline,4096,
" <file ");
1372 WriteBuffer(outline, strlen(outline)))) {
1374 "Error writing XML to export file");
1375 exportfile->
Close();
1380 ((
TMap *) nextgroup->
1381 GetValue(attributes->
GetName()))->MakeIterator();
1402 GetValue(attributes->
1406 snprintf(outline,4096,
"%s=\"%s\" ",
1416 for (
Int_t i = 0; i < xmlentrylist->
GetN(); i++) {
1419 slist += xmlentrylist->
GetEntry(i);
1421 snprintf(outline,4096,
"%s=\"%s\" ",
1426 WriteBuffer(outline, strlen(outline)))) {
1428 "Error writing XML to export file");
1429 exportfile->
Close();
1436 snprintf(outline,4096,
"/>\n");
1438 WriteBuffer(outline, strlen(outline)))) {
1440 "Error writing XML to export file");
1441 exportfile->
Close();
1450 snprintf(outline,4096,
" </event>\n");
1451 if ((exportfile->
WriteBuffer(outline, strlen(outline)))) {
1452 Error(
"ExportXML",
"Error writing XML to export file");
1453 exportfile->
Close();
1463 snprintf(outline,4096,
" <export url=\"%s\">\n",
GetExportUrl());
1464 if ((exportfile->
WriteBuffer(outline, strlen(outline)))) {
1465 Error(
"ExportXML",
"Error writing XML to export file");
1466 exportfile->
Close();
1473 snprintf(outline,4096,
1474 " <info comment=\"%s\" />\n</collection>\n</alien>\n",
1476 if ((exportfile->
WriteBuffer(outline, strlen(outline)))) {
1477 Error(
"ExportXML",
"Error writing XML to export file");
1478 exportfile->
Close();
1497 "There is no remote url defined in this collection");
1518 Bool_t rename,
const char* suffix)
1549 char rootfile[4096];
1551 while ((item = fscanf(fp,
"%4095s", rootfile)) == 1) {
1555 rootbasenosuffix = rootbase(0, rootbase.First(
'.'));;
1562 newrootname += rootbasenosuffix;
1564 newrootname += firstrun;
1568 newrootname += lastrun;
1570 newrootname += lastevent;
1572 newrootname += nevents;
1574 newrootname += suffix;
1575 Info(
"GetOutputFilename",
"Renaming File %s to %s", rootfile,
1576 newrootname.
Data());
1600 while ((group = dynamic_cast<TMap*>(
next()))) {
1603 while ((key = dynamic_cast<TObjString*> (next2()))) {
1620 collection->
Add(fileInfo);
const char * GetName() const
Returns name of object.
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Long64_t GetSize(const char *name="")
Get a file's LFN. Returns 0 in case of error.
virtual Int_t GetEntries() const
TMap * fCurrent
event file list iterator
virtual void ParseXML(UInt_t maxentries)
Parse event file collection XML file.
void AddFast(TGridCollection *addcollection)
adds <addcollection> to this collection - NO check for identical elements
virtual const char * GetName() const
Return name of this collection.
const char * GetExportUrl()
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
Collectable string class.
This class represents a WWW compatible URL.
Bool_t IsOnline(const char *name="")
Get a file's online tag. Returns false if not online or CheckIfOnline was never executed, true if online.
const char * GetLFN(const char *name="")
Get a file's LFN. Returns 0 in case of error.
This class implements a data set to be used for PROOF processing.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Bool_t IsSelected(const char *name="")
Get a file's online tag. Returns false if not online or CheckIfOnline was never executed, true if online.
Bool_t InvertSelection()
Invert the selection.
UInt_t GetNofGroupfiles() const
virtual ~TAlienCollection()
Clean up event file collection.
static const char * filename()
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection)...
virtual TList * GetStaged(TCollection *pathlist)
Retrieves the staging (online) status for a list of path names.
XMLNodePointer_t GetNext(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
return next to xmlnode node if realnode==kTRUE, any special nodes in between will be skipped ...
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Bool_t DeselectFile(const char *name, Int_t=-1, Int_t=-1)
Deselects the file <filename> from the loaded collection All files can be deselected using "*" as <fi...
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
void SetTag(const char *tag, const char *value, TMap *tagmap)
Set's a key value pair in a tagmap. If it is existing, the existing tag is overwritten. If not, it is created.
virtual FILE * OpenPipe(const char *command, const char *mode)
Open a pipe.
TFileStager * fFileStager
const char * GetOptions() const
Bool_t CheckIfOnline(Bool_t bulk=kFALSE)
Run an online check if files are currently accessible (staged) or offline (to be staged).
Iterator abstract base class.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
virtual Bool_t Cp(const char *dst, Bool_t progressbar=kTRUE, UInt_t buffersize=1000000)
Allows to copy this file to the dst URL.
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
virtual int Rename(const char *from, const char *to)
Rename a file.
virtual TObject * Clone(const char *newname="") const
Make a clone of an collection using the Streamer facility.
const char * Data() const
Bool_t SetExportUrl(const char *exporturl=0)
Set the 'default' export URL for an XML collection. A collection can be restored to the export URL us...
void Print(Option_t *opt) const
Print event file collection.
TDSet * GetDataset(const char *type, const char *objname="*", const char *dir="/")
Return a TDSet from a collection.
static TAlienCollection * OpenAlienCollection(TGridResult *queryresult, Option_t *option="")
Static method used to create an Alien event collection, by creating collection from a TGridResult Get...
static struct mg_connection * fc(struct mg_context *ctx)
Int_t Update(Long64_t avgsize=-1)
Update accumulated information about the elements of the collection (e.g.
virtual int Unlink(const char *name)
Unlink, i.e. remove, a file.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
void Add(TGridCollection *addcollection)
adds <addcollection> to this collection - equal elements are skipped
static TGridCollection * Open(const char *collectionurl, UInt_t maxentries=1000000)
Static method used to create an Alien event collection, by reading an XML collection from the specifi...
Bool_t SelectFile(const char *name, Int_t=-1, Int_t=-1)
Selects all files with name <filename> in the collection All files can be selected using "*" as filen...
UInt_t fNofGroups
current event file map
UInt_t GetNofGroups() const
const char * GetOutputFileName(const char *infile, Bool_t rename=kTRUE, const char *suffix="root")
Adds to a file given by infile the collection identification , f.e.
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
Int_t Atoi() const
Return integer value of string.
Bool_t Stage(Bool_t bulk=kFALSE, Option_t *option="")
Execute the 'stage' method for all files in this collection (trigger staging).
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
const char * GetNodeName(XMLNodePointer_t xmlnode)
returns name of xmlnode
TIter * fFileGroupListIter
TObject * FindObject(const char *keyname) const
Check if a (key,value) pair exists with keyname as name of the key.
TEntryList * GetEntryList(const char *name)
Get a file's event list. Returns 0 in case of error.
R__EXTERN TSystem * gSystem
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
TObject * Remove(TObject *key)
Remove the (key,value) pair with key from the map.
Bool_t OverlapCollection(TGridCollection *comparator)
return kTRUE if comparator overlaps with this all objects in this collection, which are not defined i...
Int_t Add(TFileInfo *info)
Add TFileInfo to the collection.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
TIterator * MakeIterator(Bool_t dir=kIterForward) const
Create an iterator for TMap.
static TGridCollection * OpenQuery(TGridResult *queryresult, Bool_t nogrouping=kFALSE)
Static method used to create an Alien event collection, by creating collection from a TGridResult Que...
virtual Bool_t WriteBuffer(const char *buf, Int_t len)
Write a buffer to the file.
void Status()
Prints statistics, selection and status about the loaded collection.
char * Form(const char *fmt,...)
virtual Long64_t GetEntry(Int_t index)
Return the number of the entry #index of this TEntryList in the TTree or TChain See also Next()...
const char * AsString() const
Return UUID as string. Copy string immediately since it will be reused.
virtual int ClosePipe(FILE *pipe)
Close the pipe.
const char * GetSURL(const char *name="")
Get a file's storage URL (SURL). Returns 0 in case of error.
const char * GetTURL(const char *name="")
Get a file's transport URL (TURL). Returns 0 in case of error.
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
virtual void Print(Option_t *option="") const
Default print for collections, calls Print(option, 1).
XMLDocPointer_t ParseFile(const char *filename, Int_t maxbuf=100000)
Parses content of file and tries to produce xml structures.
Class used by TMap to store (key,value) pairs.
void SetTagFilterList(TList *filterlist)
virtual Int_t GetSize() const
Bool_t LookupSUrls(Bool_t verbose=kTRUE)
retrieves all the SURLS for the LFNS
virtual const char * GetName() const
Returns name of object.
const char * GetAttr(XMLNodePointer_t xmlnode, const char *name)
returns value of attribute for xmlnode
Long64_t Atoll() const
Return long long value of string.
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
static TFileStager * Open(const char *stager)
Open a stager, after having loaded the relevant plug-in.
Int_t GetEntries() const
Return the number of objects in array (i.e.
Bool_t DownscaleSelection(UInt_t scaler=2)
downscales the selection with scaler
virtual Long64_t GetN() const
Mother of all ROOT objects.
Bool_t ExportXML(TFile *file, Bool_t selected, Bool_t online, const char *name, const char *comment)
Internal Export function to write a collection as an XML file. See above.
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
virtual Bool_t Add(const char *file, const char *objname=0, const char *dir=0, Long64_t first=0, Long64_t num=-1, const char *msd=0)
Add file to list of files to be analyzed.
TMap * Next()
Return next event file map.
virtual void Add(TObject *obj)
XMLNodePointer_t GetChild(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
returns first child of xml node
Class that contains a list of TFileInfo's and accumulated meta data information about its entries...
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual TObject * Next()=0
XMLNodePointer_t DocGetRootElement(XMLDocPointer_t xmldoc)
returns root node of document
void Reset()
Reset file iterator.
void SetOptions(const char *opt)
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
TString fExportUrl
pointer to the file stager object
Bool_t Remove(TMap *map)
Return next event file map.
Class describing a generic file including meta information.
TObject * At(Int_t idx) const
TFileCollection * GetFileCollection(const char *name="", const char *title="") const
creates a TFileCollection objects and fills it with the information from this collection note that TF...
TFile * OpenFile(const char *filename)
Open the file specified by <filename> from the currently active file group in the collection via its ...
TGridResult * GetGridResult(const char *filename="", Bool_t onlyonline=kTRUE, Bool_t publicaccess=kFALSE)
Return a TGridResult.
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
A List of entry numbers in a TTree or TChain.
static TString SUrl(const char *lfn)
Get surl from lfn by asking AliEn catalog.
ClassImp(TAlienCollection) TAlienCollection
Create Alien event collection by reading collection from the specified XML file.
virtual const char * GetLFN(const char *="")
virtual void Close(Option_t *option="")
Close a file.