New classes plus some renamed for a better user friendly interface
authorpulvir <pulvir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 30 Jul 2008 17:53:34 +0000 (17:53 +0000)
committerpulvir <pulvir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 30 Jul 2008 17:53:34 +0000 (17:53 +0000)
14 files changed:
PWG2/RESONANCES/AliRsnHistoDef.cxx [new file with mode: 0644]
PWG2/RESONANCES/AliRsnHistoDef.h [new file with mode: 0644]
PWG2/RESONANCES/AliRsnSimpleAnalysis.cxx [new file with mode: 0644]
PWG2/RESONANCES/AliRsnSimpleAnalysis.h [new file with mode: 0644]
PWG2/RESONANCES/AliRsnSimpleAnalysisTaskSE.cxx [new file with mode: 0644]
PWG2/RESONANCES/AliRsnSimpleAnalysisTaskSE.h [new file with mode: 0644]
PWG2/RESONANCES/AliRsnSimpleAnalyzer.cxx [new file with mode: 0644]
PWG2/RESONANCES/AliRsnSimpleAnalyzer.h [new file with mode: 0644]
PWG2/RESONANCES/AliRsnSimpleFcnInvMass.cxx [new file with mode: 0644]
PWG2/RESONANCES/AliRsnSimpleFcnInvMass.h [new file with mode: 0644]
PWG2/RESONANCES/AliRsnSimpleFcnResolution.cxx [new file with mode: 0644]
PWG2/RESONANCES/AliRsnSimpleFcnResolution.h [new file with mode: 0644]
PWG2/RESONANCES/AliRsnSimpleFunction.cxx [new file with mode: 0644]
PWG2/RESONANCES/AliRsnSimpleFunction.h [new file with mode: 0644]

