]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
updates for online PID (Uwe Westerhoff):
authorjklein <jklein@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 8 Dec 2011 18:16:14 +0000 (18:16 +0000)
committerjklein <jklein@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 8 Dec 2011 18:16:14 +0000 (18:16 +0000)
- bugfix in gain filter for MCM simulation
- protection for dictionary handling
- extend trapConfigHandler to load PID tables
- extend ltuParam to handle MCM-wise gain adjustment

TRD/AliTRDltuParam.cxx
TRD/AliTRDltuParam.h
TRD/AliTRDmcmSim.cxx
TRD/AliTRDtrapConfigHandler.cxx
TRD/AliTRDtrapConfigHandler.h

index 80096c5548eab112df9473636ee0bc7fa48449a5..8945b8f10c72c7643e5eb4cde70bde4ee1e93e3a 100644 (file)
@@ -39,7 +39,8 @@ AliTRDltuParam::AliTRDltuParam() :
   fScaleQ0(0),
   fScaleQ1(0),
   fPidTracklengthCorr(kFALSE),
-  fTiltCorr(kFALSE)
+  fTiltCorr(kFALSE),
+  fPidGainCorr(kFALSE)
 {
 
 }
@@ -122,15 +123,18 @@ Float_t AliTRDltuParam::GetElongation(Int_t det, Int_t rob, Int_t mcm, Int_t ch)
 }
 
 void AliTRDltuParam::GetCorrectionFactors(Int_t det, Int_t rob, Int_t mcm, Int_t ch,
-                                         UInt_t &cor0, UInt_t &cor1) const
+                                         UInt_t &cor0, UInt_t &cor1, Float_t gain) const
 {
+  if (fPidGainCorr==kFALSE)
+    gain=1;
+
   if (fPidTracklengthCorr == kTRUE ) {
-    cor0 = Int_t ((1.0*fScaleQ0* (1./GetElongation(det, rob, mcm, ch)) ));
-    cor1 = Int_t ((1.0*fScaleQ1* (1./GetElongation(det, rob, mcm, ch)) ));
+    cor0 = UInt_t ((1.0*fScaleQ0* (1./GetElongation(det, rob, mcm, ch))) / gain );
+    cor1 = UInt_t ((1.0*fScaleQ1* (1./GetElongation(det, rob, mcm, ch))) / gain );
   }
   else {
-    cor0 = fScaleQ0;
-    cor1 = fScaleQ1;
+    cor0 = UInt_t (fScaleQ0 / gain);
+    cor1 = UInt_t ( fScaleQ1 / gain);
   }
 }
 
index 13ba556a0809a0398f9a074dce1aacd82833e9ed..9313c77a27c10f60352a6548e44c288b2c56e5f5 100644 (file)
@@ -22,6 +22,7 @@ class AliTRDltuParam : public TObject
   void SetScaleQ1(Int_t data)   { fScaleQ1 = data; }
   void SetLengthCorrectionEnable(Int_t data) { fPidTracklengthCorr = Bool_t (data); }
   void SetTiltCorrectionEnable(Int_t data)   { fTiltCorr = Bool_t (data); }
+  void SetPIDgainCorrectionEnable(Bool_t data)   { fPidGainCorr = data; }
 
   // set values directly
   void SetRawPtMin(Float_t data)     { fPtMin = data; }
@@ -32,13 +33,14 @@ class AliTRDltuParam : public TObject
   void SetRawScaleQ1(Int_t data)     { fScaleQ1 = data; }
   void SetRawLengthCorrectionEnable(Bool_t data) { fPidTracklengthCorr = data; }
   void SetRawTiltCorrectionEnable(Bool_t data)   { fTiltCorr = data; }
+  void SetRawPIDgainCorrectionEnable(Bool_t data)   { fPidGainCorr = data; }
 
   // retrieve the calculated information
   // which is written to the TRAPs
   Int_t GetDyCorrection(Int_t det, Int_t rob, Int_t mcm) const;
   void  GetDyRange(Int_t det, Int_t rob, Int_t mcm, Int_t ch, Int_t &dyMinInt, Int_t &dyMaxInt) const;
   void  GetCorrectionFactors(Int_t det, Int_t rob, Int_t mcm, Int_t ch,
-                            UInt_t &cor0, UInt_t &cor1) const;
+                            UInt_t &cor0, UInt_t &cor1, Float_t gain = 1.) const;
   Int_t GetNtimebins() const;
 
   Float_t GetX(Int_t det, Int_t rob, Int_t mcm) const;
