]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliCaloCalibSignal.cxx
Fix coverity defects
[u/mrichter/AliRoot.git] / EMCAL / AliCaloCalibSignal.cxx
index 0977c4efcf6280c372eb7ca4f51ffe8a42ac923f..e27c7e481fbebe6b0c7f8bb87fa1bf205381006e 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,22 @@ 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<fgkMaxTowers; i++) {
+      fNHighGain[i] = sig.fNHighGain[i];
+      fNLowGain[i]  = sig.fNLowGain[i]; 
+  }
+  for (Int_t i = 0; i<(2*fgkMaxRefs); i++) {
+    fNRef[i] = sig.fNRef[i]; 
+  }
+  
+  
 }
 
 // assignment operator; use copy ctor to make life easy..
@@ -334,7 +343,7 @@ void AliCaloCalibSignal::SetParametersFromFile(const char *parameterFile)
       s >> keyValue;
       
       // check stream status
-      if( s.rdstate() & ios::failbit ) break;
+      if( ( s.rdstate() & ios::failbit ) == ios::failbit ) break;
                        
       // skip rest of line if comments found
       if( keyValue.substr( 0, 2 ) == "//" ) break;
@@ -724,8 +733,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 +745,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");
        }
 
@@ -799,7 +808,7 @@ Bool_t AliCaloCalibSignal::Analyze()
       for (int gain=0; gain<2; gain++) {
        fRefNum = GetRefNum(i, j, gain);
        if (fNRef[fRefNum] > 0) { 
-         sprintf(name, "profileLEDRef%d", fRefNum);
+         snprintf(name, buffersize, "profileLEDRef%d", fRefNum);
          profileLED[fRefNum] = new TProfile(name, name, numProfBins, timeMin, timeMax, "s");
        } 
       }// gain