]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Coverity corrections
authorgconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 16 Oct 2010 20:14:02 +0000 (20:14 +0000)
committergconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 16 Oct 2010 20:14:02 +0000 (20:14 +0000)
16 files changed:
EMCAL/AliCaloCalibSignal.cxx
EMCAL/AliCaloRawAnalyzer.cxx
EMCAL/AliCaloRawAnalyzerPeakFinder.cxx
EMCAL/AliEMCALClusterizer.cxx
EMCAL/AliEMCALEMCGeometry.cxx
EMCAL/AliEMCALPreprocessor.cxx
EMCAL/AliEMCALRecPoint.cxx
EMCAL/AliEMCALSensorTempArray.cxx
EMCAL/AliEMCALTrigger.cxx
EMCAL/AliEMCALTriggerBoard.cxx
EMCAL/AliEMCALTriggerDCSConfigDB.cxx
EMCAL/AliEMCALTriggerElectronics.cxx
EMCAL/AliEMCALTriggerRawDigitMaker.cxx
EMCAL/AliEMCALTriggerSTU.cxx
EMCAL/AliEMCALTriggerTRU.cxx
EMCAL/SMcalib/AliEMCALCCUSBRawStream.cxx

index 83e812a7f173a6ab5126dfa629e66130d31b3fe7..07de01d5bcfecf0f88c006696be2786fe4b49ccd 100644 (file)
@@ -141,7 +141,7 @@ AliCaloCalibSignal::AliCaloCalibSignal(const AliCaloCalibSignal &sig) :
   fLEDRefs(sig.GetLEDRefs()),
   fModules(sig.GetModules()),
   fCaloString(sig.GetCaloString()),
-  fMapping(NULL), //! note that we are not copying the map info
+  fMapping(), //! note that we are not copying the map info
   fRunNumber(sig.GetRunNumber()),
   fStartTime(sig.GetStartTime()),
   fAmpCut(sig.GetAmpCut()),
@@ -155,13 +155,23 @@ AliCaloCalibSignal::AliCaloCalibSignal(const AliCaloCalibSignal &sig) :
   fSecInAverage(sig.GetSecInAverage()),
   fNEvents(sig.GetNEvents()),
   fNAcceptedEvents(sig.GetNAcceptedEvents()),
-  fTreeAmpVsTime(NULL),
-  fTreeAvgAmpVsTime(NULL),
-  fTreeLEDAmpVsTime(NULL),
-  fTreeLEDAvgAmpVsTime(NULL)
+  fTreeAmpVsTime(),
+  fTreeAvgAmpVsTime(),
+  fTreeLEDAmpVsTime(),
+  fTreeLEDAvgAmpVsTime()
 {
   // also the TTree contents
   AddInfo(&sig);
+  for (Int_t i = 0; i<2*fgkMaxTowers; i++) {
+    if(i < fgkMaxTowers){
+      fNHighGain[i] = sig.fNHighGain[i];
+      fNLowGain[i]  = sig.fNLowGain[i]; 
+    }
+    fNRef[i] = sig.fNRef[i]; 
+  }
+  
+  
+  
 }
 
 // assignment operator; use copy ctor to make life easy..
@@ -724,8 +734,8 @@ Bool_t AliCaloCalibSignal::Analyze()
   //1: set up TProfiles for the towers that had data
   TProfile * profile[fgkMaxTowers*2]; // *2 is since we include both high and low gains
   memset(profile, 0, sizeof(profile));
