]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSsimulationSDD.cxx
Corrections for memory leaks, random numbers, hit number; also some data members...
[u/mrichter/AliRoot.git] / ITS / AliITSsimulationSDD.cxx
index 871d9c720145336c367c8c6f758233262d5640d8..e56f856df00a0f692f4b7eb2c1f760c28d94142c 100644 (file)
@@ -186,94 +186,99 @@ AliITSsimulationSDD& AliITSsimulationSDD::operator=(AliITSsimulationSDD &source)
 
 AliITSsimulationSDD::AliITSsimulationSDD(AliITSsegmentation *seg,AliITSresponse *resp) 
 {
-  // Standard Constructor
-
-      fHis=0;
-      fTreeB=0;
-      fResponse = resp;
-      fSegmentation = seg;
-      SetScaleFourier();
-      SetPerpendTracksFlag();
-      SetDoFFT();
-      SetCheckNoise();
-
-      fHitMap2 = new AliITSMapA2(fSegmentation,fScaleSize,1);
-      fHitMap1 = new AliITSMapA1(fSegmentation);
-
-      //
-      fNofMaps=fSegmentation->Npz();
-      fMaxNofSamples=fSegmentation->Npx();
-
-      Float_t sddLength = fSegmentation->Dx();
-      Float_t sddWidth = fSegmentation->Dz();
-
-      Int_t dummy=0;
-      Float_t anodePitch = fSegmentation->Dpz(dummy);
-      Double_t timeStep = (Double_t)fSegmentation->Dpx(dummy);
-      Float_t driftSpeed=fResponse->DriftSpeed();    
-
-      if(anodePitch*(fNofMaps/2) > sddWidth) {
-         Warning("AliITSsimulationSDD",
-           "Too many anodes %d or too big pitch %f \n",fNofMaps/2,anodePitch);
-      }
+    // Standard Constructor
+
+    fHitMap1      = 0;     // zero just in case of an error
+    fHitMap2      = 0;     // zero just in case of an error
+    fElectronics  = 0;     // zero just in case of an error
+    fStream       = 0;     // zero just in case of an error
+    fHis          = 0;
+    fTreeB        = 0;
+    fResponse     = resp;
+    fSegmentation = seg;
+    SetScaleFourier();
+    SetPerpendTracksFlag();
+    SetDoFFT();
+    SetCheckNoise();
+
+    fHitMap2 = new AliITSMapA2(fSegmentation,fScaleSize,1);
+    fHitMap1 = new AliITSMapA1(fSegmentation);
 
-      if(timeStep*fMaxNofSamples < sddLength/driftSpeed) {
-         Error("AliITSsimulationSDD",
-                             "Time Interval > Allowed Time Interval: exit\n");
-         return;
-      }
+    //
+    fNofMaps=fSegmentation->Npz();
+    fMaxNofSamples=fSegmentation->Npx();
+    
+    Float_t sddLength = fSegmentation->Dx();
+    Float_t sddWidth = fSegmentation->Dz();
 
-      fElectronics = new AliITSetfSDD(timeStep/fScaleSize,fResponse->Electronics());
+    Int_t dummy=0;
+    Float_t anodePitch = fSegmentation->Dpz(dummy);
+    Double_t timeStep = (Double_t)fSegmentation->Dpx(dummy);
+    Float_t driftSpeed=fResponse->DriftSpeed();
+
+    if(anodePitch*(fNofMaps/2) > sddWidth) {
+       Warning("AliITSsimulationSDD",
+               "Too many anodes %d or too big pitch %f \n",
+               fNofMaps/2,anodePitch);
+    } // end if
+
+    if(timeStep*fMaxNofSamples < sddLength/driftSpeed) {
+       Error("AliITSsimulationSDD",
+             "Time Interval > Allowed Time Interval: exit\n");
+       return;
+    } // end if
+
+    fElectronics = new AliITSetfSDD(timeStep/fScaleSize,
+                                   fResponse->Electronics());
+
+    char opt1[20], opt2[20];
+    fResponse->ParamOptions(opt1,opt2);
+    fParam=opt2;
+    char *same = strstr(opt1,"same");
+    if (same) {
+       fNoise.Set(0);
+       fBaseline.Set(0);
+    } else {
+       fNoise.Set(fNofMaps);
+       fBaseline.Set(fNofMaps);
+    } // end if
 
-      char opt1[20], opt2[20];
-      fResponse->ParamOptions(opt1,opt2);
-      fParam=opt2;
-      char *same = strstr(opt1,"same");
-      if (same) {
-         fNoise.Set(0);
-         fBaseline.Set(0);
-      } else {
-         fNoise.Set(fNofMaps);
-         fBaseline.Set(fNofMaps);
-      }
-      
-      //
-      const char *kopt=fResponse->ZeroSuppOption();
-        if (strstr(fParam,"file") ) {
-         fD.Set(fNofMaps);
-         fT1.Set(fNofMaps);
-          if (strstr(kopt,"2D")) {
+    //
+    const char *kopt=fResponse->ZeroSuppOption();
+    if (strstr(fParam,"file") ) {
+       fD.Set(fNofMaps);
+       fT1.Set(fNofMaps);
+       if (strstr(kopt,"2D")) {
            fT2.Set(fNofMaps);
             fTol.Set(0);
             Init2D();       // desactivate if param change module by module
-          } else if(strstr(kopt,"1D"))  {
+       } else if(strstr(kopt,"1D"))  {
             fT2.Set(2);
             fTol.Set(2);
             Init1D();      // desactivate if param change module by module
-         }
-       } else {
-          fD.Set(2);
-         fTol.Set(2);
-         fT1.Set(2);
-         fT2.Set(2);
-         SetCompressParam();
-       }
+       } // end if strstr
+    } else {
+       fD.Set(2);
+       fTol.Set(2);
+       fT1.Set(2);
+       fT2.Set(2);
+       SetCompressParam();
+    } // end if else strstr
 
+    Bool_t write=fResponse->OutputOption();
+    if(write && strstr(kopt,"2D")) MakeTreeB();
 
-       Bool_t write=fResponse->OutputOption();
-       if(write && strstr(kopt,"2D")) MakeTreeB();
+    // call here if baseline does not change by module
+    // ReadBaseline();
 
-        // call here if baseline does not change by module
-        // ReadBaseline();
+    fITS = (AliITS*)gAlice->GetModule("ITS");
+    Int_t size=fNofMaps*fMaxNofSamples;
+    fStream = new AliITSInStream(size);
 
-        fITS = (AliITS*)gAlice->GetModule("ITS");
-        Int_t size=fNofMaps*fMaxNofSamples;
-       fStream = new AliITSInStream(size); 
-       
-       fInZR = new Double_t [fScaleSize*fMaxNofSamples];
-       fInZI = new Double_t [fScaleSize*fMaxNofSamples];
-       fOutZR = new Double_t [fScaleSize*fMaxNofSamples];
-       fOutZI = new Double_t [fScaleSize*fMaxNofSamples];  
+    fInZR  = new Double_t [fScaleSize*fMaxNofSamples];
+    fInZI  = new Double_t [fScaleSize*fMaxNofSamples];
+    fOutZR = new Double_t [fScaleSize*fMaxNofSamples];
+    fOutZI = new Double_t [fScaleSize*fMaxNofSamples];  
 
 }
 