@@ -75,6 +77,7 @@ class AliTRDltuParam : public TObject
   UInt_t  fScaleQ1;            // scale factor for accumulated charge Q1
   Bool_t  fPidTracklengthCorr; // enable tracklet length correction
   Bool_t  fTiltCorr;           // enable tilt correction
+  Bool_t  fPidGainCorr;         // enable MCM gain correction factor for PID
 
   ClassDef(AliTRDltuParam, 1);
 };
index 11318c2e78d89837f38ef605d6427953eea88bc9..7aefe9ab531451a1e85267795d093199343a1876 100644 (file)
@@ -549,17 +549,18 @@ void AliTRDmcmSim::SetData(AliTRDarrayADC* const adcArray, AliTRDdigitsManager *
           continue;
 
         fDict[iDict] = newDict;
-        fDict[iDict]->Expand();
+       if(fDict[iDict]->GetDim() != 0)
+         fDict[iDict]->Expand();
       }
       else {
         fDict[iDict] = newDict;
-        if (fDict[iDict])
+        if (fDict[iDict] && (fDict[iDict]->GetDim() != 0) )
           fDict[iDict]->Expand();
-        }
+      }
 
       // If there is no data, set dictionary to zero to avoid crashes
       if (fDict[iDict]->GetDim() == 0)  {
-        AliError(Form("Dictionary %i of det. %i has dim. 0", iDict, fDetector));
+        // AliError(Form("Dictionary %i of det. %i has dim. 0", iDict, fDetector));
         fDict[iDict] = 0x0;
       }
     }
@@ -935,10 +936,14 @@ UShort_t AliTRDmcmSim::FilterGainNextSample(Int_t adc, UShort_t value)
   UShort_t    fgta = fTrapConfig->GetTrapReg(AliTRDtrapConfig::kFGTA, fDetector, fRobPos, fMcmPos); // 20;
   UShort_t    fgtb = fTrapConfig->GetTrapReg(AliTRDtrapConfig::kFGTB, fDetector, fRobPos, fMcmPos); // 2060;
 
+  UInt_t fgfExtended = 0x700 + fgf;      // The corr factor which is finally applied has to be extended by 0x700 (hex) or 0.875 (dec)
+                                         // because fgf=0 correspons to 0.875 and fgf=511 correspons to 1.125 - 2^(-11)
+                                         // (see TRAP User Manual for details)
+
   UInt_t corr; // corrected value
 
   value &= 0xFFF;
-  corr = (value * fgf) >> 11;
+  corr = (value * fgfExtended) >> 11;
   corr = corr > 0xfff ? 0xfff : corr;
   corr = AddUintClipping(corr, fga, 12);
 
index b7100b9a2308fd7cdb5a2a8acf93bb1af8f681dd..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,19 +217,24 @@ 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++) {
@@ -317,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)
 {
    //
@@ -467,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);
     }
index 84af956e26fbe57ca448748236876a4dbfae4ae0..7d2ea6c35e80c270e12e79f4b1bb20cde5222a58 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <TObject.h>
 #include "AliTRDltuParam.h"
+#include "AliTRDCalOnlineGainTable.h"
 
 class AliTRDtrapConfig;
 
@@ -23,6 +24,7 @@ class AliTRDtrapConfigHandler : public TObject {
   void ResetMCMs();                                           // Reset all trap registers and DMEM of the MCMs
   Int_t LoadConfig();                                         // load a default configuration suitable for simulation
   Int_t LoadConfig(TString filename);                         // load a TRAP configuration from a file
+  Int_t SetGaintable(AliTRDCalOnlineGainTable const &gtbl);   // Set a gain table to correct Q0 and Q1 for PID
 
   void ProcessLTUparam(Int_t dest, Int_t addr, UInt_t data);  // Process the LTU parameters
   void PrintGeoTest();                                        // Prints some information about the geometry. Only for debugging
@@ -66,6 +68,8 @@ class AliTRDtrapConfigHandler : public TObject {
 
   UInt_t fRestrictiveMask;                 // mask to restrict subsequent commands to specified chambers
 
+  AliTRDCalOnlineGainTable fGtbl;          // gain table
+
   ClassDef(AliTRDtrapConfigHandler,0)
 };