]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSsimulationSSD.cxx
Fix for coverity (Annalisa De Caro).
[u/mrichter/AliRoot.git] / ITS / AliITSsimulationSSD.cxx
index 48de1a28e2b6fc49fcce9eaae4f3f9d3f7eb9367..b28c28803109989f5f936ffa553b04f95ed25b7d 100644 (file)
@@ -21,6 +21,7 @@
 #include <TObjArray.h>
 #include <TRandom.h>
 
+#include <TGeoGlobalMagField.h>
 #include "AliITSmodule.h"
 #include "AliITSMapA2.h"
 #include "AliITSpList.h"
 #include "AliITShit.h"
 #include "AliITSdigitSSD.h"
 #include "AliRun.h"
+#include "AliMagF.h"
 #include "AliITSgeom.h"
 #include "AliITSsimulationSSD.h"
 #include "AliITSTableSSD.h"
+#include <TF1.h>
+#include "AliMathBase.h"
 
+using std::endl;
+using std::cout;
 ClassImp(AliITSsimulationSSD)
 ////////////////////////////////////////////////////////////////////////
 //                                                                    //
@@ -51,7 +57,12 @@ AliITSsimulationSSD::AliITSsimulationSSD():AliITSsimulation(),
 fMapA2(0),
 fIonE(0.0),
 fDifConst(),
