+ if (!fTrapConfig) {
+ AliError("No TRAPconfig given");
+ return;
+ }
+
+ fTrapConfig->ResetRegs();
+ fTrapConfig->ResetDmem();
+}
+
+
+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
+
+ if (!fTrapConfig) {
+ AliError("No TRAPconfig given");
+ return -1;
+ }
+
+ // prepare ltuParam
+ // ndrift (+ 5 binary digits)
+ ltuParam.SetNtimebins(20 << 5);
+ // deflection + tilt correction
+ ltuParam.SetRawOmegaTau(0.16133);
+ // deflection range table
+ ltuParam.SetRawPtMin(0.1);
+ // magnetic field
+ ltuParam.SetRawMagField(0.0);
+ // scaling factors for q0, q1
+ ltuParam.SetRawScaleQ0(0);
+ ltuParam.SetRawScaleQ1(0);
+ // disable length correction and tilting correction
+ ltuParam.SetRawLengthCorrectionEnable(kFALSE);
+ ltuParam.SetRawTiltCorrectionEnable(kFALSE);
+
+ for (Int_t iDet = 0; iDet < 540; iDet++) {
+ // HC header configuration bits
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kC15CPUA, 0x2102, iDet); // zs, deh
+
+ // no. of timebins
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kC13CPUA, 24, iDet);
+
+ // pedestal filter
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kFPNP, 4*10, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kFPTC, 0, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kFPBY, 0, iDet); // bypassed!
+
+ // gain filter
+ for (Int_t adc = 0; adc < 20; adc++) {
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::TrapReg_t(AliTRDtrapConfig::kFGA0+adc), 40, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::TrapReg_t(AliTRDtrapConfig::kFGF0+adc), 15, iDet);
+ }
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kFGTA, 20, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kFGTB, 2060, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kFGBY, 0, iDet); // bypassed!
+
+ // tail cancellation
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kFTAL, 200, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kFTLL, 0, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kFTLS, 200, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kFTBY, 0, iDet);
+
+ // tracklet calculation
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kTPQS0, 5, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kTPQE0, 10, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kTPQS1, 11, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kTPQE1, 20, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kTPFS, 5, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kTPFE, 20, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kTPVBY, 0, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kTPVT, 10, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kTPHT, 150, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kTPFP, 40, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kTPCL, 1, iDet);
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kTPCT, 10, iDet);
+
+ // apply ltuParams
+ ConfigureDyCorr(iDet);
+ ConfigureDRange(iDet); // deflection range
+ ConfigureNTimebins(iDet); // timebins in the drift region
+ ConfigurePIDcorr(iDet); // scaling parameters for the PID
+
+ // event buffer
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kEBSF, 1, iDet); // 0: store filtered; 1: store unfiltered
+
+ // zs applied to data stored in event buffer (sel. by EBSF)
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kEBIS, 15, iDet); // single indicator threshold (plus two digits)
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kEBIT, 30, iDet); // sum indicator threshold (plus two digits)
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kEBIL, 0xf0, iDet); // lookup table
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kEBIN, 0, iDet); // neighbour sensitivity
+
+ // raw data
+ fTrapConfig->SetTrapReg(AliTRDtrapConfig::kNES, (0x0000 << 16) | 0x1000, iDet);
+ }
+
+ // ****** hit position LUT
+
+ // 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 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 = (Int_t) (gr.Eval(iBin)) - iBin;
+ if (corr < 0)
+ corr = 0;
+ else if (corr > 31)
+ corr = 31;
+ for (Int_t iStack = 0; iStack < 540/6; iStack++) {
+ fTrapConfig->SetTrapReg((AliTRDtrapConfig::TrapReg_t) (AliTRDtrapConfig::kTPL00 + iBin), corr, 6*iStack + iLayer);
+ }
+ }
+ }
+ // ****** hit position LUT configuration end
+
+ return 0;