]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
And finally the last effc++ changes ...
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 16 Aug 2006 13:57:37 +0000 (13:57 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 16 Aug 2006 13:57:37 +0000 (13:57 +0000)
TRD/AliTRDSimParam.cxx
TRD/AliTRDSimParam.h
TRD/AliTRDdigitizer.cxx
TRD/AliTRDdigitizer.h

index a745f04a58ffe13aca5ec49ca40c0a6a676291c1..8ec585104f9b6bd75a08e4463ad5a14b4b2a43ef 100644 (file)
 
 /* $Id$ */
 
-///////////////////////////////////////////////////////////////////////////////
-//                                                                           //
-// Class containing constant simulation parameters                           //
-//                                                                           //
-// Request an instance with AliTRDSimParam::Instance()                 //
-// Then request the needed values                                            //
-//                                                                           //
-///////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+// Class containing constant simulation parameters                        //
+//                                                                        //
+// Request an instance with AliTRDSimParam::Instance()                    //
+// Then request the needed values                                         //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
 
 #include <TMath.h>
 
@@ -32,8 +32,8 @@
 
 ClassImp(AliTRDSimParam)
 
-AliTRDSimParam* AliTRDSimParam::fgInstance = 0;
-Bool_t AliTRDSimParam::fgTerminated = kFALSE;
+AliTRDSimParam *AliTRDSimParam::fgInstance   = 0;
+Bool_t          AliTRDSimParam::fgTerminated = kFALSE;
 
 //_ singleton implementation __________________________________________________
 AliTRDSimParam* AliTRDSimParam::Instance()
@@ -43,128 +43,127 @@ AliTRDSimParam* AliTRDSimParam::Instance()
   // Returns an instance of this class, it is created if neccessary
   // 
   
-  if (fgTerminated != kFALSE)
+  if (fgTerminated != kFALSE) {
     return 0;
+  }
 
-  if (fgInstance == 0)
+  if (fgInstance == 0) {
     fgInstance = new AliTRDSimParam();
-  
+  }  
+
   return fgInstance;
+
 }
 
+//_ singleton implementation __________________________________________________
 void AliTRDSimParam::Terminate()
 {
   //
   // Singleton implementation
-  // Deletes the instance of this class and sets the terminated flag, instances cannot be requested anymore
+  // Deletes the instance of this class and sets the terminated flag,
+  // instances cannot be requested anymore
   // This function can be called several times.
   //
   
   fgTerminated = kTRUE;
   
-  if (fgInstance != 0)
-  {
+  if (fgInstance != 0) {
     delete fgInstance;
     fgInstance = 0;
   }
+
 }
 
 //_____________________________________________________________________________
 AliTRDSimParam::AliTRDSimParam()
+  :TObject()
+  ,fGasGain(0.0)
+  ,fNoise(0.0)
+  ,fChipGain(0.0)
+  ,fADCoutRange(0.0)
+  ,fADCinRange(0.0)
+  ,fADCthreshold(0)
+  ,fADCbaseline(0)
+  ,fDiffusionOn(kFALSE)
+  ,fElAttachOn(kFALSE)
+  ,fElAttachProp(0.0)
+  ,fTRFOn(kFALSE)
+  ,fTRFsmp(0)
+  ,fTRFbin(0)
+  ,fTRFlo(0.0)
+  ,fTRFhi(0.0)
+  ,fTRFwid(0.0)
+  ,fCTOn(kFALSE)
+  ,fCTsmp(0)
+  ,fAnodeWireOffset(0.0)
+  ,fPadCoupling(0.0)
+  ,fTimeCoupling(0.0)
+  ,fTimeStructOn(kFALSE)
+  ,fPRFOn(kFALSE)
 {
   //
-  // default constructor
+  // Default constructor
   //
   
-  fGasGain            = 0.0;
-  fNoise              = 0.0;
-  fChipGain           = 0.0;
-  
-  fADCoutRange        = 0.0;
-  fADCinRange         = 0.0;
-  fADCthreshold       = 0;
-  fADCbaseline        = 0;        
-  
-  fDiffusionOn        = kFALSE;
-  
-  fElAttachOn         = kFALSE;
-  fElAttachProp       = 0.0;
-  
-  fTRFOn              = kFALSE;
-  fTRFsmp             = 0;
-  fTRFbin             = 0;
-  fTRFlo              = 0.0;
-  fTRFhi              = 0.0;
-  fTRFwid             = 0.0;
-  
-  fCTOn               = kFALSE;
-  fCTsmp              = 0;
-  
-  fAnodeWireOffset    = 0.0;
-  fPadCoupling        = 0.0;
-  fTimeCoupling       = 0.0;
-  fTimeStructOn       = kFALSE;
-  
-  fPRFOn              = kFALSE;
-  
   Init();
+
 }
 
 //_____________________________________________________________________________
 void AliTRDSimParam::Init()
 {
   // 
-  // default initializiation
+  // Default initializiation
   //
   
   // The default parameter for the digitization
-  fGasGain        = 4000.;
-  fChipGain       = 12.4;
-  fNoise          = 1000.;
-  fADCoutRange    = 1023.;          // 10-bit ADC
-  fADCinRange     = 2000.;          // 2V input range
-  fADCthreshold   = 1;
-  fADCbaseline    = 0;
+  fGasGain         = 4000.0;
+  fChipGain        =   12.4;
+  fNoise           = 1000.0;
+  fADCoutRange     = 1023.0;          // 10-bit ADC
+  fADCinRange      = 2000.0;          // 2V input range
+  fADCthreshold    =    1;
+  fADCbaseline     =    0;
 
   // Diffusion on
-  fDiffusionOn    = kTRUE;
+  fDiffusionOn     = kTRUE;
   
   // Propability for electron attachment
-  fElAttachOn     = kFALSE;
-  fElAttachProp   = 0.0;
+  fElAttachOn      = kFALSE;
+  fElAttachProp    = 0.0;
 
   // The time response function
-  fTRFOn          = kTRUE;
+  fTRFOn           = kTRUE;
 
   // The cross talk
-  fCTOn           = kTRUE;
+  fCTOn            = kTRUE;
 
   // The pad coupling factor
-  //fPadCoupling    = 0.3;
-  // Use 0.46 instead which reproduces better the test beam
-  // data, even tough it is not understood why.
-  fPadCoupling    = 0.46;
+  // Use 0.46, instead of the theroetical value 0.3, since it reproduces better 
+  // the test beam data, even tough it is not understood why.
+  fPadCoupling     = 0.46;
 
   // The time coupling factor (same number as for the TPC)
-  fTimeCoupling   = 0.4;
+  fTimeCoupling    = 0.4;
 
   // Distance of first Anode wire from first pad edge
   fAnodeWireOffset = 0.25;
 
   // Use drift time maps
-  fTimeStructOn = kTRUE;
+  fTimeStructOn    = kTRUE;
   
   // The pad response function
-  fPRFOn          = kTRUE;
+  fPRFOn           = kTRUE;
 
   ReInit();
+
 }
 
 //_____________________________________________________________________________
 AliTRDSimParam::~AliTRDSimParam() 
 {
   //
-  // destructor
+  // Destructor
   //
   
   if (fTRFsmp) {
@@ -176,18 +175,59 @@ AliTRDSimParam::~AliTRDSimParam()
     delete [] fCTsmp;
     fCTsmp  = 0;
   }
+
 }
 
 //_____________________________________________________________________________
-AliTRDSimParam::AliTRDSimParam(const AliTRDSimParam &p):TObject(p)
+AliTRDSimParam::AliTRDSimParam(const AliTRDSimParam &p)
+  :TObject(p)
+  ,fGasGain(p.fGasGain)
+  ,fNoise(p.fNoise)
+  ,fChipGain(p.fChipGain)
+  ,fADCoutRange(p.fADCoutRange)
+  ,fADCinRange(p.fADCinRange)
+  ,fADCthreshold(p.fADCthreshold)
+  ,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)
+  ,fAnodeWireOffset(p.fAnodeWireOffset)
+  ,fPadCoupling(p.fPadCoupling)
+  ,fTimeCoupling(p.fTimeCoupling)
+  ,fTimeStructOn(p.fTimeStructOn)
+  ,fPRFOn(p.fPRFOn)
 {
   //
-  // copy constructor
+  // Copy constructor
   //
 
-  ((AliTRDSimParam &) p).Copy(*this);
-}
+  Int_t iBin = 0;
+
+  if (((AliTRDSimParam &) p).fTRFsmp) {
+    delete [] ((AliTRDSimParam &) p).fTRFsmp;
+  }
+  ((AliTRDSimParam &) p).fTRFsmp = new Float_t[fTRFbin];
+  for (iBin = 0; iBin < fTRFbin; iBin++) {
+    ((AliTRDSimParam &) p).fTRFsmp[iBin] = fTRFsmp[iBin];
+  }                                                                             
+
+  if (((AliTRDSimParam &) p).fCTsmp) {
+    delete [] ((AliTRDSimParam &) p).fCTsmp;
+  }
+  ((AliTRDSimParam &) p).fCTsmp  = new Float_t[fTRFbin];
+  for (iBin = 0; iBin < fTRFbin; iBin++) {
+    ((AliTRDSimParam &) p).fCTsmp[iBin] = fCTsmp[iBin];
+  }                                                                             
 
+}
 
 //_____________________________________________________________________________
 AliTRDSimParam &AliTRDSimParam::operator=(const AliTRDSimParam &p)
@@ -197,7 +237,9 @@ AliTRDSimParam &AliTRDSimParam::operator=(const AliTRDSimParam &p)
   //
 
   if (this != &p) ((AliTRDSimParam &) p).Copy(*this);
+
   return *this;
+
 }
 
 //_____________________________________________________________________________
@@ -208,49 +250,47 @@ void AliTRDSimParam::Copy(TObject &p) const
   //
   
   AliTRDSimParam* target = dynamic_cast<AliTRDSimParam*> (&p);
-  if (!target)
+  if (!target) {
     return;
+  }
 
   target->fGasGain            = fGasGain;
-  //target->fField              = fField;
   target->fNoise              = fNoise;
-  target->fChipGain           = fChipGain;
-  
+  target->fChipGain           = fChipGain;  
   target->fADCoutRange        = fADCoutRange;
   target->fADCinRange         = fADCinRange;
   target->fADCthreshold       = fADCthreshold;
   target->fADCbaseline        = fADCbaseline; 
-  
   target->fDiffusionOn        = fDiffusionOn; 
-  
   target->fElAttachOn         = fElAttachOn;
   target->fElAttachProp       = fElAttachProp;
-  
   target->fTRFOn              = fTRFOn;
-  if (target->fTRFsmp) 
-    delete[] target->fTRFsmp;
-  target->fTRFsmp = new Float_t[fTRFbin];
-  for (Int_t iBin = 0; iBin < fTRFbin; iBin++) {
-    target->fTRFsmp[iBin] = fTRFsmp[iBin];
-  }
   target->fTRFbin             = fTRFbin;
   target->fTRFlo              = fTRFlo;
   target->fTRFhi              = fTRFhi;
   target->fTRFwid             = fTRFwid;
-  
   target->fCTOn               = fCTOn;
-  if (target->fCTsmp) 
+  target->fAnodeWireOffset    = fAnodeWireOffset;
+  target->fPadCoupling        = fPadCoupling;
+  target->fTimeCoupling       = fTimeCoupling;
+  target->fPRFOn              = fPRFOn;
+
+  if (target->fTRFsmp) {
+    delete[] target->fTRFsmp;
+  }
+  target->fTRFsmp = new Float_t[fTRFbin];
+  for (Int_t iBin = 0; iBin < fTRFbin; iBin++) {
+    target->fTRFsmp[iBin] = fTRFsmp[iBin];
+  }
+
+  if (target->fCTsmp) {
     delete[] target->fCTsmp;
+  }
   target->fCTsmp  = new Float_t[fTRFbin];
   for (Int_t iBin = 0; iBin < fTRFbin; iBin++) {
     target->fCTsmp[iBin]  = fCTsmp[iBin];
   }
   