-
-  char name[200]; // for profile id and title
+  const Int_t buffersize = 200;
+  char name[buffersize]; // for profile id and title
   int iTowerNum = 0;
 
   for (int i = 0; i<fModules; i++) {
@@ -736,14 +746,14 @@ Bool_t AliCaloCalibSignal::Analyze()
        // high gain
        if (fNHighGain[iTowerNum] > 0) {
          fChannelNum = GetChannelNum(i, ic, ir, 1); 
-         sprintf(name, "profileChan%d", fChannelNum);
+         snprintf(name,buffersize,"profileChan%d", fChannelNum);
          profile[fChannelNum] = new TProfile(name, name, numProfBins, timeMin, timeMax, "s");
        }
 
        // same for low gain
        if (fNLowGain[iTowerNum] > 0) {
          fChannelNum = GetChannelNum(i, ic, ir, 0); 
-         sprintf(name, "profileChan%d", fChannelNum);
+         snprintf(name,buffersize,"profileChan%d", fChannelNum);
          profile[fChannelNum] = new TProfile(name, name, numProfBins, timeMin, timeMax, "s");
        }
 
index 50bd8ff2b3caf7b5f39d01bab56d5e84b9d743b2..d74b1994a42f9b7f7d45a241aab054c5a078bc52 100644 (file)
@@ -48,8 +48,8 @@ AliCaloRawAnalyzer::AliCaloRawAnalyzer(const char *name, const char *nameshort)
   fAlgo(Algo::kNONE)
 {
   //Comment 
-  sprintf(fName, "%s", name);
-  sprintf(fNameShort, "%s", nameshort);
+  snprintf(fName, 256,"%s", name);
+  snprintf(fNameShort,256, "%s", nameshort);
     
   for(int i=0; i < MAXSAMPLES; i++ )
     {
index 02ebbe38b29cbeeea97f24ea8bfa4bf29b7be3f4..c246278d6af65a937e7bdc7c7164f0fca4b08c11 100644 (file)
@@ -273,53 +273,53 @@ AliCaloRawAnalyzerPeakFinder::LoadVectorsASCII()
 {
   //Read in the Peak finder vecors from ASCI files
   fIsInitialized= true;  
-
+  const Int_t buffersize = 256;
   for(int i = 0;  i < PF::MAXSTART ; i++)
+  {
+    for( int j=0; j < PF::SAMPLERANGE; j++)
     {
-      for( int j=0; j < PF::SAMPLERANGE; j++)
-       {
-         char filenameCoarse[256];
-         char filename[256];
-         int n = j+fNsampleCut;
-         double start = (double)i+0;
-         
-         sprintf(filename,        "%s/EMCAL/vectors-emcal/start%.1fN%dtau0.235fs10dt1.0.txt", getenv("ALICE_ROOT"), start, n);
-         sprintf(filenameCoarse,  "%s/EMCAL/vectors-emcal/start%.1fN%dtau0.235fs10dt3.0.txt", getenv("ALICE_ROOT"), start, n);
-         
-         FILE *fp  =  fopen(filename, "r");
-         FILE *fpc =  fopen(filenameCoarse, "r");
-
-         if( fp == 0 )
+      char filenameCoarse[buffersize];
+      char filename[buffersize];
+      int n = j+fNsampleCut;
+      double start = (double)i+0;
+      
+      snprintf(filename, buffersize,       "%s/EMCAL/vectors-emcal/start%.1fN%dtau0.235fs10dt1.0.txt", getenv("ALICE_ROOT"), start, n);
+      snprintf(filenameCoarse, buffersize, "%s/EMCAL/vectors-emcal/start%.1fN%dtau0.235fs10dt3.0.txt", getenv("ALICE_ROOT"), start, n);
+      
+      FILE *fp  =  fopen(filename, "r");
+      FILE *fpc =  fopen(filenameCoarse, "r");
+      
+      if( fp == 0 )
            {
              AliFatal( Form( "could not open file: %s", filename ) );
            }
-         if(fpc == 0)
+      else if(fpc == 0)
            {
              AliFatal( Form( "could not open file: %s", filenameCoarse ) );
            }
-         else
+      else
            {
              for(int m = 0; m < n ; m++ )
-               {
-                 fscanf(fp, "%lf\t", &fPFAmpVectors[i][j][m] );
-                 fscanf(fpc, "%lf\t", &fPFAmpVectorsCoarse[i][j][m] );
-               }
+        {
+          fscanf(fp, "%lf\t", &fPFAmpVectors[i][j][m] );
+          fscanf(fpc, "%lf\t", &fPFAmpVectorsCoarse[i][j][m] );
+        }
              fscanf(fp,   "\n" );
              fscanf(fpc,  "\n" );
              for(int m = 0; m < n ; m++ )
-               {
-                 fscanf(fp, "%lf\t",   &fPFTofVectors[i][j][m]  );
-                 fscanf(fpc, "%lf\t",  &fPFTofVectorsCoarse[i][j][m]  );  
-               }
+        {
+          fscanf(fp, "%lf\t",   &fPFTofVectors[i][j][m]  );
+          fscanf(fpc, "%lf\t",  &fPFTofVectorsCoarse[i][j][m]  );  
+        }
              
              fPeakFinderVectors->SetVector( i, j, fPFAmpVectors[i][j], fPFTofVectors[i][j],    
-                                            fPFAmpVectorsCoarse[i][j], fPFTofVectorsCoarse[i][j] );   
-                                                    
+                                      fPFAmpVectorsCoarse[i][j], fPFTofVectorsCoarse[i][j] );   
+        
              fclose (fp);
              fclose (fpc);
            }
-       }
     }
+  }
 }
 
 
index c6b88f5dca61989bd9a9cb941bd971cc2423312f..2963c2d434e41c34be66e08afcea198105b45a83 100644 (file)
@@ -259,10 +259,14 @@ void AliEMCALClusterizer::Init()
   // Attach the Clusterizer task to the list of EMCAL tasks
   
   AliRunLoader *rl = AliRunLoader::Instance();
-  if (rl->GetAliRun() && dynamic_cast<AliEMCAL*>(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){ 
     fGeom =  AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
+  }
   
   AliDebug(1,Form("geom %p",fGeom));
   
index af45c686e9dcf6c882ce6dff808e1b6b34dad351..4e4aa0c7c4ca43c87fa37073f05964c2690e7e7c 100644 (file)
@@ -92,6 +92,7 @@ AliEMCALEMCGeometry::AliEMCALEMCGeometry()
   // but should never be called by the outside world    
   fParSM[0]=0; fParSM[1]=0; fParSM[2]=0;
   fEnvelop[0] = 0; fEnvelop[1] = 0; fEnvelop[2] = 0;
+  for(Int_t i = 0; i < 6; i++) fkAdditionalOpts[i] = "";
   
   AliDebug(2, "AliEMCALEMCGeometry : default ctor ");
 }
@@ -200,6 +201,7 @@ AliEMCALEMCGeometry::AliEMCALEMCGeometry(const AliEMCALEMCGeometry& geom)
   fEnvelop[0] = geom.fEnvelop[0]; 
   fEnvelop[1] = geom.fEnvelop[1]; 
   fEnvelop[2] = geom.fEnvelop[2];
+  for(Int_t i = 0; i < 6; i++) fkAdditionalOpts[i] = geom.fkAdditionalOpts[i];
 
 }
 
index ed94b330582bc59b8c927f176e6aedc01919f231..3a30a83bafcaaa6fc1547d5cfc774412402c6257 100644 (file)
@@ -167,7 +167,7 @@ UInt_t AliEMCALPreprocessor::Process(TMap* dcsAliasMap)
   UInt_t dcsResult=0;
   if (errorHandling == "OFF" ) {
     if (!dcsAliasMap) dcsResult = kReturnCodeNoEntries;
-    if (dcsAliasMap->GetEntries() == 0 ) dcsResult = kReturnCodeNoEntries;  
+    else if (dcsAliasMap->GetEntries() == 0 ) dcsResult = kReturnCodeNoEntries;  
     status = new TParameter<int>("dcsResult",dcsResult);
     resultArray->Add(status);
   } 
@@ -207,15 +207,15 @@ UInt_t AliEMCALPreprocessor::Process(TMap* dcsAliasMap)
       if ( source == "HLT") pedestalSource[0] = AliShuttleInterface::kHLT;
       if (!GetHLTStatus()) pedestalSource[0] = AliShuttleInterface::kDAQ;
       if (source == "HLTDAQ" ) {
-       numSources=2;
-       pedestalSource[0] = AliShuttleInterface::kHLT;
-       pedestalSource[1] = AliShuttleInterface::kDAQ;
+        numSources=2;
+        pedestalSource[0] = AliShuttleInterface::kHLT;
+        pedestalSource[1] = AliShuttleInterface::kDAQ;
       }
       if (source == "DAQHLT" ) numSources=2;
       UInt_t pedestalResult=0;
       for (Int_t i=0; i<numSources; i++ ) {    
-       pedestalResult = ExtractPedestals(pedestalSource[i]);
-       if ( pedestalResult == 0 ) break;
+        pedestalResult = ExtractPedestals(pedestalSource[i]);
+        if ( pedestalResult == 0 ) break;
       }
       result += pedestalResult;
       status = new TParameter<int>("pedestalResult",pedestalResult);
@@ -233,15 +233,15 @@ UInt_t AliEMCALPreprocessor::Process(TMap* dcsAliasMap)
       if ( source == "HLT") signalSource[0] = AliShuttleInterface::kHLT;
       if (!GetHLTStatus()) signalSource[0] = AliShuttleInterface::kDAQ;
       if (source == "HLTDAQ" ) {
-       numSources=2;
-       signalSource[0] = AliShuttleInterface::kHLT;
-       signalSource[1] = AliShuttleInterface::kDAQ;
+        numSources=2;
+        signalSource[0] = AliShuttleInterface::kHLT;
+        signalSource[1] = AliShuttleInterface::kDAQ;
       }
       if (source == "DAQHLT" ) numSources=2;
       UInt_t signalResult=0;
       for (Int_t i=0; i<numSources; i++ ) {    
-       signalResult = ExtractSignal(signalSource[i]);
-       if ( signalResult == 0 ) break;
+        signalResult = ExtractSignal(signalSource[i]);
+        if ( signalResult == 0 ) break;
       }
       result += signalResult;
       status = new TParameter<int>("signalResult",signalResult);
index 733198228e51096f1fbf1204f75466fce9d70cd0..519cf2db3ad3bde5f658dcc60195f7a31581f49e 100644 (file)
@@ -835,23 +835,24 @@ Double_t phiSlope, TClonesArray * digits)
        
   for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) {
     digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ;
-    dist = deff;
-    //fGeomPtr->RelPosCellInSModule(digit->GetId(), idMax, dist, xyzi[0], xyzi[1], xyzi[2]);
-    fGeomPtr->RelPosCellInSModule(digit->GetId(), dist, xyzi[0], xyzi[1], xyzi[2]);
-    
-    if(logWeight > 0.0)  w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ));
-    else                 w = fEnergyList[iDigit]; // just energy
-    
-    if(w>0.0) {
-      wtot += w ;
-      nstat++;
-      for(i=0; i<3; i++ ) {
-        clXYZ[i]    += (w*xyzi[i]);
-        clRmsXYZ[i] += (w*xyzi[i]*xyzi[i]);
+    if(digit){
+      dist = deff;
+      //fGeomPtr->RelPosCellInSModule(digit->GetId(), idMax, dist, xyzi[0], xyzi[1], xyzi[2]);
+      fGeomPtr->RelPosCellInSModule(digit->GetId(), dist, xyzi[0], xyzi[1], xyzi[2]);
+      
+      if(logWeight > 0.0)  w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ));
+      else                 w = fEnergyList[iDigit]; // just energy
+      
+      if(w>0.0) {
+        wtot += w ;
+        nstat++;
+        for(i=0; i<3; i++ ) {
+          clXYZ[i]    += (w*xyzi[i]);
+          clRmsXYZ[i] += (w*xyzi[i]*xyzi[i]);
+        }
       }
-    }
-  }
+    }else AliError("Digit null");
+  }//loop
   //  cout << " wtot " << wtot << endl;
   if ( wtot > 0 ) { 
     //    xRMS   = TMath::Sqrt(x2m - xMean*xMean);
@@ -931,21 +932,22 @@ Bool_t AliEMCALRecPoint::EvalLocalPositionFromDigits(const Double_t esum, const
 
   for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) {
     digit = dynamic_cast<AliEMCALDigit *>(digits->At(iDigit));
-
-    //geo->RelPosCellInSModule(digit->GetId(), idMax, deff, xyzi[0], xyzi[1], xyzi[2]);
-    geo->RelPosCellInSModule(digit->GetId(), deff, xyzi[0], xyzi[1], xyzi[2]);
-
-    if(w0 > 0.0)  w = TMath::Max( 0., w0 + TMath::Log(ed[iDigit] / esum));
-    else          w = ed[iDigit]; // just energy
-
-    if(w>0.0) {
-      wtot += w ;
-      nstat++;
-      for(i=0; i<3; i++ ) {
-        clXYZ[i] += (w*xyzi[i]);
+    if(digit){
+      //geo->RelPosCellInSModule(digit->GetId(), idMax, deff, xyzi[0], xyzi[1], xyzi[2]);
+      geo->RelPosCellInSModule(digit->GetId(), deff, xyzi[0], xyzi[1], xyzi[2]);
+      
+      if(w0 > 0.0)  w = TMath::Max( 0., w0 + TMath::Log(ed[iDigit] / esum));
+      else          w = ed[iDigit]; // just energy
+      
+      if(w>0.0) {
+        wtot += w ;
+        nstat++;
+        for(i=0; i<3; i++ ) {
+          clXYZ[i] += (w*xyzi[i]);
+        }
       }
-    }
-  }
+    }else AliError("Digit null");
+  }//loop
   //  cout << " wtot " << wtot << endl;
   if (wtot > 0) { 
     for(i=0; i<3; i++ ) {
index 2c819198c9c572d238e983aede6d537a2ee92f41..7976bb3c7257decc65613092ad26705c0d9f08db 100644 (file)
@@ -44,9 +44,12 @@ AliEMCALSensorTempArray::AliEMCALSensorTempArray(Int_t run) : AliDCSSensorArray(
   
   AliCDBEntry *entry =
     AliCDBManager::Instance()->Get("EMCAL/Config/Temperature",run); 
-  TTree *tree = (TTree*) entry->GetObject();
-  fSensors = AliEMCALSensorTemp::ReadTree(tree);
-  fSensors->BypassStreamer(kFALSE);
+  if(entry){
+    TTree *tree = (TTree*) entry->GetObject();
+    fSensors = AliEMCALSensorTemp::ReadTree(tree);
+    fSensors->BypassStreamer(kFALSE);
+  }
+  else AliFatal("CDB entry null!");
 }
 //_____________________________________________________________________________
 AliEMCALSensorTempArray::AliEMCALSensorTempArray(UInt_t startTime, UInt_t endTime,
index 0560675d87bacc794f0f523d4df2dd9044509c13..933d7fb0d3b0d7f672cd71a04f560f9442582fc5 100644 (file)
@@ -266,6 +266,11 @@ Bool_t AliEMCALTrigger::IsPatchIsolated(Int_t iPatchType, const TClonesArray * a
   }
   if(iSM>9) rowborder /= 2; // half size in phi
   
+  if(!ampmatrixes){
+    AliError("Could not recover the matrix with the amplitudes");
+    return kFALSE;
+  }
+  
   //Define patch modules - what is this ??
   Int_t isolmodules   = fIsolPatchSize*(1+iPatchType);
   Int_t ipatchmodules = 2*(1+fPatchSize*iPatchType);
@@ -433,7 +438,7 @@ void AliEMCALTrigger::MakeSlidingCell(const TClonesArray * amptrus, const TClone
 */
 //____________________________________________________________________________
 void AliEMCALTrigger::MakeSlidingTowers(const TClonesArray * amptrus, const TClonesArray * timeRtrus, 
-const Int_t isupermod,TMatrixD &ampmax2, TMatrixD &ampmaxn){
+                                        const Int_t isupermod,TMatrixD &ampmax2, TMatrixD &ampmaxn){
   
   // Output from module (2x2 cells from one module)
   Int_t nModulesPhi  = fGeom->GetNModulesInTRUPhi(); // now 4 modules (3 div in phi)
@@ -444,8 +449,8 @@ const Int_t isupermod,TMatrixD &ampmax2, TMatrixD &ampmaxn){
   Int_t nTRU         = fGeom->GetNTRU();
   static int keyPrint = 0;
   if(keyPrint) AliDebug(2,Form("MakeSlidingTowers : nTRU %i nModulesPhi %i nModulesEta %i ", 
-  nTRU, nModulesPhi, nModulesEta ));
-
+                               nTRU, nModulesPhi, nModulesEta ));
+  
   Float_t amp2 = 0 ;
   Float_t ampn = 0 ; 
   for(Int_t i = 0; i < 4; i++){
@@ -453,89 +458,94 @@ const Int_t isupermod,TMatrixD &ampmax2, TMatrixD &ampmaxn){
       ampmax2(i,j) = ampmaxn(i,j) = -1;
     }
   }
-
+  
   // Create matrix that will contain 2x2 amplitude sums
   // used to calculate the nxn sums
   TMatrixD tru2x2(nModulesPhi/2,nModulesEta/2);
-
+  
   // Loop over all TRUS in a supermodule
   for(Int_t itru = 0 + isupermod * nTRU ; itru < (isupermod+1)*nTRU ; itru++) {
     TMatrixD * amptru   = dynamic_cast<TMatrixD *>(amptrus->At(itru)) ;
     TMatrixD * timeRtru = dynamic_cast<TMatrixD *>(timeRtrus->At(itru)) ;
     Int_t mtru = itru - isupermod*nTRU ; // Number of TRU in Supermodule !!
-   
+    
+    if(!amptru || !timeRtru){
+      AliError("Amplitude or Time TRU matrix not available")
+      return;
+    }
+    
     // Sliding 2x2, add 2x2 amplitudes (NOT OVERLAP)
     for(Int_t irow = 0 ; irow <  nModulesPhi; irow +=2){ 
       for(Int_t icol = 0 ; icol < nModulesEta ; icol +=2){
-       amp2 = (*amptru)(irow,icol) +(*amptru)(irow+1,icol)+
-         (*amptru)(irow,icol+1)+(*amptru)(irow+1,icol+1);
-
-       //Fill matrix with added 2x2 towers for use in nxn sums
-       tru2x2(irow/2,icol/2) = amp2 ;
-       //Select 2x2 maximum sums to select L0 
-       if(amp2 > ampmax2(0,mtru)){
-         ampmax2(0,mtru) = amp2 ; 
-         ampmax2(1,mtru) = irow;
-         ampmax2(2,mtru) = icol;
-       }
+        amp2 = (*amptru)(irow,icol) +(*amptru)(irow+1,icol)+
+        (*amptru)(irow,icol+1)+(*amptru)(irow+1,icol+1);
+        
+        //Fill matrix with added 2x2 towers for use in nxn sums
+        tru2x2(irow/2,icol/2) = amp2 ;
+        //Select 2x2 maximum sums to select L0 
+        if(amp2 > ampmax2(0,mtru)){
+          ampmax2(0,mtru) = amp2 ; 
+          ampmax2(1,mtru) = irow;
+          ampmax2(2,mtru) = icol;
+        }
       }
     }
     
     ampmax2(3,mtru) = 0.;
     if(GetTimeKey()) {
-    // Find most recent time in the selected 2x2 towers
+      // Find most recent time in the selected 2x2 towers
       Int_t row2 =  static_cast <Int_t> (ampmax2(1,mtru));
       Int_t col2 =  static_cast <Int_t> (ampmax2(2,mtru));
       for(Int_t i = 0; i<2; i++){
         for(Int_t j = 0; j<2; j++){
-         if((*amptru)(row2+i,col2+j) > 0 &&  (*timeRtru)(row2+i,col2+j)> 0){     
-           if((*timeRtru)(row2+i,col2+j) >  ampmax2(3,mtru)  )
-             ampmax2(3,mtru) =  (*timeRtru)(row2+i,col2+j); // max time
-         }
+          if((*amptru)(row2+i,col2+j) > 0 &&  (*timeRtru)(row2+i,col2+j)> 0){    
+            if((*timeRtru)(row2+i,col2+j) >  ampmax2(3,mtru)  )
+              ampmax2(3,mtru) =  (*timeRtru)(row2+i,col2+j); // max time
+          }
         }
       }
     }
-
+    
     //Sliding nxn, add nxn amplitudes  (OVERLAP)
     if(fPatchSize > 0){
       for(Int_t irow = 0 ; irow <  nModulesPhi/2; irow++){ 
-       for(Int_t icol = 0 ; icol < nModulesEta/2; icol++){
-         ampn = 0;
-         if( (irow+fPatchSize) < nModulesPhi/2 && (icol+fPatchSize) < nModulesEta/2){ //Avoid exit the TRU
-           for(Int_t i = 0 ; i <= fPatchSize ; i++)
-             for(Int_t j = 0 ; j <= fPatchSize ; j++)
-               ampn += tru2x2(irow+i,icol+j);
-           //Select nxn maximum sums to select L1 
-           if(ampn > ampmaxn(0,mtru)){
-             ampmaxn(0,mtru) = ampn ; 
-             ampmaxn(1,mtru) = irow;
-             ampmaxn(2,mtru) = icol;
-           }
-         }
-       }
+        for(Int_t icol = 0 ; icol < nModulesEta/2; icol++){
+          ampn = 0;
+          if( (irow+fPatchSize) < nModulesPhi/2 && (icol+fPatchSize) < nModulesEta/2){ //Avoid exit the TRU
+            for(Int_t i = 0 ; i <= fPatchSize ; i++)
+              for(Int_t j = 0 ; j <= fPatchSize ; j++)
+                ampn += tru2x2(irow+i,icol+j);
+            //Select nxn maximum sums to select L1 
+            if(ampn > ampmaxn(0,mtru)){
+              ampmaxn(0,mtru) = ampn ; 
+              ampmaxn(1,mtru) = irow;
+              ampmaxn(2,mtru) = icol;
+            }
+          }
+        }
       }
       
       ampmaxn(3,mtru) = 0.; // Was 1 , I don't know why
       if(GetTimeKey()) {
-      //Find most recent time in selected nxn cell
+        //Find most recent time in selected nxn cell
         Int_t rown =  static_cast <Int_t> (ampmaxn(1,mtru));
         Int_t coln =  static_cast <Int_t> (ampmaxn(2,mtru));
         for(Int_t i = 0; i<4*fPatchSize; i++){
-         for(Int_t j = 0; j<4*fPatchSize; j++){
-           if( (rown+i) < nModulesPhi && (coln+j) < nModulesEta){//Avoid exit the TRU
-             if((*amptru)(rown+i,coln+j) > 0 &&  (*timeRtru)(rown+i,coln+j)> 0){
-               if((*timeRtru)(rown+i,coln+j) >  ampmaxn(3,mtru)  )
-                 ampmaxn(3,mtru) =  (*timeRtru)(rown+i,coln+j); // max time
-             }
-           }
-         }
+          for(Int_t j = 0; j<4*fPatchSize; j++){
+            if( (rown+i) < nModulesPhi && (coln+j) < nModulesEta){//Avoid exit the TRU
+              if((*amptru)(rown+i,coln+j) > 0 &&  (*timeRtru)(rown+i,coln+j)> 0){
+                if((*timeRtru)(rown+i,coln+j) >  ampmaxn(3,mtru)  )
+                  ampmaxn(3,mtru) =  (*timeRtru)(rown+i,coln+j); // max time
+              }
+            }
+          }
         }
       }
     } else { // copy 2x2 to nxn  
-       ampmaxn(0,mtru) =  ampmax2(0,mtru); 
-       ampmaxn(1,mtru) =  ampmax2(1,mtru);
-       ampmaxn(2,mtru) =  ampmax2(2,mtru);
-       ampmaxn(3,mtru) =  ampmax2(3,mtru);
+      ampmaxn(0,mtru) =  ampmax2(0,mtru); 
+      ampmaxn(1,mtru) =  ampmax2(1,mtru);
+      ampmaxn(2,mtru) =  ampmax2(2,mtru);
+      ampmaxn(3,mtru) =  ampmax2(3,mtru);
     }
   }
   if(keyPrint) AliDebug(2,Form(" : MakeSlidingTowers -OUt \n"));
@@ -812,56 +822,67 @@ void AliEMCALTrigger::FillTRU(const TClonesArray * digits, TClonesArray * ampmat
   for(Int_t idig = 0 ; idig < digits->GetEntriesFast() ; idig++){
     
     dig = dynamic_cast<AliEMCALDigit *>(digits->At(idig)) ;
-    amp    = Float_t(dig->GetAmplitude()); // Energy of the digit (arbitrary units)
-    id     = dig->GetId() ;          // Id label of the cell
-    timeR  = dig->GetTimeR() ;       // Earliest time of the digit
-    if(amp<=0.0) AliDebug(1,Form(" id %i amp %f \n", id, amp));
-    // printf(" FILLTRU : timeR %10.5e time %10.5e : amp %10.5e \n", timeR, dig->GetTime(), amp);
-    // Get eta and phi cell position in supermodule
-    Bool_t bCell = fGeom->GetCellIndex(id, iSupMod, nModule, nIphi, nIeta) ;
-    if(!bCell)
-      AliError(Form("%i Wrong cell id number %i ", idig, id)) ;
-    
-    fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
-    // iphim, ietam - module indexes in SM
-    fGeom->GetModuleIndexesFromCellIndexesInSModule(iSupMod,iphi,ieta, iphim, ietam, nModule); 
-    //if(iSupMod >9) 
-    //printf("iSupMod %i nModule %i iphi %i  ieta %i  iphim %i  ietam %i \n",
-    //iSupMod,nModule, iphi, ieta, iphim, ietam); 
-
-    // Check to which TRU in the supermodule belongs the cell. 
-    // Supermodules are divided in a TRU matrix of dimension 
-    // (fNTRUPhi,fNTRUEta).
-    // Each TRU is a cell matrix of dimension (nModulesPhi,nModulesEta)
-
-    // First calculate the row and column in the supermodule 
-    // of the TRU to which the cell belongs.
-    Int_t row   = iphim / nModulesPhi;
-    Int_t col   = ietam / nModulesEta;
-    //Calculate label number of the TRU
-    Int_t itru  = fGeom->GetAbsTRUNumberFromNumberInSm(row, col, iSupMod);
-    //Fill TRU matrix with cell values
-    TMatrixD * amptrus   = dynamic_cast<TMatrixD *>(ampmatrix->At(itru)) ;
-    TMatrixD * timeRtrus = dynamic_cast<TMatrixD *>(timeRmatrix->At(itru)) ;
-
-    //Calculate row and column of the module inside the TRU with number itru
-    Int_t irow = iphim - row * nModulesPhi;
-    if(iSupMod > 9)
-      irow = iphim - row *  nModulesPhi2; // size of matrix the same
-    Int_t icol = ietam - col * nModulesEta;
-    
-    (*amptrus)(irow,icol)  += amp ;
-    if((*timeRtrus)(irow,icol) <0.0 || (*timeRtrus)(irow,icol) <= timeR){ // ??
-      (*timeRtrus)(irow,icol) = timeR ;
+    if(dig){
+      amp    = Float_t(dig->GetAmplitude()); // Energy of the digit (arbitrary units)
+      id     = dig->GetId() ;          // Id label of the cell
+      timeR  = dig->GetTimeR() ;       // Earliest time of the digit
+      if(amp<=0.0) AliDebug(1,Form(" id %i amp %f \n", id, amp));
+      // printf(" FILLTRU : timeR %10.5e time %10.5e : amp %10.5e \n", timeR, dig->GetTime(), amp);
+      // Get eta and phi cell position in supermodule
+      Bool_t bCell = fGeom->GetCellIndex(id, iSupMod, nModule, nIphi, nIeta) ;
+      if(!bCell)
+        AliError(Form("%i Wrong cell id number %i ", idig, id)) ;
+      
+      fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
+      // iphim, ietam - module indexes in SM
+      fGeom->GetModuleIndexesFromCellIndexesInSModule(iSupMod,iphi,ieta, iphim, ietam, nModule); 
+      //if(iSupMod >9) 
+      //printf("iSupMod %i nModule %i iphi %i  ieta %i  iphim %i  ietam %i \n",
+      //iSupMod,nModule, iphi, ieta, iphim, ietam); 
+      
+      // Check to which TRU in the supermodule belongs the cell. 
+      // Supermodules are divided in a TRU matrix of dimension 
+      // (fNTRUPhi,fNTRUEta).
+      // Each TRU is a cell matrix of dimension (nModulesPhi,nModulesEta)
+      
+      // First calculate the row and column in the supermodule 
+      // of the TRU to which the cell belongs.
+      Int_t row   = iphim / nModulesPhi;
+      Int_t col   = ietam / nModulesEta;
+      //Calculate label number of the TRU
+      Int_t itru  = fGeom->GetAbsTRUNumberFromNumberInSm(row, col, iSupMod);
+      
+      //Fill TRU matrix with cell values
+      TMatrixD * amptrus   = dynamic_cast<TMatrixD *>(ampmatrix->At(itru)) ;
+      TMatrixD * timeRtrus = dynamic_cast<TMatrixD *>(timeRmatrix->At(itru)) ;
+      
+      if(!amptrus || timeRtrus){
+        AliError("Could not recover the TRU matrix with amplitudes or times");
+        continue;
+      }
+      //Calculate row and column of the module inside the TRU with number itru
+      Int_t irow = iphim - row * nModulesPhi;
+      if(iSupMod > 9)
+        irow = iphim - row *  nModulesPhi2; // size of matrix the same
+      Int_t icol = ietam - col * nModulesEta;
+      
+      (*amptrus)(irow,icol)  += amp ;
+      if((*timeRtrus)(irow,icol) <0.0 || (*timeRtrus)(irow,icol) <= timeR){ // ??
+        (*timeRtrus)(irow,icol) = timeR ;
+      }
+      //printf(" ieta %i iphi %i iSM %i || col %i row %i : itru %i -> amp %f\n", 
+      //          ieta, iphi, iSupMod, col, row, itru, amp);     
+      //####################SUPERMODULE MATRIX ##################
+      TMatrixD * ampsmods   = dynamic_cast<TMatrixD *>(ampmatrixsmod->At(iSupMod)) ;
+      if(!ampsmods){
+        AliError("Could not recover the matrix per SM");
+        continue;
+      }
+      (*ampsmods)(iphim,ietam)  += amp ;
+      //    printf(" id %i iphim %i ietam %i SM %i : irow %i icol %i itru %i : amp %6.0f\n", 
+      //id, iphim, ietam, iSupMod, irow, icol, itru, amp); 
     }
-    //printf(" ieta %i iphi %i iSM %i || col %i row %i : itru %i -> amp %f\n", 
-    //    ieta, iphi, iSupMod, col, row, itru, amp);     
-    //####################SUPERMODULE MATRIX ##################
-    TMatrixD * ampsmods   = dynamic_cast<TMatrixD *>(ampmatrixsmod->At(iSupMod)) ;
-    (*ampsmods)(iphim,ietam)  += amp ;
-    //    printf(" id %i iphim %i ietam %i SM %i : irow %i icol %i itru %i : amp %6.0f\n", 
-    //id, iphim, ietam, iSupMod, irow, icol, itru, amp); 
+    else AliError("Could not recover the digit");
   }
   //assert(0);
   //printf("<I> AliEMCALTrigger::FillTRU() is ended \n");
@@ -880,13 +901,15 @@ void AliEMCALTrigger::Trigger()
   }
  
   //Load EMCAL Geometry
-  if (runLoader && runLoader->GetAliRun() && runLoader->GetAliRun()->GetDetector("EMCAL"))
-    fGeom = dynamic_cast<AliEMCAL*>(runLoader->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
-
-  if (fGeom == 0)       
+  if (runLoader && runLoader->GetAliRun()){
+    AliEMCAL* emcal = dynamic_cast<AliEMCAL*>(runLoader->GetAliRun()->GetDetector("EMCAL"));
+    if(emcal)fGeom = emcal->GetGeometry();
+  }
+  
+  if (!fGeom)   
     fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());          
 
-  if (fGeom==0)
+  if (!fGeom)
     AliFatal("Did not get geometry from EMCALLoader");
   
   //Define parameters
@@ -995,6 +1018,9 @@ void AliEMCALTrigger::FillJetMatrixFromSMs(TClonesArray *ampmatrixsmod, TMatrixD
   Int_t nEtaSM=0, nPhiSM=0;
   for(Int_t iSM=0; iSM<ampmatrixsmod->GetEntries(); iSM++) {
     TMatrixD * ampsmods   = dynamic_cast<TMatrixD *>(ampmatrixsmod->At(iSM));
+    
+    if(!ampsmods) return;
+    
     Int_t nrow = ampsmods->GetNrows();
     Int_t ncol = ampsmods->GetNcols();
     //printf("%s",Form(" ######## SM %i : nrow %i : ncol %i ##### \n", iSM, nrow, ncol));
index 83f6dfacbe0a9aa2d6094c620be0c9a589a01544..4841bc250f75909dde0e8cabe95eada5639f415e 100644 (file)
@@ -54,34 +54,38 @@ fSubRegionSize( new TVector2() ),
 fPatchSize(     new TVector2() ),
 fPatches( new TClonesArray("AliEMCALTriggerPatch",10) )
 {
-   fRegion = (int**)malloc( (int)fRegionSize->X() * sizeof( int* ) );  
-
-   if (!fRegion) printf("Error: malloc could not allocate %d bytes for fRegion\n",
-                        int(fRegionSize->X() * sizeof( int* )));
-
-      fMap = (int**)malloc( (int)fRegionSize->X() * sizeof( int* ) );
-
-      if (!fMap) printf("Error: malloc could not allocate %d bytes for fMap\n",
-                        int(fRegionSize->X() * sizeof( int* )));
-
-   for (Int_t i=0;i<fRegionSize->X();i++)
-   {
+  fRegion = (int**)malloc( (int)fRegionSize->X() * sizeof( int* ) );  
+  
+  if (!fRegion) printf("Error: malloc could not allocate %d bytes for fRegion\n",
+                       int(fRegionSize->X() * sizeof( int* )));
+  
+  fMap = (int**)malloc( (int)fRegionSize->X() * sizeof( int* ) );
+  
+  if (!fMap) printf("Error: malloc could not allocate %d bytes for fMap\n",
+                    int(fRegionSize->X() * sizeof( int* )));
+  
+  for (Int_t i=0;i<fRegionSize->X();i++)
+  {
+    if(fRegion){
       fRegion[i] = (int*)malloc( (int)fRegionSize->Y() * sizeof( int ) );
-      
+    
       if (!fRegion[i]) printf("Error: malloc could not allocate %d bytes for fRegion[%d]\n",
-                              i,int(fRegionSize->Y() * sizeof( int )));
-
-         fMap[i] = (int*)malloc( (int)fRegionSize->Y() * sizeof( int ) );
-
-            if (!fMap[i]) printf("Error: malloc could not allocate %d bytes for fMap[%d]\n",
-                              i,int(fRegionSize->Y() * sizeof( int )));
-   }
-
+                            i,int(fRegionSize->Y() * sizeof( int )));
+    }
+    if(fMap){
+      fMap[i] = (int*)malloc( (int)fRegionSize->Y() * sizeof( int ) );
+    
+      if (!fMap[i]) printf("Error: malloc could not allocate %d bytes for fMap[%d]\n",
+                           i,int(fRegionSize->Y() * sizeof( int )));
+    }
+  }
+  
        // Initialize region matrix
        ZeroRegion();
-       
+       if(fMap){
        for (int i=0; i<fRegionSize->X(); ++i)
                for (int j=0; j<fRegionSize->Y(); ++j) fMap[i][j] = 0;
+  }
 }
 
 //_______________
index 23c28ab20c792bdd24e881d4a6c882a67b285764..9d243014205a4b2a4d42e3d5c04deb4fa72dfff1 100644 (file)
@@ -253,28 +253,37 @@ void AliEMCALTriggerDCSConfigDB::GetSTUSegmentation(Int_t ssg[], Int_t spg[], In
        //
        //
        const AliEMCALTriggerDCSConfig* dcsConf = dynamic_cast<const AliEMCALTriggerDCSConfig*>(GetCachedCDBObject(kIDTriggerConfig));
-
-       AliEMCALTriggerSTUDCSConfig* stuConf = dcsConf->GetSTUDCSConfig();
-       
-       Int_t fw = stuConf->GetFw();
-       
-       switch ( fw )
-       {
-               case 2223:
-                       ssg[0] = 1;
-                       ssg[1] = 1;
-                       spg[0] = 2;
-                       spg[1] = 2;
-                       
-                       ssj[0] = 4;
-                       ssj[1] = 4;
-                       spj[0] = 2;
-                       spj[1] = 2;
-                       break;
-               default:
-                       AliError("Firmware version do not match!");
-                       break;
-       }
+  if(dcsConf){
+    AliEMCALTriggerSTUDCSConfig* stuConf = dcsConf->GetSTUDCSConfig();
+    if(stuConf){
+      Int_t fw = stuConf->GetFw();
+      
+      switch ( fw )
+      {
+        case 2223:
+          ssg[0] = 1;
+          ssg[1] = 1;
+          spg[0] = 2;
+          spg[1] = 2;
+          
+          ssj[0] = 4;
+          ssj[1] = 4;
+          spj[0] = 2;
+          spj[1] = 2;
+          break;
+        default:
+          AliError("Firmware version do not match!");
+          break;
+      }
+    }
+    else {
+      AliError("STUDCSConfig is null!");
+    }
+  }
+  else {
+    AliError("DCSConfig is null!");
+  }
+  
 }
 
 //_____________________________________________________________________________
index cb175b302d958b6b44239c5df46feec4ded46163..cb183ab0f986e61715f75530596e61f1dd427305 100644 (file)
@@ -92,12 +92,14 @@ void AliEMCALTriggerElectronics::Digits2Trigger(TClonesArray* digits, const Int_
        AliEMCALGeometry* geom = 0x0;
        
        AliRunLoader *rl = AliRunLoader::Instance();
-       if (rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL"))
-               geom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
-       else 
-               geom =  AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
-
-       if (!geom) AliError("Cannot access geometry!");
+       if (rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL")){
+         AliEMCAL* emcal = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"));
+         if(emcal)geom = emcal->GetGeometry();
+       }
+       
+       if(!geom) geom =  AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
+       
+       if(!geom) AliError("Cannot access geometry!");
        
        //      digits->Sort();
        
index 5cda590ce82b550dea47dcbde6dec1a81afde2a6..dfc8b5a3c1f2696dcc3add10b9d89f44578d58fe 100644 (file)
@@ -61,22 +61,25 @@ fRawAnalyzer(0x0),
 fDCSConfig(0x0),
 fTriggerData(0x0)
 {
-       // def ctor
-       
-       AliRunLoader* rl = AliRunLoader::Instance();
-       if (rl && rl->GetAliRun() && dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))) 
-               fGeometry = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
-       else 
-       {
-               AliDebug(1, Form("Using default geometry"));
-               fGeometry =  AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
-       }
-       
-       fRawAnalyzer = new AliCaloRawAnalyzerFakeALTRO();
-       
-       fDCSConfig = AliEMCALTriggerDCSConfigDB::Instance();
-       
-       for (Int_t i=0; i<3072; i++) fRawDigitIndex[i] = -1;
+  // def ctor
+  
+  AliRunLoader* rl = AliRunLoader::Instance();
+  if (rl && rl->GetAliRun()){
+    AliEMCAL * emcal = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"));
+    if(emcal) fGeometry = emcal->GetGeometry();
+  }
+  
+  if(!fGeometry)
+    {
+      AliDebug(1, Form("Using default geometry"));
+      fGeometry =  AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
+    }
+  
+  fRawAnalyzer = new AliCaloRawAnalyzerFakeALTRO();
+  
+  fDCSConfig = AliEMCALTriggerDCSConfigDB::Instance();
+  
+  for (Int_t i=0; i<3072; i++) fRawDigitIndex[i] = -1;
 }      
 
 //_______________
index 943aa6dba74d0747e8bcd374901b5145780d393b..405c07ccfab42f5f3ac03da4b76c42e65df37dce 100644 (file)
@@ -98,9 +98,11 @@ void AliEMCALTriggerSTU::Build( TString& str, Int_t iTRU, Int_t** M, const TVect
        {
                AliError("Operation not allowed: STU won't be configured properly!");
        }
-       
-       for (Int_t i=0; i<rSize->X(); i++)
-               for (Int_t j=0; j<rSize->Y(); j++) v[i + ix][j + iy * 4] = M[i][j];
+  
+  if(v){       
+    for (Int_t i=0; i<rSize->X(); i++)
+      for (Int_t j=0; j<rSize->Y(); j++) v[i + ix][j + iy * 4] = M[i][j];
+  }
 }
 
 //_______________
index 72a540bf6a52c9ae0653a617d49a3e0810031817..3d542d484e9f07db9785e6dcc90c6497e695e984 100644 (file)
@@ -327,9 +327,13 @@ Int_t AliEMCALTriggerTRU::L0()
 //________________
 void AliEMCALTriggerTRU::SetADC( Int_t channel, Int_t bin, Int_t sig )
 {
-       //
-       if (channel>95) AliError("TRU has 96 ADC channels only!");
-       fADC[channel][bin] = sig;
+  //Set ADC value
+  if (channel > 95 || bin > 255) {
+    AliError("TRU has 96 ADC channels and 256 bins only!");
+  }
+  else{ 
+    fADC[channel][bin] = sig;
+  }
 }
 
 //________________
index 7a65da97a31dceeccc2082023f21d8cb2c6073ce..1f0c103951a5751d0880514f27c9854ff746eed4 100644 (file)
@@ -37,6 +37,11 @@ AliEMCALCCUSBRawStream::AliEMCALCCUSBRawStream(AliRawReader* rawReader) :
 
   fRawReader->Reset();
   fRawReader->SelectEquipment(1, 1, 1);
+  
+  for(Int_t i = 0 ; i < fgkNTDC; i++ )          fTDC[i] = 0 ;             
+  for(Int_t i = 0 ; i < fgkNQDC; i++ )          fQDC[i] = 0 ;                         
+  for(Int_t i = 0 ; i < fgkNScalerCCUSB; i++ )  fScalerCCUSB[i]  = 0;          
+  for(Int_t i = 0 ; i < fgkNScalerLecroy; i++ ) fScalerLecroy[i] = 0;       
 }
 
 Bool_t AliEMCALCCUSBRawStream::Next()