TObjArray replaced with TClonesArray in AliITSpList - Typo corrected
[u/mrichter/AliRoot.git] / ITS / AliITSsimulationSPDdubna.cxx
index 0e0e2e4..bf76b68 100644 (file)
 /*
 $Id$
 */
+
 #include <Riostream.h>
-#include <TRandom.h>
 #include <TH1.h>
 #include <TMath.h>
-#include <TString.h>
 #include <TParticle.h>
-
-#include "AliRun.h"
+#include <TRandom.h>
+#include <TString.h>
 #include "AliITS.h"
-#include "AliITShit.h"
+#include "AliITSMapA2.h" 
 #include "AliITSdigitSPD.h"
+#include "AliITSgeom.h"
+#include "AliITShit.h"
 #include "AliITSmodule.h"
-#include "AliITSMapA2.h" 
 #include "AliITSpList.h"
-#include "AliITSsimulationSPDdubna.h"
+#include "AliITSCalibrationSPD.h"
 #include "AliITSsegmentationSPD.h"
-#include "AliITSresponseSPD.h"
+#include "AliITSsimulationSPDdubna.h"
+#include "AliLog.h"
+#include "AliRun.h"
 
 //#define DEBUG
 
@@ -59,13 +61,11 @@ fCoupling(0){
     // Return:
     //    A default constructed AliITSsimulationSPDdubna class.
 
-    if(GetDebug(1)) Info("AliITSsimulationSPDdubda()",
-                         "Calling degault constructor");
+    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
@@ -85,13 +85,13 @@ fCoupling(cup){
     // Return:
     //    A default constructed AliITSsimulationSPDdubna class.
 
-    if(GetDebug(1)) Info("AliITSsimulationSPDdubda",
-                         "Calling degault constructor seg=%p resp=%p cup=%d",
-                         seg,resp,cup);
+    AliDebug(1,
+            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();
 }
@@ -109,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(){
@@ -159,6 +161,23 @@ AliITSsimulationSPDdubna&  AliITSsimulationSPDdubna::operator=(const
     return *this;
 }
 //______________________________________________________________________
+AliITSsimulation&  AliITSsimulationSPDdubna::operator=(const 
+                                           AliITSsimulation &s){
+    //    Assignment operator
+    // Inputs:
+    //    AliITSsimulationSPDdubna &s The original class for which
+    //                                this class is a copy of
+    // Outputs:
+    //    none.
+    // Return:
+
+    if(&s == this) return *this;
+    Error("AliITSsimulationSPDdubna","Not allowed to make a = with "
+          "AliITSsimulationSPDdubna","Using default creater instead");
+
+    return *this;
+}
+//______________________________________________________________________
 void AliITSsimulationSPDdubna::InitSimulationModule(Int_t module, Int_t event){
     //  This function creates maps to build the list of tracks for each
     //  summable digit. Inputs defined by base class.
@@ -170,8 +189,7 @@ void AliITSsimulationSPDdubna::InitSimulationModule(Int_t module, Int_t event){
     //  Returns:
     //    none
 
-    if(GetDebug(1)) Info("InitSimulationModule","(module=%d,event=%d)",
-                         module,event);
+    AliDebug(1,Form("(module=%d,event=%d)",module,event));
     SetModuleNumber(module);
     SetEventNumber(event);
     ClearMap();
@@ -191,11 +209,10 @@ void AliITSsimulationSPDdubna::SDigitiseModule(AliITSmodule *mod,Int_t,
     //    test              //  test returns kTRUE if the module contained hits
     //                      //  test returns kFALSE if it did not contain hits
 
-    if(GetDebug(1)) Info("SDigitiseModule","(mod=%p, ,event=%d)",mod,event);
+    AliDebug(1,Form("(mod=%p, ,event=%d)",mod,event));
     if(!(mod->GetNhits())){
-        if(GetDebug(1)) Info("SDigitiseModule","In event %d module %d there "
-                             "are %d hits returning.",event,
-                             mod->GetIndex(),mod->GetNhits());
+        AliDebug(1,Form("In event %d module %d there are %d hits returning.",
+                       event, mod->GetIndex(),mod->GetNhits()));
         return;// if module has no hits don't create Sdigits
     } // end if
     SetModuleNumber(mod->GetIndex());
@@ -216,15 +233,14 @@ void AliITSsimulationSPDdubna::WriteSDigits(){
     Int_t ix, nix, iz, niz;
     static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
 
-    if(GetDebug(1))Info("WriteSDigits","Writing SDigits for module %d",
-                        GetModuleNumber());
+    AliDebug(1,Form("Writing SDigits for module %d",GetModuleNumber()));
     GetMap()->GetMaxMapIndex(niz, nix);
     for(iz=0; iz<niz; iz++)for(ix=0; ix<nix; ix++){
         if(GetMap()->GetSignalOnly(iz,ix)>0.0){
             aliITS->AddSumDigit(*(GetMap()->GetpListItem(iz,ix)));
-            if(GetDebug(1)){
-                cout <<"AliITSsimulationSPDdubna:WriteSDigits " << iz << "," 
-                     << ix << "," << *(GetMap()->GetpListItem(iz,ix)) << endl;
+           if(AliDebugLevel()>0) {
+             AliDebug(1,Form("%d, %d",iz,ix));
+             cout << *(GetMap()->GetpListItem(iz,ix)) << endl;
             } // end if GetDebug
         } // end if GetMap()->GetSignalOnly(iz,ix)>0.0
     } // end for iz,ix
@@ -240,7 +256,7 @@ void AliITSsimulationSPDdubna::FinishSDigitiseModule(){
     //  Return
     //    none
 
-    if(GetDebug(1)) Info("SDigitiseModule","()");
+    AliDebug(1,"()");
     pListToDigits(); // Charge To Signal both adds noise and
     ClearMap();
     return;
@@ -260,7 +276,7 @@ void AliITSsimulationSPDdubna::DigitiseModule(AliITSmodule *mod,Int_t,
     //  Return:
     //    none.
 
-    if(GetDebug(1)) Info("DigitiseModule","(mod=%p,,)",mod);
+    AliDebug(1,Form("(mod=%p,,)",mod));
     HitToSDigit(mod);
     pListToDigits();
     ClearMap();
@@ -281,15 +297,17 @@ 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();
 
-    if(GetDebug(1)) Info("HitsToSDigits","(mod=%p) fCoupling=%d",
-                         mod,fCoupling);
+    AliDebug(1,Form("(mod=%p) fCoupling=%d",mod,fCoupling));
     if(nhits<=0) return;
     for(h=0;h<nhits;h++){
-        if(GetDebug(1)){
-            cout << "Hits=" << h << "," << *(mod->GetHit(h)) << endl;
-        } // end if GetDebug
+      if(AliDebugLevel()>0) {
+       AliDebug(1,Form("Hits, %d", h));
+       cout << *(mod->GetHit(h)) << endl;
+      } // end if GetDebug
         if(!mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)) continue;
         st = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
         if(st>0.0){
@@ -301,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
@@ -377,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);
@@ -392,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
@@ -437,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.
@@ -450,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
@@ -572,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;
@@ -587,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;
@@ -643,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;
@@ -656,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;