]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HBTAN/AliHBTAnalysis.cxx
Bug in formula for pi0 energy for decay corrected.
[u/mrichter/AliRoot.git] / HBTAN / AliHBTAnalysis.cxx
index 2afb7684e89ba9f1ed86e7638f4c38c3db0fc6d0..cf2be767457fb995b4af7019162d1be764be4c4c 100644 (file)
@@ -1,8 +1,4 @@
-
 #include "AliHBTAnalysis.h"
-
-#include <iostream.h>
-
 #include "AliHBTRun.h"
 #include "AliHBTEvent.h"
 #include "AliHBTReader.h"
 #include "AliHBTPairCut.h"
 #include "AliHBTFunction.h"
 #include "AliHBTMonitorFunction.h"
-
 #include <TBenchmark.h>
 #include <TList.h>
 
-
+//_________________________________________________________
+///////////////////////////////////////////////////////////
+//
+//Central Object Of HBTAnalyser: 
+//This class performs main looping within HBT Analysis
+//User must plug a reader of Type AliHBTReader
+//User plugs in coorelation and monitor functions
+//as well as monitor functions
+//
+//HBT Analysis Tool, which is integral part of AliRoot,
+//ALICE Off-Line framework:
+//
+//Piotr.Skowronski@cern.ch
+//more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html
+//
+//_________________________________________________________
 
 ClassImp(AliHBTAnalysis)
 
 const UInt_t AliHBTAnalysis::fgkFctnArraySize = 100;
-const Int_t AliHBTAnalysis::fgkHbtAnalyzeAll = 0;
-
-AliHBTAnalysis::AliHBTAnalysis()
+const UInt_t AliHBTAnalysis::fgkDefaultMixingInfo = 1000;
+const Int_t  AliHBTAnalysis::fgkDefaultBufferSize = 5;
+
+AliHBTAnalysis::AliHBTAnalysis():
+ fReader(0x0),
+ fNTrackFunctions(0),
+ fNParticleFunctions(0),
+ fNParticleAndTrackFunctions(0),
+ fNTrackMonitorFunctions(0),
+ fNParticleMonitorFunctions(0), 
+ fNParticleAndTrackMonitorFunctions(0),
+ fBufferSize(2),
+ fDisplayMixingInfo(fgkDefaultMixingInfo),
+ fIsOwner(kFALSE)
  {
-   fReader = 0x0;
-   
    fTrackFunctions = new AliHBTOnePairFctn* [fgkFctnArraySize];
    fParticleFunctions = new AliHBTOnePairFctn* [fgkFctnArraySize];
    fParticleAndTrackFunctions = new AliHBTTwoPairFctn* [fgkFctnArraySize];
@@ -35,26 +55,46 @@ AliHBTAnalysis::AliHBTAnalysis()
    fTrackMonitorFunctions = new AliHBTMonOneParticleFctn* [fgkFctnArraySize];    
    fParticleAndTrackMonitorFunctions = new AliHBTMonTwoParticleFctn* [fgkFctnArraySize];    
 
-   fNTrackFunctions = 0;
-   fNParticleFunctions = 0;
-   fNParticleAndTrackFunctions = 0;
-  
-   fNParticleMonitorFunctions = 0; 
-   fNTrackMonitorFunctions = 0; 
-   fNParticleAndTrackMonitorFunctions = 0; 
-
    fPairCut = new AliHBTEmptyPairCut();//empty cut - accepts all particles
-   
-   fBufferSize = 2; 
  }
 /*************************************************************************************/ 
 
+AliHBTAnalysis::AliHBTAnalysis(const AliHBTAnalysis& in):
+ fReader(0x0),
+ fNTrackFunctions(0),
+ fNParticleFunctions(0),
+ fNParticleAndTrackFunctions(0),
+ fNTrackMonitorFunctions(0),
+ fNParticleMonitorFunctions(0), 
+ fNParticleAndTrackMonitorFunctions(0),
+ fTrackFunctions(0x0),
+ fParticleFunctions(0x0),
+ fParticleAndTrackFunctions(0x0),
+ fParticleMonitorFunctions(0x0),
+ fTrackMonitorFunctions(0x0),
+ fParticleAndTrackMonitorFunctions(0x0),
+ fPairCut(0x0),
+ fBufferSize(fgkDefaultBufferSize),
+ fDisplayMixingInfo(fgkDefaultMixingInfo),
+ fIsOwner(kFALSE)
+ {
+   Fatal("AliHBTAnalysis(const AliHBTAnalysis&)","Sensless");
+ }
+/*************************************************************************************/ 
+const AliHBTAnalysis& AliHBTAnalysis::operator=(const AliHBTAnalysis& right)
+ {
+   Fatal("AliHBTAnalysis(const AliHBTAnalysis&)","Sensless");
+   return *this;
+ }
+/*************************************************************************************/ 
 AliHBTAnalysis::~AliHBTAnalysis()
  {
  //destructor
  //note that we do not delete functions itself
  // they should be deleted by whom where created
  //we only store pointers, and we use "new" only for pointers array
+   if (fIsOwner) 
+    DeleteFunctions();
    delete [] fTrackFunctions;
    delete [] fParticleFunctions;
    delete [] fParticleAndTrackFunctions;
@@ -68,6 +108,76 @@ AliHBTAnalysis::~AliHBTAnalysis()
 
 /*************************************************************************************/ 
 
+void AliHBTAnalysis::DeleteFunctions()
+{
+ //Deletes all functions added to analysis
+ UInt_t ii;
+ for(ii = 0;ii<fNParticleFunctions;ii++)
+   delete fParticleFunctions[ii];
+ fNParticleFunctions = 0;
+                
+ for(ii = 0;ii<fNTrackFunctions;ii++)
+   delete fTrackFunctions[ii];
+ fNTrackFunctions = 0;
+ for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
+   delete fParticleAndTrackFunctions[ii];
+ fNParticleAndTrackFunctions = 0;
+ for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
+   delete fParticleMonitorFunctions[ii];
+ fNParticleMonitorFunctions = 0;
+   
+ for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
+   delete fTrackMonitorFunctions[ii];
+ fNTrackMonitorFunctions = 0;
+   
+ for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
+   delete fParticleAndTrackMonitorFunctions[ii];
+ fNParticleAndTrackMonitorFunctions = 0;
+}
+/*************************************************************************************/ 
+
+void AliHBTAnalysis::Init()
+{
+ UInt_t ii;
+ for(ii = 0;ii<fNParticleFunctions;ii++)
+   fParticleFunctions[ii]->Init();
+                
+ for(ii = 0;ii<fNTrackFunctions;ii++)
+   fTrackFunctions[ii]->Init();
+
+ for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
+   fParticleAndTrackFunctions[ii]->Init();
+ for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
+   fParticleMonitorFunctions[ii]->Init();
+   
+ for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
+   fTrackMonitorFunctions[ii]->Init();
+   
+ for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
+   fParticleAndTrackMonitorFunctions[ii]->Init();
+}
+/*************************************************************************************/ 
+
+void AliHBTAnalysis::ResetFunctions()
+{
+//In case fOwner is true, deletes all functions
+//in other case, just set number of analysis to 0
+ if (fIsOwner) DeleteFunctions();
+ else
+  {
+    fNParticleFunctions = 0;
+    fNTrackFunctions = 0;
+    fNParticleAndTrackFunctions = 0;
+    fNParticleMonitorFunctions = 0;
+    fNTrackMonitorFunctions = 0;
+    fNParticleAndTrackMonitorFunctions = 0;
+  }
+}
+/*************************************************************************************/ 
+
 void AliHBTAnalysis::Process(Option_t* option)
 {
  //default option  = "TracksAndParticles"
@@ -100,13 +210,10 @@ void AliHBTAnalysis::Process(Option_t* option)
    return;
   }
  
  const char *oT = strstr(option,"Tracks");
  const char *oP = strstr(option,"Particles");
  
  Bool_t nonid = IsNonIdentAnalysis();
- // nonid=0;
- cout<<"nonid = "<<nonid<<endl; 
  
  if(oT && oP)
   { 
@@ -127,6 +234,7 @@ void AliHBTAnalysis::Process(Option_t* option)
               "Coherency check not passed. Maybe change the option?\n");
         return;
       }
