]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFFEEReader.cxx
Fixed install target
[u/mrichter/AliRoot.git] / TOF / AliTOFFEEReader.cxx
index 102020071a55e0d8b03b4bd820864af5b770edfb..d414252e54863d87289870c6780ba2b81c1790c2 100644 (file)
 #include <TSystem.h>
 #include "AliTOFFEEReader.h"
 #include "AliTOFFEEConfig.h"
+#include "AliTOFFEElightConfig.h"
 #include "AliTOFRawStream.h"
 #include "AliTOFGeometry.h"
+#include "AliTOFcalibHisto.h"
 #include "AliLog.h"
 #include <fstream>
 
@@ -40,8 +42,10 @@ ClassImp(AliTOFFEEReader)
 AliTOFFEEReader::AliTOFFEEReader() :
   TObject(),
   fFEEConfig(new AliTOFFEEConfig()),
+  fFEElightConfig(new AliTOFFEElightConfig()),
   fChannelEnabled(),
-  fMatchingWindow()
+  fMatchingWindow(),
+  fLatencyWindow()
 {
   /* 
    * 
@@ -56,7 +60,8 @@ AliTOFFEEReader::AliTOFFEEReader() :
 
 AliTOFFEEReader::AliTOFFEEReader(const AliTOFFEEReader &source) :
   TObject(source),
-  fFEEConfig(new AliTOFFEEConfig())
+  fFEEConfig(new AliTOFFEEConfig()),
+  fFEElightConfig(new AliTOFFEElightConfig())
 {
   /* 
    * 
@@ -65,6 +70,7 @@ AliTOFFEEReader::AliTOFFEEReader(const AliTOFFEEReader &source) :
    */
 
   memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig));
+  memcpy(fFEElightConfig, source.fFEElightConfig, sizeof(AliTOFFEElightConfig));
 }
 
 //_______________________________________________________________
@@ -80,6 +86,7 @@ AliTOFFEEReader::operator=(const AliTOFFEEReader &source)
 
   TObject::operator=(source);
   memcpy(fFEEConfig, source.fFEEConfig, sizeof(AliTOFFEEConfig));
+  memcpy(fFEElightConfig, source.fFEElightConfig, sizeof(AliTOFFEElightConfig));
   return *this;
 }
 
@@ -94,6 +101,7 @@ AliTOFFEEReader::~AliTOFFEEReader()
    */
 
   delete fFEEConfig;
+  delete fFEElightConfig;
 }
 
 //_______________________________________________________________
@@ -113,6 +121,21 @@ AliTOFFEEReader::ResetChannelEnabledArray()
 
 //_______________________________________________________________
 
+void
+AliTOFFEEReader::ResetTriggerMaskArray()
+{
+  /*
+   *
+   * reset trigger mask array
+   *
+   */
+
+  for (Int_t iddl = 0; iddl < GetNumberOfDDLs(); iddl++)
+    fTriggerMask[iddl] = 0x0;
+}
+
+//_______________________________________________________________
+
 void
 AliTOFFEEReader::Reset()
 {
@@ -125,7 +148,11 @@ AliTOFFEEReader::Reset()
   for (Int_t iIndex = 0; iIndex < GetNumberOfIndexes(); iIndex++) {
     fChannelEnabled[iIndex] = kFALSE;
     fMatchingWindow[iIndex] = 0;
+    fLatencyWindow[iIndex] = 0;
   }
+
+  for (Int_t iddl = 0; iddl < GetNumberOfDDLs(); iddl++)
+    fTriggerMask[iddl] = 0x0;
 }
 
 //_______________________________________________________________
@@ -148,6 +175,24 @@ AliTOFFEEReader::LoadFEEConfig(const Char_t *FileName) const
 
 //_______________________________________________________________
 
