]>
Commit | Line | Data |
---|---|---|
c1b83ab9 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | /* $Id$ */ | |
17 | ||
18 | //----------------------------------------------------------------- | |
19 | // Implementation of the AliXMLCollection class | |
20 | // This is the class that creates XML collections after querying the tags | |
21 | // Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch | |
22 | //----------------------------------------------------------------- | |
23 | ||
24 | //ROOT | |
25 | #include <Riostream.h> | |
26 | #include <TString.h> | |
27 | #include <TEventList.h> | |
28 | ||
29 | #include "AliXMLCollection.h" | |
30 | ||
31 | ClassImp(AliXMLCollection) | |
32 | ||
33 | //___________________________________________________________________________ | |
34 | AliXMLCollection::AliXMLCollection() : | |
35 | TObject(), | |
fe12e09c | 36 | fCollectionName(), |
37 | fout() | |
c1b83ab9 | 38 | { |
39 | //Default constructor | |
40 | } | |
41 | ||
42 | //___________________________________________________________________________ | |
43 | AliXMLCollection::~AliXMLCollection() { | |
44 | //Destructor | |
45 | } | |
46 | ||
47 | //___________________________________________________________________________ | |
48 | Bool_t AliXMLCollection::WriteHeader() { | |
49 | //Creates the xml output file | |
50 | ||
51 | TString xmlName = fCollectionName; | |
52 | xmlName += ".xml"; | |
53 | ||
54 | TString collectionHeader = "<collection name="; | |
55 | collectionHeader += "\""; | |
56 | collectionHeader += fCollectionName; | |
57 | collectionHeader += "\""; | |
58 | collectionHeader += ">"; | |
59 | ||
60 | // Open the output stream | |
61 | fout.open(xmlName); | |
62 | fout<<"<?xml version=\"1.0\"?>\n"; | |
eb771b73 | 63 | fout<<"<alien>\n"; |
c1b83ab9 | 64 | fout<<" "<<collectionHeader<<"\n"; |
65 | ||
66 | return kTRUE; | |
67 | } | |
68 | ||
69 | //___________________________________________________________________________ | |
eb771b73 | 70 | Bool_t AliXMLCollection::WriteBody(Int_t counter, const char* guid, const char* lfn, const char* turl, TEventList *list) { |
c1b83ab9 | 71 | //Writes the body of the xml collection |
72 | TString listline; | |
73 | for(Int_t i = 0; i < list->GetN(); i++) { | |
74 | listline += list->GetEntry(i); | |
75 | listline += ","; | |
76 | } | |
77 | listline = listline(0,listline.Length()-1); | |
78 | ||
79 | TString line0 = "<event name=\""; | |
80 | line0 += counter; | |
81 | line0 += "\">"; | |
82 | ||
83 | TString line1 = "<file name=\"AliESDs.root\" "; | |
84 | line1 += "guid=\""; | |
85 | line1 += guid; | |
86 | line1 += "\" "; | |
eb771b73 | 87 | line1 += "lfn=\""; |
88 | line1 += lfn; | |
89 | line1 += "\" "; | |
ab02b208 | 90 | line1 += "turl=\""; |
91 | line1 += turl; | |
92 | line1 += "\" "; | |
93 | line1 += "evlist=\""; | |
c1b83ab9 | 94 | line1 += listline; |
95 | line1 += "\""; | |
96 | line1 += " />"; | |
97 | ||
98 | fout<<" "<<line0<<"\n"; | |
99 | fout<<" "<<line1<<"\n"; | |
100 | fout<<" </event>\n"; | |
101 | ||
102 | return kTRUE; | |
103 | } | |
104 | ||
105 | //___________________________________________________________________________ | |
106 | Bool_t AliXMLCollection::Export() { | |
107 | //Closes the stream | |
108 | fout<<" "<<"</collection>\n"; | |
eb771b73 | 109 | fout<<"</alien>\n"; |
c1b83ab9 | 110 | |
111 | fout.close(); | |
112 | ||
113 | return kTRUE; | |
114 | } |