+    Init();
     if (nonid) ProcessTracksAndParticlesNonIdentAnal();
     else ProcessTracksAndParticles();
     return;
@@ -139,6 +247,7 @@ void AliHBTAnalysis::Process(Option_t* option)
        Error("Process","There is no data to analyze.");
        return;
      }
+    Init();
     if (nonid) ProcessTracksNonIdentAnal();
     else ProcessTracks();
     return;
@@ -151,19 +260,13 @@ void AliHBTAnalysis::Process(Option_t* option)
        Error("Process","There is no data to analyze.");
        return;
      }
+    Init();
     if (nonid) ProcessParticlesNonIdentAnal();
     else ProcessParticles();
-    
-//    cout<<"NON ID"<<endl;
-//    ProcessParticlesNonIdentAnal();
-//    cout<<"\n\n\n NORMAL"<<endl;
-//    ProcessParticles();
-    
     return;
   }
  
 }
-
 /*************************************************************************************/ 
 
 void AliHBTAnalysis::ProcessTracksAndParticles()
@@ -192,8 +295,8 @@ void AliHBTAnalysis::ProcessTracksAndParticles()
 
   AliHBTPair * tmptrackpair;//temprary pointers to pairs
   AliHBTPair * tmppartpair;
-  
-  
+
+  register UInt_t ii;
   
   for (Int_t i = 0;i<Nev;i++)
     {
@@ -206,18 +309,22 @@ void AliHBTAnalysis::ProcessTracksAndParticles()
       
       for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
        {
-         if ( (j%100) == 0) cout<<"Mixing particle "<<j<<" from event "<<i<<" with particles from event "<<i<<endl;
+
+         if ( (j%fDisplayMixingInfo) == 0) 
+            Info("ProcessTracksAndParticles",
+                 "Mixing particle %d from event %d with particles from event %d",j,i,i);
 
          part1= partEvent->GetParticle(j);
          track1= trackEvent->GetParticle(j);       
-       
-         UInt_t zz;
-         for(zz = 0; zz<fNParticleMonitorFunctions; zz++)
-           fParticleMonitorFunctions[zz]->ProcessSameEventParticles(part1);
-         for(zz = 0; zz<fNTrackMonitorFunctions; zz++)
-           fTrackMonitorFunctions[zz]->ProcessSameEventParticles(track1);
-        for(zz = 0; zz<fNParticleAndTrackMonitorFunctions; zz++)
-           fParticleAndTrackMonitorFunctions[zz]->ProcessSameEventParticles(track1,part1);
+
+         if (fPairCut->GetFirstPartCut()->Pass(part1)) continue;
+
+         for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
+           fParticleMonitorFunctions[ii]->Process(part1);
+         for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
+           fTrackMonitorFunctions[ii]->Process(track1);
+         for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
+           fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
 
          if ( (fNParticleFunctions == 0) && (fNTrackFunctions ==0) && (fNParticleAndTrackFunctions == 0))
            continue; 
@@ -230,9 +337,9 @@ void AliHBTAnalysis::ProcessTracksAndParticles()
             track2= trackEvent->GetParticle(k);       
             trackpair->SetParticles(track1,track2);
 
-            if(fPairCut->Pass(partpair) || (fPairCut->Pass(trackpair))) //check pair cut
+            if(fPairCut->Pass(partpair) ) //check pair cut
               { //do not meets crietria of the pair cut, try with swaped pairs
-                if( ( fPairCut->Pass(partpair->GetSwapedPair()) ) || ( fPairCut->Pass(trackpair->GetSwapedPair()) ) ) 
+                if( fPairCut->Pass(partpair->GetSwapedPair()) )
                   continue; //swaped pairs do not meet criteria of pair cut as well, take next particle
                 else 
                { //swaped pair meets all the criteria
@@ -245,7 +352,6 @@ void AliHBTAnalysis::ProcessTracksAndParticles()
                tmptrackpair = trackpair;
                tmppartpair = partpair;
              }
-            UInt_t ii;
             for(ii = 0;ii<fNParticleFunctions;ii++)
                    fParticleFunctions[ii]->ProcessSameEventParticles(tmppartpair);
                 
@@ -258,10 +364,11 @@ void AliHBTAnalysis::ProcessTracksAndParticles()
        }
     }
 
-
+  /***************************************/
   /***** Filling denominators    *********/
   /***************************************/
-  for (Int_t i = 0;i<Nev-1;i++)   //In each event (but last) ....
+  if (fBufferSize != 0)
+   for (Int_t i = 0;i<Nev-1;i++)   //In each event (but last) ....
     {
   
       if ((fNParticleFunctions == 0) && (fNTrackFunctions ==0) && (fNParticleAndTrackFunctions == 0))
@@ -272,65 +379,61 @@ void AliHBTAnalysis::ProcessTracksAndParticles()
       
       trackEvent = fReader->GetTrackEvent(i); 
       
-//      N=0;
-
       for (Int_t j = 0; j< partEvent->GetNumberOfParticles(); j++) // ... Loop over all particles ...
        {
-           
            part1= partEvent->GetParticle(j);
-
            track1= trackEvent->GetParticle(j);
+
+           if (fPairCut->GetFirstPartCut()->Pass(part1)) continue;
  
            Int_t NNN;
            
            if ( ((i+fBufferSize) >= Nev) ||( fBufferSize < 0) ) //if buffer size is negative 
                                                                 //or current event+buffersize is greater
                                                                 //than max nuber of events
-            {
-             NNN = Nev; //set the max event number 
-            }
+             {
+               NNN = Nev; //set the max event number 
+             }
            else 
-            {
-             NNN = i+fBufferSize; //set the current event number + fBufferSize
-            }
+             {
+               NNN = i+fBufferSize; //set the current event number + fBufferSize
+             }
  
            for (Int_t k = i+1; k<NNN;k++)  // ... Loop over next event
             {
              
-              partEvent2= fReader->GetParticleEvent(k);
-              if (!partEvent2) continue;
+             partEvent2= fReader->GetParticleEvent(k);
+             if (!partEvent2) continue;
               
-              trackEvent2 = fReader->GetTrackEvent(k);
+             trackEvent2 = fReader->GetTrackEvent(k);
              
-             if ( (j%100) == 0) cout<<"Mixing particle "<<j<<" from event "<<i<<" with particles from event "<<k<<endl;
+             if ( (j%fDisplayMixingInfo) == 0) 
+                 Info("ProcessTracksAndParticles",
+                      "Mixing particle %d from event %d with particles from event %d",j,i,k);
             
              for(Int_t l = 0; l<partEvent2->GetNumberOfParticles();l++)   //  ... on all particles
               {
-               
-                // if (N>MAXCOMB) break;
-                
                 part2= partEvent2->GetParticle(l);
                 partpair->SetParticles(part1,part2);
 
                 track2= trackEvent2->GetParticle(l);
                 trackpair->SetParticles(track1,track2);
 
-                if( (fPairCut->Pass(partpair)) || (fPairCut->Pass(trackpair)) ) //check pair cut
+                if( fPairCut->Pass(partpair) ) //check pair cut
                   { //do not meets crietria of the 
-                    if( ( fPairCut->Pass(partpair->GetSwapedPair()) ) || ( fPairCut->Pass(trackpair->GetSwapedPair()) ) )
-          continue;
-       else 
-        {
-          tmppartpair = partpair->GetSwapedPair();
-          tmptrackpair = trackpair->GetSwapedPair();
-        }
+                    if( fPairCut->Pass(partpair->GetSwapedPair()) )
+                      continue;
+                    else 
+                     {
+                       tmppartpair = partpair->GetSwapedPair();
+                       tmptrackpair = trackpair->GetSwapedPair();
+                     }
                   }
                 else
                  {//meets criteria of the pair cut
                   tmptrackpair = trackpair;
                   tmppartpair = partpair;
                  }
-                UInt_t ii;
                 for(ii = 0;ii<fNParticleFunctions;ii++)
                   fParticleFunctions[ii]->ProcessDiffEventParticles(tmppartpair);
                  
@@ -339,17 +442,11 @@ void AliHBTAnalysis::ProcessTracksAndParticles()
                  
                 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
                   fParticleAndTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair,tmppartpair);
-           
-               
               }//for(Int_t l = 0; l<N2;l++)   //  ... on all particles
             }//for (Int_t k = i+1; k<NNN;k++)  // ... Loop over next event
        }
-    
     } 
