]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpMotifReader.cxx
commented logging message
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpMotifReader.cxx
index 5f063fe31715da04722a499fa551ecded721a637..5c895f57af4629ba0b1e92e045e9fa757f8805d7 100644 (file)
@@ -14,7 +14,7 @@
  **************************************************************************/
 
 // $Id$
-// $MpId: AliMpMotifReader.cxx,v 1.4 2005/08/26 15:43:36 ivana Exp $
+// $MpId: AliMpMotifReader.cxx,v 1.10 2006/05/24 13:58:41 ivana Exp $
 // Category: sector
 //
 // Class AliMpMotifReader
 // Included in AliRoot: 2003/05/02
 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
 
-#if !defined(__HP_aCC) && !defined(__alpha)
-  #include <sstream>
-#endif
-
-#include <Riostream.h>
-#include <Rstrstream.h>
-#include <TSystem.h>
-#include <TError.h>
-#include <TMath.h>
-
-#include "AliLog.h"
 #include "AliMpFiles.h"
 #include "AliMpMotifReader.h"
 #include "AliMpMotifMap.h"
 #include "AliMpMotifType.h"
 #include "AliMpConnection.h"
 #include "AliMpIntPair.h"
-#include "AliMpDirection.h"
 
-ClassImp(AliMpMotifReader)
+#include "AliLog.h"
 
-#ifdef WITH_ROOT
-const Int_t    AliMpMotifReader::fgkSeparator = 100;
+#include <TSystem.h>
+#include <TMath.h>
+#include <Riostream.h>
+#include <Rstrstream.h>
+
+#if !defined(__HP_aCC) && !defined(__alpha)
+  #include <sstream>
 #endif
 
+/// \cond CLASSIMP
+ClassImp(AliMpMotifReader)
+/// \endcond
+
 //_____________________________________________________________________________
-AliMpMotifReader::AliMpMotifReader(AliMpStationType station, 
-                                   AliMpPlaneType plane) 
+AliMpMotifReader::AliMpMotifReader(AliMp::StationType station, 
+                                   AliMp::PlaneType plane) 
   : TObject(),
     fStationType(station),
-    fPlaneType(plane),
-    fVerboseLevel(0)
+    fPlaneType(plane)
 {
 /// Standard constructor
 }
