Coverity corrections
authorgconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 1 Oct 2010 14:11:29 +0000 (14:11 +0000)
committergconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 1 Oct 2010 14:11:29 +0000 (14:11 +0000)
EMCAL/AliEMCALAodCluster.cxx
EMCAL/AliEMCALClusterizerNxN.cxx
EMCAL/AliEMCALDigitizer.cxx
EMCAL/AliEMCALEMCGeometry.cxx
EMCAL/AliEMCALGeoUtils.cxx
EMCAL/AliEMCALPIDUtils.cxx
EMCAL/AliEMCALQAChecker.cxx
EMCAL/AliEMCALReconstructor.cxx
EMCAL/AliEMCALSDigitizer.cxx
EMCAL/AliEMCALSurvey.cxx

index fe01738..f8bfc5c 100644 (file)
@@ -67,8 +67,7 @@ void AliEMCALAodCluster::Recalibrate(AliEMCALCalibData * calibData, AliAODCaloCe
     return ;
 
   AliEMCALGeometry * emcalgeo =  AliEMCALGeometry::GetInstance(emcalGeoName) ;
-  if(!emcalgeo)
-    AliFatal("AliEMCALGeometry was not constructed\n") ;
+  if(emcalgeo){
        
   Double32_t * cellsAmpFraction = GetCellsAmplitudeFraction(); 
   Int_t iSupMod = -1;
@@ -94,6 +93,10 @@ void AliEMCALAodCluster::Recalibrate(AliEMCALCalibData * calibData, AliAODCaloCe
        
   SetCellsAmplitudeFraction(cellsAmpFraction);
   fRecalibrated=kTRUE; 
+    
+  }
+  else  AliFatal("AliEMCALGeometry was not constructed\n") ;
+
 }
 //____________________________________________________________________________
 void  AliEMCALAodCluster::EvalAll(Float_t logWeight, TString geoname){
@@ -177,8 +180,7 @@ void AliEMCALAodCluster::EvalPositionAndShowerShape(Float_t logWeight, TString e
   Double_t zmean = 0.;
 
   AliEMCALGeometry * emcalgeo =  AliEMCALGeometry::GetInstance(emcalGeoName) ;
-  if(!emcalgeo)
-    AliFatal("AliEMCALGeometry was not constructed\n") ;
+  if(emcalgeo){
        
   Double_t dist  = TmaxInCm(E(),0);
   for(Int_t iDigit=0; iDigit < GetNCells(); iDigit++) {
@@ -268,6 +270,11 @@ void AliEMCALAodCluster::EvalPositionAndShowerShape(Float_t logWeight, TString e
          SetDispersion(TMath::Sqrt(d)) ;
   else    
          SetDispersion(0) ;
+  }
+  else {
+    AliFatal("AliEMCALGeometry was not constructed\n") ;
+  }
+
 
 }
 
index be588f3..cca2fc8 100644 (file)
@@ -142,8 +142,12 @@ void AliEMCALClusterizerNxN::Digits2Clusters(Option_t * option)
   
   for(index = 0; index < fRecPoints->GetEntries(); index++) 
   {
-    (dynamic_cast<AliEMCALRecPoint *>(fRecPoints->At(index)))->SetIndexInList(index) ;
-    (dynamic_cast<AliEMCALRecPoint *>(fRecPoints->At(index)))->Print();
+    AliEMCALRecPoint * rp = dynamic_cast<AliEMCALRecPoint *>(fRecPoints->At(index));
+    if(rp){
+      rp->SetIndexInList(index) ;
+      rp->Print();
+    }
+    else AliFatal("RecPoint NULL!!");
   }
   
   fTreeR->Fill();
@@ -359,45 +363,51 @@ void AliEMCALClusterizerNxN::MakeUnfolding()
 {
   // Unfolds clusters using the shape of an ElectroMagnetic shower
   // Performs unfolding of all clusters
-               
+  
   if(fNumberOfECAClusters > 0){
-    if (fGeom==0)
-      AliFatal("Did not get geometry from EMCALLoader") ;
-    Int_t nModulesToUnfold = fGeom->GetNCells();
-
-    Int_t numberofNotUnfolded = fNumberOfECAClusters ;
-    Int_t index ;
-    for(index = 0 ; index < numberofNotUnfolded ; index++){
-
-      AliEMCALRecPoint * recPoint = dynamic_cast<AliEMCALRecPoint *>( fRecPoints->At(index) ) ;
-
-      TVector3 gpos;
-      Int_t absId;
-      recPoint->GetGlobalPosition(gpos);
-      fGeom->GetAbsCellIdFromEtaPhi(gpos.Eta(),gpos.Phi(),absId);
-      if(absId > nModulesToUnfold)
-        break ;
-
-      Int_t nMultipl = recPoint->GetMultiplicity() ;
-      AliEMCALDigit ** maxAt = new AliEMCALDigit*[nMultipl] ;
-      Float_t * maxAtEnergy = new Float_t[nMultipl] ;
-      Int_t nMax = recPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy,fECALocMaxCut,fDigitsArr) ;
-
-      if( nMax > 1 ) {     // if cluster is very flat (no pronounced maximum) then nMax = 0
-        //UnfoldCluster(recPoint, nMax, maxAt, maxAtEnergy) ;
-        fRecPoints->Remove(recPoint);
-        fRecPoints->Compress() ;
-        index-- ;
-        fNumberOfECAClusters-- ;
-        numberofNotUnfolded-- ;
-      }
-      else{
-        recPoint->SetNExMax(1) ; //Only one local maximum
-      }
-
-      delete[] maxAt ;
-      delete[] maxAtEnergy ;
+    
+    if (fGeom){
+      
+      Int_t nModulesToUnfold = fGeom->GetNCells();
+      
+      Int_t numberofNotUnfolded = fNumberOfECAClusters ;
+      Int_t index ;
+      for(index = 0 ; index < numberofNotUnfolded ; index++){
+        
+        AliEMCALRecPoint * recPoint = dynamic_cast<AliEMCALRecPoint *>( fRecPoints->At(index) ) ;
+        if(recPoint){
+          TVector3 gpos;
+          Int_t absId;
+          recPoint->GetGlobalPosition(gpos);
+          fGeom->GetAbsCellIdFromEtaPhi(gpos.Eta(),gpos.Phi(),absId);
+          if(absId > nModulesToUnfold)
+            break ;
+          
+          Int_t nMultipl = recPoint->GetMultiplicity() ;
+          AliEMCALDigit ** maxAt = new AliEMCALDigit*[nMultipl] ;
+          Float_t * maxAtEnergy = new Float_t[nMultipl] ;
+          Int_t nMax = recPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy,fECALocMaxCut,fDigitsArr) ;
+          
+          if( nMax > 1 ) {     // if cluster is very flat (no pronounced maximum) then nMax = 0
+            //UnfoldCluster(recPoint, nMax, maxAt, maxAtEnergy) ;
+            fRecPoints->Remove(recPoint);
+            fRecPoints->Compress() ;
+            index-- ;
+            fNumberOfECAClusters-- ;
+            numberofNotUnfolded-- ;
+          }
+          else{
+            recPoint->SetNExMax(1) ; //Only one local maximum
+          }
+          
+          delete[] maxAt ;
+          delete[] maxAtEnergy ;
+        }
+        else AliFatal("Could not get RecPoint!") ;
+      }//loop
     }
+    else AliFatal("Could not get geometry from EMCALLoader!") ;
+
   }
   // End of Unfolding of clusters
 }
index 619c093..011b441 100644 (file)
@@ -288,6 +288,8 @@ void AliEMCALDigitizer::Digitize(Int_t event)
   
   AliRunLoader *rl = AliRunLoader::Instance();
   AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
+  
+  if(emcalLoader){
   Int_t readEvent = event ; 
   // fManager is data member from AliDigitizer
   if (fManager) 
@@ -295,7 +297,7 @@ void AliEMCALDigitizer::Digitize(Int_t event)
   AliDebug(1,Form("Adding event %d from input stream 0 %s %s", 
                   readEvent, GetTitle(), fEventFolderName.Data())) ; 
   rl->GetEvent(readEvent);
-  
+    
   TClonesArray * digits = emcalLoader->Digits() ; 
   digits->Delete() ;  //correct way to clear array when memory is
   //allocated by objects stored in array
@@ -363,9 +365,9 @@ void AliEMCALDigitizer::Digitize(Int_t event)
       sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
       if(sdigits){
         if (sdigits->GetEntriesFast() ){
-          if(dynamic_cast<AliEMCALDigit *>(sdigits->At(0))){
-            
-            Int_t curNext = dynamic_cast<AliEMCALDigit *>(sdigits->At(0))->GetId() ;
+          AliEMCALDigit *sd = dynamic_cast<AliEMCALDigit *>(sdigits->At(0));
+          if(sd){
+            Int_t curNext = sd->GetId() ;
             if(curNext < nextSig) 
               nextSig = curNext ;
             AliDebug(1,Form("input %i : #sdigits %i \n",
@@ -429,11 +431,12 @@ void AliEMCALDigitizer::Digitize(Int_t event)
           
           // loop over input
           for(i = 0; i< fInput ; i++){  //loop over (possible) merge sources
-            if(dynamic_cast<TClonesArray *>(sdigArray->At(i))) {
-              Int_t sDigitEntries = dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast();
+            TClonesArray* sdtclarr = dynamic_cast<TClonesArray *>(sdigArray->At(i));
+            if(sdtclarr) {
+              Int_t sDigitEntries = sdtclarr->GetEntriesFast();
               
               if(sDigitEntries > index[i] )
-                curSDigit = dynamic_cast<AliEMCALDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;       
+                curSDigit = dynamic_cast<AliEMCALDigit*>(sdtclarr->At(index[i])) ;     
               else
                 curSDigit = 0 ;
               
@@ -461,7 +464,7 @@ void AliEMCALDigitizer::Digitize(Int_t event)
                 
                 index[i]++ ;
                 if( sDigitEntries > index[i] )
-                  curSDigit = dynamic_cast<AliEMCALDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
+                  curSDigit = dynamic_cast<AliEMCALDigit*>(sdtclarr->At(index[i])) ;
                 else
                   curSDigit = 0 ;
               }// while
@@ -484,8 +487,9 @@ void AliEMCALDigitizer::Digitize(Int_t event)
             sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
             if(sdigits){
               Int_t curNext = nextSig ;
-              if(sdigits->GetEntriesFast() > index[i] && dynamic_cast<AliEMCALDigit *>(sdigits->At(index[i]))){
-                curNext = dynamic_cast<AliEMCALDigit *>(sdigits->At(index[i]))->GetId() ;        
+              AliEMCALDigit * tmpdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(index[i]));
+              if(sdigits->GetEntriesFast() > index[i] && tmpdigit){
+                curNext = tmpdigit->GetId() ;    
               }
               if(curNext < nextSig) nextSig = curNext ;
             }// sdigits exist
@@ -554,6 +558,9 @@ void AliEMCALDigitizer::Digitize(Int_t event)
     }//Digit loop
     
   }//SDigitizer not null
+  }
+  else AliFatal("EMCALLoader is NULL!") ;
+
 }
 
 // //_____________________________________________________________________
@@ -714,73 +721,76 @@ void AliEMCALDigitizer::Digits2FastOR(TClonesArray* digitsTMP, TClonesArray* dig
     AliFatal("Did not get the  Loader");
   }
   else {
-    AliEMCALGeometry* geom = dynamic_cast<AliEMCAL*>(run->GetDetector("EMCAL"))->GetGeometry();
-    
-    // build FOR from simulated digits
-    // and xfer to the corresponding TRU input (mapping)
-    
-    TClonesArray* digits = emcalLoader->Digits();
-    
-    TIter NextDigit(digits);
-    while (AliEMCALDigit* digit = (AliEMCALDigit*)NextDigit())
-    {
-      Int_t id = digit->GetId();
+    AliEMCAL* emcal = dynamic_cast<AliEMCAL*>(run->GetDetector("EMCAL"));
+    if(emcal){
+      AliEMCALGeometry* geom = emcal->GetGeometry();
       
-      Int_t trgid;
-      if (geom && geom->GetFastORIndexFromCellIndex(id , trgid)) 
+      // build FOR from simulated digits
+      // and xfer to the corresponding TRU input (mapping)
+      
+      TClonesArray* digits = emcalLoader->Digits();
+      
+      TIter NextDigit(digits);
+      while (AliEMCALDigit* digit = (AliEMCALDigit*)NextDigit())
       {
-        AliDebug(1,Form("trigger digit id: %d from cell id: %d\n",trgid,id));
-        
-        AliEMCALDigit* d = static_cast<AliEMCALDigit*>(digitsTMP->At(trgid));
+        Int_t id = digit->GetId();
         
-        if (!d)
-             {
-          new((*digitsTMP)[trgid]) AliEMCALDigit(*digit);
-          d = (AliEMCALDigit*)digitsTMP->At(trgid);
-          d->SetId(trgid);
-             } 
-        else
-             {
-          *d = *d + *digit;
-             }
+        Int_t trgid;
+        if (geom && geom->GetFastORIndexFromCellIndex(id , trgid)) 
+        {
+          AliDebug(1,Form("trigger digit id: %d from cell id: %d\n",trgid,id));
+          
+          AliEMCALDigit* d = static_cast<AliEMCALDigit*>(digitsTMP->At(trgid));
+          
+          if (!d)
+          {
+            new((*digitsTMP)[trgid]) AliEMCALDigit(*digit);
+            d = (AliEMCALDigit*)digitsTMP->At(trgid);
+            d->SetId(trgid);
+          }    
+          else
+          {
+            *d = *d + *digit;
+          }
+        }
       }
-    }
-    
-    if (AliDebugLevel()) printf("Number of TRG digits: %d\n",digitsTMP->GetEntriesFast());
-    
-    Int_t    nSamples = 32;
-    Int_t *timeSamples = new Int_t[nSamples];
-    
-    NextDigit = TIter(digitsTMP);
-    while (AliEMCALDigit* digit = (AliEMCALDigit*)NextDigit())
-    {
-      if (digit)
+      
+      if (AliDebugLevel()) printf("Number of TRG digits: %d\n",digitsTMP->GetEntriesFast());
+      
+      Int_t    nSamples = 32;
+      Int_t *timeSamples = new Int_t[nSamples];
+      
+      NextDigit = TIter(digitsTMP);
+      while (AliEMCALDigit* digit = (AliEMCALDigit*)NextDigit())
       {
-        Int_t     id = digit->GetId();
-        Float_t time = digit->GetTime();
-        
-        Double_t depositedEnergy = 0.;
-        for (Int_t j = 1; j <= digit->GetNprimary(); j++) depositedEnergy += digit->GetDEPrimary(j);
-        
-        if (AliDebugLevel()) printf("Deposited Energy: %f\n", depositedEnergy);
-        
-        // FIXME: Check digit time!
-        if (depositedEnergy)
-             {
-          DigitalFastOR(time, depositedEnergy, timeSamples, nSamples);
+        if (digit)
+        {
+          Int_t     id = digit->GetId();
+          Float_t time = digit->GetTime();
           
-          for (Int_t j=0;j<nSamples;j++) 
+          Double_t depositedEnergy = 0.;
+          for (Int_t j = 1; j <= digit->GetNprimary(); j++) depositedEnergy += digit->GetDEPrimary(j);
+          
+          if (AliDebugLevel()) printf("Deposited Energy: %f\n", depositedEnergy);
+          
+          // FIXME: Check digit time!
+          if (depositedEnergy)
           {
-            timeSamples[j] = ((j << 12) & 0xFF000) | (timeSamples[j] & 0xFFF);
+            DigitalFastOR(time, depositedEnergy, timeSamples, nSamples);
+            
+            for (Int_t j=0;j<nSamples;j++) 
+            {
+              timeSamples[j] = ((j << 12) & 0xFF000) | (timeSamples[j] & 0xFFF);
+            }
+            
+            new((*digitsTRG)[digitsTRG->GetEntriesFast()]) AliEMCALRawDigit(id, timeSamples, nSamples);
           }
-          
-          new((*digitsTRG)[digitsTRG->GetEntriesFast()]) AliEMCALRawDigit(id, timeSamples, nSamples);
-             }
+        }
       }
-    }
-    
-    delete [] timeSamples;
-    
+      
+      delete [] timeSamples;
+    }// AliEMCAL exists
+    else AliFatal("Could not get AliEMCAL");
   }// loader exists
   
 }
index 630c69f..07bbc8b 100644 (file)
@@ -90,7 +90,7 @@ AliEMCALEMCGeometry::AliEMCALEMCGeometry()
   // default ctor only for internal usage (singleton)
   // must be kept public for root persistency purposes, 
   // but should never be called by the outside world    
-
+  fParSM[0]=0; fParSM[1]=0; fParSM[2]=0;
   AliDebug(2, "AliEMCALEMCGeometry : default ctor ");
 }
 //______________________________________________________________________
@@ -192,6 +192,9 @@ AliEMCALEMCGeometry::AliEMCALEMCGeometry(const AliEMCALEMCGeometry& geom)
     fTubsTurnAngle(geom.fTubsTurnAngle)
 {
   //copy ctor
+  fParSM[0]=geom.fParSM[0]; 
+  fParSM[1]=geom.fParSM[1]; 
+  fParSM[2]=geom.fParSM[2];
 }
 
 //______________________________________________________________________
index da5b2d8..7eebde9 100644 (file)
@@ -1270,13 +1270,14 @@ const TGeoHMatrix * AliEMCALGeoUtils::GetMatrixForSuperModule(Int_t smod) const
        //    TGeoHMatrix* m = gGeoManager->GetCurrentMatrix();
        
        if(gGeoManager){
-               char path[255] ;
-               sprintf(path,"/ALIC_1/XEN1_1/SMOD_%d",smod+1) ;
+    const Int_t buffersize = 255;
+               char path[buffersize] ;
+               snprintf(path,buffersize,"/ALIC_1/XEN1_1/SMOD_%d",smod+1) ;
                //TString volpath = "ALIC_1/XEN1_1/SMOD_";
            //volpath += smod+1;
 
                if(fKey110DEG && smod >= 10){
-                         sprintf(path,"/ALIC_1/XEN1_1/SM10_%d",smod-10+1) ;
+                         snprintf(path,buffersize,"/ALIC_1/XEN1_1/SM10_%d",smod-10+1) ;
                        //volpath = "ALIC_1/XEN1_1/SM10_";
                        //volpath += smod-10+1;
                }
index 3975b94..bae8bcc 100644 (file)
@@ -411,9 +411,10 @@ void AliEMCALPIDUtils::SetLowFluxParam()
       fGamma[i][j]      = fHadron[i][j] =  fPiZero[i][j] = 0.;
       fGamma1to10[i][j] = fHadron1to10[i][j] = 0.;
     }
-       fGammaEnergyProb[i]  =  fGammaEnergyProb[i];
-       fPiZeroEnergyProb[i] = fPiZeroEnergyProb[i];
-       fHadronEnergyProb[i] = fHadronEnergyProb[i];
+       //Why we had the next 3 lines?
+       //fGammaEnergyProb[i]  =  fGammaEnergyProb[i];
+       //fPiZeroEnergyProb[i] = fPiZeroEnergyProb[i];
+       //fHadronEnergyProb[i] = fHadronEnergyProb[i];
   }
   
   // New parameterization for lambda0^2 (=x): f(x) = normLandau*TMath::Landau(x,mpvLandau,widthLandau)+normgaus*TMath::Gaus(x,meangaus,sigmagaus)
index c36bcc1..54089f9 100644 (file)
@@ -211,21 +211,22 @@ void AliEMCALQAChecker::CheckRaws(Double_t * test, TObjArray ** list)
       printf("%2.2f %% towers out of range [0.8, 1.2]\n", (1-rv)*100);
       if(fText){
         fText->Clear() ; 
-      }      
-      fText->AddText(Form("%2.2f %% towers out of range [0.8, 1.2]", (1-rv)*100));     
-      if (rv < 0.9) {
-        test[specie] = 0.9 ;
-        // 2 lines text info for quality         
-        fText->SetFillColor(2) ;
-        fText->AddText(Form("EMCAL = NOK, CALL EXPERTS!!!")); 
-      }
-      else {
-        test[specie] = 0.1 ;
-        fText->SetFillColor(3) ;
-        fText->AddText(Form("EMCAL = OK, ENJOY...")); 
-      }
-      //hdata->Reset("ICE");
-     //ratio->Reset("ICE");
+        
+        fText->AddText(Form("%2.2f %% towers out of range [0.8, 1.2]", (1-rv)*100));     
+        if (rv < 0.9) {
+          test[specie] = 0.9 ;
+          // 2 lines text info for quality         
+          fText->SetFillColor(2) ;
+          fText->AddText(Form("EMCAL = NOK, CALL EXPERTS!!!")); 
+        }
+        else {
+          test[specie] = 0.1 ;
+          fText->SetFillColor(3) ;
+          fText->AddText(Form("EMCAL = OK, ENJOY...")); 
+        }
+        //hdata->Reset("ICE");
+        //ratio->Reset("ICE");
+      }//fText
      } 
     } //finish the checking
 }
index 3ca7095..566cf6f 100644 (file)
@@ -88,9 +88,12 @@ AliEMCALReconstructor::AliEMCALReconstructor()
   //To make sure we match with the geometry in a simulation file,
   //let's try to get it first.  If not, take the default geometry
   AliRunLoader *rl = AliRunLoader::Instance();
-  if (rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL")) {
-    fGeom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
-  } else {
+  if (rl->GetAliRun()){
+    AliEMCAL * emcal = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"));
+    if(emcal) fGeom = emcal->GetGeometry();
+  }
+  
+  if(!fGeom) {
     AliInfo(Form("Using default geometry in reconstruction"));
     fGeom =  AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
   }
@@ -176,22 +179,24 @@ void AliEMCALReconstructor::InitClusterizer()
   
   AliEMCALRecParam *recParam = NULL;
   AliCDBEntry *entry = (AliCDBEntry*) 
-    AliCDBManager::Instance()->Get("EMCAL/Calib/RecoParam");
+  AliCDBManager::Instance()->Get("EMCAL/Calib/RecoParam");
   //Get The reco param for the default event specie
   if (entry) 
     recParam = (AliEMCALRecParam*)((TObjArray *) entry->GetObject())->At(0);
   
-  if(!recParam)  
+  if(!recParam){  
     AliFatal("RecoParam not found in CDB!");
-  
-  if (recParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
+  }
+  else{
+    if (recParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
     {
       fgClusterizer = new AliEMCALClusterizerv1(fGeom, fCalibData,fPedestalData); 
     }
-  else
+    else
     {
       fgClusterizer = new AliEMCALClusterizerNxN(fGeom, fCalibData,fPedestalData); 
     }
+  }
   
 }
 
@@ -559,11 +564,12 @@ void AliEMCALReconstructor::FillMisalMatrixes(AliESDEvent* esd)const{
                return ;
        }
        //Note, that owner of copied marixes will be header
-       char path[255] ;
+  const Int_t bufsize = 255;
+       char path[bufsize] ;
        TGeoHMatrix * m = 0x0;
        for(Int_t sm = 0; sm < fGeom->GetNumberOfSuperModules(); sm++){
-               sprintf(path,"/ALIC_1/XEN1_1/SMOD_%d",sm+1) ; //In Geometry modules numbered 1,2,.,5
-               if(sm >= 10) sprintf(path,"/ALIC_1/XEN1_1/SM10_%d",sm-10+1) ;
+               snprintf(path,bufsize,"/ALIC_1/XEN1_1/SMOD_%d",sm+1) ; //In Geometry modules numbered 1,2,.,5
+               if(sm >= 10) snprintf(path,bufsize,"/ALIC_1/XEN1_1/SM10_%d",sm-10+1) ;
                
                if (gGeoManager->CheckPath(path)){
                        gGeoManager->cd(path);
index 5ddce28..eab20f7 100644 (file)
@@ -251,7 +251,7 @@ void AliEMCALSDigitizer::Exec(Option_t *option)
        if (!fInit) { // to prevent overwrite existing file
                AliError( Form("Give a version name different from %s", fEventFolderName.Data()) ) ;
                return ;
-    }
+  }
        
        if (fLastEvent == -1) 
                fLastEvent = rl->GetNumberOfEvents() - 1 ;
@@ -272,7 +272,7 @@ void AliEMCALSDigitizer::Exec(Option_t *option)
                        emcalLoader->MakeSDigitsContainer();
                        treeS = emcalLoader->TreeS();
                }
-
+    
                TClonesArray * sdigits = emcalLoader->SDigits() ;
                sdigits->Clear("C");
                
@@ -288,52 +288,64 @@ void AliEMCALSDigitizer::Exec(Option_t *option)
                        //if(fHits)fHits->Clear();
                        branchH->SetAddress(&fHits);
                        for (iTrack = 0; iTrack < nTrack; iTrack++) {
-                               branchH->GetEntry(iTrack);
-                               Int_t nHit = fHits->GetEntriesFast();
-                               for(iHit = 0; iHit< nHit;iHit++){
-                                       
-                                       AliEMCALHit * hit = dynamic_cast<AliEMCALHit*>(fHits->At(iHit)) ;
-                                       AliEMCALDigit * curSDigit = 0 ;
-                                       AliEMCALDigit * sdigit = 0 ;
-                                       Bool_t newsdigit = kTRUE; 
-                                       
-                                       // hit->GetId() - Absolute Id number EMCAL segment
-                                       if(geom->CheckAbsCellId(hit->GetId())) { // was IsInECA(hit->GetId())
-                                               energy = hit->GetEnergy() * fSampling; // 23-nov-04
-                                               if(energy >  fECPrimThreshold )
-                                                       // Assign primary number only if deposited energy is significant
-                                                       curSDigit =  new AliEMCALDigit(hit->GetPrimary(),
-                                                                                                                  hit->GetIparent(), hit->GetId(), 
-                                                                                                                  Digitize(energy), hit->GetTime(),kFALSE,
-                                                                                                                  -1, 0,0,energy ) ;
-                                               else
-                                                       curSDigit =  new AliEMCALDigit(-1, 
-                                                                                                                  -1,
-                                                                                                                  hit->GetId(), 
-                                                                                                                  Digitize(energy), hit->GetTime(),kFALSE,
-                                                                                                                  -1, 0,0,energy ) ;
-                                       } else {
-                                               Warning("Exec"," abs id %i is bad \n", hit->GetId());
-                                               newsdigit = kFALSE;
-                                               curSDigit = 0;
-                                       }
-                                       
-                                       if(curSDigit != 0){
-                                               for(Int_t check= 0; check < nSdigits ; check++) {
-                                                       sdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(check)) ;
-                                                       
-                                                       if( sdigit->GetId() == curSDigit->GetId()) { // Are we in the same ECAL tower ?              
-                                                               *sdigit = *sdigit + *curSDigit;
-                                                               newsdigit = kFALSE;
-                                                       }
-                                               }
-                                       }
-                                       if (newsdigit) {
-                                               new((*sdigits)[nSdigits])  AliEMCALDigit(*curSDigit);
-                                               nSdigits++ ;  
-                                       }
-                                       delete curSDigit ; 
-                               }  // loop over all hits (hit = deposited energy/entering particle)
+                               branchH->GetEntry(iTrack); 
+        
+        if(fHits){
+          
+          Int_t nHit = fHits->GetEntriesFast();
+          for(iHit = 0; iHit< nHit;iHit++){
+            
+            AliEMCALHit * hit = dynamic_cast<AliEMCALHit*>(fHits->At(iHit)) ;
+            AliEMCALDigit * curSDigit = 0 ;
+            AliEMCALDigit * sdigit = 0 ;
+            Bool_t newsdigit = kTRUE; 
+            
+            // hit->GetId() - Absolute Id number EMCAL segment
+            if(hit){
+              if(geom->CheckAbsCellId(hit->GetId())) { // was IsInECA(hit->GetId())
+                energy = hit->GetEnergy() * fSampling; // 23-nov-04
+                if(energy >  fECPrimThreshold )
+                  // Assign primary number only if deposited energy is significant
+                  curSDigit =  new AliEMCALDigit(hit->GetPrimary(),
+                                                 hit->GetIparent(), hit->GetId(), 
+                                                 Digitize(energy), hit->GetTime(),kFALSE,
+                                                 -1, 0,0,energy ) ;
+                else
+                  curSDigit =  new AliEMCALDigit(-1, 
+                                                 -1,
+                                                 hit->GetId(), 
+                                                 Digitize(energy), hit->GetTime(),kFALSE,
+                                                 -1, 0,0,energy ) ;
+              } else {
+                Warning("Exec"," abs id %i is bad \n", hit->GetId());
+                newsdigit = kFALSE;
+                curSDigit = 0;
+              }
+              
+              if(curSDigit != 0){
+                for(Int_t check= 0; check < nSdigits ; check++) {
+                  sdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(check)) ;
+                  
+                  if( sdigit->GetId() == curSDigit->GetId()) { // Are we in the same ECAL tower ?              
+                    *sdigit = *sdigit + *curSDigit;
+                    newsdigit = kFALSE;
+                  }
+                }
+              }
+              if (newsdigit) {
+                new((*sdigits)[nSdigits])  AliEMCALDigit(*curSDigit);
+                nSdigits++ ;  
+              }
+              delete curSDigit ;
+              
+            }// hit exists
+            else AliFatal("Hit is NULL!");
+            
+          }  // loop over all hits (hit = deposited energy/entering particle)
+          
+        }//fHits is not NULL
+        else AliFatal("fHit is NULL!");
+        
                                sdigits->Sort() ;
                                
                                nSdigits = sdigits->GetEntriesFast() ;
@@ -341,7 +353,8 @@ void AliEMCALSDigitizer::Exec(Option_t *option)
                                
                                for (iSDigit = 0 ; iSDigit < sdigits->GetEntriesFast() ; iSDigit++) { 
                                        AliEMCALDigit * sdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(iSDigit)) ;
-                                       sdigit->SetIndexInList(iSDigit) ;
+                                       if(sdigit)sdigit->SetIndexInList(iSDigit) ;
+          else AliFatal("sdigit is NULL!");
                                }       
                                if(fHits)fHits->Clear();
                        }//track loop
