]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnPairFunctions.cxx
Fixed bug in AliRsnPair::Fill()
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnPairFunctions.cxx
CommitLineData
2dab9030 1//
2// *** Class AliRsnPairFunctions ***
3//
4// "Core" method for defining the work on a pari of particles.
5// For one analysis, one must setup one of this for each pair he wants to analyze,
6// adding to it all analysis which he desires to do.
7// Here he defines the cuts, and the particle types and charges, and can add
8// functions which do different operations on the same pair, and some binning
9// with respect to some kinematic variables (eta, momentum)
10//
11// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
12// M. Vala (email: martin.vala@cern.ch)
13//
14
15#include <TList.h>
16
17#include "AliLog.h"
18
19#include "AliRsnMother.h"
20#include "AliRsnEvent.h"
21#include "AliRsnFunction.h"
22#include "AliRsnCutSet.h"
2dab9030 23#include "AliRsnValue.h"
24
25#include "AliRsnPairFunctions.h"
26
27ClassImp(AliRsnPairFunctions)
28
29//_____________________________________________________________________________
30AliRsnPairFunctions::AliRsnPairFunctions(const char *name, AliRsnPairDef *def) :
2a1c7696 31 AliRsnPair(name, def),
32 fFunctions("AliRsnFunction", 0)
2dab9030 33{
34//
35// Default constructor
36//
2dab9030 37}
38
39//_____________________________________________________________________________
40AliRsnPairFunctions::AliRsnPairFunctions(const AliRsnPairFunctions& copy) :
2a1c7696 41 AliRsnPair(copy),
42 fFunctions(copy.fFunctions)
2dab9030 43{
44//
45// Default constructor
46//
2dab9030 47}
48
49//_____________________________________________________________________________
50AliRsnPairFunctions& AliRsnPairFunctions::operator=(const AliRsnPairFunctions& copy)
51{
2a1c7696 52 AliRsnPair::operator=(copy);
2dab9030 53
2a1c7696 54 Int_t i, n = copy.fFunctions.GetEntries();
55 for (i = 0; i < n; i++) {
56 AliRsnFunction *fcn = (AliRsnFunction*)copy.fFunctions[i];
57 if (fcn) AddFunction(fcn);
58 }
2dab9030 59
2a1c7696 60 return (*this);
2dab9030 61}
62
63//_____________________________________________________________________________
64AliRsnPairFunctions::~AliRsnPairFunctions()
65{
66//
67// Destructor
68//
2dab9030 69}
70
71//_____________________________________________________________________________
72void AliRsnPairFunctions::Compute()
73{
74//
75// Makes computations using the two passed daughter objects.
76// Checks all cuts and then computes the corresponding pair object
77// and then fill the list of required values using it.
78//
2a1c7696 79
2a1c7696 80 TObjArrayIter nextFcn(&fFunctions);
81 AliRsnFunction *fcn = 0x0;
82
83 while ((fcn = (AliRsnFunction*)nextFcn())) {
84 fcn->SetPairDef(fPairDef);
85 fcn->SetPair(&fMother);
86 fcn->Fill();
87 }
2dab9030 88}
89
90//_____________________________________________________________________________
91void AliRsnPairFunctions::Init(const char *prefix, TList *list)
92{
93//
94// Generates needed histograms, giving them a name based on
95// the flags defined here, on the pair definition, and attaches
96// a prefix to it, according to the argument.
97//
98// All generated histograms are stored into the output TList.
99//
100
2a1c7696 101 Int_t i;
102 TString hName("");
103 AliRsnFunction *fcn = 0;
104 for (i = 0; i < fFunctions.GetEntries(); i++) {
105 fcn = (AliRsnFunction*)fFunctions.At(i);
712900a5 106 hName = prefix;
2a1c7696 107 hName += '_';
108 hName += GetName();
109 hName += '_';
110 hName += fcn->GetName();
111 if (fcn->IsUsingTH1()) list->Add(fcn->CreateHistogram(hName.Data(), ""));
112 else list->Add(fcn->CreateHistogramSparse(hName.Data(), ""));
113 }
2dab9030 114}
115
116//_____________________________________________________________________________
117void AliRsnPairFunctions::AddFunction(AliRsnFunction *const fcn)
118{
119//
120// Adds a new computing function
121//
122
2a1c7696 123 Int_t size = fFunctions.GetEntries();
11ed73f6 124 new (fFunctions[size]) AliRsnFunction(*fcn);
125 fFunctions.Print();
2dab9030 126}