]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG3/dielectron/AliDielectronSignalExt.cxx
defects from coverity fixed
[u/mrichter/AliRoot.git] / PWG3 / dielectron / AliDielectronSignalExt.cxx
index f25a0709281906a2b524f26cf617d463d0736969..88e0329b571e948811a75f648f14560c2886bf75 100644 (file)
@@ -13,6 +13,8 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
+/* $Id$ */
+
 ///////////////////////////////////////////////////////////////////////////
 //                                                                       //
 //                      Dielectron SignalExt                             //
@@ -76,6 +78,7 @@ void AliDielectronSignalExt::Process(TObjArray* const arrhist)
   //
   switch ( fMethod ){
     case kLikeSign :
+    case kLikeSignArithm :
       ProcessLS(arrhist);    // process like-sign subtraction method
       break;
 
@@ -104,6 +107,9 @@ void AliDielectronSignalExt::ProcessLS(TObjArray* const arrhist)
   fHistDataPP->Sumw2();
   fHistDataPM->Sumw2();
   fHistDataMM->Sumw2();
+  fHistDataPP->SetDirectory(0);
+  fHistDataPM->SetDirectory(0);
+  fHistDataMM->SetDirectory(0);
   
   // rebin the histograms
   if (fRebin>1) { 
@@ -115,10 +121,12 @@ void AliDielectronSignalExt::ProcessLS(TObjArray* const arrhist)
   fHistSignal = new TH1D("HistSignal", "Like-Sign substracted signal",
                         fHistDataPM->GetXaxis()->GetNbins(),
                         fHistDataPM->GetXaxis()->GetXmin(), fHistDataPM->GetXaxis()->GetXmax());
+  fHistSignal->SetDirectory(0);
   fHistBackground = new TH1D("HistBackground", "Like-sign contribution",
                             fHistDataPM->GetXaxis()->GetNbins(),
                             fHistDataPM->GetXaxis()->GetXmin(), fHistDataPM->GetXaxis()->GetXmax());
-
+  fHistBackground->SetDirectory(0);
+  
   // fill out background and subtracted histogram
   for(Int_t ibin=1; ibin<=fHistDataPM->GetXaxis()->GetNbins(); ibin++) {
     Float_t pm = fHistDataPM->GetBinContent(ibin);
@@ -128,14 +136,26 @@ void AliDielectronSignalExt::ProcessLS(TObjArray* const arrhist)
 
     Float_t background = 2*TMath::Sqrt(pp*mm);
     Float_t ebackground = TMath::Sqrt(mm+pp);
-    Float_t signal = pm - background;
-    Float_t error = TMath::Sqrt(epm*epm+mm+pp);
-
-    fHistSignal->SetBinContent(ibin, signal);
-    fHistSignal->SetBinError(ibin, error);
+    if (fMethod==kLikeSignArithm){
+      //Arithmetic mean instead of geometric
+      background=(pp+mm);
+      ebackground=TMath::Sqrt(pp+mm);
+      if (TMath::Abs(ebackground)<1e-30) ebackground=1;
+    }
+//     Float_t signal = pm - background;
+//     Float_t error = TMath::Sqrt(epm*epm+mm+pp);
+
+    fHistSignal->SetBinContent(ibin, pm);
+    fHistSignal->SetBinError(ibin, epm);
     fHistBackground->SetBinContent(ibin, background);
     fHistBackground->SetBinError(ibin, ebackground);
   }
+  //scale histograms to match integral between fScaleMin and fScaleMax
+  if (fScaleMax>fScaleMin) fScaleFactor=ScaleHistograms(fHistDataPM,fHistBackground,fScaleMin,fScaleMax);
+
+  //subract background
+  fHistSignal->Add(fHistBackground,-1);
+  
   // signal
   fValues(0) = fHistSignal->IntegralAndError(fHistSignal->FindBin(fIntMin),
                                             fHistSignal->FindBin(fIntMax), fErrors(0));
@@ -180,8 +200,9 @@ void AliDielectronSignalExt::ProcessRotation(TObjArray* const arrhist)
     return;
   }
 
-  //scale histograms to match integral between 3.2 and 4. GeV
-  ScaleHistograms(fHistDataPM,fHistBackground,3.2,4.0);
+  //scale histograms to match integral between fScaleMin and fScaleMax
+  if (fScaleMax>fScaleMin) fScaleFactor=ScaleHistograms(fHistDataPM,fHistBackground,fScaleMin,fScaleMax);
+  
   fHistSignal=(TH1*)fHistDataPM->Clone("histSignal");
   fHistSignal->Add(fHistBackground,-1.);