@@ -64,102 +60,18 @@ AliMpMotifReader::AliMpMotifReader(AliMpStationType station,
 //_____________________________________________________________________________
 AliMpMotifReader::AliMpMotifReader() 
   : TObject(),
-    fStationType(kStation1),
-    fPlaneType(kBendingPlane),
-    fVerboseLevel(0)
+    fStationType(AliMp::kStation1),
+    fPlaneType(AliMp::kBendingPlane)
 {
 /// Default constructor
 }
 
-//_____________________________________________________________________________
-AliMpMotifReader::AliMpMotifReader(const AliMpMotifReader& right) 
-  : TObject(right) 
-{
-/// Protected copy constructor (not provided)
-
-  Fatal("AliMpMotifReader", "Copy constructor not provided.");
-}
-
 //_____________________________________________________________________________
 AliMpMotifReader::~AliMpMotifReader() 
 {
 /// Destructor  
 }
 
-//
-// operators
-//
-
-//_____________________________________________________________________________
-AliMpMotifReader& AliMpMotifReader::operator=(const AliMpMotifReader& 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
-//
-
-#ifdef WITH_ROOT
-//_____________________________________________________________________________
-Int_t  AliMpMotifReader::GetIndex(const string& s) const 
-{
-/// Converts the TString to integer.
-
-  if (s.length() > 5) {
-    Fatal("GetIndex", "String too long.");
-    return 0;
-  }  
-
-  Int_t index = 0;
-  for (Int_t i=s.length(); i>=0; --i)  index = index*100 + int(s[i]);
-  
-  return index;
-}
-
-//______________________________________________________________________________
-Int_t  AliMpMotifReader::GetIndex(const AliMpIntPair& pair) const
-{
-/// Convert the pair of integers to integer.
-
-  if (pair.GetFirst() >= fgkSeparator || pair.GetSecond() >= fgkSeparator)
-    Fatal("GetIndex", "Index out of limit.");
-      
-  return pair.GetFirst()*fgkSeparator + pair.GetSecond() + 1;
-}  
-
-//_____________________________________________________________________________
-string  AliMpMotifReader::GetString(Int_t index) const
-{
-/// Convert the integer index to the string.
-
-  string s;
-  while (index >0) {
-    Char_t c = index%100;
-    s += c;
-    index = index/100;
-  }
-  
-  return s;
-  
-}
-
-//______________________________________________________________________________
-AliMpIntPair  AliMpMotifReader::GetPair(Int_t index) const
-{
-/// Convert the integer index to the pair of integers.
-
-  return AliMpIntPair((index-1)/fgkSeparator, (index-1)%fgkSeparator);
-}  
-#endif
-
 //
 // public methods
 //
@@ -174,11 +86,10 @@ AliMpMotifType* AliMpMotifReader::BuildMotifType(const TString& motifTypeId)
 
   AliMpMotifType*  motifType = new AliMpMotifType(motifTypeId);        
 
-  TString padPosFileName 
-    = AliMpFiles::Instance()
-      ->PadPosFilePath(fStationType, fPlaneType, motifTypeId);
+  TString padPosFileName(AliMpFiles::PadPosFilePath(fStationType, 
+                                                    fPlaneType, motifTypeId));
   ifstream padPos(padPosFileName);
-  if (fVerboseLevel>0) cout<<"Opening file "<<padPosFileName<<endl;
+  AliDebugStream(2) << "Opening file " << padPosFileName << endl;
 
   PadMapType positions;
 
@@ -205,20 +116,20 @@ AliMpMotifType* AliMpMotifReader::BuildMotifType(const TString& motifTypeId)
     positions[key].second=j;
 #endif
 #ifdef WITH_ROOT
-    positions.Add(GetIndex(key), GetIndex(AliMpIntPair(i,j))); 
+    positions.Add( AliMpExMap::GetIndex(key), 
+                   AliMpExMap::GetIndex(AliMpIntPair(i,j)) ); 
 #endif
   } while (!padPos.eof());
 
   padPos.close();
 
   TString bergToGCFileName
-    = AliMpFiles::Instance()->BergToGCFilePath(fStationType);
-  if (fVerboseLevel>0) 
-    cout << "Opening file " << bergToGCFileName << endl;
+    = AliMpFiles::BergToGCFilePath(fStationType);
+  AliDebugStream(2) << "Opening file " << bergToGCFileName << endl;
 
   ifstream bergToGCFile(bergToGCFileName);
   const Int_t knbergpins = 
-    (fStationType == kStation1 || fStationType == kStation2 ) ? 80 : 100;
+    (fStationType == AliMp::kStation1 || fStationType == AliMp::kStation2 ) ? 80 : 100;
   // Station1 & 2 Bergstak connectors have 80 pins, while for stations
   // 3, 4 and 5 they have 100 pins.
   Int_t gassiChannel[100];
@@ -236,11 +147,10 @@ AliMpMotifType* AliMpMotifReader::BuildMotifType(const TString& motifTypeId)
   }
   bergToGCFile.close();
   
-  TString motifTypeFileName 
-    = AliMpFiles::Instance()
-      ->MotifFilePath(fStationType, fPlaneType, motifTypeId);
+  TString motifTypeFileName(AliMpFiles::MotifFilePath(fStationType, 
+                                                      fPlaneType, motifTypeId));
   ifstream motif(motifTypeFileName);
-  if (fVerboseLevel>0) cout<<"Opening file "<<motifTypeFileName<<endl;
+  AliDebugStream(2) << "Opening file " << motifTypeFileName << endl;
 
   Int_t nofPadsX=0;
   Int_t nofPadsY=0;
