]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnPairFunctions.cxx
Fixed bug in AliRsnPair::Fill()
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnPairFunctions.cxx
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"
23 #include "AliRsnValue.h"
24
25 #include "AliRsnPairFunctions.h"
26
27 ClassImp(AliRsnPairFunctions)
28
29 //_____________________________________________________________________________
30 AliRsnPairFunctions::AliRsnPairFunctions(const char *name, AliRsnPairDef *def) :
31    AliRsnPair(name, def),
32    fFunctions("AliRsnFunction", 0)
33 {
34 //
35 // Default constructor
36 //
37 }
38
39 //_____________________________________________________________________________
40 AliRsnPairFunctions::AliRsnPairFunctions(const AliRsnPairFunctions& copy) :
41    AliRsnPair(copy),
42    fFunctions(copy.fFunctions)
43 {
44 //
45 // Default constructor
46 //
47 }
48
49 //_____________________________________________________________________________
50 AliRsnPairFunctions& AliRsnPairFunctions::operator=(const AliRsnPairFunctions& copy)
51 {
52    AliRsnPair::operator=(copy);
53
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    }
59
60    return (*this);
61 }
62
63 //_____________________________________________________________________________
64 AliRsnPairFunctions::~AliRsnPairFunctions()
65 {
66 //
67 // Destructor
68 //
69 }
70
71 //_____________________________________________________________________________
72 void 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 //
79
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    }
88 }
89
90 //_____________________________________________________________________________
91 void 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
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);
106       hName  = prefix;
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    }
114 }
115
116 //_____________________________________________________________________________
117 void AliRsnPairFunctions::AddFunction(AliRsnFunction *const fcn)
118 {
119 //
120 // Adds a new computing function
121 //
122
123    Int_t size = fFunctions.GetEntries();
124    new (fFunctions[size]) AliRsnFunction(*fcn);
125    fFunctions.Print();
126 }