]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
ParNames are always initialized
authorshahoian <shahoian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 5 Mar 2013 22:06:43 +0000 (22:06 +0000)
committershahoian <shahoian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 5 Mar 2013 22:06:43 +0000 (22:06 +0000)
STEER/STEER/AliParamList.cxx

index be608bd0eef143ba31e259cced55e2444b34f05a..86834814b6ad238878ee3c520d3763b4b44f8716 100644 (file)
@@ -29,10 +29,9 @@ AliParamList::AliParamList(const AliParamList& src)
 {
   // copy c-tor
   if (fNPar>0) {
-    if (src.fNames) fNames = new TString[fNPar];
     fParams = new Double_t[fNPar];
     for (int i=fNPar;i--;) {
-      if (fNames) fNames[i] = src.fNames[i];
+      fNames[i] = src.fNames[i];
       fParams[i] = src.fParams[i];
     }
   }
@@ -65,6 +64,7 @@ void AliParamList::SetNParams(Int_t n)
   if (fNPar) AliFatal(Form("N params was already set to %d",fNPar));
   fNPar = n;
   fParams = new Double_t[fNPar];
+  fNames = new TString[fNPar];
   for (int i=fNPar;i--;) fParams[i] = 0.;
   //
 }
@@ -74,7 +74,6 @@ void AliParamList::SetParName(Int_t i,const char* nm)
 {
   // assign param name
   if (i<0||i>=fNPar) AliFatal(Form("Param %d accessed while the range is %d : %d",i,0,fNPar));
-  if (!fNames) fNames = new TString[fNPar];
   fNames[i] = nm;
 }
 
@@ -84,10 +83,7 @@ void AliParamList::SetParameter(Int_t i, Double_t v, const char* nm)
   // assign param value and optionally name
   if (i<0||i>=fNPar) AliFatal(Form("Param %d accessed while the range is %d : %d",i,0,fNPar));
   fParams[i] = v;
-  if (nm) {
-    if (!fNames) fNames = new TString[fNPar];
-    fNames[i] = nm;
-  }
+  fNames[i] = nm;
 }
 
 //_____________________________________________________________________
@@ -95,12 +91,12 @@ void AliParamList::Print(Option_t *) const
 {
   // print itself
   printf("ParamList#%d/%d %s %s\n",fID,GetUniqueID(),GetName(),GetTitle());
-  for (int i=0;i<fNPar;i++) printf("#%2d\t%s\t%e\n",i,GetParName(i),GetParameter(i));
+  for (int i=0;i<fNPar;i++) printf("#%2d\t%20s\t%e\n",i,GetParName(i),GetParameter(i));
 }
 
 //_____________________________________________________________________
 const Char_t* AliParamList::GetParName(Int_t i) const 
 {
   // get par name
-  return (fNames && !fNames[i].IsNull()) ? fNames[i].Data() : Form("par%d",i);;
+  return (fNames[i].IsNull()) ? Form("par%d",i) : fNames[i].Data();;
 }