]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpSectorReader.cxx
Changed default values of cuts
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpSectorReader.cxx
index 4afaa36a8aa3babfbea696f589b9820822786a6e..6e721410c67d69f886533da44905425224e791c7 100755 (executable)
 // $Id$
 // $MpId: AliMpSectorReader.cxx,v 1.9 2006/05/24 13:58:46 ivana Exp $
 // Category: sector
-//
+
+//-----------------------------------------------------------------------------
 // Class AliMpSectorReader
 // -----------------------
 // Class that takes care of reading the sector data.
 // Included in AliRoot: 2003/05/02
 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+//-----------------------------------------------------------------------------
 
 #include "AliMpSectorReader.h"
 #include "AliMpSector.h"
 #include "AliMpFiles.h"
+#include "AliMpDataStreams.h"
 #include "AliMpZone.h"
 #include "AliMpSubZone.h"
 #include "AliMpRow.h"
@@ -40,7 +43,6 @@
 #include "AliMpMotifSpecial.h"
 #include "AliMpMotifType.h"
 #include "AliMpConnection.h"
-#include "AliMpIntPair.h"
 #include "AliMpDirection.h"
 #include "AliMpConstants.h"
 
@@ -71,35 +73,18 @@ const TString  AliMpSectorReader::fgkPadRowsKeyword        = "PAD_ROWS";
 const TString  AliMpSectorReader::fgkPadRowSegmentKeyword  = "PAD_ROW_SEGMENT";
 
 //_____________________________________________________________________________
-AliMpSectorReader::AliMpSectorReader(AliMpStationType station, 
-                                     AliMpPlaneType plane) 
+AliMpSectorReader::AliMpSectorReader(const AliMpDataStreams& dataStreams,
+                                     AliMq::Station12Type station, 
+                                     AliMp::PlaneType plane) 
   : TObject(),
+    fkDataStreams(dataStreams),
     fStationType(station),
     fPlaneType(plane),
     fSector(0),
-    fMotifReader(new AliMpMotifReader(station, plane))
-{
-// Standard constructor
-}
-
-//_____________________________________________________________________________
-AliMpSectorReader::AliMpSectorReader() 
-  : TObject(),
-    fStationType(kStation1),
-    fPlaneType(kBendingPlane),
-    fSector(0),
-    fMotifReader(0)
-{
-// Default constructor
-}
-
-//_____________________________________________________________________________
-AliMpSectorReader::AliMpSectorReader(const AliMpSectorReader& right) 
-  : TObject(right) 
+    fMotifReader(new AliMpMotifReader(dataStreams, AliMp::kStation12, station, plane))
 {
-/// Protected copy constructor (not provided) 
-
-  Fatal("AliMpSectorReader", "Copy constructor not provided.");
+/// Standard constructor
 }
 
 //_____________________________________________________________________________
@@ -110,29 +95,12 @@ AliMpSectorReader::~AliMpSectorReader()
   delete fMotifReader;
 }
 
-//
-// operators
-//
-
-//_____________________________________________________________________________
-AliMpSectorReader& AliMpSectorReader::operator=(const AliMpSectorReader& right)
-{
-/// Protected assignment operator (not provided) 
-
-  // check assignment to self
-  if (this == &right) return *this;
-
-  Fatal("operator =", "Assignment operator not provided.");
-    
-  return *this;  
-}    
-
 //
 // private methods
 //
 
 //_____________________________________________________________________________
