]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSsimulationSDD.cxx
Coding rule violations corrected.
[u/mrichter/AliRoot.git] / ITS / AliITSsimulationSDD.cxx
index 059bfdc4b60bb159e01331860f969816514e7d49..ffdf5dfab3b83ea1f1275c03a43234e1aa24ac53 100644 (file)
@@ -61,16 +61,17 @@ ClassImp(AliITSsimulationSDD)
   //
 //Begin_Html
 /*
-<img src="picts/ITS/AliITShit_Class_Diagram.gif">
-</pre>
-<br clear=left>
-<font size=+2 color=red>
-<p>This show the relasionships between the ITS hit class and the rest of Aliroot.
-</font>
-<pre>
+  <img src="picts/ITS/AliITShit_Class_Diagram.gif">
+  </pre>
+  <br clear=left>
+  <font size=+2 color=red>
+  <p>This show the relasionships between the ITS hit class and the 
+  rest of Aliroot.
+  </font>
+  <pre>
 */
 //End_Html
-//______________________________________________________________________
+ //______________________________________________________________________
 Int_t power(Int_t b, Int_t e) {
     // compute b to the e power, where both b and e are Int_ts.
     Int_t power = 1,i;
@@ -137,27 +138,35 @@ void FastFourierTransform(AliITSetfSDD *alisddetf,Double_t *real,
     return;
 }
 //______________________________________________________________________
-AliITSsimulationSDD::AliITSsimulationSDD() {
+AliITSsimulationSDD::AliITSsimulationSDD():
+AliITSsimulation(),
+fITS(0),
+fHitMap2(0),
+fHitSigMap2(0),
+fHitNoiMap2(0),
+fStream(0),
+fElectronics(0),
+fInZR(0),
+fInZI(0),
+fOutZR(0),
+fOutZI(0),
+fAnodeFire(0),
+fHis(0),
+fD(),
+fT1(),
+fTol(),
+fBaseline(),
+fNoise(),
+fTreeB(0),
+fFileName(),
+fFlag(kFALSE),
+fCheckNoise(kFALSE),
+fCrosstalkFlag(kFALSE),
+fDoFFT(1),
+fNofMaps(0),
+fMaxNofSamples(0),
+fScaleSize(0){
     // Default constructor
-
-    fResponse      = 0;
-    fSegmentation  = 0;
-    fHis           = 0;
-//    fpList         = 0;
-    fHitMap2       = 0;
-    fHitSigMap2    = 0;
-    fHitNoiMap2    = 0;
-    fElectronics   = 0;
-    fStream        = 0;
-    fInZR          = 0;
-    fInZI          = 0;
-    fOutZR         = 0;
-    fOutZI         = 0;
-    fNofMaps       = 0;
-    fMaxNofSamples = 0;
-    fITS           = 0;
-    fTreeB         = 0;
-    fAnodeFire     = 0;
     SetScaleFourier();
     SetPerpendTracksFlag();
     SetCrosstalkFlag();
@@ -185,60 +194,65 @@ AliITSsimulationSDD& AliITSsimulationSDD::operator=(AliITSsimulationSDD &src){
 }
 //______________________________________________________________________
 AliITSsimulationSDD::AliITSsimulationSDD(AliITSsegmentation *seg,
-                                         AliITSresponse *resp){
+                                         AliITSresponse *resp):
+AliITSsimulation(seg,resp),
+fITS(0),
+fHitMap2(0),
+fHitSigMap2(0),
+fHitNoiMap2(0),
+fStream(0),
+fElectronics(0),
+fInZR(0),
+fInZI(0),
+fOutZR(0),
+fOutZI(0),
+fAnodeFire(0),
+fHis(0),
+fD(),
+fT1(),
+fTol(),
+fBaseline(),
+fNoise(),
+fTreeB(0),
+fFileName(),
+fFlag(kFALSE),
+fCheckNoise(kFALSE),
+fCrosstalkFlag(kFALSE),
+fDoFFT(1),
+fNofMaps(0),
+fMaxNofSamples(0),
+fScaleSize(0){
     // Standard Constructor
 
-    fResponse      = 0;
-    fSegmentation  = 0;
-    fHis           = 0;
-//    fpList         = 0;
-    fHitMap2       = 0;
-    fHitSigMap2    = 0;
-    fHitNoiMap2    = 0;
-    fElectronics   = 0;
-    fStream        = 0;
-    fInZR          = 0;
-    fInZI          = 0;
-    fOutZR         = 0;
-    fOutZI         = 0;
-    fNofMaps       = 0;
-    fMaxNofSamples = 0;
-    fITS           = 0;
-    fTreeB         = 0;
-    SetDebug(kFALSE);
-
-    Init((AliITSsegmentationSDD*)seg,(AliITSresponseSDD*)resp);
+    Init();
 }
 //______________________________________________________________________
-void AliITSsimulationSDD::Init(AliITSsegmentationSDD *seg,
-                               AliITSresponseSDD *resp){
+void AliITSsimulationSDD::Init(){
     // Standard Constructor
 
-    fResponse     = resp;
-    fSegmentation = seg;
     SetScaleFourier();
     SetPerpendTracksFlag();
     SetCrosstalkFlag();
     SetDoFFT();
     SetCheckNoise();
 
-    fpList = new AliITSpList( fSegmentation->Npz(),
-                              fScaleSize*fSegmentation->Npx() );
-    fHitSigMap2 = new AliITSMapA2(fSegmentation,fScaleSize,1);
-    fHitNoiMap2 = new AliITSMapA2(fSegmentation,fScaleSize,1);
+    fpList = new AliITSpList( GetSeg()->Npz(),
+                              fScaleSize*GetSeg()->Npx() );
+    fHitSigMap2 = new AliITSMapA2(GetSeg(),fScaleSize,1);
+    fHitNoiMap2 = new AliITSMapA2(GetSeg(),fScaleSize,1);
     fHitMap2 = fHitSigMap2;
 
-    fNofMaps = fSegmentation->Npz();
-    fMaxNofSamples = fSegmentation->Npx();
+    fNofMaps = GetSeg()->Npz();
+    fMaxNofSamples = GetSeg()->Npx();
     fAnodeFire = new Bool_t [fNofMaps];
     
-    Float_t sddLength = fSegmentation->Dx();
-    Float_t sddWidth  = fSegmentation->Dz();
+    Float_t sddLength = GetSeg()->Dx();
+    Float_t sddWidth  = GetSeg()->Dz();
 
     Int_t dummy        = 0;
-    Float_t anodePitch = fSegmentation->Dpz(dummy);
-    Double_t timeStep  = (Double_t)fSegmentation->Dpx(dummy);
-    Float_t driftSpeed = fResponse->DriftSpeed();
+    Float_t anodePitch = GetSeg()->Dpz(dummy);
+    Double_t timeStep  = (Double_t)GetSeg()->Dpx(dummy);
+    Float_t driftSpeed = GetResp()->DriftSpeed();
 
     if(anodePitch*(fNofMaps/2) > sddWidth) {
         Warning("AliITSsimulationSDD",
@@ -253,10 +267,10 @@ void AliITSsimulationSDD::Init(AliITSsegmentationSDD *seg,
     } // end if
 
     fElectronics = new AliITSetfSDD(timeStep/fScaleSize,
-                                    fResponse->Electronics());
+                                    GetResp()->Electronics());
 
     char opt1[20], opt2[20];
-    fResponse->ParamOptions(opt1,opt2);
+    GetResp()->ParamOptions(opt1,opt2);
     fParam = opt2;
     char *same = strstr(opt1,"same");
     if (same) {
@@ -267,7 +281,7 @@ void AliITSsimulationSDD::Init(AliITSsegmentationSDD *seg,
         fBaseline.Set(fNofMaps);
     } // end if
 
-    const char *kopt=fResponse->ZeroSuppOption();
+    const char *kopt=GetResp()->ZeroSuppOption();
     if (strstr(fParam.Data(),"file") ) {
         fD.Set(fNofMaps);
         fT1.Set(fNofMaps);
@@ -288,7 +302,7 @@ void AliITSsimulationSDD::Init(AliITSsegmentationSDD *seg,
         SetCompressParam();
     } // end if else strstr
 
-    Bool_t write = fResponse->OutputOption();
+    Bool_t write = GetResp()->OutputOption();
     if(write && strstr(kopt,"2D")) MakeTreeB();
 
     // call here if baseline does not change by module
@@ -302,13 +316,12 @@ void AliITSsimulationSDD::Init(AliITSsegmentationSDD *seg,
     fInZI  = new Double_t [fScaleSize*fMaxNofSamples];
     fOutZR = new Double_t [fScaleSize*fMaxNofSamples];
     fOutZI = new Double_t [fScaleSize*fMaxNofSamples];  
-
 }
 //______________________________________________________________________
 AliITSsimulationSDD::~AliITSsimulationSDD() { 
     // destructor
 
-//    delete fpList;
+    //    delete fpList;
     delete fHitSigMap2;
     delete fHitNoiMap2;
     delete fStream;
@@ -343,7 +356,7 @@ void AliITSsimulationSDD::ClearMaps() {
     fHitNoiMap2->ClearMap();
 }
 //______________________________________________________________________
-void AliITSsimulationSDD::SDigitiseModule( AliITSmodule *mod, Int_t md, Int_t ev){
+void AliITSsimulationSDD::SDigitiseModule(AliITSmodule *mod,Int_t md,Int_t ev){
     // digitize module using the "slow" detector simulator creating
     // summable digits.
 
@@ -361,23 +374,24 @@ void AliITSsimulationSDD::SDigitiseModule( AliITSmodule *mod, Int_t md, Int_t ev
     ClearMaps();
 }
 //______________________________________________________________________
-Bool_t AliITSsimulationSDD::AddSDigitsToModule( TClonesArray *pItemArray, Int_t mask ) {
+Bool_t AliITSsimulationSDD::AddSDigitsToModule(TClonesArray *pItemArray,
+                                               Int_t mask ) {
     // Add Summable digits to module maps.
     Int_t    nItems = pItemArray->GetEntries();
-    Double_t maxadc = fResponse->MaxAdc();
-    //Bool_t sig = kFALSE;
+    Double_t maxadc = GetResp()->MaxAdc();
+    Bool_t sig = kFALSE;
     
     // cout << "Adding "<< nItems <<" SDigits to module " << fModule << endl;
     for( Int_t i=0; i<nItems; i++ ) {
         AliITSpListItem * pItem = (AliITSpListItem *)(pItemArray->At( i ));
         if( pItem->GetModule() != fModule ) {
-            Error( "AliITSsimulationSDD",
-                   "Error reading, SDigits module %d != current module %d: exit\n",
-                    pItem->GetModule(), fModule );
-            return kFALSE;
+            Error( "AliITSsimulationSDD","Error reading, SDigits module "
+                   "%d != current module %d: exit",
+                   pItem->GetModule(), fModule );
+            return sig;
         } // end if
 
-      //  if(pItem->GetSignal()>0.0 ) sig = kTRUE;
+        if(pItem->GetSignal()>0.0 ) sig = kTRUE;
         
         fpList->AddItemTo( mask, pItem ); // Add SignalAfterElect + noise
         AliITSpListItem * pItem2 = fpList->GetpListItem( pItem->GetIndex() );
@@ -389,7 +403,7 @@ Bool_t AliITSsimulationSDD::AddSDigitsToModule( TClonesArray *pItemArray, Int_t
         fHitMap2->SetHit( ia, it, sigAE );
         fAnodeFire[ia] = kTRUE;
     }
-    return kTRUE;
+    return sig;
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::FinishSDigitiseModule() {
@@ -433,7 +447,6 @@ void AliITSsimulationSDD::DigitiseModule(AliITSmodule *mod,Int_t md,Int_t ev){
             fpList->AddItemTo( 0, &pItemTmp2 );
         }
     }
-
     FinishDigits();
     ClearMaps();
 }
@@ -444,32 +457,33 @@ void AliITSsimulationSDD::FinishDigits() {
     ApplyDeadChannels();
     if( fCrosstalkFlag ) ApplyCrosstalk();
 
-    const char *kopt = fResponse->ZeroSuppOption();
+    const char *kopt = GetResp()->ZeroSuppOption();
     ZeroSuppression( kopt );
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::HitsToAnalogDigits( AliITSmodule *mod ) {
     // create maps to build the lists of tracks for each digit
 
-    TObjArray *fHits    = mod->GetHits();
-    Int_t      nhits    = fHits->GetEntriesFast();
-//    Int_t      arg[6]   = {0,0,0,0,0,0};
+    TObjArray *hits     = mod->GetHits();
+    Int_t      nhits    = hits->GetEntriesFast();
+    //    Int_t      arg[6]   = {0,0,0,0,0,0};
     Int_t    dummy      = 0;
     Int_t    nofAnodes  = fNofMaps/2;
-    Float_t  sddLength  = fSegmentation->Dx();
-    Float_t  sddWidth   = fSegmentation->Dz();
-    Float_t  anodePitch = fSegmentation->Dpz(dummy);
-    Float_t  timeStep   = fSegmentation->Dpx(dummy);
-    Float_t  driftSpeed = fResponse->DriftSpeed();
-    Float_t  maxadc     = fResponse->MaxAdc();    
-    Float_t  topValue   = fResponse->DynamicRange();
-    Float_t  cHloss     = fResponse->ChargeLoss();
+    Float_t  sddLength  = GetSeg()->Dx();
+    Float_t  sddWidth   = GetSeg()->Dz();
+    Float_t  anodePitch = GetSeg()->Dpz(dummy);
+    Float_t  timeStep   = GetSeg()->Dpx(dummy);
+    Float_t  driftSpeed = GetResp()->DriftSpeed();
+    Float_t  maxadc     = GetResp()->MaxAdc();    
+    Float_t  topValue   = GetResp()->DynamicRange();
+    Float_t  cHloss     = GetResp()->ChargeLoss();
     Float_t  norm       = maxadc/topValue;
-    Float_t  dfCoeff, s1; fResponse->DiffCoeff(dfCoeff,s1); // Signal 2d Shape
+    Double_t dfCoeff, s1; GetResp()->DiffCoeff(dfCoeff,s1); // Signal 2d Shape
     Double_t eVpairs    = 3.6;  // electron pair energy eV.
-    Float_t  nsigma     = fResponse->NSigmaIntegration(); //
-    Int_t    nlookups   = fResponse->GausNLookUp();       //
-    Float_t  jitter     = ((AliITSresponseSDD*)fResponse)->JitterError(); // 
+                                // GetResp()->GetGeVToCharge()/1.0E8; //2.778
+    Float_t  nsigma     = GetResp()->NSigmaIntegration(); //
+    Int_t    nlookups   = GetResp()->GausNLookUp();       //
+    Float_t  jitter     = ((AliITSresponseSDD*)GetResp())->JitterError(); // 
 
     // Piergiorgio's part (apart for few variables which I made float
     // when i thought that can be done
@@ -515,7 +529,7 @@ void AliITSsimulationSDD::HitsToAnalogDigits( AliITSmodule *mod ) {
     Double_t aExpo;          // exponent of Gaussian anode direction
     Double_t timeAmplitude;  // signal amplitude in time direction
     Double_t tExpo;          // exponent of Gaussian time direction
-//  Double_t tof;            // Time of flight in ns of this step.    
+    //  Double_t tof;            // Time of flight in ns of this step.    
 
     for(ii=0; ii<nhits; ii++) {
         if(!mod->LineSegmentL(ii,xL[0],dxL[0],xL[1],dxL[1],xL[2],dxL[2],
@@ -525,17 +539,17 @@ void AliITSsimulationSDD::HitsToAnalogDigits( AliITSmodule *mod ) {
         hitDetector = mod->GetDet();
         //tof         = 1.E+09*(mod->GetHit(ii)->GetTOF()); // tof in ns.
         //if(tof>sddLength/driftSpeed) continue; // hit happed too late.
-
+        
         // scale path to simulate a perpendicular track
         // continue if the particle did not lose energy
         // passing through detector
         if (!depEnergy) {
-         if(GetDebug()){ 
-            Warning("HitsToAnalogDigits", 
-                    "fTrack = %d hit=%d module=%d This particle has"
-                    " passed without losing energy!",
-                    itrack,ii,mod->GetIndex());
-         }
+            if(GetDebug()){ 
+                Warning("HitsToAnalogDigits", 
+                        "fTrack = %d hit=%d module=%d This particle has"
+                        " passed without losing energy!",
+                        itrack,ii,mod->GetIndex());
+            }
             continue;
         } // end if !depEnergy
 
@@ -546,13 +560,13 @@ void AliITSsimulationSDD::HitsToAnalogDigits( AliITSmodule *mod ) {
         if(drPath < 0) drPath = -drPath;
         drPath = sddLength-drPath;
         if(drPath < 0) {
-         if(GetDebug()){ // this should be fixed at geometry level
-            Warning("HitsToAnalogDigits",
-                    "negative drift path drPath=%e sddLength=%e dxL[0]=%e "
-                    "xL[0]=%e",
-                    drPath,sddLength,dxL[0],xL[0]);
-         }
-         continue;
+            if(GetDebug()){ // this should be fixed at geometry level
+                Warning("HitsToAnalogDigits",
+                        "negative drift path drPath=%e sddLength=%e dxL[0]=%e "
+                        "xL[0]=%e",
+                        drPath,sddLength,dxL[0],xL[0]);
+            }
+            continue;
         } // end if drPath < 0
 
         // Compute number of segments to brake step path into
@@ -579,11 +593,12 @@ void AliITSsimulationSDD::HitsToAnalogDigits( AliITSmodule *mod ) {
             driftPath = sddLength-driftPath;
             detector  = 2*(hitDetector-1) + iWing;
             if(driftPath < 0) {
-              if(GetDebug()){ // this should be fixed at geometry level
-                Warning("HitsToAnalogDigits","negative drift path "
-                        "driftPath=%e sddLength=%e avDrft=%e dxL[0]=%e "
-                        "xL[0]=%e",driftPath,sddLength,avDrft,dxL[0],xL[0]);
-             }
+                if(GetDebug()){ // this should be fixed at geometry level
+                    Warning("HitsToAnalogDigits","negative drift path "
+                            "driftPath=%e sddLength=%e avDrft=%e dxL[0]=%e "
+                            "xL[0]=%e",driftPath,sddLength,avDrft,dxL[0],
+                            xL[0]);
+                }
                 continue;
             } // end if driftPath < 0
 
@@ -603,9 +618,9 @@ void AliITSsimulationSDD::HitsToAnalogDigits( AliITSmodule *mod ) {
             //   Anode
             xAnode = 10000.*(avAnode)/anodePitch + nofAnodes/2;  // +1?
             if(xAnode*anodePitch > sddWidth || xAnode*anodePitch < 0.) 
-                          Warning("HitsToAnalogDigits",
-                                  "Exceedubg sddWidth=%e Z = %e",
-                                  sddWidth,xAnode*anodePitch);
+                Warning("HitsToAnalogDigits",
+                        "Exceedubg sddWidth=%e Z = %e",
+                        sddWidth,xAnode*anodePitch);
             iAnode = (Int_t) (1.+xAnode); // xAnode?
             if(iAnode < 1 || iAnode > nofAnodes) {
                 Warning("HitToAnalogDigits","Wrong iAnode: 1<%d>%d",
@@ -622,10 +637,10 @@ void AliITSsimulationSDD::HitsToAnalogDigits( AliITSmodule *mod ) {
             sigT       = sigA/driftSpeed;
             // Peak amplitude in nanoAmpere
             amplitude  = fScaleSize*160.*depEnergy/
-                                 (timeStep*eVpairs*2.*acos(-1.)*sigT*sigA);
+                (timeStep*eVpairs*2.*acos(-1.)*sigT*sigA);
             amplitude *= timeStep/25.; // WARNING!!!!! Amplitude scaling to 
-                                       // account for clock variations 
-                                       // (reference value: 40 MHz)
+            // account for clock variations 
+            // (reference value: 40 MHz)
             chargeloss = 1.-cHloss*driftPath/1000;
             amplitude *= chargeloss;
             width  = 2.*nsigma/(nlookups-1);
@@ -651,13 +666,13 @@ void AliITSsimulationSDD::HitsToAnalogDigits( AliITSmodule *mod ) {
             jamax = (iAnode + anodeWindow/ndiv)*fScaleSize*nsplit;
             if(jamin <= 0) jamin = 1;
             if(jamax > fScaleSize*nofAnodes*nsplit) 
-                                         jamax = fScaleSize*nofAnodes*nsplit;
+                jamax = fScaleSize*nofAnodes*nsplit;
             // jtmin and jtmax are Hard-wired
             jtmin = (Int_t)(timeSample-timeWindow*nmul-1)*nsplit+1;
             jtmax = (Int_t)(timeSample+timeWindow*nmul)*nsplit;
             if(jtmin <= 0) jtmin = 1;
             if(jtmax > fScaleSize*fMaxNofSamples*nsplit) 
-                                      jtmax = fScaleSize*fMaxNofSamples*nsplit;
+                jtmax = fScaleSize*fMaxNofSamples*nsplit;
             // Spread the charge in the anode-time window
             for(ka=jamin; ka <=jamax; ka++) {
                 ia = (ka-1)/(fScaleSize*nsplit) + 1;
@@ -670,7 +685,7 @@ void AliITSsimulationSDD::HitsToAnalogDigits( AliITSmodule *mod ) {
                 if(TMath::Abs(aExpo) > nsigma)  anodeAmplitude = 0.;
                 else {
                     dummy          = (Int_t) ((aExpo+nsigma)/width);
-                    anodeAmplitude = amplitude*fResponse->GausLookUp(dummy);
+                    anodeAmplitude = amplitude*GetResp()->GausLookUp(dummy);
                 } // end if TMath::Abs(aEspo) > nsigma
                 // index starts from 0
                 index = ((detector+1)%2)*nofAnodes+ia-1;
@@ -681,38 +696,37 @@ void AliITSsimulationSDD::HitsToAnalogDigits( AliITSmodule *mod ) {
                         continue;
                     } // end if 
                     if(it>fScaleSize*fMaxNofSamples)
-                                                it = fScaleSize*fMaxNofSamples;
+                        it = fScaleSize*fMaxNofSamples;
                     tExpo    = (tStep*(kt-0.5)-tConst);
                     if(TMath::Abs(tExpo) > nsigma) timeAmplitude = 0.;
                     else {
                         dummy         = (Int_t) ((tExpo+nsigma)/width);
                         timeAmplitude = anodeAmplitude*
-                                        fResponse->GausLookUp(dummy);
+                            GetResp()->GausLookUp(dummy);
                     } // end if TMath::Abs(tExpo) > nsigma
                     // build the list of Sdigits for this module        
-//                    arg[0]         = index;
-//                    arg[1]         = it;
-//                    arg[2]         = itrack; // track number
-//                    arg[3]         = ii-1; // hit number.
+                    //                    arg[0]     = index;
+                    //                    arg[1]     = it;
+                    //                    arg[2]     = itrack; // track number
+                    //                    arg[3]     = ii-1; // hit number.
                     timeAmplitude *= norm;
                     timeAmplitude *= 10;
-//                    ListOfFiredCells(arg,timeAmplitude,alst,padr);
+                    //         ListOfFiredCells(arg,timeAmplitude,alst,padr);
                     Double_t charge = timeAmplitude;
                     charge += fHitMap2->GetSignal(index,it-1);
                     fHitMap2->SetHit(index, it-1, charge);
                     fpList->AddSignal(index,it-1,itrack,ii-1,
-                                     mod->GetIndex(),timeAmplitude);
+                                      mod->GetIndex(),timeAmplitude);
                     fAnodeFire[index] = kTRUE;                 
                 } // end if anodeAmplitude and loop over time in window
             } // loop over anodes in window
         } // end loop over "sub-hits"
     } // end loop over hits
 }
-
 /*
 //______________________________________________________________________
 void AliITSsimulationSDD::ListOfFiredCells(Int_t *arg,Double_t timeAmplitude,
-                                          TObjArray *alist,TClonesArray *padr){
+                                          TObjArray *alist,TClonesArray *padr){
     // Returns the list of "fired" cells.
 
     Int_t index     = arg[0];
@@ -743,7 +757,7 @@ void AliITSsimulationSDD::ListOfFiredCells(Int_t *arg,Double_t timeAmplitude,
         trinfo(0) = (Float_t)idtrack;
         trinfo(1) = (Float_t)idhit;
         trinfo(2) = (Float_t)timeAmplitude;
-
+      
         alist->AddAtAndExpand(new AliITSTransientDigit(phys,digits),counter);
         fHitMap1->SetHit(index, it, counter);
         counter++;
@@ -782,23 +796,23 @@ void AliITSsimulationSDD::ListOfFiredCells(Int_t *arg,Double_t timeAmplitude,
             trlist->Add(&trinfo);
         } // end if lasttrack==idtrack
 
-#ifdef print
-        // check the track list - debugging
-        Int_t trk[20], htrk[20];
-        Float_t chtrk[20];  
-        Int_t nptracks = trlist->GetEntriesFast();
-        if (nptracks > 2) {
-            Int_t tr;
-            for (tr=0;tr<nptracks;tr++) {
-                TVector *pptrkp = (TVector*)trlist->At(tr);
-                TVector &pptrk  = *pptrkp;
-                trk[tr]   = Int_t(pptrk(0));
-                htrk[tr]  = Int_t(pptrk(1));
-                chtrk[tr] = (pptrk(2));
-                cout << "nptracks "<<nptracks << endl;
-            } // end for tr
-        } // end if nptracks
-#endif
+        if(GetDebug()){
+            // check the track list - debugging
+            Int_t trk[20], htrk[20];
+            Float_t chtrk[20];  
+            Int_t nptracks = trlist->GetEntriesFast();
+            if (nptracks > 2) {
+                Int_t tr;
+                for (tr=0;tr<nptracks;tr++) {
+                    TVector *pptrkp = (TVector*)trlist->At(tr);
+                    TVector &pptrk  = *pptrkp;
+                    trk[tr]   = Int_t(pptrk(0));
+                    htrk[tr]  = Int_t(pptrk(1));
+                    chtrk[tr] = (pptrk(2));
+                    cout << "nptracks "<<nptracks << endl;
+                } // end for tr
+            } // end if nptracks
+        } // end if GetDebug()
     } //  end if pdigit
 
     // update counter and countadr for next call.
@@ -806,7 +820,6 @@ void AliITSsimulationSDD::ListOfFiredCells(Int_t *arg,Double_t timeAmplitude,
     arg[5] = countadr;
 }
 */
-
 //____________________________________________
 void AliITSsimulationSDD::AddDigit( Int_t i, Int_t j, Int_t signal ) {
     // Adds a Digit.
@@ -817,7 +830,6 @@ void AliITSsimulationSDD::AddDigit( Int_t i, Int_t j, Int_t signal ) {
     Float_t phys;
     Float_t * charges = new Float_t[size];
 
-//    if( fResponse->Do10to8() ) signal = Convert8to10( signal ); 
     digits[0] = i;
     digits[1] = j;
     digits[2] = signal;
@@ -843,7 +855,7 @@ void AliITSsimulationSDD::AddDigit( Int_t i, Int_t j, Int_t signal ) {
             tracks[l]  = -3;
             hits[l]    = -1;
             charges[l] = 0.0;
-       }// end for if
+        }// end for if
     }
 
     fITS->AddSimDigit( 1, phys, digits, tracks, hits, charges ); 
@@ -851,26 +863,25 @@ void AliITSsimulationSDD::AddDigit( Int_t i, Int_t j, Int_t signal ) {
     delete [] hits;
     delete [] charges;
 }
-
 //______________________________________________________________________
 void AliITSsimulationSDD::ChargeToSignal(Bool_t bAddNoise) {
     // add baseline, noise, electronics and ADC saturation effects
 
     char opt1[20], opt2[20];
-    fResponse->ParamOptions(opt1,opt2);
+    GetResp()->ParamOptions(opt1,opt2);
     char *read = strstr(opt1,"file");
-    Float_t baseline, noise; 
+    Double_t baseline, noise; 
 
     if (read) {
         static Bool_t readfile=kTRUE;
         //read baseline and noise from file
         if (readfile) ReadBaseline();
         readfile=kFALSE;
-    } else fResponse->GetNoiseParam(noise,baseline);
+    } else GetResp()->GetNoiseParam(noise,baseline);
 
     Float_t contrib=0;
     Int_t i,k,kk;
-    Float_t maxadc = fResponse->MaxAdc();    
+    Float_t maxadc = GetResp()->MaxAdc();    
     if(!fDoFFT) {
         for (i=0;i<fNofMaps;i++) {
             if( !fAnodeFire[i] ) continue;
@@ -932,12 +943,12 @@ void AliITSsimulationSDD::ChargeToSignal(Bool_t bAddNoise) {
             fHitMap2->SetHit(i,k,newcont1);
         } // end for k
     } // end for i loop over anodes
-  return;
+    return;
 }
 //____________________________________________________________________
 void AliITSsimulationSDD::ApplyDeadChannels() {    
     // Set dead channel signal to zero
-    AliITSresponseSDD * response = (AliITSresponseSDD *)fResponse;
+    AliITSresponseSDD * response = (AliITSresponseSDD *)GetResp();
     
     // nothing to do
     if( response->GetDeadModules() == 0 && 
@@ -947,7 +958,7 @@ void AliITSsimulationSDD::ApplyDeadChannels() {
     
     static AliITS *iTS = (AliITS*)gAlice->GetModule( "ITS" );
 
-    Int_t fMaxNofSamples = fSegmentation->Npx();    
+    Int_t fMaxNofSamples = GetSeg()->Npx();    
     AliITSgeom *geom = iTS->GetITSgeom();
     Int_t firstSDDMod = geom->GetStartDet( 1 );
     // loop over wings
@@ -958,8 +969,8 @@ void AliITSsimulationSDD::ApplyDeadChannels() {
                 Float_t Gain = response->Gain( mod, u, v );
                 for( Int_t k=0; k<fMaxNofSamples; k++ ) {
                     Int_t i = j*response->Chips()*response->Channels() +
-                              u*response->Channels() + 
-                              v;
+                        u*response->Channels() + 
+                        v;
                     Double_t signal =  Gain * fHitMap2->GetSignal( i, k );
                     fHitMap2->SetHit( i, k, signal );  ///
                 }
@@ -970,9 +981,9 @@ void AliITSsimulationSDD::ApplyDeadChannels() {
 void AliITSsimulationSDD::ApplyCrosstalk() {
     // function add the crosstalk effect to signal
     // temporal function, should be checked...!!!
-    
-    Int_t fNofMaps = fSegmentation->Npz();
-    Int_t fMaxNofSamples = fSegmentation->Npx();
+
+    Int_t fNofMaps = GetSeg()->Npz();
+    Int_t fMaxNofSamples = GetSeg()->Npx();
 
     // create and inizialice crosstalk map
     Float_t* ctk = new Float_t[fNofMaps*fMaxNofSamples+1];
@@ -981,10 +992,10 @@ void AliITSsimulationSDD::ApplyCrosstalk() {
         return;
     }
     memset( ctk, 0, sizeof(Float_t)*(fNofMaps*fMaxNofSamples+1) );
-    
-    Float_t noise, baseline;
-    fResponse->GetNoiseParam( noise, baseline );
-    
+
+    Double_t noise, baseline;
+    GetResp()->GetNoiseParam( noise, baseline );
+
     for( Int_t z=0; z<fNofMaps; z++ ) {
         Bool_t on = kFALSE;
         Int_t tstart = 0;
@@ -1018,9 +1029,9 @@ void AliITSsimulationSDD::ApplyCrosstalk() {
                         for( Int_t i=tstart; i<tstop; i++ ) {   
                             if( i > 2 && i < fMaxNofSamples-2 )
                                 dev[i] = -0.2*fHitMap2->GetSignal( z,i-2 ) 
-                                         -0.1*fHitMap2->GetSignal( z,i-1 ) 
-                                         +0.1*fHitMap2->GetSignal( z,i+1 ) 
-                                         +0.2*fHitMap2->GetSignal( z,i+2 );
+                                    -0.1*fHitMap2->GetSignal( z,i-1 ) 
+                                    +0.1*fHitMap2->GetSignal( z,i+1 ) 
+                                    +0.2*fHitMap2->GetSignal( z,i+2 );
                         }
                         
                         // add crosstalk contribution to neibourg anodes  
@@ -1029,7 +1040,7 @@ void AliITSsimulationSDD::ApplyCrosstalk() {
                             Int_t i1 = (Int_t)((i-tstart)*.61+tstart+0.5); // 
                             Float_t ctktmp =  -dev[i1] * 0.25;
                             if( anode > 0 ) {
-                                ctk[anode*fMaxNofSamples+i] += ctktmp;           
+                                ctk[anode*fMaxNofSamples+i] += ctktmp;
                             }
                             anode = z + 1;
                             if( anode < fNofMaps ) {
@@ -1047,15 +1058,15 @@ void AliITSsimulationSDD::ApplyCrosstalk() {
     
     for( Int_t a=0; a<fNofMaps; a++ )
         for( Int_t t=0; t<fMaxNofSamples; t++ ) {     
-            Float_t signal = fHitMap2->GetSignal( a, t ) + ctk[a*fMaxNofSamples+t];
+            Float_t signal = fHitMap2->GetSignal(a,t)+ctk[a*fMaxNofSamples+t];
             fHitMap2->SetHit( a, t, signal );
         }
-    
+
     delete [] ctk;
 }
 //______________________________________________________________________
-void AliITSsimulationSDD::GetAnodeBaseline(Int_t i,Float_t &baseline,
-                                           Float_t &noise){
+void AliITSsimulationSDD::GetAnodeBaseline(Int_t i,Double_t &baseline,
+                                           Double_t &noise){
     // Returns the Baseline for a particular anode.
     baseline = fBaseline[i];
     noise    = fNoise[i];
@@ -1088,6 +1099,9 @@ void AliITSsimulationSDD::CompressionParam(Int_t i,Int_t &db,Int_t &tl){
         } else {
             db=fD[0]; tl=fT1[0]; 
         } // end if size <=2 && i>=fNofMaps/2
+        //     Warning("CompressionParam",
+        //             "Size= %d . Values i=%d ; db= %d ; tl= %d",
+        //              size,i,db,tl);
     } // end if size > 2
 }
 //______________________________________________________________________
@@ -1095,7 +1109,7 @@ void AliITSsimulationSDD::SetCompressParam(){
     // Sets the compression alogirthm parameters  
     Int_t cp[8],i;
 
-    fResponse->GiveCompressParam(cp);
+    GetResp()->GiveCompressParam(cp);
     for (i=0; i<2; i++) {
         fD[i]   = cp[i];
         fT1[i]  = cp[i+2];
@@ -1116,9 +1130,9 @@ void AliITSsimulationSDD::ReadBaseline(){
     char input[100], base[100], param[100];
     char *filtmp;
 
-    fResponse->Filenames(input,base,param);
+    GetResp()->Filenames(input,base,param);
     fFileName=base;
-//
+    //
     filtmp = gSystem->ExpandPathName(fFileName.Data());
     FILE *bline = fopen(filtmp,"r");
     na = 0;
@@ -1153,36 +1167,14 @@ Int_t AliITSsimulationSDD::Convert10to8(Int_t signal) const {
     if (signal < 1024) return (224+((signal-512)>>4));
     return 0;
 }
-//______________________________________________________________________
-Int_t AliITSsimulationSDD::Convert8to10(Int_t signal) const {
-    // Undo the lossive 10 to 8 bit compression.
-    // code from Davide C. and Albert W.
-    if (signal < 0 || signal > 255) {
-        Warning("Convert8to10","out of range signal=%d",signal);
-        return 0;
-    } // end if signal <0 || signal >255
-
-    if (signal < 128) return signal;
-    if (signal < 192) {
-        if (TMath::Odd(signal)) return (128+((signal-128)<<1));
-        else  return (128+((signal-128)<<1)+1);
-    } // end if signal < 192
-    if (signal < 224) {
-        if (TMath::Odd(signal)) return (256+((signal-192)<<3)+3);
-        else  return (256+((signal-192)<<3)+4);
-    } // end if signal < 224
-    if (TMath::Odd(signal)) return (512+((signal-224)<<4)+7);
-    return (512+((signal-224)<<4)+8);
-}
-
 /*
 //______________________________________________________________________
 AliITSMap*   AliITSsimulationSDD::HitMap(Int_t i){
     //Return the correct map.
 
     return ((i==0)? fHitMap1 : fHitMap2);
-}*/
-
+}
+*/
 //______________________________________________________________________
 void AliITSsimulationSDD::ZeroSuppression(const char *option) {
     // perform the zero suppresion
@@ -1214,13 +1206,13 @@ void AliITSsimulationSDD::Init2D(){
     Float_t *savesigma = new Float_t [fNofMaps];
     char input[100],basel[100],par[100];
     char *filtmp;
-    Float_t tmp1,tmp2;
-    fResponse->Thresholds(tmp1,tmp2);
+    Double_t tmp1,tmp2;
+    GetResp()->Thresholds(tmp1,tmp2);
     Int_t minval = static_cast<Int_t>(tmp1);
 
-    fResponse->Filenames(input,basel,par);
+    GetResp()->Filenames(input,basel,par);
     fFileName = par;
-//
+    //
     filtmp = gSystem->ExpandPathName(fFileName.Data());
     FILE *param = fopen(filtmp,"r");
     na = 0;
@@ -1232,18 +1224,18 @@ void AliITSsimulationSDD::Init2D(){
                 exit(1);
             } // end if pos != na+1
             savemu[na] = mu;
-          savesigma[na] = sigma;
-          if ((2.*sigma) < mu) {
-              fD[na] = (Int_t)floor(mu - 2.0*sigma + 0.5);
-              mu = 2.0 * sigma;
-          } else fD[na] = 0;
-          tempTh = (Int_t)floor(mu+2.25*sigma+0.5) - minval;
-          if (tempTh < 0) tempTh=0;
-          fT1[na] = tempTh;
-          tempTh = (Int_t)floor(mu+3.0*sigma+0.5) - minval;
-          if (tempTh < 0) tempTh=0;
-          fT2[na] = tempTh;
-          na++;
+            savesigma[na] = sigma;
+            if ((2.*sigma) < mu) {
+                fD[na] = (Int_t)floor(mu - 2.0*sigma + 0.5);
+                mu = 2.0 * sigma;
+            } else fD[na] = 0;
+            tempTh = (Int_t)floor(mu+2.25*sigma+0.5) - minval;
+            if (tempTh < 0) tempTh=0;
+            fT1[na] = tempTh;
+            tempTh = (Int_t)floor(mu+3.0*sigma+0.5) - minval;
+            if (tempTh < 0) tempTh=0;
+            fT2[na] = tempTh;
+            na++;
         } // end while
     } else {
         Error("Init2D","THE FILE %s DOES NOT EXIST !",filtmp);
@@ -1260,11 +1252,11 @@ void AliITSsimulationSDD::Compress2D(){
     // simple ITS cluster finder -- online zero-suppression conditions
 
     Int_t db,tl,th; 
-    Float_t tmp1,tmp2;
-    fResponse->Thresholds(tmp1,tmp2); 
+    Double_t tmp1,tmp2;
+    GetResp()->Thresholds(tmp1,tmp2); 
     Int_t minval   = static_cast<Int_t>(tmp1);
-    Bool_t write   = fResponse->OutputOption();   
-    Bool_t do10to8 = fResponse->Do10to8();
+    Bool_t write   = GetResp()->OutputOption();   
+    Bool_t do10to8 = GetResp()->Do10to8();
     Int_t nz, nl, nh, low, i, j; 
 
     for (i=0; i<fNofMaps; i++) {
@@ -1304,18 +1296,18 @@ void AliITSsimulationSDD::Compress2D(){
 void  AliITSsimulationSDD::FindCluster(Int_t i,Int_t j,Int_t signal,
                                        Int_t minval,Bool_t &cond){
     // Find clusters according to the online 2D zero-suppression algorithm
-    Bool_t do10to8 = fResponse->Do10to8();
+    Bool_t do10to8 = GetResp()->Do10to8();
     Bool_t high    = kFALSE;
 
     fHitMap2->FlagHit(i,j);
-//
-//  check the online zero-suppression conditions
-//  
+    //
+    //  check the online zero-suppression conditions
+    //  
     const Int_t kMaxNeighbours = 4;
     Int_t nn;
     Int_t dbx,tlx,thx;  
     Int_t xList[kMaxNeighbours], yList[kMaxNeighbours];
-    fSegmentation->Neighbours(i,j,&nn,xList,yList);
+    GetSeg()->Neighbours(i,j,&nn,xList,yList);
     Int_t in,ix,iy,qns;
     for (in=0; in<nn; in++) {
         ix=xList[in];
@@ -1347,7 +1339,7 @@ void AliITSsimulationSDD::Init1D(){
     // this is just a copy-paste of input taken from 2D algo
     // Torino people should give input
     // Read 1D zero-suppression parameters for SDD
-
+    
     if (!strstr(fParam.Data(),"file")) return;
 
     Int_t na,pos,tempTh;
@@ -1356,20 +1348,20 @@ void AliITSsimulationSDD::Init1D(){
     Float_t *savesigma = new Float_t [fNofMaps];
     char input[100],basel[100],par[100];
     char *filtmp;
-    Float_t tmp1,tmp2;
-    fResponse->Thresholds(tmp1,tmp2);
+    Double_t tmp1,tmp2;
+    GetResp()->Thresholds(tmp1,tmp2);
     Int_t minval = static_cast<Int_t>(tmp1);
 
-    fResponse->Filenames(input,basel,par);
+    GetResp()->Filenames(input,basel,par);
     fFileName=par;
 
-//  set first the disable and tol param
+    //  set first the disable and tol param
     SetCompressParam();
-//
+    //
     filtmp = gSystem->ExpandPathName(fFileName.Data());
     FILE *param = fopen(filtmp,"r");
     na = 0;
-
     if (param) {
         fscanf(param,"%d %d %d %d ", &fT2[0], &fT2[1], &fTol[0], &fTol[1]);
         while(fscanf(param,"%d %f %f",&pos, &mu, &sigma) != EOF) {
@@ -1404,7 +1396,7 @@ void AliITSsimulationSDD::Compress1D(){
     Int_t    dis,tol,thres,decr,diff;
     UChar_t *str=fStream->Stream();
     Int_t    counter=0;
-    Bool_t   do10to8=fResponse->Do10to8();
+    Bool_t   do10to8=GetResp()->Do10to8();
     Int_t    last=0;
     Int_t    k,i,j;
 
@@ -1416,6 +1408,7 @@ void AliITSsimulationSDD::Compress1D(){
             Int_t idx=i+k*fNofMaps/2;
             if( !fAnodeFire[idx] ) continue;
             CompressionParam(idx,decr,thres); 
+            
             for (j=0; j<fMaxNofSamples; j++) {
                 Int_t signal=(Int_t)(fHitMap2->GetSignal(idx,j));
                 signal -= decr;  // if baseline eq.
@@ -1458,7 +1451,7 @@ void AliITSsimulationSDD::Compress1D(){
     // open file and write out the stream of diff's
     static Bool_t open=kTRUE;
     static TFile *outFile;
-    Bool_t write = fResponse->OutputOption();
+    Bool_t write = GetResp()->OutputOption();
     TDirectory *savedir = gDirectory;
  
     if (write ) {
@@ -1471,7 +1464,7 @@ void AliITSsimulationSDD::Compress1D(){
         open = kFALSE;
         outFile->cd();
         fStream->Write();
-    }  // endif write        
+    }  // endif write
 
     fStream->ClearStream();
 
@@ -1481,14 +1474,13 @@ void AliITSsimulationSDD::Compress1D(){
 //______________________________________________________________________
 void AliITSsimulationSDD::StoreAllDigits(){
     // if non-zero-suppressed data
-    Bool_t do10to8 = fResponse->Do10to8();
+    Bool_t do10to8 = GetResp()->Do10to8();
     Int_t i, j, digits[3];
 
     for (i=0; i<fNofMaps; i++) {
         for (j=0; j<fMaxNofSamples; j++) {
             Int_t signal=(Int_t)(fHitMap2->GetSignal(i,j));
             if(do10to8) signal = Convert10to8(signal);
-            if(do10to8) signal = Convert8to10(signal); 
             digits[0] = i;
             digits[1] = j;
             digits[2] = signal;
@@ -1501,15 +1493,15 @@ void AliITSsimulationSDD::CreateHistograms(Int_t scale){
     // Creates histograms of maps for debugging
     Int_t i;
 
-      fHis=new TObjArray(fNofMaps);
-      for (i=0;i<fNofMaps;i++) {
-           TString sddName("sdd_");
-           Char_t candNum[4];
-           sprintf(candNum,"%d",i+1);
-           sddName.Append(candNum);
-           fHis->AddAt(new TH1F(sddName.Data(),"SDD maps",scale*fMaxNofSamples,
-                                0.,(Float_t) scale*fMaxNofSamples), i);
-      } // end for i
+    fHis=new TObjArray(fNofMaps);
+    for (i=0;i<fNofMaps;i++) {
+        TString sddName("sdd_");
+        Char_t candNum[4];
+        sprintf(candNum,"%d",i+1);
+        sddName.Append(candNum);
+        fHis->AddAt(new TH1F(sddName.Data(),"SDD maps",scale*fMaxNofSamples,
+                             0.,(Float_t) scale*fMaxNofSamples), i);
+    } // end for i
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::FillHistograms(){
@@ -1567,18 +1559,18 @@ void AliITSsimulationSDD::WriteToFile(TFile *hfile) {
 //______________________________________________________________________
 Float_t AliITSsimulationSDD::GetNoise() {  
     // Returns the noise value
-    //Bool_t do10to8=fResponse->Do10to8();
+    //Bool_t do10to8=GetResp()->Do10to8();
     //noise will always be in the liniar part of the signal
     Int_t decr;
     Int_t threshold = fT1[0];
     char opt1[20], opt2[20];
 
-    fResponse->ParamOptions(opt1,opt2);
+    GetResp()->ParamOptions(opt1,opt2);
     fParam=opt2;
     char *same = strstr(opt1,"same");
-    Float_t noise,baseline;
+    Double_t noise,baseline;
     if (same) {
-        fResponse->GetNoiseParam(noise,baseline);
+        GetResp()->GetNoiseParam(noise,baseline);
     } else {
         static Bool_t readfile=kTRUE;
         //read baseline and noise from file
@@ -1604,7 +1596,7 @@ Float_t AliITSsimulationSDD::GetNoise() {
         for (k=0;k<fMaxNofSamples;k++) {
             Float_t signal=(Float_t)fHitMap2->GetSignal(i,k);
             //if (signal <= (float)threshold) noisehist->Fill(signal-baseline);
-            if (signal <= (float)threshold) noisehist->Fill(signal);
+            if (signal <= (float)(threshold+decr)) noisehist->Fill(signal);
             anode->Fill((float)k,signal);
         } // end for k
         anode->Draw();
@@ -1636,12 +1628,12 @@ void AliITSsimulationSDD::WriteSDigits(){
                 AliITSpListItem pItemTmp2( fModule, index, 0. );
                 // put the fScaleSize analog digits in only one
                 for( Int_t ik=0; ik<fScaleSize; ik++ ) {
-                    AliITSpListItem *pItemTmp = fpList->GetpListItem( i, jdx+ik );
+                    AliITSpListItem *pItemTmp = fpList->GetpListItem(i,jdx+ik);
                     if( pItemTmp == 0 ) continue;
                     pItemTmp2.Add( pItemTmp );
                 }
                 pItemTmp2.AddSignalAfterElect( fModule, index, sig );
-                pItemTmp2.AddNoise( fModule, index, fHitNoiMap2->GetSignal( i, j ) );         
+                pItemTmp2.AddNoise(fModule,index,fHitNoiMap2->GetSignal(i,j));
                 aliITS->AddSumDigit( pItemTmp2 );
             } // end if (sig > 0.2)
         }