Added new background scheeme, did some cleanup. added new bethe block parameters...
authorkaamodt <kaamodt@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 14 Jan 2010 13:08:35 +0000 (13:08 +0000)
committerkaamodt <kaamodt@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 14 Jan 2010 13:08:35 +0000 (13:08 +0000)
PWG4/GammaConv/AliAnalysisTaskGammaConversion.cxx
PWG4/GammaConv/AliGammaConversionBGHandler.cxx [new file with mode: 0644]
PWG4/GammaConv/AliGammaConversionBGHandler.h [new file with mode: 0644]
PWG4/GammaConv/AliV0Reader.cxx
PWG4/GammaConv/AliV0Reader.h
PWG4/PWG4GammaConvLinkDef.h
PWG4/libPWG4GammaConv.pkg
PWG4/macros/ConfigGammaConversion.C

index f1d2c14..95584cb 100644 (file)
@@ -31,6 +31,7 @@
 //#include "AliCFManager.h"  // for CF
 //#include "AliCFContainer.h"   // for CF
 #include "AliGammaConversionAODObject.h"
+#include "AliGammaConversionBGHandler.h"
 
 class AliCFContainer;
 class AliCFManager;
@@ -291,33 +292,24 @@ void AliAnalysisTaskGammaConversion::Exec(Option_t */*option*/)
   fKFReconstructedGammasCutTClone->Delete();
   fPreviousEventTLVNegElectronTClone->Delete();
   fPreviousEventTLVPosElectronTClone->Delete();
-  //fKFReconstructedGammasTClone->Clear();
-  //fCurrentEventPosElectronTClone->Clear();
-  //fCurrentEventNegElectronTClone->Clear();
-  //fKFReconstructedGammasCutTClone->Clear();
-  //fPreviousEventTLVNegElectronTClone->Clear();
-  //fPreviousEventTLVPosElectronTClone->Clear();
-       
+
   //clear vectors
-  //  fKFReconstructedGammas.clear();
   fElectronv1.clear();
   fElectronv2.clear();
-  //  fCurrentEventPosElectron.clear();
-  //  fCurrentEventNegElectron.clear();        
-  //  fKFReconstructedGammasCut.clear(); 
        
   fChargedParticles->Delete(); 
-  //fChargedParticles->Clear();        
+
   fChargedParticlesId.clear(); 
        
   //Clear the data in the v0Reader
-  fV0Reader->UpdateEventByEventData();
+  //  fV0Reader->UpdateEventByEventData();
 
   //Take Only events with proper trigger
