]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Adding the AliXMLCollection class to the repository. It will be used to create xml...
authorpanos <panos@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 17 Aug 2006 11:43:44 +0000 (11:43 +0000)
committerpanos <panos@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 17 Aug 2006 11:43:44 +0000 (11:43 +0000)
STEER/AliXMLCollection.cxx [new file with mode: 0644]
STEER/AliXMLCollection.h [new file with mode: 0644]

diff --git a/STEER/AliXMLCollection.cxx b/STEER/AliXMLCollection.cxx
new file mode 100644 (file)
index 0000000..61e6c76
--- /dev/null
@@ -0,0 +1,107 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
+//-----------------------------------------------------------------
+//           Implementation of the AliXMLCollection class
+//   This is the class that creates XML collections after querying the tags
+//   Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
+//-----------------------------------------------------------------
+
+//ROOT
+#include <Riostream.h>
+#include <TString.h>
+#include <TEventList.h>
+
+#include "AliXMLCollection.h"
+
+ClassImp(AliXMLCollection)
+
+//___________________________________________________________________________
+  AliXMLCollection::AliXMLCollection() :
+    TObject(),
+    fCollectionName(0)
+{
+  //Default constructor
+}
+
+//___________________________________________________________________________
+AliXMLCollection::~AliXMLCollection() {
+  //Destructor
+}
+
+//___________________________________________________________________________
+Bool_t AliXMLCollection::WriteHeader() {
+  //Creates the xml output file
+
+  TString xmlName = fCollectionName;
+  xmlName += ".xml";
+
+  TString collectionHeader = "<collection name=";
+  collectionHeader += "\"";
+  collectionHeader += fCollectionName;
+  collectionHeader += "\"";
+  collectionHeader += ">";
+  
+  // Open the output stream
+  fout.open(xmlName);
+  fout<<"<?xml version=\"1.0\"?>\n";
+  fout<<"<tags>\n";
+  fout<<"  "<<collectionHeader<<"\n";  
+
+  return kTRUE;
+}
+
+//___________________________________________________________________________
+Bool_t AliXMLCollection::WriteBody(Int_t counter, const char* guid, TEventList *list) {
+  //Writes the body of the xml collection
+  TString listline;
+  for(Int_t i = 0; i < list->GetN(); i++) {
+    listline += list->GetEntry(i);
+    listline += ",";
+  }  
+  listline = listline(0,listline.Length()-1);
+
+  TString line0 = "<event name=\"";
+  line0 += counter;
+  line0 += "\">";
+  
+  TString line1 = "<file name=\"AliESDs.root\" ";
+  line1 += "guid=\"";
+  line1 += guid;
+  line1 += "\" ";
+  line1 += "eventlist=\"";
+  line1 += listline;
+  line1 += "\"";
+  line1 += " />";
+  
+  fout<<"    "<<line0<<"\n";
+  fout<<"      "<<line1<<"\n";
+  fout<<"    </event>\n";
+  
+  return kTRUE;
+}
+
+//___________________________________________________________________________
+Bool_t AliXMLCollection::Export() {
+  //Closes the stream
+  fout<<"  "<<"</collection>\n";
+  fout<<"</tags>\n";
+
+  fout.close();
+
+  return kTRUE;
+}
diff --git a/STEER/AliXMLCollection.h b/STEER/AliXMLCollection.h
new file mode 100644 (file)
index 0000000..e96b762
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef ALIXMLCOLLECTION_H
+#define ALIXMLCOLLECTION_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+
+/* $Id$ */
+
+//-------------------------------------------------------------------------
+//                          Class AliXMLCollection
+//   This is the class that creates XML collections after querying the tags
+//
+//    Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
+//-------------------------------------------------------------------------
+
+#include <TObject.h>
+#include <Riostream.h>
+#include <TString.h>
+
+class TEventList;
+
+//___________________________________________________________________________
+class AliXMLCollection : public TObject {
+ public:
+  AliXMLCollection();
+  ~AliXMLCollection();
+  
+  //____________________________________________________//
+  Bool_t WriteHeader();
+  Bool_t WriteBody(Int_t counter, const char* guid, TEventList *fEventList);
+  Bool_t Export();
+
+  void SetCollectionName(const char* name) {fCollectionName = name;}
+  
+  //____________________________________________________//
+  const char* GetCollectionName() {return fCollectionName.Data();}
+
+  //____________________________________________________//
+ protected:
+  TString fCollectionName;   //the name of the xml file
+  ofstream fout; // The output stream
+  
+  ClassDef(AliXMLCollection,0)  //(ClassName, ClassVersion)
+};
+//___________________________________________________________________________
+
+#endif