-void  AliMpSectorReader::ReadSectorData(ifstream& in)
+void  AliMpSectorReader::ReadSectorData(istream& in)
 {
 /// Read sector input data;
 /// prepare zones and rows vectors to be filled in.
@@ -140,7 +108,7 @@ void  AliMpSectorReader::ReadSectorData(ifstream& in)
   TString keyword;
   in >> keyword;
   
-  AliDebugStream(1) << keyword << endl;
+  AliDebugStream(2) << keyword << endl;
 
   if (keyword != fgkSectorKeyword) {
      Fatal("ReadSectorData", "Wrong file format.");
@@ -156,13 +124,13 @@ void  AliMpSectorReader::ReadSectorData(ifstream& in)
   in >> offsetX;
   in >> offsetY;
   
-  AliMpDirection direction;
-  direction = (directionStr == "Y") ? kY  :  kX;
+  AliMp::Direction direction;
+  direction = (directionStr == "Y") ? AliMp::kY  :  AliMp::kX;
 
-  AliDebugStream(1) << nofZones << " " <<  nofRows << endl;
+  AliDebugStream(2) << nofZones << " " <<  nofRows << endl;
 
   fSector = new AliMpSector("Not defined", nofZones, nofRows,direction,
-                            TVector2(offsetX, offsetY));
+                            offsetX, offsetY);
   
   TString nextKeyword;
   in >> nextKeyword;
@@ -176,7 +144,7 @@ void  AliMpSectorReader::ReadSectorData(ifstream& in)
 }  
 
 //_____________________________________________________________________________
-void AliMpSectorReader::ReadZoneData(ifstream& in)
+void AliMpSectorReader::ReadZoneData(istream& in)
 {
 /// Read zone input data;
 /// create zone and adds it to zones vector.
@@ -186,12 +154,12 @@ void AliMpSectorReader::ReadZoneData(ifstream& in)
   in >> zoneID;    
   in >> sizex;
   in >> sizey;
-  AliDebugStream(1)
+  AliDebugStream(2)
      << fgkZoneKeyword << " " <<  zoneID << "  " 
      << sizex << " " << sizey << endl;
   
   AliMpZone* zone =  fSector->GetZone(zoneID);
-  zone->SetPadDimensions(TVector2(sizex/2.,sizey/2.)); 
+  zone->SetPadDimensions(sizex/2.,sizey/2.); 
       
   TString nextKeyword;
   in >> nextKeyword;
@@ -205,12 +173,12 @@ void AliMpSectorReader::ReadZoneData(ifstream& in)
 }
 
 //_____________________________________________________________________________
-void AliMpSectorReader::ReadSubZoneData(ifstream& in, AliMpZone* zone)
+void AliMpSectorReader::ReadSubZoneData(istream& in, AliMpZone* zone)
 {
 /// Read subzone input data;
 /// create subzone and its to the specified zone.
 
-  AliDebugStream(1) << fgkSubZoneKeyword << endl;
+  AliDebugStream(2) << fgkSubZoneKeyword << endl;
 
   AliMpVMotif* motif = ReadMotifData(in, zone);
   AliMpSubZone* subZone = new AliMpSubZone(motif); 
@@ -228,7 +196,7 @@ void AliMpSectorReader::ReadSubZoneData(ifstream& in, AliMpZone* zone)
 }   
 
 //_____________________________________________________________________________
