]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpDDLStore.cxx
Fixing a backward compatibility issue
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpDDLStore.cxx
index 9775e2677fff79a02bb0f3a2c4e30262254519b2..f92e69829645dacba661018051e5db68f288c266 100644 (file)
@@ -38,6 +38,7 @@
 #include "AliMpDataStreams.h"
 #include "AliMpHelper.h"
 #include "AliMpDEManager.h"
+#include "AliMpManuStore.h"
 #include "AliMpDetElement.h"
 #include "AliMpBusPatch.h"
 #include "AliMpTriggerCrate.h"
@@ -45,6 +46,8 @@
 #include "AliMpSegmentation.h"
 #include "AliMpVSegmentation.h"
 #include "AliMpStringObjMap.h"
+#include "AliMpEncodePair.h"
+#include "AliMpIntPair.h"
 
 #include "AliLog.h"
 
@@ -83,7 +86,8 @@ AliMpDDLStore* AliMpDDLStore::Instance(Bool_t warn)
 }
 
 //______________________________________________________________________________
-AliMpDDLStore* AliMpDDLStore::ReadData(Bool_t warn) 
+AliMpDDLStore* AliMpDDLStore::ReadData(const AliMpDataStreams& dataStreams,
+                                       Bool_t warn) 
 {
     /// Load the DDL store from ASCII data files
     /// and return its instance
@@ -94,10 +98,10 @@ AliMpDDLStore* AliMpDDLStore::ReadData(Bool_t warn)
         return fgInstance;
     }
 
-    if ( AliMpDataStreams::Instance()->GetReadFromFiles() )
-      AliInfoClass("Reading DDL Store from ASCII files.");
+    if ( dataStreams.GetReadFromFiles() )
+      AliInfoClass("Reading Manu Store from ASCII files.");
 
-    fgInstance = new AliMpDDLStore();
+    fgInstance = new AliMpDDLStore(dataStreams);
     return fgInstance;
 }
 
@@ -106,38 +110,40 @@ AliMpDDLStore* AliMpDDLStore::ReadData(Bool_t warn)
 //
 
 //______________________________________________________________________________
-AliMpDDLStore::AliMpDDLStore()
+AliMpDDLStore::AliMpDDLStore(const AliMpDataStreams& dataStreams)
         : TObject(),
+        fkDataStreams(dataStreams),
         fDDLs(fgkNofDDLs+fgkNofTriggerDDLs), // FIXEME
         fBusPatches(),
         fManuList12(),
         fManuBridge2(),
         fRegionalTrigger()
 {
-    /// Standard constructor
-
-    AliDebug(1,"");
-    fDDLs.SetOwner(true);
-    fBusPatches.SetOwner(true);
-    fBusPatches.SetSize(900);
+  /// Standard constructor
+  
+  AliDebug(1,"");
+  fDDLs.SetOwner(true);
+  fBusPatches.SetOwner(true);
+  fBusPatches.SetSize(900);
+
+  // Load segmentation & DE store data
+  if ( ! AliMpSegmentation::Instance(false) )
+    AliMpSegmentation::ReadData(dataStreams, true);
     
-    // Load segmentation & DE store data
-    if ( ! AliMpSegmentation::Instance(false) )
-        AliMpSegmentation::ReadData(true);
-
-    // Create all detection elements
-    ReadDDLs();
-    ReadTrigger();
-    SetTriggerDDLs();
-    SetManus();
-    ReadBusPatchSpecial();
-    SetPatchModules();
-    ReadBusPatchInfo();
+  // Create all detection elements
+  ReadDDLs();
+  ReadTrigger();
+  SetTriggerDDLs();
+  SetManus();
+  ReadBusPatchSpecial();
+  SetPatchModules();
+  ReadBusPatchInfo();
 }
 
 //______________________________________________________________________________
 AliMpDDLStore::AliMpDDLStore(TRootIOCtor* ioCtor)
         : TObject(),
+        fkDataStreams(ioCtor),
         fDDLs(),
         fBusPatches(ioCtor),
         fRegionalTrigger(ioCtor)
@@ -205,8 +211,8 @@ Bool_t AliMpDDLStore::ReadDDLs()
     /// Read ddl <-> bus patch file
 
     istream& in 
-      = AliMpDataStreams::Instance()
-        ->CreateDataStream(AliMpFiles::BusPatchFilePath());
+      = fkDataStreams.
+          CreateDataStream(AliMpFiles::BusPatchFilePath());
 
     char line[255];
 
@@ -248,7 +254,7 @@ Bool_t AliMpDDLStore::ReadDDLs()
             TString sManu = ((TObjString*)stringList->At(3))->GetString();
             AliMpHelper::DecodeName(sManu,',',fManuList12[GetManuListIndex(idDE)]);
 
