Fix Coverity defects (Jochen)
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 8 Nov 2010 15:31:28 +0000 (15:31 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 8 Nov 2010 15:31:28 +0000 (15:31 +0000)
TRD/AliTRDgtuParam.cxx
TRD/AliTRDgtuSim.cxx
TRD/AliTRDgtuTMU.cxx
TRD/AliTRDmcmSim.cxx
TRD/AliTRDrawStream.cxx
TRD/AliTRDtrapConfig.cxx

index b4f6011..8af2332 100644 (file)
@@ -23,6 +23,7 @@
 //                                                                        //
 ////////////////////////////////////////////////////////////////////////////
 
+#include "TROOT.h"
 #include "TMath.h"
 #include "TMatrix.h"
 #include "TDecompLU.h"
@@ -73,6 +74,12 @@ AliTRDgtuParam::AliTRDgtuParam() :
   fRefLayers[0] = 3;
   fRefLayers[1] = 2;
   fRefLayers[2] = 1;
+  for (Int_t iLayer = 0; iLayer < 6; iLayer++) {
+    fAki[iLayer] = 0.;
+    fBki[iLayer] = 0.;
+    fCki[iLayer] = 0.;
+  }
+
   GenerateZChannelMap(); 
 }
 
@@ -193,7 +200,7 @@ Bool_t AliTRDgtuParam::DisplayZChannelMap(Int_t zchannel, Int_t subchannel) cons
 {
   // display the z-channel map 
 
-  if (zchannel > fgkNZChannels) {
+  if (zchannel >= fgkNZChannels) {
     AliError("Invalid Z channel!");
     return kFALSE;
   }
@@ -227,11 +234,13 @@ Bool_t AliTRDgtuParam::DisplayZChannelMap(Int_t zchannel, Int_t subchannel) cons
   }
   graph->SetMarkerStyle(kDot);
   graph->Draw("AP");
+  gROOT->Add(graph);
   for (Int_t zch = zchmin; zch < zchmax; zch++) {
     graphz[zch]->SetMarkerStyle(kCircle);
     graphz[zch]->SetMarkerColor(zch+2);
     graphz[zch]->SetMarkerSize(0.3 + zch*0.2);
     graphz[zch]->Draw("P");
+    gROOT->Add(graphz[zch]);
   }
   return kTRUE;
 }
@@ -391,10 +400,13 @@ Bool_t AliTRDgtuParam::GetIntersectionPoints(Int_t k, Float_t &x1, Float_t &x2)
     }
   }
 
-  x1 = fGeo->GetTime0(l1) + 10./6 * (nHits -1);
-  x2 = fGeo->GetTime0(l2) - 10./6 * (nHits -1);
-
-  return ( (l1 >= 0) && (l2 >= 0) );
+  if ( (l1 >= 0) && (l2 >= 0) ) {
+    x1 = fGeo->GetTime0(l1) + 10./6 * (nHits -1);
+    x2 = fGeo->GetTime0(l2) - 10./6 * (nHits -1);
+    return kTRUE;
+  }
+  else
+    return kFALSE;
 }
 
 Float_t AliTRDgtuParam::GetPt(Int_t a, Float_t /* b */, Float_t x1, Float_t x2) const
index dc25fe9..89f8a43 100644 (file)
@@ -140,12 +140,13 @@ Bool_t AliTRDgtuSim::RunGTUFromTrackletFile(TString filename, Int_t event, Int_t
        }
        for (Int_t i = 5; i < tokens->GetEntriesFast(); i++) {
            UInt_t trackletWord = 0;
-           sscanf(((TObjString*) tokens->At(i))->GetString().Data(), "%x", &trackletWord);
+           sscanf(((TObjString*) tokens->At(i))->GetString().Data(), "%u", &trackletWord);
            if (trackletWord == 0x10001000) 
                break;
            AliDebug(2,Form("%i. tracklet: %s -> 0x%08x", i-4, ((TObjString*) tokens->At(i))->GetString().Data(), trackletWord));
            AliTRDtrackletWord *trkl = new AliTRDtrackletWord(trackletWord);
-           fTMU->AddTracklet(trkl, iLink);
+           if (fTMU)
+             fTMU->AddTracklet(trkl, iLink);
        }
     }
     
@@ -216,7 +217,8 @@ Bool_t AliTRDgtuSim::RunGTU(AliLoader *loader, AliESDEvent *esd)
            iSecPrev = iSec;
        }
        AliDebug(1, Form("adding tracklet: 0x%08x", trkl->GetTrackletWord()));
