]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpSt345Reader.cxx
In mapping:
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpSt345Reader.cxx
index 189dcef723dd2217123937826ab16590e04e80c1..3b97d45e2413e5c2f48f46cb8457af57e9f6bbbd 100644 (file)
@@ -22,6 +22,7 @@
 #include "AliMpSlatMotifMap.h"
 #include "AliMpMotifReader.h"
 #include "AliMpFiles.h"
+#include "AliMpDataStreams.h"
 #include "AliMpMotifType.h"
 #include "AliMpPCB.h"
 #include "AliMpSlat.h"
@@ -37,7 +38,8 @@
 
 #include <sstream>
 
-/// 
+//-----------------------------------------------------------------------------
 /// \class AliMpSt345Reader
 //
 /// Read slat and pcb ASCII files.
 /// - AliMpPCB ReadPCB()
 ///
 /// \author Laurent Aphecetche
+//-----------------------------------------------------------------------------
 
 /// \cond CLASSIMP
 ClassImp(AliMpSt345Reader)
 /// \endcond
 
 //_____________________________________________________________________________
-AliMpSt345Reader::AliMpSt345Reader(AliMpSlatMotifMap& motifMap
+AliMpSt345Reader::AliMpSt345Reader() 
 : 
 TObject(),
-fMotifMap(motifMap)
+fMotifMap(AliMpSlatMotifMap::Instance())
 {
   ///
   /// Default ctor.
@@ -79,12 +82,10 @@ AliMpSt345Reader::ReadPCB(const char* pcbType)
   /// Create a new AliMpPCB object, by reading it from file.
   /// The returned object must be deleted by the client
   
-  std::ifstream in(AliMpFiles::SlatPCBFilePath(AliMp::kStation345,pcbType).Data());
-  if (!in.good()) 
-  {
-    AliErrorClass(Form("Cannot open file for PCB %s",pcbType));
-    return 0;
-  }
+  istream& in 
+    = AliMpDataStreams::Instance()
+       ->CreateDataStream(AliMpFiles::SlatPCBFilePath(
+                             AliMp::kStation345, pcbType));
  
   AliMpMotifReader reader(AliMp::kStation345,AliMp::kNonBendingPlane); 
   // note that the nonbending
@@ -118,7 +119,7 @@ AliMpSt345Reader::ReadPCB(const char* pcbType)
       {
         AliError("pcb not null as expected");
       }
-      pcb = new AliMpPCB(&fMotifMap,pcbType,padSizeX,padSizeY,pcbSizeX,pcbSizeY);
+      pcb = new AliMpPCB(fMotifMap,pcbType,padSizeX,padSizeY,pcbSizeX,pcbSizeY);
     }
     
     if ( sline(0,kMotifKeyword.Length()) == kMotifKeyword )
@@ -130,12 +131,12 @@ AliMpSt345Reader::ReadPCB(const char* pcbType)
       int iy;
       sin >> sMotifType >> ix >> iy;
       
-      AliMpMotifType* motifType = fMotifMap.FindMotifType(sMotifType);
+      AliMpMotifType* motifType = fMotifMap->FindMotifType(sMotifType);
       if (!motifType)
       {
         AliDebug(1,Form("Reading motifType %s from file",sMotifType.Data()));
         motifType = reader.BuildMotifType(sMotifType.Data());
-        fMotifMap.AddMotifType(motifType);
+        fMotifMap->AddMotifType(motifType);
       }
       else
       {
@@ -146,7 +147,7 @@ AliMpSt345Reader::ReadPCB(const char* pcbType)
     }
   }
   
-  in.close();
+  delete &in;
   
   return pcb;
 }
@@ -159,15 +160,11 @@ AliMpSt345Reader::ReadSlat(const char* slatType, AliMp::PlaneType planeType)
   /// Create a new AliMpSlat object, by reading it from file.
   /// The returned object must be deleted by the client.
   
-  std::ifstream in(AliMpFiles::SlatFilePath(AliMp::kStation345,slatType,
-                                            planeType).Data());
-  if (!in.good()) 
-  {
-    AliErrorClass(Form("Cannot read slat from %s",
-                       AliMpFiles::SlatFilePath(AliMp::kStation345,slatType,planeType).Data()));
-    return 0;
-  }
-  
+  istream& in 
+    = AliMpDataStreams::Instance()
+       ->CreateDataStream(AliMpFiles::SlatFilePath(
+                             AliMp::kStation345, slatType, planeType));
+
   char line[80];
   
   const TString kpcbKeyword("PCB");
@@ -224,8 +221,9 @@ AliMpSt345Reader::ReadSlat(const char* slatType, AliMp::PlaneType planeType)
     }
   }
   
-  in.close();
+  delete &in;
   
   return slat;
-}
+}  
+