Always take the number of time bins from OCDB, unless explicitly overwritten
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 May 2011 13:40:05 +0000 (13:40 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 May 2011 13:40:05 +0000 (13:40 +0000)
TRD/AliTRDSimParam.cxx
TRD/AliTRDSimParam.h
TRD/AliTRDdigitizer.cxx

index 9832e02..3a6ae64 100644 (file)
@@ -101,6 +101,7 @@ AliTRDSimParam::AliTRDSimParam()
   ,fTimeStructOn(kFALSE)
   ,fPRFOn(kFALSE)
   ,fNTimeBins(0)
+  ,fNTBoverwriteOCDB(kFALSE)
 {
   //
   // Default constructor
@@ -153,7 +154,8 @@ void AliTRDSimParam::Init()
   fPRFOn             = kTRUE;
 
   // The number of time bins
-  fNTimeBins         = 30;
+  fNTimeBins         = 27;
+  fNTBoverwriteOCDB  = kFALSE;
 
   ReInit();
 
@@ -203,6 +205,7 @@ AliTRDSimParam::AliTRDSimParam(const AliTRDSimParam &p)
   ,fTimeStructOn(p.fTimeStructOn)
   ,fPRFOn(p.fPRFOn)
   ,fNTimeBins(p.fNTimeBins)
+  ,fNTBoverwriteOCDB(p.fNTBoverwriteOCDB)
 {
   //
   // Copy constructor
@@ -268,6 +271,7 @@ void AliTRDSimParam::Copy(TObject &p) const
   target->fTimeCoupling       = fTimeCoupling;
   target->fPRFOn              = fPRFOn;
   target->fNTimeBins          = fNTimeBins;
+  target->fNTBoverwriteOCDB   = fNTBoverwriteOCDB;
 
   if (target->fTRFsmp) {
     delete[] target->fTRFsmp;
index d99ece5..60f5968 100644 (file)
@@ -46,7 +46,8 @@ class AliTRDSimParam : public TObject {
           void     SetTimeStruct(Bool_t tsOn = 1)            { fTimeStructOn      = tsOn;             }
           void     SetPadResponse(Int_t prfOn = 1)           { fPRFOn             = prfOn;            }
           void     SetNTimeBins(Int_t ntb)                   { fNTimeBins         = ntb;              }
-    
+          void     SetNTBoverwriteOCDB(Bool_t over = kTRUE)  { fNTBoverwriteOCDB  = over;             }
+
           Float_t  GetGasGain() const                        { return fGasGain;                       }
           Float_t  GetNoise() const                          { return fNoise;                         }
           Float_t  GetChipGain() const                       { return fChipGain;                      }
@@ -58,6 +59,7 @@ class AliTRDSimParam : public TObject {
           Float_t  GetPadCoupling() const                    { return fPadCoupling;                   }
           Float_t  GetTimeCoupling() const                   { return fTimeCoupling;                  }
           Int_t    GetNTimeBins() const                      { return fNTimeBins;                     }
+          Bool_t   GetNTBoverwriteOCDB() const               { return fNTBoverwriteOCDB;              }
 
           Bool_t   DiffusionOn() const                       { return fDiffusionOn;                   }
           Bool_t   ElAttachOn() const                        { return fElAttachOn;                    } 
@@ -75,7 +77,7 @@ class AliTRDSimParam : public TObject {
  protected:
 
   static AliTRDSimParam* fgInstance;   //  Instance of this class (singleton implementation)
-  static  Bool_t   fgTerminated;       //  Defines if this class has already been terminated and
+  static Bool_t          fgTerminated; //  Defines if this class has already been terminated and
                                        //  therefore does not return instances in GetInstance anymore
   
           // Digitization parameter
@@ -108,7 +110,8 @@ class AliTRDSimParam : public TObject {
   
           Int_t    fPRFOn;             //  Switch for the pad response
 
-          Int_t    fNTimeBins;         //  Number of time bins
+          Int_t    fNTimeBins;         //  Number of time bins (only used it fNTBoverwriteOCDB = true)
+          Bool_t   fNTBoverwriteOCDB;  //  Switch to overwrite number of time bins from PCDB
 
  private:
 
@@ -119,7 +122,7 @@ class AliTRDSimParam : public TObject {
           void Init();
           void SampleTRF();
   
-  ClassDef(AliTRDSimParam,5)          // The TRD simulation parameters
+  ClassDef(AliTRDSimParam,6)          // The TRD simulation parameters
 
 };
 
index b571eab..0e6a67f 100644 (file)
@@ -559,6 +559,7 @@ Bool_t AliTRDdigitizer::InitDetector()
   return kTRUE;
 
 }
+
 //_____________________________________________________________________________
 Bool_t AliTRDdigitizer::MakeBranch(TTree *tree) const
 {
@@ -619,12 +620,25 @@ Bool_t AliTRDdigitizer::MakeDigits()
 
   AliTRDarraySignal *signals = 0x0;
 
-  // 
-  if (calibration->GetNumberOfTimeBinsDCS() != AliTRDSimParam::Instance()->GetNTimeBins()) {
-    AliWarning(Form("Number of time bins is different to OCDB value [SIM=%d, OCDB=%d]"
-                  ,AliTRDSimParam::Instance()->GetNTimeBins()
-                   ,calibration->GetNumberOfTimeBinsDCS()));
+  // Check the number of time bins from simParam against OCDB,
+  // if OCDB value is not supposed to be used.
+  // As default, the value from OCDB is taken
+  if (AliTRDSimParam::Instance()->GetNTBoverwriteOCDB()) {
+    if (calibration->GetNumberOfTimeBinsDCS() != AliTRDSimParam::Instance()->GetNTimeBins()) {
+      AliWarning(Form("Number of time bins is different to OCDB value [SIM=%d, OCDB=%d]"
+                     ,AliTRDSimParam::Instance()->GetNTimeBins()
+                     ,calibration->GetNumberOfTimeBinsDCS()));
+    }
+    // Save the values for the raw data headers
+    fDigitsManager->GetDigitsParam()->SetNTimeBinsAll(AliTRDSimParam::Instance()->GetNTimeBins());
+  }
+  else {
+    // Save the values for the raw data headers
+    fDigitsManager->GetDigitsParam()->SetNTimeBinsAll(calibration->GetNumberOfTimeBinsDCS());
   }
+
+  // Save the values for the raw data headers
+  fDigitsManager->GetDigitsParam()->SetADCbaselineAll(AliTRDSimParam::Instance()->GetADCbaseline());
  
   // Sort all hits according to detector number
   if (!SortHits(hits,nhit)) {
@@ -684,10 +698,6 @@ Bool_t AliTRDdigitizer::MakeDigits()
   delete [] hits;
   delete [] nhit;
 
-  // Save the values for the raw data headers
-  fDigitsManager->GetDigitsParam()->SetNTimeBinsAll(AliTRDSimParam::Instance()->GetNTimeBins());
-  fDigitsManager->GetDigitsParam()->SetADCbaselineAll(AliTRDSimParam::Instance()->GetADCbaseline());
-
   return kTRUE;
 
 }
@@ -869,7 +879,7 @@ Bool_t AliTRDdigitizer::ConvertHits(Int_t det
                   * commonParam->GetSamplingFrequency())) - 1;
   }
 
-  Int_t   nTimeTotal   = simParam->GetNTimeBins();
+  Int_t   nTimeTotal   = fDigitsManager->GetDigitsParam()->GetNTimeBins(det);
   Float_t samplingRate = commonParam->GetSamplingFrequency();
   Float_t elAttachProp = simParam->GetElAttachProp() / 100.0; 
 
@@ -1223,7 +1233,14 @@ Bool_t AliTRDdigitizer::Signal2ADC(Int_t det, AliTRDarraySignal *signals)
 
   Int_t nRowMax    = fGeo->GetPadPlane(det)->GetNrows();
   Int_t nColMax    = fGeo->GetPadPlane(det)->GetNcols();
-  Int_t nTimeTotal = simParam->GetNTimeBins();
+  Int_t nTimeTotal = fDigitsManager->GetDigitsParam()->GetNTimeBins(det);
+  if (fSDigitsManager->GetDigitsParam()->GetNTimeBins(det)) {
+    nTimeTotal = fSDigitsManager->GetDigitsParam()->GetNTimeBins(det);
+  }
+  else {
+    AliFatal("Could not get number of time bins");
+    return kFALSE;
+  }
 
   // The gainfactor calibration objects
   const AliTRDCalDet *calGainFactorDet      = calibration->GetGainFactorDet();  
@@ -1339,10 +1356,9 @@ Bool_t AliTRDdigitizer::Signal2SDigits(Int_t det, AliTRDarraySignal *signals)
 
   Int_t nRowMax    = fGeo->GetPadPlane(det)->GetNrows();
   Int_t nColMax    = fGeo->GetPadPlane(det)->GetNcols();
-  Int_t nTimeTotal = AliTRDSimParam::Instance()->GetNTimeBins();
+  Int_t nTimeTotal = fDigitsManager->GetDigitsParam()->GetNTimeBins(det);
 
   // Get the container for the digits of this detector
-
   if (!fDigitsManager->HasSDigits()) {
     AliError("Digits manager has no s-digits");
     return kFALSE;
@@ -1724,7 +1740,12 @@ Bool_t AliTRDdigitizer::ConvertSDigits()
   }
 
   // Save the values for the raw data headers
-  fDigitsManager->GetDigitsParam()->SetNTimeBinsAll(AliTRDSimParam::Instance()->GetNTimeBins());
+  if (AliTRDSimParam::Instance()->GetNTBoverwriteOCDB()) {
+    fDigitsManager->GetDigitsParam()->SetNTimeBinsAll(AliTRDSimParam::Instance()->GetNTimeBins());
+  }
+  else {
+    fDigitsManager->GetDigitsParam()->SetNTimeBinsAll(AliTRDcalibDB::Instance()->GetNumberOfTimeBinsDCS());
+  }
   fDigitsManager->GetDigitsParam()->SetADCbaselineAll(AliTRDSimParam::Instance()->GetADCbaseline());
 
   return kTRUE;
@@ -1753,7 +1774,7 @@ Bool_t AliTRDdigitizer::CopyDictionary(Int_t det)
 
   Int_t nRowMax    = fGeo->GetPadPlane(det)->GetNrows();
   Int_t nColMax    = fGeo->GetPadPlane(det)->GetNcols();
-  Int_t nTimeTotal = AliTRDSimParam::Instance()->GetNTimeBins();
+  Int_t nTimeTotal = fSDigitsManager->GetDigitsParam()->GetNTimeBins(det);
 
   Int_t row  = 0;
   Int_t col  = 0;
@@ -1967,5 +1988,6 @@ void AliTRDdigitizer::RunDigitalProcessing(Int_t det)
       fMcmSim->WriteData(digits);
     }
   }
+
 }