-  target->fAnodeWireOffset    = fAnodeWireOffset;
-  target->fPadCoupling        = fPadCoupling;
-  target->fTimeCoupling       = fTimeCoupling;
-  
-  target->fPRFOn              = fPRFOn;
 }
 
 //_____________________________________________________________________________
@@ -265,14 +305,13 @@ void AliTRDSimParam::ReInit()
   // Start 0.2 mus before the signal
   fTRFlo  = -0.4;
   // End the maximum drift time after the signal 
-  fTRFhi  = 3.58;
-  // 
+  fTRFhi  =  3.58;
   fTRFwid = (fTRFhi - fTRFlo) / ((Float_t) fTRFbin);
 
   // Create the sampled TRF
   SampleTRF();
-}
 
+}
 
 //_____________________________________________________________________________
 void AliTRDSimParam::SampleTRF()
@@ -285,51 +324,59 @@ void AliTRDSimParam::SampleTRF()
 
   const Int_t kNpasa     = 200;  // kNpasa should be equal to fTRFbin!
 
-  Float_t signal[kNpasa]={0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
-                         0.0002, 0.0007, 0.0026, 0.0089, 0.0253, 0.0612, 0.1319,
-                         0.2416, 0.3913, 0.5609, 0.7295, 0.8662, 0.9581, 1.0000,
-                         0.9990, 0.9611, 0.8995, 0.8269, 0.7495, 0.6714, 0.5987,
-                         0.5334, 0.4756, 0.4249, 0.3811, 0.3433, 0.3110, 0.2837,
-                         0.2607, 0.2409, 0.2243, 0.2099, 0.1974, 0.1868, 0.1776,
-                         0.1695, 0.1627, 0.1566, 0.1509, 0.1457, 0.1407, 0.1362,
-                         0.1317, 0.1274, 0.1233, 0.1196, 0.1162, 0.1131, 0.1102,
-                         0.1075, 0.1051, 0.1026, 0.1004, 0.0979, 0.0956, 0.0934,
-                         0.0912, 0.0892, 0.0875, 0.0858, 0.0843, 0.0829, 0.0815,
-                         0.0799, 0.0786, 0.0772, 0.0757, 0.0741, 0.0729, 0.0718,
-                         0.0706, 0.0692, 0.0680, 0.0669, 0.0655, 0.0643, 0.0630,
-                         0.0618, 0.0607, 0.0596, 0.0587, 0.0576, 0.0568, 0.0558,
-                         0.0550, 0.0541, 0.0531, 0.0522, 0.0513, 0.0505, 0.0497,
-                         0.0490, 0.0484, 0.0474, 0.0465, 0.0457, 0.0449, 0.0441,
-                         0.0433, 0.0425, 0.0417, 0.0410, 0.0402, 0.0395, 0.0388,
-                         0.0381, 0.0374, 0.0368, 0.0361, 0.0354, 0.0348, 0.0342,
-                         0.0336, 0.0330, 0.0324, 0.0318, 0.0312, 0.0306, 0.0301,
-                         0.0296, 0.0290, 0.0285, 0.0280, 0.0275, 0.0270, 0.0265,
-                         0.0260, 0.0256, 0.0251, 0.0246, 0.0242, 0.0238, 0.0233,
-                         0.0229, 0.0225, 0.0221, 0.0217, 0.0213, 0.0209, 0.0206,
-                         0.0202, 0.0198, 0.0195, 0.0191, 0.0188, 0.0184, 0.0181,
-                         0.0178, 0.0175, 0.0171, 0.0168, 0.0165, 0.0162, 0.0159,
-                         0.0157, 0.0154, 0.0151, 0.0148, 0.0146, 0.0143, 0.0140,
-                         0.0138, 0.0135, 0.0133, 0.0131, 0.0128, 0.0126, 0.0124,
-                         0.0121, 0.0119, 0.0120, 0.0115, 0.0113, 0.0111, 0.0109,
-                         0.0107, 0.0105, 0.0103, 0.0101, 0.0100, 0.0098, 0.0096,
-                         0.0094, 0.0092, 0.0091, 0.0089, 0.0088, 0.0086, 0.0084,
-                         0.0083, 0.0081, 0.0080, 0.0078};
+  Float_t signal[kNpasa]={ 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000
+                        , 0.0002, 0.0007, 0.0026, 0.0089, 0.0253, 0.0612, 0.1319
+                        , 0.2416, 0.3913, 0.5609, 0.7295, 0.8662, 0.9581, 1.0000
+                        , 0.9990, 0.9611, 0.8995, 0.8269, 0.7495, 0.6714, 0.5987
+                        , 0.5334, 0.4756, 0.4249, 0.3811, 0.3433, 0.3110, 0.2837
+                        , 0.2607, 0.2409, 0.2243, 0.2099, 0.1974, 0.1868, 0.1776
+                        , 0.1695, 0.1627, 0.1566, 0.1509, 0.1457, 0.1407, 0.1362
+                        , 0.1317, 0.1274, 0.1233, 0.1196, 0.1162, 0.1131, 0.1102
+                        , 0.1075, 0.1051, 0.1026, 0.1004, 0.0979, 0.0956, 0.0934
+                        , 0.0912, 0.0892, 0.0875, 0.0858, 0.0843, 0.0829, 0.0815
+                        , 0.0799, 0.0786, 0.0772, 0.0757, 0.0741, 0.0729, 0.0718
+                        , 0.0706, 0.0692, 0.0680, 0.0669, 0.0655, 0.0643, 0.0630
+                        , 0.0618, 0.0607, 0.0596, 0.0587, 0.0576, 0.0568, 0.0558
+                        , 0.0550, 0.0541, 0.0531, 0.0522, 0.0513, 0.0505, 0.0497
+                        , 0.0490, 0.0484, 0.0474, 0.0465, 0.0457, 0.0449, 0.0441
+                        , 0.0433, 0.0425, 0.0417, 0.0410, 0.0402, 0.0395, 0.0388
+                        , 0.0381, 0.0374, 0.0368, 0.0361, 0.0354, 0.0348, 0.0342
+                        , 0.0336, 0.0330, 0.0324, 0.0318, 0.0312, 0.0306, 0.0301
+                        , 0.0296, 0.0290, 0.0285, 0.0280, 0.0275, 0.0270, 0.0265
+                        , 0.0260, 0.0256, 0.0251, 0.0246, 0.0242, 0.0238, 0.0233
+                        , 0.0229, 0.0225, 0.0221, 0.0217, 0.0213, 0.0209, 0.0206
+                        , 0.0202, 0.0198, 0.0195, 0.0191, 0.0188, 0.0184, 0.0181
+                        , 0.0178, 0.0175, 0.0171, 0.0168, 0.0165, 0.0162, 0.0159
+                        , 0.0157, 0.0154, 0.0151, 0.0148, 0.0146, 0.0143, 0.0140
+                        , 0.0138, 0.0135, 0.0133, 0.0131, 0.0128, 0.0126, 0.0124
+                        , 0.0121, 0.0119, 0.0120, 0.0115, 0.0113, 0.0111, 0.0109
+                        , 0.0107, 0.0105, 0.0103, 0.0101, 0.0100, 0.0098, 0.0096
+                        , 0.0094, 0.0092, 0.0091, 0.0089, 0.0088, 0.0086, 0.0084
+                        , 0.0083, 0.0081, 0.0080, 0.0078 };
 
   Float_t xtalk[kNpasa];
 
+  // With undershoot, positive peak corresponds to ~3% of the main signal:
   for (Int_t ipasa = 3; ipasa < kNpasa; ipasa++) {
-    //signal[ipasa] /= 0.44; // normalise area to 1
-    // With undershoot, positive peak corresponds to ~3% of the main signal:
-    xtalk[ipasa] = 0.2*(signal[ipasa-2]-signal[ipasa-3]);
+    xtalk[ipasa] = 0.2 * (signal[ipasa-2] - signal[ipasa-3]);
   }
 
-  xtalk[0] =  0.0;      signal[0] = 0.0;
-  xtalk[1] =  0.0;      signal[1] = 0.0;
-  xtalk[2] =  0.0;      signal[2] = 0.0;
+  xtalk[0]  = 0.0;   
+  xtalk[1]  = 0.0;  
+  xtalk[2]  = 0.0;  
 
-  if (fTRFsmp) delete [] fTRFsmp;
+  signal[0] = 0.0;
+  signal[1] = 0.0;
+  signal[2] = 0.0;
+
+  if (fTRFsmp) {
+    delete [] fTRFsmp;
+  }
   fTRFsmp = new Float_t[fTRFbin];