@@ -374,7 +387,7 @@ void AliEMCALSDigitizer::Exec(Option_t *option)
        if(strstr(option,"tim")){
                gBenchmark->Stop("EMCALSDigitizer"); 
                printf("\n Exec: took %f seconds for SDigitizing %f seconds per event\n", 
-                          gBenchmark->GetCpuTime("EMCALSDigitizer"), gBenchmark->GetCpuTime("EMCALSDigitizer")/nEvents ) ; 
+           gBenchmark->GetCpuTime("EMCALSDigitizer"), gBenchmark->GetCpuTime("EMCALSDigitizer")/nEvents ) ; 
        }
 }
 
@@ -459,37 +472,44 @@ Bool_t AliEMCALSDigitizer::operator==( AliEMCALSDigitizer const &sd )const
 void AliEMCALSDigitizer::PrintSDigits(Option_t * option)
 {
   //Prints list of digits produced at the current pass of AliEMCALDigitizer
-    
-  AliEMCALLoader *rl = dynamic_cast<AliEMCALLoader*>(AliRunLoader::Instance()->GetDetectorLoader("EMCAL"));
-  const TClonesArray * sdigits = rl->SDigits() ; 
   
-  printf("\n") ;  
-  printf("event %i", rl->GetRunLoader()->GetEventNumber());
-  printf(" Number of entries in SDigits list %i", sdigits->GetEntriesFast()); 
-  if(strstr(option,"all")||strstr(option,"EMC")){
+  AliEMCALLoader *rl = dynamic_cast<AliEMCALLoader*>(AliRunLoader::Instance()->GetDetectorLoader("EMCAL"));
+  if(rl){
+    const TClonesArray * sdigits = rl->SDigits() ; 
     
-    //loop over digits
-    AliEMCALDigit * digit;
-    printf("\n   Id  Amplitude    Time          Index Nprim: Primaries list \n") ;    
-       Int_t   index = 0;
-    Float_t isum  = 0.;
-    char * tempo = new char[8192]; 
-    for (index = 0 ; index < sdigits->GetEntries() ; index++) {
-      digit = dynamic_cast<AliEMCALDigit *>( sdigits->At(index) ) ;
-      sprintf(tempo, "\n%6d  %8f    %6.5e %4d      %2d :",
-             digit->GetId(), digit->GetAmplitude(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;  
-      printf("%s",tempo);
-      isum += digit->GetAmplitude();
+    printf("\n") ;  
+    printf("event %i", rl->GetRunLoader()->GetEventNumber());
+    printf(" Number of entries in SDigits list %i", sdigits->GetEntriesFast()); 
+    if(strstr(option,"all")||strstr(option,"EMC")){
       
-      Int_t iprimary;
-      for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
-                 sprintf(tempo, "%d ",digit->GetPrimary(iprimary+1) ) ; 
-       printf("%s",tempo); 
-      }         
-    }
-    delete [] tempo ;
-    printf("\n** Sum %2.3f : %10.3f GeV/c **\n ", isum, Calibrate(isum));
-  } else printf("\n");
+      //loop over digits
+      AliEMCALDigit * digit;
+      printf("\n   Id  Amplitude    Time          Index Nprim: Primaries list \n") ;    
+      Int_t   index = 0;
+      Float_t isum  = 0.;
+      const Int_t bufferSize = 8192;
+      char * tempo = new char[bufferSize]; 
+      for (index = 0 ; index < sdigits->GetEntries() ; index++) {
+        digit = dynamic_cast<AliEMCALDigit *>( sdigits->At(index) ) ;
+        if(digit){
+          snprintf(tempo, bufferSize,"\n%6d  %8f    %6.5e %4d      %2d :",
+                  digit->GetId(), digit->GetAmplitude(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;  
+          printf("%s",tempo);
+          isum += digit->GetAmplitude();
+          
+          Int_t iprimary;
+          for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
+            snprintf(tempo,bufferSize, "%d ",digit->GetPrimary(iprimary+1) ) ; 
+            printf("%s",tempo); 
+          }  
+        } //sdigit exists
+        else AliFatal("SDigit is NULL!");
+      }//loop
+      delete [] tempo ;
+      printf("\n** Sum %2.3f : %10.3f GeV/c **\n ", isum, Calibrate(isum));
+    } else printf("\n");
+  }
+  else AliFatal("EMCALLoader is NULL!");
 }
 
 //____________________________________________________________________________ 
@@ -497,8 +517,11 @@ void AliEMCALSDigitizer::Unload() const
 {
   // Unload Hits and SDigits from the folder
   AliEMCALLoader *rl = dynamic_cast<AliEMCALLoader*>(AliRunLoader::Instance()->GetDetectorLoader("EMCAL"));
-  rl->UnloadHits() ; 
-  rl->UnloadSDigits() ; 
+  if(rl){
+    rl->UnloadHits() ; 
+    rl->UnloadSDigits() ;
+  }
+  else AliFatal("EMCALLoader is NULL!");
 }
 
 //____________________________________________________________________________ 
index 7782097..d27f890 100644 (file)
@@ -84,24 +84,24 @@ AliEMCALSurvey::AliEMCALSurvey(const TString &txtFileName,const SurveyDataType_t
   //Get the geometry object and then attempt to
   //read survey data from a file, depending on which
   //method (kSurvey or kDummy) is selected.
-
+  
   const AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance();
   if (!geom) {
     AliError("Cannot obtain AliEMCALGeometry instance.");
     return;
   }
-
+  
   fNSuperModule = geom->GetNumberOfSuperModules();
-
+  
   if(fDataType == kSurvey) {
-
+    
     AliSurveyObj *s1 = new AliSurveyObj();
     s1->FillFromLocalFile(txtFileName);
     TObjArray* points = s1->GetData();
     InitSuperModuleData(points);
-
+    
   } else {
-
+    
     //Use a dummy file that stores x,y,z of the center of each SM
     //useful for testing...
     std::ifstream inputFile(txtFileName.Data());
@@ -109,39 +109,48 @@ AliEMCALSurvey::AliEMCALSurvey(const TString &txtFileName,const SurveyDataType_t
       AliError(("Cannot open the survey file " + txtFileName).Data());
       return;
     }
+    
     Int_t dummyInt = 0;
-    Double_t *xReal = new Double_t[fNSuperModule];
-    Double_t *yReal = new Double_t[fNSuperModule];
-    Double_t *zReal = new Double_t[fNSuperModule];
-    Double_t *psiReal = new Double_t[fNSuperModule];
+    Double_t *xReal     = new Double_t[fNSuperModule];
+    Double_t *yReal     = new Double_t[fNSuperModule];
+    Double_t *zReal     = new Double_t[fNSuperModule];
+    Double_t *psiReal   = new Double_t[fNSuperModule];
     Double_t *thetaReal = new Double_t[fNSuperModule];
-    Double_t *phiReal = new Double_t[fNSuperModule];
-
+    Double_t *phiReal   = new Double_t[fNSuperModule];
+    //init the arrays
+    memset(xReal,     0,sizeof(Int_t)*fNSuperModule);
+    memset(yReal,     0,sizeof(Int_t)*fNSuperModule);
+    memset(zReal,     0,sizeof(Int_t)*fNSuperModule);
+    memset(psiReal,   0,sizeof(Int_t)*fNSuperModule);
+    memset(thetaReal, 0,sizeof(Int_t)*fNSuperModule);
+    memset(phiReal,   0,sizeof(Int_t)*fNSuperModule);
+    
+    
     for (Int_t i = 0; i < fNSuperModule; ++i) {
       if (!inputFile) {
-       AliError("Error while reading input file.");
-       delete [] xReal;
-       delete [] yReal;
-       delete [] zReal;
-       delete [] psiReal;
-       delete [] thetaReal;
-       delete [] phiReal;
-       return;
+        AliError("Error while reading input file.");
+        delete [] xReal;
+        delete [] yReal;
+        delete [] zReal;
+        delete [] psiReal;
+        delete [] thetaReal;
+        delete [] phiReal;
+        return;
       }
       inputFile>>dummyInt>>xReal[i]>>yReal[i]>>zReal[i]>>psiReal[i]>>thetaReal[i]>>phiReal[i];
     }
-
+    
     InitSuperModuleData(xReal, yReal, zReal, psiReal, thetaReal, phiReal);
-
+    
     delete [] xReal;
     delete [] yReal;
     delete [] zReal;
     delete [] psiReal;
     delete [] thetaReal;
     delete [] phiReal;
-
+    
   } //kDummy way of doing it
-
+  
 }
 
 //____________________________________________________________________________
@@ -241,54 +250,54 @@ void AliEMCALSurvey::InitSuperModuleData(const TObjArray *svypts)
   //This method uses the data points from the EMCAL survey and CATIA program to
   //create the alignment matrices.  Only valid for (installed)
   //SM, others will have null objects
-
+  
   /*--------------------------------------
-    The bottom edges of the strip modules
-    define the active area of the EMCAL, but
-    in software we have a box to hold them which
-    is longer than that.  We need to convert
-    info about the position of the corners of the
-    bottom of the active area to the center of
-    the software box that contains the strip
-    modules.
-
-    View from beam axis up to EMCAL
-              Ai                Ci
-
-        0,1         0,0 1,0          1,1
-    xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx
-    x   x             x x              x   x
-    x   x    % *      x x      * %     x   x
-    x   x             x x              x   x
-    xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx
-        1,1         1,0 0,0          0,1
-    <--> = added length                 <--> = added length
-
-    * represents the center of the active area
-    % represents the center of the full box (with added length)
-
-         View from side of topmost SM
-
-              Ai                Ci
-
-        0,1         0,0 1,0          1,1
-    xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx
-    x   x    % *      x x      % *     x   x
-    xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx
-        1,1         1,0 0,0          0,1
-    <--> = added length                 <--> = added length
-
-    * represents the center of the active area
-    % represents the center of the full box (with added length)
-
-    -------------------------------------*/
-
+   The bottom edges of the strip modules
+   define the active area of the EMCAL, but
+   in software we have a box to hold them which
+   is longer than that.  We need to convert
+   info about the position of the corners of the
+   bottom of the active area to the center of
+   the software box that contains the strip
+   modules.
+   
+   View from beam axis up to EMCAL
+   Ai                Ci
+   
+   0,1         0,0 1,0          1,1
+   xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx
+   x   x             x x              x   x
+   x   x    % *      x x      * %     x   x
+   x   x             x x              x   x
+   xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx
+   1,1         1,0 0,0          0,1
+   <--> = added length                 <--> = added length
+   
+   * represents the center of the active area
+   % represents the center of the full box (with added length)
+   
+   View from side of topmost SM
+   
+   Ai                Ci
+   
+   0,1         0,0 1,0          1,1
+   xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx
+   x   x    % *      x x      % *     x   x
+   xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx
+   1,1         1,0 0,0          0,1
+   <--> = added length                 <--> = added length
+   
+   * represents the center of the active area
+   % represents the center of the full box (with added length)
+   
+   -------------------------------------*/
+  
   AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance();
   //Center of supermodules
   Float_t *pars = geom->GetSuperModulesPars();
   Double_t rpos = (geom->GetEnvelop(0) + geom->GetEnvelop(1))/2.;
   Double_t phi=0, phiRad=0, xpos=0, ypos=0, zpos=0;
-
+  
   AliEMCALSuperModuleCoords *idealSM = new AliEMCALSuperModuleCoords[fNSuperModule];
   for (Int_t smodnum = 0; smodnum < geom->GetNumberOfSuperModules(); ++smodnum) {
     AliEMCALSuperModuleCoords &smc = idealSM[smodnum];
@@ -311,25 +320,25 @@ void AliEMCALSurvey::InitSuperModuleData(const TObjArray *svypts)
     } else {
       smc.fZ1 = -zpos;
     }
-
+    
     //printf("PHI OF IDEAL SM = %.2f\n",smc.fPhi);
-
+    
   }
-
+  
   //Real coordinates of center and rotation angles need to be computed
   //from the survey/CATIA points
-
-  char substr[100];
+  const Int_t buffersize = 255;
+  char substr[buffersize];
   AliEMCALSuperModuleCoords *realSM = new AliEMCALSuperModuleCoords[fNSuperModule];
   for (Int_t smodnum = 0; smodnum < geom->GetNumberOfSuperModules(); ++smodnum) {
     AliEMCALSuperModuleCoords &smc = realSM[smodnum];
     Double_t zLength = pars[2]*2.; //length of SM in z from software
     Double_t halfHeight = pars[0]; //half the height of the SM in y direction
-
-    sprintf(substr,"4096%d",smodnum);
+    
+    snprintf(substr,buffersize,"4096%d",smodnum);
     //retrieve components of four face points and determine average position of center
     //in x,y,z
-
+    
     std::vector<Double_t> xval;
     std::vector<Double_t> yval;
     std::vector<Double_t> zval;
@@ -338,22 +347,22 @@ void AliEMCALSurvey::InitSuperModuleData(const TObjArray *svypts)
       AliSurveyPoint* pt = (AliSurveyPoint*)svypts->At(i);
       TString ptname = pt->GetPointName();
       if(ptname.Contains(substr)) {
-       //Note: order of values is 00, 01, 10, 11
-       xval.push_back(pt->GetX()*100.); //convert m to cm
-       yval.push_back(pt->GetY()*100.); 
-       zval.push_back(pt->GetZ()*100.); 
+        //Note: order of values is 00, 01, 10, 11
+        xval.push_back(pt->GetX()*100.); //convert m to cm
+        yval.push_back(pt->GetY()*100.); 
+        zval.push_back(pt->GetZ()*100.); 
       }
     }
-
+    
     //compute center of active area of each SM on bottome face from survey points
     Double_t activeX = ((xval[0] + (xval[2] - xval[0])/2.)        //x00 and x10
-                       +(xval[1] + (xval[3] - xval[1])/2.) ) /2.; //x01 and x11
+                        +(xval[1] + (xval[3] - xval[1])/2.) ) /2.; //x01 and x11
     
