]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
- use identical code for calculation of tracklet parameters as in FEE
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 19 Feb 2011 18:23:56 +0000 (18:23 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 19 Feb 2011 18:23:56 +0000 (18:23 +0000)
- automatically load default values of TRAP settings for simulation

TRD/AliTRDltuParam.cxx [new file with mode: 0644]
TRD/AliTRDltuParam.h [new file with mode: 0644]
TRD/AliTRDtrapConfig.cxx
TRD/AliTRDtrapConfig.h
TRD/AliTRDtrapConfigHandler.cxx
TRD/AliTRDtrapConfigHandler.h
TRD/CMakelibTRDbase.pkg
TRD/TRDbaseLinkDef.h

diff --git a/TRD/AliTRDltuParam.cxx b/TRD/AliTRDltuParam.cxx
new file mode 100644 (file)
index 0000000..ddc2bab
--- /dev/null
@@ -0,0 +1,196 @@
+#include <stdio.h>
+
+#include "TMath.h"
+
+#include "AliTRDltuParam.h"
+
+// definition of geometry constants
+Float_t AliTRDltuParam::fgZrow[6][5] = {
+  {301, 177, 53, -57, -181},
+  {301, 177, 53, -57, -181},
+  {315, 184, 53, -57, -188},
+  {329, 191, 53, -57, -195},
+  {343, 198, 53, -57, -202},
+  {347, 200, 53, -57, -204}};
+Float_t AliTRDltuParam::fgX[6] =
+  {300.65, 313.25, 325.85, 338.45, 351.05, 363.65};
+Float_t AliTRDltuParam::fgTiltingAngle[6] =
+  {-2., 2., -2., 2., -2., 2.};
+Int_t   AliTRDltuParam::fgDyMax =  63;
+Int_t   AliTRDltuParam::fgDyMin = -64;
+Float_t AliTRDltuParam::fgBinDy = 140e-6;
+Float_t AliTRDltuParam::fgWidthPad[6] =
+  {0.635, 0.665, 0.695, 0.725, 0.755, 0.785};
+Float_t AliTRDltuParam::fgLengthInnerPadC1[6] =
+  {7.5, 7.5, 8.0, 8.5, 9.0, 9.0};
+Float_t AliTRDltuParam::fgLengthOuterPadC1[6] =
+  {7.5, 7.5, 7.5, 7.5, 7.5, 8.5};
+Float_t AliTRDltuParam::fgLengthInnerPadC0 = 9.0;
+Float_t AliTRDltuParam::fgLengthOuterPadC0 = 8.0;
+Float_t AliTRDltuParam::fgScalePad = 256. * 32.;
+Float_t AliTRDltuParam::fgDriftLength = 3.e-2;
+
+AliTRDltuParam::AliTRDltuParam() :
+  TObject(),
+  fMagField(0.),
+  fOmegaTau(0.),
+  fPtMin(0.1),
+  fNtimebins(20 << 5),
+  fScaleQ0(1),
+  fScaleQ1(1),
+  fPidTracklengthCorr(kFALSE),
+  fTiltCorr(kFALSE)
+{
+
+}
+
+AliTRDltuParam::~AliTRDltuParam()
+{
+
+}
+
+Int_t AliTRDltuParam::GetDyCorrection(Int_t det, Int_t rob, Int_t mcm) const
+{
+  // calculate the correction of the deflection
+  // i.e. Lorentz angle and tilt correction (if active)
+
+  Int_t layer = det % 6;
+
+  Float_t dyTilt = ( fgDriftLength * TMath::Tan(fgTiltingAngle[layer]) *
+                    GetLocalZ(det, rob, mcm) / fgX[layer] );
+
+  // calculate Lorentz correction
+  Float_t dyCorr = - fOmegaTau * fgDriftLength;
+
+  if(fTiltCorr)
+    dyCorr += dyTilt; // add tilt correction
+
+  return (int) TMath::Nint(dyCorr * fgScalePad / fgWidthPad[layer]);
+}
+
+void AliTRDltuParam::GetDyRange(Int_t det, Int_t rob, Int_t mcm, Int_t ch,
+                                Int_t &dyMinInt, Int_t &dyMaxInt) const
+{
+  // calculate the deflection range in which tracklets are accepted
+
+  dyMinInt = fgDyMin;
+  dyMaxInt = fgDyMax;
+
+  if (fMagField < 0.1)
+    return;
+
+  Float_t e = 0.30;
+
+  Float_t maxDeflTemp = GetPerp(det, rob, mcm, ch)/2. *         // Sekante/2
+    (e * TMath::Abs(fMagField) / fPtMin);   // 1/R
+
+  Float_t maxDeflAngle = 0.;
+
+  if (maxDeflTemp < 1.) {
+    maxDeflAngle = TMath::ASin(maxDeflTemp);
+
+    Float_t dyMin = ( fgDriftLength *
+                     tan(GetPhi(det, rob, mcm, ch) - maxDeflAngle) );
+
+    dyMinInt = Int_t(dyMin / fgBinDy);
+    if (dyMinInt < fgDyMin)
+      dyMinInt = fgDyMin;
+
+    Float_t dyMax = ( fgDriftLength *
+                     TMath::Tan(GetPhi(det, rob, mcm, ch) + maxDeflAngle) );
+
+    dyMaxInt = Int_t(dyMax / fgBinDy);
+    if (dyMaxInt > fgDyMax)
+      dyMaxInt = fgDyMax;
+  }
+  if ((dyMaxInt - dyMinInt) <= 0) {
+    printf("strange dy range: [%i,%i]\n", dyMinInt, dyMaxInt);
+  }
+}
+
+Float_t AliTRDltuParam::GetElongation(Int_t det, Int_t rob, Int_t mcm, Int_t ch) const
+{
+  Int_t layer = det % 6;
+
+  Float_t elongation = TMath::Abs(GetDist(det, rob, mcm, ch) / fgX[layer]);
+
+  // sanity check
+  if(elongation<0.001) {
+    elongation=1.;
+  }
+  return elongation;
+}
+
+void AliTRDltuParam::GetCorrectionFactors(Int_t det, Int_t rob, Int_t mcm, Int_t ch,
+                                         UInt_t &cor0, UInt_t &cor1) const
+{
+  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)) ));
+  }
+  else {
+    cor0 = fScaleQ0;
+    cor1 = fScaleQ1;
+  }
+}
+
+Int_t AliTRDltuParam::GetNtimebins() const
+{
+  return fNtimebins;
+}
+
+Float_t AliTRDltuParam::GetX(Int_t det, Int_t /* rob */, Int_t /* mcm */) const
+{
+  Int_t layer = det%6;
+  return fgX[layer];
+}
+
+Float_t AliTRDltuParam::GetLocalY(Int_t det, Int_t rob, Int_t mcm, Int_t ch) const
+{
+  Int_t layer = det%6;
+  // calculate the pad position as in the TRAP
+  Float_t ypos = (-4 + (rob&0x1) * 4 + (mcm&0x3)) * 18 - ch - 0.5; // y position in bins of pad widths
+  return ypos*fgWidthPad[layer];
+}
+
+Float_t AliTRDltuParam::GetLocalZ(Int_t det, Int_t rob, Int_t mcm) const
+{
+  Int_t stack = (det%30) / 6;
+  Int_t layer = det % 6;
+  Int_t row   = (rob/2) * 4 + mcm/4;
+
+  if (stack == 2) {
+    if (row == 0)
+      return (fgZrow[layer][stack] - 0.5 * fgLengthOuterPadC0);
+    else if (row == 11)
+      return (fgZrow[layer][stack] - 1.5 * fgLengthOuterPadC0 - (row - 1) * fgLengthInnerPadC0);
+    else
+      return (fgZrow[layer][stack] - fgLengthOuterPadC0 - (row - 0.5) * fgLengthInnerPadC0);
+  }
+  else {
+    if (row == 0)
+      return (fgZrow[layer][stack] - 0.5 * fgLengthOuterPadC1[layer]);
+    else if (row == 15)
+      return (fgZrow[layer][stack] - 1.5 * fgLengthOuterPadC1[layer] - (row - 1) * fgLengthInnerPadC1[layer]);
+    else
+      return (fgZrow[layer][stack] - fgLengthOuterPadC1[layer] - (row - 0.5) * fgLengthInnerPadC1[layer]);
+  }
+}
+
+Float_t AliTRDltuParam::GetPerp(Int_t det, Int_t rob, Int_t mcm, Int_t ch) const
+{
+  return TMath::Sqrt(GetLocalY(det, rob, mcm, ch)*GetLocalY(det, rob, mcm, ch) +
+                    GetX(det, rob, mcm)*GetX(det, rob, mcm) );
+}
+
+Float_t AliTRDltuParam::GetPhi(Int_t det, Int_t rob, Int_t mcm, Int_t ch) const
+{
+  return TMath::ATan2(GetLocalY(det, rob, mcm, ch), GetX(det, rob, mcm));
+}
+
+Float_t AliTRDltuParam::GetDist(Int_t det, Int_t rob, Int_t mcm, Int_t ch) const
+{
+  return TMath::Sqrt(GetLocalY(det, rob, mcm, ch)*GetLocalY(det, rob, mcm, ch) +
+                    GetX(det, rob, mcm)*GetX(det, rob, mcm) +
+                    GetLocalZ(det, rob, mcm)*GetLocalZ(det, rob, mcm) );
+}
diff --git a/TRD/AliTRDltuParam.h b/TRD/AliTRDltuParam.h
new file mode 100644 (file)
index 0000000..13ba556
--- /dev/null
@@ -0,0 +1,82 @@
+// This class is used in both AliRoot and libTRD. If you update it in
+// one place you have to update also the other.
+
+#ifndef ALITRDLTUPARAM_H
+#define ALITRDLTUPARAM_H
+
+#include "TObject.h"
+
+class AliTRDltuParam : public TObject
+{
+ public:
+  AliTRDltuParam();
+  ~AliTRDltuParam();
+
+  // configuration settings
+  // called with special SCSN commands
+  void SetPtMin(Int_t data)     { fPtMin = Float_t(data) / 1000.; }
+  void SetMagField(Int_t data)  { fMagField = Float_t(data) / 1000.; }
+  void SetOmegaTau(Int_t data)  { fOmegaTau = Float_t(data) / 1.e6; }
+  void SetNtimebins(Int_t data) { fNtimebins = data; }
+  void SetScaleQ0(Int_t data)   { fScaleQ0 = data; }
+  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); }
+
+  // set values directly
+  void SetRawPtMin(Float_t data)     { fPtMin = data; }
+  void SetRawMagField(Float_t data)  { fMagField = data; }
+  void SetRawOmegaTau(Float_t data)  { fOmegaTau = data; }
+  void SetRawNtimebins(Int_t data)   { fNtimebins = data; }
+  void SetRawScaleQ0(Int_t data)     { fScaleQ0 = data; }
+  void SetRawScaleQ1(Int_t data)     { fScaleQ1 = data; }
+  void SetRawLengthCorrectionEnable(Bool_t data) { fPidTracklengthCorr = data; }
+  void SetRawTiltCorrectionEnable(Bool_t data)   { fTiltCorr = 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;
+  Int_t GetNtimebins() const;
+
+  Float_t GetX(Int_t det, Int_t rob, Int_t mcm) const;
+  Float_t GetLocalY(Int_t det, Int_t rob, Int_t mcm, Int_t ch) const;
+  Float_t GetLocalZ(Int_t det, Int_t rob, Int_t mcm) const;
+
+  Float_t GetDist(Int_t det, Int_t rob, Int_t mcm, Int_t ch) const;
+  Float_t GetElongation(Int_t det, Int_t rob, Int_t mcm, Int_t ) const;
+  Float_t GetPhi(Int_t det, Int_t rob, Int_t mcm, Int_t ch) const;
+  Float_t GetPerp(Int_t det, Int_t rob, Int_t mcm, Int_t ch) const;
+
+ protected:
+  // geometry constants
+  static Float_t fgZrow[6][5];             // z-position of pad row edge
+  static Float_t fgX[6];                   // x-position for all layers
+  static Float_t fgTiltingAngle[6];       // tilting angle for every layer
+  static Float_t fgWidthPad[6];            // pad width for all layers
+  static Float_t fgLengthInnerPadC0;       // inner pad length C0 chamber
+  static Float_t fgLengthOuterPadC0;       // outer pad length C0 chamber
+  static Float_t fgLengthInnerPadC1[6];    // inner pad length C1 chambers
+  static Float_t fgLengthOuterPadC1[6];    // outer pad length C1 chambers
+  static Float_t fgScalePad;              // scaling factor for pad width
+  static Float_t fgDriftLength;                   // length of the  parse gaintbl Krypton_2009-01 drift region
+  static Float_t fgBinDy;                 // bin in dy (140 um)
+  static Int_t   fgDyMax;                 // max dy for a tracklet (hard limit)
+  static Int_t   fgDyMin;                 // min dy for a tracklet (hard limit)
+
+  // settings
+  Float_t fMagField;           // magnetic field
+  Float_t fOmegaTau;           // omega tau, i.e. tan(Lorentz angle)
+  Float_t fPtMin;              // min. pt for deflection cut
+  Int_t   fNtimebins;          // drift time in units of timebins << 5n
+  UInt_t  fScaleQ0;            // scale factor for accumulated charge Q0
+  UInt_t  fScaleQ1;            // scale factor for accumulated charge Q1
+  Bool_t  fPidTracklengthCorr; // enable tracklet length correction
+  Bool_t  fTiltCorr;           // enable tilt correction
+
+  ClassDef(AliTRDltuParam, 1);
+};
+
+#endif
index 3619f5ddff0b6ffbaf31307c395612b9acafbba9..e26f6fcb011dd25b95299456103b1ce51fcb7fa3 100644 (file)
@@ -26,6 +26,7 @@
 #include "AliTRDgeometry.h"
 #include "AliTRDfeeParam.h"
 #include "AliTRDtrapConfig.h"
 #include "AliTRDgeometry.h"
 #include "AliTRDfeeParam.h"
 #include "AliTRDtrapConfig.h"