-  if (fCTsmp)  delete [] fCTsmp;
+
+  if (fCTsmp)  {
+    delete [] fCTsmp;
+  }
   fCTsmp  = new Float_t[fTRFbin];
 
   for (Int_t iBin = 0; iBin < fTRFbin; iBin++) {
@@ -347,8 +394,9 @@ 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.) / fTRFwid)); 
-  if ((iBin >= 0) && (iBin < fTRFbin)) {
+  Int_t iBin = ((Int_t) ((time - fTRFlo/2.0) / fTRFwid)); 
+  if ((iBin >=       0) && 
+      (iBin <  fTRFbin)) {
     return fTRFsmp[iBin];
   }
   else {
@@ -365,7 +413,8 @@ Double_t AliTRDSimParam::CrossTalk(Double_t time) const
   //
 
   Int_t iBin = ((Int_t) ((time - fTRFlo) / fTRFwid)); 
-  if ((iBin >= 0) && (iBin < fTRFbin)) {
+  if ((iBin >=       0) && 
+      (iBin <  fTRFbin)) {
     return fCTsmp[iBin];
   }
   else {
@@ -373,4 +422,3 @@ Double_t AliTRDSimParam::CrossTalk(Double_t time) const
   }    
 
 }
-
index b695c740c0c3fc55ace7bdb2dfe050787f298c7b..6b2d173259c22360ca6cd8970731aa6f82ad34ff 100644 (file)
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-///////////////////////////////////////////////////////////////////////////////
-//                                                                           //
-// Class containing constant simulation parameters                           //
-//                                                                           //
-///////////////////////////////////////////////////////////////////////////////
-
 /* $Id$ */
 
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+// Class containing constant simulation parameters                        //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+
 #include "TObject.h"
 
-class AliTRDSimParam : public TObject
-{
+class AliTRDSimParam : public TObject {
   
-public:
-  static AliTRDSimParam* Instance();
-  static void Terminate();
+ public:
   
-  enum { kNplan = 6, kNcham = 5, kNsect = 18, kNdet = 540 };
+          enum { kNplan =   6
+               , kNcham =   5
+               , kNsect =  18
+               , kNdet  = 540 };
+
+  static  AliTRDSimParam *Instance();
+  static  void     Terminate();
   
   AliTRDSimParam(const AliTRDSimParam &p);   
   AliTRDSimParam &operator=(const AliTRDSimParam &p); 
-  virtual void Copy(TObject &p) const;
-  
-  void SetGasGain(Float_t gasgain)                    { fGasGain        = gasgain;  };
-  void SetNoise(Float_t noise)                        { fNoise          = noise;    };
-  void SetChipGain(Float_t chipgain)                  { fChipGain       = chipgain; };
-  
-  void SetADCoutRange(Float_t range)                  { fADCoutRange    = range;    };
-  void SetADCinRange(Float_t range)                   { fADCinRange     = range;    };
-  void SetADCthreshold(Int_t thresh)                  { fADCthreshold   = thresh;   };
-  void SetADCbaseline(Int_t basel)                    { fADCbaseline    = basel;    };   
-  
-  void SetDiffusion(Int_t diffOn = 1)                 { fDiffusionOn    = diffOn;   };
-  
-  void SetElAttach(Int_t elOn = 1)                    { fElAttachOn     = elOn;     };
-  void SetElAttachProp(Float_t prop)                  { fElAttachProp   = prop;     };
-  
-  void SetTimeResponse(Int_t trfOn = 1)               { fTRFOn          = trfOn; ReInit(); };
-  
-  void SetCrossTalk(Int_t ctOn = 1)                   { fCTOn           = ctOn; ReInit(); };
-  
-  void SetPadCoupling(Float_t v)                      { fPadCoupling    = v;        };
-  void SetTimeCoupling(Float_t v)                     { fTimeCoupling   = v;        };
-  void SetAnodeWireOffset(Float_t offset = 0.25)      { fAnodeWireOffset = offset;};
-  void SetTimeStruct(Bool_t tsOn = 1)                 { fTimeStructOn   = tsOn;     };
-  
-  void     SetPadResponse(Int_t prfOn = 1)                { fPRFOn          = prfOn;    };
-    
-  Float_t  GetGasGain()                             const { return fGasGain;           };
-  Float_t  GetNoise()                               const { return fNoise;             };
-  Float_t  GetChipGain()                            const { return fChipGain;          };
-  
-  Float_t  GetADCoutRange()                         const { return fADCoutRange;       };
-  Float_t  GetADCinRange()                          const { return fADCinRange;        };
-  Int_t    GetADCthreshold()                        const { return fADCthreshold;      };
-  Int_t    GetADCbaseline()                         const { return fADCbaseline;       };
-  
-  Bool_t   DiffusionOn()                            const { return fDiffusionOn;   };
-  
-  Bool_t   ElAttachOn()                             const { return fElAttachOn;    }; 
-  Float_t  GetElAttachProp()                        const { return fElAttachProp;      };
-  
-  Bool_t   TRFOn()                                  const { return fTRFOn;         };
-  Double_t TimeResponse(Double_t time) const;  
-  Float_t  GetTRFlo()                               const { return fTRFlo;             };
-  Float_t  GetTRFhi()                               const { return fTRFhi;             };
-  
-  Bool_t   CTOn()                                   const { return fCTOn;          };
-  Double_t CrossTalk(Double_t time) const; 
-  
-  Float_t  GetPadCoupling()                         const { return fPadCoupling;       };
-  Float_t  GetTimeCoupling()                        const { return fTimeCoupling;      };
-  Float_t  GetAnodeWireOffset()                     const { return fAnodeWireOffset;   };
-  Bool_t TimeStructOn()                             const { return fTimeStructOn;  };
+
+  virtual void     Copy(TObject &p) const;
+  
+          void     SetGasGain(Float_t gasgain)               { fGasGain         = gasgain;         }
+          void     SetNoise(Float_t noise)                   { fNoise           = noise;           }
+          void     SetChipGain(Float_t chipgain)             { fChipGain        = chipgain;        }
+          void     SetADCoutRange(Float_t range)             { fADCoutRange     = range;           }
+          void     SetADCinRange(Float_t range)              { fADCinRange      = range;           }
+          void     SetADCthreshold(Int_t thresh)             { fADCthreshold    = thresh;          }
+          void     SetADCbaseline(Int_t basel)               { fADCbaseline     = basel;           }   
+          void     SetDiffusion(Int_t diffOn = 1)            { fDiffusionOn     = diffOn;          }
+          void     SetElAttach(Int_t elOn = 1)               { fElAttachOn      = elOn;            }
+          void     SetElAttachProp(Float_t prop)             { fElAttachProp    = prop;            }
+          void     SetTimeResponse(Int_t trfOn = 1)          { fTRFOn           = trfOn; ReInit(); }  
+          void     SetCrossTalk(Int_t ctOn = 1)              { fCTOn            = ctOn; ReInit();  }
+          void     SetPadCoupling(Float_t v)                 { fPadCoupling     = v;               }
+          void     SetTimeCoupling(Float_t v)                { fTimeCoupling    = v;               }
+          void     SetAnodeWireOffset(Float_t offset = 0.25) { fAnodeWireOffset = offset;          }
+          void     SetTimeStruct(Bool_t tsOn = 1)            { fTimeStructOn    = tsOn;            }
+          void     SetPadResponse(Int_t prfOn = 1)           { fPRFOn           = prfOn;           }
     
-  Bool_t   PRFOn()                                  const { return fPRFOn;         };
+          Float_t  GetGasGain() const                        { return fGasGain;                    }
+          Float_t  GetNoise() const                          { return fNoise;                      }
+          Float_t  GetChipGain() const                       { return fChipGain;                   }
+          Float_t  GetADCoutRange() const                    { return fADCoutRange;                }
+          Float_t  GetADCinRange() const                     { return fADCinRange;                 }
+          Int_t    GetADCthreshold() const                   { return fADCthreshold;               }
+          Int_t    GetADCbaseline() const                    { return fADCbaseline;                }
+          Float_t  GetTRFlo() const                          { return fTRFlo;                      }
+          Float_t  GetTRFhi() const                          { return fTRFhi;                      }
+          Float_t  GetPadCoupling() const                    { return fPadCoupling;                }
+          Float_t  GetTimeCoupling() const                   { return fTimeCoupling;               }
+          Float_t  GetAnodeWireOffset() const                { return fAnodeWireOffset;            }
+
+          Bool_t   DiffusionOn() const                       { return fDiffusionOn;                }
+          Bool_t   ElAttachOn() const                        { return fElAttachOn;                 } 
+          Float_t  GetElAttachProp() const                   { return fElAttachProp;               }
+          Bool_t   TRFOn() const                             { return fTRFOn;                      }
+          Bool_t   CTOn() const                              { return fCTOn;                       }
+          Bool_t   TimeStructOn() const                      { return fTimeStructOn;               }
+          Bool_t   PRFOn() const                             { return fPRFOn;                      }
+
+          Double_t TimeResponse(Double_t time) const;  
+          Double_t CrossTalk(Double_t time) const; 
   
 protected:
-  static AliTRDSimParam* fgInstance;     // Instance of this class (singleton implementation)
-  static Bool_t fgTerminated;               // Defines if this class has already been terminated and therefore does not return instances in GetInstance anymore
+
+  static AliTRDSimParam* fgInstance;  //  Instance of this class (singleton implementation)
+  static  Bool_t   fgTerminated;      //  Defines if this class has already been terminated and
+                                      //  therefore does not return instances in GetInstance anymore
   
-  // Digitization parameter
-  Float_t              fGasGain;                            //  Gas gain
-  Float_t              fNoise;                              //  Electronics noise
-  Float_t              fChipGain;                           //  Electronics gain
+          // Digitization parameter
+          Float_t  fGasGain;          //  Gas gain
+          Float_t  fNoise;            //  Electronics noise
+          Float_t  fChipGain;         //  Electronics gain
   
-  Float_t              fADCoutRange;                        //  ADC output range (number of channels)
-  Float_t              fADCinRange;                         //  ADC input range (input charge)
-  Int_t                fADCthreshold;                       //  ADC threshold in ADC channel
-  Int_t                fADCbaseline;                        //  ADC baseline in ADC chann
+          Float_t  fADCoutRange;      //  ADC output range (number of channels)
+          Float_t  fADCinRange;       //  ADC input range (input charge)
+          Int_t    fADCthreshold;     //  ADC threshold in ADC channel
+          Int_t    fADCbaseline;      //  ADC baseline in ADC chann
   
-  Int_t                fDiffusionOn;                        //  Switch for the diffusion
+          Int_t    fDiffusionOn;      //  Switch for the diffusion
   
-  Int_t                fElAttachOn;                         //  Switch for the electron attachment
-  Float_t              fElAttachProp;                       //  Propability for electron attachment (for 1m)
+          Int_t    fElAttachOn;       //  Switch for the electron attachment
+          Float_t  fElAttachProp;     //  Propability for electron attachment (for 1m)
   
-  Int_t                fTRFOn;                              //  Switch for the time response
-  Float_t             *fTRFsmp;                             //! Integrated time response
-  Int_t                fTRFbin;                             //  Number of bins for the TRF
-  Float_t              fTRFlo;                              //  Lower boundary of the TRF
-  Float_t              fTRFhi;                              //  Higher boundary of the TRF
-  Float_t              fTRFwid;                             //  Bin width of the integrated TRF
+          Int_t    fTRFOn;            //  Switch for the time response
+          Float_t *fTRFsmp;           //! Integrated time response
+          Int_t    fTRFbin;           //  Number of bins for the TRF
+          Float_t  fTRFlo;            //  Lower boundary of the TRF
+          Float_t  fTRFhi;            //  Higher boundary of the TRF
+          Float_t  fTRFwid;           //  Bin width of the integrated TRF
   
-  Int_t                fCTOn;                               //  Switch for cross talk
-  Float_t             *fCTsmp;                              //! Integrated cross talk
+          Int_t    fCTOn;             //  Switch for cross talk
+          Float_t *fCTsmp;            //! Integrated cross talk
   
-  Float_t              fAnodeWireOffset;                    //  Distance of first anode wire from pad edge
-  Float_t              fPadCoupling;                        //  Pad coupling factor
-  Float_t              fTimeCoupling;                       //  Time coupling factor (image charge of moving ions)
-  Int_t                fTimeStructOn;                       //  Switch for cell time structure
+          Float_t  fAnodeWireOffset;  //  Distance of first anode wire from pad edge
+          Float_t  fPadCoupling;      //  Pad coupling factor
+          Float_t  fTimeCoupling;     //  Time coupling factor (image charge of moving ions)
+          Int_t    fTimeStructOn;     //  Switch for cell time structure
   
-  Int_t                fPRFOn;                              //  Switch for the pad response
+          Int_t    fPRFOn;            //  Switch for the pad response
   
-private:
-  // this is a singleton, constructor is private!  
+ private:
+
+  // This is a singleton, constructor is private!  
   AliTRDSimParam();
   virtual ~AliTRDSimParam();
 
-  void Init();
-  void ReInit();
-  void SampleTRF();
+          void Init();
+          void ReInit();
+          void SampleTRF();
   
-  ClassDef(AliTRDSimParam, 1)
+  ClassDef(AliTRDSimParam,1)          // The TRD simulation parameters
+
 };
 
 #endif
index 0b28a76ad979ca61506e0465a7dfd22ca1cc674d..879acf8da633a31ea331a17e2570e3c24c72d02d 100644 (file)
@@ -78,42 +78,63 @@ ClassImp(AliTRDdigitizer)
 
 //_____________________________________________________________________________
 AliTRDdigitizer::AliTRDdigitizer()
+  :AliDigitizer()
+  ,fRunLoader(0)
+  ,fDigitsManager(0)
+  ,fSDigitsManager(0)
+  ,fSDigitsManagerList(0)
+  ,fTRD(0)
+  ,fGeo(0)
+  ,fEvent(0)
+  ,fMasks(0)
+  ,fCompress(kTRUE)
+  ,fSDigits(kFALSE)
+  ,fSDigitsScale(0.0)
+  ,fMergeSignalOnly(kFALSE)
+  ,fDiffLastVdrift(0)
+  ,fDiffusionT(0.0)
+  ,fDiffusionL(0.0)
+  ,fOmegaTau(0.0)
+  ,fLorentzFactor(0.0)
+  ,fTimeLastVdrift(0)
+  ,fTimeStruct1(0)
+  ,fTimeStruct2(0)
+  ,fVDlo(0)
+  ,fVDhi(0)
 {
   //
   // AliTRDdigitizer default constructor
   //
-
-  fRunLoader          = 0;
-  fDigitsManager      = 0;
-  fSDigitsManager     = 0;
-  fSDigitsManagerList = 0;
-  fTRD                = 0;
-  fGeo                = 0;
-  fEvent              = 0;
-  fMasks              = 0;
-  fCompress           = kTRUE;
-  fSDigits            = kFALSE;
-  fSDigitsScale       = 0.0;
-  fMergeSignalOnly    = kFALSE;
-  fTimeStructInfo.fLastVdrift   = 0;
-  fTimeStructInfo.fTimeStruct1  = 0;
-  fTimeStructInfo.fTimeStruct2  = 0;
-  fTimeStructInfo.fVDlo         = 0;
-  fTimeStructInfo.fVDhi         = 0;
-  
-  fDiffusionInfo.fLastVdrift    = 0;
-  fDiffusionInfo.fDiffusionT    = 0.0;
-  fDiffusionInfo.fDiffusionL    = 0.0;
-  fDiffusionInfo.fLorentzFactor = 0.0;
   
   Init();
 
 }
 
 //_____________________________________________________________________________
-AliTRDdigitizer::AliTRDdigitizer(const Text_t *name, const Text_t *title)
-                :AliDigitizer(name,title)
+AliTRDdigitizer::AliTRDdigitizer(const Text_t *name, const Text_t *title)              
+  :AliDigitizer(name,title)
+  ,fRunLoader(0)
+  ,fDigitsManager(0)
+  ,fSDigitsManager(0)
+  ,fSDigitsManagerList(0)
+  ,fTRD(0)
+  ,fGeo(0)
+  ,fEvent(0)
+  ,fMasks(0)
+  ,fCompress(kTRUE)
+  ,fSDigits(kFALSE)
+  ,fSDigitsScale(0.0)
+  ,fMergeSignalOnly(kFALSE)
+  ,fDiffLastVdrift(0)
+  ,fDiffusionT(0.0)
+  ,fDiffusionL(0.0)
+  ,fOmegaTau(0.0)
+  ,fLorentzFactor(0.0)
+  ,fTimeLastVdrift(0)
+  ,fTimeStruct1(0)
+  ,fTimeStruct2(0)
+  ,fVDlo(0)
+  ,fVDhi(0)
 {
   //
   // AliTRDdigitizer constructor
@@ -125,8 +146,30 @@ AliTRDdigitizer::AliTRDdigitizer(const Text_t *name, const Text_t *title)
 
 //_____________________________________________________________________________
 AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager
-                                , const Text_t *name, const Text_t *title)
-                :AliDigitizer(manager,name,title)
+                               , const Text_t *name, const Text_t *title)
+  :AliDigitizer(manager,name,title)
+  ,fRunLoader(0)
+  ,fDigitsManager(0)
+  ,fSDigitsManager(0)
+  ,fSDigitsManagerList(0)
+  ,fTRD(0)
+  ,fGeo(0)
+  ,fEvent(0)
+  ,fMasks(0)
+  ,fCompress(kTRUE)
+  ,fSDigits(kFALSE)
+  ,fSDigitsScale(0.0)
+  ,fMergeSignalOnly(kFALSE)
+  ,fDiffLastVdrift(0)
+  ,fDiffusionT(0.0)
+  ,fDiffusionL(0.0)
+  ,fOmegaTau(0.0)
+  ,fLorentzFactor(0.0)
+  ,fTimeLastVdrift(0)
+  ,fTimeStruct1(0)
+  ,fTimeStruct2(0)
+  ,fVDlo(0)
+  ,fVDhi(0)
 {
   //
   // AliTRDdigitizer constructor
@@ -138,7 +181,29 @@ AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager
 
 //_____________________________________________________________________________
 AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager)
-                :AliDigitizer(manager,"AliTRDdigitizer","TRD digitizer")
+  :AliDigitizer(manager,"AliTRDdigitizer","TRD digitizer")
+  ,fRunLoader(0)
+  ,fDigitsManager(0)
+  ,fSDigitsManager(0)
+  ,fSDigitsManagerList(0)
+  ,fTRD(0)
+  ,fGeo(0)
+  ,fEvent(0)
+  ,fMasks(0)
+  ,fCompress(kTRUE)
+  ,fSDigits(kFALSE)
+  ,fSDigitsScale(0.0)
+  ,fMergeSignalOnly(kFALSE)
+  ,fDiffLastVdrift(0)
+  ,fDiffusionT(0.0)
+  ,fDiffusionL(0.0)
+  ,fOmegaTau(0.0)
+  ,fLorentzFactor(0.0)
+  ,fTimeLastVdrift(0)
+  ,fTimeStruct1(0)
+  ,fTimeStruct2(0)
+  ,fVDlo(0)
+  ,fVDhi(0)
 {
   //
   // AliTRDdigitizer constructor
@@ -156,45 +221,74 @@ Bool_t AliTRDdigitizer::Init()
   //
 
   fRunLoader          = 0;
-
-  //NewIO: These data members probably are not needed anymore
   fDigitsManager      = 0;
   fSDigitsManager     = 0;
   fSDigitsManagerList = 0;
   fTRD                = 0;
   fGeo                = 0;
-  //End NewIO comment
 
   fEvent              = 0;
   fMasks              = 0;
   fCompress           = kTRUE;
   fSDigits            = kFALSE;
-  fSDigitsScale       = 100.; // For the summable digits
+  fSDigitsScale       = 100.0;
   fMergeSignalOnly    = kFALSE;
  
-  fTimeStructInfo.fLastVdrift   = -1;
-  fTimeStructInfo.fTimeStruct1  = 0;
-  fTimeStructInfo.fTimeStruct2  = 0;
-  fTimeStructInfo.fVDlo         = 0;
-  fTimeStructInfo.fVDhi         = 0;
+  fTimeLastVdrift     = -1;
+  fTimeStruct1        =  0;
+  fTimeStruct2        =  0;
+  fVDlo               =  0;
+  fVDhi               =  0;
   
-  fDiffusionInfo.fLastVdrift    = -1;
-  fDiffusionInfo.fDiffusionT    = 0.0;
-  fDiffusionInfo.fDiffusionL    = 0.0;
-  fDiffusionInfo.fLorentzFactor = 0.0;
+  fDiffLastVdrift     = -1;
+  fDiffusionT         =  0.0;
+  fDiffusionL         =  0.0;
+  fLorentzFactor      =  0.0;
 
   return AliDigitizer::Init();
 
 }
 
 //_____________________________________________________________________________
-AliTRDdigitizer::AliTRDdigitizer(const AliTRDdigitizer &d):AliDigitizer(d)
+AliTRDdigitizer::AliTRDdigitizer(const AliTRDdigitizer &d)
+  :AliDigitizer(d)
+  ,fRunLoader(0)
+  ,fDigitsManager(0)
+  ,fSDigitsManager(0)
+  ,fSDigitsManagerList(0)
+  ,fTRD(0)
+  ,fGeo(0)
+  ,fEvent(0)
+  ,fMasks(0)
+  ,fCompress(d.fCompress)
+  ,fSDigits(d.fSDigits)
+  ,fSDigitsScale(d.fSDigitsScale)
+  ,fMergeSignalOnly(d.fMergeSignalOnly)
+  ,fDiffLastVdrift(-1)
+  ,fDiffusionT(0.0)
+  ,fDiffusionL(0.0)
+  ,fOmegaTau(0.0)
+  ,fLorentzFactor(0.0)
+  ,fTimeLastVdrift(-1)
+  ,fTimeStruct1(0)
+  ,fTimeStruct2(0)
+  ,fVDlo(0)
+  ,fVDhi(0)
 {
   //
   // AliTRDdigitizer copy constructor
   //
 
-  ((AliTRDdigitizer &) d).Copy(*this);
+  // Do not copy timestructs, just invalidate lastvdrift.
+  // Next time they are requested, they get recalculated
+  if (((AliTRDdigitizer &) d).fTimeStruct1) {
+    delete [] ((AliTRDdigitizer &) d).fTimeStruct1;
+    ((AliTRDdigitizer &) d).fTimeStruct1 = 0;
+  }
+  if (((AliTRDdigitizer &) d).fTimeStruct2) {
+    delete [] ((AliTRDdigitizer &) d).fTimeStruct2;
+    ((AliTRDdigitizer &) d).fTimeStruct2 = 0;
+  }
 
 }
 
@@ -207,10 +301,13 @@ AliTRDdigitizer::~AliTRDdigitizer()
 
   if (fDigitsManager) {
     delete fDigitsManager;
-    fDigitsManager = 0;
+    fDigitsManager      = 0;
   }
 
-  fSDigitsManager = 0;
+  if (fDigitsManager) {
+    delete fSDigitsManager;
+    fSDigitsManager     = 0;
+  }
 
   if (fSDigitsManagerList) {
     fSDigitsManagerList->Delete();
@@ -223,16 +320,14 @@ AliTRDdigitizer::~AliTRDdigitizer()
     fMasks = 0;
   }
 
-  if (fTimeStructInfo.fTimeStruct1)
-  {
-    delete [] fTimeStructInfo.fTimeStruct1;
-    fTimeStructInfo.fTimeStruct1 = 0;
+  if (fTimeStruct1) {
+    delete [] fTimeStruct1;
+    fTimeStruct1 = 0;
   }
 
-  if (fTimeStructInfo.fTimeStruct2) 
-  {
-    delete [] fTimeStructInfo.fTimeStruct2;
-    fTimeStructInfo.fTimeStruct2 = 0;
+  if (fTimeStruct2) {
+    delete [] fTimeStruct2;
+    fTimeStruct2 = 0;
   }
 
 }
@@ -245,6 +340,7 @@ AliTRDdigitizer &AliTRDdigitizer::operator=(const AliTRDdigitizer &d)
   //
 
   if (this != &d) ((AliTRDdigitizer &) d).Copy(*this);
+
   return *this;
 
 }
@@ -271,26 +367,22 @@ void AliTRDdigitizer::Copy(TObject &d) const
                                        
   AliTRDdigitizer& target = (AliTRDdigitizer &) d;
   
-  target.fDiffusionInfo = fDiffusionInfo;
-  
   // Do not copy timestructs, just invalidate lastvdrift.
   // Next time they are requested, they get recalculated
-  if (target.fTimeStructInfo.fTimeStruct1)
-  {
-    delete[] target.fTimeStructInfo.fTimeStruct1;
-    target.fTimeStructInfo.fTimeStruct1 = 0;
+  if (target.fTimeStruct1) {
+    delete[] target.fTimeStruct1;
+    target.fTimeStruct1 = 0;
   }
-  if (target.fTimeStructInfo.fTimeStruct2)
-  {
-    delete[] target.fTimeStructInfo.fTimeStruct2;
-    target.fTimeStructInfo.fTimeStruct2 = 0;
+  if (target.fTimeStruct2) {
+    delete[] target.fTimeStruct2;
+    target.fTimeStruct2 = 0;
   }  
-  target.fTimeStructInfo.fLastVdrift = -1;
+  target.fTimeLastVdrift = -1;
 
 }
 
 //_____________________________________________________________________________
-void AliTRDdigitizer::Exec(Option_toption)
+void AliTRDdigitizer::Exec(Option_t *option)
 {
   //
   // Executes the merging
@@ -307,7 +399,7 @@ void AliTRDdigitizer::Exec(Option_t* option)
   }
 
   // The AliRoot file is already connected by the manager
-  AliRunLoaderinrl;
+  AliRunLoader *inrl;
   
   if (gAlice) {
     AliDebug(1,"AliRun object found on file.\n");
@@ -323,7 +415,7 @@ void AliTRDdigitizer::Exec(Option_t* option)
   }
                                                                            
   Int_t nInput = fManager->GetNinputs();
-  fMasks = new Int_t[nInput];
+  fMasks       = new Int_t[nInput];
   for (iInput = 0; iInput < nInput; iInput++) {
     fMasks[iInput] = fManager->GetMask(iInput);
   }
@@ -365,15 +457,15 @@ void AliTRDdigitizer::Exec(Option_t* option)
 
     // Check if the input tree exists
     inrl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput));
-    AliLoadergime = inrl->GetLoader("TRDLoader");
+    AliLoader *gime = inrl->GetLoader("TRDLoader");
 
-    TTree * treees =  gime->TreeS();
+    TTree *treees = gime->TreeS();
     if (treees == 0x0) {
       if (gime->LoadSDigits()) {
         AliError(Form("Error Occured while loading S. Digits for input %d.",iInput));
         return;
       }
-      treees =  gime->TreeS();
+      treees = gime->TreeS();
     }
     
     if (treees == 0x0) {
@@ -385,9 +477,11 @@ void AliTRDdigitizer::Exec(Option_t* option)
     sdigitsManager = new AliTRDdigitsManager();
     sdigitsManager->SetSDigits(kTRUE);
     
-    AliRunLoader* rl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput));
-    AliLoader* gimme = rl->GetLoader("TRDLoader");
-    if (!gimme->TreeS()) gimme->LoadSDigits();
+    AliRunLoader *rl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput));
+    AliLoader *gimme = rl->GetLoader("TRDLoader");
+    if (!gimme->TreeS()) {
+      gimme->LoadSDigits();
+    }
     sdigitsManager->ReadDigits(gimme->TreeS());
 
     // Add the s-digits to the input list 
