]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RALICE/AliInvmass.cxx
Library class for parton quenching calculations.
[u/mrichter/AliRoot.git] / RALICE / AliInvmass.cxx
index 0812ba1bf6e692e2e70d168ce6f39561cf207917..ecd0d0c6b8bf7403f26f9da86e633f2ee2ac2f59 100644 (file)
@@ -1,3 +1,107 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+// $Id$
+
+////////////////////////////////////////////////////////////////////////////////
+// Class AliInvmass
+// Construction of invariant mass and combinatorial background.
+//
+// Example :
+// ---------
+//
+// TObjArray* photons=new TObjArray(); // Array with photon tracks for pi0 rec.
+//
+// // Code to create some photon tracks from pi0 decays
+// Int_t ntracks=200;
+// for (Int_t i=0; i<ntracks; i++)
+// {
+//  photons->Add(new Alitrack);
+//  ...
+//  ...
+//  ...
+// }  
+//
+// // Perform the invariant mass and comb. bkg. reconstruction
+//
+// TObjArray* allm=q.Invmass(photons,photons); // All reconstructed invariant masses
+//
+// TH1F* hall=new TH1F("hall","hall",200,0,2); // Histo with M_inv of all combinations
+//
+// Int_t nall=0;
+// if (allm) nall=allm->GetEntries();
+//
+// AliTrack* t;
+// Float_t minv;
+// for (Int_t j=0; j<nall; j++)
+// {
+//  t=(AliTrack*)allm->At(j);
+//  if (t)
+//  {
+//   minv=t->GetMass();
+//   hall->Fill(minv);
+//  }
+// }
+//
+// TObjArray* bkgm=q.CombBkg(photons,photons); // Reconstructed comb. background
+//
+// TH1F* hbkg=new TH1F("hbkg","hbkg",200,0,2); // Histo with M_inv. of comb. background
+//
+// Int_t nbkg=0;
+// if (bkgm) nbkg=bkgm->GetEntries();
+//
+// for (Int_t j=0; j<nbkg; j++)
+// {
+//  t=(AliTrack*)bkgm->At(j);
+//  if (t)
+//  {
+//   minv=t->GetMass();
+//   hbkg->Fill(minv);
+//  }
+// }
+//
+// TH1F* hsig=new TH1F("sig","sig",200,0,2);   // Histo with the bkg. subtracted signal
+// hsig->Sumw2();
+// hsig->Add(hall,hbkg,1,-1);
+//
+//
+// Note : By default the storage of the reconstructed information is performed
+//        in separate TObjArrays for the signal and comb. background resp.
+//        In order to limit the memory usage, AliInvmass::SetStorageMode(1) may be
+//        used to activate only a single TObjArray to store the reconstructed information.
+//        Consequently, the following statements 
+//
+//         TObjArray* allm=q.Invmass(photons,photons);
+//         TObjArray* bkgm=q.CombBkg(photons,photons);
+//
+//        will result in the fact that after he invokation of CombBkg
+//        the information of "allm" is lost due to the fact that the storage is
+//        is re-used for "bkgm" in case the "single storage" option has been selected.
+//        Usage of the, in that case invalid, pointer "allm" may cause your
+//        program to crash.
+//
+//        * Thus : In case of single storage usage, all invokations of the returned
+//                 array pointer have to be completed before invoking any memberfunction
+//                 of the same AliInvmass object again.
+//        
+//        
+//
+//--- Author: Nick van Eijndhoven 12-apr-1999 UU-SAP Utrecht
+//- Modified: NvE $Date$ UU-SAP Utrecht
+////////////////////////////////////////////////////////////////////////////////
+
 #include "AliInvmass.h"
  
 ClassImp(AliInvmass) // Class implementation to enable ROOT I/O
@@ -19,14 +123,12 @@ AliInvmass::~AliInvmass()
 // Destructor to delete dynamically allocated memory
  if (fMinv)
  {
-  fMinv->Delete();
   delete fMinv;
   fMinv=0;
  }
 
  if (fMbkg)
  {
-  fMbkg->Delete();
   delete fMbkg;
   fMbkg=0;
  }
@@ -102,14 +204,12 @@ void AliInvmass::Combine(TObjArray* a1,TObjArray* a2)
  
  if ((!fBkg || fMode==1) && fMinv)
  {
-  fMinv->Delete();
   delete fMinv;
   fMinv=0;
  }
  
  if (fBkg && (fMode !=1) && fMbkg)
  {
-  fMbkg->Delete();
   delete fMbkg;
   fMbkg=0;
  }
@@ -194,12 +294,20 @@ void AliInvmass::Combine(TObjArray* a1,TObjArray* a2)
     t->SetCharge(q1+q2);
     if (!fBkg || fMode==1) 
     {
-     if (!fMinv) fMinv=new TObjArray();
+     if (!fMinv)
+     {
+      fMinv=new TObjArray();
+      fMinv->SetOwner();
+     }
      fMinv->Add(t);
     }
     else
     {
-     if (!fMbkg) fMbkg=new TObjArray();
+     if (!fMbkg)
+     {
+      fMbkg=new TObjArray();
+      fMbkg->SetOwner();
+     }
      fMbkg->Add(t);
     }
    }