+#include "AliTRDtrapConfigHandler.h"
 
 #include <fstream>
 #include <iostream>
 
 #include <fstream>
 #include <iostream>
@@ -544,7 +545,8 @@ AliTRDtrapConfig* AliTRDtrapConfig::Instance()
 
   if (!fgInstance) {
     fgInstance = new AliTRDtrapConfig();
 
   if (!fgInstance) {
     fgInstance = new AliTRDtrapConfig();
-    fgInstance->LoadConfig();
+    AliTRDtrapConfigHandler cfgHandler;
+    cfgHandler.LoadConfig();
   }
 
   return fgInstance;
   }
 
   return fgInstance;
@@ -999,86 +1001,6 @@ UInt_t AliTRDtrapConfig::GetDmemUnsigned(Int_t addr, Int_t det, Int_t rob, Int_t
 }
 
 
 }
 
 
-Bool_t AliTRDtrapConfig::LoadConfig()
-{
-  // load a set of TRAP register values (configuration)
-  // here a default set is implemented for testing
-  // for a detailed description of the registers see the TRAP manual
-
-  // HC header configuration bits
-  SetTrapReg(kC15CPUA, 0x2102); // zs, deh
-
-  // no. of timebins
-  SetTrapReg(kC13CPUA, 24); 
-
-  // pedestal filter
-  SetTrapReg(kFPNP, 4*10);
-  SetTrapReg(kFPTC, 0);
-  SetTrapReg(kFPBY, 0); // bypassed!
-  
-  // gain filter
-  for (Int_t adc = 0; adc < 20; adc++) {
-    SetTrapReg(TrapReg_t(kFGA0+adc), 40);
-    SetTrapReg(TrapReg_t(kFGF0+adc), 15);
-  }
-  SetTrapReg(kFGTA, 20);
-  SetTrapReg(kFGTB, 2060);
-  SetTrapReg(kFGBY, 0);  // bypassed!
-
-  // tail cancellation
-  SetTrapReg(kFTAL, 267);
-  SetTrapReg(kFTLL, 356);
-  SetTrapReg(kFTLS, 387);
-  SetTrapReg(kFTBY, 0);
-
-  // tracklet calculation
-  SetTrapReg(kTPQS0, 5);
-  SetTrapReg(kTPQE0, 10);
-  SetTrapReg(kTPQS1, 11);
-  SetTrapReg(kTPQE1, 20);
-  SetTrapReg(kTPFS, 5);
-  SetTrapReg(kTPFE, 20);
-  SetTrapReg(kTPVBY, 0);
-  SetTrapReg(kTPVT, 10);
-  SetTrapReg(kTPHT, 150);
-  SetTrapReg(kTPFP, 40);
-  SetTrapReg(kTPCL, 1);
-  SetTrapReg(kTPCT, 10);
-
-  // ndrift (+ 5 binary digits)
-  SetDmem(0xc025, 20 << 5);
-  // deflection + tilt correction
-  SetDmem(0xc022, 0); 
-  // deflection range table
-  for (Int_t iTrklCh = 0; iTrklCh < 18; iTrklCh++) {
-    SetDmem(0xc030 + 2 * iTrklCh, -64); // min. deflection
-    SetDmem(0xc031 + 2 * iTrklCh,  63); // max. deflection
-  }
-  
-  // hit position LUT
-  const UShort_t lutPos[128] = {
-    0,  1,  1,  2,  2,  3,  3,  4,  4,  5,  5,  6,  6,  7,  7,  8,  8,  9,  9, 10, 10, 11, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15,
-    16, 16, 16, 17, 17, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 26, 26, 26, 26,
-    27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 27, 27, 27, 27, 26,
-    26, 26, 26, 25, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 18, 18, 17, 17, 16, 15, 14, 13, 12, 11, 10,  9,  8,  7,  7};
-  for (Int_t iCOG = 0; iCOG < 128; iCOG++)
-    SetTrapReg((TrapReg_t) (kTPL00 + iCOG), lutPos[iCOG]);
-
-  // event buffer
-  SetTrapReg(kEBSF, 1);  // 0: store filtered; 1: store unfiltered
-  // zs applied to data stored in event buffer (sel. by EBSF)
-  SetTrapReg(kEBIS, 15 << 2); // single indicator threshold (plus two digits)
-  SetTrapReg(kEBIT, 30 << 2); // sum indicator threshold (plus two digits)
-  SetTrapReg(kEBIL, 0xf0);   // lookup table
-  SetTrapReg(kEBIN, 0);      // neighbour sensitivity
-
-  // raw data
-  SetTrapReg(kNES, (0x0000 << 16) | 0x1000);
-
-  return kTRUE;
-}
-
-
 Bool_t AliTRDtrapConfig::ReadPackedConfig(Int_t hc, UInt_t *data, Int_t size) 
 {
   // Read the packed configuration from the passed memory block
 Bool_t AliTRDtrapConfig::ReadPackedConfig(Int_t hc, UInt_t *data, Int_t size) 
 {
   // Read the packed configuration from the passed memory block
index a70b457200be3cfb70aaad65a2f4f493718771f9..0e45edaac644d06da4d72bbf9c976f2c083d3a0a 100644 (file)
@@ -499,8 +499,6 @@ class AliTRDtrapConfig : public TObject
   void GetPIDscale(Double_t scale[2]) {scale[0] = fScaleQ0; scale[1]=fScaleQ1;}  // The two scaling factors are not available in the TRAP but needed by the DCS board
 
   // configuration handling
   void GetPIDscale(Double_t scale[2]) {scale[0] = fScaleQ0; scale[1]=fScaleQ1;}  // The two scaling factors are not available in the TRAP but needed by the DCS board
 
   // configuration handling
-  Bool_t LoadConfig();
-
   Bool_t ReadPackedConfig(Int_t det, UInt_t *data, Int_t size);
 
   Bool_t AddValues(UInt_t det, UInt_t cmd, UInt_t extali, Int_t addr, UInt_t data);
   Bool_t ReadPackedConfig(Int_t det, UInt_t *data, Int_t size);
 
   Bool_t AddValues(UInt_t det, UInt_t cmd, UInt_t extali, Int_t addr, UInt_t data);
index 9ee5918c14d42c5360b8fae101e2487d6b115a19..31d187bfa21533de1972c1317cf95becf594952c 100644 (file)
@@ -1,4 +1,3 @@
-
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
 //                                                                        //
 ////////////////////////////////////////////////////////////////////////////
 
 //                                                                        //
 ////////////////////////////////////////////////////////////////////////////
 
-
-
 #include "AliTRDtrapConfigHandler.h"
 
 #include <iostream>
 #include <iomanip>
 
 #include "AliTRDtrapConfigHandler.h"
 
 #include <iostream>
 #include <iomanip>
 
-#include "AliTRDpadPlane.h"
-#include "AliTRDtrapConfig.h"
-#include "AliTRDcalibDB.h"
-#include "AliTRDCommonParam.h"
 #include "AliLog.h"
 
 #include "AliLog.h"
 
-#include "AliTRDarrayDictionary.h"
-
-#include "AliMagF.h"
-#include "TGeoGlobalMagField.h"
-#include "AliMagWrapCheb.h"
+#include "AliTRDtrapConfig.h"
 #include "AliTRDgeometry.h"
 #include "AliTRDgeometry.h"
+#include "AliTRDcalibDB.h"
 
 #include "TMath.h"
 #include "TGeoMatrix.h"
 
 #include "TMath.h"
 #include "TGeoMatrix.h"
+#include "TGraph.h"
 
 using namespace std;
 
 ClassImp(AliTRDtrapConfigHandler)
 
 
 using namespace std;
 
 ClassImp(AliTRDtrapConfigHandler)
 
-
 AliTRDtrapConfigHandler::AliTRDtrapConfigHandler() :
 AliTRDtrapConfigHandler::AliTRDtrapConfigHandler() :
-     fGeo(NULL)
+     ltuParam()
      , fDet(0)
      , fDet(0)
-     , fBField(0)
-     , fOmegaTau(1)
-     , fPtMin(0)
-     , fNTimebins(0)
-     , fScaleQ0(1)
-     , fScaleQ1(1)
-     , fPidTracklengthCorr(kFALSE)
-     , fTiltCorr(kTRUE)
+     , fRestrictiveMask((0x3ffff << 11) | (0x1f << 6) | 0x3f)
 {
 {
-   fGeo = new AliTRDgeometry;
+
 }
 
 
 AliTRDtrapConfigHandler::~AliTRDtrapConfigHandler()
 {
 }
 
 
 AliTRDtrapConfigHandler::~AliTRDtrapConfigHandler()
 {
-   delete fGeo;
+
 }
 
 void AliTRDtrapConfigHandler::ResetMCMs()
 }
 
 void AliTRDtrapConfigHandler::ResetMCMs()
@@ -83,6 +66,121 @@ void AliTRDtrapConfigHandler::ResetMCMs()
 }
 
 
 }
 
 