@@ -427,11 +521,10 @@ Bool_t AliTRDdigitizer::Open(const Char_t *file, Int_t nEvent)
   if (!fRunLoader) {
     fRunLoader = AliRunLoader::Open(file,evfoldname,"UPDATE");
   }  
-
   if (!fRunLoader) {
      AliError(Form("Can not open session for file %s.",file));
      return kFALSE;
-   }
+  }
    
   if (!fRunLoader->GetAliRun()) {
     fRunLoader->LoadgAlice();
@@ -448,31 +541,28 @@ Bool_t AliTRDdigitizer::Open(const Char_t *file, Int_t nEvent)
 
   fEvent = nEvent;
 
-  // Import the Trees for the event nEvent in the file
-  //fRunLoader->GetEvent(fEvent);
-  
-  AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
+  AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
   if (!loader) {
     AliError("Can not get TRD loader from Run Loader");
     return kFALSE;
   }
   
   if (InitDetector()) {
-    TTreetree = 0;
+    TTree *tree = 0;
     if (fSDigits) { 
       // If we produce SDigits
       tree = loader->TreeS();
       if (!tree) {
         loader->MakeTree("S");
         tree = loader->TreeS();
-       }
+      }
     }
     else {
       // If we produce Digits
       if (!tree) {
         loader->MakeTree("D");
         tree = loader->TreeD();
-       }
+      }
     }
     return MakeBranch(tree);
   }