-       fTMU->AddTracklet(trkl, iLink);
+       if (fTMU)
+         fTMU->AddTracklet(trkl, iLink);
     }
     
     if (fTMU) {
index 7b80ce7..5a631ee 100644 (file)
@@ -676,6 +676,26 @@ Bool_t AliTRDgtuTMU::RunTrackMerging(TList* ListOfTracks)
     
     Uniquifier(tracksZMergedStage1, ListOfTracks);
     
+    // cleaning up                                                                                                                         
+    for (Int_t zch = 0; zch < fGtuParam->GetNZChannels(); zch++) {
+      delete tracksRefMerged[zch];
+      delete tracksRefUnique[zch];
+    }
+    delete [] tracksRefMerged;
+    delete [] tracksRefUnique;
+
+
+    delete tracksZMergedStage0;
+    delete tracksZUniqueStage0;
+
+    for (Int_t i = 0; i < 2; i++)
+      delete tracksZSplitted[i];
+    delete tracksZSplitted;
+
+    delete tracksZMergedStage1;
+
+    delete [] trkInRefLayer;
+
     return kTRUE;
 }
 
index 1ffce2c..e36f3cc 100644 (file)
@@ -1388,7 +1388,7 @@ void AliTRDmcmSim::CalcFitreg()
               }
             }
           }
-         Int_t index[maxLabels];
+         Int_t index[2*maxLabels];
          TMath::Sort(maxLabels, count, index);
          for (Int_t i = 0; i < 3; i++) {
            if (count[index[i]] <= 0)
@@ -1677,7 +1677,7 @@ void AliTRDmcmSim::FitTracklet()
              }
            }
          }
-         Int_t index[maxLabels];
+         Int_t index[2*maxLabels];
          TMath::Sort(maxLabels, count, index);
          for (Int_t i = 0; i < 3; i++) {
            if (count[index[i]] <= 0)
index 01898ea..1cff83c 100644 (file)
@@ -635,11 +635,13 @@ Int_t AliTRDrawStream::ReadLinkData()
           *fPayloadCurr != fgkDataEndmarker)
       fPayloadCurr++;
   }
-  
-  fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fBytes     += (fPayloadCurr - startPosLink) * sizeof(UInt_t);
-  fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fBytesRead += count * sizeof(UInt_t);
-  fStats.fStatsSector[fCurrSm].fBytesRead                      += count * sizeof(UInt_t);
-  fStats.fBytesRead                                            += count * sizeof(UInt_t);
+
+  if (fCurrSm > -1 && fCurrSm < 18) {
+    fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fBytes     += (fPayloadCurr - startPosLink) * sizeof(UInt_t);
+    fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fBytesRead += count * sizeof(UInt_t);
+    fStats.fStatsSector[fCurrSm].fBytesRead                      += count * sizeof(UInt_t);
+    fStats.fBytesRead                                            += count * sizeof(UInt_t);
+  }
 
   return count;
 }
@@ -1001,14 +1003,18 @@ Int_t AliTRDrawStream::ReadZSData()
       channelcount++;
     }
 
-    fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fNChannels += channelcount;
-    fStats.fStatsSector[fCurrSm].fNChannels                      += channelcount;
+    if (fCurrSm > -1 && fCurrSm < 18) {
+      fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fNChannels += channelcount;
+      fStats.fStatsSector[fCurrSm].fNChannels                      += channelcount;
+    }
     if (channelcount != channelcountExp)
       MCMError(kAdcChannelsMiss);
     
     mcmcount++;
-    fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fNMCMs++;
-    fStats.fStatsSector[fCurrSm].fNMCMs++;
+    if (fCurrSm > -1 && fCurrSm < 18) {
+      fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fNMCMs++;
+      fStats.fStatsSector[fCurrSm].fNMCMs++;
+    }
 
     if (IsDumping() && DumpingMCM(fCurrHC/2, fCurrRobPos, fCurrMcmPos)) {
       DumpRaw(Form("Event %i: Det %3i ROB %i MCM %2i", fRawReader->GetEventIndex(), fCurrHC/2, fCurrRobPos, fCurrMcmPos),
index b30fbbf..a18550f 100644 (file)
@@ -650,15 +650,14 @@ Int_t AliTRDtrapConfig::GetTrapReg(TrapReg_t reg, Int_t det, Int_t rob, Int_t mc
        }
        else {
          AliError("Invalid MCM specified or register is individual");
-         return -1;
+         return 0;
        }
     }
     else {  // should never be reached
       AliError("MCM register status neither kGlobal nor kIndividual");
-      return -1;
+      return 0;
     }
   }
-  return -1;
 }