-            if(AliMpDEManager::GetStationType(idDE) == AliMp::kStation2) {
+            if(AliMpDEManager::GetStation12Type(idDE) == AliMq::kStation2) {
                 TString sManuBridge = ((TObjString*)stringList->At(4))->GetString();
                 AliMpHelper::DecodeName(sManuBridge,',',fManuBridge2[GetManuListIndex(idDE)]);
             }
@@ -294,7 +300,7 @@ Bool_t  AliMpDDLStore::ReadTrigger()
 {
     /// create trigger DDL object and Global crate object
   
-  if ( ! fRegionalTrigger.ReadData() ) return false;
+  if ( ! fRegionalTrigger.ReadData(fkDataStreams) ) return false;
 
   return true;
 }
@@ -473,8 +479,8 @@ Bool_t AliMpDDLStore::ReadBusPatchSpecial()
 /// and reset the manus arrays filled via SetManu function
 
   istream& in 
-    = AliMpDataStreams::Instance()
-       ->CreateDataStream(AliMpFiles::BusPatchSpecialFilePath());
+    = fkDataStreams.
+        CreateDataStream(AliMpFiles::BusPatchSpecialFilePath());
 
   char line[255];
 
@@ -564,7 +570,7 @@ Bool_t AliMpDDLStore::SetPatchModules()
             Bool_t newResult = false;
             Int_t idDE = busPatch->GetDEId();
 
-            if (AliMpDEManager::GetStationType(idDE) == AliMp::kStation2 )
+            if (AliMpDEManager::GetStation12Type(idDE) == AliMq::kStation2 )
                 newResult = busPatch->SetNofManusPerModule(fManuBridge2[GetManuListIndex(idDE)].At(i));
             else
                 newResult = busPatch->SetNofManusPerModule();
@@ -580,8 +586,8 @@ Bool_t AliMpDDLStore::ReadBusPatchInfo()
     /// read the buspatch info file and set buspatch info
 
     istream& in 
-      = AliMpDataStreams::Instance()
-        ->CreateDataStream(AliMpFiles::BusPatchInfoFilePath());
+      = fkDataStreams.
+          CreateDataStream(AliMpFiles::BusPatchInfoFilePath());
 
     char line[255];
 
@@ -816,9 +822,11 @@ Int_t AliMpDDLStore::GetBusPatchId(Int_t detElemId, Int_t manuId) const {
 
 
 //______________________________________________________________________________
-AliMpIntPair  AliMpDDLStore::GetLinkPortId(Int_t busPatchId) const {
+Long_t AliMpDDLStore::GetLinkPortId(Int_t busPatchId) const {
 
-  /// Return link port for a given frtId and global busPatchId
+    /// Get link port and DSP from busPatch id.
+    /// Return -1 if the value is not valid 
+    /// (the validity has to be tested in the client code)
 
     AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
     Int_t ddlId = busPatch->GetDdlId();
@@ -831,18 +839,6 @@ AliMpIntPair  AliMpDDLStore::GetLinkPortId(Int_t busPatchId) const {
 
 }
 
-//______________________________________________________________________________
-AliMpIntPair  AliMpDDLStore::GetDetElemIdManu(Int_t manuSerial) const {
-    /// Return the detElemId and manuId for given serial manu number
-
-    if ( ! AliMpDEStore::Instance() ) {
-        AliFatal("DE Store has not been loaded.");
-        return AliMpIntPair::Invalid();
-    }
-
-    return AliMpDEStore::Instance()->GetDetElemIdManu(manuSerial);
-}
-
 //______________________________________________________________________________
 void AliMpDDLStore::PrintAllManu() const {
     /// Print all manu Ids and their serial numbers sorted by detection element
@@ -868,11 +864,15 @@ void AliMpDDLStore::PrintAllManu() const {
             }
             cout << endl;
 
-            cout << "    Manu serial: ";
-            for ( Int_t k=0; k<busPatch->GetNofManus(); ++k ) {
-                cout << std::setw(6) << de->GetManuSerialFromId(busPatch->GetManuId(k)) << " ";
-            }
-            cout << endl;
+            if ( AliMpManuStore::Instance(kFALSE) ) {
+              cout << "    Manu serial: ";
+              for ( Int_t k=0; k<busPatch->GetNofManus(); ++k ) {
+                cout << std::setw(6) 
+                     << AliMpManuStore::Instance()
+                        ->GetManuSerial(de->GetId(), busPatch->GetManuId(k)) << " ";
+              }
+              cout << endl;
+            }  
         }
     }
 }
@@ -885,7 +885,7 @@ Int_t  AliMpDDLStore::GetNextDEfromLocalBoard(Int_t localBoardId, Int_t chamberI
 
     TString name(localBoard->GetName());
 
-    Int_t line = localBoard->GetPosition().GetFirst();
+    Int_t line = AliMp::PairFirst(localBoard->GetPosition());
     ++line;
 
     name.Replace(4,1,Form("%d", line));
@@ -907,7 +907,7 @@ Int_t  AliMpDDLStore::GetPreviousDEfromLocalBoard(Int_t localBoardId, Int_t cham
 
     TString name(localBoard->GetName());
 
-    Int_t line = localBoard->GetPosition().GetFirst();
+    Int_t line = AliMp::PairFirst(localBoard->GetPosition());
     --line;
 
     name.Replace(4,1,Form("%d", line));