@@ -546,7 +636,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
   ///////////////////////////////////////////////////////////////
 
   // Converts number of electrons to fC
-  const Double_t kEl2fC  = 1.602E-19 * 1.0E15; 
+  const Double_t kEl2fC  = 1.602e-19 * 1.0e15; 
 
   ///////////////////////////////////////////////////////////////
 
@@ -557,11 +647,14 @@ Bool_t AliTRDdigitizer::MakeDigits()
   const Int_t kNDict     = AliTRDdigitsManager::kNDict;
 
   // Half the width of the amplification region
-  const Float_t kAmWidth = AliTRDgeometry::AmThick() / 2.;
+  const Float_t kAmWidth = AliTRDgeometry::AmThick() / 2.0;
   // Width of the drift region
   const Float_t kDrWidth = AliTRDgeometry::DrThick();
   
-  Int_t    iRow, iCol, iTime, iPad;
+  Int_t    iRow;
+  Int_t    iCol;
+  Int_t    iTime;
+  Int_t    iPad;
   Int_t    iDict  = 0;
   Int_t    nBytes = 0;
 
@@ -596,7 +689,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
   
   AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance();
   if (!commonParam) {
-    AliError("Could not get common params\n");
+    AliError("Could not get common parameterss\n");
     return kFALSE;
   }
   
@@ -612,11 +705,11 @@ Bool_t AliTRDdigitizer::MakeDigits()
 
   if (simParam->TRFOn()) {
     timeBinTRFend = ((Int_t) (simParam->GetTRFhi() 
-                            * calibration->GetSamplingFrequency())) - 1;
+                  * calibration->GetSamplingFrequency())) - 1;
     AliDebug(1,Form("Sample the TRF up to bin %d\n",timeBinTRFend));
   }
 