-//    Double_t activeY = ((yval[0] + (yval[2] - yval[0])/2.)
-//                     +(yval[1] + (yval[3] - yval[1])/2.) ) /2.;
-//    
-//    Double_t activeZ = ((zval[0] + (zval[2] - zval[0])/2.)
-//                     +(zval[1] + (zval[3] - zval[1])/2.) ) /2.;
+    //    Double_t activeY = ((yval[0] + (yval[2] - yval[0])/2.)
+    //                 +(yval[1] + (yval[3] - yval[1])/2.) ) /2.;
+    //    
+    //    Double_t activeZ = ((zval[0] + (zval[2] - zval[0])/2.)
+    //                 +(zval[1] + (zval[3] - zval[1])/2.) ) /2.;
     
     //printf("Bottom Center of active area of SM %s: %.2f, %.2f, %.2f\n",substr,activeX,activeY,activeZ);
     
@@ -365,26 +374,26 @@ void AliEMCALSurvey::InitSuperModuleData(const TObjArray *svypts)
     //Note: this is phi wrt y axis.  To get phi wrt to x, add pi/2
     if(smodnum%2 == 0) {
       realphi = (TMath::ATan((yval[2] - yval[0])/(xval[2] - xval[0])) 
-                +TMath::ATan((yval[3] - yval[1])/(xval[3] - xval[1])) )/2.;
+                 +TMath::ATan((yval[3] - yval[1])/(xval[3] - xval[1])) )/2.;
     } else {
       realphi = (TMath::ATan((yval[0] - yval[2])/(xval[0] - xval[2]))
-                +TMath::ATan((yval[1] - yval[3])/(xval[1] - xval[3])) )/2.;
+                 +TMath::ATan((yval[1] - yval[3])/(xval[1] - xval[3])) )/2.;
     }
