fixing mem leak in operator=
authorkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 10 Apr 2011 11:44:13 +0000 (11:44 +0000)
committerkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 10 Apr 2011 11:44:13 +0000 (11:44 +0000)
STEER/AliAODHeader.cxx

index d1bb9ff..4a2c56a 100644 (file)
@@ -308,9 +308,13 @@ AliAODHeader& AliAODHeader::operator=(const AliAODHeader& hdr)
     fL0TriggerInputs    = hdr.fL0TriggerInputs;
     fL1TriggerInputs    = hdr.fL1TriggerInputs;
     fL2TriggerInputs    = hdr.fL2TriggerInputs;
-    fCentralityP        = new AliCentrality(*hdr.fCentralityP);
     fEventplaneP        = new AliEventplane(*hdr.fEventplaneP);
 
+    if(hdr.fCentralityP){
+      if(fCentralityP)*fCentralityP = *hdr.fCentralityP;
+      else fCentralityP = new AliCentrality(*hdr.fCentralityP);
+    }
+
     SetName(hdr.fName);
     SetTitle(hdr.fTitle);
     SetQTheta(hdr.fQTheta, hdr.fNQTheta);
@@ -319,19 +323,23 @@ AliAODHeader& AliAODHeader::operator=(const AliAODHeader& hdr)
     for(Int_t i=0; i<3; i++) fDiamondCovXY[i]=hdr.fDiamondCovXY[i];
 
     for(Int_t m=0; m<kNPHOSMatrix; m++){
-       if(hdr.fPHOSMatrix[m])
-           fPHOSMatrix[m]=new TGeoHMatrix(*(hdr.fPHOSMatrix[m])) ;
-       else
-           fPHOSMatrix[m]=0;
+      if(hdr.fPHOSMatrix[m]){
+       if(fPHOSMatrix[m])delete fPHOSMatrix[m];
+       fPHOSMatrix[m]=new TGeoHMatrix(*(hdr.fPHOSMatrix[m])) ;
+      }
+      else
+       fPHOSMatrix[m]=0;
     }
     
     for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
-       if(hdr.fEMCALMatrix[sm])
-           fEMCALMatrix[sm]=new TGeoHMatrix(*(hdr.fEMCALMatrix[sm])) ;
-       else
-           fEMCALMatrix[sm]=0;
-  }
-
+      if(hdr.fEMCALMatrix[sm]){
+       if(fEMCALMatrix[sm])delete fEMCALMatrix[sm];
+       fEMCALMatrix[sm]=new TGeoHMatrix(*(hdr.fEMCALMatrix[sm])) ;
+      }
+      else
+       fEMCALMatrix[sm]=0;
+    }
+    
   }