]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDtrapConfigHandler.cxx
File used to set the path to the OCDB Default Storage older in alien when using raw...
[u/mrichter/AliRoot.git] / TRD / AliTRDtrapConfigHandler.cxx
index ec502800479978ba04e508e19ff0edbe6ceaae65..ae3b480bbc05366129ec8f718d6b562459426405 100644 (file)
@@ -24,6 +24,7 @@
 #include "AliTRDtrapConfigHandler.h"
 
 #include <iostream>
+#include <sstream>
 #include <iomanip>
 
 #include "AliLog.h"
 #include "TGeoMatrix.h"
 #include "TGraph.h"
 
+#include "Cal/AliTRDCalOnlineGainTable.h"
+#include "Cal/AliTRDCalOnlineGainTableROC.h"
+#include "Cal/AliTRDCalOnlineGainTableMCM.h"
+
 using namespace std;
 
 ClassImp(AliTRDtrapConfigHandler)
@@ -43,6 +48,7 @@ ClassImp(AliTRDtrapConfigHandler)
 AliTRDtrapConfigHandler::AliTRDtrapConfigHandler() :
      ltuParam()
      , fRestrictiveMask((0x3ffff << 11) | (0x1f << 6) | 0x3f)
+     , fGtbl()
 {
 
 }
@@ -211,25 +217,33 @@ Int_t AliTRDtrapConfigHandler::LoadConfig(TString filename)
    }
 
    UInt_t cmd;
-   Int_t extali, addr, data;
+   Int_t extali, addr, data, cmdno;
 
    // reset restrictive mask
    fRestrictiveMask = (0x3ffff << 11) | (0x1f << 6) | 0x3f;
+   char linebuffer[512];
+   istringstream line;
 
