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())) {
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())) {
1210 while ((filemap =
Next())) {
1214 while ((attributes = (
TMap *) nextfile->
Next())) {
1222 Info(
"CheckIfOnline",
"[%05u/%05u] <Online> : %s",
fc,
1228 Info(
"CheckIfOnline",
"[%05u/%05u]<Offline> : %s",
fc,
1239 GetValue(attributes->
GetName()))->
1244 GetValue(attributes->
GetName()))->
1249 GetValue(attributes->
GetName()))->
1253 GetValue(attributes->
GetName()))->
1287 if ((exporturl == 0) || (
TString(exporturl) ==
"")) {
1290 "You used the option to store to the collection export url, but this is not defined!");
1294 TUrl expfn(exporturl);
1297 options +=
",filetype=raw";
1299 options =
"filetype=raw";
1304 Error(
"ExportXML",
"Cannot open export URL %s", expfn.
GetUrl());
1309 exportfile->
Close();
1324 "<?xml version=\"1.0\"?>\n<alien>\n <collection name=\"%s\">\n",
1326 if ((exportfile->
WriteBuffer(outline, strlen(outline)))) {
1327 Error(
"ExportXML",
"Error writing XML to export file");
1328 exportfile->
Close();
1335 filegroups->
Reset();
1337 while ((nextgroup = (
TMap *) filegroups->
Next())) {
1344 while ((attributes = (
TMap *) nextfile->
Next())) {
1353 if ((!selected) || isselected) {
1358 snprintf(outline,4096,
" <event name=\"%d\">\n", groupcnt);
1359 if ((exportfile->
WriteBuffer(outline, strlen(outline)))) {
1360 Error(
"ExportXML",
"Error writing XML to export file");
1361 exportfile->
Close();
1364 while ((attributes = (
TMap *) nextfile->
Next())) {
1374 WriteBuffer(outline, strlen(outline)))) {
1376 "Error writing XML to export file");
1377 exportfile->
Close();
1382 ((
TMap *) nextgroup->
1383 GetValue(attributes->
GetName()))->MakeIterator();
1393 while ((filtertag = (
TObjString *) next())) {
1404 GetValue(attributes->
1408 snprintf(outline,4096,
"%s=\"%s\" ",
1418 for (
Int_t i = 0; i < xmlentrylist->
GetN(); i++) {
1421 slist += xmlentrylist->
GetEntry(i);
1423 snprintf(outline,4096,
"%s=\"%s\" ",
1428 WriteBuffer(outline, strlen(outline)))) {
1430 "Error writing XML to export file");
1431 exportfile->
Close();
1440 WriteBuffer(outline, strlen(outline)))) {
1442 "Error writing XML to export file");
1443 exportfile->
Close();
1452 snprintf(outline,4096,
" </event>\n");
1453 if ((exportfile->
WriteBuffer(outline, strlen(outline)))) {
1454 Error(
"ExportXML",
"Error writing XML to export file");
1455 exportfile->
Close();
1466 if ((exportfile->
WriteBuffer(outline, strlen(outline)))) {
1467 Error(
"ExportXML",
"Error writing XML to export file");
1468 exportfile->
Close();
1476 " <info comment=\"%s\" />\n</collection>\n</alien>\n",
1478 if ((exportfile->
WriteBuffer(outline, strlen(outline)))) {
1479 Error(
"ExportXML",
"Error writing XML to export file");
1480 exportfile->
Close();
1499 "There is no remote url defined in this collection");
1520 Bool_t rename,
const char* suffix)
1551 char rootfile[4096];
1553 while ((item = fscanf(fp,
"%4095s", rootfile)) == 1) {
1557 rootbasenosuffix = rootbase(0, rootbase.
First(
'.'));;
1564 newrootname += rootbasenosuffix;
1566 newrootname += firstrun;
1568 newrootname += firstevent;
1570 newrootname += lastrun;
1572 newrootname += lastevent;
1574 newrootname += nevents;
1576 newrootname += suffix;
1577 Info(
"GetOutputFilename",
"Renaming File %s to %s", rootfile,
1578 newrootname.
Data());
1602 while ((
group =
dynamic_cast<TMap*
>(next()))) {
1605 while ((key =
dynamic_cast<TObjString*
> (next2()))) {
1622 collection->
Add(fileInfo);
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
static struct mg_connection * fc(struct mg_context *ctx)
void Print(Option_t *opt) const
Print event file collection.
const char * GetExportUrl()
Bool_t IsSelected(const char *name="")
Get a file's online tag. Returns false if not online or CheckIfOnline was never executed,...
const char * GetLFN(const char *name="")
Get a file's LFN. Returns 0 in case of error.
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.
void Reset()
Reset file iterator.
Bool_t Remove(TMap *map)
Return next event file map.
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.
TMap * Next()
Return next event file map.
void Add(TGridCollection *addcollection)
adds <addcollection> to this collection - equal elements are skipped
Bool_t InvertSelection()
Invert the selection.
UInt_t GetNofGroupfiles() const
static TAlienCollection * OpenAlienCollection(TGridResult *queryresult, Option_t *option="")
Static method used to create an Alien event collection, by creating collection from a TGridResult Get...
void Status()
Prints statistics, selection and status about the loaded collection.
Bool_t LookupSUrls(Bool_t verbose=kTRUE)
retrieves all the SURLS for the LFNS
TDSet * GetDataset(const char *type, const char *objname="*", const char *dir="/")
Return a TDSet from a collection.
TString fExportUrl
pointer to the file stager object
Bool_t OverlapCollection(TGridCollection *comparator)
return kTRUE if comparator overlaps with this all objects in this collection, which are not defined i...
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...
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...
TFileStager * fFileStager
virtual void ParseXML(UInt_t maxentries)
Parse event file collection XML file.
TMap * fCurrent
event file list iterator
TEntryList * GetEntryList(const char *name)
Get a file's event list. Returns 0 in case of error.
void SetTagFilterList(TList *filterlist)
Bool_t DownscaleSelection(UInt_t scaler=2)
downscales the selection with scaler
TFile * OpenFile(const char *filename)
Open the file specified by <filename> from the currently active file group in the collection via its ...
Long64_t GetSize(const char *name="")
Get a file's LFN. Returns 0 in case of error.
TGridResult * GetGridResult(const char *filename="", Bool_t onlyonline=kTRUE, Bool_t publicaccess=kFALSE)
Return a TGridResult.
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 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...
UInt_t GetNofGroups() const
UInt_t fNofGroups
current event file map
Bool_t IsOnline(const char *name="")
Get a file's online tag. Returns false if not online or CheckIfOnline was never executed,...
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 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....
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.
Bool_t CheckIfOnline(Bool_t bulk=kFALSE)
Run an online check if files are currently accessible (staged) or offline (to be staged).
virtual ~TAlienCollection()
Clean up event file collection.
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...
TIter * fFileGroupListIter
void AddFast(TGridCollection *addcollection)
adds <addcollection> to this collection - NO check for identical elements
Bool_t Stage(Bool_t bulk=kFALSE, Option_t *option="")
Execute the 'stage' method for all files in this collection (trigger staging).
static TString SUrl(const char *lfn)
Get surl from lfn by asking AliEn catalog.
virtual const char * GetName() const
Return name of this collection.
virtual void Print(Option_t *option="") const
Default print for collections, calls Print(option, 1).
virtual Int_t GetEntries() const
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual TObject * Clone(const char *newname="") const
Make a clone of an collection using the Streamer facility.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
This class implements a data set to be used for PROOF processing.
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.
A List of entry numbers in a TTree or TChain.
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().
virtual Long64_t GetN() const
Class that contains a list of TFileInfo's and accumulated meta data information about its entries.
Int_t Update(Long64_t avgsize=-1)
Update accumulated information about the elements of the collection (e.g.
Int_t Add(TFileInfo *info)
Add TFileInfo to the collection.
Class describing a generic file including meta information.
static TFileStager * Open(const char *stager)
Open a stager, after having loaded the relevant plug-in.
virtual TList * GetStaged(TCollection *pathlist)
Retrieves the staging (online) status for a list of path names.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
virtual Bool_t WriteBuffer(const char *buf, Int_t len)
Write a buffer to the 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.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
void Close(Option_t *option="") override
Close a file.
virtual const char * GetLFN(const char *="")
Iterator abstract base class.
virtual TObject * Next()=0
virtual void Add(TObject *obj)
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
TIterator * MakeIterator(Bool_t dir=kIterForward) const
Create an iterator for TMap.
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection).
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
TObject * FindObject(const char *keyname) const
Check if a (key,value) pair exists with keyname as name of the key.
TObject * Remove(TObject *key)
Remove the (key,value) pair with key from the map.
Int_t GetEntries() const
Return the number of objects in array (i.e.
TObject * At(Int_t idx) const
Collectable string class.
const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Class used by TMap to store (key,value) pairs.
Int_t Atoi() const
Return integer value of string.
Ssiz_t First(char c) const
Find first occurrence of a character c.
const char * Data() const
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Long64_t Atoll() const
Return long long value of string.
virtual FILE * OpenPipe(const char *command, const char *mode)
Open a pipe.
virtual int Rename(const char *from, const char *to)
Rename a file.
virtual int ClosePipe(FILE *pipe)
Close the pipe.
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
virtual TString GetDirName(const char *pathname)
Return the directory name in pathname.
virtual int Unlink(const char *name)
Unlink, i.e.
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
const char * AsString() const
Return UUID as string. Copy string immediately since it will be reused.
This class represents a WWW compatible URL.
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
void SetOptions(const char *opt)
const char * GetOptions() const
XMLNodePointer_t GetChild(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
returns first child of xmlnode
XMLNodePointer_t DocGetRootElement(XMLDocPointer_t xmldoc)
returns root node of document
const char * GetNodeName(XMLNodePointer_t xmlnode)
returns name of xmlnode
const char * GetAttr(XMLNodePointer_t xmlnode, const char *name)
returns value of attribute for xmlnode
XMLDocPointer_t ParseFile(const char *filename, Int_t maxbuf=100000)
Parses content of file and tries to produce xml structures.
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