]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpManuStore.cxx
Replacement of AliMpIntPair object with algoritmic
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpManuStore.cxx
index 2e72e59796def2687b51f1e9a0471c58fa1411c6..8fb5777490b474abbd60c738d8f84f327dd6987d 100644 (file)
@@ -33,8 +33,8 @@
 #include "AliMpDataStreams.h"
 #include "AliMpFiles.h"
 #include "AliMpHelper.h"
-#include "AliMpIntPair.h"
 #include "AliMpConstants.h"
+#include "AliMpEncodePair.h"
 
 #include "AliLog.h"
 
@@ -100,7 +100,7 @@ AliMpManuStore* AliMpManuStore::ReadData(const AliMpDataStreams& dataStreams,
 //______________________________________________________________________________
 AliMpManuStore::AliMpManuStore(const AliMpDataStreams& dataStreams)
 : TObject(),
-  fDataStreams(dataStreams),
+  fkDataStreams(dataStreams),
   fManuToSerialNbs(),
   fSerialNbToManus(),
   fNofManusInDE(),
@@ -124,7 +124,7 @@ AliMpManuStore::AliMpManuStore(const AliMpDataStreams& dataStreams)
 //______________________________________________________________________________
 AliMpManuStore::AliMpManuStore(TRootIOCtor* ioCtor)
 : TObject(),
-  fDataStreams(ioCtor),
+  fkDataStreams(ioCtor),
   fManuToSerialNbs(),
   fSerialNbToManus(),
   fNofManusInDE(),
@@ -157,6 +157,8 @@ Bool_t AliMpManuStore::ReadData(const AliMpDetElement* de, Int_t& nofManus)
   TString deName = de->GetDEName();
   AliMp::StationType stationType 
     =  AliMpDEManager::GetStationType(de->GetId());
+  AliMq::Station12Type station12Type 
+    =  AliMpDEManager::GetStation12Type(de->GetId());
 
   // Nothing to be done for trigger
   if ( stationType == AliMp::kStationTrigger ) {
@@ -167,8 +169,9 @@ Bool_t AliMpManuStore::ReadData(const AliMpDetElement* de, Int_t& nofManus)
   static Int_t manuMask = AliMpConstants::ManuMask(AliMp::kNonBendingPlane);
 
   istream& in 
-    = fDataStreams.
-        CreateDataStream(AliMpFiles::ManuToSerialPath(deName, stationType));
+    = fkDataStreams.
+        CreateDataStream(
+          AliMpFiles::ManuToSerialPath(deName, stationType, station12Type));
 
   char line[80];
 
@@ -236,7 +239,7 @@ void  AliMpManuStore::ReplaceManu(Int_t detElemId, Int_t manuId, Int_t serialNb)
 /// As TExMap has no replcae function, we have to rebuild map once again.
 /// Not yet in use, declared private.
 
-  Long_t index = AliMpExMap::GetIndex(AliMpIntPair(detElemId, manuId));
+  Long_t index = AliMp::Pair(detElemId, manuId);
 
   TExMap newManuToSerialNbs;
   // Loop over map
@@ -298,12 +301,14 @@ Bool_t  AliMpManuStore::WriteData(const TString& outDir)
     TString deName = detElement->GetDEName();
     AliMp::StationType stationType 
       =  AliMpDEManager::GetStationType(detElemId);
+    AliMq::Station12Type station12Type 
+      =  AliMpDEManager::GetStation12Type(detElemId);
       
     if ( stationType == AliMp::kStationTrigger ) continue;  
 
     // Create directory if it does not yet exist
     //
-    TString dirPath = outDir + AliMpFiles::StationDataDir(stationType);
+    TString dirPath = outDir + AliMpFiles::StationDataDir(stationType, station12Type);
     if ( ! gSystem->OpenDirectory(dirPath.Data()) ) {
       AliDebugStream(2) << "Making directory " <<  dirPath.Data() << endl;
       gSystem->mkdir(dirPath.Data());
@@ -311,7 +316,7 @@ Bool_t  AliMpManuStore::WriteData(const TString& outDir)
 
     // Compose output file path 
     //
-    string dataPath = AliMpFiles::ManuToSerialPath(deName, stationType).Data();
+    string dataPath = AliMpFiles::ManuToSerialPath(deName, stationType, station12Type).Data();
     string top = AliMpFiles::GetTop().Data();
     if ( dataPath.find(top) != string::npos ) dataPath.erase(0, top.size()+1);
     dataPath.erase(0,dataPath.find('/')+1);
@@ -332,18 +337,20 @@ Bool_t  AliMpManuStore::WriteData(const TString& outDir)
     Long_t key;
     Long_t value;
     while ( ( it2.Next(key, value) ) ) {
-      AliMpIntPair pair = AliMpExMap::GetPair(key);
+      Int_t pairFirst = AliMp::PairFirst(key);
       
-      if ( pair.GetFirst() != detElemId ) continue;
+      if ( pairFirst != detElemId ) continue;
       
+      Int_t manuId = AliMp::PairSecond(key);
+
       AliDebugStream(3) 
-        << "Go to write " << key << " " << pair << " " << value << endl;
+        << "Go to write " << key << " " 
+        << pairFirst << " " << manuId << " " << value << endl;
 
-      Int_t manuId = pair.GetSecond();
       static Int_t manuMask = AliMpConstants::ManuMask(AliMp::kNonBendingPlane);
 
       TString planeName = PlaneTypeName(AliMp::kBendingPlane);
-      if ( pair.GetSecond()> manuMask ) {
+      if ( manuId> manuMask ) {
         planeName = PlaneTypeName(AliMp::kNonBendingPlane);
         manuId -= manuMask;
       } 
@@ -387,7 +394,7 @@ Bool_t  AliMpManuStore::AddManu(Int_t detElemId, Int_t manuId, Int_t serialNb)
 {
 /// Add manu to the map
 
-  Long_t index = AliMpExMap::GetIndex(AliMpIntPair(detElemId, manuId));
+  Long_t index = AliMp::Pair(detElemId, manuId);
   
   AliDebugStream(2)
     << "Adding (" << detElemId << "," <<  manuId 
@@ -400,9 +407,8 @@ Bool_t  AliMpManuStore::AddManu(Int_t detElemId, Int_t manuId, Int_t serialNb)
     if ( fgWarnIfDoublon ) {
       AliWarningStream() 
         << "Serial number " << serialNb 
-        << " already present for (detElemId, manuId) = " << AliMpExMap::GetPair(value)
-        << ", it will nod be added for (" 
-        << detElemId << "," << manuId << ")" << endl;
+        << " already present for (detElemId, manuId) = " ;
+        AliMp::PairPut(AliWarningStream(), (MpPair_t) value) << endl;
      }
      return kFALSE;    
   }
@@ -418,20 +424,18 @@ Int_t AliMpManuStore::GetManuSerial(Int_t detElemId, Int_t manuId) const
 {
 /// Return manu serial number for given detElemId and manuId
 
-  Long_t index = AliMpExMap::GetIndex(AliMpIntPair(detElemId, manuId));
+  Long_t index = AliMp::Pair(detElemId, manuId);
   // cout << index << " " << fManuToSerialNbs.GetValue(index) << endl;
   
   return fManuToSerialNbs.GetValue(index);
 }  
 
 //______________________________________________________________________________
-AliMpIntPair  AliMpManuStore::GetDetElemIdManu(Int_t manuSerial) const
+MpPair_t  AliMpManuStore::GetDetElemIdManu(Int_t manuSerial) const
 {
 /// Return detElemId and manuId for given manu serial number 
+/// as encoded pair
 
-  Long_t value = fSerialNbToManus.GetValue(Long_t(manuSerial));
-  // cout << manuSerial << " " << value << endl;
-  
-  return AliMpExMap::GetPair(value);
+  return fSerialNbToManus.GetValue(Long_t(manuSerial));
 }