-   while(infile.good()) {
+   while(infile.getline(linebuffer, 512) && infile.good()) {
+      line.clear();
+      line.str(linebuffer);
       cmd=999;
       extali=-1;
       addr=-1;
       data=-1;
-      infile >> std::skipws >> cmd >> addr >> data >> extali;
+      line >> std::skipws >> cmd >> addr >> data >> extali;  // the lines read from config file can contain additional columns.
+      // Therefore the detour via istringstream
 
-      if(cmd!=999 && extali!=-1 && addr != -1 && data!= -1 && extali!=-1) {
+      if(cmd!=999 && addr != -1 && data!= -1 && extali!=-1) {
 
         if(cmd==fgkScsnCmdWrite) {
            for(Int_t det=0; det<AliTRDgeometry::Ndet(); det++) {
               UInt_t rocpos = (1 << (AliTRDgeometry::GetSector(det)+11)) | (1 << (AliTRDgeometry::GetStack(det)+6)) | (1 << AliTRDgeometry::GetLayer(det));
-              if ((fRestrictiveMask & rocpos) == rocpos)
+              AliDebug(1, Form("checking restriction: mask=0x%08x, rocpos=0x%08x", fRestrictiveMask, rocpos));
+              if ((fRestrictiveMask & rocpos) == rocpos) {
+                AliDebug(1, Form("match: %i %i %i %i", cmd, extali, addr, data));
                  cfg->AddValues(det, cmd, extali, addr, data);
+              }
            }
         }
 
@@ -239,10 +253,54 @@ Int_t AliTRDtrapConfigHandler::LoadConfig(TString filename)
 
         else if(cmd == fgkScsnCmdRestr) {
            fRestrictiveMask = data;
+          AliDebug(1, Form("updated restrictive mask to 0x%08x", fRestrictiveMask));
         }
 
-        else
+        else if((cmd == fgkScsnCmdReset) ||
+                (cmd == fgkScsnCmdRobReset)) {
+          cfg->ResetRegs();
+        }
+
+        else if (cmd == fgkScsnCmdSetHC) {
+          Int_t fullVersion = ((data & 0x7F00) >> 1) | (data & 0x7f);
+
+          for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) {
+            Int_t smls = (AliTRDgeometry::GetSector(iDet) << 6) | (AliTRDgeometry::GetLayer(iDet) << 3) | AliTRDgeometry::GetStack(iDet);
+
+            for (Int_t iRob = 0; iRob < 8; iRob++) {
+              // HC mergers
+              cfg->SetTrapReg(AliTRDtrapConfig::kC14CPUA, 0xc << 16, iDet, iRob, 17);
+              cfg->SetTrapReg(AliTRDtrapConfig::kC15CPUA, ((1<<29) | (fullVersion<<15) | (1<<12) | (smls<<1) | (iRob%2)), iDet, iRob, 17);
+
+              // board mergers
+              cfg->SetTrapReg(AliTRDtrapConfig::kC14CPUA, 0, iDet, iRob, 16);
+              cfg->SetTrapReg(AliTRDtrapConfig::kC15CPUA, ((1<<29) | (fullVersion<<15) | (1<<12) | (smls<<1) | (iRob%2)), iDet, iRob, 16);
+
+              // and now for the others
+              for (Int_t iMcm = 0; iMcm < 16; iMcm++) {
+                cfg->SetTrapReg(AliTRDtrapConfig::kC14CPUA, iMcm | (iRob << 4) | (3 << 16), iDet, iRob, iMcm);
+                cfg->SetTrapReg(AliTRDtrapConfig::kC15CPUA, ((1<<29) | (fullVersion<<15) | (1<<12) | (smls<<1) | (iRob%2)), iDet, iRob, iMcm);
+              }
+            }
+          }
+        }
+
+        else if((cmd == fgkScsnCmdRead) ||
+                (cmd == fgkScsnCmdPause) ||
+                (cmd == fgkScsnCmdPtrg) ||
+                (cmd == fgkScsnCmdHwPtrg) ||
+                (cmd == fgkScsnCmdRobPower) ||
+                (cmd == fgkScsnCmdTtcRx) ||
+                (cmd == fgkScsnCmdMcmTemp) ||
+                (cmd == fgkScsnCmdOri) ||
+                (cmd == fgkScsnCmdPM) ) {
+          AliDebug(2, Form("ignored SCSN command: %i %i %i %i", cmd, addr, data, extali));
+        }
+
+        else {
+            AliWarning(Form("unknown SCSN command: %i %i %i %i", cmd, addr, data, extali));
            ignoredCmds++;
+        }
 
         readLines++;
       }
@@ -256,7 +314,7 @@ Int_t AliTRDtrapConfigHandler::LoadConfig(TString filename)
       if(!infile.eof())
         infile.clear();
    }
-      
+
    infile.close();
 
    AliDebug(5, Form("Ignored lines: %i, ignored cmds: %i", ignoredLines, ignoredCmds));
@@ -270,6 +328,14 @@ Int_t AliTRDtrapConfigHandler::LoadConfig(TString filename)
 }
 
 
+
+Int_t AliTRDtrapConfigHandler::SetGaintable(AliTRDCalOnlineGainTable const &gtbl)
+{
+   fGtbl=gtbl;
+   return 0;
+}
+
+
 void AliTRDtrapConfigHandler::ProcessLTUparam(Int_t dest, Int_t addr, UInt_t data)
 {
    //
@@ -420,7 +486,10 @@ void AliTRDtrapConfigHandler::ConfigurePIDcorr(Int_t det)
    for (Int_t r=0; r<nRobs; r++) {
       for(Int_t m=0; m<16; m++) {
         Int_t dest =  1<<10 | r<<7 | m;
-        ltuParam.GetCorrectionFactors(det, r, m, 9, cor0, cor1);
+        if(fGtbl.GetGainTableROC(det) && fGtbl.GetGainTableROC(det)->GetGainTableMCM(r, m))
+           ltuParam.GetCorrectionFactors(det, r, m, 9, cor0, cor1, fGtbl.GetGainTableROC(det)->GetGainTableMCM(r, m)->GetMCMGain());
+        else
+           ltuParam.GetCorrectionFactors(det, r, m, 9, cor0, cor1);
         AliTRDtrapConfig::Instance()->AddValues(det, fgkScsnCmdWrite, dest, addrLUTcor0, cor0);
         AliTRDtrapConfig::Instance()->AddValues(det, fgkScsnCmdWrite, dest, addrLUTcor1, cor1);
     }