]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSsimulationSPD.cxx
New AliPoissonCalculator class
[u/mrichter/AliRoot.git] / ITS / AliITSsimulationSPD.cxx
index 428a2a0fd249fdaf5f7c3cee0655a4b3bddbf260..9c9a4d6b613b74bdb3b333fea48546229e337fdb 100644 (file)
@@ -32,6 +32,7 @@ $Id$
 #include "AliLog.h"
 #include "AliRun.h"
 #include "AliMagF.h"
+#include "AliMathBase.h"
 
 //#define DEBUG
 
@@ -127,8 +128,8 @@ void AliITSsimulationSPD::Init(){
    } else {
        fCoupling=1;
    } // end if
-   //SetLorentzDrift(kTRUE);
-   if (fLorentz) SetTanLorAngle();
+   SetLorentzDrift(simpar->GetSPDLorentzDrift());
+   if (fLorentz) SetTanLorAngle(simpar->GetSPDLorentzHoleWeight());
    //SetStrobeGeneration(kFALSE);
    if (fStrobe) GenerateStrobePhase();
 }
@@ -154,13 +155,11 @@ Bool_t AliITSsimulationSPD::SetTanLorAngle(Double_t WeightHole) {
     }
     Double_t WeightEle=1.-WeightHole;
     AliITSSimuParam* simpar = fDetType->GetSimuParam();
-    Double_t pos[3]={0.,0.,0.};
-    Double_t B[3]={0.,0.,0.};
-    TGeoGlobalMagField::Instance()->Field(pos,B);
-    fTanLorAng = TMath::Tan(WeightHole*simpar->LorentzAngleHole(B[2]) +
-                             WeightEle*simpar->LorentzAngleElectron(B[2]));
-    fTanLorAng*=-1.; // this only for the old geometry
-                      // comment the upper line for the new geometry
+    AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
+    if (!fld) AliFatal("The field is not initialized");
+    Double_t bz = fld->SolenoidField();
+    fTanLorAng = TMath::Tan(WeightHole*simpar->LorentzAngleHole(bz) +
+                             WeightEle*simpar->LorentzAngleElectron(bz));
     return kTRUE;
 }
 //______________________________________________________________________
@@ -627,13 +626,13 @@ void AliITSsimulationSPD::SpreadCharge(Double_t x0,Double_t z0,
        z1 -= z0; // Distance from where track traveled
        z2 -= z0; // Distance from where track traveled
        s   = 0.25; // Correction based on definision of Erfc
-       s  *= TMath::Erfc(sp*x1) - TMath::Erfc(sp*x2);
+       s  *= AliMathBase::ErfcFast(sp*x1) - AliMathBase::ErfcFast(sp*x2);
        if(GetDebug(3)){
            cout <<"el="<<el<<" ix0="<<ix0<<" ix="<<ix<<" x0="<<x<<
                " iz0="<<iz0<<" iz="<<iz<<" z0="<<z<< 
                " sp*x1="<<sp*x1<<" sp*x2="<<sp*x2<<" s="<<s;
        } // end if GetDebug
-       s  *= TMath::Erfc(sp*z1) - TMath::Erfc(sp*z2);
+       s  *= AliMathBase::ErfcFast(sp*z1) - AliMathBase::ErfcFast(sp*z2);
        if(GetDebug(3)){
            cout<<" sp*z1="<<sp*z1<<" sp*z2="<<sp*z2<<" s="<<s<< endl;
        } // end if GetDebug
@@ -676,7 +675,7 @@ void AliITSsimulationSPD::SpreadChargeAsym(Double_t x0,Double_t z0,
 
 
    if(GetDebug(4)) Info("SpreadChargeAsym","(x0=%e,z0=%e,ix0=%d,iz0=%d,el=%e,"
-                        "sig=%e,t=%d,i=%d)",x0,z0,ix0,iz0,el,sigx,sigz,t,hi);
+                        "sigx=%e, sigz=%e, t=%d,i=%d)",x0,z0,ix0,iz0,el,sigx,sigz,t,hi);
    if(sigx<=0.0 || sigz<=0.0) { // if sig<=0 No diffusion to simulate.
        GetMap()->AddSignal(iz0,ix0,t,hi,GetModuleNumber(),el);
        if(GetDebug(2)){
@@ -707,13 +706,13 @@ void AliITSsimulationSPD::SpreadChargeAsym(Double_t x0,Double_t z0,
        z1 -= z0; // Distance from where track traveled
        z2 -= z0; // Distance from where track traveled
        s   = 0.25; // Correction based on definision of Erfc
-       s  *= TMath::Erfc(spx*x1) - TMath::Erfc(spx*x2);
+       s  *= AliMathBase::ErfcFast(spx*x1) - AliMathBase::ErfcFast(spx*x2);
        if(GetDebug(3)){
            cout <<"el="<<el<<" ix0="<<ix0<<" ix="<<ix<<" x0="<<x<<
                " iz0="<<iz0<<" iz="<<iz<<" z0="<<z<< 
                " spx*x1="<<spx*x1<<" spx*x2="<<spx*x2<<" s="<<s;
        } // end if GetDebug
-       s  *= TMath::Erfc(spz*z1) - TMath::Erfc(spz*z2);
+       s  *= AliMathBase::ErfcFast(spz*z1) - AliMathBase::ErfcFast(spz*z2);
        if(GetDebug(3)){
            cout<<" spz*z1="<<spz*z1<<" spz*z2="<<spz*z2<<" s="<<s<< endl;
        } // end if GetDebug
@@ -839,7 +838,7 @@ void AliITSsimulationSPD::CreateHistograms(){
    fSPDname="spd_";
    for(Int_t i=0;i<GetNPixelsZ();i++) {
        Char_t pixelz[4];
-       sprintf(pixelz,"%d",i);
+       snprintf(pixelz,3,"%d",i);
        fSPDname.Append(pixelz);
        fHis->AddAt(new TH1F(fSPDname.Data(),"SPD maps",
                             GetNPixelsX(),0.,(Double_t)GetNPixelsX()),i);