]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTriggerIO.cxx
ALIROOT-5420 Changes for CDH v3
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerIO.cxx
index 21f476dbae3bfb82db1e22ff56b2a1fbbae407bf..e05b1022da503c91376c98c7d83009f33988ba3a 100644 (file)
@@ -45,6 +45,9 @@
 /// \author Laurent Aphecetche, Christian Finck Subatech
 /// \author Bogdan Vulpescu, LPC Clermont-Ferrand
 
+using std::endl;
+using std::cout;
+using std::ofstream;
 /// \cond CLASSIMP
 ClassImp(AliMUONTriggerIO)
 /// \endcond
@@ -283,7 +286,10 @@ AliMUONTriggerIO::ReadLocalLUT(AliMUONTriggerLut& lut,
   Bool_t trigx = kFALSE;
   
   // read two lut addresses at once, 32768/2=16384 times
-  fread(buffer,fgkLocalLutSize,1,flut);
+  if (fread(buffer,fgkLocalLutSize,1,flut) == 0) {
+    AliWarning("Error reading the LUT file");
+    return;
+  }
 
   // create the 32767 addresses for the 4-bits lpt and hpt half-bytes
   for (UShort_t ilut = 0; ilut < fgkLocalLutSize*2; ilut += 2) 
@@ -375,8 +381,30 @@ AliMUONTriggerIO::ReadLUT(const char* lutFileToRead, AliMUONTriggerLut& lut)
     ReadLocalLUT(lut,fRegionalTrigger.LocalBoardId(i),flut);
   }
   
+  // 
+  // 1st/2nd cut code   pt cut [GeV/c]
+  //
+  // 0                 0.5 (a.k.a. Apt)
+  // 1                 1.0 (a.k.a. Lpt)
+  // 2                 1.7 (a.k.a. Hpt)
+  // 3                 4.2 (a.k.a. infinity)
+  // 4                 free
+  // .
+  // .
+  // .
+  //15                 default (for backward compatibility)
+
+  UChar_t lutCode = 0xFF;
+
+  if (!fread(&lutCode,1,1,flut)) {
+    AliWarning("No LUT info in the file (old version)");
+  }
+  AliInfo(Form("LUT code: 0x%02x",lutCode));
+
   fclose(flut);
-  
+
+  lut.SetLutCode(lutCode);
+
   return kTRUE;
   
 }
@@ -392,7 +420,7 @@ AliMUONTriggerIO::ReadConfig(const char* localFile,
 {
   /// Fill the various masks store from files
   
-  if ( !regionalFile || strlen(regionalFile)==0 ) 
+  if ( !regionalConfig || !regionalFile || strlen(regionalFile)==0 ) 
   {
     AliError("Must have a regional file name to proceeed");
     return kFALSE;
@@ -492,7 +520,7 @@ Bool_t
 AliMUONTriggerIO::WriteConfig(const char* localFile,
                             const char* regionalFile,
                             const char* globalFile,
-                            AliMUONVStore* localMasks,
+                            const AliMUONVStore* localMasks,
                     AliMUONRegionalTriggerConfig* regionalConfig,
                     AliMUONGlobalCrateConfig* globalConfig) const
 {
@@ -530,7 +558,7 @@ AliMUONTriggerIO::WriteGlobalConfig(const char* globalFile, AliMUONGlobalCrateCo
   
   // Jtag
   out << globalConfig->GetJtagName() << endl;
-  out << Form("0x%08x", globalConfig->GetJtagVmeAddr()) << endl;
+  out << Form("0x%08lx", globalConfig->GetJtagVmeAddr()) << endl;
   out << Form("%d %d %d", globalConfig->GetJtagClockDiv(), 
               globalConfig->GetJtagRxPhase(), globalConfig->GetJtagRdDelay()) << endl;
  
@@ -548,7 +576,7 @@ AliMUONTriggerIO::WriteGlobalConfig(const char* globalFile, AliMUONGlobalCrateCo
   
   // first darc board
   out << globalConfig->GetFirstDarcName() << endl;
-  out << Form("0x%08x", globalConfig->GetFirstDarcVmeAddr()) << endl;
+  out << Form("0x%08lx", globalConfig->GetFirstDarcVmeAddr()) << endl;
   out << globalConfig->GetFirstDarcType() << endl;
   disable = globalConfig->GetFirstDarcDisable();
   out << Form("0x%02x", disable) << endl;
@@ -559,7 +587,7 @@ AliMUONTriggerIO::WriteGlobalConfig(const char* globalFile, AliMUONGlobalCrateCo
   
   // second darc board
   out << globalConfig->GetSecondDarcName() << endl;
-  out << Form("0x%08x", globalConfig->GetSecondDarcVmeAddr()) << endl;
+  out << Form("0x%08lx", globalConfig->GetSecondDarcVmeAddr()) << endl;
   out << globalConfig->GetSecondDarcType() << endl;
   disable = globalConfig->GetSecondDarcDisable();
   out << Form("0x%02x", disable) << endl;
@@ -570,13 +598,13 @@ AliMUONTriggerIO::WriteGlobalConfig(const char* globalFile, AliMUONGlobalCrateCo
   
   // global board
   out << globalConfig->GetGlobalName() << endl;
-  out << Form("0x%08x", globalConfig->GetGlobalVmeAddr()) << endl;
+  out << Form("0x%08lx", globalConfig->GetGlobalVmeAddr()) << endl;
   for (Int_t i = 0; i < globalConfig->GetGlobalNofRegisters(); ++i)
     out << Form("0x%x", globalConfig->GetGlobalRegister(i)) << endl;
   
   // Fet board
   out << globalConfig->GetFetName() << endl;
-  out << Form("0x%08x", globalConfig->GetFetVmeAddr()) << endl;
+  out << Form("0x%08lx", globalConfig->GetFetVmeAddr()) << endl;
   for (Int_t i = 0; i < globalConfig->GetFetNofRegisters(); ++i)
     out << Form("0x%x", globalConfig->GetFetRegister(i)) << endl;
   
@@ -671,7 +699,7 @@ AliMUONTriggerIO::WriteRegionalConfig(const char* regionalFile, AliMUONRegionalT
 
 //_____________________________________________________________________________
 Bool_t 
-AliMUONTriggerIO::WriteLocalMasks(const char* localFile, AliMUONVStore& localMasks) 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