-
+    
     //NOTE: Psi angle is always zero because the two z values being
     //subtracted are exactly the same, but just in case that could change...
     //psi = angle in x-z plane
     Double_t realpsi = (TMath::ATan((zval[0] - zval[2])/(xval[2] - xval[0]))
-                       +TMath::ATan((zval[1] - zval[3])/(xval[3] - xval[1])) )/2.;
+                        +TMath::ATan((zval[1] - zval[3])/(xval[3] - xval[1])) )/2.;
     
     //theta = angle in y-z plane
     Double_t realtheta = TMath::Pi()/2. 
-                       - (TMath::ATan((zval[2] - zval[3])/(yval[3] - yval[2]))
-                         +TMath::ATan((zval[0] - zval[1])/(yval[1] - yval[0])) )/2.;
-
+    - (TMath::ATan((zval[2] - zval[3])/(yval[3] - yval[2]))
+       +TMath::ATan((zval[0] - zval[1])/(yval[1] - yval[0])) )/2.;
+    
     //printf("Old edge of %s 01: %.2f, %.2f, %.2f\n",substr,xval[1],yval[1],zval[1]);
     //printf("Old edge of %s 11: %.2f, %.2f, %.2f\n",substr,xval[3],yval[3],zval[3]);
-
+    
     //Now calculate the center of the box in z with length added to the 01
     //and 11 corners, corrected by the theta angle
     Double_t activeLength = TMath::Abs(((zval[1] - zval[0]) + (zval[3] - zval[2]))/2.);
