]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDCalibStripRange.cxx
Included ReadFromFile and WriteToFile methods to read/write from ASCII files and...
[u/mrichter/AliRoot.git] / FMD / AliFMDCalibStripRange.cxx
index 9831c3ee83284f9cf9c834c82576d744da963a90..18c05a4331463ac0f8183b705bf1269c35a1376b 100644 (file)
@@ -27,6 +27,7 @@
 // This information comes from DCS or the like.
 //
 #include "AliFMDCalibStripRange.h"     // ALIFMDCALIBGAIN_H
+#include "TString.h"
 // #include "AliFMDParameters.h"           // ALIFMDPARAMETERS_H
 
 //____________________________________________________________________
@@ -93,6 +94,75 @@ AliFMDCalibStripRange::Max(UShort_t det, Char_t ring,
   UInt_t board = sec / nSec;
   return ((fRanges(det, ring, board, 0) >> 8) & 0x7f);
 }
+//____________________________________________________________________
+void 
+AliFMDCalibStripRange::WriteToFile(ofstream &outFile)
+{
+  outFile.write("# StripRange \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);
+      UShort_t nstr = (ir == 0 ? 256 : 512);
+      for(UShort_t sec =0; sec < nsec;  sec++)  {
+       outFile << det                   << ','
+               << ring                  << ','
+               << sec                   << ','
+               << Min(det,ring,sec)     << ','
+               << Max(det,ring,sec)     << "\n";
+         
+
+      }
+    }
+  }
+      
+}
+//____________________________________________________________________
+void 
+AliFMDCalibStripRange::ReadFromFile(ifstream &inFile)
+{
+  TString line;
+  Bool_t readData=kFALSE;
+
+  while(line.ReadLine(inFile)) {
+    if(line.Contains("striprange",TString::kIgnoreCase)) {
+      readData = kTRUE;
+      break;
+    }
+    
+  }
+  
+  UShort_t det, sec;
+  Char_t ring;
+  UShort_t min, max;
+  Int_t thisline = inFile.tellg();
+  Char_t c[4];
+  
+  while(line.ReadLine(inFile) && readData ) {
+    thisline = inFile.tellg();
+    thisline = thisline--;
+    if(line.Contains("# ",TString::kIgnoreCase)) {
+      readData = kFALSE;
+      continue;
+    }
+    
+    inFile.seekg(thisline);
+    inFile     >> det          >> c[0]
+              >> ring         >> c[1]
+              >> sec          >> c[2]
+              >> min          >> c[3]
+              >> max;
+    
+    Set(det,ring,sec,0,min,max);
+
+  }
+  
+  inFile.seekg(0);
+  
+}
 
 //____________________________________________________________________
 //