+  /*
   if(fTriggerCINT1B){
     if(!fV0Reader->GetESDEvent()->IsTriggerClassFired("CINT1B-ABCE-NOPF-ALL")) return;
   }
-
+  */
        
   // Process the MC information
   if(fDoMCTruth){
@@ -330,14 +322,10 @@ void AliAnalysisTaskGammaConversion::Exec(Option_t */*option*/)
   // Process the v0 information
   ProcessV0s();
   
+
   //Fill Gamma AOD
   FillAODWithConversionGammas() ; 
        
-  //calculate background if flag is set
-  if(fCalculateBackground){
-    CalculateBackground();
-  }
-       
   // Process reconstructed gammas
   if(fDoNeutralMeson == kTRUE){
     ProcessGammasForNeutralMesonAnalysis();
@@ -355,6 +343,14 @@ void AliAnalysisTaskGammaConversion::Exec(Option_t */*option*/)
     ProcessGammasForGammaJetAnalysis();
   }
        
+  //calculate background if flag is set
+  if(fCalculateBackground){
+    CalculateBackground();
+  }
+       
+  //Clear the data in the v0Reader
+  fV0Reader->UpdateEventByEventData();
+
   PostData(1, fOutputContainer);
   PostData(2, fCFManager->GetParticleContainer());  // for CF
        
@@ -1357,69 +1353,71 @@ void AliAnalysisTaskGammaConversion::ProcessGammasForNeutralMesonAnalysis(){
 
 void AliAnalysisTaskGammaConversion::CalculateBackground(){
   // see header file for documentation
+
+
+  TClonesArray * currentEventV0s = fV0Reader->GetCurrentEventGoodV0s();
+
+  for(Int_t nEventsInBG=0;nEventsInBG <fV0Reader->GetNBGEvents();nEventsInBG++){
+    AliGammaConversionKFVector * previousEventV0s = fV0Reader->GetBGGoodV0s(nEventsInBG);
+    for(Int_t iCurrent=0;iCurrent<currentEventV0s->GetEntriesFast();iCurrent++){
+      AliKFParticle currentEventGoodV0 = *(AliKFParticle *)(currentEventV0s->At(iCurrent)); 
+      for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
+       AliKFParticle previousGoodV0 = (AliKFParticle)(*(previousEventV0s->at(iPrevious)));
+
+       AliKFParticle *backgroundCandidate = new AliKFParticle(currentEventGoodV0,previousGoodV0);
        
-  vector<AliKFParticle> vectorCurrentEventGoodV0s = fV0Reader->GetCurrentEventGoodV0s();
-  vector<AliKFParticle> vectorPreviousEventGoodV0s = fV0Reader->GetPreviousEventGoodV0s();
-       
-  for(UInt_t iCurrent=0;iCurrent<vectorCurrentEventGoodV0s.size();iCurrent++){
-    AliKFParticle * currentEventGoodV0 = &vectorCurrentEventGoodV0s.at(iCurrent);
-    for(UInt_t iPrevious=0;iPrevious<vectorPreviousEventGoodV0s.size();iPrevious++){
-      AliKFParticle * previousGoodV0 = &vectorPreviousEventGoodV0s.at(iPrevious);
-                       
-      AliKFParticle *backgroundCandidate = new AliKFParticle(*currentEventGoodV0,*previousGoodV0);
-                       
-      Double_t massBG =0.;
-      Double_t widthBG = 0.;
-      Double_t chi2BG =10000.; 
-      backgroundCandidate->GetMass(massBG,widthBG);
-      if(backgroundCandidate->GetNDF()>0){
-       chi2BG = backgroundCandidate->GetChi2()/backgroundCandidate->GetNDF();
-       if(chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()){
+       Double_t massBG =0.;
+       Double_t widthBG = 0.;
+       Double_t chi2BG =10000.;        
+       backgroundCandidate->GetMass(massBG,widthBG);
+       if(backgroundCandidate->GetNDF()>0){
+         chi2BG = backgroundCandidate->GetChi2()/backgroundCandidate->GetNDF();
+         if(chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()){
                                        
-         TVector3 momentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
-         TVector3 spaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
+           TVector3 momentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
+           TVector3 spaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
                                        
-         Double_t openingAngleBG = currentEventGoodV0->GetAngle(*previousGoodV0);
+           Double_t openingAngleBG = currentEventGoodV0.GetAngle(previousGoodV0);
                                        
-         Double_t rapidity;
-         if(backgroundCandidate->GetE() - backgroundCandidate->GetPz() == 0 || backgroundCandidate->GetE() + backgroundCandidate->GetPz() == 0) rapidity=0;
-         else rapidity = 0.5*(TMath::Log((backgroundCandidate->GetE() +backgroundCandidate->GetPz()) / (backgroundCandidate->GetE()-backgroundCandidate->GetPz())));
+           Double_t rapidity;
+           if(backgroundCandidate->GetE() - backgroundCandidate->GetPz() == 0 || backgroundCandidate->GetE() + backgroundCandidate->GetPz() == 0) rapidity=0;
+           else rapidity = 0.5*(TMath::Log((backgroundCandidate->GetE() +backgroundCandidate->GetPz()) / (backgroundCandidate->GetE()-backgroundCandidate->GetPz())));
                                        
                                        
                                        
                                        
-         if(openingAngleBG < fMinOpeningAngleGhostCut ){
-           delete backgroundCandidate;   
-           continue;   // minimum opening angle to avoid using ghosttracks
-         }                     
+           if(openingAngleBG < fMinOpeningAngleGhostCut ){
+             delete backgroundCandidate;   
+             continue;   // minimum opening angle to avoid using ghosttracks
+           }                   
                                        
-         fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle", openingAngleBG);
-         fHistograms->FillHistogram("ESD_Background_Energy", backgroundCandidate->GetE());
-         fHistograms->FillHistogram("ESD_Background_Pt",  momentumVectorbackgroundCandidate.Pt());
-         fHistograms->FillHistogram("ESD_Background_Eta", momentumVectorbackgroundCandidate.Eta());
-         fHistograms->FillHistogram("ESD_Background_Rapidity", rapidity);
-         fHistograms->FillHistogram("ESD_Background_Phi", spaceVectorbackgroundCandidate.Phi());
-         fHistograms->FillHistogram("ESD_Background_Mass", massBG);
-         fHistograms->FillHistogram("ESD_Background_R", spaceVectorbackgroundCandidate.Pt());  // Pt in Space == R!!!!
-         fHistograms->FillHistogram("ESD_Background_ZR", backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
-         fHistograms->FillHistogram("ESD_Background_XY", backgroundCandidate->GetX(), backgroundCandidate->GetY());
-         fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt",massBG,momentumVectorbackgroundCandidate.Pt());
-         fHistograms->FillHistogram("ESD_Background_InvMass",massBG);
-
-         if ( TMath::Abs(currentEventGoodV0->GetEta())<0.9 &&  TMath::Abs(previousGoodV0->GetEta())<0.9 ){
-           fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_Fiducial",massBG,momentumVectorbackgroundCandidate.Pt());
-           fHistograms->FillHistogram("ESD_Background_InvMass_Fiducial",massBG);
-         }
+           fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle", openingAngleBG);
+           fHistograms->FillHistogram("ESD_Background_Energy", backgroundCandidate->GetE());
+           fHistograms->FillHistogram("ESD_Background_Pt",  momentumVectorbackgroundCandidate.Pt());
+           fHistograms->FillHistogram("ESD_Background_Eta", momentumVectorbackgroundCandidate.Eta());
+           fHistograms->FillHistogram("ESD_Background_Rapidity", rapidity);
+           fHistograms->FillHistogram("ESD_Background_Phi", spaceVectorbackgroundCandidate.Phi());
+           fHistograms->FillHistogram("ESD_Background_Mass", massBG);
+           fHistograms->FillHistogram("ESD_Background_R", spaceVectorbackgroundCandidate.Pt());  // Pt in Space == R!!!!
+           fHistograms->FillHistogram("ESD_Background_ZR", backgroundCandidate->GetZ(), spaceVectorbackgroundCandidate.Pt());
+           fHistograms->FillHistogram("ESD_Background_XY", backgroundCandidate->GetX(), backgroundCandidate->GetY());
+           fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt",massBG,momentumVectorbackgroundCandidate.Pt());
+           fHistograms->FillHistogram("ESD_Background_InvMass",massBG);
+
+           if ( TMath::Abs(currentEventGoodV0.GetEta())<0.9 &&  TMath::Abs(previousGoodV0.GetEta())<0.9 ){
+             fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt_Fiducial",massBG,momentumVectorbackgroundCandidate.Pt());
+             fHistograms->FillHistogram("ESD_Background_InvMass_Fiducial",massBG);
+           }
 
+         }
        }
+       delete backgroundCandidate;      
       }
-      delete backgroundCandidate;   
     }
   }
 }
 
 
-
 void AliAnalysisTaskGammaConversion::ProcessGammasForGammaJetAnalysis(){
   //ProcessGammasForGammaJetAnalysis
        
@@ -1668,7 +1666,7 @@ Double_t AliAnalysisTaskGammaConversion::GetMCOpeningAngle(TParticle* const daug
 
 void AliAnalysisTaskGammaConversion::CheckV0Efficiency(){
   // see header file for documentation
-       
+
   vector<Int_t> indexOfGammaParticle;
        
   fStack = fV0Reader->GetMCStack();
@@ -1889,14 +1887,7 @@ void AliAnalysisTaskGammaConversion::ProcessGammaElectronsForChicAnalysis(){
                        
     }
     else {
-      //      vESDxNegTemp.push_back(curTrack);
-      /*                       if(vESDxNegTemp == NULL){
-                               cout<<"TCloes is zero"<<endl;
-                               }
-                               if(curTrack == NULL){
-                               cout<<"curTrack is zero"<<endl;
-                               }
-      */       
+
       new((*vESDxNegTemp)[vESDxNegTemp->GetEntriesFast()])  AliESDtrack(*curTrack);
                        
       if( pid == 0){
@@ -1904,9 +1895,6 @@ void AliAnalysisTaskGammaConversion::ProcessGammaElectronsForChicAnalysis(){
        fHistograms->FillHistogram("ESD_ElectronPosNegPt",curElec.Pt());
        fHistograms->FillHistogram("ESD_ElectronNegPt",curElec.Pt());
        fHistograms->FillHistogram("ESD_ElectronPosNegEta",curElec.Eta());
-       //      fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());
-       //      fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());
-       //vESDeNegTemp.push_back(curTrack);
        new((*vESDeNegTemp)[vESDeNegTemp->GetEntriesFast()])  AliESDtrack(*curTrack);
                                
       }
diff --git a/PWG4/GammaConv/AliGammaConversionBGHandler.cxx b/PWG4/GammaConv/AliGammaConversionBGHandler.cxx
new file mode 100644 (file)
index 0000000..2b35c6a
--- /dev/null
@@ -0,0 +1,176 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt                        *
+ * Version 1.0                                                            *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+////////////////////////////////////////////////
+//--------------------------------------------- 
+// Class for handling of background calculation
+//---------------------------------------------
+////////////////////////////////////////////////
+
+#include "AliGammaConversionBGHandler.h"
+#include "AliKFParticle.h"
+#include "AliAnalysisTaskGammaConversion.h"
+
+using namespace std;
+
+ClassImp(AliGammaConversionBGHandler)
+
+AliGammaConversionBGHandler::AliGammaConversionBGHandler() :
+  TObject(),
+  fNEvents(10),
+  fBGEventCounter(NULL),
+  fNBinsZ(0),
+  fNBinsMultiplicity(0),
+  fBinLimitsArrayZ(NULL),
+  fBinLimitsArrayMultiplicity(NULL),
+  fBGEvents()
+{
+  // constructor
+}
+
+AliGammaConversionBGHandler::AliGammaConversionBGHandler(UInt_t binsZ,UInt_t binsMultiplicity,UInt_t nEvents) :
+  TObject(),
+  fNEvents(nEvents),
+  fBGEventCounter(NULL),
+  fNBinsZ(binsZ),
+  fNBinsMultiplicity(binsMultiplicity),
+  fBinLimitsArrayZ(NULL),
+  fBinLimitsArrayMultiplicity(NULL),
+  fBGEvents(binsZ,AliGammaConversionMultipicityVector(binsMultiplicity,AliGammaConversionBGEventVector(nEvents)))
+{
+  // constructor
+}
+
+AliGammaConversionBGHandler::AliGammaConversionBGHandler(const AliGammaConversionBGHandler & original) :
+  TObject(original),
+  fNEvents(original.fNEvents),
+  fBGEventCounter(original.fBGEventCounter),
+  fNBinsZ(original.fNBinsZ),
+  fNBinsMultiplicity(original.fNBinsMultiplicity),
+  fBinLimitsArrayZ(original.fBinLimitsArrayZ),
+  fBinLimitsArrayMultiplicity(original.fBinLimitsArrayMultiplicity),
+  fBGEvents(original.fBGEvents)
+{
+  //copy constructor   
+}
+
+AliGammaConversionBGHandler & AliGammaConversionBGHandler::operator = (const AliGammaConversionBGHandler & /*source*/)
+{
+  // assignment operator
+  return *this;
+}
+
+AliGammaConversionBGHandler::~AliGammaConversionBGHandler(){
+
+  //Kenneth remember to clear memory!!!!!!!!!!!!!!!!!!!!!
+  if(fBGEventCounter){
+    for(Int_t z=0;z<fNBinsZ;z++){
+      delete[] fBGEventCounter[z];
+    }
+    delete[] fBGEventCounter;
+    fBGEventCounter = NULL;
+  }
+  
+  if(fBinLimitsArrayZ){
+    delete[] fBinLimitsArrayZ;
+  }
+
+  if(fBinLimitsArrayMultiplicity){
+    delete[] fBinLimitsArrayMultiplicity;
+  }
+}
+
+void AliGammaConversionBGHandler::Initialize(Double_t *zBinLimitsArray, Double_t *multiplicityBinLimitsArray){
+  // see header file for documantation  
+
+  if(zBinLimitsArray){
+    fBinLimitsArrayZ = zBinLimitsArray;
+  }
+  else{
+    //Print warning
+  }
+  
+  if(multiplicityBinLimitsArray){
+    fBinLimitsArrayMultiplicity = multiplicityBinLimitsArray ;
+  }
+  else{
+    //Print warning
+  }
+  fBGEventCounter= new Int_t*[fNBinsZ];
+  for(Int_t z=0;z<fNBinsZ;z++){
+    fBGEventCounter[z]=new Int_t[fNBinsMultiplicity];
+  }
+}
+
+Int_t AliGammaConversionBGHandler::GetZBinIndex(Double_t zvalue){
+  // see header file for documantation
+  if(fNBinsZ<2 || zvalue<=fBinLimitsArrayZ[0]){
+    return 0;
+  }
+
+  for(Int_t i=0; i<fNBinsZ-1 ;i++){
+    if(zvalue >= fBinLimitsArrayZ[i] && zvalue <= fBinLimitsArrayZ[i+1]){
+      return i;
+    }
+  }
+  return fNBinsZ-1;
+}
+
+Int_t AliGammaConversionBGHandler::GetMultiplicityBinIndex(Int_t multiplicity){
+  // see header file for documantation  
+  if(fNBinsMultiplicity<2){
+    return 0;
+  }
+
+  for(Int_t i=0; i<fNBinsMultiplicity-1 ;i++){
+    if(multiplicity > fBinLimitsArrayMultiplicity[i] && multiplicity < fBinLimitsArrayMultiplicity[i+1]){
+      return i;
+    }
+  }
+  return fNBinsMultiplicity-1;
+}
+
+void AliGammaConversionBGHandler::AddEvent(TClonesArray * eventGammas, Double_t zvalue, Int_t multiplicity){
+  // see header file for documantation  
+
+  Int_t z = GetZBinIndex(zvalue);
+  Int_t m = GetMultiplicityBinIndex(multiplicity);
+
+  if(fBGEventCounter[z][m] >= fNEvents -1){
+    fBGEventCounter[z][m]=0;
+  }
+  Int_t eventCounter=fBGEventCounter[z][m];
+
+  //first clear the vector which is present for any gammas
+  fBGEvents[z][m][eventCounter].fReconstructedGammas.clear();
+
+  // add the gammas to the vector
+  for(Int_t i=0; i< eventGammas->GetEntriesFast();i++){
+
+    fBGEvents[z][m][eventCounter].fReconstructedGammas.push_back((AliKFParticle*)(eventGammas->At(i)));
+  }
+
+  //set the z and multiplicity numbers
+  fBGEvents[z][m][eventCounter].fZVertexPosition = zvalue;
+  fBGEvents[z][m][eventCounter].fChargedTrackMultiplicity = multiplicity;
+}
+
+AliGammaConversionKFVector* AliGammaConversionBGHandler::GetBGGoodV0s(Int_t event, Double_t zvalue, Int_t multiplicity){
+
+  Int_t z = GetZBinIndex(zvalue);
+  Int_t m = GetMultiplicityBinIndex(multiplicity);
+
+  return &(fBGEvents[z][m][event].fReconstructedGammas);
+}
diff --git a/PWG4/GammaConv/AliGammaConversionBGHandler.h b/PWG4/GammaConv/AliGammaConversionBGHandler.h
new file mode 100644 (file)
index 0000000..974aff4
--- /dev/null
@@ -0,0 +1,83 @@
+//-*- Mode: C++ -*-
+#ifndef ALIGAMMACONVERSIONBGHANDLER_H
+#define ALIGAMMACONVERSIONBGHANDLER_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+
+////////////////////////////////////////////////
+//--------------------------------------------- 
+// Class  for handling of background calculation
+//---------------------------------------------
+////////////////////////////////////////////////
+
+#include <vector>
+
+
+// --- ROOT system ---
+#include <TObject.h> 
+#include "AliKFParticle.h"
+#include "TClonesArray.h"
+
+#if __GNUC__ >= 3
+using namespace std;
+#endif
+
+typedef vector<AliKFParticle*> AliGammaConversionKFVector;
+
+
+class AliGammaConversionBGHandler : public TObject {
+
+ public: 
+struct AliGammaConversionBGEvent
+{
+  AliGammaConversionBGEvent() :
+    fReconstructedGammas(),
+    fChargedTrackMultiplicity(0),
+    fZVertexPosition(0.)
+  {
+  }
+  AliGammaConversionKFVector fReconstructedGammas;
+  UInt_t fChargedTrackMultiplicity;
+  Double_t fZVertexPosition;
+}; typedef struct AliGammaConversionBGEvent AliGammaConversionBGEvent; //!     
+
+  
+  typedef vector<AliGammaConversionBGEvent> AliGammaConversionBGEventVector;
+  //  typedef vector<Int_t> AliGammaConversionBGEventVector;
+  typedef vector<AliGammaConversionBGEventVector> AliGammaConversionMultipicityVector;
+  typedef vector<AliGammaConversionMultipicityVector> AliGammaConversionBGVector;
+  
+    
+
+  AliGammaConversionBGHandler();                                                        //constructor
+  AliGammaConversionBGHandler(UInt_t binsZ,UInt_t binsMultiplicity,UInt_t fNEvents);    //constructor
+  AliGammaConversionBGHandler(const AliGammaConversionBGHandler & g);                   //copy constructor
+  AliGammaConversionBGHandler & operator = (const AliGammaConversionBGHandler & g);     //assignment operator
+  virtual ~AliGammaConversionBGHandler();                                               //virtual destructor
+
+  void Initialize(Double_t *zBinLimitsArray, Double_t *multiplicityBinLimitsArray);
+
+  Int_t GetZBinIndex(Double_t z);
+
+  Int_t GetMultiplicityBinIndex(Int_t mult);
+
+  void AddEvent(TClonesArray * eventGammas, Double_t zvalue, Int_t multiplicity);
+
+  Int_t GetNBGEvents(){return fNEvents;}
+
+  AliGammaConversionKFVector* GetBGGoodV0s(Int_t event, Double_t zvalue, Int_t multiplicity);
+
+ private:
+
+  Int_t fNEvents;
+  Int_t ** fBGEventCounter;
+  
+  Int_t fNBinsZ;
+  Int_t fNBinsMultiplicity;
+  Double_t *fBinLimitsArrayZ;
+  Double_t *fBinLimitsArrayMultiplicity;
+  AliGammaConversionBGVector fBGEvents;
+
+  ClassDef(AliGammaConversionBGHandler,0)
+};
+#endif
index 3d981ea..a9e829f 100644 (file)
@@ -33,6 +33,7 @@
 #include "AliStack.h"
 #include "AliMCEventHandler.h"
 #include "AliTPCpidESD.h"
+#include "AliGammaConversionBGHandler.h"
 
 class iostream;
 class AliESDv0;
@@ -102,8 +103,10 @@ AliV0Reader::AliV0Reader() :
   fDoCF(kFALSE),
   fUseOnFlyV0Finder(kTRUE),
   fUpdateV0AlreadyCalled(kFALSE),
-  fCurrentEventGoodV0s(),
-  fPreviousEventGoodV0s()
+  fCurrentEventGoodV0s(NULL),
+//  fPreviousEventGoodV0s(),
+  fBGEventHandler(NULL),
+  fBGEventInitialized(kFALSE)
 {
   fTPCpid = new AliTPCpidESD;  
 }
@@ -168,7 +171,9 @@ AliV0Reader::AliV0Reader(const AliV0Reader & original) :
   fUseOnFlyV0Finder(original.fUseOnFlyV0Finder),
   fUpdateV0AlreadyCalled(original.fUpdateV0AlreadyCalled),
   fCurrentEventGoodV0s(original.fCurrentEventGoodV0s),
-  fPreviousEventGoodV0s(original.fPreviousEventGoodV0s)
+  //  fPreviousEventGoodV0s(original.fPreviousEventGoodV0s),
+  fBGEventHandler(original.fBGEventHandler),
+  fBGEventInitialized(original.fBGEventInitialized)
 {
        
 }
@@ -188,6 +193,7 @@ AliV0Reader::~AliV0Reader()
 
 void AliV0Reader::Initialize(){
   //see header file for documentation
+
   fUpdateV0AlreadyCalled = kFALSE;     
   // Get the input handler from the manager
   fESDHandler = (AliESDInputHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
@@ -214,6 +220,20 @@ void AliV0Reader::Initialize(){
     if(fMCStack == NULL){
       //print warning here
     }
+    // Better parameters for MonteCarlo from A. Kalweit 2010/01/8
+    fTPCpid->SetBetheBlochParameters( 2.15898e+00/50.,
+                                     1.75295e+01,
+                                     3.40030e-09,
+                                     1.96178e+00,
+                                     3.91720e+00);
+  }
+  else{
+    // Better parameters for data from A. Kalweit 2010/01/8
+    fTPCpid->SetBetheBlochParameters(0.0283086,
+                                    2.63394e+01,
+                                    5.04114e-11,
+                                    2.12543e+00,
+                                    4.88663e+00);
   }
        
   // for CF
@@ -225,9 +245,38 @@ void AliV0Reader::Initialize(){
       fDoCF = kFALSE;
     }  
   }
+
+
+
        
   AliKFParticle::SetField(fESDEvent->GetMagneticField());
-       
+
+  //  fCurrentEventGoodV0s = new TClonesArray("TClonesArray", 0);
+  fCurrentEventGoodV0s = new TClonesArray("AliKFParticle", 0);
+
+  if(fBGEventInitialized == kFALSE){
+    Double_t *zBinLimitsArray = new Double_t[8];//{-7,-5,-3,-1,1,3,5,7};
+    zBinLimitsArray[0] = -7;
+    zBinLimitsArray[1] = -5;
+    zBinLimitsArray[2] = -3;
+    zBinLimitsArray[3] = -1;
+    zBinLimitsArray[4] = 1;
+    zBinLimitsArray[5] = 3;
+    zBinLimitsArray[6] = 5;
+    zBinLimitsArray[7] = 7;
+    
+    Double_t *multiplicityBinLimitsArray= new Double_t[4];//={0,10,20,500};
+    multiplicityBinLimitsArray[0] = 0;
+    multiplicityBinLimitsArray[1] = 10;
+    multiplicityBinLimitsArray[2] = 20;
+    multiplicityBinLimitsArray[3] = 500;
+    
+    
+    fBGEventHandler = new AliGammaConversionBGHandler(8,4,10);
+    
+    fBGEventHandler->Initialize(zBinLimitsArray, multiplicityBinLimitsArray);
+    fBGEventInitialized = kTRUE;
+  }
 }
 
 AliESDv0* AliV0Reader::GetV0(Int_t index){
@@ -413,8 +462,10 @@ Bool_t AliV0Reader::NextV0(){
       fHistograms->FillHistogram("ESD_GoodV0s_InvMass",GetMotherCandidateMass());
     }
 
-    fCurrentEventGoodV0s.push_back(*fCurrentMotherKFCandidate);
-               
+    //    fCurrentEventGoodV0s.push_back(*fCurrentMotherKFCandidate);
+
+    new((*fCurrentEventGoodV0s)[fCurrentEventGoodV0s->GetEntriesFast()])  AliKFParticle(*fCurrentMotherKFCandidate);
+
     iResult=kTRUE;//means we have a v0 who survived all the cuts applied
                
     fCurrentV0IndexNumber++;
@@ -679,30 +730,10 @@ void AliV0Reader::GetPIDProbability(Double_t &negPIDProb,Double_t & posPIDProb){
 
 void AliV0Reader::UpdateEventByEventData(){
   //see header file for documentation
-       
-  if(fCurrentEventGoodV0s.size() >0 ){
-    //    fPreviousEventGoodV0s.clear();
-    //    fPreviousEventGoodV0s = fCurrentEventGoodV0s;
-    if(fPreviousEventGoodV0s.size()>19){
-      for(UInt_t nCurrent=0;nCurrent<fCurrentEventGoodV0s.size();nCurrent++){
-       fPreviousEventGoodV0s.erase(fPreviousEventGoodV0s.begin());
-       fPreviousEventGoodV0s.push_back(fCurrentEventGoodV0s.at(nCurrent));
-      }
-    }
-    else{
-      for(UInt_t nCurrent=0;nCurrent<fCurrentEventGoodV0s.size();nCurrent++){
-       if(fPreviousEventGoodV0s.size()<20){
-         fPreviousEventGoodV0s.push_back(fCurrentEventGoodV0s.at(nCurrent));
-       }
-       else{
-         fPreviousEventGoodV0s.erase(fPreviousEventGoodV0s.begin());
-         fPreviousEventGoodV0s.push_back(fCurrentEventGoodV0s.at(nCurrent));
-       }
-      }
-    }
+  if(fCurrentEventGoodV0s->GetEntriesFast() >0 ){
+    fBGEventHandler->AddEvent(fCurrentEventGoodV0s,fESDEvent->GetPrimaryVertex()->GetZ(),fESDEvent->GetNumberOfTracks());
   }
-  fCurrentEventGoodV0s.clear();
-       
+  fCurrentEventGoodV0s->Delete();
   fCurrentV0IndexNumber=0;
 }
 
@@ -977,3 +1008,8 @@ Double_t AliV0Reader::GetConvPosZ(AliESDtrack* ptrack,AliESDtrack* ntrack, Doubl
 
    return convposz;
 }
+
+AliGammaConversionKFVector* AliV0Reader::GetBGGoodV0s(Int_t event){
+
+  return fBGEventHandler->GetBGGoodV0s(event,fESDEvent->GetPrimaryVertex()->GetZ(),fESDEvent->GetNumberOfTracks());
+}
index 34c2b5a..c937e14 100644 (file)
@@ -19,7 +19,7 @@
 #include "AliGammaConversionHistograms.h"
 #include <vector>
 #include "AliCFManager.h"
-
+#include "AliGammaConversionBGHandler.h"
 
 class TClonesArray; 
 class TFormula;
@@ -577,12 +577,13 @@ class AliV0Reader : public TObject {
   /*
    * Gets a vector of good v0s.
    */
-  vector<AliKFParticle> GetCurrentEventGoodV0s() const{return fCurrentEventGoodV0s;}
+  TClonesArray* GetCurrentEventGoodV0s() const{return fCurrentEventGoodV0s;}
        
   /*
    * Gets the vector of previous events v0s (for bacground analysis)
    */
-  vector<AliKFParticle> GetPreviousEventGoodV0s() const{return fPreviousEventGoodV0s;}
+  AliGammaConversionKFVector* GetBGGoodV0s(Int_t event);
+  //  vector<AliKFParticle> GetPreviousEventGoodV0s() const{return fPreviousEventGoodV0s;}
 
   void SetUseOwnXYZCalculation(Bool_t flag){fUseOwnXYZCalculation=flag;}
 
@@ -598,6 +599,7 @@ class AliV0Reader : public TObject {
 
   void SetOnFlyFlag(Bool_t flag){fUseOnFlyV0Finder = flag;}
 
+ Int_t GetNBGEvents(){return fBGEventHandler->GetNBGEvents();}
 
  private:
   AliStack * fMCStack;           // pointer to MonteCarlo particle stack 
@@ -681,10 +683,13 @@ class AliV0Reader : public TObject {
 
   Bool_t fUpdateV0AlreadyCalled; //flag
        
-  vector<AliKFParticle> fCurrentEventGoodV0s; //vector of good v0s
-  vector<AliKFParticle> fPreviousEventGoodV0s; // vector of good v0s from prevous events
+  TClonesArray* fCurrentEventGoodV0s; //vector of good v0s
+  //  vector<AliKFParticle> fPreviousEventGoodV0s; // vector of good v0s from prevous events
+
+  AliGammaConversionBGHandler *fBGEventHandler;
+  Bool_t fBGEventInitialized;
        
-  ClassDef(AliV0Reader,7)
+  ClassDef(AliV0Reader,8)
 };
 #endif
 
index 7a7bd22..2263b18 100644 (file)
@@ -8,5 +8,6 @@
 #pragma link C++ class AliV0Reader+;
 #pragma link C++ class AliGammaConversionHistograms+;
 #pragma link C++ class AliGammaConversionAODObject+;
+#pragma link C++ class AliGammaConversionBGHandler+;
 
 #endif
index 6c8187d..e7ea9c1 100644 (file)
@@ -1,6 +1,6 @@
 #-*- Mode: Makefile -*-
 
-SRCS = GammaConv/AliV0Reader.cxx GammaConv/AliAnalysisTaskGammaConversion.cxx GammaConv/AliGammaConversionHistograms.cxx GammaConv/AliGammaConversionAODObject.cxx
+SRCS = GammaConv/AliV0Reader.cxx GammaConv/AliAnalysisTaskGammaConversion.cxx GammaConv/AliGammaConversionHistograms.cxx GammaConv/AliGammaConversionAODObject.cxx GammaConv/AliGammaConversionBGHandler.cxx
       
 HDRS:= $(SRCS:.cxx=.h) 
 
index c90a248..47505a3 100644 (file)
@@ -744,6 +744,9 @@ Bool_t scanArguments(TString arguments){
          cout<<"Setting output file name to: "<<kGCoutputFileName<<endl;
        }
       }
+      else if (argument.CompareTo("-bg-off") == 0){
+       kGCcalculateBackground =kFALSE;
+      }
       else if (argument.CompareTo("-use-offline-finder") == 0){
        kGCUseOnFlyV0Finder = kFALSE;
       }
@@ -1021,13 +1024,7 @@ AliAnalysisTaskGammaConversion* ConfigGammaConversion(TString arguments,AliAnaly
     }
   }
   else{
-    if(kGCrunOnTrain == kFALSE){
-      cinput1 = mgr->GetCommonInputContainer(); // added by kenneth to avoid writing the standard AOD
-    }
-    else{ //CKB if and else do the same here
-      //      cinput = cin_esd;
       cinput1 = mgr->GetCommonInputContainer();
-    }
   }
        
   // Common Output Tree in common Ã¢\80\98defaultâ\80\99 output file