@@ -400,37 +409,37 @@ void AliEMCALSurvey::InitSuperModuleData(const TObjArray *svypts)
       zval[1] -= (zLength - activeLength)*cos(realtheta);
       zval[3] -= (zLength - activeLength)*cos(realtheta);
     }
-
+    
     //printf("New extended edge of %s 01: %.2f, %.2f, %.2f\n",substr,xval[1],yval[1],zval[1]);            
     //printf("New extended edge of %s 11: %.2f, %.2f, %.2f\n",substr,xval[3],yval[3],zval[3]);
-
+    
     //Compute the center of the bottom of the box in x,y,z
     Double_t realX = activeX;    
     Double_t realY = ((yval[0] + (yval[2] - yval[0])/2.)
-                       +(yval[1] + (yval[3] - yval[1])/2.) ) /2.;    
+                      +(yval[1] + (yval[3] - yval[1])/2.) ) /2.;    
     Double_t realZ = ((zval[0] + (zval[2] - zval[0])/2.)
-                       +(zval[1] + (zval[3] - zval[1])/2.) ) /2.;
-
-
+                      +(zval[1] + (zval[3] - zval[1])/2.) ) /2.;
+    
+    
     //printf("Bottom Center of SM %s Box: %.2f, %.2f, %.2f\n",substr,realX,realY,realZ);