-
   /***************************************/
-  
-   
 } 
 /*************************************************************************************/
 
@@ -358,36 +455,35 @@ void AliHBTAnalysis::ProcessTracks()
   //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
 //the loops are splited
   AliHBTParticle * track1, * track2;
-  
   AliHBTEvent * trackEvent;
   AliHBTEvent * trackEvent2;
-  
-//  Int_t N1, N2, N=0; //number of particles in current event(we prcess two events in one time)
-  
+
+  UInt_t ii;
   Int_t Nev = fReader->GetNumberOfTrackEvents();
+
+  AliHBTPair * trackpair = new AliHBTPair();
+  AliHBTPair * tmptrackpair; //temporary pointer 
   
   /***************************************/
   /******   Looping same events   ********/
   /******   filling numerators    ********/
   /***************************************/
-  AliHBTPair * trackpair = new AliHBTPair();
-  AliHBTPair * tmptrackpair; //temporary pointer 
-  
   for (Int_t i = 0;i<Nev;i++)
     {
       trackEvent = fReader->GetTrackEvent(i);
       if (!trackEvent) continue;
-      //N = 0;
       
       for (Int_t j = 0; j<trackEvent->GetNumberOfParticles() ; j++)
        {
-         if ( (j%100) == 0) cout<<"Mixing particle "<<j<<" from event "<<i<<" with particles from event "<<i<<endl;
-
+         if ( (j%fDisplayMixingInfo) == 0) 
+               Info("ProcessTracks",
+                    "Mixing particle %d from event %d with particles from event %d",j,i,i);
+         
          track1= trackEvent->GetParticle(j);       
-        
-         UInt_t zz;
-         for(zz = 0; zz<fNTrackMonitorFunctions; zz++)
-           fTrackMonitorFunctions[zz]->ProcessSameEventParticles(track1);
+         if (fPairCut->GetFirstPartCut()->Pass(track1)) continue;
+
+         for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
+           fTrackMonitorFunctions[ii]->Process(track1);
 
          if ( fNTrackFunctions ==0 )
            continue; 
@@ -397,99 +493,88 @@ void AliHBTAnalysis::ProcessTracks()
            track2= trackEvent->GetParticle(k);       
            trackpair->SetParticles(track1,track2);
            if(fPairCut->Pass(trackpair)) //check pair cut
-             { //do not meets crietria of the 
+            { //do not meets crietria of the 
               if( fPairCut->Pass(trackpair->GetSwapedPair()) ) continue;
               else tmptrackpair = trackpair->GetSwapedPair();
-              }
-            else
-              {
-                tmptrackpair = trackpair;
-              }
-            UInt_t ii;
-                
-            for(ii = 0;ii<fNTrackFunctions;ii++)
-                   fTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair);
-                 
-           
-           }
+            }
+           else
+            {
+              tmptrackpair = trackpair;
+            }
+           for(ii = 0;ii<fNTrackFunctions;ii++)
+               fTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair);
+          }
        }
     }
 
   /***************************************/
   /***** Filling diff histogram *********/
   /***************************************/