-AliMpVMotif*  AliMpSectorReader::ReadMotifData(ifstream& in, AliMpZone* zone)
+AliMpVMotif*  AliMpSectorReader::ReadMotifData(istream& in, AliMpZone* zone)
 {
 /// Read the motif input data.
 
@@ -237,13 +205,14 @@ AliMpVMotif*  AliMpSectorReader::ReadMotifData(ifstream& in, AliMpZone* zone)
   in >> motifID;
   in >> motifTypeID;
 
-  AliDebugStream(1) << motifID << " " << motifTypeID << endl;
+  AliDebugStream(2) << motifID << " " << motifTypeID << endl;
   
   AliMpMotifMap* motifMap = fSector->GetMotifMap();
 
   AliMpMotifType* motifType = 0;
   AliMpVMotif* motif 
-    = motifMap->FindMotif(motifID, motifTypeID, zone->GetPadDimensions());
+    = motifMap->FindMotif(motifID, motifTypeID, 
+                          zone->GetPadDimensionX(), zone->GetPadDimensionY());
   if (!motif) {    
     motifType = motifMap->FindMotifType(motifTypeID);
     if (!motifType) {
@@ -251,8 +220,9 @@ AliMpVMotif*  AliMpSectorReader::ReadMotifData(ifstream& in, AliMpZone* zone)
       motifMap->AddMotifType(motifType);
     }
     
-    if (zone->GetPadDimensions().X() != 0. && zone->GetPadDimensions().Y() != 0.) 
-      motif = new AliMpMotif(motifID, motifType, zone->GetPadDimensions());
+    if (zone->GetPadDimensionX() != 0. && zone->GetPadDimensionY() != 0.) 
+      motif = new AliMpMotif(motifID, motifType, 
+                     zone->GetPadDimensionX(), zone->GetPadDimensionY());
     else 
       motif = fMotifReader->BuildMotifSpecial(motifID, motifType);
       
@@ -265,7 +235,7 @@ AliMpVMotif*  AliMpSectorReader::ReadMotifData(ifstream& in, AliMpZone* zone)
 }  
 
 //_____________________________________________________________________________
-void AliMpSectorReader::ReadRowSegmentsData(ifstream& in, 
+void AliMpSectorReader::ReadRowSegmentsData(istream& in, 
                                       AliMpZone* zone, AliMpSubZone* subZone)
 {
 /// Read row segments input data of a specified zone and subzone;
@@ -287,7 +257,7 @@ void AliMpSectorReader::ReadRowSegmentsData(ifstream& in,
     
     firstMotifPositionId |= AliMpConstants::ManuMask(fPlaneType);
     
-    AliDebugStream(1)
+    AliDebugStream(2)
       << fgkRowKeyword << " " 
       << offX << " " << offY << " " << inRow << " " << nofMotifs << " " 
       << firstMotifPositionId << " " << firstMotifPositionDId
@@ -303,7 +273,7 @@ void AliMpSectorReader::ReadRowSegmentsData(ifstream& in,
     
     // Create row segment and add it to its zone, row   
     AliMpVRowSegment* rowSegment
-      = new AliMpRowSegment(row, motif, AliMpIntPair(offX, offY), nofMotifs, 
+      = new AliMpRowSegment(row, motif, offX, offY, nofMotifs, 
                         firstMotifPositionId, firstMotifPositionDId);
                        
     subZone->AddRowSegment(rowSegment);
@@ -325,7 +295,7 @@ void AliMpSectorReader::ReadRowSegmentsData(ifstream& in,
 }   
 
 //_____________________________________________________________________________
-void AliMpSectorReader::ReadSectorSpecialData(ifstream& in, AliMpXDirection direction)
+void AliMpSectorReader::ReadSectorSpecialData(istream& in, AliMp::XDirection direction)
 {
 /// Read sector input data
 /// with a special (irregular) motifs.
@@ -333,7 +303,7 @@ void AliMpSectorReader::ReadSectorSpecialData(ifstream& in, AliMpXDirection dire
   TString keyword;
   in >> keyword;
 
-  AliDebugStream(1) << keyword << endl;
+  AliDebugStream(2) << keyword << endl;
 
   if (keyword != fgkSectorSpecialKeyword) {
      Fatal("ReadSectorSpecialData", "Wrong file format.");
@@ -343,7 +313,7 @@ void AliMpSectorReader::ReadSectorSpecialData(ifstream& in, AliMpXDirection dire
   TString nextKeyword;
   in >> nextKeyword;
 
-  AliDebugStream(1) << keyword << endl;
+  AliDebugStream(2) << keyword << endl;
     
   if (nextKeyword != fgkMotifKeyword) {
     Fatal("ReadSectorSpecialData", "Wrong file format.");
@@ -355,11 +325,11 @@ void AliMpSectorReader::ReadSectorSpecialData(ifstream& in, AliMpXDirection dire
 }  
 
 //_____________________________________________________________________________
-void AliMpSectorReader::ReadMotifsSpecialData(ifstream& in)
+void AliMpSectorReader::ReadMotifsSpecialData(istream& in)
 {
 /// Read the special (irregular) motifs input data.
 
-  AliDebugStream(1) << fgkMotifKeyword << endl;
+  AliDebugStream(2) << fgkMotifKeyword << endl;
 
   TString nextKeyword;
   do {
@@ -371,7 +341,7 @@ void AliMpSectorReader::ReadMotifsSpecialData(ifstream& in)
   
     in >> nextKeyword;
 
-    AliDebugStream(1) << nextKeyword << endl;      
+    AliDebugStream(2) << nextKeyword << endl;      
   }
   while (nextKeyword == fgkMotifKeyword);
     
@@ -382,7 +352,7 @@ void AliMpSectorReader::ReadMotifsSpecialData(ifstream& in)
 }  
 
 //_____________________________________________________________________________
-void AliMpSectorReader::ReadRowSpecialData(ifstream& in, AliMpXDirection direction)
+void AliMpSectorReader::ReadRowSpecialData(istream& in, AliMp::XDirection direction)
 {
 /// Read row input data
 /// with a special (irregular) motifs.
@@ -390,13 +360,13 @@ void AliMpSectorReader::ReadRowSpecialData(ifstream& in, AliMpXDirection directi
   Int_t id;
   in >> id;
 
-  AliDebugStream(1) << id << endl;      
+  AliDebugStream(2) << id << endl;      
   
   // Get the row and its border
   AliMpRow* row = fSector->GetRow(id);
 
   AliMpVRowSegmentSpecial* segment = 0;
-  if (direction == kLeft) {
+  if (direction == AliMp::kLeft) {
     AliMpVRowSegment* firstNormalSeg = row->GetRowSegment(0);
     Double_t offsetX = firstNormalSeg->LeftBorderX();
   
@@ -417,7 +387,7 @@ void AliMpSectorReader::ReadRowSpecialData(ifstream& in, AliMpXDirection directi
   TString nextKeyword;
   in >> nextKeyword;
   
-  AliDebugStream(1) << nextKeyword << endl;
+  AliDebugStream(2) << nextKeyword << endl;
     
   if (nextKeyword != fgkPadRowsKeyword) {
      Fatal("ReadRowSpecialData", "Wrong file format.");
@@ -443,9 +413,9 @@ void AliMpSectorReader::ReadRowSpecialData(ifstream& in, AliMpXDirection directi
 }  
 
 //_____________________________________________________________________________
-void AliMpSectorReader::ReadRowSegmentSpecialData(ifstream& in, 
+void AliMpSectorReader::ReadRowSegmentSpecialData(istream& in, 
                                             AliMpVRowSegmentSpecial* segment,
-                                           AliMpXDirection direction)
+                                           AliMp::XDirection direction)
 {
 /// Read row segment input data
 /// with a special (irregular) motifs.
@@ -453,12 +423,12 @@ void AliMpSectorReader::ReadRowSegmentSpecialData(ifstream& in,
   Int_t nofPadRows;
   in >> nofPadRows;
   
-  AliDebugStream(1) << nofPadRows << endl;
+  AliDebugStream(2) << nofPadRows << endl;
   
   TString keyword;
   in >> keyword;
 
-  AliDebugStream(1) << keyword << endl;
+  AliDebugStream(2) << keyword << endl;
     
   if (keyword != fgkPadRowSegmentKeyword) {
      Fatal("ReadRowSegmentSpecialData", "Wrong file format.");
@@ -469,7 +439,7 @@ void AliMpSectorReader::ReadRowSegmentSpecialData(ifstream& in,
   // Process data
   //
     
-  AliMpVRowSegmentSpecial::PadRowVector  newPadRows;
+  TObjArray newPadRows;
   for (Int_t i=0; i<nofPadRows; i++) {
     
      // Create pad row
@@ -477,12 +447,7 @@ void AliMpSectorReader::ReadRowSegmentSpecialData(ifstream& in,
      segment->AddPadRow(padRow);
      
      // Keep the new rows in a temporary vector
-#ifdef WITH_STL
-     newPadRows.push_back(padRow);
-#endif
-#ifdef WITH_ROOT
      newPadRows.Add(padRow);
-#endif
   }   
       
   TString nextKeyword;
@@ -498,12 +463,12 @@ void AliMpSectorReader::ReadRowSegmentSpecialData(ifstream& in,
   
     motifPositionId |= AliMpConstants::ManuMask(fPlaneType);
 
-    AliDebugStream(1)
+    AliDebugStream(2)
       << nofPadsInRow << " " << motifId << " " << motifPositionId << endl;
 
     in >> nextKeyword;
 
-    AliDebugStream(1) << nextKeyword << endl;
+    AliDebugStream(2) << nextKeyword << endl;
 
     //
     // Process data
@@ -512,12 +477,7 @@ void AliMpSectorReader::ReadRowSegmentSpecialData(ifstream& in,
     for (Int_t i=0; i<nofPadRows; i++) {
     
       // Get pad row from the temporary vector
-#ifdef WITH_STL
-      AliMpPadRow* padRow = newPadRows[i];
-#endif
-#ifdef WITH_ROOT
       AliMpPadRow* padRow = (AliMpPadRow*)newPadRows[i];
-#endif
       
       // Find motif
       AliMpVMotif* motif = fSector->GetMotifMap()->FindMotif(motifId);
@@ -554,50 +514,47 @@ void AliMpSectorReader::ReadRowSegmentSpecialData(ifstream& in,
 //_____________________________________________________________________________
 AliMpSector* AliMpSectorReader::BuildSector()
 {
-/// Read the mapping data from ascii data file
-/// and create the basic objects:                                            \n
+/// Read the mapping data from stream and create the basic objects:         \n
 /// zones, subzones, rows, row segments, motifs.
 
-  // Open input file
-  ifstream in(AliMpFiles::SectorFilePath(fStationType, fPlaneType).Data(), ios::in);
-  if (!in) {
-     AliErrorStream()
-       << "File " << AliMpFiles::SectorFilePath(fStationType, fPlaneType) 
-       << " not found." << endl;
-     return 0;
-  }
-  
+  // Open input stream
+  //
+  istream& in 
+    = fkDataStreams.
+        CreateDataStream(AliMpFiles::SectorFilePath(fStationType,fPlaneType));
+
   ReadSectorData(in);
+  delete &in;
+  
   fSector->SetRowSegmentOffsets();
 
-  // Open input file for special inner zone
+  // Open input stream for special inner zone
+  
+  // add is data function
+  
   TString sectorSpecialFileName 
     = AliMpFiles::SectorSpecialFilePath(fStationType, fPlaneType);
-  if (!gSystem->AccessPathName(sectorSpecialFileName.Data())) {
-    ifstream in2(sectorSpecialFileName.Data(), ios::in);
-    if (!in2) {        
-       AliErrorStream()
-         << "File " << AliMpFiles::SectorSpecialFilePath(fStationType, fPlaneType) 
-        << " not found." << endl;
-       return 0;
-    }
+  if ( fkDataStreams.IsDataStream(sectorSpecialFileName) ) {
+    istream& in2 
+      = fkDataStreams.
+          CreateDataStream(sectorSpecialFileName);
+  
+    ReadSectorSpecialData(in2, AliMp::kLeft);
     
-    ReadSectorSpecialData(in2, kLeft);
-  }   
+    delete &in2;
+  }  
 
   // Open input file for special outer zone
   TString sectorSpecialFileName2 
     = AliMpFiles::SectorSpecialFilePath2(fStationType, fPlaneType);
-  if (!gSystem->AccessPathName(sectorSpecialFileName2.Data())) {
-    ifstream in3(sectorSpecialFileName2.Data(), ios::in);
-    if (!in3) {        
-       AliErrorStream()
-         << "File " << AliMpFiles::SectorSpecialFilePath2(fStationType, fPlaneType) 
-        << " not found."<< endl;       
-       return 0;
-    }
+  if ( fkDataStreams.IsDataStream(sectorSpecialFileName2) ) {
+    istream& in3
+      = fkDataStreams.
+          CreateDataStream(sectorSpecialFileName2);
+    
+    ReadSectorSpecialData(in3, AliMp::kRight);
     
-    ReadSectorSpecialData(in3, kRight);
+    delete &in3;
   }   
 
   fSector->Initialize();