-  Float_t elAttachProp = simParam->GetElAttachProp() / 100.; 
+  Float_t elAttachProp = simParam->GetElAttachProp() / 100.0
 
   if (!fGeo) {
     AliError("No geometry defined\n");
@@ -625,11 +718,11 @@ Bool_t AliTRDdigitizer::MakeDigits()
 
   AliDebug(1,"Start creating digits.\n");
 
-  AliLoadergimme = fRunLoader->GetLoader("TRDLoader");
+  AliLoader *gimme = fRunLoader->GetLoader("TRDLoader");
   if (!gimme->TreeH()) {
     gimme->LoadHits();
   }
-  TTreehitTree = gimme->TreeH();
+  TTree *hitTree = gimme->TreeH();
   if (hitTree == 0x0) {
     AliError("Can not get TreeH");
     return kFALSE;
@@ -766,7 +859,8 @@ Bool_t AliTRDdigitizer::MakeDigits()
               continue;
            }
             Float_t tt = driftlength + kAmWidth;
-            if (tt < 0.0 || tt > kDrWidth + 2.*kAmWidth) {
+            if ((tt < 0.0) || 
+                (tt > kDrWidth + 2.0*kAmWidth)) {
               if (iEl == 0) {
                 AliDebug(2,Form("Hit outside of sensitive volume, time (Q = %d)\n"
                                ,((Int_t) q)));
@@ -777,15 +871,15 @@ Bool_t AliTRDdigitizer::MakeDigits()
 
           // Get row and col of unsmeared electron to retrieve drift velocity
           // The pad row (z-direction)
-          Int_t    rowE       = padPlane->GetPadRowNumber(xyz[2]);
+          Int_t    rowE         = padPlane->GetPadRowNumber(xyz[2]);
           if (rowE < 0) continue;
-          Double_t rowOffset  = padPlane->GetPadRowOffset(rowE,xyz[2]);
+          Double_t rowOffset    = padPlane->GetPadRowOffset(rowE,xyz[2]);
 
           // The pad column (rphi-direction)
-         Double_t offsetTilt = padPlane->GetTiltOffset(rowOffset);
-          Int_t    colE       = padPlane->GetPadColNumber(xyz[1]+offsetTilt,rowOffset);
+         Double_t offsetTilt   = padPlane->GetTiltOffset(rowOffset);
+          Int_t    colE         = padPlane->GetPadColNumber(xyz[1]+offsetTilt,rowOffset);
           if (colE < 0) continue;        
-          Double_t colOffset  = padPlane->GetPadColOffset(colE,xyz[1]+offsetTilt);
+          Double_t colOffset    = padPlane->GetPadColOffset(colE,xyz[1]+offsetTilt);
 
           Float_t driftvelocity = calibration->GetVdrift(detector,colE,rowE);
                     
@@ -802,12 +896,12 @@ Bool_t AliTRDdigitizer::MakeDigits()
           
           // Apply the diffusion smearing
           if (simParam->DiffusionOn()) {
-            if (!(Diffusion(driftvelocity, absdriftlength,xyz))) continue;
+            if (!(Diffusion(driftvelocity,absdriftlength,xyz))) continue;
           }
 
           // Apply E x B effects (depends on drift direction)
           if (commonParam->ExBOn()) { 
-            if (!(ExB(driftvelocity, driftlength,xyz))) continue;
+            if (!(ExB(driftvelocity,driftlength,xyz))) continue;
           }
 
           // The electron position after diffusion and ExB in pad coordinates.
@@ -832,7 +926,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
           if (simParam->TimeStructOn()) {
            // Get z-position with respect to anode wire:
             Double_t Z  =  row0 - xyz[2] + simParam->GetAnodeWireOffset();
-           Z -= ((Int_t)(2*Z))/2.0;
+           Z -= ((Int_t)(2 * Z)) / 2.0;
            if (Z > 0.25) {
               Z  = 0.5 - Z;
            }
@@ -840,7 +934,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
             drifttime = TimeStruct(driftvelocity,time0-xyz[0]+kAmWidth,Z);
          } 
           else {
-           // use constant drift velocity
+           // Use constant drift velocity
             drifttime = TMath::Abs(time0 - xyz[0]) / driftvelocity;
          }
 
@@ -908,7 +1002,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
               // Add the signals
               Int_t iCurrentTimeBin = iTimeBin;
               signalOld[iPad]  = signals->GetDataUnchecked(rowE,colPos,iCurrentTimeBin);
-              if( colPos != colE ) {
+              if (colPos != colE) {
                 signalOld[iPad] += padSignal[iPad] * (timeResponse + crossTalk);
               } 
               else {
@@ -960,14 +1054,14 @@ Bool_t AliTRDdigitizer::MakeDigits()
   Int_t iDetEnd = AliTRDgeometry::Ndet();
   for (Int_t iDet = iDetBeg; iDet < iDetEnd; iDet++) {
 
-    Int_t plane       = fGeo->GetPlane(iDet);
-    Int_t sector      = fGeo->GetSector(iDet);
-    Int_t chamber     = fGeo->GetChamber(iDet);
-    Int_t nRowMax     = commonParam->GetRowMax(plane,chamber,sector);
-    Int_t nColMax     = commonParam->GetColMax(plane);
+    Int_t plane      = fGeo->GetPlane(iDet);
+    Int_t sector     = fGeo->GetSector(iDet);
+    Int_t chamber    = fGeo->GetChamber(iDet);
+    Int_t nRowMax    = commonParam->GetRowMax(plane,chamber,sector);
+    Int_t nColMax    = commonParam->GetColMax(plane);
 
-    Double_t *inADC   = new Double_t[nTimeTotal];
-    Double_t *outADC  = new Double_t[nTimeTotal];
+    Double_t *inADC  = new Double_t[nTimeTotal];
+    Double_t *outADC = new Double_t[nTimeTotal];
 
     AliDebug(1,Form("Digitization for chamber %d\n",iDet));
 
@@ -1027,6 +1121,7 @@ Bool_t AliTRDdigitizer::MakeDigits()
           else {
 
             for (iTime = 0; iTime < nTimeTotal; iTime++) {         
+
               Float_t signalAmp = signals->GetDataUnchecked(iRow,iCol,iTime);
 
               // Pad and time coupling
@@ -1040,15 +1135,15 @@ Bool_t AliTRDdigitizer::MakeDigits()
 
               // Add the noise, starting from minus ADC baseline in electrons
               Double_t baselineEl = simParam->GetADCbaseline() * (simParam->GetADCinRange()
-                                                           / simParam->GetADCoutRange())
-                                                           / convert;
+                                                               / simParam->GetADCoutRange())
+                                                               / convert;
               signalAmp  = TMath::Max((Double_t) gRandom->Gaus(signalAmp,simParam->GetNoise())
                                      ,-baselineEl);
               // Convert to mV
               signalAmp *= convert;
               // Add ADC baseline in mV
               signalAmp += simParam->GetADCbaseline() * (simParam->GetADCinRange()
-                                                   / simParam->GetADCoutRange());
+                                                      / simParam->GetADCoutRange());
              // Convert to ADC counts. Set the overflow-bit fADCoutRange if the
              // signal is larger than fADCinRange
               Int_t adc  = 0;
@@ -1057,11 +1152,12 @@ Bool_t AliTRDdigitizer::MakeDigits()
              }
               else {
                 adc = TMath::Nint(signalAmp * (simParam->GetADCoutRange()
-                                           / simParam->GetADCinRange()));
+                                            / simParam->GetADCinRange()));
              }
 
               inADC[iTime]  = adc;
               outADC[iTime] = adc;
+
            }
 
             for (iTime = 0; iTime < nTimeTotal; iTime++) {   
@@ -1092,8 +1188,8 @@ Bool_t AliTRDdigitizer::MakeDigits()
 
     Float_t nPixel = nRowMax * nColMax * nTimeTotal;
     AliDebug(1,Form("Found %d digits in detector %d (%3.0f).\n"
-              ,nDigits,iDet
-              ,100.0 * ((Float_t) nDigits) / nPixel));
+                   ,nDigits,iDet
+                   ,100.0 * ((Float_t) nDigits) / nPixel));
 
     if (fCompress) {
       signals->Compress(1,0);
@@ -1152,26 +1248,26 @@ Bool_t AliTRDdigitizer::ConvertSDigits()
   const Int_t    kNDict = AliTRDdigitsManager::kNDict;
 
   // Converts number of electrons to fC
-  const Double_t kEl2fC = 1.602E-19 * 1.0E15; 
+  const Double_t kEl2fC = 1.602e-19 * 1.0e15; 
 
   Int_t iDict = 0;
   Int_t iRow;
   Int_t iCol;
   Int_t iTime;
 
-  AliTRDSimParamsimParam = AliTRDSimParam::Instance();
+  AliTRDSimParam *simParam = AliTRDSimParam::Instance();
   if (!simParam) {
     AliError("Could not get simulation parameters\n");
     return kFALSE;
   }
   
-  AliTRDCommonParamcommonParam = AliTRDCommonParam::Instance();
+  AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance();
   if (!commonParam) {
     AliError("Could not get common parameters\n");
     return kFALSE;
   }
   
-  AliTRDcalibDBcalibration = AliTRDcalibDB::Instance();
+  AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
   if (!calibration) {
     AliError("Could not get calibration object\n");
     return kFALSE;
@@ -1227,10 +1323,10 @@ Bool_t AliTRDdigitizer::ConvertSDigits()
         for (iTime = 0; iTime < nTimeTotal; iTime++) {
 
           Double_t signal = (Double_t) digitsIn->GetDataUnchecked(iRow,iCol,iTime);
-          signal *= sDigitsScale;
+          signal         *= sDigitsScale;
           Float_t padgain = calibration->GetGainFactor(iDet,iCol,iRow);
           if (padgain <= 0.0) {
-            AliError(Form("Not a valid gain %f, %d %d %d\n", padgain, iDet, iCol, iRow));
+            AliError(Form("Not a valid gain %f, %d %d %d\n",padgain,iDet,iCol,iRow));
           }
 
           signal *= padgain;
@@ -1303,19 +1399,19 @@ Bool_t AliTRDdigitizer::MergeSDigits()
   // Number of track dictionary arrays
   const Int_t kNDict = AliTRDdigitsManager::kNDict;
 
-  AliTRDSimParam*    simParam    = AliTRDSimParam::Instance();
+  AliTRDSimParam    *simParam    = AliTRDSimParam::Instance();
   if (!simParam) {
     AliError("Could not get simulation parameters\n");
     return kFALSE;
   }
   
-  AliTRDCommonParamcommonParam = AliTRDCommonParam::Instance();
+  AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance();
   if (!commonParam) {
     AliError("Could not get common parameters\n");
     return kFALSE;
   }
   
-  AliTRDcalibDB*     calibration = AliTRDcalibDB::Instance();
+  AliTRDcalibDB     *calibration = AliTRDcalibDB::Instance();
   if (!calibration) {
     AliError("Could not get calibration object\n");
     return kFALSE;
@@ -1338,7 +1434,8 @@ Bool_t AliTRDdigitizer::MergeSDigits()
 
   // Loop through the other sets of s-digits
   AliTRDdigitsManager *mergeSDigitsManager;
-  mergeSDigitsManager = (AliTRDdigitsManager *) fSDigitsManagerList->After(fSDigitsManager);
+  mergeSDigitsManager = (AliTRDdigitsManager *) 
+                        fSDigitsManagerList->After(fSDigitsManager);
 
   if (mergeSDigitsManager) {
     AliDebug(1,Form("Merge %d input files.\n",fSDigitsManagerList->GetSize()));
@@ -1357,11 +1454,11 @@ Bool_t AliTRDdigitizer::MergeSDigits()
     // Loop through the detectors
     for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) {
 
-      Int_t plane      = fGeo->GetPlane(iDet);
-      Int_t sector     = fGeo->GetSector(iDet);
-      Int_t chamber    = fGeo->GetChamber(iDet);
-      Int_t nRowMax    = commonParam->GetRowMax(plane,chamber,sector);
-      Int_t nColMax    = commonParam->GetColMax(plane);
+      Int_t plane   = fGeo->GetPlane(iDet);
+      Int_t sector  = fGeo->GetSector(iDet);
+      Int_t chamber = fGeo->GetChamber(iDet);
+      Int_t nRowMax = commonParam->GetRowMax(plane,chamber,sector);
+      Int_t nColMax = commonParam->GetColMax(plane);
 
       // Loop through the pixels of one detector and add the signals
       digitsA = fSDigitsManager->GetDigits(iDet);
@@ -1429,7 +1526,8 @@ Bool_t AliTRDdigitizer::MergeSDigits()
     }    
 
     // The next set of s-digits
-    mergeSDigitsManager = (AliTRDdigitsManager *) fSDigitsManagerList->After(mergeSDigitsManager);
+    mergeSDigitsManager = (AliTRDdigitsManager *) 
+                          fSDigitsManagerList->After(mergeSDigitsManager);
 
   }
 
@@ -1444,7 +1542,9 @@ Bool_t AliTRDdigitizer::SDigits2Digits()
   // Merges the input s-digits and converts them to normal digits
   //
 
-  if (!MergeSDigits()) return kFALSE;
+  if (!MergeSDigits()) {
+    return kFALSE;
+  }
 
   return ConvertSDigits();
 
@@ -1457,7 +1557,7 @@ Bool_t AliTRDdigitizer::WriteDigits() const
   // Writes out the TRD-digits and the dictionaries
   //
 
-  //Write parameters
+  // Write parameters
   fRunLoader->CdGAFile();
 
   // Store the digits and the dictionary in the tree
@@ -1485,7 +1585,7 @@ void AliTRDdigitizer::InitOutput(Int_t iEvent)
     return;
   }
 
-  TTreetree = 0;
+  TTree *tree = 0;
   
   if (fSDigits) { 
     // If we produce SDigits
@@ -1532,8 +1632,8 @@ Double_t AliTRDdigitizer::TimeStruct(Float_t vdrift, Double_t dist, Double_t z)
 
   SampleTimeStruct(vdrift);
   
-  // indices:
-  Int_t r1 = (Int_t)(10*dist);
+  // Indices:
+  Int_t r1 = (Int_t)(10 * dist);
   if (r1 <  0) r1 =  0;
   if (r1 > 37) r1 = 37;
   Int_t r2 = r1 + 1;
@@ -1542,42 +1642,45 @@ Double_t AliTRDdigitizer::TimeStruct(Float_t vdrift, Double_t dist, Double_t z)
   const Int_t kz1 = ((Int_t)(100 * z / 2.5));
   const Int_t kz2 = kz1 + 1;
 
-  if ((r1 <  0) || (r1 > 37) || (kz1 <  0) || (kz1 > 10)) {
+  if ((r1  <  0) || 
+      (r1  > 37) || 
+      (kz1 <  0) || 
+      (kz1 > 10)) {
     AliWarning(Form("Indices out of range: dist=%.2f, z=%.2f, r1=%d, kz1=%d\n"
                    ,dist,z,r1,kz1));
   }
 
-  const Float_t ky111 = fTimeStructInfo.fTimeStruct1[r1+38*kz1];
+  const Float_t ky111 = fTimeStruct1[r1+38*kz1];
   const Float_t ky221 = ((r2 <= 37) && (kz2 <= 10)) 
-                      ? fTimeStructInfo.fTimeStruct1[r2+38*kz2] 
-                      : fTimeStructInfo.fTimeStruct1[37+38*10];
+                      ? fTimeStruct1[r2+38*kz2] 
+                      : fTimeStruct1[37+38*10];
   const Float_t ky121 = (kz2 <= 10)             
-                      ? fTimeStructInfo.fTimeStruct1[r1+38*kz2] 
-                      : fTimeStructInfo.fTimeStruct1[r1+38*10];
+                      ? fTimeStruct1[r1+38*kz2] 
+                      : fTimeStruct1[r1+38*10];
   const Float_t ky211 = (r2 <= 37)              
-                      ? fTimeStructInfo.fTimeStruct1[r2+38*kz1] 
-                      : fTimeStructInfo.fTimeStruct1[37+38*kz1];
+                      ? fTimeStruct1[r2+38*kz1] 
+                      : fTimeStruct1[37+38*kz1];
 
   // 2D Interpolation, lower drift time map
   const Float_t ky11  = (ky211-ky111)*10*dist + ky111 - (ky211-ky111)*r1;
   const Float_t ky21  = (ky221-ky121)*10*dist + ky121 - (ky221-ky121)*r1;
 
-  const Float_t ky112 = fTimeStructInfo.fTimeStruct2[r1+38*kz1];
+  const Float_t ky112 = fTimeStruct2[r1+38*kz1];
   const Float_t ky222 = ((r2 <= 37) && (kz2 <= 10)) 
-                      ? fTimeStructInfo.fTimeStruct2[r2+38*kz2] 
-                      : fTimeStructInfo.fTimeStruct2[37+38*10];
+                      ? fTimeStruct2[r2+38*kz2] 
+                      : fTimeStruct2[37+38*10];
   const Float_t ky122 = (kz2 <= 10)             
-                      ? fTimeStructInfo.fTimeStruct2[r1+38*kz2] 
-                      : fTimeStructInfo.fTimeStruct2[r1+38*10];
+                      ? fTimeStruct2[r1+38*kz2] 
+                      : fTimeStruct2[r1+38*10];
   const Float_t ky212 = (r2 <= 37)              
-                      ? fTimeStructInfo.fTimeStruct2[r2+38*kz1] 
-                      : fTimeStructInfo.fTimeStruct2[37+38*kz1];
+                      ? fTimeStruct2[r2+38*kz1] 
+                      : fTimeStruct2[37+38*kz1];
 
   // 2D Interpolation, larger drift time map
   const Float_t ky12  = (ky212-ky112)*10*dist + ky112 - (ky212-ky112)*r1;
   const Float_t ky22  = (ky222-ky122)*10*dist + ky122 - (ky222-ky122)*r1;
 
-  // dist now is the drift distance to the anode wires (negative if electrons are
+  // Dist now is the drift distance to the anode wires (negative if electrons are
   // between anode wire plane and cathode pad plane)
   dist -= AliTRDgeometry::AmThick() / 2.0;
 
@@ -1590,8 +1693,9 @@ Double_t AliTRDdigitizer::TimeStruct(Float_t vdrift, Double_t dist, Double_t z)
                          : 0.0;
 
   // 1D Interpolation between the values at fVDlo and fVDhi
-  Float_t a = (ktdrift2 - ktdrift1) / (fTimeStructInfo.fVDhi - fTimeStructInfo.fVDlo);
-  Float_t b = ktdrift2 - a * fTimeStructInfo.fVDhi;
+  Float_t a = (ktdrift2 - ktdrift1) 
+            / (fVDhi - fVDlo);
+  Float_t b = ktdrift2 - a * fVDhi;
 
   return a * vdrift + b;
 
@@ -1608,11 +1712,11 @@ void AliTRDdigitizer::SampleTimeStruct(Float_t vdrift)
   // TODO make caching proper, if same timing structure is selected: do not update timestructs!
   
   // Noting to do
-  if (vdrift == fTimeStructInfo.fLastVdrift) {
+  if (vdrift == fTimeLastVdrift) {
     return;
   }
 
-  fTimeStructInfo.fLastVdrift = vdrift;
+  fTimeLastVdrift = vdrift;
   
   // Drift time maps are saved for some drift velocity values (in drift region):
   Float_t  fVDsmp[8];
@@ -2269,128 +2373,138 @@ void AliTRDdigitizer::SampleTimeStruct(Float_t vdrift)
        {1.48122, 1.48219, 1.48482, 1.48991, 1.50030, 1.53991,
         1.52898, 1.52653, 1.53653, 1.57282, 1.82386}};
 
-  if (fTimeStructInfo.fTimeStruct1)  delete [] fTimeStructInfo.fTimeStruct1;
-  fTimeStructInfo.fTimeStruct1  = new Float_t[ktimebin*kZbin];
-
-  if (fTimeStructInfo.fTimeStruct2)  delete [] fTimeStructInfo.fTimeStruct2;
-  fTimeStructInfo.fTimeStruct2  = new Float_t[ktimebin*kZbin];
-
-  for (Int_t ctrt = 0; ctrt<ktimebin; ctrt++) {
-    for (Int_t ctrz = 0; ctrz<kZbin; ctrz++) {
-      if ( vdrift > fVDsmp[6] ) {
-        fTimeStructInfo.fTimeStruct1[ctrt+ctrz*ktimebin] = time2100[ctrt][ctrz];
-        fTimeStructInfo.fTimeStruct2[ctrt+ctrz*ktimebin] = time2200[ctrt][ctrz];            
-        fTimeStructInfo.fVDlo = fVDsmp[6];
-        fTimeStructInfo.fVDhi = fVDsmp[7];
-      } else if ( vdrift > fVDsmp[5] ) {
-        fTimeStructInfo.fTimeStruct1[ctrt+ctrz*ktimebin] = time2000[ctrt][ctrz];
-        fTimeStructInfo.fTimeStruct2[ctrt+ctrz*ktimebin] = time2100[ctrt][ctrz];            
-        fTimeStructInfo.fVDlo = fVDsmp[5];
-        fTimeStructInfo.fVDhi = fVDsmp[6];
-      } else if ( vdrift > fVDsmp[4] ) {
-        fTimeStructInfo.fTimeStruct1[ctrt+ctrz*ktimebin] = time1900[ctrt][ctrz];
-        fTimeStructInfo.fTimeStruct2[ctrt+ctrz*ktimebin] = time2000[ctrt][ctrz];            
-        fTimeStructInfo.fVDlo = fVDsmp[4];
-        fTimeStructInfo.fVDhi = fVDsmp[5];
-      } else if ( vdrift > fVDsmp[3] ) {
-        fTimeStructInfo.fTimeStruct1[ctrt+ctrz*ktimebin] = time1800[ctrt][ctrz];
-        fTimeStructInfo.fTimeStruct2[ctrt+ctrz*ktimebin] = time1900[ctrt][ctrz];            
-        fTimeStructInfo.fVDlo = fVDsmp[3];
-        fTimeStructInfo.fVDhi = fVDsmp[4];
-      } else if ( vdrift > fVDsmp[2] ) {
-        fTimeStructInfo.fTimeStruct1[ctrt+ctrz*ktimebin] = time1700[ctrt][ctrz];
-        fTimeStructInfo.fTimeStruct2[ctrt+ctrz*ktimebin] = time1800[ctrt][ctrz];            
-        fTimeStructInfo.fVDlo = fVDsmp[2];
-        fTimeStructInfo.fVDhi = fVDsmp[3];
-      } else if ( vdrift > fVDsmp[1] ) {
-        fTimeStructInfo.fTimeStruct1[ctrt+ctrz*ktimebin] = time1600[ctrt][ctrz];
-        fTimeStructInfo.fTimeStruct2[ctrt+ctrz*ktimebin] = time1700[ctrt][ctrz];            
-        fTimeStructInfo.fVDlo = fVDsmp[1];
-        fTimeStructInfo.fVDhi = fVDsmp[2];
-      } else if ( vdrift > (fVDsmp[0] - 1.e-5) ) {
-        fTimeStructInfo.fTimeStruct1[ctrt+ctrz*ktimebin] = time1500[ctrt][ctrz];
-        fTimeStructInfo.fTimeStruct2[ctrt+ctrz*ktimebin] = time1600[ctrt][ctrz];            
-        fTimeStructInfo.fVDlo = fVDsmp[0];
-        fTimeStructInfo.fVDhi = fVDsmp[1];
+  if (fTimeStruct1) {
+    delete [] fTimeStruct1;
+  }
+  fTimeStruct1 = new Float_t[ktimebin*kZbin];
+
+  if (fTimeStruct2) {
+    delete [] fTimeStruct2;
+  }
+  fTimeStruct2 = new Float_t[ktimebin*kZbin];
+
+  for (Int_t ctrt = 0; ctrt < ktimebin; ctrt++) {
+    for (Int_t ctrz = 0; ctrz <    kZbin; ctrz++) {
+      if      (vdrift > fVDsmp[6]) {
+        fTimeStruct1[ctrt+ctrz*ktimebin] = time2100[ctrt][ctrz];
+        fTimeStruct2[ctrt+ctrz*ktimebin] = time2200[ctrt][ctrz];            
+        fVDlo = fVDsmp[6];
+        fVDhi = fVDsmp[7];
+      } 
+      else if (vdrift > fVDsmp[5]) {
+        fTimeStruct1[ctrt+ctrz*ktimebin] = time2000[ctrt][ctrz];
+        fTimeStruct2[ctrt+ctrz*ktimebin] = time2100[ctrt][ctrz];            
+        fVDlo = fVDsmp[5];
+        fVDhi = fVDsmp[6];
+      } 
+      else if (vdrift > fVDsmp[4]) {
+        fTimeStruct1[ctrt+ctrz*ktimebin] = time1900[ctrt][ctrz];
+        fTimeStruct2[ctrt+ctrz*ktimebin] = time2000[ctrt][ctrz];            
+        fVDlo = fVDsmp[4];
+        fVDhi = fVDsmp[5];
+      } 
+      else if (vdrift > fVDsmp[3]) {
+        fTimeStruct1[ctrt+ctrz*ktimebin] = time1800[ctrt][ctrz];
+        fTimeStruct2[ctrt+ctrz*ktimebin] = time1900[ctrt][ctrz];            
+        fVDlo = fVDsmp[3];
+        fVDhi = fVDsmp[4];
+      } 
+      else if (vdrift > fVDsmp[2]) {
+        fTimeStruct1[ctrt+ctrz*ktimebin] = time1700[ctrt][ctrz];
+        fTimeStruct2[ctrt+ctrz*ktimebin] = time1800[ctrt][ctrz];            
+        fVDlo = fVDsmp[2];
+        fVDhi = fVDsmp[3];
+      } 
+      else if (vdrift > fVDsmp[1]) {
+        fTimeStruct1[ctrt+ctrz*ktimebin] = time1600[ctrt][ctrz];
+        fTimeStruct2[ctrt+ctrz*ktimebin] = time1700[ctrt][ctrz];            
+        fVDlo = fVDsmp[1];
+        fVDhi = fVDsmp[2];
+      } 
+      else if (vdrift > (fVDsmp[0] - 1.0e-5)) {
+        fTimeStruct1[ctrt+ctrz*ktimebin] = time1500[ctrt][ctrz];
+        fTimeStruct2[ctrt+ctrz*ktimebin] = time1600[ctrt][ctrz];            
+        fVDlo = fVDsmp[0];
+        fVDhi = fVDsmp[1];
       }
     }
   }
+
 }
 
 //_____________________________________________________________________________
 void AliTRDdigitizer::RecalcDiffusion(Float_t vdrift)
 {
-  if (vdrift == fDiffusionInfo.fLastVdrift)
+  //
+  // Recalculates the diffusion parameters
+  //
+
+  if (vdrift == fDiffLastVdrift) {
     return;
+  }
 
-  AliTRDSimParam*    simParam    = AliTRDSimParam::Instance();
+  AliTRDSimParam    *simParam    = AliTRDSimParam::Instance();
   if (!simParam) {
     AliError("Could not get simulation parameters\n");
     return;
   }
   
-  AliTRDCommonParamcommonParam = AliTRDCommonParam::Instance();
+  AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance();
   if (!commonParam) {
     AliError("Could not get common parameters\n");
     return;
   }
   
-  AliTRDcalibDB*     calibration = AliTRDcalibDB::Instance();
+  AliTRDcalibDB     *calibration = AliTRDcalibDB::Instance();
   if (!calibration) {
     AliError("Could not get calibration object\n");
     return;
   }
   
   Float_t field = commonParam->GetField();
-  fDiffusionInfo.fLastVdrift = vdrift;
+  fDiffLastVdrift = vdrift;
   
   // DiffusionL
-  {
-    const Int_t kNb = 5;
-    Float_t p0[kNb] = {  0.007440,  0.007493,  0.007513,  0.007672,  0.007831 };
-    Float_t p1[kNb] = {  0.019252,  0.018912,  0.018636,  0.018012,  0.017343 };
-    Float_t p2[kNb] = { -0.005042, -0.004926, -0.004867, -0.004650, -0.004424 };
-    Float_t p3[kNb] = {  0.000195,  0.000189,  0.000195,  0.000182,  0.000169 };
-
-    Int_t ib = ((Int_t) (10 * (field - 0.15)));
-    ib       = TMath::Max(  0,ib);
-    ib       = TMath::Min(kNb,ib);
-
-    fDiffusionInfo.fDiffusionL = p0[ib] 
-                               + p1[ib] * vdrift
-                               + p2[ib] * vdrift*vdrift
-                               + p3[ib] * vdrift*vdrift*vdrift;
-  }
+  const Int_t kNbL = 5;
+  Float_t p0L[kNbL] = {  0.007440,  0.007493,  0.007513,  0.007672,  0.007831 };
+  Float_t p1L[kNbL] = {  0.019252,  0.018912,  0.018636,  0.018012,  0.017343 };
+  Float_t p2L[kNbL] = { -0.005042, -0.004926, -0.004867, -0.004650, -0.004424 };
+  Float_t p3L[kNbL] = {  0.000195,  0.000189,  0.000195,  0.000182,  0.000169 };
+
+  Int_t ibL = ((Int_t) (10 * (field - 0.15)));
+  ibL       = TMath::Max(   0,ibL);
+  ibL       = TMath::Min(kNbL,ibL);
+
+  fDiffusionL = p0L[ibL] 
+              + p1L[ibL] * vdrift
+              + p2L[ibL] * vdrift*vdrift
+              + p3L[ibL] * vdrift*vdrift*vdrift;
   
   // DiffusionT
-  {
-    const Int_t kNb = 5;
-    Float_t p0[kNb] = {  0.009550,  0.009599,  0.009674,  0.009757,  0.009850 };
-    Float_t p1[kNb] = {  0.006667,  0.006539,  0.006359,  0.006153,  0.005925 };
-    Float_t p2[kNb] = { -0.000853, -0.000798, -0.000721, -0.000635, -0.000541 };
-    Float_t p3[kNb] = {  0.000131,  0.000122,  0.000111,  0.000098,  0.000085 };
-
-    Int_t ib = ((Int_t) (10 * (field - 0.15)));
-    ib       = TMath::Max(  0,ib);
-    ib       = TMath::Min(kNb,ib);
-
-    fDiffusionInfo.fDiffusionT = p0[ib] 
-                               + p1[ib] * vdrift
-                               + p2[ib] * vdrift*vdrift
-                               + p3[ib] * vdrift*vdrift*vdrift;
-  }    
+  const Int_t kNbT = 5;
+  Float_t p0T[kNbT] = {  0.009550,  0.009599,  0.009674,  0.009757,  0.009850 };
+  Float_t p1T[kNbT] = {  0.006667,  0.006539,  0.006359,  0.006153,  0.005925 };
+  Float_t p2T[kNbT] = { -0.000853, -0.000798, -0.000721, -0.000635, -0.000541 };
+  Float_t p3T[kNbT] = {  0.000131,  0.000122,  0.000111,  0.000098,  0.000085 };
+
+  Int_t ibT= ((Int_t) (10 * (field - 0.15)));
+  ibT      = TMath::Max(   0,ibT);
+  ibT      = TMath::Min(kNbT,ibT);
+
+  fDiffusionT = p0T[ibT] 
+              + p1T[ibT] * vdrift
+              + p2T[ibT] * vdrift*vdrift
+              + p3T[ibT] * vdrift*vdrift*vdrift;
 
   // OmegaTau
-  fDiffusionInfo.fOmegaTau = calibration->GetOmegaTau(vdrift);
+  fOmegaTau = calibration->GetOmegaTau(vdrift);
   
   // Lorentzfactor
-  {
-    if (commonParam->ExBOn()) {
-      fDiffusionInfo.fLorentzFactor = 1.0 / (1.0 + fDiffusionInfo.fOmegaTau*fDiffusionInfo.fOmegaTau);
-    }
-    else {
-      fDiffusionInfo.fLorentzFactor = 1.0;
-    }
+  if (commonParam->ExBOn()) {
+    fLorentzFactor = 1.0 / (1.0 + fOmegaTau*fOmegaTau);
+  }
+  else {
+    fLorentzFactor = 1.0;
   }
 
 }
@@ -2405,7 +2519,8 @@ Float_t AliTRDdigitizer::GetDiffusionL(Float_t vdrift)
   //
 
   RecalcDiffusion(vdrift);
-  return fDiffusionInfo.fDiffusionL;
+
+  return fDiffusionL;
 
 }
 
@@ -2419,7 +2534,8 @@ Float_t AliTRDdigitizer::GetDiffusionT(Float_t vdrift)
   //
 
   RecalcDiffusion(vdrift);
-  return fDiffusionInfo.fDiffusionT;
+
+  return fDiffusionT;
 
 }
 
@@ -2433,11 +2549,11 @@ Int_t AliTRDdigitizer::Diffusion(Float_t vdrift, Double_t driftlength, Double_t
   RecalcDiffusion(vdrift);
 
   Float_t driftSqrt = TMath::Sqrt(driftlength);
-  Float_t sigmaT    = driftSqrt * fDiffusionInfo.fDiffusionT;
-  Float_t sigmaL    = driftSqrt * fDiffusionInfo.fDiffusionL;
-  xyz[0] = gRandom->Gaus(xyz[0], sigmaL * GetLorentzFactor(vdrift));
-  xyz[1] = gRandom->Gaus(xyz[1], sigmaT * GetLorentzFactor(vdrift));
-  xyz[2] = gRandom->Gaus(xyz[2], sigmaT);
+  Float_t sigmaT    = driftSqrt * fDiffusionT;
+  Float_t sigmaL    = driftSqrt * fDiffusionL;
+  xyz[0] = gRandom->Gaus(xyz[0],sigmaL * GetLorentzFactor(vdrift));
+  xyz[1] = gRandom->Gaus(xyz[1],sigmaT * GetLorentzFactor(vdrift));
+  xyz[2] = gRandom->Gaus(xyz[2],sigmaT);
 
   return 1;
 
@@ -2451,7 +2567,8 @@ Float_t AliTRDdigitizer::GetLorentzFactor(Float_t vd)
   //
 
   RecalcDiffusion(vd);
-  return fDiffusionInfo.fLorentzFactor;
+
+  return fLorentzFactor;
 
 }
   
@@ -2465,7 +2582,7 @@ Int_t AliTRDdigitizer::ExB(Float_t vdrift, Double_t driftlength, Double_t *xyz)
   RecalcDiffusion(vdrift);
   
   xyz[0] = xyz[0];
-  xyz[1] = xyz[1] + fDiffusionInfo.fOmegaTau * driftlength;
+  xyz[1] = xyz[1] + fOmegaTau * driftlength;
   xyz[2] = xyz[2];
 
   return 1;
index d4fa591e445da0ddb0ff9e498a327f0564f23246..611f98a633a737ce3b7ffc87d32ffd770b411f15 100644 (file)
@@ -5,6 +5,12 @@
 
 /* $Id$ */
 
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+//  Produces digits from the hits information                             //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+
 #include "AliDigitizer.h"
 
 class TFile;
@@ -17,101 +23,90 @@ class AliTRD;
 class AliTRDdigitsManager;
 class AliTRDgeometry;
 
-///////////////////////////////////////////////////////
-//  Produces digits from the hits information        //
-///////////////////////////////////////////////////////
-
 class AliTRDdigitizer : public AliDigitizer {
 
  public:
 
   AliTRDdigitizer();
-  AliTRDdigitizer(const Text_t* name, const Text_t* title);
-  AliTRDdigitizer(AliRunDigitizer *manager, const Text_t* name, const Text_t* title);
+  AliTRDdigitizer(const Text_t *name, const Text_t *title);
+  AliTRDdigitizer(AliRunDigitizer *manager, const Text_t *name, const Text_t *title);
   AliTRDdigitizer(AliRunDigitizer *manager);
   AliTRDdigitizer(const AliTRDdigitizer &d);
-  virtual ~AliTRDdigitizer();
+  virtual         ~AliTRDdigitizer();
   AliTRDdigitizer &operator=(const AliTRDdigitizer &d);
 
-  virtual void         Copy(TObject &d) const;
-  virtual Bool_t       InitDetector();
-  virtual void         Exec(Option_t* option = 0);  
-  virtual Bool_t       Open(const Char_t *file, Int_t nEvent = 0);
-  virtual Bool_t       MakeBranch(TTree* tree) const;
-  virtual Bool_t       MakeDigits();
-  virtual void         AddSDigitsManager(AliTRDdigitsManager *manager);
-  virtual void         DeleteSDigitsManager();
-  virtual Bool_t       ConvertSDigits();
-  virtual Bool_t       MergeSDigits();
-  virtual Bool_t       SDigits2Digits();
-  virtual Bool_t       WriteDigits() const;
-
-          void         InitOutput(Int_t iEvent);
-  virtual void         SetCompress(Int_t c = 1)             { fCompress        = c;   };
-  virtual void         SetSDigits(Int_t v = 1)              { fSDigits         = v;   };
-  virtual void         SetSDigitsScale(Float_t s)           { fSDigitsScale    = s;   };
-  virtual void         SetEvent(Int_t v = 0)                { fEvent           = v;   };
-  virtual void         SetManager(AliTRDdigitsManager *man) { fDigitsManager   = man; };
-  virtual void         SetGeometry(AliTRDgeometry *geo)     { fGeo             = geo; };
-  virtual void         SetMergeSignalOnly(Bool_t m = kTRUE) { fMergeSignalOnly = m;   };
-
-  AliTRDdigitsManager *Digits()                       const { return fDigitsManager; };
-
-  Bool_t               GetCompress()                  const { return fCompress;      };
-  Bool_t               GetSDigits()                   const { return fSDigits;       };
-  Float_t              GetSDigitsScale()              const { return fSDigitsScale;  };
-
-  virtual Double_t     TimeStruct(Float_t vdrift, Double_t time, Double_t z);
-
-          Float_t      GetDiffusionT(Float_t vdrift);
-          Float_t      GetDiffusionL(Float_t vdrift);
-  virtual Int_t        Diffusion(Float_t vdrift, Double_t driftlength, Double_t *xyz);
-
-          Float_t      GetLorentzFactor(Float_t vdrift);
-  virtual Int_t        ExB(Float_t vdrift, Double_t driftlength, Double_t *xyz);  
+  virtual void     Copy(TObject &d) const;
+  virtual Bool_t   InitDetector();
+          void     InitOutput(Int_t iEvent);
+  virtual void     Exec(Option_t *option = 0);  
+  virtual Bool_t   Open(const Char_t *file, Int_t nEvent = 0);
+  virtual Bool_t   MakeBranch(TTree *tree) const;
+  virtual Bool_t   MakeDigits();
+
+  virtual void     AddSDigitsManager(AliTRDdigitsManager *manager);
+  virtual void     DeleteSDigitsManager();
+  virtual Bool_t   ConvertSDigits();
+  virtual Bool_t   MergeSDigits();
+  virtual Bool_t   SDigits2Digits();
+  virtual Bool_t   WriteDigits() const;
+
+  virtual void     SetCompress(Int_t c = 1)             { fCompress        = c;   }
+  virtual void     SetSDigits(Int_t v = 1)              { fSDigits         = v;   }
+  virtual void     SetSDigitsScale(Float_t s)           { fSDigitsScale    = s;   }
+  virtual void     SetEvent(Int_t v = 0)                { fEvent           = v;   }
+  virtual void     SetManager(AliTRDdigitsManager *man) { fDigitsManager   = man; }
+  virtual void     SetGeometry(AliTRDgeometry *geo)     { fGeo             = geo; }
+  virtual void     SetMergeSignalOnly(Bool_t m = kTRUE) { fMergeSignalOnly = m;   }
+
+          Bool_t   GetCompress() const                  { return fCompress;       }
+          Bool_t   GetSDigits() const                   { return fSDigits;        }
+          Float_t  GetSDigitsScale() const              { return fSDigitsScale;   }
+          Float_t  GetDiffusionT(Float_t vdrift);
+          Float_t  GetDiffusionL(Float_t vdrift);
+          Float_t  GetLorentzFactor(Float_t vdrift);
+
+  virtual Double_t TimeStruct(Float_t vdrift, Double_t time, Double_t z);
+  virtual Int_t    Diffusion(Float_t vdrift, Double_t driftlength, Double_t *xyz);
+  virtual Int_t    ExB(Float_t vdrift, Double_t driftlength, Double_t *xyz);  
+
+  AliTRDdigitsManager *Digits() const                   { return fDigitsManager;  }
   
  protected:
 
+          void     SampleTimeStruct(Float_t vdrift);
+          void     RecalcDiffusion(Float_t vdrift);
+
   AliRunLoader        *fRunLoader;          //! Local pointer
   AliTRDdigitsManager *fDigitsManager;      //! Manager for the output digits
   AliTRDdigitsManager *fSDigitsManager;     //! Manager for the summed input s-digits
   TList               *fSDigitsManagerList; //! List of managers of input s-digits
   AliTRD              *fTRD;                //! TRD detector class
   AliTRDgeometry      *fGeo;                //! TRD geometry
-  Int_t                fEvent;              //! Event number
-  Int_t               *fMasks;              //! Masks for the merging
-  Bool_t               fCompress;           //  Switch to keep only compressed data in memory
-  Bool_t               fSDigits;            //  Switch for the summable digits
-  Float_t              fSDigitsScale;       //  Scale factor for the summable digits 
-  Bool_t               fMergeSignalOnly;    //  Merge only detectors that contain a signal
-
-          void         SampleTimeStruct(Float_t vdrift);
-          void         RecalcDiffusion(Float_t vdrift);
+
+          Int_t    fEvent;                  //! Event number
+          Int_t   *fMasks;                  //! Masks for the merging
+          Bool_t   fCompress;               //  Switch to keep only compressed data in memory
+          Bool_t   fSDigits;                //  Switch for the summable digits
+          Float_t  fSDigitsScale;           //  Scale factor for the summable digits 
+          Bool_t   fMergeSignalOnly;        //  Merge only detectors that contain a signal
   
-  struct
-  {
-    Float_t fLastVdrift;                                      //! The structures are valid for fLastVdrift (caching)
-    Float_t fDiffusionT;                                      //! Transverse drift coefficient
-    Float_t fDiffusionL;                                      //! Longitudinal drift coefficient
-    Float_t              fOmegaTau;                           //! Tangens of the Lorentz angle
-    Float_t              fLorentzFactor;                      //! Factor due to Lorentz force
-  } fDiffusionInfo;                                           //! Do not write the structures
-    
-  struct 
-  {
-    Float_t fLastVdrift;                                      //! The structures are valid for fLastVdrift (caching)
-    Float_t             *fTimeStruct1;                        //! Time Structure of Drift Cells
-    Float_t             *fTimeStruct2;                        //! Time Structure of Drift Cells
-    Float_t              fVDlo;                               //! Lower drift velocity, for interpolation
-    Float_t              fVDhi;                               //! Higher drift velocity, for interpolation
-  } fTimeStructInfo;                                          //! Do not write the structures
+          Float_t  fDiffLastVdrift;         //  The structures are valid for fLastVdrift (caching)
+          Float_t  fDiffusionT;             //  Transverse drift coefficient
+          Float_t  fDiffusionL;             //  Longitudinal drift coefficient
+          Float_t  fOmegaTau;               //  Tangens of the Lorentz angle
+          Float_t  fLorentzFactor;          //  Factor due to Lorentz force
+
+          Float_t  fTimeLastVdrift;         //  The structures are valid for fLastVdrift (caching)
+          Float_t *fTimeStruct1;            //  Time Structure of Drift Cells
+          Float_t *fTimeStruct2;            //  Time Structure of Drift Cells
+          Float_t  fVDlo;                   //  Lower drift velocity, for interpolation
+          Float_t  fVDhi;                   //  Higher drift velocity, for interpolation
   
  private:
     
-  virtual Bool_t       Init();
+  virtual Bool_t   Init();
 
-  ClassDef(AliTRDdigitizer,12)               //  Produces TRD-Digits
+  ClassDef(AliTRDdigitizer,13)              //  Produces TRD-Digits
 
 };