+Int_t AliTRDtrapConfigHandler::LoadConfig()
+{
+  // load a default configuration which is suitable for simulation
+  // for a detailed description of the registers see the TRAP manual
+  // if you want to resimulate tracklets on real data use the appropriate config instead
+
+  AliTRDtrapConfig *cfg = AliTRDtrapConfig::Instance();
+
+  // HC header configuration bits
+  cfg->SetTrapReg(AliTRDtrapConfig::kC15CPUA, 0x2102); // zs, deh
+
+  // no. of timebins
+  cfg->SetTrapReg(AliTRDtrapConfig::kC13CPUA, 24);
+
+  // pedestal filter
+  cfg->SetTrapReg(AliTRDtrapConfig::kFPNP, 4*10);
+  cfg->SetTrapReg(AliTRDtrapConfig::kFPTC, 0);
+  cfg->SetTrapReg(AliTRDtrapConfig::kFPBY, 0); // bypassed!
+
+  // gain filter
+  for (Int_t adc = 0; adc < 20; adc++) {
+    cfg->SetTrapReg(AliTRDtrapConfig::TrapReg_t(AliTRDtrapConfig::kFGA0+adc), 40);
+    cfg->SetTrapReg(AliTRDtrapConfig::TrapReg_t(AliTRDtrapConfig::kFGF0+adc), 15);
+  }
+  cfg->SetTrapReg(AliTRDtrapConfig::kFGTA, 20);
+  cfg->SetTrapReg(AliTRDtrapConfig::kFGTB, 2060);
+  cfg->SetTrapReg(AliTRDtrapConfig::kFGBY, 0);  // bypassed!
+
+  // tail cancellation
+  cfg->SetTrapReg(AliTRDtrapConfig::kFTAL, 200);
+  cfg->SetTrapReg(AliTRDtrapConfig::kFTLL, 0);
+  cfg->SetTrapReg(AliTRDtrapConfig::kFTLS, 200);
+  cfg->SetTrapReg(AliTRDtrapConfig::kFTBY, 0);
+
+  // tracklet calculation
+  cfg->SetTrapReg(AliTRDtrapConfig::kTPQS0, 5);
+  cfg->SetTrapReg(AliTRDtrapConfig::kTPQE0, 10);
+  cfg->SetTrapReg(AliTRDtrapConfig::kTPQS1, 11);
+  cfg->SetTrapReg(AliTRDtrapConfig::kTPQE1, 20);
+  cfg->SetTrapReg(AliTRDtrapConfig::kTPFS, 5);
+  cfg->SetTrapReg(AliTRDtrapConfig::kTPFE, 20);
+  cfg->SetTrapReg(AliTRDtrapConfig::kTPVBY, 0);
+  cfg->SetTrapReg(AliTRDtrapConfig::kTPVT, 10);
+  cfg->SetTrapReg(AliTRDtrapConfig::kTPHT, 150);
+  cfg->SetTrapReg(AliTRDtrapConfig::kTPFP, 40);
+  cfg->SetTrapReg(AliTRDtrapConfig::kTPCL, 1);
+  cfg->SetTrapReg(AliTRDtrapConfig::kTPCT, 10);
+
+  // ndrift (+ 5 binary digits)
+  ltuParam.SetNtimebins(20 << 5);
+  ConfigureNTimebins();
+
+  // deflection + tilt correction
+  ltuParam.SetRawOmegaTau(0.16133);
+  ConfigureDyCorr();
+
+  // deflection range table
+  ltuParam.SetRawPtMin(0.1);
+  ConfigureDRange();
+
+  // hit position LUT
+  // reset values
+  const UShort_t lutPos[128] = {
+    0,  1,  1,  2,  2,  3,  3,  4,  4,  5,  5,  6,  6,  7,  7,  8,  8,  9,  9, 10, 10, 11, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15,
+    16, 16, 16, 17, 17, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 26, 26, 26, 26,
+    27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 27, 27, 27, 27, 26,
+    26, 26, 26, 25, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 18, 18, 17, 17, 16, 15, 14, 13, 12, 11, 10,  9,  8,  7,  7};
+  for (Int_t iCOG = 0; iCOG < 128; iCOG++)
+    cfg->SetTrapReg((AliTRDtrapConfig::TrapReg_t) (AliTRDtrapConfig::kTPL00 + iCOG), lutPos[iCOG]);
+
+  // now calculate it from PRF
+  AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
+
+  Double_t padResponse[3]; // pad response left, central, right
+  Double_t padResponseR[3]; // pad response left, central, right
+  Double_t padResponseL[3]; // pad response left, central, right
+
+  for (Int_t iBin = 0; iBin < 128; iBin++)
+    cfg->SetTrapReg((AliTRDtrapConfig::TrapReg_t) (AliTRDtrapConfig::kTPL00 + iBin), 0, 0, 0, 0);
+
+  for (Int_t iLayer = 0; iLayer < 6; iLayer++) {
+    TGraph gr(128);
+    for (Int_t iBin = 0; iBin < 256*0.5; iBin++) {
+      cal->PadResponse(1., iBin*1./256.,    iLayer, padResponse);
+      cal->PadResponse(1., iBin*1./256.-1., iLayer, padResponseR);
+      cal->PadResponse(1., iBin*1./256.+1., iLayer, padResponseL);
+      gr.SetPoint(iBin, (0.5 * (padResponseR[1] - padResponseL[1])/padResponse[1] * 256), iBin);
+    }
+    for (Int_t iBin = 0; iBin < 128; iBin++) {
+      Int_t corr = gr.Eval(iBin) - iBin;
+      if (corr < 0)
+        corr = 0;
+      else if (corr > 31)
+        corr = 31;
+      for (Int_t iStack = 0; iStack < 540/6; iStack++) {
+        cfg->SetTrapReg((AliTRDtrapConfig::TrapReg_t) (AliTRDtrapConfig::kTPL00 + iBin), corr, 6*iStack + iLayer);
+      }
+    }
+  }
+
+  // event buffer
+  cfg->SetTrapReg(AliTRDtrapConfig::kEBSF, 1);  // 0: store filtered; 1: store unfiltered
+
+  // zs applied to data stored in event buffer (sel. by EBSF)
+  cfg->SetTrapReg(AliTRDtrapConfig::kEBIS, 15 << 2); // single indicator threshold (plus two digits)
+  cfg->SetTrapReg(AliTRDtrapConfig::kEBIT, 30 << 2); // sum indicator threshold (plus two digits)
+  cfg->SetTrapReg(AliTRDtrapConfig::kEBIL, 0xf0);   // lookup table
+  cfg->SetTrapReg(AliTRDtrapConfig::kEBIN, 0);      // neighbour sensitivity
+
+  // raw data
+  cfg->SetTrapReg(AliTRDtrapConfig::kNES, (0x0000 << 16) | 0x1000);
+
+  return 0;
+}
+
 Int_t AliTRDtrapConfigHandler::LoadConfig(TString filename, Int_t det)
 {
    //
 Int_t AliTRDtrapConfigHandler::LoadConfig(TString filename, Int_t det)
 {
    //
@@ -113,6 +211,13 @@ Int_t AliTRDtrapConfigHandler::LoadConfig(TString filename, Int_t det)
    UInt_t cmd;
    Int_t extali, addr, data;
 
    UInt_t cmd;
    Int_t extali, addr, data;
 
+   // reset restrictive mask
+   fRestrictiveMask = (0x3ffff << 11) | (0x1f << 6) | 0x3f;
+   Int_t sec   = AliTRDgeometry::GetSector(fDet);
+   Int_t stack = AliTRDgeometry::GetStack(fDet);
+   Int_t layer = AliTRDgeometry::GetLayer(fDet);
+   UInt_t rocpos = (1 << (sec+11)) | (1 << (stack+6)) | (1 << layer);
+
    while(infile.good()) {
       cmd=999;
       extali=-1;
    while(infile.good()) {
       cmd=999;
       extali=-1;
@@ -122,8 +227,12 @@ Int_t AliTRDtrapConfigHandler::LoadConfig(TString filename, Int_t det)
       //      std::cout << "no: " << no << ", cmd " << cmd << ", extali " << extali << ", addr " << addr << ", data " << data <<  endl;
 
       if(cmd!=999 && extali!=-1 && addr != -1 && data!= -1 && extali!=-1) {
       //      std::cout << "no: " << no << ", cmd " << cmd << ", extali " << extali << ", addr " << addr << ", data " << data <<  endl;
 
       if(cmd!=999 && extali!=-1 && addr != -1 && data!= -1 && extali!=-1) {
-        if(cmd==fgkScsnCmdWrite)
+       if(cmd==fgkScsnCmdWrite) {
+         if ((fRestrictiveMask & rocpos) == rocpos)
            cfg->AddValues(det, cmd, extali, addr, data);
            cfg->AddValues(det, cmd, extali, addr, data);
+       }
+        else if(cmd == fgkScsnCmdRestr)
+          fRestrictiveMask = data;
         else if(cmd == fgkScsnLTUparam)
            ProcessLTUparam(extali, addr, data);
         else
         else if(cmd == fgkScsnLTUparam)
            ProcessLTUparam(extali, addr, data);
         else
@@ -154,7 +263,6 @@ Int_t AliTRDtrapConfigHandler::LoadConfig(TString filename, Int_t det)
 }
 
 
 }
 
 
-
 void AliTRDtrapConfigHandler::ProcessLTUparam(Int_t dest, Int_t addr, UInt_t data)
 {
    //
 void AliTRDtrapConfigHandler::ProcessLTUparam(Int_t dest, Int_t addr, UInt_t data)
 {
    //
@@ -174,15 +282,15 @@ void AliTRDtrapConfigHandler::ProcessLTUparam(Int_t dest, Int_t addr, UInt_t dat
    case 1: // set variables
       switch (addr) {
 
    case 1: // set variables
       switch (addr) {
 
-      case 0: fPtMin =  float(data) / 1000.; break; // pt_min in GeV/c (*1000)
-      case 1: fBField = float(data) / 1000. ; break; // B in T (*1000)
-      case 2: fOmegaTau = float(data) / 1.0E6  ; break; // omega*tau
-      case 3: fNTimebins = data; break;
+      case 0: ltuParam.SetPtMin(data); break; // pt_min in GeV/c (*1000)
+      case 1: ltuParam.SetMagField(data); break; // B in T (*1000)
+      case 2: ltuParam.SetOmegaTau(data); break; // omega*tau
+      case 3: ltuParam.SetNtimebins(data); break;
        // ntimbins: drift time (for 3 cm) in timebins (5 add. bin. digits)
        // ntimbins: drift time (for 3 cm) in timebins (5 add. bin. digits)
-      case 4: fScaleQ0 = data; break;
-      case 5: fScaleQ1 = data; break;
-      case 6: fPidTracklengthCorr = (bool) data; break;
-      case 7: fTiltCorr = (bool) data; break;
+      case 4: ltuParam.SetScaleQ0(data); break;
+      case 5: ltuParam.SetScaleQ1(data); break;
+      case 6: ltuParam.SetLengthCorrectionEnable(data); break;
+      case 7: ltuParam.SetTiltCorrectionEnable(data); break;
       }
       break;
 
       }
       break;
 
@@ -198,7 +306,7 @@ void AliTRDtrapConfigHandler::ConfigureNTimebins()
    //
    // Set timebins in the drift region
    //
    //
    // Set timebins in the drift region
    //
-   AliTRDtrapConfig::Instance()->AddValues(fDet, fgkScsnCmdWrite, 127, AliTRDtrapConfig::fgkDmemAddrNdrift, fNTimebins);
+  AliTRDtrapConfig::Instance()->AddValues(fDet, fgkScsnCmdWrite, 127, AliTRDtrapConfig::fgkDmemAddrNdrift, ltuParam.GetNtimebins());
 }
 
 
 }
 
 
@@ -211,41 +319,15 @@ void AliTRDtrapConfigHandler::ConfigureDyCorr()
    //  This correction is in units of padwidth / (256*32)
    //
 
    //  This correction is in units of padwidth / (256*32)
    //
 
-   Int_t nRobs;
-   if(fGeo->GetStack(fDet) == 2)
-      nRobs=6;
-   else
-      nRobs=8;
-
-   Double_t dyLorentz = - fOmegaTau * fGeo->CdrHght();    // CdrHght: Height of the drift region
-   Double_t globalPos[3];
-   Double_t tiltingAngle = fGeo->GetPadPlane(fDet)->GetTiltingAngle();
-   Double_t scalePad = 256. * 32.;
-   Int_t dyCorrInt=0;
-
-    for (Int_t r = 0; r < nRobs; r++) {
-       for (Int_t m = 0; m < 16; m++) {
-          if(GetPadPosNonRot(r, m, 9, globalPos)==0) {
-             double dyTilt = ( fGeo->CdrHght() *  TMath::Tan(tiltingAngle * TMath::DegToRad()) * globalPos[2]/globalPos[0]);
-
-             double dyCorr;
-             if(fTiltCorr==kTRUE)
-                dyCorr = dyLorentz + dyTilt;
-             else
-                dyCorr = dyTilt;
-
-
-             dyCorrInt =  TMath::Nint(dyCorr * scalePad /  fGeo->GetPadPlane(fDet)->GetWidthIPad());  // The correction is in units of 1/256 of the
-                                                                                                      // pad width, including 5 binary digits
-          }
-          else {
-             AliError("No transformation matrix available");
-             dyCorrInt=0;
-          }
-          Int_t dest =  1<<10 | r<<7 | m;
-          AliTRDtrapConfig::Instance()->AddValues(fDet, fgkScsnCmdWrite, dest, AliTRDtrapConfig::fgkDmemAddrDeflCorr, dyCorrInt);
-       }
+  Int_t nRobs = AliTRDgeometry::GetStack(fDet) == 2 ? 6 : 8;
+
+  for (Int_t r = 0; r < nRobs; r++) {
+    for (Int_t m = 0; m < 16; m++) {
+      Int_t dest =  1<<10 | r<<7 | m;
+      Int_t dyCorrInt = ltuParam.GetDyCorrection(fDet, r, m);
+      AliTRDtrapConfig::Instance()->AddValues(fDet, fgkScsnCmdWrite, dest, AliTRDtrapConfig::fgkDmemAddrDeflCorr, dyCorrInt);
     }
     }
+  }
 }
 
 
 }
 
 
@@ -261,72 +343,23 @@ void AliTRDtrapConfigHandler::ConfigureDRange()
    // deflection (-64..63) is used
    //
 
    // deflection (-64..63) is used
    //
 
-   static const int x=0;
-   static const int y=1;
-   static const Double_t dyBin = 140e-6;
-
-   Int_t dyMinInt=fgkDyMinCut;
-   Int_t dyMaxInt=fgkDyMaxCut;
-   Double_t mcmPos[3];
+  Int_t nRobs = AliTRDgeometry::GetStack(fDet) == 2 ? 6 : 8;
 
 
-   Int_t nRobs=-1;
-   if(fGeo->GetStack(fDet) == 2)
-      nRobs=6;
-   else
-      nRobs=8;
+  Int_t dyMinInt;
+  Int_t dyMaxInt;
 
    for (Int_t r = 0; r < nRobs; r++) {
       for (Int_t m = 0; m < 16; m++) {
         for (Int_t c = 0; c < 18; c++) {
 
 
    for (Int_t r = 0; r < nRobs; r++) {
       for (Int_t m = 0; m < 16; m++) {
         for (Int_t c = 0; c < 18; c++) {
 
-           if(fPtMin<0.1) {
-              dyMinInt=fgkDyMinCut;
-              dyMaxInt=fgkDyMaxCut;
-           }
-           else {
-              if(GetPadPosNonRot(r, m, c, mcmPos)==0) {
-                 Double_t radius = fPtMin/(0.3*fBField);
-
-                 double vertexPos[2] = {0,0};
-
-                 Double_t distanceX = (vertexPos[x]-mcmPos[x]) / 100.; // cm -> m
-                 Double_t distanceY = (vertexPos[y]-mcmPos[y]) / 100.; // cm -> m
-
-                 Double_t maxDeflTemp = (TMath::Sqrt( Square(distanceX) + Square(distanceY)) / 2) / radius;
-                 Double_t localPhi = TMath::ATan2(distanceY, distanceX);
-
-                 Double_t maxDeflAngle=0;
-                 if(maxDeflTemp < 1. ) {
-                    maxDeflAngle = TMath::ASin(maxDeflTemp);
-                    Double_t dyMin = fGeo->CdrHght()/100. * TMath::Tan(localPhi - maxDeflAngle);  // CdrHght: Height of the drift region in cm
-                    Double_t dyMax = fGeo->CdrHght()/100. * TMath::Tan(localPhi + maxDeflAngle);
-
-                    dyMinInt = Int_t (dyMin / dyBin);
-                    dyMaxInt = Int_t (dyMax / dyBin);
-
-                    if(dyMinInt < fgkDyMinCut)
-                       dyMinInt = fgkDyMinCut;
-                    if(dyMaxInt > fgkDyMaxCut)
-                       dyMaxInt = fgkDyMaxCut;
-                 }
-                 else {
-                    dyMinInt = fgkDyMinCut;
-                    dyMaxInt = fgkDyMaxCut;
-                 }
-
-//               cout << "maxdefl: " << maxDeflAngle << ", localPhi " << localPhi << endl;
-//               cout << "r " << r << ", m" << m << ", c " << c << ", min angle: " << localPhi-maxDeflAngle << ", max: " << localPhi+maxDeflAngle
-//                    << ", min int: " << dyMinInt << ", max int: " << dyMaxInt << endl;
-              }
-              else {
-                 AliError("No geometry model loaded\n");
-              }
-           }
-
-           Int_t dest =  1<<10 | r<<7 | m;
-           Int_t lutAddr = AliTRDtrapConfig::fgkDmemAddrDeflCutStart + 2*c;
-           AliTRDtrapConfig::Instance()->AddValues(fDet, fgkScsnCmdWrite, dest, lutAddr+0, dyMinInt);
-           AliTRDtrapConfig::Instance()->AddValues(fDet, fgkScsnCmdWrite, dest, lutAddr+1, dyMaxInt);
+          // cout << "maxdefl: " << maxDeflAngle << ", localPhi " << localPhi << endl;
+          // cout << "r " << r << ", m" << m << ", c " << c << ", min angle: " << localPhi-maxDeflAngle << ", max: " << localPhi+maxDeflAngle
+          //   << ", min int: " << dyMinInt << ", max int: " << dyMaxInt << endl;
+          Int_t dest =  1<<10 | r<<7 | m;
+          Int_t lutAddr = AliTRDtrapConfig::fgkDmemAddrDeflCutStart + 2*c;
+          ltuParam.GetDyRange(fDet, r, m, c, dyMinInt, dyMaxInt);
+          AliTRDtrapConfig::Instance()->AddValues(fDet, fgkScsnCmdWrite, dest, lutAddr+0, dyMinInt);
+          AliTRDtrapConfig::Instance()->AddValues(fDet, fgkScsnCmdWrite, dest, lutAddr+1, dyMaxInt);
         }
       }
    }
         }
       }
    }
@@ -338,7 +371,6 @@ void AliTRDtrapConfigHandler::PrintGeoTest()
    // Prints some information about the geometry. Only for debugging
    //
 
    // Prints some information about the geometry. Only for debugging
    //
 
-   Double_t mcmPos[3];
    int sm=0;
    //   for(int sm=0; sm<6; sm++) {
    for(int stack=0; stack<5; stack++) {
    int sm=0;
    //   for(int sm=0; sm<6; sm++) {
    for(int stack=0; stack<5; stack++) {
@@ -348,9 +380,10 @@ void AliTRDtrapConfigHandler::PrintGeoTest()
         for (Int_t r = 0; r < 6; r++) {
            for (Int_t m = 0; m < 16; m++) {
               for (Int_t c = 7; c < 8; c++) {
         for (Int_t r = 0; r < 6; r++) {
            for (Int_t m = 0; m < 16; m++) {
               for (Int_t c = 7; c < 8; c++) {
-                 GetPadPosNonRot(r, m, c, mcmPos);
-                 cout << stack << ";" << layer << ";" << r << ";" << m
-                      << ";" << mcmPos[0] << ";" << mcmPos[1] << ";" << mcmPos[2] << endl;
+                cout << stack << ";" << layer << ";" << r << ";" << m
+                     << ";" << ltuParam.GetX(fDet, r, m)
+                     << ";" << ltuParam.GetLocalY(fDet, r, m, c)
+                     << ";" << ltuParam.GetLocalZ(fDet, r, m) << endl;
               }
            }
         }
               }
            }
         }
@@ -360,7 +393,6 @@ void AliTRDtrapConfigHandler::PrintGeoTest()
 }
 
 
 }
 
 
-
 void AliTRDtrapConfigHandler::ConfigurePIDcorr()
 {
    //
 void AliTRDtrapConfigHandler::ConfigurePIDcorr()
 {
    //
@@ -374,127 +406,14 @@ void AliTRDtrapConfigHandler::ConfigurePIDcorr()
    UInt_t cor0;
    UInt_t cor1;
 
    UInt_t cor0;
    UInt_t cor1;
 
-   Double_t globalPos[3];
-
-   Int_t nRobs=-1;
-   if(fGeo->GetStack(fDet) == 2)
-      nRobs=6;
-   else
-      nRobs=8;
+   Int_t nRobs = AliTRDgeometry::GetStack(fDet) == 2 ? 6 : 8;
 
    for (Int_t r=0; r<nRobs; r++) {
       for(Int_t m=0; m<16; m++) {
 
    for (Int_t r=0; r<nRobs; r++) {
       for(Int_t m=0; m<16; m++) {
-
-        if(GetPadPosNonRot(r, m, 9, globalPos)==0) {
-           Double_t elongation = TMath::Abs(TMath::Sqrt(globalPos[0]*globalPos[0] + globalPos[1]*globalPos[1] + globalPos[2]*globalPos[2]) / globalPos[0]);
-
-           if(fPidTracklengthCorr==kFALSE) {
-              cor0 = fScaleQ0;
-              cor1 = fScaleQ1;
-           }
-           else {
-              cor0 = Int_t ((1.0*fScaleQ0* (1/elongation) ));
-              cor1 = Int_t ((1.0*fScaleQ1* (1/elongation) ));
-           }
-
-           Int_t dest =  1<<10 | r<<7 | m;
-           AliTRDtrapConfig::Instance()->AddValues(fDet, fgkScsnCmdWrite, dest, addrLUTcor0, cor0);
-           AliTRDtrapConfig::Instance()->AddValues(fDet, fgkScsnCmdWrite, dest, addrLUTcor1, cor1);
-        }
-        else {
-           AliError("No transformation matrix available");
-        }
-      }
-   }
-}
-
-
-
-Int_t AliTRDtrapConfigHandler::GetPadPosNonRot(Int_t rob, Int_t mcm, Int_t channel, Double_t trackCoor[3])
-{
-   //
-   // Calcutate the gobal coordinates for an mcm channel in the supermodule at position -0.5
-   //
-
-   Int_t stack = fGeo->GetStack(fDet);
-   Int_t layer = fGeo->GetLayer(fDet);
-
-   AliTRDpadPlane *plane = fGeo->GetPadPlane(layer, stack);
-   if(plane==NULL) {
-      AliError(Form("stack %i, layer %i, det %i", stack, layer, fDet));
-      return 1;
-   }
-
-   Double_t locYZ[2];
-   Double_t loc[3];
-
-   Double_t radialPos = fGeo->AnodePos()-0.83; //
-   //   Double_t radialPos = 300.65 + 12.60 * layer; // cm // taken from libTRD/geometry/geometry.cc, probably not the final value
-
-   GetLocalPadPos(plane, rob, mcm, channel, locYZ);
-
-   loc[0] = radialPos;
-   loc[1] = locYZ[0];
-   loc[2] = locYZ[1];
-
-   //transform from loc[3] - coordinates of the pad
-   // Go to tracking coordinates
-
-   TGeoHMatrix *fMatrix  = fGeo->GetClusterMatrix(fDet);
-   if(fMatrix==NULL) {
-      AliError(Form("stack %i, layer %i, det %i", stack, layer, fDet));
-      return 2;
-   }
-   fMatrix->LocalToMaster(loc, trackCoor);
-   return 0;
-}
-
-
-void AliTRDtrapConfigHandler::GetLocalPadPos(AliTRDpadPlane *plane, Int_t rob, Int_t mcm, Int_t channel, Double_t result[2])
-{
-   //
-   // calculate the local coordinates for an mcm channel
-   //
-
-   Double_t localY, localZ;
-
-    Int_t padCol;
-    if(rob%2 == 0) //side a
-       padCol  = (mcm % fgkMCMperROBCol) * fgkPadsPerMCM + channel;
-    else
-       padCol  = (mcm % fgkMCMperROBCol) * fgkPadsPerMCM + (plane->GetNcols()/2) + channel;
-
-    Int_t padRow = ((Int_t) floor(rob/2.0)) * fgkMCMperROBRow + ((Int_t) floor(mcm/4));
-
-    if(padCol<0 || padCol>= plane->GetNcols())
-       AliError(Form("Invalid pad col: %i\n", padCol));
-
-    if(padRow<0 || padRow>= plane->GetNrows())
-       AliError(Form("Invalid pad row: %i\n", padRow));
-
-    if(padCol+1 == plane->GetNcols()) // last pad
-       localY = plane->GetColPos(padCol) + (plane->GetColEnd()-plane->GetColPos(padCol))/2;
-    else
-       localY = plane->GetColPos(padCol) + (plane->GetColPos(padCol+1)-plane->GetColPos(padCol))/2;
-
-    if(padRow+1 == plane->GetNrows())
-       localZ = plane->GetRowPosROC(padRow) + (plane->GetRowEndROC() - plane->GetRowPosROC(padRow))/2;
-    else
-       localZ = plane->GetRowPosROC(padRow) + (plane->GetRowPosROC(padRow+1) - plane->GetRowPosROC(padRow))/2;
-
-    //    std::cout << "pad col " << padCol << ", pad row " << padRow << std::endl;
-    //    std::cout << "pos y (col) " << localY << ", pos z (row) " << localZ << std::endl;
-
-    result[0]=localY;
-    result[1]=localZ;
-}
-
-
-Double_t AliTRDtrapConfigHandler::Square(Double_t val)
-{
-   //
-   // calculate the square of the argument
-   //
-
-   return val*val;
+        Int_t dest =  1<<10 | r<<7 | m;
+        ltuParam.GetCorrectionFactors(fDet, r, m, 0, cor0, cor1);
+        AliTRDtrapConfig::Instance()->AddValues(fDet, fgkScsnCmdWrite, dest, addrLUTcor0, cor0);
+        AliTRDtrapConfig::Instance()->AddValues(fDet, fgkScsnCmdWrite, dest, addrLUTcor1, cor1);
+    }
+  }
 }
 }
index 77ebf4eaa693d12ce3ed2cd9130a42dd4015fcaf..e59e668b2d4e9e982d4c7f144e5f068c3d588306 100644 (file)
 
 
 #include <TObject.h>
 
 
 #include <TObject.h>
+#include "AliTRDltuParam.h"
 
 
-class AliTRDgeometry;
 class AliTRDtrapConfig;
 class AliTRDtrapConfig;
-class AliTRDpadPlane;
-
 
 class AliTRDtrapConfigHandler : public TObject {
  public:
 
 class AliTRDtrapConfigHandler : public TObject {
  public:
@@ -23,6 +21,7 @@ class AliTRDtrapConfigHandler : public TObject {
   virtual          ~AliTRDtrapConfigHandler();
 
   void ResetMCMs();                                           // Reset all trap registers and DMEM of the MCMs
   virtual          ~AliTRDtrapConfigHandler();
 
   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, Int_t det);              // load a TRAP configuration from a file
 
   void ProcessLTUparam(Int_t dest, Int_t addr, UInt_t data);  // Process the LTU parameters
   Int_t LoadConfig(TString filename, Int_t det);              // load a TRAP configuration from a file
 
   void ProcessLTUparam(Int_t dest, Int_t addr, UInt_t data);  // Process the LTU parameters
@@ -37,44 +36,26 @@ class AliTRDtrapConfigHandler : public TObject {
   void  ConfigureNTimebins();                                 // timebins in the drift region
   void  ConfigurePIDcorr();                                   // Calculate the mcm individual correction factors for the PID
 
   void  ConfigureNTimebins();                                 // timebins in the drift region
   void  ConfigurePIDcorr();                                   // Calculate the mcm individual correction factors for the PID
 
-  Int_t GetPadPosNonRot(Int_t rob, Int_t mcm, Int_t channel, Double_t trackCoor[3]);    // calcutate the gobal coordinates for an mcm channel in the supermodule at position -0.5
-  void GetLocalPadPos(AliTRDpadPlane *plane, Int_t rob, Int_t mcm, Int_t channel, Double_t result[2]); // calculate the local coordinates for an mcm channel
-
-  Double_t Square(Double_t val);  // returns the square of a given number
+  Double_t Square(Double_t val) { return val*val; };          // returns the square of a given number
 
   AliTRDtrapConfigHandler(const AliTRDtrapConfigHandler &h);             // not implemented
   AliTRDtrapConfigHandler &operator=(const AliTRDtrapConfigHandler &h);  // not implemented
 
 
   AliTRDtrapConfigHandler(const AliTRDtrapConfigHandler &h);             // not implemented
   AliTRDtrapConfigHandler &operator=(const AliTRDtrapConfigHandler &h);  // not implemented
 
-
-
   static const UInt_t fgkScsnCmdWrite=10;  // SCSN command for the write command
   static const UInt_t fgkScsnCmdWrite=10;  // SCSN command for the write command
+  static const UInt_t fgkScsnCmdRestr=18;  // SCSN command to restrict commands to specified chambers
   static const UInt_t fgkScsnLTUparam=27;  // extended SCSN command for the LTU configuration
 
   static const UInt_t fgkScsnLTUparam=27;  // extended SCSN command for the LTU configuration
 
-  static const Int_t fgkDyMaxCut = 63;     // Maximum value of the deflection cut
-  static const Int_t fgkDyMinCut = -64;    // Minimum value of the deflection cut
-
   static const Int_t fgkMCMperROBCol = 4;  // MCMs per ROB column
   static const Int_t fgkPadsPerMCM = 18;   // readout pads per MCM
   static const Int_t fgkMCMperROBRow = 4;  // MCMs per ROB row
 
   static const Int_t fgkMCMperROBCol = 4;  // MCMs per ROB column
   static const Int_t fgkPadsPerMCM = 18;   // readout pads per MCM
   static const Int_t fgkMCMperROBRow = 4;  // MCMs per ROB row
 
+  AliTRDltuParam     ltuParam;             // ltuParam class for the actual calculation of the parameters
 
 
-  AliTRDgeometry *fGeo;                    // Pointer to the AliTRDgeometry class
-
-  Int_t fDet;   // detector number (0 - 539)
-
-  Double_t fBField;                        // value of the L3 magnet field
-  Double_t fOmegaTau;                      // ometa tau
-  Double_t fPtMin;                         // lower p_t threshold for the tracks which should pass the deflection cut
-  Int_t fNTimebins;                        // Number of time bins in the drift region (only relevant for GTU)
-  UInt_t fScaleQ0;                         // scale parameter to map the accumulated charge in the first time window to a memory address
-  UInt_t fScaleQ1;                         // scale parameter to map the accumulated charge in the second time window to a memory address
-  Bool_t fPidTracklengthCorr;              // Factor to correct the accumulated charge for track length effects
-  Bool_t fTiltCorr;                        // tilting correction
+  Int_t fDet;                              // detector number (0 - 539)
 
 
+  UInt_t fRestrictiveMask;                 // mask to restrict subsequent commands to specified chambers
 
   ClassDef(AliTRDtrapConfigHandler,0)
 };
 
 
   ClassDef(AliTRDtrapConfigHandler,0)
 };
 
-
 #endif
 #endif
-
index 6a37187f2dab08620b42bce11bcc2edb4764c8c0..1fb90073a8ddbd2a5c21304f3dc94cc02212db1c 100644 (file)
@@ -25,7 +25,7 @@
 # SHLIBS - Shared Libraries and objects for linking (Executables only)           #
 #--------------------------------------------------------------------------------#
 
 # SHLIBS - Shared Libraries and objects for linking (Executables only)           #
 #--------------------------------------------------------------------------------#
 
-set ( SRCS  AliTRDarraySignal.cxx AliTRDarrayDictionary.cxx AliTRDarrayADC.cxx AliTRDSignalIndex.cxx AliTRDgeometry.cxx AliTRDdigit.cxx AliTRDdigitsManager.cxx AliTRDdigitsParam.cxx AliTRDrawData.cxx AliTRDpadPlane.cxx AliTRDrawStream.cxx AliTRDCommonParam.cxx AliTRDfeeParam.cxx AliTRDgtuParam.cxx AliTRDcalibDB.cxx Cal/AliTRDCalROC.cxx Cal/AliTRDCalPad.cxx Cal/AliTRDCalDet.cxx Cal/AliTRDCalDCS.cxx Cal/AliTRDCalDCSFEE.cxx Cal/AliTRDCalDCSv2.cxx Cal/AliTRDCalDCSFEEv2.cxx Cal/AliTRDCalDCSPTR.cxx Cal/AliTRDCalDCSGTUBoardInfo.cxx Cal/AliTRDCalDCSGTUCtpOpc.cxx Cal/AliTRDCalDCSGTUSegment.cxx Cal/AliTRDCalDCSGTUTgu.cxx Cal/AliTRDCalDCSGTUTmu.cxx Cal/AliTRDCalDCSGTU.cxx Cal/AliTRDCalMonitoring.cxx Cal/AliTRDCalChamberStatus.cxx Cal/AliTRDCalPadStatus.cxx Cal/AliTRDCalSingleChamberStatus.cxx Cal/AliTRDCalPID.cxx AliTRDCalibraFit.cxx AliTRDCalibraMode.cxx AliTRDCalibraVector.cxx AliTRDCalibraVdriftLinearFit.cxx AliTRDCalibPadStatus.cxx AliTRDCalibChamberStatus.cxx AliTRDCalibViewer.cxx AliTRDCalibViewerGUI.cxx AliTRDEntriesInfo.cxx AliTRDPhInfo.cxx AliTRDPrfInfo.cxx AliTRDUshortInfo.cxx AliTRDQAChecker.cxx AliTRDPreprocessor.cxx AliTRDSaxHandler.cxx AliTRDDataDCS.cxx AliTRDSensor.cxx AliTRDSensorArray.cxx AliTRDalignment.cxx AliTRDtrapConfig.cxx AliTRDmcmSim.cxx AliTRDtrapConfigHandler.cxx AliTRDtrackGTU.cxx AliTRDtrackletBase.cxx AliTRDtrackletGTU.cxx AliTRDtrackletMCM.cxx AliTRDtrackletWord.cxx AliTRDgtuSim.cxx AliTRDgtuTMU.cxx AliTRDhit.cxx AliTRDrecoParam.cxx AliTRDSimParam.cxx)
+set ( SRCS  AliTRDarraySignal.cxx AliTRDarrayDictionary.cxx AliTRDarrayADC.cxx AliTRDSignalIndex.cxx AliTRDgeometry.cxx AliTRDdigit.cxx AliTRDdigitsManager.cxx AliTRDdigitsParam.cxx AliTRDrawData.cxx AliTRDpadPlane.cxx AliTRDrawStream.cxx AliTRDCommonParam.cxx AliTRDfeeParam.cxx AliTRDgtuParam.cxx AliTRDcalibDB.cxx Cal/AliTRDCalROC.cxx Cal/AliTRDCalPad.cxx Cal/AliTRDCalDet.cxx Cal/AliTRDCalDCS.cxx Cal/AliTRDCalDCSFEE.cxx Cal/AliTRDCalDCSv2.cxx Cal/AliTRDCalDCSFEEv2.cxx Cal/AliTRDCalDCSPTR.cxx Cal/AliTRDCalDCSGTUBoardInfo.cxx Cal/AliTRDCalDCSGTUCtpOpc.cxx Cal/AliTRDCalDCSGTUSegment.cxx Cal/AliTRDCalDCSGTUTgu.cxx Cal/AliTRDCalDCSGTUTmu.cxx Cal/AliTRDCalDCSGTU.cxx Cal/AliTRDCalMonitoring.cxx Cal/AliTRDCalChamberStatus.cxx Cal/AliTRDCalPadStatus.cxx Cal/AliTRDCalSingleChamberStatus.cxx Cal/AliTRDCalPID.cxx AliTRDCalibraFit.cxx AliTRDCalibraMode.cxx AliTRDCalibraVector.cxx AliTRDCalibraVdriftLinearFit.cxx AliTRDCalibPadStatus.cxx AliTRDCalibChamberStatus.cxx AliTRDCalibViewer.cxx AliTRDCalibViewerGUI.cxx AliTRDEntriesInfo.cxx AliTRDPhInfo.cxx AliTRDPrfInfo.cxx AliTRDUshortInfo.cxx AliTRDQAChecker.cxx AliTRDPreprocessor.cxx AliTRDSaxHandler.cxx AliTRDDataDCS.cxx AliTRDSensor.cxx AliTRDSensorArray.cxx AliTRDalignment.cxx AliTRDtrapConfig.cxx AliTRDmcmSim.cxx AliTRDltuParam.cxx AliTRDtrapConfigHandler.cxx AliTRDtrackGTU.cxx AliTRDtrackletBase.cxx AliTRDtrackletGTU.cxx AliTRDtrackletMCM.cxx AliTRDtrackletWord.cxx AliTRDgtuSim.cxx AliTRDgtuTMU.cxx AliTRDhit.cxx AliTRDrecoParam.cxx AliTRDSimParam.cxx)
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
 
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
 
index 0bbe787406f8bc97f3b3e8c8c48642e21f9dae7f..0c0d046c3357e3f27554bceb9ced8d4ea8d1ccec 100644 (file)
@@ -84,6 +84,7 @@
 
 #pragma link C++ class  AliTRDmcmSim+;
 #pragma link C++ class  AliTRDtrapConfigHandler+;
 
 #pragma link C++ class  AliTRDmcmSim+;
 #pragma link C++ class  AliTRDtrapConfigHandler+;
+#pragma link C++ class  AliTRDltuParam+;
 #pragma link C++ class  AliTRDtrapConfig+;
 #pragma link C++ class  AliTRDtrackletBase+;
 #pragma link C++ class  AliTRDtrackletGTU+;
 #pragma link C++ class  AliTRDtrapConfig+;
 #pragma link C++ class  AliTRDtrackletBase+;
 #pragma link C++ class  AliTRDtrackletGTU+;