+void
+AliTOFFEEReader::LoadFEElightConfig(const Char_t *FileName) const
+{
+  /*
+   *
+   * load FEElight config
+   *
+   */
+
+  Char_t *expandedFileName = gSystem->ExpandPathName(FileName);
+  std::ifstream is;
+  is.open(expandedFileName, std::ios::binary);
+  is.read((Char_t *)fFEElightConfig, sizeof(AliTOFFEElightConfig));
+  is.close();
+}
+
+//_______________________________________________________________
+
 Int_t
 AliTOFFEEReader::ParseFEEConfig()
 {
@@ -160,7 +205,7 @@ AliTOFFEEReader::ParseFEEConfig()
    *
    */
 
-  AliInfo("parsing TOF FEE config")
+  AliInfo("parsing TOF FEE config");
 
   AliTOFRawStream rawStream;
   Int_t nEnabled = 0;
@@ -203,6 +248,50 @@ AliTOFFEEReader::ParseFEEConfig()
 
 //_______________________________________________________________
 
+Int_t
+AliTOFFEEReader::ParseFEElightConfig()
+{
+  /* 
+   *
+   * parse FEElight config
+   *
+   * loops over all FEE channels, checks whether they are enabled
+   * and sets channel enabled 
+   *
+   */
+
+  AliInfo("parsing TOF FEElight config");
+
+  Reset();
+
+  AliTOFcalibHisto calibHisto;
+  calibHisto.LoadCalibHisto();
+
+  Int_t nEnabled = 0, index;
+  AliTOFFEEchannelConfig *channelConfig = NULL;
+  for (Int_t i = 0; i < GetNumberOfIndexesEO(); i++) {
+    channelConfig = fFEElightConfig->GetChannelConfig(i);
+    if (!channelConfig->IsEnabled()) continue;
+    /* get index DO from index EO */
+    index = (Int_t)calibHisto.GetCalibMap(AliTOFcalibHisto::kIndex, i);
+    if (index == -1) continue;
+    nEnabled++;
+    fChannelEnabled[index] = channelConfig->IsEnabled();
+    fMatchingWindow[index] = channelConfig->GetMatchingWindow();
+    fLatencyWindow[index] = channelConfig->GetLatencyWindow();
+  }
+
+  AliTOFFEEtriggerConfig *triggerConfig = NULL;
+  for (Int_t iddl = 0; iddl < GetNumberOfDDLs(); iddl++) {
+    triggerConfig = fFEElightConfig->GetTriggerConfig(iddl);
+    fTriggerMask[iddl] = triggerConfig->GetStatusMap();
+  }
+  return nEnabled;
+}
+
+//_______________________________________________________________
+
 Bool_t 
 AliTOFFEEReader::IsChannelEnabled(Int_t iDDL, Int_t iTRM, Int_t iChain, Int_t iTDC, Int_t iChannel) const
 {
@@ -382,7 +471,7 @@ AliTOFFEEReader::DumpFEEConfig()
   AliInfo("dumping TOF FEE config");
   AliInfo("-------------------------------------");
   AliInfo(Form("version: %d", feeConfig->GetVersion()));
-  AliInfo(Form("dump time: %d", feeConfig->GetDumpTime()));
+  AliInfo(Form("dump time: %d", (Int_t)feeConfig->GetDumpTime()));
   AliInfo(Form("run number: %d", feeConfig->GetRunNumber()));
   AliInfo(Form("run type: %d", feeConfig->GetRunType()));
   AliInfo("-------------------------------------");
@@ -449,3 +538,36 @@ AliTOFFEEReader::DumpFEEConfig()
   } /* loop over crates */
 }
 
+//_______________________________________________________________
+
+void
+AliTOFFEEReader::CreateFEElightConfig(const Char_t *filename)
+{
+  /*
+   *
+   * create FEElight config 
+   *
+   */
+
+  AliTOFFEElightConfig lightConfig;
+
+  for (Int_t i = 0; i < GetNumberOfIndexes(); i++) {
+    if (fChannelEnabled[i]) {
+      lightConfig.GetChannelConfig(i)->SetStatus(AliTOFFEEchannelConfig::kStatusEnabled);
+      lightConfig.GetChannelConfig(i)->SetMatchingWindow(fMatchingWindow[i]);
+      lightConfig.GetChannelConfig(i)->SetLatencyWindow(fLatencyWindow[i]);
+    }
+    else {
+      lightConfig.GetChannelConfig(i)->SetStatus(0x0);
+      lightConfig.GetChannelConfig(i)->SetMatchingWindow(0);
+      lightConfig.GetChannelConfig(i)->SetLatencyWindow(0);
+    }
+  }
+
+  Char_t *expandedFileName = gSystem->ExpandPathName(filename);
+  std::ofstream os;
+  os.open(expandedFileName, std::ios::binary);
+  os.write((Char_t *)&lightConfig, sizeof(AliTOFFEElightConfig));
+  os.close();
+  
+}