@@ -890,7 +895,6 @@ void AliITSsimulationSDD::ChargeToSignal() {
 
   Float_t contrib=0;
 
-  TRandom random; 
   Int_t i,k,kk; 
 
   Float_t maxadc = fResponse->MaxAdc();    
@@ -899,7 +903,7 @@ void AliITSsimulationSDD::ChargeToSignal() {
         if  (read && i<fNofMaps) GetAnodeBaseline(i,baseline,noise);
        for(k=0; k<fScaleSize*fMaxNofSamples; k++) {
           fInZR[k] = fHitMap2->GetSignal(i,k);
-          contrib = (baseline + noise*random.Gaus());
+          contrib = (baseline + noise*gRandom->Gaus());
           fInZR[k] += contrib;
        }
        for(k=0; k<fMaxNofSamples; k++) {
@@ -926,7 +930,7 @@ void AliITSsimulationSDD::ChargeToSignal() {
       if  (read && i<fNofMaps) GetAnodeBaseline(i,baseline,noise);
       for(k=0; k<fScaleSize*fMaxNofSamples; k++) {
        fInZR[k] = fHitMap2->GetSignal(i,k);
-       contrib = (baseline + noise*random.Gaus());
+       contrib = (baseline + noise*gRandom->Gaus());
        fInZR[k] += contrib;
        fInZI[k] = 0.;
       }