]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTriggerIO.cxx
Adding GetGeometryFromOCDB method
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerIO.cxx
index ab85f16e00e17ee21b3b6320ced1d1144f7a6292..df9a8e5d4ce6f18e51f2e9e1beb4d91d62c1605d 100644 (file)
@@ -384,15 +384,15 @@ AliMUONTriggerIO::ReadLUT(const char* lutFileToRead, AliMUONTriggerLut& lut)
 //_____________________________________________________________________________
 Bool_t 
 AliMUONTriggerIO::ReadConfig(const char* localFile,
-                            const char* regionalFile,
-                            const char* globalFile,
-                            AliMUONVStore* localMasks,
-                            AliMUONRegionalTriggerConfig* regionalConfig,
-                            AliMUONGlobalCrateConfig* globalConfig)
+                             const char* regionalFile,
+                             const char* globalFile,
+                             AliMUONVStore* localMasks,
+                             AliMUONRegionalTriggerConfig* regionalConfig,
+                             AliMUONGlobalCrateConfig* globalConfig)
 {
   /// Fill the various masks store from files
   
-  if ( !regionalFile ) 
+  if ( !regionalFile || strlen(regionalFile)==0 
   {
     AliError("Must have a regional file name to proceeed");
     return kFALSE;
@@ -408,7 +408,7 @@ AliMUONTriggerIO::ReadConfig(const char* localFile,
     return kFALSE;
   }
   
-  if (localMasks && localFile)
+  if (localMasks && localFile && strlen(localFile) > 0 )
   {
     Int_t nLocal = ReadLocalMasks(localFile,*localMasks);
     AliDebug(1,Form("Read masks for %d local boards",nLocal));
@@ -426,7 +426,7 @@ AliMUONTriggerIO::ReadConfig(const char* localFile,
 
 //_____________________________________________________________________________
  Int_t 
- AliMUONTriggerIO::ReadGlobalConfig(const char* globalFile, AliMUONGlobalCrateConfig* globalConfig)
+ AliMUONTriggerIO::ReadGlobalConfig(const char* globalFile, AliMUONGlobalCrateConfig* globalConfig) const
 {
   /// read the global crate file
   /// the masks are disable bit for each crate, 8 per darc board
@@ -492,14 +492,14 @@ Bool_t
 AliMUONTriggerIO::WriteConfig(const char* localFile,
                             const char* regionalFile,
                             const char* globalFile,
-                            AliMUONVStore* localMasks,
+                            const AliMUONVStore* localMasks,
                     AliMUONRegionalTriggerConfig* regionalConfig,
                     AliMUONGlobalCrateConfig* globalConfig) const
 {
 /// write config files
 
     Bool_t ok;
-    ok  = WriteLocalMasks(localFile, *localMasks, regionalConfig);
+    ok  = WriteLocalMasks(localFile, *localMasks);
     ok &= WriteRegionalConfig(regionalFile, regionalConfig);
     ok &= WriteGlobalConfig(globalFile, globalConfig);
     
@@ -526,7 +526,7 @@ AliMUONTriggerIO::WriteGlobalConfig(const char* globalFile, AliMUONGlobalCrateCo
   }
    
   out << globalConfig->GetName() << endl;
-  out << globalConfig->GetGlobalCrateEnable() << endl;
+  out << Form("0x%x",globalConfig->GetGlobalCrateEnable()) << endl;
   
   // Jtag
   out << globalConfig->GetJtagName() << endl;
@@ -606,47 +606,63 @@ AliMUONTriggerIO::WriteRegionalConfig(const char* regionalFile, AliMUONRegionalT
       AliError("Could not write regional no configuration in memory");
       return kFALSE;
     }
-    
-    TIter next(fRegionalTrigger.CreateCrateIterator());
+
+    Int_t nofDDLs = 0;
+    TString name;
     AliMpTriggerCrate* crate;
-    while ( ( crate = static_cast<AliMpTriggerCrate*>(next()) ) )
-    {
-      AliMUONTriggerCrateConfig* crateConfig = regionalConfig->FindTriggerCrate(crate->GetName());
-      if (!crateConfig) 
+    for (Int_t ddlId = 0; ddlId < 2; ddlId++) // right & left side            
       {
-        AliError(Form("Cannot find crate %s in CDB", crate->GetName()));
-        return kFALSE;
+       for (Int_t crateId = 0; crateId < 8; crateId++) // 8 crates/regional boards for each side.
+         {
+           
+           name = AliMpTriggerCrate::GenerateName(crateId, ddlId, nofDDLs);
+           
+           crate = fRegionalTrigger.FindTriggerCrate(name, false);
+           
+           AliMUONTriggerCrateConfig* crateConfig = regionalConfig->FindTriggerCrate(crate->GetName());
+           if (!crateConfig) 
+             {
+               AliError(Form("Cannot find crate %s in CDB", crate->GetName()));
+               return kFALSE;
+             }
+           
+           out << crate->GetName()  << endl;
+           out << Form("%02x", crate->GetId())   << endl;
+           out << crateConfig->GetMode()  << endl;
+           out << crateConfig->GetCoinc() << endl;
+           out << Form("%04x", crateConfig->GetMask()) << endl;
+           out << Form("%02d",crate->GetNofLocalBoards()) << endl;
+           
+           for (Int_t iLocal = 0; iLocal < crate->GetNofLocalBoards(); ++iLocal) 
+             {
+               Int_t localBoardId = crate->GetLocalBoardId(iLocal);
+               
+               AliMpLocalBoard* board = fRegionalTrigger.FindLocalBoard(localBoardId);
+               
+               out << Form("%02d ", board->GetSlot())  
+                   << board->GetName() 
+                   << Form(" %03d ", localBoardId) 
+                   << Form("%03x", board->GetSwitch()) 
+                   << endl;
+               
+               out << " ";
+               
+               if (board->IsNotified()) {
+                 for (Int_t i = 0; i < board->GetNofDEs(); ++i)
+                   out << Form("%4d ", board->GetDEId(i));
+               } else {
+                 out << Form("%4d ", 0);
+               }
+               out << endl;
+               
+               // print copy card numbers & TC
+               out << Form(" %4d %4d", board->GetInputXfrom(), board->GetInputXto());
+               out << Form(" %4d %4d", board->GetInputYfrom(), board->GetInputYto());
+               out << Form(" %4d",     board->GetTC()) << endl;
+             }
+         }
       }
 
-      out << crate->GetName()  << endl;
-      out << Form("%02x", crate->GetId())   << endl;
-      out << crateConfig->GetMode()  << endl;
-      out << crateConfig->GetCoinc() << endl;
-      out << Form("%04x", crateConfig->GetMask()) << endl;
-
-      for (Int_t iLocal = 0; iLocal < crate->GetNofLocalBoards(); ++iLocal) 
-      {
-       Int_t localBoardId = crate->GetLocalBoardId(iLocal);
-        
-       AliMpLocalBoard* board = fRegionalTrigger.FindLocalBoard(localBoardId);
-        
-       out << Form("%02d ", board->GetSlot())  
-           << board->GetName() 
-           << Form(" %03d ", localBoardId) 
-           << Form("%03x", board->GetSwitch()) 
-           << endl;
-        out << " ";
-        for (Int_t i = 0; i < board->GetNofDEs(); ++i)
-          out << Form("%4d ", board->GetDEId(i));
-        out << endl;
-          
-        // print copy card numbers & TC
-        out << Form(" %4d %4d", board->GetInputXfrom(), board->GetInputXto());
-        out << Form(" %4d %4d", board->GetInputYfrom(), board->GetInputYto());
-        out << Form(" %4d",     board->GetTC()) << endl;
-      }
-    }
     out.close();
     
     return kTRUE;
@@ -655,7 +671,7 @@ AliMUONTriggerIO::WriteRegionalConfig(const char* regionalFile, AliMUONRegionalT
 
 //_____________________________________________________________________________
 Bool_t 
-AliMUONTriggerIO::WriteLocalMasks(const char* localFile, AliMUONVStore& localMasks, AliMUONRegionalTriggerConfig* regionalConfig) const
+AliMUONTriggerIO::WriteLocalMasks(const char* localFile, const AliMUONVStore& localMasks) const
 {
     /// write local mask
     /// removing/adding enable for a local board need a update of the configuration 
@@ -670,32 +686,23 @@ AliMUONTriggerIO::WriteLocalMasks(const char* localFile, AliMUONVStore& localMas
     }   
 
     UShort_t maskBuffer[8];
+    Int_t localBoardIndex(0);
+    while (localBoardIndex < NofLocalBoards()) {
 
-    TIter next(regionalConfig->CreateCrateIterator());
-    AliMUONTriggerCrateConfig* crate;
-    
-    while ( ( crate = static_cast<AliMUONTriggerCrateConfig*>(next()) ) )
-    {      
-      UShort_t mask = crate->GetMask(); // getting mask from current config
+      Int_t localBoardId = fRegionalTrigger.LocalBoardId(localBoardIndex);
 
-      for (Int_t iLocal = 0; iLocal < crate->GetNofLocalBoards(); ++iLocal) 
-      {
-       Int_t localBoardId = crate->GetLocalBoardId(iLocal);
+      AliMUONVCalibParam* localMask = 
+       static_cast<AliMUONVCalibParam*>(localMasks.FindObject(localBoardId));
 
-       if ( (mask >> iLocal ) & 0x1 
+      for (Int_t index = 0; index < 8; ++index
        {
-         AliMUONVCalibParam* localMask = 
-             static_cast<AliMUONVCalibParam*>(localMasks.FindObject(localBoardId));
-
-         for (Int_t index = 0; index < 8; ++index) 
-         {
-           maskBuffer[index] = localMask->ValueAsInt(index,0); 
-         }
-
-         fwrite ( maskBuffer, 2, 8, fp); 
+         maskBuffer[index] = localMask->ValueAsInt(index,0); 
        }
+      
+      fwrite ( maskBuffer, 2, 8, fp); 
+
+      ++localBoardIndex;
 
-      }
     }
 
     fclose(fp);