-  for (Int_t i = 0;i<Nev-1;i++)   //In each event (but last) ....
+  if (fBufferSize != 0)
+   for (Int_t i = 0;i<Nev-1;i++)   //In each event (but last) ....
     {
       if ( fNTrackFunctions ==0 )
         continue; 
 
       trackEvent = fReader->GetTrackEvent(i);
       if (!trackEvent) continue;
-//      N=0;
-      
+
       for (Int_t j = 0; j< trackEvent->GetNumberOfParticles(); j++) // ... Loop over all particles ...
        {
-//         if (N>MAXCOMB) break;
-           
-           track1= trackEvent->GetParticle(j);
-           Int_t NNN;
+         track1= trackEvent->GetParticle(j);
+         if (fPairCut->GetFirstPartCut()->Pass(track1)) continue;
+
+         Int_t NNN;
            
-           if ( ((i+fBufferSize) >= Nev) ||( fBufferSize < 0) ) //if buffer size is negative 
-                                                                //or current event+buffersize is greater
-                                                                //than max nuber of events
-            {
-             NNN = Nev; //set the max event number 
-            }
-           else 
-            {
-             NNN = i+fBufferSize; //set the current event number + fBufferSize
-            }
+         if ( ((i+fBufferSize) >= Nev) ||( fBufferSize < 0) ) //if buffer size is negative 
+                                                              //or current event+buffersize is greater
+                                                              //than max nuber of events
+          {
+            NNN = Nev; //set the max event number 
+          }
+         else 
+          {
+            NNN = i+fBufferSize; //set the current event number + fBufferSize
+          }
  
-           for (Int_t k = i+1; k<NNN;k++)  // ... Loop over next event
-            {
-             
-             trackEvent2 = fReader->GetTrackEvent(k);
-             if (!trackEvent2) continue;
+         for (Int_t k = i+1; k<NNN;k++)  // ... Loop over next event
+          {
+            trackEvent2 = fReader->GetTrackEvent(k);
+            if (!trackEvent2) continue;
              
-             if ( (j%100) == 0) cout<<"Mixing particle "<<j<<" from event "<<i<<" with particles from event "<<k<<endl;
+            if ( (j%fDisplayMixingInfo) == 0) 
+                 Info("ProcessTracksAndParticles",
+                      "Mixing particle %d from event %d with particles from event %d",j,i,k);
             
-             for(Int_t l = 0; l<trackEvent2->GetNumberOfParticles();l++)   //  ... on all particles
-              {
-               
-                // if (N>MAXCOMB) break;
-                track2= trackEvent2->GetParticle(l);
-                trackpair->SetParticles(track1,track2);
+            for(Int_t l = 0; l<trackEvent2->GetNumberOfParticles();l++)   //  ... on all particles
+             {
+               track2= trackEvent2->GetParticle(l);
+               trackpair->SetParticles(track1,track2);
                 
-                if(fPairCut->Pass(trackpair)) //check pair cut
-                  { //do not meets crietria of the 
-                    if( fPairCut->Pass(trackpair->GetSwapedPair()) ) continue;
-       else tmptrackpair = trackpair->GetSwapedPair();
-                  }
-                else
-                  {
-                    tmptrackpair = trackpair;
-                  }
-                UInt_t ii;
-                for(ii = 0;ii<fNTrackFunctions;ii++)
-                  fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
+               if(fPairCut->Pass(trackpair)) //check pair cut
+                { //do not meets crietria of the 
+                  if( fPairCut->Pass(trackpair->GetSwapedPair()) ) continue;
+                  else tmptrackpair = trackpair->GetSwapedPair();
+                }
+               else
+                {
+                  tmptrackpair = trackpair;
+                }
+               for(ii = 0;ii<fNTrackFunctions;ii++)
+                   fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
                
-              }//for(Int_t l = 0; l<N2;l++)   //  ... on all particles
-            }//for (Int_t k = i+1; k<NNN;k++)  // ... Loop over next event
+             }//for(Int_t l = 0; l<N2;l++)   //  ... on all particles
+          }//for (Int_t k = i+1; k<NNN;k++)  // ... Loop over next event
        }
-    
     } 
-
   /***************************************/
