]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDCalibSampleRate.cxx
Commit of new FMD3 geometry and other geometry related issues.
[u/mrichter/AliRoot.git] / FMD / AliFMDCalibSampleRate.cxx
index 80dbdba8cc132c331559f2cb61f8233413caf19f..607e7184c5b94be480071bc589a90a09dccfc0ed 100644 (file)
 //
 #include "AliFMDCalibSampleRate.h"     // ALIFMDCALIBGAIN_H
 // #include "AliFMDParameters.h"           // ALIFMDPARAMETERS_H
-#include <AliLog.h>
+// #include <AliLog.h>
+#include "TString.h"
+#include "AliFMDDebug.h" // Better debug macros
+#include "iostream"
 
 //____________________________________________________________________
 ClassImp(AliFMDCalibSampleRate)
@@ -67,9 +70,10 @@ AliFMDCalibSampleRate::Set(UShort_t det, Char_t ring,
                           UShort_t sector, UShort_t, UShort_t rate)
 {
   // Set values.  Strip argument is ignored 
-  UInt_t nSec  = (ring == 'I' ? 20 : 40);
+  UInt_t nSec  = (ring == 'I' ? 10 : 20);
   UInt_t board = sector / nSec;
   fRates(det, ring, board, 0) = rate;
+  
 }
 
 //____________________________________________________________________
@@ -78,12 +82,82 @@ AliFMDCalibSampleRate::Rate(UShort_t det, Char_t ring,
                            UShort_t sec, UShort_t) const
 {
   // Get the sample rate 
-  UInt_t nSec  = (ring == 'I' ? 20 : 40);
+  UInt_t nSec  = (ring == 'I' ? 10 : 20);
   UInt_t board = sec / nSec;
-  AliDebug(10, Form("Getting sample rate for FMD%d%c[%2d,0] (board %d)", 
+  AliFMDDebug(10, ("Getting sample rate for FMD%d%c[%2d,0] (board %d)", 
                    det, ring, sec, board));
   return fRates(det, ring, board, 0);
 }
+//____________________________________________________________________
+void 
+AliFMDCalibSampleRate::WriteToFile(ofstream &outFile)
+{
+  outFile.write("# SampleRate \n",14);
+  for(Int_t det=1;det<=3;det++) {
+    UShort_t FirstRing = (det == 1 ? 1 : 0);
+    for (UShort_t ir = FirstRing; ir < 2; ir++) {
+      Char_t   ring = (ir == 0 ? 'O' : 'I');
+      // UShort_t nsec = (ir == 0 ? 40  : 20);
+      
+      for(UShort_t board = 0; board < 2;  board++)  {
+       outFile << det                     << ','
+               << ring                    << ','
+               << board                   << ','
+               << Rate(det,ring,board)    << "\n";
+         
+
+      }
+    }
+  }
+      
+}
+//____________________________________________________________________
+void 
+AliFMDCalibSampleRate::ReadFromFile(ifstream &inFile)
+{
+  TString line;
+  Bool_t readData=kFALSE;
+
+  while(line.ReadLine(inFile)) {
+    if(line.Contains("samplerate",TString::kIgnoreCase)) {
+      readData = kTRUE;
+      break;
+    }
+    
+  }
+  
+  UShort_t det, board;
+  Char_t ring;
+  UShort_t sampleRate;
+  Int_t thisline = inFile.tellg();
+  Char_t c[3];
+  
+  while( readData ) {
+    thisline = inFile.tellg();
+    line.ReadLine(inFile);
+    if(line.Contains("# ",TString::kIgnoreCase)) {
+      readData = kFALSE;
+      continue;
+    }
+    
+    inFile.seekg(thisline);
+    inFile     >> det          >> c[0]
+              >> ring         >> c[1]
+              >> board        >> c[2]
+              >> sampleRate;
+    
+    UInt_t nSec  = (ring == 'I' ? 10 : 20);
+    UShort_t sector = board*nSec;
+    Set(det,ring,sector,0,sampleRate);
+    
+    
+  }
+  
+  inFile.seekg(0);
+  
+}
 
 //____________________________________________________________________
 //