diff --git a/PWG2/RESONANCES/AliRsnHistoDef.cxx b/PWG2/RESONANCES/AliRsnHistoDef.cxx
new file mode 100644 (file)
index 0000000..d87f7e7
--- /dev/null
@@ -0,0 +1,139 @@
+//
+// Class AliRsnHistoDef
+//
+// Definition for a histogram type.
+// Since one could do an analysis which is not an invariant mass
+// the histogram definition should be more flexible, and it is stored
+// separately in a new class.
+// This class considers the possibility of a 1D or 2D histograms
+// with its related binning, and can create a new histo from his definitions
+//
+
+#include <TH1.h>
+#include <TH2.h>
+
+#include "AliLog.h"
+
+#include "AliRsnHistoDef.h"
+
+ClassImp(AliRsnHistoDef)
+
+//_____________________________________________________________________________
+AliRsnHistoDef::AliRsnHistoDef() :
+  fNDim(0)
+{
+//
+// Default constructor
+//
+}
+
+//_____________________________________________________________________________
+AliRsnHistoDef::AliRsnHistoDef
+(Int_t nbins, Double_t min, Double_t max) :
+  fNDim(1)
+{
+//
+// 1D histo definition.
+//
+
+    SetBins(nbins, min, max);
+}
+//_____________________________________________________________________________
+AliRsnHistoDef::AliRsnHistoDef
+(Int_t nbinsX, Double_t minX, Double_t maxX, Int_t nbinsY, Double_t minY, Double_t maxY):
+  fNDim(2)
+{
+//
+// 1D histo definition.
+//
+
+    SetBins(nbinsX, minX, maxX, nbinsY, minY, maxY);
+}
+
+//_____________________________________________________________________________
+void AliRsnHistoDef::SetBins(Int_t n, Double_t min, Double_t max)
+{
+//
+// Binning for 1D histograms.
+//
+
+    fNDim = 1;
+    
+    fNBins[0] = n;
+    fMin[0] = min;
+    fMax[0] = max;
+    
+    CheckEdges();
+}
+
+//_____________________________________________________________________________
+void AliRsnHistoDef::SetBins
+(Int_t nx, Double_t minx, Double_t maxx, Int_t ny, Double_t miny, Double_t maxy)
+{
+//
+// Binning for 1D histograms.
+//
+
+    fNDim = 2;
+    
+    fNBins[0] = nx;
+    fMin[0] = minx;
+    fMax[0] = maxx;
+    
+    fNBins[1] = ny;
+    fMin[1] = miny;
+    fMax[1] = maxy;
+    
+    CheckEdges();
+}
+
+//_____________________________________________________________________________
+void AliRsnHistoDef::CheckEdges()
+{
+//
+// Checks that histogram edges are appropriate,
+// otherwise swaps them.
+//
+
+    Int_t i;
+    for (i = 0; i < fNDim; i++) {
+        if (fMin[i] > fMax[i]) {
+            AliWarning(Form("min = %f -- max = %f --> swapping", fMin, fMax));
+            Double_t temp = fMin[i];
+            fMin[i] = fMax[i];
+            fMax[i] = temp;
+        }
+    }
+}
+
+//_____________________________________________________________________________
+TH1D* AliRsnHistoDef::Create1DHistogram(const char *name, const char *title)
+{
+//
+// Create 1D histogram, if the configuration is appropriate for this.
+//
+
+    if (fNDim != 1) {
+        AliError("Number of dimension not set to 1!");
+        return 0x0;
+    }
+
+    TH1D *histo = new TH1D(name, title, fNBins[0], fMin[0], fMax[0]);
+    return histo;
+}
+
+//_____________________________________________________________________________
+TH2D* AliRsnHistoDef::Create2DHistogram(const char *name, const char *title)
+{
+//
+// Create 2D histogram, if the configuration is appropriate for this.
+//
+
+    if (fNDim != 2) {
+        AliError("Number of dimension not set to 2!");
+        return 0x0;
+    }
+    
+    TH2D *histo = new TH2D(name, title, fNBins[0], fMin[0], fMax[0], fNBins[1], fMin[1], fMax[1]);
+    return histo;
+}
diff --git a/PWG2/RESONANCES/AliRsnHistoDef.h b/PWG2/RESONANCES/AliRsnHistoDef.h
new file mode 100644 (file)
index 0000000..5cd6cbb
--- /dev/null
@@ -0,0 +1,52 @@
+//
+// Class AliRsnHistoDef
+//
+// Definition for a histogram type.
+// Since one could do an analysis which is not an invariant mass
+// the histogram definition should be more flexible, and it is stored
+// separately in a new class.
+// This class considers the possibility of a 1D or 2D histograms
+// with its related binning, and can create a new histo from his definitions
+//
+
+#ifndef AliRsnHistoDef_H
+#define AliRsnHistoDef_H
+
+class TH1;
+class TH1D;
+class TH2D;
+
+class AliRsnHistoDef : public TObject
+{
+public:
+
+    AliRsnHistoDef();
+    AliRsnHistoDef(Int_t n, Double_t min, Double_t max);
+    AliRsnHistoDef(Int_t nX, Double_t minX, Double_t maxX, Int_t nY, Double_t minY, Double_t maxY);
+    virtual ~AliRsnHistoDef() { }
+
+    Int_t    GetNDimensions() const {return fNDim;}
+    Int_t    GetNBins(Int_t axis=0) const {return (axis==0)?fNBins[0]:fNBins[1];}
+    Double_t GetMin(Int_t axis=0) const {return (axis==0)?fMin[0]:fMin[1];}
+    Double_t GetMax(Int_t axis=0) const {return (axis==0)?fMax[0]:fMax[1];}
+
+    void     SetBins(Int_t n, Double_t min, Double_t max);
+    void     SetBins(Int_t nX, Double_t minX, Double_t maxX, Int_t nY, Double_t minY, Double_t maxY);
+
+    TH1D*    Create1DHistogram(const char *name, const char *title);
+    TH2D*    Create2DHistogram(const char *name, const char *title);
+
+private:
+
+    void  CheckEdges();
+
+    Int_t        fNDim;       // number of dimensions
+    Int_t        fNBins[2];   // number of bins
+    Double_t     fMin[2];     // lower edge
+    Double_t     fMax[2];     // upper edge
+    
+    // ROOT dictionary
+    ClassDef(AliRsnHistoDef, 1)
+};
+
+#endif
diff --git a/PWG2/RESONANCES/AliRsnSimpleAnalysis.cxx b/PWG2/RESONANCES/AliRsnSimpleAnalysis.cxx
new file mode 100644 (file)
index 0000000..89d3feb
--- /dev/null
@@ -0,0 +1,176 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+//-------------------------------------------------------------------------
+//                     Class AliRsnSimpleAnalysis
+//-------------------------------------------------------------------------
+// This class is a manager to process one or more pair analysis with a
+// given event sample, specified as a TTree passed to this object.
+// Each single pair analysis must be defined with its specifications, like
+// histogram binning, cuts and everything else.
+// This class utiliy consists in defining a unique event sample which is
+// used for all pairs analysis, and all kinds of event mixing (if required).
+// All histograms computed in a single execution, are then saved into a file.
+// This object contains a two TObjArray's:
+//  - one to contain single event pair analysis objects (signal, like-sign)
+//  - one to contain all event-mixing pair analysis objects
+// When a new pair is added, it must be then specified in what container it
+// must be placed, in order to avoid meaningless results.
+//
+// author: A. Pulvirenti
+// email : alberto.pulvirenti@ct.infn.it
+//-------------------------------------------------------------------------
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TTree.h>
+#include <TFile.h>
+#include <TArray.h>
+#include <TClonesArray.h>
+
+#include "AliLog.h"
+#include "AliRsnPID.h"
+#include "AliRsnDaughter.h"
+#include "AliRsnEvent.h"
+#include "AliRsnEventBuffer.h"
+#include "AliRsnSimpleFunction.h"
+#include "AliRsnSimpleAnalyzer.h"
+#include "AliRsnSimpleAnalysis.h"
+
+ClassImp(AliRsnSimpleAnalysis)
+
+//_____________________________________________________________________________
+AliRsnSimpleAnalysis::AliRsnSimpleAnalysis(AliRsnSimpleAnalyzer *ana, AliRsnPID *pid) :
+  TObject(),
+  fInitialized(kFALSE),
+  fStep(1000),
+  fTree(0x0),
+  fPID(pid),
+  fAnalyzer(ana)
+{
+//
+// Constructor
+// Initializes all pointers and collections to NULL.
+//
+
+    strcpy(fFileName, "default.root");
+}
+
+
+//_____________________________________________________________________________
+void AliRsnSimpleAnalysis::Clear(Option_t* /*option*/)
+{
+//
+// Clear heap
+//
+}
+
+//_____________________________________________________________________________
+void AliRsnSimpleAnalysis::SetEventsTree(TTree *tree)
+{
+//
+// Set the tree containing the events to be processed.
+// Counts also the number of events and stores it in a private datamember.
+// This can avoid the time-wasting entries count in a long TChain.
+//
+    fTree = tree;
+    AliInfo(Form("Total number of events to be processed: %d", fTree->GetEntries()));
+}
+
+//_____________________________________________________________________________
+Bool_t AliRsnSimpleAnalysis::Initialize()
+{
+//
+// Various initialization processes
+//
+    // check process objects
+    if (!fAnalyzer) {
+        AliError("Analyzer not initialized");
+        return kFALSE;
+    }
+
+    // initialize analyzer
+    fAnalyzer->Init();
+
+    // at the end, update flag for initialization
+    fInitialized = kTRUE;
+
+    return kTRUE;
+}
+
+//_____________________________________________________________________________
+Stat_t AliRsnSimpleAnalysis::Process()
+{
+//
+// Computes all invariant mass distributions defined in the AliRsnPair objects collected.
+// Depending on the kind of background evaluation method, computes also this one.
+//
+
+    // check initialization
+    if (!fInitialized) {
+        AliError("Analysis not initialized. Use method 'Initialize()'");
+        return 0.0;
+    }
+
+    // set cursor object
+    AliRsnEvent *event = 0x0;
+    fTree->SetBranchAddress("rsnEvents", &event);
+
+    // output counter
+    Stat_t nPairs = 0.0;
+
+       // loop on events
+       Int_t i, nEvents = (Int_t)fTree->GetEntries();
+    for (i = 0; i < nEvents; i++) {
+        // message
+        if ((i % fStep) == 0) AliInfo(Form("Processing event %d", i));
+        // get entry
+        fTree->GetEntry(i);
+        if (!event) continue;
+        fPID->Process(event);
+        fAnalyzer->Process(event);
+    }
+
+    return nPairs;
+}
+
+//_____________________________________________________________________________
+void AliRsnSimpleAnalysis::SaveOutput() const
+{
+//
+// Writes histograms in current directory
+//
+    TFile *file = TFile::Open(fFileName, "RECREATE");
+    AliRsnSimpleFunction *pair = 0;
+    TH1D *h1D = 0;
+    TH2D *h2D = 0;
+    TObjArrayIter pairIterator(fAnalyzer->GetSingle());
+    while ( (pair = (AliRsnSimpleFunction*)pairIterator.Next()) ) {
+        h1D = pair->GetHistogram1D();
+        h2D = pair->GetHistogram2D();
+        if (h1D) h1D->Write();
+        if (h2D) h2D->Write();
+    }
+    if (fAnalyzer->GetMix() && !fAnalyzer->GetMix()->IsEmpty()) {
+       TObjArrayIter mixIterator(fAnalyzer->GetMix());
+        while ( (pair = (AliRsnSimpleFunction*)mixIterator.Next()) ) {
+            h1D = pair->GetHistogram1D();
+            h2D = pair->GetHistogram2D();
+            if (h1D) h1D->Write();
+            if (h2D) h2D->Write();
+        }
+       }
+       file->Close();
+}
diff --git a/PWG2/RESONANCES/AliRsnSimpleAnalysis.h b/PWG2/RESONANCES/AliRsnSimpleAnalysis.h
new file mode 100644 (file)
index 0000000..307d4e1
--- /dev/null
@@ -0,0 +1,59 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               *
+ **************************************************************************/
+
+//-------------------------------------------------------------------------
+//                      Class AliRsnSimpleAnalysis
+//             Reconstruction and analysis of K* Rsn
+// ........................................
+// ........................................
+// ........................................
+// ........................................
+//
+// author: A. Pulvirenti             (email: alberto.pulvirenti@ct.infn.it)
+//-------------------------------------------------------------------------
+
+#ifndef AliRsnSimpleAnalysis_H
+#define AliRsnSimpleAnalysis_H
+
+class TTree;
+class AliRsnPID;
+class AliRsnSimpleAnalyzer;
+
+class AliRsnSimpleAnalysis : public TObject
+{
+public:
+
+    AliRsnSimpleAnalysis(AliRsnSimpleAnalyzer *ana = 0x0, AliRsnPID *pid = 0x0);
+    virtual ~AliRsnSimpleAnalysis() {Clear();}
+    virtual void Clear(Option_t *option = "");
+
+    void    SetPID(AliRsnPID *pid) {fPID = pid;}
+    void    SetAnalyzer(AliRsnSimpleAnalyzer *analyzer) {fAnalyzer = analyzer;}
+    void    SetEventsTree(TTree *tree);
+    void    SetFileName(char *fname) {strcpy(fFileName, fname);}
+    void    SetStep(Int_t step) {fStep = step;}
+
+    Bool_t  Initialize();
+    Stat_t  Process();
+    void    SaveOutput() const;
+
+private:
+
+    AliRsnSimpleAnalysis(const AliRsnSimpleAnalysis &copy) :
+      TObject(copy),fInitialized(kFALSE),fStep(1000),fTree(0x0),fPID(0x0),fAnalyzer(0x0) { }
+    AliRsnSimpleAnalysis& operator=(const AliRsnSimpleAnalysis & /*copy*/) 
+      { return (*this); }
+
+    Bool_t                fInitialized;     // flag to check initialization
+    Int_t                 fStep;            // progress step
+    Char_t                fFileName[250];   // output file name
+    TTree                *fTree;            //! TTree of events
+    AliRsnPID            *fPID;             //! PID manager
+    AliRsnSimpleAnalyzer *fAnalyzer;        //! analyzer
+
+    ClassDef(AliRsnSimpleAnalysis,1)        // dictionary
+};
+
+#endif
diff --git a/PWG2/RESONANCES/AliRsnSimpleAnalysisTaskSE.cxx b/PWG2/RESONANCES/AliRsnSimpleAnalysisTaskSE.cxx
new file mode 100644 (file)
index 0000000..65882d2
--- /dev/null
@@ -0,0 +1,260 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+//----------------------------------------------------------------------------------
+//  Class AliRsnSimpleAnalysisTaskSE
+// ------------------------
+// Reader for conversion of ESD output into the internal format
+// used for resonance study.
+// ---
+// original author: A. Pulvirenti             (email: alberto.pulvirenti@ct.infn.it)
+// ---
+// adapted for Analysis Framework
+// by    : R. Vernet                          (email: renaud.vernet@cern.ch)
+//----------------------------------------------------------------------------------
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TChain.h>
+#include <TROOT.h>
+#include <TObjArray.h>
+
+#include "AliLog.h"
+#include "AliVEvent.h"
+#include "AliMCEventHandler.h"
+#include "AliInputEventHandler.h"
+#include "AliAnalysisManager.h"
+
+#include "AliMCEvent.h"
+
+#include "AliRsnPairDef.h"
+#include "AliRsnEvent.h"
+#include "AliRsnReader.h"
+#include "AliRsnPID.h"
+#include "AliRsnSimpleFunction.h"
+#include "AliRsnSimpleAnalyzer.h"
+#include "AliRsnSimpleAnalysisTaskSE.h"
+
+ClassImp(AliRsnSimpleAnalysisTaskSE)
+
+//_____________________________________________________________________________
+AliRsnSimpleAnalysisTaskSE::AliRsnSimpleAnalysisTaskSE() :
+  AliAnalysisTaskSE(),
+  fReader(0x0),
+  fPID(0x0),
+  fAnalyzer(0x0),
+  fRsnEvent(0x0),
+  fHistograms(0x0)
+{
+//
+// Default constructor (not recommended)
+//
+}
+
+//_____________________________________________________________________________
+AliRsnSimpleAnalysisTaskSE::AliRsnSimpleAnalysisTaskSE(const char *name) :
+  AliAnalysisTaskSE(name),
+  fReader(0x0),
+  fPID(0x0),
+  fAnalyzer(0x0),
+  fRsnEvent(0x0),
+  fHistograms(0x0)
+{
+//
+// Working constructor (recommended)
+//
+
+    DefineOutput (1, TList::Class());
+}
+
+//_____________________________________________________________________________
+void AliRsnSimpleAnalysisTaskSE::UserCreateOutputObjects()
+{
+//
+// Create the output container
+//
+
+    // check for presence of NECESSARY data-members
+    if (!fReader) {
+        AliFatal("Event reader not initialized. Impossible to continue. Aborting with fatal error.");
+        return;
+    }
+    if (!fPID) {
+        AliFatal("PID manager not initialized. Impossible to continue. Aborting with fatal error.");
+        return;
+    }
+    if (!fAnalyzer) {
+        AliFatal("Analysis manager not initialized. Impossible to continue. Aborting with fatal error.");
+        return;
+    }
+
+    // output histogram list
+    fHistograms = new TList;
+
+    // initialize analyzer
+    fAnalyzer->Init();
+
+    // store all histograms in the functions into the list
+    TObjArray *array = fAnalyzer->GetSingle();
+    AliRsnSimpleFunction *fcn;
+    TH1D *h1D;
+    TH2D *h2D;
+    if (array) {
+        TObjArrayIter iter(array);
+        while ( (fcn = (AliRsnSimpleFunction*)iter.Next()) ) {
+            h1D = fcn->GetHistogram1D();
+            h2D = fcn->GetHistogram2D();
+            if (h1D) fHistograms->AddLast(h1D);
+            if (h2D) fHistograms->AddLast(h2D);
+            
+        }
+    }
+    else {
+        AliWarning("No single-event functions in analyzer");
+    }
+    array = fAnalyzer->GetMix();
+    if (array) {
+        TObjArrayIter iter(array);
+        while ( (fcn = (AliRsnSimpleFunction*)iter.Next()) ) {
+            h1D = fcn->GetHistogram1D();
+            h2D = fcn->GetHistogram2D();
+            if (h1D) fHistograms->AddLast(h1D);
+            if (h2D) fHistograms->AddLast(h2D);
+        }
+    }
+    else {
+        AliWarning("No mixing functions in analyzer");
+    }
+}
+
+//_____________________________________________________________________________
+void AliRsnSimpleAnalysisTaskSE::UserExec(Option_t */*option*/)
+{
+//
+// Loops on input container to store data of all tracks.
+// Uses the AliRsnReader methods to save them in the output.
+//
+
+    // clear previous event
+    if (!fRsnEvent) {
+        fRsnEvent = new AliRsnEvent;
+        fRsnEvent->Init();
+    }
+    else fRsnEvent->Clear();
+
+    // read event
+    if (!fReader->Fill(fRsnEvent, fInputEvent, fMCEvent)) AliWarning("Failed reading");
+    AliInfo(Form("Collected %d tracks", fRsnEvent->GetMultiplicity()));
+    
+    // identify event if the class is available
+    if (fPID) fPID->Process(fRsnEvent);
+
+    // process event with analyzer
+    fAnalyzer->Process(fRsnEvent);
+    
+    // post histograms in slot #1
+    PostData(1, fHistograms);
+}
+
+//_____________________________________________________________________________
+Bool_t AliRsnSimpleAnalysisTaskSE::Configure(const char *configFile)
+{
+//
+// Configure this object using an external macro which creates
+// all required objects and stores them in the appropriate data members
+// Returns kFALSE if not all the required objects were created.
+//
+
+    gROOT->LoadMacro(configFile);
+    gROOT->ProcessLine("RsnConfig()");
+    
+    fReader = (AliRsnReader*)gDirectory->Get("RsnReader");
+    fPID = (AliRsnPID*)gDirectory->Get("RsnPID");
+    fAnalyzer = (AliRsnSimpleAnalyzer*)gDirectory->Get("RsnSimpleAnalyzer");
+    
+    // check for presence of NECESSARY data-members
+    if (!fReader) {
+        AliError("Event reader not initialized. Impossible to continue. Aborting with fatal error.");
+        return kFALSE;
+    }
+    if (!fPID) {
+        AliError("PID manager not initialized. Impossible to continue. Aborting with fatal error.");
+        return kFALSE;
+    }
+    if (!fAnalyzer) {
+        AliError("Analysis manager not initialized. Impossible to continue. Aborting with fatal error.");
+        return kFALSE;
+    }
+    
+    return kTRUE;
+}
+
+//_____________________________________________________________________________
+void AliRsnSimpleAnalysisTaskSE::PrintSettings()
+{
+//
+// Print analysis settings
+//
+
+    AliInfo("==== ANALYSIS TASK INFO =======================================================");
+
+    // reader
+    AliInfo(Form("Reader address, name: %x %s", fReader, fReader->GetName()));
+    switch (fReader->GetSource()) {
+        case AliRsnReader::kESD:
+            AliInfo("Reader source: kESD");
+            break;
+        case AliRsnReader::kESDTPC:
+            AliInfo("Reader source: kESDTPC");
+            break;
+        case AliRsnReader::kAOD:
+            AliInfo("Reader source: kAOD");
+            break;
+        case AliRsnReader::kMC:
+            AliInfo("Reader source: kMC");
+            break;
+        default:
+            AliInfo("Reader source not properly set");
+    }
+    AliInfo(Form("Reader->CheckSplit  = %s", (fReader->CheckSplit() ? "true" : "false")));
+    AliInfo(Form("Reader->RejectFakes = %s", (fReader->RejectFakes() ? "true" : "false")));
+    
+    // PID
+    Int_t i;
+    AliRsnPID::EType type;
+    AliInfo(Form("PID address, name: %x", fPID, fPID->GetName()));
+    for (i = 0; i < AliRsnPID::kSpecies; i++) {
+        type = (AliRsnPID::EType)i;
+        AliInfo(Form("Prior probability [%d] = %f (%s)", i, fPID->GetPriorProbability(type), AliRsnPID::ParticleName(type)));
+    }
+    AliInfo(Form("PID momentum    threshold = %f", fPID->GetMaxPt()));
+    AliInfo(Form("PID probability threshold = %f", fPID->GetMinProb()));
+    
+    // analyzer
+    AliRsnSimpleFunction *fcn;
+    AliInfo(Form("Analyzer address, name: %x", fAnalyzer, fAnalyzer->GetName()));
+    TObjArrayIter iter1(fAnalyzer->GetSingle());
+    while ( (fcn = (AliRsnSimpleFunction*)iter1.Next()) ) {
+        AliInfo(Form("Single-event function: %s [%s]", fcn->GetName(), fcn->ClassName()));
+    }
+    if (fAnalyzer->GetMix()) {
+        TObjArrayIter iter2(fAnalyzer->GetMix());
+        while ( (fcn = (AliRsnSimpleFunction*)iter2.Next()) ) {
+            AliInfo(Form("Mix function: %s [%s]", fcn->GetName(), fcn->ClassName()));
+        }
+    }
+
+    AliInfo("===============================================================================");
+}
diff --git a/PWG2/RESONANCES/AliRsnSimpleAnalysisTaskSE.h b/PWG2/RESONANCES/AliRsnSimpleAnalysisTaskSE.h
new file mode 100644 (file)
index 0000000..d1d09e1
--- /dev/null
@@ -0,0 +1,66 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               *
+ **************************************************************************/
+
+//----------------------------------------------------------------------------------
+//  Class AliRsnSimpleAnalysisTaskSE
+// ------------------------
+// Reader for conversion of ESD output into the internal format
+// used for resonance study.
+// ---
+// original author: A. Pulvirenti             (email: alberto.pulvirenti@ct.infn.it)
+// ---
+// adapted for Analysis Framework
+// by    : R. Vernet                          (email: renaud.vernet@cern.ch)
+//----------------------------------------------------------------------------------
+
+#ifndef AliRsnSimpleAnalysisTaskSE_H
+#define AliRsnSimpleAnalysisTaskSE_H
+
+#include "AliAnalysisTaskSE.h"
+
+class TList;
+class AliVEvent;
+class AliMCEvent;
+class AliRsnReader;
+class AliRsnEvent;
+class AliRsnSimpleAnalyzer;
+
+class AliRsnSimpleAnalysisTaskSE : public AliAnalysisTaskSE
+{
+public:
+
+    AliRsnSimpleAnalysisTaskSE();
+    AliRsnSimpleAnalysisTaskSE(const char *name);
+    virtual ~AliRsnSimpleAnalysisTaskSE() { }
+    
+    // Implementation of interface methods
+    virtual void UserCreateOutputObjects();
+    virtual void UserExec(Option_t *option);
+    
+    // setters
+    Bool_t Configure(const char *configFile = "RsnConfig.C");
+    void   SetReader(AliRsnReader *reader) {fReader = reader;}
+    void   SetPID(AliRsnPID *pid) {fPID = pid;}
+    void   SetAnalyzer(AliRsnSimpleAnalyzer *analyzer) {fAnalyzer = analyzer;}
+    void   PrintSettings();
+    
+private:
+
+    AliRsnSimpleAnalysisTaskSE(const AliRsnSimpleAnalysisTaskSE&) :
+      AliAnalysisTaskSE(),fReader(0x0),fPID(0x0),fAnalyzer(0x0),fRsnEvent(0x0),fHistograms(0x0)
+      { /*nothing*/ }
+    AliRsnSimpleAnalysisTaskSE& operator=(const AliRsnSimpleAnalysisTaskSE&)
+      { /*nothing*/ return (*this); }
+
+    AliRsnReader*         fReader;     // read manager
+    AliRsnPID*            fPID;        // PID manager
+    AliRsnSimpleAnalyzer* fAnalyzer;   // analyzer
+    AliRsnEvent*          fRsnEvent;   // current event pointer -> for moving among methods
+    TList*                fHistograms; // list of output histograms
+
+    ClassDef(AliRsnSimpleAnalysisTaskSE, 1); // implementation of RsnReader as ReaderTaskSE
+};
+
+#endif
diff --git a/PWG2/RESONANCES/AliRsnSimpleAnalyzer.cxx b/PWG2/RESONANCES/AliRsnSimpleAnalyzer.cxx
new file mode 100644 (file)
index 0000000..8e53fcd
--- /dev/null
@@ -0,0 +1,175 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+//=========================================================================
+// Class AliRsnSimpleAnalyzer
+//
+// Implementation of the event processing which returns histograms of
+// invariant mass for resonances and backgrounds evaluation.
+//
+// author: A. Pulvirenti             (email: alberto.pulvirenti@ct.infn.it)
+//=========================================================================
+
+#include <TTree.h>
+#include <TFile.h>
+#include <TArray.h>
+#include <TClonesArray.h>
+#include <TDirectory.h>
+
+#include "AliLog.h"
+
+#include "AliRsnDaughter.h"
+#include "AliRsnEvent.h"
+#include "AliRsnEventBuffer.h"
+#include "AliRsnSimpleFunction.h"
+
+#include "AliRsnSimpleAnalyzer.h"
+
+ClassImp(AliRsnSimpleAnalyzer)
+
+//_____________________________________________________________________________
+AliRsnSimpleAnalyzer::AliRsnSimpleAnalyzer(Int_t bufferSize) :
+  TNamed("RsnSimpleAnalyzer", ""),
+  fBufferSize(bufferSize),
+  fMixMultCut(10),
+  fMixVzCut(0.5),
+  fNMix(10),
+  fSingle(0x0),
+  fMix(0x0),
+  fBuffer(0x0)
+{
+//
+// Constructor
+// Initializes all pointers and collections to NULL.
+// Adds this object to the global Directory.
+//
+    gDirectory->Append(this, kTRUE);
+}
+
+
+//_____________________________________________________________________________
+void AliRsnSimpleAnalyzer::Clear(Option_t *option)
+{
+//
+// Clear heap
+//
+
+    fSingle->Clear(option);
+    fMix->Clear(option);
+    delete fBuffer;
+    fBuffer = 0;
+}
+
+//_____________________________________________________________________________
+void AliRsnSimpleAnalyzer::Add(AliRsnSimpleFunction *fcn)
+{
+//
+// Add a pair of particle types to be analyzed.
+// Second argument tells if the added object is for event mixing.
+//
+
+    Bool_t mixing = fcn->MixFlag();
+    TObjArray* &target = mixing ? fMix : fSingle;
+    if (!target) target = new TObjArray(0);
+    target->AddLast(fcn);
+}
+
+//_____________________________________________________________________________
+void AliRsnSimpleAnalyzer::Init()
+{
+//
+// Initialize what needs to.
+//
+
+    // buffer
+    fBuffer = new AliRsnEventBuffer(fBufferSize, kFALSE);
+
+    // histograms
+    AliRsnSimpleFunction *fcn = 0;
+    if (fSingle) {
+        TObjArrayIter iter(fSingle);
+        while ( (fcn = (AliRsnSimpleFunction*)iter.Next()) ) {
+            fcn->Init();
+        }
+    }
+    if (fMix) {
+        TObjArrayIter iter(fMix);
+        while ( (fcn = (AliRsnSimpleFunction*)iter.Next()) ) {
+            fcn->Init();
+        }
+    }
+}
+
+//_____________________________________________________________________________
+void AliRsnSimpleAnalyzer::Process(AliRsnEvent *event)
+{
+//
+// Computes all invariant mass distributions defined in the AliRsnPair objects collected.
+// Depending on the kind of background evaluation method, computes also this one.
+//
+
+    // loop over the collection of pair defs
+    ProcessEvents(fSingle, event, 0x0);
+    
+    if (fMix) {
+        // variables for mixing
+        Int_t    mult1, mult2, i, j, count = 0;
+        Double_t vz1, vz2;
+        // add this event to buffer
+        fBuffer->AddEvent(event);
+        // event mixing
+        vz1 = event->GetPrimaryVertexZ();
+        mult1 = event->GetMultiplicity();
+        if (!fBuffer->NEmptySlots()) {
+            i = fBuffer->GetEventsBufferIndex();
+            j = i+1;
+            for (;;j++) {
+                if (count >= fNMix) break;
+                if (j == fBufferSize) j = 0;
+                if (j == i) break;
+                AliRsnEvent *evmix = fBuffer->GetEvent(j);
+                if (!evmix) continue;
+                vz2 = evmix->GetPrimaryVertexZ();
+                mult2 = evmix->GetMultiplicity();
+                if (TMath::Abs(vz1 - vz2) <= fMixVzCut && TMath::Abs(mult1- mult2) <= fMixMultCut) {
+                    // loop over the collection of pair defs
+                    ProcessEvents(fMix, event, evmix);
+                    ProcessEvents(fMix, evmix, event);
+                    count++;
+                }
+            }
+        }
+    }
+}
+
+//_____________________________________________________________________________
+void AliRsnSimpleAnalyzer::ProcessEvents
+(TObjArray *array, AliRsnEvent *event1, AliRsnEvent *event2)
+{
+//
+// Takes all AliRsnSimpleFunction objects in the passed array
+// and processes the given pair of AliRsnEvents with all of them
+// If the array is NULL nothing is done
+//
+
+    if (!array) return;
+
+    AliRsnSimpleFunction *fcn = 0;
+    TObjArrayIter iter(array);
+    while ( (fcn = (AliRsnSimpleFunction*)iter.Next()) ) {
+        if (event2) fcn->ProcessTwo(event1, event2);
+        else fcn->ProcessOne(event1);
+    }
+}
diff --git a/PWG2/RESONANCES/AliRsnSimpleAnalyzer.h b/PWG2/RESONANCES/AliRsnSimpleAnalyzer.h
new file mode 100644 (file)
index 0000000..764d27e
--- /dev/null
@@ -0,0 +1,69 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               *
+ **************************************************************************/
+
+//=========================================================================
+// Class AliRsnSimpleAnalyzer
+//
+// Implementation of the event processing which returns histograms of
+// invariant mass for resonances and backgrounds evaluation.
+//
+// author: A. Pulvirenti             (email: alberto.pulvirenti@ct.infn.it)
+//=========================================================================
+
+#ifndef AliRsnSimpleAnalyzer_H
+#define AliRsnSimpleAnalyzer_H
+
+#include <TNamed.h>
+
+class TObjArray;
+class AliRsnSimpleFunction;
+class AliRsnEventBuffer;
+
+class AliRsnSimpleAnalyzer : public TNamed
+{
+public:
+
+    AliRsnSimpleAnalyzer(Int_t bufferSize = 1000);
+    virtual ~AliRsnSimpleAnalyzer() {Clear();}
+
+    // setters
+    void    SetBufferSize(Int_t value) {fBufferSize = value;}
+    void    SetMixMultiplicityCut(Int_t cut) {fMixMultCut = cut;}
+    void    SetMixVzCut(Double_t cut) {fMixVzCut = cut;}
+    void    SetNMix(Int_t value) {fNMix = value;}
+
+    // getters
+    TObjArray*   GetSingle() {return fSingle;}
+    TObjArray*   GetMix()    {return fMix;}
+
+    // working routines
+    void         Init();
+    virtual void Clear(Option_t *option = "C");
+    void         Add(AliRsnSimpleFunction *pair);
+    void         Process(AliRsnEvent *event);
+
+private:
+
+    AliRsnSimpleAnalyzer(const AliRsnSimpleAnalyzer &copy) :
+      TNamed(copy),fBufferSize(1000),
+      fMixMultCut(10),fMixVzCut(0.5),fNMix(10),
+      fSingle(0x0),fMix(0x0),fBuffer(0x0) { }
+    AliRsnSimpleAnalyzer& operator=(const AliRsnSimpleAnalyzer & /*copy*/) { return (*this); }
+    void ProcessEvents(TObjArray *pairs, AliRsnEvent *event1, AliRsnEvent *event2 = 0x0);
+
+    Int_t              fBufferSize;  // size of buffer
+    Int_t              fMixMultCut;  // multiplicity cut for event mixing
+    Double_t           fMixVzCut;    // difference in VZ cut for event mixing
+    Int_t              fNMix;        // number of events for mixing
+
+    TObjArray         *fSingle;      // collection of particle pairs to be read for 1-event analysis
+    TObjArray         *fMix;         // collection of particle pairs to be read for event-mixing
+    AliRsnEventBuffer *fBuffer;      // buffer for event mixing
+
+    // Rsn analyzer implementation
+    ClassDef(AliRsnSimpleAnalyzer,1)
+};
+
+#endif
diff --git a/PWG2/RESONANCES/AliRsnSimpleFcnInvMass.cxx b/PWG2/RESONANCES/AliRsnSimpleFcnInvMass.cxx
new file mode 100644 (file)
index 0000000..a2f554e
--- /dev/null
@@ -0,0 +1,213 @@
+//
+// Class AliRsnSimpleFcnInvMass
+//
+// This is the most fundamental AliRsnSimpleFunction,
+// which computes the invariant mass spectrum of a resonance,
+// by correlating pairs of tracks from an event (or mixing, for BG)
+//
+
+#include <TH1.h>
+#include <TArrayI.h>
+
+#include "AliLog.h"
+
+#include "AliRsnDaughter.h"
+#include "AliRsnEvent.h"
+#include "AliRsnSimpleFcnInvMass.h"
+
+ClassImp(AliRsnSimpleFcnInvMass)
+
+//________________________________________________________________________________________
+AliRsnSimpleFcnInvMass::AliRsnSimpleFcnInvMass() :
+  AliRsnSimpleFunction(),
+  fUseMCValues(kFALSE),
+  fPIDMethod(AliRsnDaughter::kNoPID)
+{
+//
+// Constructor.
+// Only default initializations.
+//
+}
+
+//________________________________________________________________________________________
+AliRsnSimpleFcnInvMass::AliRsnSimpleFcnInvMass
+(const char *name, AliRsnDaughter::EPIDMethod method, AliRsnPairDef *pd,
+ AliRsnHistoDef *hd, AliRsnCutMgr *cuts, Option_t *option) :
+  AliRsnSimpleFunction(name, pd, hd, cuts, option),
+  fUseMCValues(kFALSE),
+  fPIDMethod(method)
+{
+//
+// Constructor.
+// Only default initializations.
+//
+}
+
+//________________________________________________________________________________________
+Bool_t AliRsnSimpleFcnInvMass::ProcessOne(AliRsnEvent* event)
+{
+//
+// Process a single event to build the invariant mass histogram
+// from the correlation of track pairs, according to the AliRsnPairDef settings.
+// The collection of used tracks depends on the PID method chosen.
+//
+
+    if (!event) {
+        AliError("Argument cannot be NULL.");
+        return kFALSE;
+    }
+    
+    // check PID method
+    if (fPIDMethod < AliRsnDaughter::kNoPID || fPIDMethod >= AliRsnDaughter::kMethods) {
+        AliError("PID method not properly initialized");
+        return kFALSE;
+    }
+    
+    // check event cut
+    if (!CutPass(event)) return kFALSE;
+
+    // assign pointers to the list of indexes to be used
+    TArrayI *listCharged1 = 0x0, *listCharged2 = 0x0;
+    if (fPIDMethod == AliRsnDaughter::kNoPID || fPIDMethod == AliRsnDaughter::kWeighted) {
+        listCharged1 = event->GetCharged(fPairDef->GetCharge(0));
+        listCharged2 = event->GetCharged(fPairDef->GetCharge(1));
+    }
+    else {
+        listCharged1 = event->GetTracksArray(fPIDMethod, fPairDef->GetCharge(0), fPairDef->GetType(0));
+        listCharged2 = event->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), fPairDef->GetType(1));
+    }
+    if (!listCharged1 || !listCharged2) return 0.0;
+    TArrayI &list1 = *listCharged1;
+    TArrayI &list2 = *listCharged2;
+
+    Stat_t count = 0;
+    Int_t i1, i2, start2;
+    AliRsnDaughter *track1 = 0x0, *track2 = 0x0;
+
+    // loop on particle of type 1
+    for (i1 = 0; i1 < list1.GetSize(); i1++) {
+        track1 = event->GetTrack(list1[i1]);
+        if (!CutPass(track1)) continue;
+        // loop on particle of type 2
+        // in case we are building a like-sign histogram with particles
+        // of the same type, we must avoid that each pair is used twice
+        start2 = 0;
+        if (listCharged1 == listCharged2) start2 = i1 + 1;
+        for (i2 = start2; i2 < list2.GetSize(); i2++) {
+            track2 = event->GetTrack(list2[i2]);
+            if (!CutPass(track2)) continue;
+            if (Add(track1, track2)) count++;
+        }
+    }
+
+    return (count > (Stat_t)0);
+}
+
+//________________________________________________________________________________________
+Bool_t AliRsnSimpleFcnInvMass::ProcessTwo
+(AliRsnEvent* event1, AliRsnEvent* event2)
+{
+//
+// Process a single event to build the invariant mass histogram
+// from the correlation of track pairs, according to the AliRsnPairDef settings.
+// The collection of used tracks depends on the PID method chosen.
+//
+
+    if (!event1 || !event2) {
+        AliError("Arguments cannot be NULL.");
+        return kFALSE;
+    }
+    
+    // check event cut
+    if (!CutPass(event1)) return kFALSE;
+    if (!CutPass(event2)) return kFALSE;
+
+    // assign pointers to the list of indexes to be used
+    TArrayI *listCharged1 = 0x0, *listCharged2 = 0x0;
+    if (fPIDMethod == AliRsnDaughter::kNoPID || fPIDMethod == AliRsnDaughter::kWeighted) {
+        listCharged1 = event1->GetCharged(fPairDef->GetCharge(0));
+        listCharged2 = event2->GetCharged(fPairDef->GetCharge(1));
+    }
+    else {
+        listCharged1 = event1->GetTracksArray(fPIDMethod, fPairDef->GetCharge(0), fPairDef->GetType(0));
+        listCharged2 = event2->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), fPairDef->GetType(1));
+    }
+    if (!listCharged1 || !listCharged2) return 0.0;
+    TArrayI &list1 = *listCharged1;
+    TArrayI &list2 = *listCharged2;
+
+    Stat_t count = 0;
+    Int_t i1, i2;
+    AliRsnDaughter *track1 = 0x0, *track2 = 0x0;
+
+    // loop on particle of type 1
+    for (i1 = 0; i1 < list1.GetSize(); i1++) {
+        track1 = event1->GetTrack(list1[i1]);
+        if (!CutPass(track1)) continue;
+        // loop on particle of type 2
+        for (i2 = 0; i2 < list2.GetSize(); i2++) {
+            track2 = event2->GetTrack(list2[i2]);
+            if (!CutPass(track2)) continue;
+            if (Add(track1, track2)) count++;
+        }
+    }
+
+    return (count > (Stat_t)0);
+}
+
+//________________________________________________________________________________________
+Bool_t AliRsnSimpleFcnInvMass::Add
+(AliRsnDaughter *track1, AliRsnDaughter *track2)
+{
+//
+// Add a histogram entry from two tracks, if they pass the cuts.
+// The order matters, because track1 is processed using first element
+// in the AliRsnPairDef definition, and track2 is processed using second ones.
+// In case the study is done only for true pairs, this is checked automatically.
+//
+
+    // set the static variable pointing to PID method
+    // to the current one in use by this object
+    AliRsnDaughter::SetPIDMethod(fPIDMethod);
+
+    // setup pair and check pair cuts
+    fPair.SetPair(track1, track2);
+    if (!CutPass(&fPair)) return kFALSE;
+
+    // computation variables
+    Double_t mass1[2] = {fPairDef->GetMass(0), fPairDef->GetMass(1)};
+    Double_t mass2[2] = {fPairDef->GetMass(1), fPairDef->GetMass(0)};
+    
+    // define the value of the entry weight according to PID method selected:
+    // - in case of "weighted" computations, which is done with all tracks
+    //   using the PID computed probabilities, the weight will be the product
+    //   of the ones related to the used PID for the tracks
+    Bool_t   useWeight = kFALSE;
+    Double_t entryWeight[2];
+    entryWeight[0] = fPairDef->ComputeWeight(track1, track2);
+    entryWeight[1] = fPairDef->ComputeWeight(track2, track1);
+    if (fPIDMethod != AliRsnDaughter::kWeighted) {
+        useWeight = kTRUE;
+        entryWeight[0] = 1.0;
+        entryWeight[0] = 1.0;
+    }
+    
+    // when filling the histogram, if the defined pair is a like-sign one,
+    // and if the two PID involved are different, it is necessary
+    // to fill it twice, exchanging the tracks with respect to pair definition
+    // in all other cases (unlike sign, like sign with same PID) this is not done
+    Int_t i, lastAdd = 0;
+    if (fPairDef->IsLikeSign() && !fPairDef->HasEqualTypes()) lastAdd = 1;
+    
+    // make computation
+    Double_t invmass;
+    for (i = 0; i <= lastAdd; i++) {
+        if (fUseMCValues) invmass = fPair.GetInvMassMC(mass1[i], mass2[i]);
+        else invmass = fPair.GetInvMass(mass1[i], mass2[i]);
+        
+        if (useWeight) fHisto1D->Fill(invmass, entryWeight[i]);
+        else fHisto1D->Fill(invmass);
+    }
+
+    return kTRUE;
+}
diff --git a/PWG2/RESONANCES/AliRsnSimpleFcnInvMass.h b/PWG2/RESONANCES/AliRsnSimpleFcnInvMass.h
new file mode 100644 (file)
index 0000000..3d355ab
--- /dev/null
@@ -0,0 +1,49 @@
+//
+// Class AliRsnSimpleFcnInvMass
+//
+// This is the most fundamental AliRsnSimpleFunction,
+// which computes the invariant mass spectrum of a resonance,
+// by correlating pairs of tracks from an event (or mixing, for BG)
+//
+
+#ifndef AliRsnSimpleFcnInvMass_H
+#define AliRsnSimpleFcnInvMass_H
+
+#include "AliRsnDaughter.h"
+#include "AliRsnSimpleFunction.h"
+
+class AliRsnSimpleFcnInvMass : public AliRsnSimpleFunction
+{
+public:
+
+    AliRsnSimpleFcnInvMass();
+    AliRsnSimpleFcnInvMass
+      (const char* name, AliRsnDaughter::EPIDMethod method, AliRsnPairDef *pd, 
+       AliRsnHistoDef *hd, AliRsnCutMgr *cuts=0, Option_t *option="");
+
+    void               SetUseMCValues(Bool_t value) {fUseMCValues = value;}
+    Bool_t             UseMCValues() {return fUseMCValues;}
+
+    // virtual working routines
+    virtual Bool_t ProcessOne(AliRsnEvent *event);
+    virtual Bool_t ProcessTwo(AliRsnEvent *event1, AliRsnEvent *event2);
+
+private:
+
+    // dummy required methods
+    AliRsnSimpleFcnInvMass(const AliRsnSimpleFcnInvMass &copy) :
+      AliRsnSimpleFunction(copy),fUseMCValues(kFALSE),fPIDMethod(AliRsnDaughter::kNoPID)
+      { /*nothing */ }
+    AliRsnSimpleFcnInvMass& operator=(const AliRsnSimpleFcnInvMass& /*copy*/)
+      { /* nothing */ return (*this); }
+
+    // utility methods
+    Bool_t Add(AliRsnDaughter *t1, AliRsnDaughter *t2);
+
+    Bool_t                     fUseMCValues;  // flag to switch between MC/rec values
+    AliRsnDaughter::EPIDMethod fPIDMethod;    // flag to PID method used
+
+    ClassDef(AliRsnSimpleFcnInvMass, 1); // dictionary
+};
+
+#endif
diff --git a/PWG2/RESONANCES/AliRsnSimpleFcnResolution.cxx b/PWG2/RESONANCES/AliRsnSimpleFcnResolution.cxx
new file mode 100644 (file)
index 0000000..a1e0b0f
--- /dev/null
@@ -0,0 +1,124 @@
+//
+// Class AliRsnSimpleFcnResolution
+//
+// This is the most fundamental AliRsnSimpleFunction,
+// which computes the invariant mass spectrum of a resonance,
+// by correlating pairs of tracks from an event (or mixing, for BG)
+//
+
+#include <TH1.h>
+
+#include "AliLog.h"
+
+#include "AliRsnDaughter.h"
+#include "AliRsnEvent.h"
+#include "AliRsnPID.h"
+#include "AliRsnSimpleFcnResolution.h"
+
+ClassImp(AliRsnSimpleFcnResolution)
+
+//________________________________________________________________________________________
+AliRsnSimpleFcnResolution::AliRsnSimpleFcnResolution() :
+  AliRsnSimpleFunction()
+{
+//
+// Constructor.
+// Only default initializations.
+//
+
+    fTrueFlag = kTRUE;
+    fMixFlag = kFALSE;
+}
+
+//________________________________________________________________________________________
+AliRsnSimpleFcnResolution::AliRsnSimpleFcnResolution
+(const char *name, AliRsnPairDef *pd, 
+ AliRsnHistoDef *hd, AliRsnCutMgr *cuts, Option_t *option) :
+  AliRsnSimpleFunction(name, pd, hd, cuts, option)
+{
+//
+// Constructor.
+// Only default initializations.
+//
+
+    fTrueFlag = kTRUE;
+    fMixFlag = kFALSE;
+}
+
+//________________________________________________________________________________________
+Bool_t AliRsnSimpleFcnResolution::ProcessOne(AliRsnEvent* event)
+{
+//
+// Process a single event to build the invariant mass resolution histogram
+// from the correlation of track pairs, according to the AliRsnPairDef settings.
+// This class uses always the perfect PID.
+//
+
+    if (!event) {
+        AliError("Argument cannot be NULL.");
+        return kFALSE;
+    }
+    
+    // check event cut
+    if (!CutPass(event)) return kFALSE;
+
+    // assign pointers to the list of indexes to be used
+    AliRsnDaughter::EPIDMethod mtd = AliRsnDaughter::kPerfect;
+    TArrayI *plist1 = event->GetTracksArray(mtd, fPairDef->GetCharge(0), fPairDef->GetType(0));
+    TArrayI *plist2 = event->GetTracksArray(mtd, fPairDef->GetCharge(1), fPairDef->GetType(1));
+    if (!plist1 || !plist2) return 0.0;
+    TArrayI &list1 = *plist1;
+    TArrayI &list2 = *plist2;
+
+    Stat_t count = 0;
+    Int_t i1, i2, start2;
+    AliRsnDaughter *track1 = 0x0, *track2 = 0x0;
+
+    // loop on particle of type 1
+    for (i1 = 0; i1 < list1.GetSize(); i1++) {
+        track1 = event->GetTrack(list1[i1]);
+        if (!CutPass(track1)) continue;
+        // loop on particle of type 2
+        // in case we are building a like-sign histogram with particles
+        // of the same type, we must avoid that each pair is used twice
+        start2 = 0;
+        if (plist1 == plist2) start2 = i1 + 1;
+        for (i2 = start2; i2 < list2.GetSize(); i2++) {
+            track2 = event->GetTrack(list2[i2]);
+            if (!CutPass(track2)) continue;
+            if (Add(track1, track2)) count++;
+        }
+    }
+
+    return (count > (Stat_t)0);
+}
+
+//________________________________________________________________________________________
+Bool_t AliRsnSimpleFcnResolution::Add
+(AliRsnDaughter *track1, AliRsnDaughter *track2)
+{
+//
+// Add a histogram entry from two tracks, if they pass the cuts.
+// The order matters, because track1 is processed using first element
+// in the AliRsnPairDef definition, and track2 is processed using second ones.
+// In case the study is done only for true pairs, this is checked automatically.
+//
+
+    // setup pair and check pair cuts
+    fPair.SetPair(track1, track2);
+    if (!CutPass(&fPair)) return kFALSE;
+
+    // computation variables
+    Double_t mass1 = fPairDef->GetMass(0);
+    Double_t mass2 = fPairDef->GetMass(1);
+    
+    // make computation
+    Double_t invmass = fPair.GetInvMass(mass1, mass2);
+    Double_t invmassMC = fPair.GetInvMassMC(mass1, mass2);
+    Double_t res = (invmassMC - invmass) / invmassMC;
+    
+    // fill
+    fHisto1D->Fill(res);
+
+    return kTRUE;
+}
diff --git a/PWG2/RESONANCES/AliRsnSimpleFcnResolution.h b/PWG2/RESONANCES/AliRsnSimpleFcnResolution.h
new file mode 100644 (file)
index 0000000..d326356
--- /dev/null
@@ -0,0 +1,40 @@
+//
+// Class AliRsnSimpleFcnResolution
+//
+// This is the most fundamental AliRsnSimpleFunction,
+// which computes the invariant mass spectrum of a resonance,
+// by correlating pairs of tracks from an event (or mixing, for BG)
+//
+
+#ifndef AliRsnSimpleFcnResolution_H
+#define AliRsnSimpleFcnResolution_H
+
+#include "AliRsnSimpleFunction.h"
+
+class AliRsnSimpleFcnResolution : public AliRsnSimpleFunction
+{
+public:
+
+    AliRsnSimpleFcnResolution();
+    AliRsnSimpleFcnResolution
+      (const char* name, AliRsnPairDef *pd,
+       AliRsnHistoDef *hd, AliRsnCutMgr *cuts=0, Option_t *option="");
+
+    // virtual working routines
+    virtual Bool_t ProcessOne(AliRsnEvent *event);
+
+private:
+
+    // dummy required methods
+    AliRsnSimpleFcnResolution(const AliRsnSimpleFcnResolution &copy) :
+      AliRsnSimpleFunction(copy) { /*nothing */ }
+    AliRsnSimpleFcnResolution& operator=(const AliRsnSimpleFcnResolution& /*copy*/)
+      { /* nothing */ return (*this); }
+      
+    // utility methods
+    Bool_t Add(AliRsnDaughter *t1, AliRsnDaughter *t2);
+
+    ClassDef(AliRsnSimpleFcnResolution, 1); // dictionary
+};
+
+#endif
diff --git a/PWG2/RESONANCES/AliRsnSimpleFunction.cxx b/PWG2/RESONANCES/AliRsnSimpleFunction.cxx
new file mode 100644 (file)
index 0000000..ce746c8
--- /dev/null
@@ -0,0 +1,224 @@
+//
+// Class AliRsnSimpleFcn
+//
+// This class defines a base classe to implement a typical computation
+// which uses the internal RSN package event format (AliRsnEvent).
+// It contains some default flags which turn out to be useful:
+//  - a flag to select only the "true" pairs (tracks from same resonance)
+//  - a flag to know if the computation is done over two events (mixing)
+//
+// Any kind of analysis object should be implemented as inheriting from this
+// because the AliRsnAnalyzer which executes the analysis will accept a collection
+// of such objects, in order to have a unique format of processing method
+//
+// The user who implements a kind of computation type should inherit from 
+// this class and override the virtual functions defined in it, which 
+// initialize the final output histogram and define how to process data.
+//
+//
+// author: A. Pulvirenti             (email: alberto.pulvirenti@ct.infn.it)
+//
+
+#include <Riostream.h>
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TString.h>
+
+#include "AliLog.h"
+
+#include "AliRsnMCInfo.h"
+#include "AliRsnDaughter.h"
+#include "AliRsnEvent.h"
+#include "AliRsnCut.h"
+
+#include "AliRsnSimpleFunction.h"
+
+ClassImp(AliRsnSimpleFunction)
+
+//________________________________________________________________________________________
+AliRsnSimpleFunction::AliRsnSimpleFunction
+(const char *name, AliRsnPairDef *pd, AliRsnHistoDef *hd,
+ AliRsnCutMgr *cuts, Option_t *option) :
+  TNamed(name, ""),
+  fTrueFlag(kFALSE),
+  fMixFlag(kFALSE),
+  fPair(),
+  fPairDef(pd),
+  fHistoDef(hd),
+  fCuts(cuts),
+  fHisto1D(0x0),
+  fHisto2D(0x0)
+{
+//
+// Constructor.
+// The histogram data member cannot be passed externally,
+// its initialization MUST be defined inside the Init() method,
+// which must be overridden in any derivate implementation.
+// Last argument (option) allows to set in a user-friedly way the flags:
+// - TRUE (for true pairs)
+// - MIX (for mixing pairs)
+//
+
+    TString opt(option);
+    opt.ToUpper();
+    fTrueFlag = opt.Contains("TRUE");
+    fMixFlag = opt.Contains("MIX");
+}
+//________________________________________________________________________________________
+AliRsnSimpleFunction::AliRsnSimpleFunction(const AliRsnSimpleFunction &copy) :
+  TNamed(copy),
+  fTrueFlag(copy.fTrueFlag),
+  fMixFlag(copy.fMixFlag),
+  fPair(),
+  fPairDef(copy.fPairDef),
+  fHistoDef(copy.fHistoDef),
+  fCuts(copy.fCuts),
+  fHisto1D(0x0),
+  fHisto2D(0x0)
+{
+//
+// Copy constructor.
+// Pointer data members are not cloned.
+// The histogram is not copied, because it is always initialized
+// by the Init() method.
+//
+}
+//________________________________________________________________________________________
+const AliRsnSimpleFunction& AliRsnSimpleFunction::operator=
+(const AliRsnSimpleFunction &copy)
+{
+//
+// Assignment operator.
+// Behaves like copy constructor.
+// Also in this case, the histogram is not copied, and,
+// if it was present, it is destroyed and will need to be recreated.
+//
+
+    Clear();
+    SetName(copy.GetName());
+
+    fTrueFlag = copy.fTrueFlag;
+    fMixFlag = copy.fMixFlag;
+    
+    fPairDef = copy.fPairDef;
+    fHistoDef = copy.fHistoDef;
+    fCuts = copy.fCuts;
+
+    return (*this);
+}
+//________________________________________________________________________________________
+void AliRsnSimpleFunction::Clear(Option_t* /*option*/)
+{
+//
+// Clear arrays and histogram.
+// For the sake of security, all pointers are also set explicitly to NULL.
+//
+    if (fHisto1D) delete fHisto1D;
+    fHisto1D = 0x0;
+    if (fHisto2D) delete fHisto2D;
+    fHisto2D = 0x0;
+}
+
+//________________________________________________________________________________________
+Bool_t AliRsnSimpleFunction::Init()
+{
+//
+// Initialization function.
+// By default, it initializes the owned histogram using the method
+// from AliRsnHistoDef class, giving the same name and title of this.
+// A user can override this behaviour, if necessary.
+// Before creating, the HistoDef is checked for proper initialization.
+//
+
+    Clear();
+
+    Char_t name[200];
+    sprintf(name, "h_%s", GetName());
+
+    switch (fHistoDef->GetNDimensions()) {
+        case 1:
+            fHisto1D = (TH1D*)fHistoDef->Create1DHistogram(name, "");
+            return kTRUE;
+        case 2:
+            fHisto2D = (TH2D*)fHistoDef->Create1DHistogram(name, "");
+            return kTRUE;
+        default:
+            AliError("Number of dimensions not properly set.");
+            return kFALSE;
+    }
+}
+
+//________________________________________________________________________________________
+Bool_t AliRsnSimpleFunction::ProcessOne(AliRsnEvent* /*event*/)
+{
+//
+// Process a single event according to the purposes of the derived class.
+// Here the user must put the code which defines how the internal histogram is filled.
+// The boolean return value allows to catch a failure in execution.
+//
+
+    AliWarning("This method must be defined in the derived class");
+    return kFALSE;
+}
+
+//________________________________________________________________________________________
+Bool_t AliRsnSimpleFunction::ProcessTwo(AliRsnEvent* /*event1*/, AliRsnEvent* /*event2*/)
+{
+//
+// Process two events according to relations between them.
+// This method must be defined whenever the derived object is used in event mixing.
+// The boolean return value allows to catch a failure in execution.
+//
+
+    AliWarning("This method must be defined in the derived class");
+    return kFALSE;
+}
+
+//________________________________________________________________________________________
+Bool_t AliRsnSimpleFunction::CutPass(AliRsnDaughter *d)
+{
+//
+// Check if the AliRsnDaughter argument pass its cuts.
+// If the cut data member is not initialized for it, returns kTRUE.
+//
+    if (!fCuts) return kTRUE;
+    else return fCuts->IsSelected(AliRsnCut::kParticle, d);
+}
+
+//________________________________________________________________________________________
+Bool_t AliRsnSimpleFunction::CutPass(AliRsnPairParticle *p)
+{
+//
+// Check if the AliRsnPairParticle argument pass its cuts.
+// If the cut data member is not initialized for it, returns kTRUE.
+// In this case, another separate check which could be necessary
+// concerns the possibility that the two tracks are a "true pair" of 
+// daughters of the same resonance. If the corresponding flag is set,
+// this further check is done, and the method returns kTRUE only 
+// when also this check is passed.
+//
+
+    Bool_t cutPassed, truePair;
+    
+    cutPassed = fCuts->IsSelected(AliRsnCut::kPair, p);
+    truePair = fPair.IsTruePair(fPairDef->GetMotherPDG());
+    
+    if (fTrueFlag) {
+        return (cutPassed && truePair);
+    }
+    else {
+        return cutPassed;
+    }
+}
+
+//________________________________________________________________________________________
+Bool_t AliRsnSimpleFunction::CutPass(AliRsnEvent *e)
+{
+//
+// Check if the AliRsnEvent argument pass its cuts.
+// If the cut data member is not initialized for it, returns kTRUE.
+//
+    if (!fCuts) return kTRUE;
+    else return fCuts->IsSelected(AliRsnCut::kEvent, e);
+}
diff --git a/PWG2/RESONANCES/AliRsnSimpleFunction.h b/PWG2/RESONANCES/AliRsnSimpleFunction.h
new file mode 100644 (file)
index 0000000..4a2d37e
--- /dev/null
@@ -0,0 +1,91 @@
+//
+// Class AliRsnSimpleFcn
+//
+// This class defines a base classe to implement a typical computation
+// which uses the internal RSN package event format (AliRsnEvent).
+// It contains some default flags which turn out to be useful:
+//  - a flag to select only the "true" pairs (tracks from same resonance)
+//  - a flag to know if the computation is done over two events (mixing)
+//
+// Any kind of analysis object should be implemented as inheriting from this
+// because the AliRsnAnalyzer which executes the analysis will accept a collection
+// of such objects, in order to have a unique format of processing method
+//
+// The user who implements a kind of computation type should inherit from 
+// this class and override the virtual functions defined in it, which 
+// initialize the final output histogram and define how to process data.
+//
+//
+// author: A. Pulvirenti             (email: alberto.pulvirenti@ct.infn.it)
+//
+
+#ifndef ALIRSNSIMPLEFCN_H
+#define ALIRSNSIMPLEFCN_H
+
+#include <TNamed.h>
+
+#include "AliRsnCutMgr.h"
+#include "AliRsnPairDef.h"
+#include "AliRsnHistoDef.h"
+#include "AliRsnPairParticle.h"
+
+class TH1D;
+class TH2D;
+class AliRsnEvent;
+
+class AliRsnSimpleFunction : public TNamed
+{
+
+public:
+
+    AliRsnSimpleFunction
+      (const char *name="", 
+       AliRsnPairDef *pd=0, AliRsnHistoDef *hd=0, AliRsnCutMgr *cuts=0, 
+       Option_t *option="");
+    AliRsnSimpleFunction(const AliRsnSimpleFunction &copy);
+    const AliRsnSimpleFunction& operator=(const AliRsnSimpleFunction &copy);
+    virtual ~AliRsnSimpleFunction() {Clear();}
+    virtual void Clear(Option_t *option = "");
+
+    Bool_t              TrueFlag() {return fTrueFlag;}
+    Bool_t              MixFlag() {return fMixFlag;}
+    AliRsnPairParticle* GetPair() {return &fPair;}
+    AliRsnPairDef*      GetPairDef() {return fPairDef;}
+    AliRsnHistoDef*     GetHistoDef() {return fHistoDef;}
+    AliRsnCutMgr*       GetCutMgr() {return fCuts;}
+    TH1D*               GetHistogram1D() {return fHisto1D;}
+    TH2D*               GetHistogram2D() {return fHisto2D;}
+
+    void   SetTrueFlag(Bool_t value = kTRUE) {fTrueFlag = value;}
+    void   SetMixFlag(Bool_t value = kTRUE) {fMixFlag = value;}
+    void   SetPairDef(AliRsnPairDef *def) {fPairDef = def;}
+    void   SetHistoDef(AliRsnHistoDef *def) {fHistoDef = def;}
+    void   SetCutMgr(AliRsnCutMgr *cutMgr) {fCuts = cutMgr;}
+
+    // virtual working routines
+    virtual Bool_t Init();
+    virtual Bool_t ProcessOne(AliRsnEvent *event);
+    virtual Bool_t ProcessTwo(AliRsnEvent *event1, AliRsnEvent *event2);
+
+protected:
+
+    Bool_t CutPass(AliRsnDaughter *d);
+    Bool_t CutPass(AliRsnPairParticle *p);
+    Bool_t CutPass(AliRsnEvent *e);
+
+    Bool_t               fTrueFlag;      // flag to store only true pairs
+    Bool_t               fMixFlag;       // flag to reserve this object for mixing
+
+    AliRsnPairParticle   fPair;          // utility class for pair
+    AliRsnPairDef       *fPairDef;       // definitions for pair
+    AliRsnHistoDef      *fHistoDef;      // definitions for histogram
+    AliRsnCutMgr        *fCuts;          // cut manager
+    
+    TH1D                *fHisto1D;       // output histogram (1D)
+    TH2D                *fHisto2D;       // output histogram (2D)
+
+    // ROOT dictionary
+    ClassDef(AliRsnSimpleFunction, 1)
+};
+
+#endif