TObjArray replaced with TClonesArray in AliITSpList - Typo corrected
[u/mrichter/AliRoot.git] / ITS / AliITSsimulationSPDdubna.cxx
index b41629a..bf76b68 100644 (file)
 /*
 $Id$
 */
+
 #include <Riostream.h>
 #include <TH1.h>
 #include <TMath.h>
 #include <TParticle.h>
 #include <TRandom.h>
 #include <TString.h>
-
 #include "AliITS.h"
 #include "AliITSMapA2.h" 
 #include "AliITSdigitSPD.h"
+#include "AliITSgeom.h"
 #include "AliITShit.h"
 #include "AliITSmodule.h"
 #include "AliITSpList.h"
-#include "AliITSresponseSPD.h"
+#include "AliITSCalibrationSPD.h"
 #include "AliITSsegmentationSPD.h"
 #include "AliITSsimulationSPDdubna.h"
 #include "AliLog.h"
@@ -63,9 +64,8 @@ fCoupling(0){
     AliDebug(1,Form("Calling degault constructor"));
 }
 //______________________________________________________________________
-AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(AliITSsegmentation *seg,
-                                                                AliITSresponse *resp,Int_t cup):
-AliITSsimulation(seg,resp),
+AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(AliITSDetTypeSim *dettyp, Int_t cup):
+AliITSsimulation(dettyp),
 fHis(0),
 fSPDname(),
 fCoupling(cup){
@@ -73,7 +73,7 @@ fCoupling(cup){
     // Inputs:
     //    AliITSsegmentation *seg  A pointer to the segmentation class
     //                             to be used for this simulation
-    //    AliITSresponse     *resp A pointer to the responce class to
+    //    AliITSCalibration     *resp A pointer to the responce class to
     //                             be used for this simulation
     //    Int_t              cup   The type of coupling to be used
     //                             =1 uses SetCoupling, =2 uses SetCouplingOld
@@ -86,11 +86,12 @@ fCoupling(cup){
     //    A default constructed AliITSsimulationSPDdubna class.
 
     AliDebug(1,
-            Form("Calling degault constructor seg=%p resp=%p cup=%d",seg,resp,cup));
+            Form("Calling degault constructor cup=%d",cup));
     if(cup==1||cup==2){ // For the moment, remove defusion if Coupling is
         // set.
-        resp->SetTemperature(0.0);
-        resp->SetDistanceOverVoltage(0.0);
+      AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
+      res->SetTemperature(0.0);
+      res->SetDistanceOverVoltage(0.0);
     } // end if
     Init();
 }
@@ -108,7 +109,9 @@ void AliITSsimulationSPDdubna::Init(){
     SetModuleNumber(0);
     SetEventNumber(0);
     SetMap(new AliITSpList(GetNPixelsZ(),GetNPixelsX()));
-    GetResp(0,0)->SetDistanceOverVoltage(kmictocm*GetSeg()->Dy(),50.0);
+    AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
+    AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
+    res->SetDistanceOverVoltage(kmictocm*seg->Dy(),50.0);
 }
 //______________________________________________________________________
 AliITSsimulationSPDdubna::~AliITSsimulationSPDdubna(){
@@ -158,7 +161,7 @@ AliITSsimulationSPDdubna&  AliITSsimulationSPDdubna::operator=(const
     return *this;
 }
 //______________________________________________________________________
-AliITSsimulationSPDdubna&  AliITSsimulationSPDdubna::operator=(const 
+AliITSsimulation&  AliITSsimulationSPDdubna::operator=(const 
                                            AliITSsimulation &s){
     //    Assignment operator
     // Inputs:
@@ -294,7 +297,9 @@ void AliITSsimulationSPDdubna::HitToSDigit(AliITSmodule *mod){
     Int_t idtrack;
     Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0;
     Double_t x,y,z,t,tp,st,dt=0.2,el,sig;
-    Double_t thick = kmictocm*GetSeg()->Dy();
+    AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
+    AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
+    Double_t thick = kmictocm*seg->Dy();
 
     AliDebug(1,Form("(mod=%p) fCoupling=%d",mod,fCoupling));
     if(nhits<=0) return;
@@ -314,22 +319,22 @@ void AliITSsimulationSPDdubna::HitToSDigit(AliITSmodule *mod){
                 x   = x0+x1*tp;
                 y   = y0+y1*tp;
                 z   = z0+z1*tp;
-                if(!(GetSeg()->LocalToDet(x,z,ix,iz))) continue; // outside
-                el  = GetResp(ix,iz)->GeVToCharge((Double_t)(dt*de));
+                if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
+                el  = res->GeVToCharge((Double_t)(dt*de));
                 if(GetDebug(1)){
                     if(el<=0.0) cout<<"el="<<el<<" dt="<<dt
                                     <<" de="<<de<<endl;
                 } // end if GetDebug
-                sig = GetResp(ix,iz)->SigmaDiffusion1D(thick + y);
+                sig = res->SigmaDiffusion1D(thick + y);
                 SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
             } // end for t
         } else { // st == 0.0 deposit it at this point
             x   = x0;
             y   = y0;
             z   = z0;
-            if(!(GetSeg()->LocalToDet(x,z,ix,iz))) continue; // outside
-            el  = GetResp(ix,iz)->GeVToCharge((Double_t)de);
-            sig = GetResp(ix,iz)->SigmaDiffusion1D(thick + y);
+            if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
+            el  = res->GeVToCharge((Double_t)de);
+            sig = res->SigmaDiffusion1D(thick + y);
             SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
         } // end if st>0.0
         // Coupling
@@ -390,6 +395,8 @@ void AliITSsimulationSPDdubna::SpreadCharge(Double_t x0,Double_t z0,
     Int_t ix,iz,ixs,ixe,izs,ize;
     Float_t x,z;
     Double_t x1,x2,z1,z2,s,sp;
+    AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
+
 
     if(GetDebug(4)) Info("SpreadCharge","(x0=%e,z0=%e,ix0=%d,iz0=%d,el=%e,"
                          "sig=%e,t=%d,i=%d)",x0,z0,ix0,iz0,el,sig,t,hi);
@@ -405,17 +412,17 @@ void AliITSsimulationSPDdubna::SpreadCharge(Double_t x0,Double_t z0,
         cout << "sig=" << sig << " sp=" << sp << endl;
     } // end if GetDebug
     ixs = TMath::Max(-knx+ix0,0);
-    ixe = TMath::Min(knx+ix0,GetSeg()->Npx()-1);
+    ixe = TMath::Min(knx+ix0,seg->Npx()-1);
     izs = TMath::Max(-knz+iz0,0);
-    ize = TMath::Min(knz+iz0,GetSeg()->Npz()-1);
+    ize = TMath::Min(knz+iz0,seg->Npz()-1);
     for(ix=ixs;ix<=ixe;ix++) for(iz=izs;iz<=ize;iz++){
-        GetSeg()->DetToLocal(ix,iz,x,z); // pixel center
+        seg->DetToLocal(ix,iz,x,z); // pixel center
         x1  = x;
         z1  = z;
-        x2  = x1 + 0.5*kmictocm*GetSeg()->Dpx(ix); // Upper
-        x1 -= 0.5*kmictocm*GetSeg()->Dpx(ix);  // Lower
-        z2  = z1 + 0.5*kmictocm*GetSeg()->Dpz(iz); // Upper
-        z1 -= 0.5*kmictocm*GetSeg()->Dpz(iz);  // Lower
+        x2  = x1 + 0.5*kmictocm*seg->Dpx(ix); // Upper
+        x1 -= 0.5*kmictocm*seg->Dpx(ix);  // Lower
+        z2  = z1 + 0.5*kmictocm*seg->Dpz(iz); // Upper
+        z1 -= 0.5*kmictocm*seg->Dpz(iz);  // Lower
         x1 -= x0; // Distance from where track traveled
         x2 -= x0; // Distance from where track traveled
         z1 -= z0; // Distance from where track traveled
@@ -450,12 +457,12 @@ void AliITSsimulationSPDdubna::pListToDigits(){
     Double_t sig;
     const Int_t    nmaxtrk=AliITSdigitSPD::GetNTracks();
     static AliITSdigitSPD dig;
-
+    AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
     if(GetDebug(1)) Info("pListToDigits","()");
     for(iz=0; iz<GetNPixelsZ(); iz++) for(ix=0; ix<GetNPixelsX(); ix++){
         // Apply Noise/Dead channals and the like
-        if(GetResp(ix,iz)->IsPixelDead(GetModuleNumber(),ix,iz)) continue;
-        electronics = GetResp(ix,iz)->ApplyBaselineAndNoise();
+        if(res->IsPixelDead(GetModuleNumber(),ix,iz)) continue;
+        electronics = res->ApplyBaselineAndNoise();
         UpdateMapNoise(ix,iz,electronics);
         //
         // Apply Threshold and write Digits.
@@ -463,15 +470,15 @@ void AliITSsimulationSPDdubna::pListToDigits(){
         FillHistograms(ix,iz,sig+electronics);
         if(GetDebug(3)){
             cout<<sig<<"+"<<electronics<<">threshold("<<ix<<","<<iz
-                <<")="<<GetThreshold(ix,iz) <<endl;
+                <<")="<<GetThreshold() <<endl;
         } // end if GetDebug
-        if (sig+electronics <= GetThreshold(ix,iz)) continue;
+        if (sig+electronics <= GetThreshold()) continue;
         dig.SetCoord1(iz);
         dig.SetCoord2(ix);
         dig.SetSignal(1);
         dig.SetSignalSPD((Int_t) GetMap()->GetSignal(iz,ix));
         for(j=0;j<nmaxtrk;j++){
-            if (j<GetMap()->GetNEnteries()) {
+            if (j<GetMap()->GetNEntries()) {
                 dig.SetTrack(j,GetMap()->GetTrack(iz,ix,j));
                 dig.SetHit(j,GetMap()->GetHit(iz,ix,j));
             }else { // Default values
@@ -585,7 +592,7 @@ void AliITSsimulationSPDdubna::SetCoupling(Int_t row, Int_t col, Int_t ntrack,
             j1 += isign;
             //   pulse1 *= couplR; 
             xr = gRandom->Rndm();
-            //if ((j1<0)||(j1>GetNPixelsZ()-1)||(pulse1<GetThreshold(j1,col))){
+            //if ((j1<0)||(j1>GetNPixelsZ()-1)||(pulse1<GetThreshold())){
             if ((j1<0) || (j1>GetNPixelsZ()-1) || (xr>couplR)){
                 j1 = row;
                 flag = 1;
@@ -600,7 +607,7 @@ void AliITSsimulationSPDdubna::SetCoupling(Int_t row, Int_t col, Int_t ntrack,
             j2 += isign;
             // pulse2 *= couplC; 
             xr = gRandom->Rndm();
-            //if((j2<0)||j2>(GetNPixelsX()-1)||pulse2<GetThreshold(row,j2)){
+            //if((j2<0)||j2>(GetNPixelsX()-1)||pulse2<GetThreshold()){
             if ((j2<0) || (j2>GetNPixelsX()-1) || (xr>couplC)){
                 j2 = col;
                 flag = 1;
@@ -656,7 +663,7 @@ void AliITSsimulationSPDdubna::SetCouplingOld(Int_t row, Int_t col,
         do{
             j1 += isign;
             pulse1 *= couplR;
-            if ((j1<0)||(j1>GetNPixelsZ()-1)||(pulse1<GetThreshold(j1,col))){
+            if ((j1<0)||(j1>GetNPixelsZ()-1)||(pulse1<GetThreshold())){
                 pulse1 = GetMap()->GetSignalOnly(row,col);
                 j1 = row;
                 flag = 1;
@@ -669,7 +676,7 @@ void AliITSsimulationSPDdubna::SetCouplingOld(Int_t row, Int_t col,
         do{
             j2 += isign;
             pulse2 *= couplC;
-            if((j2<0)||(j2>(GetNPixelsX()-1))||(pulse2<GetThreshold(row,j2))){
+            if((j2<0)||(j2>(GetNPixelsX()-1))||(pulse2<GetThreshold())){
                 pulse2 = GetMap()->GetSignalOnly(row,col);
                 j2 = col;
                 flag = 1;