@@ -299,8 +209,10 @@ AliMpMotifType* AliMpMotifReader::BuildMotifType(const TString& motifTypeId)
 #ifdef WITH_STL
     PadMapTypeIterator iter = positions.find(padName);
     if (iter==positions.end()) {
-      cerr<<"Problem: Pad number "<<padNum<<" found in the file "<<motifTypeFileName
-         <<" but not in the file"<<padPosFileName<<endl;
+      AliWarningStream()
+        << "Problem: Pad number " << padNum
+       << " found in the file " << motifTypeFileName
+       << " but not in the file " << padPosFileName << endl;
       continue;
     }
 
@@ -309,15 +221,17 @@ AliMpMotifType* AliMpMotifReader::BuildMotifType(const TString& motifTypeId)
 #endif
 
 #ifdef WITH_ROOT
-    Long_t value = positions.GetValue(GetIndex(padName));
+    Long_t value = positions.GetValue(AliMpExMap::GetIndex(padName));
     if (!value) {
-      cerr<<"Problem: Pad number "<<padNum<<" found in the file "<<motifTypeFileName
-         <<" but not in the file"<<padPosFileName<<endl;
+      AliWarningStream()
+        << "Problem: Pad number " << padNum
+       << " found in the file " << motifTypeFileName
+       << " but not in the file " << padPosFileName << endl;
       continue;
     }
 
-    ix = GetPair(value).GetFirst();
-    iy = GetPair(value).GetSecond();
+    ix = AliMpExMap::GetPair(value).GetFirst();
+    iy = AliMpExMap::GetPair(value).GetSecond();
 #endif
 
     motifType->AddConnection(AliMpIntPair(ix,iy),
@@ -336,46 +250,57 @@ AliMpMotifType* AliMpMotifReader::BuildMotifType(const TString& motifTypeId)
   return motifType;
 }
 
+//_____________________________________________________________________________
+TString 
+AliMpMotifReader::MotifSpecialName(const TString& motifID, Double_t scale)
+{
+  /// Build the name taking into the scale, if not 1.0
+  TString id;
+  
+  if ( scale != 1.0 )
+  {
+    id = Form("%s-%e",motifID.Data(),scale);
+  }
+  else
+  {
+    id = motifID;
+  }
+  return id;
+}
 
 //_____________________________________________________________________________
 AliMpMotifSpecial*  
 AliMpMotifReader::BuildMotifSpecial(const TString& motifID,
-                                    AliMpMotifType* motifType)
+                                    AliMpMotifType* motifType,
+                                    Double_t scale)
 {
 /// Build a special motif by reading the file motifSpecial<motifId>.dat
 /// in the data directory
 
   // Open the input file
-  TString motifSpecialFileName
-    = AliMpFiles::Instance()
-      ->MotifSpecialFilePath(fStationType, fPlaneType, motifID);
+  TString motifSpecialFileName(AliMpFiles::MotifSpecialFilePath(fStationType, 
+                                                                fPlaneType, motifID));
   ifstream in(motifSpecialFileName);
   if (!in) {   
-     Error("BuildMotifSpecial", "File not found.");
+     AliErrorStream() 
+       << "File " << motifSpecialFileName.Data() << " not found." << endl;
      return 0;
   }
 
-  AliMpMotifSpecial* res = new AliMpMotifSpecial(motifID,motifType);
+  TString id = MotifSpecialName(motifID,scale);
+  
+  AliMpMotifSpecial* res = new AliMpMotifSpecial(id,motifType);
   Int_t i,j;
   Double_t x,y;
   in >> i;
   while (!in.eof()){
     in >>j >>x >> y;
-    res->SetPadDimensions(AliMpIntPair(i,j),TVector2(x/2.,y/2.));
+    res->SetPadDimensions(AliMpIntPair(i,j),TVector2(x*scale/2.,y*scale/2.));
     in >> i;
   }
+  res->CalculateDimensions();
   
   in.close();
   return res;
 }
 
-
-//_____________________________________________________________________________
-void AliMpMotifReader::SetVerboseLevel(Int_t verboseLevel)
-{
-// Sets verbose level.
-// ---
-
-  fVerboseLevel = verboseLevel;
-}
-