]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDSimParam.cxx
Add a protection againts runs with missing DCS information in the OCDB
[u/mrichter/AliRoot.git] / TRD / AliTRDSimParam.cxx
index 18ed40fe57b1bd652c125f789015ce1d838455e6..f19617bdac8105a4062769aa5ced5a4196d2fca1 100644 (file)
@@ -29,6 +29,8 @@
 #include "AliRun.h"
 
 #include "AliTRDSimParam.h"
+#include "AliTRDCommonParam.h"
+#include "AliLog.h"
 
 ClassImp(AliTRDSimParam)
 
@@ -94,12 +96,12 @@ AliTRDSimParam::AliTRDSimParam()
   ,fTRFwid(0.0)
   ,fCTOn(kFALSE)
   ,fCTsmp(0)
-  ,fAnodeWireOffset(0.0)
   ,fPadCoupling(0.0)
   ,fTimeCoupling(0.0)
   ,fTimeStructOn(kFALSE)
   ,fPRFOn(kFALSE)
-  ,fGasMixture(0)
+  ,fNTimeBins(0)
+  ,fNTBoverwriteOCDB(kFALSE)
 {
   //
   // Default constructor
@@ -122,9 +124,7 @@ void AliTRDSimParam::Init()
   fNoise             = 1250.0;
   fADCoutRange       = 1023.0;          // 10-bit ADC
   fADCinRange        = 2000.0;          // 2V input range
-  // Go back to 0 again, just to be consistent with reconstruction
-  fADCbaseline       =      0;
-  //fADCbaseline       =   10;
+  fADCbaseline       =   10;
 
   // Diffusion on
   fDiffusionOn       = kTRUE;
@@ -147,17 +147,15 @@ void AliTRDSimParam::Init()
   // The time coupling factor (same number as for the TPC)
   fTimeCoupling      = 0.4;
 
-  // Distance of first Anode wire from first pad edge
-  fAnodeWireOffset   = 0.25;
-
   // Use drift time maps
   fTimeStructOn      = kTRUE;
   
   // The pad response function
   fPRFOn             = kTRUE;
 
-  // The gas mixture, default Xenon
-  fGasMixture        = kXenon;
+  // The number of time bins
+  fNTimeBins         = 24;
+  fNTBoverwriteOCDB  = kFALSE;
 
   ReInit();
 
@@ -202,12 +200,12 @@ AliTRDSimParam::AliTRDSimParam(const AliTRDSimParam &p)
   ,fTRFwid(p.fTRFwid)
   ,fCTOn(p.fCTOn)
   ,fCTsmp(0)
-  ,fAnodeWireOffset(p.fAnodeWireOffset)
   ,fPadCoupling(p.fPadCoupling)
   ,fTimeCoupling(p.fTimeCoupling)
   ,fTimeStructOn(p.fTimeStructOn)
   ,fPRFOn(p.fPRFOn)
-  ,fGasMixture(p.fGasMixture)
+  ,fNTimeBins(p.fNTimeBins)
+  ,fNTBoverwriteOCDB(p.fNTBoverwriteOCDB)
 {
   //
   // Copy constructor
@@ -215,20 +213,14 @@ AliTRDSimParam::AliTRDSimParam(const AliTRDSimParam &p)
 
   Int_t iBin = 0;
 
-  if (((AliTRDSimParam &) p).fTRFsmp) {
-    delete [] ((AliTRDSimParam &) p).fTRFsmp;
-  }
-  ((AliTRDSimParam &) p).fTRFsmp = new Float_t[fTRFbin];
+  fTRFsmp = new Float_t[fTRFbin];
   for (iBin = 0; iBin < fTRFbin; iBin++) {
-    ((AliTRDSimParam &) p).fTRFsmp[iBin] = fTRFsmp[iBin];
+    fTRFsmp[iBin] = ((AliTRDSimParam &) p).fTRFsmp[iBin];
   }                                                                             
 
-  if (((AliTRDSimParam &) p).fCTsmp) {
-    delete [] ((AliTRDSimParam &) p).fCTsmp;
-  }
-  ((AliTRDSimParam &) p).fCTsmp  = new Float_t[fTRFbin];
+  fCTsmp  = new Float_t[fTRFbin];
   for (iBin = 0; iBin < fTRFbin; iBin++) {
-    ((AliTRDSimParam &) p).fCTsmp[iBin] = fCTsmp[iBin];
+    fCTsmp[iBin]  = ((AliTRDSimParam &) p).fCTsmp[iBin];
   }                                                                             
 
 }
@@ -240,9 +232,53 @@ AliTRDSimParam &AliTRDSimParam::operator=(const AliTRDSimParam &p)
   // Assignment operator
   //
 
-  if (this != &p) {
-    ((AliTRDSimParam &) p).Copy(*this);
+  if (this == &p) {
+    return *this;
+  }
+
+  Init();
+
+  fGasGain          = p.fGasGain;
+  fNoise            = p.fNoise;
+  fChipGain         = p.fChipGain;
+  fADCoutRange      = p.fADCoutRange;
+  fADCinRange       = p.fADCinRange;
+  fADCbaseline      = p.fADCbaseline;
+  fDiffusionOn      = p.fDiffusionOn;
+  fElAttachOn       = p.fElAttachOn;
+  fElAttachProp     = p.fElAttachProp;
+  fTRFOn            = p.fTRFOn;
+  fTRFsmp           = 0;
+  fTRFbin           = p.fTRFbin;
+  fTRFlo            = p.fTRFlo;
+  fTRFhi            = p.fTRFhi;
+  fTRFwid           = p.fTRFwid;
+  fCTOn             = p.fCTOn;
+  fCTsmp            = 0;
+  fPadCoupling      = p.fPadCoupling;
+  fTimeCoupling     = p.fTimeCoupling;
+  fTimeStructOn     = p.fTimeStructOn;
+  fPRFOn            = p.fPRFOn;
+  fNTimeBins        = p.fNTimeBins;
+  fNTBoverwriteOCDB = p.fNTBoverwriteOCDB;
+
+  Int_t iBin = 0;
+
+  if (fTRFsmp) {
+    delete[] fTRFsmp;
   }
+  fTRFsmp = new Float_t[fTRFbin];
+  for (iBin = 0; iBin < fTRFbin; iBin++) {
+    fTRFsmp[iBin] = ((AliTRDSimParam &) p).fTRFsmp[iBin];
+  }                                                                             
+
+  if (fCTsmp) {
+    delete[] fCTsmp;
+  }
+  fCTsmp  = new Float_t[fTRFbin];
+  for (iBin = 0; iBin < fTRFbin; iBin++) {
+    fCTsmp[iBin]  = ((AliTRDSimParam &) p).fCTsmp[iBin];
+  }                                                                             
 
   return *this;
 
@@ -275,11 +311,11 @@ void AliTRDSimParam::Copy(TObject &p) const
   target->fTRFhi              = fTRFhi;
   target->fTRFwid             = fTRFwid;
   target->fCTOn               = fCTOn;
-  target->fAnodeWireOffset    = fAnodeWireOffset;
   target->fPadCoupling        = fPadCoupling;
   target->fTimeCoupling       = fTimeCoupling;
   target->fPRFOn              = fPRFOn;
-  target->fGasMixture         = fGasMixture;
+  target->fNTimeBins          = fNTimeBins;
+  target->fNTBoverwriteOCDB   = fNTBoverwriteOCDB;
 
   if (target->fTRFsmp) {
     delete[] target->fTRFsmp;
@@ -306,21 +342,25 @@ void AliTRDSimParam::ReInit()
   // Reinitializes the parameter class after a change
   //
 
-  if      (fGasMixture == kXenon) {
+  if      (AliTRDCommonParam::Instance()->IsXenon()) {
     // The range and the binwidth for the sampled TRF 
     fTRFbin = 200;
     // Start 0.2 mus before the signal
     fTRFlo  = -0.4;
     // End the maximum drift time after the signal 
     fTRFhi  =  3.58;
+    // Standard gas gain
+    fGasGain = 4000.0;
   }
-  else if (fGasMixture == kArgon) {
+  else if (AliTRDCommonParam::Instance()->IsArgon()) {
     // The range and the binwidth for the sampled TRF 
-    fTRFbin =  50;
+    fTRFbin  =  50;
     // Start 0.2 mus before the signal
-    fTRFlo  =  0.02;
+    fTRFlo   =  0.02;
     // End the maximum drift time after the signal 
-    fTRFhi  =  1.98;
+    fTRFhi   =  1.98;
+    // Higher gas gain
+    fGasGain = 8000.0;
   }
   else {
     AliFatal("Not a valid gas mixture!");
@@ -427,12 +467,23 @@ void AliTRDSimParam::SampleTRF()
   }
   fCTsmp  = new Float_t[fTRFbin];
 
+  if      (AliTRDCommonParam::Instance()->IsXenon()) {
+    if (fTRFbin != kNpasa) {
+      AliError("Array mismatch (xenon)\n\n");
+    }
+  }
+  else if (AliTRDCommonParam::Instance()->IsArgon()) {
+    if (fTRFbin != kNpasaAr) {
+      AliError("Array mismatch (argon)\n\n");
+    }
+  }
+
   for (Int_t iBin = 0; iBin < fTRFbin; iBin++) {
-    if (fGasMixture == kXenon) {
+    if      (AliTRDCommonParam::Instance()->IsXenon()) {
       fTRFsmp[iBin] = signal[iBin];
       fCTsmp[iBin]  = xtalk[iBin];
     }
-    else {
+    else if (AliTRDCommonParam::Instance()->IsArgon()) {
       fTRFsmp[iBin] = signalAr[iBin];
       fCTsmp[iBin]  = xtalkAr[iBin];
     }
@@ -448,14 +499,15 @@ Double_t AliTRDSimParam::TimeResponse(Double_t time) const
   // (We assume a signal rise time of 0.2us = fTRFlo/2.
   //
 
-  Int_t iBin = ((Int_t) ((time - fTRFlo/2.0) / fTRFwid)); 
-  if ((iBin >=       0) && 
-      (iBin <  fTRFbin)) {
-    return fTRFsmp[iBin];
-  }
+  Double_t rt   = (time - .5*fTRFlo) / fTRFwid;
+  Int_t    iBin = (Int_t) rt; 
+  Double_t dt   = rt - iBin; 
+  if ((iBin >= 0) && (iBin+1 < fTRFbin)) {
+    return fTRFsmp[iBin] + (fTRFsmp[iBin+1] - fTRFsmp[iBin])*dt;
+  } 
   else {
     return 0.0;
-  }    
+  }
 
 }
 
@@ -466,13 +518,14 @@ Double_t AliTRDSimParam::CrossTalk(Double_t time) const
   // Applies the pad-pad capacitive cross talk
   //
 
-  Int_t iBin = ((Int_t) ((time - fTRFlo) / fTRFwid)); 
-  if ((iBin >=       0) && 
-      (iBin <  fTRFbin)) {
-    return fCTsmp[iBin];
-  }
+  Double_t rt   = (time - fTRFlo) / fTRFwid;
+  Int_t    iBin = (Int_t) rt; 
+  Double_t dt   = rt - iBin; 
+  if ((iBin >= 0) && (iBin+1 < fTRFbin)) {
+    return fCTsmp[iBin] + (fCTsmp[iBin+1] - fCTsmp[iBin])*dt;
+  } 
   else {
     return 0.0;
-  }    
+  }
 
 }