-fDriftVel(){
+fDriftVel(),
+fTimeResponse(NULL),
+fLorentz(kFALSE),
+fTanLorAngP(0),
+fTanLorAngN(0)
+{
     //default Constructor
     //Inputs:
     // none.
@@ -67,7 +78,12 @@ AliITSsimulation(dettyp),
 fMapA2(0),
 fIonE(0.0),
 fDifConst(),
-fDriftVel(){
+fDriftVel(),
+fTimeResponse(NULL),
+fLorentz(kFALSE),
+fTanLorAngP(0),
+fTanLorAngN(0)
+{
     // Constructor 
     // Input:
     //   AliITSDetTypeSim    Pointer to the SSD dettype to be used
@@ -76,6 +92,7 @@ fDriftVel(){
     // Return
     //   A standard constructed AliITSsimulationSSD class
 
+  fTimeResponse = new TF1("ftimeresponse",".5*x*exp(1.-.5*x)");
     Init();
 }
 //----------------------------------------------------------------------
@@ -89,13 +106,38 @@ void AliITSsimulationSSD::Init(){
   // Return
   //   none.
   AliITSsegmentationSSD* seg = (AliITSsegmentationSSD*)GetSegmentationModel(2);
+  AliITSSimuParam* simpar = fDetType->GetSimuParam();
   
   SetDriftVelocity(); // use default values in .h file
   SetIonizeE();       // use default values in .h file
   SetDiffConst();     // use default values in .h file
   fpList           = new AliITSpList(2,GetNStrips());
   fMapA2           = new AliITSMapA2(seg);
+  SetLorentzDrift(simpar->GetSSDLorentzDrift());
+  if (fLorentz) SetTanLorAngle();
 }
+
+//______________________________________________________________________
+Bool_t AliITSsimulationSSD::SetTanLorAngle() {
+    // This function set the Tangent of the Lorentz angles. 
+    // output: Bool_t : kTRUE in case of success
+    //
+
+    if(!fDetType) {
+      AliError("AliITSsimulationSPD::SetTanLorAngle: AliITSDetTypeSim* fDetType not set ");
+      return kFALSE;}
+
+    AliITSSimuParam* simpar = fDetType->GetSimuParam();
+    AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
+    if (!fld) AliFatal("The field is not initialized");
+    Double_t bz = fld->SolenoidField();
+
+    fTanLorAngN = TMath::Tan( simpar->LorentzAngleElectron(bz) );
+    fTanLorAngP = TMath::Tan( simpar->LorentzAngleHole(bz) );
+
+    return kTRUE;
+}
+
 //______________________________________________________________________
 AliITSsimulationSSD& AliITSsimulationSSD::operator=(
                                          const AliITSsimulationSSD &s){
@@ -110,6 +152,10 @@ AliITSsimulationSSD& AliITSsimulationSSD::operator=(
   this->fDifConst[1] = s.fDifConst[1];
   this->fDriftVel[0] = s.fDriftVel[0];
   this->fDriftVel[1] = s.fDriftVel[1];
+  this->fTimeResponse = s.fTimeResponse;
+  this->fLorentz   = s.fLorentz;
+  this->fTanLorAngP = s.fTanLorAngP;
+  this->fTanLorAngN = s.fTanLorAngN;
   return *this;
 }
 /*
@@ -131,7 +177,12 @@ AliITSsimulationSSD::AliITSsimulationSSD(const AliITSsimulationSSD &source):
 fMapA2(source.fMapA2),
 fIonE(source.fIonE),
 fDifConst(),
-fDriftVel(){
+fDriftVel(),
+fTimeResponse(source.fTimeResponse),
+fLorentz(source.fLorentz),
+fTanLorAngP(source.fTanLorAngP),
+fTanLorAngN(source.fTanLorAngN)
+{
   // copy constructor
   fDifConst[0] = source.fDifConst[0];
   fDifConst[1] = source.fDifConst[1];
@@ -142,6 +193,7 @@ fDriftVel(){
 AliITSsimulationSSD::~AliITSsimulationSSD() {
   // destructor
   delete fMapA2;
+  delete fTimeResponse;
   //delete fDCS;
 }
 //______________________________________________________________________
@@ -218,6 +270,8 @@ void AliITSsimulationSSD::HitsToAnalogDigits(AliITSmodule *mod,
   Double_t x1=0.0, y1=0.0, z1=0.0;
   Double_t de=0.0;
   Int_t module = mod->GetIndex();
+  Double_t tof = 0.;
+  
   
   AliITSsegmentationSSD* seg = (AliITSsegmentationSSD*)GetSegmentationModel(2);
   
@@ -228,6 +282,7 @@ void AliITSsimulationSSD::HitsToAnalogDigits(AliITSmodule *mod,
   module = mod->GetIndex();
   if ( mod->GetLayer() == 6 ) seg->SetLayer(6);
   if ( mod->GetLayer() == 5 ) seg->SetLayer(5);
+
   for(Int_t i=0; i<nhits; i++) {    
     // LineSegmentL returns 0 if the hit is entering
     // If hits is exiting returns positions of entering and exiting hits
@@ -239,6 +294,16 @@ void AliITSsimulationSSD::HitsToAnalogDigits(AliITSmodule *mod,
       cout << endl;
     } // end if
     if (mod->LineSegmentL(i, x0, x1, y0, y1, z0, z1, de, idtrack)) {
+
+      // Scale down dE/dx according to the hit's TOF wrt to the trigger
+      // Necessary for pileup simulation
+      // EF - 21/04/09
+      tof = mod->GetHit(i)->GetTOF();
+      tof *= 1.E+6; // convert time in microsecond
+      if(tof<2.) de = de * fTimeResponse->Eval(-1.*tof+2.);
+      else de = 0.;
+      //
+
       HitToDigit(module, x0, y0, z0, x1, y1, z1, de,tav);
       if (lasttrack != idtrack || i==(nhits-1)) {
        GetList(idtrack,i,module,pList,tav);
@@ -268,7 +333,15 @@ void AliITSsimulationSSD::HitToDigit(Int_t module, Double_t x0, Double_t y0,
   Double_t tdrift[2] = {0.,0.}; // time of drift
   Double_t w;
   Double_t inf[2], sup[2], par0[2];                 
-  
+  // Set up corrections for Lorentz drift (ExB)
+  Double_t tanLorAngP = fTanLorAngP;
+  Double_t tanLorAngN = fTanLorAngN;
+  if(seg->GetLayer()==6) {
+    tanLorAngP = -1.*fTanLorAngP;
+    tanLorAngN = -1.*fTanLorAngN;
+  }
+
   // Steps in the module are determined "manually" (i.e. No Geant)
   // NumOfSteps divide path between entering and exiting hits in steps 
   Int_t numOfSteps = NumOfSteps(x1, y1, z1, dex, dey, dez);
@@ -299,16 +372,23 @@ void AliITSsimulationSSD::HitToDigit(Int_t module, Double_t x0, Double_t y0,
       y=-y; // Lay6 module has sensor up-side-down!!!
     }
     
-    // w is the coord. perpendicular to the strips
-    //    Float_t xp=x*1.e+4,zp=z*1.e+4; // microns    
-    Float_t xp=x,zp=z; 
-    seg->GetPadTxz(xp,zp);
-
     Int_t k;
     //---------------------------------------------------------
     // Pside
     //------------------------------------------------------------
     k=0;
+
+    // w is the coord. perpendicular to the strips
+    //    Float_t xp=x*1.e+4,zp=z*1.e+4; // microns    
+    Float_t xp=x,zp=z; 
+
+    // correction for the Lorentz's angle
+    if(fLorentz) {
+      Float_t deltaxp = (y+(seg->Dy()*1.0E-4)/2)*tanLorAngP;
+      xp+=deltaxp;  
+    }
+
+    seg->GetPadTxz(xp,zp);
     
     // calculate drift time
     // y is the minimum path
@@ -322,8 +402,7 @@ void AliITSsimulationSSD::HitToDigit(Int_t module, Double_t x0, Double_t y0,
       if(GetDebug(4)) cout << "Dead SSD region, x,z="<<x<<","<<z<<endl;
       return; // There are dead region on the SSD sensitive volume!!!
     } // end if
-    
-      // sigma is the standard deviation of the diffusion gaussian
+    // sigma is the standard deviation of the diffusion gaussian
     if(tdrift[k]<0) return;
     
     sigma[k] = TMath::Sqrt(2*GetDiffConst(k)*tdrift[k]);
@@ -350,6 +429,18 @@ void AliITSsimulationSSD::HitToDigit(Int_t module, Double_t x0, Double_t y0,
     // Nside
     //-------------------------------------------------------
     k=1;
+
+    xp=x; zp=z; 
+
+    // correction for the Lorentz's angle
+    if(fLorentz) {
+      Float_t deltaxn = ((seg->Dy()*1.0E-4)/2-y)*tanLorAngN;
+      xp+=deltaxn;
+    }
+    
+
+    seg->GetPadTxz(xp,zp);
+
     tdrift[1] = ((seg->Dy()*1.0E-4)/2-y)/GetDriftVelocity(1);
     
     //tang[k]=TMath::Tan(tang[k]);
@@ -498,7 +589,7 @@ Float_t AliITSsimulationSSD::F(Float_t av, Float_t x, Float_t s) {
     Float_t sigm2 = sqrt2*s;
     Float_t integral;
 
-    integral = 0.5 * TMath::Erf( (x - av) / sigm2);
+    integral = 0.5 * AliMathBase::ErfFast( (x - av) / sigm2);
     return integral;
 }
 //______________________________________________________________________
@@ -628,7 +719,7 @@ void AliITSsimulationSSD::GetList(Int_t label,Int_t hit,Int_t mod,
     tav->Clear();
 }
 //----------------------------------------------------------------------
-void AliITSsimulationSSD::ChargeToSignal(Int_t module,AliITSpList *pList) {
+void AliITSsimulationSSD::ChargeToSignal(Int_t module,const AliITSpList *pList) {
     // charge to signal
     static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
     Float_t threshold = 0.;
@@ -658,7 +749,7 @@ void AliITSsimulationSSD::ChargeToSignal(Int_t module,AliITSpList *pList) {
 
        // signal is converted in unit of ADC
        signal = res->GetSSDDEvToADC(signal);
-       if(signal>4096.) signal = 4096.;//if exceeding, accumulate last one
+       if(signal>4095.) signal = 4095.;//if exceeding, accumulate last one
 
        // threshold for zero suppression is set on the basis of the noise
        // A good value is 3*sigma_noise
@@ -754,4 +845,3 @@ istream &operator>>(istream &os,AliITSsimulationSSD &source){
 
 
 
-