-  
-
 }
 
 /*************************************************************************************/
 
 void AliHBTAnalysis::ProcessParticles()
 {
-  //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
+//In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
 //the loops are splited
   AliHBTParticle * part1, * part2;
   
@@ -499,17 +584,12 @@ void AliHBTAnalysis::ProcessParticles()
   AliHBTPair * partpair = new AliHBTPair();
   AliHBTPair * tmppartpair; //temporary pointer to the pair
   
-//  Int_t N1, N2, N=0; //number of particles in current event(we prcess two events in one time)
-  
   Int_t Nev = fReader->GetNumberOfPartEvents();
   
- // Nev = 1;
   /***************************************/
   /******   Looping same events   ********/
   /******   filling numerators    ********/
   /***************************************/
-//  gBenchmark->Start("id");
-  
   for (Int_t i = 0;i<Nev;i++)
     {
       partEvent= fReader->GetParticleEvent(i);
@@ -518,13 +598,16 @@ void AliHBTAnalysis::ProcessParticles()
       
       for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
        {
-         if ( (j%100) == 0) cout<<"Mixing particle "<<j<<" from event "<<i<<" with particles from event "<<i<<endl;
+         if ( (j%fDisplayMixingInfo) == 0) 
+                 Info("ProcessParticles",
+                      "Mixing particle %d from event %d with particles from event %d",j,i,i);
 
          part1= partEvent->GetParticle(j);
+         if (fPairCut->GetFirstPartCut()->Pass(part1)) continue;
         
          UInt_t zz;
          for(zz = 0; zz<fNParticleMonitorFunctions; zz++)
-           fParticleMonitorFunctions[zz]->ProcessSameEventParticles(part1);
+           fParticleMonitorFunctions[zz]->Process(part1);
 
          if ( fNParticleFunctions ==0 )
            continue; 
@@ -558,7 +641,8 @@ void AliHBTAnalysis::ProcessParticles()
   /***************************************/
   /***** Filling diff histogram *********/
   /***************************************/
-  for (Int_t i = 0;i<Nev-1;i++)   //In each event (but last)....
+  if (fBufferSize != 0) //less then 0 mix everything, == 0 do not mix denominator
+   for (Int_t i = 0;i<Nev-1;i++)   //In each event (but last)....
     {
       if ( fNParticleFunctions ==0 )
         continue; 
@@ -566,16 +650,12 @@ void AliHBTAnalysis::ProcessParticles()
       partEvent= fReader->GetParticleEvent(i);
       if (!partEvent) continue;
 
-//      N=0;
-      
       for (Int_t j = 0; j< partEvent->GetNumberOfParticles(); j++) // ... Loop over all particles ...
        {
-//         if (N>MAXCOMB) break;
-           
            part1= partEvent->GetParticle(j);
+           if (fPairCut->GetFirstPartCut()->Pass(part1)) continue;
            Int_t NNN;
-           
+
            if ( ((i+fBufferSize) >= Nev) ||( fBufferSize < 0) ) //if buffer size is negative 
                                                                 //or current event+buffersize is greater
                                                                 //than max nuber of events
@@ -587,26 +667,25 @@ void AliHBTAnalysis::ProcessParticles()
              NNN = i+fBufferSize; //set the current event number + fBufferSize
             }
            
-//           cout<<"NNN = "<<NNN<<endl;
            for (Int_t k = i+1; k<NNN;k++)  // ... Loop over next event
             {
              
              partEvent2= fReader->GetParticleEvent(k);
              if (!partEvent2) continue;
              
-             if ( (j%100) == 0) cout<<"Mixing particle "<<j<<" from event "<<i<<" with particles from event "<<k<<endl;
+             if ( (j%fDisplayMixingInfo) == 0) 
+                Info("ProcessParticles",
+                     "Mixing particle %d from event %d with particles from event %d",j,i,k);
             
              for(Int_t l = 0; l<partEvent2->GetNumberOfParticles();l++)   //  ... on all particles
               {
-               
-                // if (N>MAXCOMB) break;
                 part2= partEvent2->GetParticle(l);
                 partpair->SetParticles(part1,part2);
                 
                 if(fPairCut->Pass(partpair)) //check pair cut
                   { //do not meets crietria of the 
                     if( fPairCut->Pass(partpair->GetSwapedPair()) ) continue;
-       else tmppartpair = partpair->GetSwapedPair();
+                    else tmppartpair = partpair->GetSwapedPair();
                   }
                 else
                   {
@@ -619,21 +698,16 @@ void AliHBTAnalysis::ProcessParticles()
               }//for(Int_t l = 0; l<N2;l++)   //  ... on all particles
             }//for (Int_t k = i+1; k<NNN;k++)  // ... Loop over next event
        }
-    
     } 
-
   /***************************************/
-  
-//  gBenchmark->Stop("id");
-//  gBenchmark->Show("id");
 
 }
-
 /*************************************************************************************/
 
-
 void AliHBTAnalysis::WriteFunctions()
 {
+//Calls Write for all defined functions in analysis
+//== writes all results
   UInt_t ii;
   for(ii = 0;ii<fNParticleFunctions;ii++)
     fParticleFunctions[ii]->Write();
@@ -657,6 +731,7 @@ void AliHBTAnalysis::WriteFunctions()
 
 void AliHBTAnalysis::SetGlobalPairCut(AliHBTPairCut* cut)
 {
+//Sets the global cut
   if (cut == 0x0)
    {
      Error("AliHBTAnalysis::SetGlobalPairCut","Pointer is NULL. Ignoring");
@@ -669,6 +744,7 @@ void AliHBTAnalysis::SetGlobalPairCut(AliHBTPairCut* cut)
 
 void AliHBTAnalysis::AddTrackFunction(AliHBTOnePairFctn* f)
 {
+//Adds track function
   if (f == 0x0) return;
   if (fNTrackFunctions == fgkFctnArraySize)
    {
@@ -681,6 +757,7 @@ void AliHBTAnalysis::AddTrackFunction(AliHBTOnePairFctn* f)
 
 void AliHBTAnalysis::AddParticleFunction(AliHBTOnePairFctn* f)
 {
+//adds particle function
   if (f == 0x0) return;
   
   if (fNParticleFunctions == fgkFctnArraySize)
@@ -694,6 +771,7 @@ void AliHBTAnalysis::AddParticleFunction(AliHBTOnePairFctn* f)
 
 void AliHBTAnalysis::AddParticleAndTrackFunction(AliHBTTwoPairFctn* f)
 {
+//add resolution function
   if (f == 0x0) return;
   if (fNParticleAndTrackFunctions == fgkFctnArraySize)
    {
@@ -706,6 +784,7 @@ void AliHBTAnalysis::AddParticleAndTrackFunction(AliHBTTwoPairFctn* f)
 
 void AliHBTAnalysis::AddParticleMonitorFunction(AliHBTMonOneParticleFctn* f)
 {
+//add particle monitoring function
   if (f == 0x0) return;
 
   if (fNParticleMonitorFunctions == fgkFctnArraySize)
@@ -719,6 +798,7 @@ void AliHBTAnalysis::AddParticleMonitorFunction(AliHBTMonOneParticleFctn* f)
 
 void AliHBTAnalysis::AddTrackMonitorFunction(AliHBTMonOneParticleFctn* f)
 {
+//add track monitoring function
   if (f == 0x0) return;
 
   if (fNTrackMonitorFunctions == fgkFctnArraySize)
@@ -732,6 +812,7 @@ void AliHBTAnalysis::AddTrackMonitorFunction(AliHBTMonOneParticleFctn* f)
 
 void AliHBTAnalysis::AddParticleAndTrackMonitorFunction(AliHBTMonTwoParticleFctn* f)
 {
+//add resolution monitoring function
   if (f == 0x0) return;
   if (fNParticleAndTrackMonitorFunctions == fgkFctnArraySize)
     {
@@ -751,13 +832,12 @@ Bool_t AliHBTAnalysis::RunCoherencyCheck()
  //return true if error found
  //if they seem to be OK return false
  Int_t i;  
- cout<<"Checking HBT Runs Coherency"<<endl;
- cout<<"Number of events ..."; fflush(stdout);
+ Info("RunCoherencyCheck","Checking HBT Runs Coherency");
+
+ Info("RunCoherencyCheck","Number of events ...");
  if (fReader->GetNumberOfPartEvents() == fReader->GetNumberOfTrackEvents() ) //check whether there is the same  number of events
   {
-    cout<<"OK. "<<fReader->GetNumberOfTrackEvents()<<"  found"<<endl;
+    Info("RunCoherencyCheck","OK. %d found\n",fReader->GetNumberOfTrackEvents());
   }
  else
   { //if not the same - ERROR
@@ -767,7 +847,7 @@ Bool_t AliHBTAnalysis::RunCoherencyCheck()
    return kTRUE;
   }
  
cout<<"Checking number of Particles AND Particles Types in each event ...";fflush(stdout);
Info("RunCoherencyCheck","Checking number of Particles AND Particles Types in each event ...");
  
  AliHBTEvent *partEvent;
  AliHBTEvent *trackEvent;
@@ -804,8 +884,8 @@ Bool_t AliHBTAnalysis::RunCoherencyCheck()
          }
       }
   }
cout<<"  Done"<<endl;
cout<<"  Everything looks OK"<<endl;
Info("RunCoherencyCheck","  Done");
Info("RunCoherencyCheck","  Everything looks OK");
  return kFALSE;
 }
 
@@ -813,16 +893,16 @@ Bool_t AliHBTAnalysis::RunCoherencyCheck()
  
 void AliHBTAnalysis::ProcessTracksAndParticlesNonIdentAnal()
 {
+//Performs analysis for both, tracks and particles
+
   AliHBTParticle * part1, * part2;
   AliHBTParticle * track1, * track2;
 
-  AliHBTEvent * trackEvent1,*partEvent1;
-  AliHBTEvent * trackEvent2,*partEvent2;
-  AliHBTEvent * trackEvent3,*partEvent3;
+  AliHBTEvent * trackEvent1=0x0,*partEvent1=0x0;
+  AliHBTEvent * trackEvent2=0x0,*partEvent2=0x0;
+  AliHBTEvent * trackEvent3=0x0,*partEvent3=0x0;
 
   AliHBTEvent * rawtrackEvent, *rawpartEvent;
-//  AliHBTEvent * rawtrackEvent2,*rawpartEvent2;
-  
   
   Int_t Nev = fReader->GetNumberOfTrackEvents();
 
@@ -832,15 +912,17 @@ void AliHBTAnalysis::ProcessTracksAndParticlesNonIdentAnal()
   TList tbuffer;
   TList pbuffer;
   Int_t ninbuffer = 0;
+  UInt_t ii;
 
   trackEvent1 = new AliHBTEvent();
   partEvent1 = new AliHBTEvent();
   trackEvent1->SetOwner(kFALSE);
   partEvent1->SetOwner(kFALSE);;
   
-  cout<<"**************************************"<<endl;
-  cout<<"*****  NON IDENT MODE ****************"<<endl;
-  cout<<"**************************************"<<endl;
+  Info("ProcessTracksAndParticlesNonIdentAnal","**************************************");
+  Info("ProcessTracksAndParticlesNonIdentAnal","*****  NON IDENT MODE ****************");
+  Info("ProcessTracksAndParticlesNonIdentAnal","**************************************");
+  
   for (Int_t i = 0;i<Nev;i++)
     {
       rawpartEvent  = fReader->GetParticleEvent(i);
@@ -850,35 +932,37 @@ void AliHBTAnalysis::ProcessTracksAndParticlesNonIdentAnal()
       /********************************/
       /*      Filtering out           */
       /********************************/
-      if ((ninbuffer > fBufferSize) && (fBufferSize > 0))
-       {//if we have in buffer desired number of events, use the last. If fBufferSize<0 mix all events for background
-        partEvent2  = (AliHBTEvent*)pbuffer.Remove(pbuffer.Last()); //remove from the end to be reset, filled and put on the beginning
-        trackEvent2 = (AliHBTEvent*)tbuffer.Remove(tbuffer.Last());
-        ninbuffer--;
-       }
-      else
-       {
-        partEvent2  = new AliHBTEvent();
-        trackEvent2 = new AliHBTEvent();
-        partEvent2->SetOwner(kFALSE);
-        trackEvent2->SetOwner(kFALSE);
-       }
+      if ( (fBufferSize != 0) || ( (partEvent2==0x0)||(trackEvent2==0x0)) )//in case fBufferSize == 0 and pointers are created do not eneter
+       if ((ninbuffer > fBufferSize) && (fBufferSize > 0))
+        {//if we have in buffer desired number of events, use the last. If fBufferSize<0 mix all events for background
+         partEvent2  = (AliHBTEvent*)pbuffer.Remove(pbuffer.Last()); //remove from the end to be reset, filled and put on the beginning
+         trackEvent2 = (AliHBTEvent*)tbuffer.Remove(tbuffer.Last());
+         ninbuffer--;
+        }
+       else
+        {
+         partEvent2  = new AliHBTEvent();
+         trackEvent2 = new AliHBTEvent();
+         partEvent2->SetOwner(kFALSE);
+         trackEvent2->SetOwner(kFALSE);
+        }
       FilterOut(partEvent1, partEvent2, rawpartEvent, trackEvent1, trackEvent2, rawtrackEvent);
       
       for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
        {
-         if ( (j%100) == 0) cout<<"Mixing particle "<<j<<" from event "<<i<<" with particles from event "<<i<<endl;
+         if ( (j%fDisplayMixingInfo) == 0) 
+            Info("ProcessTracksAndParticlesNonIdentAnal",
+                 "Mixing particle %d from event %d with particles from event %d",j,i,i);
 
          part1= partEvent1->GetParticle(j);
          track1= trackEvent1->GetParticle(j);
 
-         UInt_t zz;
-         for(zz = 0; zz<fNParticleMonitorFunctions; zz++)
-           fParticleMonitorFunctions[zz]->ProcessSameEventParticles(part1);
-         for(zz = 0; zz<fNTrackMonitorFunctions; zz++)
-           fTrackMonitorFunctions[zz]->ProcessSameEventParticles(track1);
-         for(zz = 0; zz<fNParticleAndTrackMonitorFunctions; zz++)
-           fParticleAndTrackMonitorFunctions[zz]->ProcessSameEventParticles(track1,part1);
+         for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
+           fParticleMonitorFunctions[ii]->Process(part1);
+         for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
+           fTrackMonitorFunctions[ii]->Process(track1);
+         for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
+           fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
 
          /***************************************/
          /******   filling numerators    ********/
@@ -892,14 +976,12 @@ void AliHBTAnalysis::ProcessTracksAndParticlesNonIdentAnal()
             track2= trackEvent2->GetParticle(k);
             trackpair->SetParticles(track1,track2);
 
-
-            if( (fPairCut->PassPairProp(partpair)) || (fPairCut->PassPairProp(trackpair))) //check pair cut
-              { //do not meets crietria of the pair cut
-                  continue; 
-              }
+            if( (fPairCut->PassPairProp(partpair)) ) //check pair cut
+             { //do not meets crietria of the pair cut
+              continue; 
+             }
             else
              {//meets criteria of the pair cut
-              UInt_t ii;
               for(ii = 0;ii<fNParticleFunctions;ii++)
                      fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
 
@@ -911,7 +993,7 @@ void AliHBTAnalysis::ProcessTracksAndParticlesNonIdentAnal()
              }
            }
         
-
+     if ( fBufferSize == 0) continue;//do not mix diff histograms
      /***************************************/
      /***** Filling denominators    *********/
      /***************************************/
@@ -922,7 +1004,9 @@ void AliHBTAnalysis::ProcessTracksAndParticlesNonIdentAnal()
      while ( (partEvent3 = (AliHBTEvent*)piter.Next()) != 0x0)
       {
         trackEvent3 = (AliHBTEvent*)titer.Next();
-        if ( (j%100) == 0) cout<<"Mixing particle "<<j<<" from event "<<i<<" with particles from event "<<i - (++nmonitor)<<endl;
+        if ( (j%fDisplayMixingInfo) == 0) 
+          Info("ProcessTracksAndParticlesNonIdentAnal",
+               "Mixing particle %d from event %d with particles from event %d",j,i,i-(++nmonitor));
         
         for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
           {
@@ -932,11 +1016,10 @@ void AliHBTAnalysis::ProcessTracksAndParticlesNonIdentAnal()
             track2= trackEvent3->GetParticle(k);
             trackpair->SetParticles(track1,track2);
 
-
-            if( (fPairCut->PassPairProp(partpair)) || (fPairCut->PassPairProp(trackpair))) //check pair cut
-              { //do not meets crietria of the pair cut
-                  continue; 
-              }
+            if( (fPairCut->PassPairProp(partpair)) ) //check pair cut
+             { //do not meets crietria of the pair cut
+              continue; 
+             }
             else
              {//meets criteria of the pair cut
               UInt_t ii;
@@ -953,14 +1036,26 @@ void AliHBTAnalysis::ProcessTracksAndParticlesNonIdentAnal()
          }//while event2
        }//for over particles in event1
      
+     if ( fBufferSize == 0) continue;//do not mix diff histograms-> do not add to buffer list
      pbuffer.AddFirst(partEvent2);
      tbuffer.AddFirst(trackEvent2);
+     partEvent2 = 0x0;
+     trackEvent2 = 0x0;
      ninbuffer++;
 
   }//end of loop over events (1)
-  
  pbuffer.SetOwner();  //to clean stored events by the way of buffer destruction
  tbuffer.SetOwner();  
+ delete partEvent1;
+ delete trackEvent1;
+ delete partpair;
+ delete trackpair;
+ if ( fBufferSize == 0)
+  {//in that case we did not add these events to list
+    delete partEvent2;
+    delete trackEvent2;
+  }
+
 }
 /*************************************************************************************/  
  
@@ -968,13 +1063,11 @@ void AliHBTAnalysis::ProcessTracksNonIdentAnal()
 {
   AliHBTParticle * track1, * track2;
 
-  AliHBTEvent * trackEvent1;
-  AliHBTEvent * trackEvent2;
-  AliHBTEvent * trackEvent3;
+  AliHBTEvent * trackEvent1=0x0;
+  AliHBTEvent * trackEvent2=0x0;
+  AliHBTEvent * trackEvent3=0x0;
 
   AliHBTEvent * rawtrackEvent;
-//  AliHBTEvent * rawtrackEvent2,*rawpartEvent2;
-  
   
   Int_t Nev = fReader->GetNumberOfTrackEvents();
 
@@ -982,13 +1075,15 @@ void AliHBTAnalysis::ProcessTracksNonIdentAnal()
 
   TList tbuffer;
   Int_t ninbuffer = 0;
+  register UInt_t ii;
 
   trackEvent1 = new AliHBTEvent();
   trackEvent1->SetOwner(kFALSE);
   
-  cout<<"**************************************"<<endl;
-  cout<<"*****  NON IDENT MODE ****************"<<endl;
-  cout<<"**************************************"<<endl;
+  Info("ProcessTracksNonIdentAnal","**************************************");
+  Info("ProcessTracksNonIdentAnal","*****  NON IDENT MODE ****************");
+  Info("ProcessTracksNonIdentAnal","**************************************");
+  
   for (Int_t i = 0;i<Nev;i++)
     {
       rawtrackEvent = fReader->GetTrackEvent(i);
@@ -997,27 +1092,29 @@ void AliHBTAnalysis::ProcessTracksNonIdentAnal()
       /********************************/
       /*      Filtering out           */
       /********************************/
-      if ((ninbuffer > fBufferSize) && (fBufferSize > 0))
-       {//if we have in buffer desired number of events, use the last. If fBufferSize<0 mix all events for background
-        trackEvent2 = (AliHBTEvent*)tbuffer.Remove(tbuffer.Last());
-        ninbuffer--;
-       }
-      else
-       {
-        trackEvent2 = new AliHBTEvent();
-        trackEvent2->SetOwner(kFALSE);
-       }
+      if ( (fBufferSize != 0) || ( trackEvent2==0x0) )//in case fBufferSize == 0 and pointers are created do not eneter
+       if ((ninbuffer > fBufferSize) && (fBufferSize > 0))
+        {//if we have in buffer desired number of events, use the last. If fBufferSize<0 mix all events for background
+         trackEvent2 = (AliHBTEvent*)tbuffer.Remove(tbuffer.Last());
+         ninbuffer--;
+        }
+       else
+        {
+         trackEvent2 = new AliHBTEvent();
+         trackEvent2->SetOwner(kFALSE);
+        }
       FilterOut(trackEvent1, trackEvent2, rawtrackEvent);
       
       for (Int_t j = 0; j<trackEvent1->GetNumberOfParticles() ; j++)
        {
-         if ( (j%100) == 0) cout<<"Mixing particle "<<j<<" from event "<<i<<" with particles from event "<<i<<endl;
+         if ( (j%fDisplayMixingInfo) == 0) 
+           Info("ProcessTracksNonIdentAnal",
+                "Mixing particle %d from event %d with particles from event %d",j,i,i);
 
          track1= trackEvent1->GetParticle(j);
 
-        UInt_t zz;
-         for(zz = 0; zz<fNTrackMonitorFunctions; zz++)
-           fTrackMonitorFunctions[zz]->ProcessSameEventParticles(track1);
+         for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
+           fTrackMonitorFunctions[ii]->Process(track1);
 
          /***************************************/
          /******   filling numerators    ********/
@@ -1040,6 +1137,7 @@ void AliHBTAnalysis::ProcessTracksNonIdentAnal()
                      fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
              }
            }
+     if ( fBufferSize == 0) continue;//do not mix diff histograms
      /***************************************/
      /***** Filling denominators    *********/
      /***************************************/
@@ -1049,7 +1147,9 @@ void AliHBTAnalysis::ProcessTracksNonIdentAnal()
      while ( (trackEvent3 = (AliHBTEvent*)titer.Next()) != 0x0)
       {
         
-        if ( (j%100) == 0) cout<<"Mixing particle "<<j<<" from event "<<i<<" with particles from event "<<i - (++nmonitor)<<endl;
+        if ( (j%fDisplayMixingInfo) == 0) 
+            Info("ProcessTracksNonIdentAnal",
+                 "Mixing particle %d from event %d with particles from event %d",j,i,i-(++nmonitor));
         
         for (Int_t k = 0; k < trackEvent3->GetNumberOfParticles() ; k++)
           {
@@ -1059,25 +1159,28 @@ void AliHBTAnalysis::ProcessTracksNonIdentAnal()
 
 
             if( fPairCut->PassPairProp(trackpair)) //check pair cut
-              { //do not meets crietria of the pair cut
-                  continue; 
-              }
+             { //do not meets crietria of the pair cut
+               continue; 
+             }
             else
              {//meets criteria of the pair cut
-              UInt_t ii;
-              for(ii = 0;ii<fNTrackFunctions;ii++)
-                     fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
-
+               for(ii = 0;ii<fNTrackFunctions;ii++)
+                   fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
              }
            }// for particles event2
          }//while event2
        }//for over particles in event1
      
+     if ( fBufferSize == 0) continue;//do not mix diff histograms     
      tbuffer.AddFirst(trackEvent2);
+     trackEvent2 = 0x0;
      ninbuffer++;
 
   }//end of loop over events (1)
-  
+
+ delete trackpair;
+ delete trackEvent1;
+ if (fBufferSize == 0) delete trackEvent2;
  tbuffer.SetOwner();  
 }
 /*************************************************************************************/  
@@ -1102,11 +1205,10 @@ void AliHBTAnalysis::ProcessParticlesNonIdentAnal()
   partEvent1 = new AliHBTEvent();
   partEvent1->SetOwner(kFALSE);;
   
-  cout<<"**************************************"<<endl;
-  cout<<"*****    PART NON IDENT MODE    ******"<<endl;
-  cout<<"**************************************"<<endl;
+  Info("ProcessParticlesNonIdentAnal","**************************************");
+  Info("ProcessParticlesNonIdentAnal","*****  NON IDENT MODE ****************");
+  Info("ProcessParticlesNonIdentAnal","**************************************");
 
-//  gBenchmark->Start("non_id");
   for (Int_t i = 0;i<Nev;i++)
     {
       rawpartEvent  = fReader->GetParticleEvent(i);
@@ -1115,27 +1217,30 @@ void AliHBTAnalysis::ProcessParticlesNonIdentAnal()
       /********************************/
       /*      Filtering out           */
       /********************************/
-      if ((ninbuffer > fBufferSize) && (fBufferSize > 0))
-       {//if we have in buffer desired number of events, use the last. If fBufferSize<0 mix all events for background
-        partEvent2  = (AliHBTEvent*)pbuffer.Remove(pbuffer.Last()); //remove from the end to be reset, filled and put on the beginning
-        ninbuffer--;
-       }
-      else
-       {
-        partEvent2  = new AliHBTEvent();
-        partEvent2->SetOwner(kFALSE);
-       }
+      if ( (fBufferSize != 0) || ( partEvent2==0x0) )//in case fBufferSize == 0 and pointers are created do not eneter
+       if ((ninbuffer > fBufferSize) && (fBufferSize > 0))
+        {//if we have in buffer desired number of events, use the last. If fBufferSize<0 mix all events for background
+         partEvent2  = (AliHBTEvent*)pbuffer.Remove(pbuffer.Last()); //remove from the end to be reset, filled and put on the beginning
+         ninbuffer--; 
+        }
+       else
+        {
+         partEvent2  = new AliHBTEvent();
+         partEvent2->SetOwner(kFALSE);
+        }
       FilterOut(partEvent1, partEvent2, rawpartEvent);
       
       for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
        {
-         if ( (j%100) == 0) cout<<"Mixing particle "<<j<<" from event "<<i<<" with particles from event "<<i<<endl;
+         if ( (j%fDisplayMixingInfo) == 0) 
+            Info("ProcessParticlesNonIdentAnal",
+                 "Mixing particle %d from event %d with particles from event %d",j,i,i);
 
          part1= partEvent1->GetParticle(j);
 
          UInt_t zz;
          for(zz = 0; zz<fNParticleMonitorFunctions; zz++)
-           fParticleMonitorFunctions[zz]->ProcessSameEventParticles(part1);
+           fParticleMonitorFunctions[zz]->Process(part1);
 
          /***************************************/
          /******   filling numerators    ********/
@@ -1155,11 +1260,11 @@ void AliHBTAnalysis::ProcessParticlesNonIdentAnal()
               UInt_t ii;
               for(ii = 0;ii<fNParticleFunctions;ii++)
                 {
-                  //  if ((k%100) == 0) cout<<".";
                   fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
                 }
              }
            }
+     if ( fBufferSize == 0) continue;//do not mix diff histograms
      /***************************************/
      /***** Filling denominators    *********/
      /***************************************/
@@ -1168,14 +1273,15 @@ void AliHBTAnalysis::ProcessParticlesNonIdentAnal()
 
      while ( (partEvent3 = (AliHBTEvent*)piter.Next()) != 0x0)
       {
-        if ( (j%100) == 0) cout<<"Mixing particle "<<j<<" from event "<<i<<" with particles from event "<<i - (++nmonitor)<<endl;
-        
+        if ( (j%fDisplayMixingInfo) == 0) 
+            Info("ProcessParticlesNonIdentAnal",
+                 "Mixing particle %d from event %d with particles from event %d",j,i,i-(++nmonitor));
+
         for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
           {
             part2= partEvent3->GetParticle(k);
             partpair->SetParticles(part1,part2);
 
-
             if(fPairCut->PassPairProp(partpair) ) //check pair cut
               { //do not meets crietria of the pair cut
                   continue; 
@@ -1185,21 +1291,21 @@ void AliHBTAnalysis::ProcessParticlesNonIdentAnal()
               UInt_t ii;
               for(ii = 0;ii<fNParticleFunctions;ii++)
                {
-                //  if ((k%100) == 0) cout<<"*";
                  fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
                }
              }
            }// for particles event2
          }//while event2
        }//for over particles in event1
-     
+     if ( fBufferSize == 0) continue;//do not mix diff histograms
      pbuffer.AddFirst(partEvent2);
+     partEvent2 = 0x0; 
      ninbuffer++;
 
   }//end of loop over events (1)
-
-// gBenchmark->Stop("non_id");
-// gBenchmark->Show("non_id");
+ delete partpair;
+ delete partEvent1;
+ if ( fBufferSize == 0) delete partEvent2;
  pbuffer.SetOwner();//to delete stered events.
 }
 
@@ -1228,8 +1334,8 @@ void AliHBTAnalysis::FilterOut(AliHBTEvent* outpart1, AliHBTEvent* outpart2, Ali
      part = inpart->GetParticle(i);
      track = intrack->GetParticle(i);
      
-     if ( (cut1->Pass(part)) || ( cut1->Pass(track) ) ) in1 = kFALSE; //if any, part or track, is rejected by cut1, in1 is false
-     if ( (cut2->Pass(part)) || ( cut2->Pass(track) ) ) in2 = kFALSE; //if any, part or track, is rejected by cut2, in2 is false
+     if ( (cut1->Pass(part))  ) in1 = kFALSE; //if part  is rejected by cut1, in1 is false
+     if ( (cut2->Pass(part))  ) in2 = kFALSE; //if part  is rejected by cut2, in2 is false
      
      if (gDebug)//to be removed in real analysis     
      if ( in1 && in2 ) //both cuts accepted, should never happen, just in case
@@ -1253,11 +1359,9 @@ void AliHBTAnalysis::FilterOut(AliHBTEvent* outpart1, AliHBTEvent* outpart2, Ali
         continue;
       }
    }
 }
-
-
 /*************************************************************************************/  
+
 void AliHBTAnalysis::FilterOut(AliHBTEvent* out1, AliHBTEvent* out2, AliHBTEvent* in)
 {
  //Puts particles accepted as a first particle by global cut in out1