-
+    
     //correct the SM centers so that we have the center of the box in
     //x,y using the phi,theta angles                   
     realX += halfHeight*TMath::Cos(TMath::Pi()/2+realphi);
     realY += halfHeight*(TMath::Sin(TMath::Pi()/2+realphi) + TMath::Sin(realtheta));
     realZ += halfHeight*TMath::Cos(TMath::Pi()/2-realtheta);
-
+    
     //printf("Rotation angles of SM %s: %.4f, %.4f, %.4f\n",substr,realphi*TMath::RadToDeg(),realpsi*TMath::RadToDeg(),realtheta*TMath::RadToDeg());
     //printf("Middle of SM %s: %.2f, %.2f, %.2f\n\n",substr,realX,realY,realZ);
-
+    
     smc.fX1 = realX;
     smc.fY1 = realY;
     smc.fZ1 = realZ;
-
+    
     smc.fPhi = 90. + realphi*TMath::RadToDeg();
     smc.fTheta = 0. + realtheta*TMath::RadToDeg();
     smc.fPsi = 0. + realpsi*TMath::RadToDeg();
-
+    
   }//loop over supermodules
   
   fSuperModuleData = new AliEMCALSuperModuleDelta[fNSuperModule];
@@ -445,7 +454,7 @@ void AliEMCALSurvey::InitSuperModuleData(const TObjArray *svypts)
     t.fPhi = real.fPhi - ideal.fPhi;
     t.fTheta = real.fTheta - ideal.fTheta;
     t.fPsi = real.fPsi - ideal.fPsi;
-
+    
     printf("===================== SM %d =======================\n",i);
     printf("real x (%.2f) - ideal x (%.2f) = shift in x (%.2f)\n",real.fX1,ideal.fX1,t.fXShift);
     printf("real y (%.2f) - ideal y (%.2f) = shift in y (%.2f)\n",real.fY1,ideal.fY1,t.fYShift);
@@ -455,7 +464,7 @@ void AliEMCALSurvey::InitSuperModuleData(const TObjArray *svypts)
     printf("real phi (%.2f) - ideal phi (%.2f) = shift in phi %.2f\n",real.fPhi,ideal.fPhi,t.fPhi);
     printf("===================================================\n");    
   }
-
+  
   delete [] realSM;
   delete [] idealSM;
 }