Added ReadFromFile and WriteToFile methods in AliFMDCalibSampleRate to allow file...
authorhdalsgaa <hdalsgaa@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 3 Jun 2008 15:06:43 +0000 (15:06 +0000)
committerhdalsgaa <hdalsgaa@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 3 Jun 2008 15:06:43 +0000 (15:06 +0000)
FMD/AliFMDBaseDA.cxx
FMD/AliFMDCalibSampleRate.cxx
FMD/AliFMDCalibSampleRate.h

index 7fb11a2..a85bcfd 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "AliFMDRawReader.h"
 #include "AliFMDCalibSampleRate.h"
+#include "AliFMDCalibStripRange.h"
 #include "AliLog.h"
 //_____________________________________________________________________
 ClassImp(AliFMDBaseDA)
@@ -278,37 +279,52 @@ void AliFMDBaseDA::WriteConditionsData()
   
   // Sample Rate
   
-  UInt_t defSampleRate = 4;
-  UInt_t sampleRateFromSOD;
+  UShort_t defSampleRate = 4;
+  UShort_t sampleRateFromSOD;
   //UInt_t timebins   = 544;
   AliFMDCalibSampleRate* sampleRate = new AliFMDCalibSampleRate();
-  for(UShort_t det=1;det<=3;det++) {
+
+  UShort_t firstStrip = 0;
+  UShort_t lastStrip  = 127;
+  UShort_t firstStripSOD;
+  UShort_t lastStripSOD;
+  AliFMDCalibStripRange* stripRange = new AliFMDCalibStripRange();
+  
+  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++)  {
-       for(UShort_t strip = 0; strip < nstr; strip++) {
-         sampleRateFromSOD = defSampleRate;
-         sampleRate->Set(det,ring,sec,strip,sampleRateFromSOD);
-         fConditionsFile << det                 << ',' 
-                         << ring                << ','
-                         << sec                 << ','
-                         << strip               << ','
-                         << "samplerate"        << ','
-                         << sampleRateFromSOD   << "\n";
-       }
+       for(UShort_t strip = 0 ; strip <nstr; nstr++)
+         {
+           sampleRateFromSOD = defSampleRate;
+           sampleRate->Set(det,ring,sec,strip,sampleRateFromSOD);
+           firstStripSOD = firstStrip;
+           lastStripSOD  = lastStrip;
+           stripRange->Set(det,ring,sec,strip,firstStripSOD,lastStripSOD);
+          
+         }
+       
       }
     }
   }
   
-  pars->SetSampleRate(sampleRate);
+  sampleRate->WriteToFile(fConditionsFile);
   
+  pars->SetSampleRate(sampleRate);
+  pars->SetStripRange(firstStrip,lastStrip);
+
   // Zero Suppresion
   
   // Strip Range
   
+  
+  
+  
   // Gain Relevant stuff
   
   UShort_t defPulseSize = 32 ; 
index 8cb2202..85a8631 100644 (file)
@@ -29,6 +29,7 @@
 #include "AliFMDCalibSampleRate.h"     // ALIFMDCALIBGAIN_H
 // #include "AliFMDParameters.h"           // ALIFMDPARAMETERS_H
 // #include <AliLog.h>
+#include "TString.h"
 #include "AliFMDDebug.h" // Better debug macros
 
 //____________________________________________________________________
@@ -85,6 +86,73 @@ AliFMDCalibSampleRate::Rate(UShort_t det, Char_t ring,
                    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);
+      UShort_t nstr = (ir == 0 ? 256 : 512);
+      for(UShort_t sec =0; sec < nsec;  sec++)  {
+       outFile << det                   << ','
+               << ring                  << ','
+               << sec                   << ','
+               << Rate(det,ring,sec)    << "\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, sec;
+  Char_t ring;
+  UShort_t sampleRate;
+  Int_t thisline = inFile.tellg();
+  Char_t c[3];
+  
+  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]
+              >> sampleRate;
+    
+    Set(det,ring,sec,0,sampleRate);
+
+  }
+  
+  inFile.seekg(0);
+  
+}
 
 //____________________________________________________________________
 //
index 7719554..3e6caa9 100644 (file)
@@ -19,6 +19,9 @@
     @brief   Per digitizer card pulser calibration
     @ingroup FMD_base    
 */
+
+#include <iostream>
+#include <fstream>
 #ifndef ROOT_TObject
 # include <TObject.h>
 #endif
@@ -59,6 +62,10 @@ public:
       @param str  Strip number (not used)
       @return Sample rate */
   UShort_t Rate(UShort_t det, Char_t ring, UShort_t sec, UShort_t str=0) const;
+
+  void WriteToFile(ofstream &);
+  
+  void ReadFromFile(ifstream &);
 protected:
   // TArrayI fRates; // Sample rates 
   AliFMDUShortMap fRates; // Sample rates