]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnMonitorFunctions.cxx
Add new version of macros for RSN analysis
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnMonitorFunctions.cxx
1 //
2 // *** Class AliRsnMonitorFunctions ***
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 "AliRsnMonitorFunctions.h"
26
27 ClassImp(AliRsnMonitorFunctions)
28
29 //_____________________________________________________________________________
30 AliRsnMonitorFunctions::AliRsnMonitorFunctions(const char *name, AliRsnDaughterDef *def) :
31    AliRsnMonitor(name, def),
32    fFunctions("AliRsnFunction", 0)
33 {
34 //
35 // Default constructor
36 //
37
38    AliDebug(AliLog::kDebug + 2, "<-");
39    AliDebug(AliLog::kDebug + 2, "->");
40 }
41
42 //_____________________________________________________________________________
43 AliRsnMonitorFunctions::AliRsnMonitorFunctions(const AliRsnMonitorFunctions& copy) :
44    AliRsnMonitor(copy),
45    fFunctions(copy.fFunctions)
46 {
47 //
48 // Default constructor
49 //
50
51    AliDebug(AliLog::kDebug + 2, "<-");
52    AliDebug(AliLog::kDebug + 2, "->");
53 }
54
55 //_____________________________________________________________________________
56 AliRsnMonitorFunctions& AliRsnMonitorFunctions::operator=(const AliRsnMonitorFunctions& copy)
57 {
58    AliRsnMonitor::operator=(copy);
59
60    Int_t i, n = copy.fFunctions.GetEntries();
61    for (i = 0; i < n; i++) {
62       AliRsnFunction *fcn = (AliRsnFunction*)copy.fFunctions[i];
63       if (fcn) AddFunction(fcn);
64    }
65
66    return (*this);
67 }
68
69 //_____________________________________________________________________________
70 AliRsnMonitorFunctions::~AliRsnMonitorFunctions()
71 {
72 //
73 // Destructor
74 //
75
76    AliDebug(AliLog::kDebug + 2, "<-");
77    AliDebug(AliLog::kDebug + 2, "->");
78 }
79
80 //_____________________________________________________________________________
81 void AliRsnMonitorFunctions::Compute()
82 {
83 //
84 // Makes computations using the two passed daughter objects.
85 // Checks all cuts and then computes the corresponding pair object
86 // and then fill the list of required values using it.
87 //
88
89    AliDebug(AliLog::kDebug + 2, "<-");
90
91    TObjArrayIter   nextFcn(&fFunctions);
92    AliRsnFunction *fcn = 0x0;
93
94    while ((fcn = (AliRsnFunction*)nextFcn())) {
95       fcn->Fill(fDaughter);
96    }
97
98    AliDebug(AliLog::kDebug + 2, "->");
99 }
100
101 //_____________________________________________________________________________
102 void AliRsnMonitorFunctions::Init(const char *prefix, TList *list)
103 {
104 //
105 // Generates needed histograms, giving them a name based on
106 // the flags defined here, on the pair definition, and attaches
107 // a prefix to it, according to the argument.
108 //
109 // All generated histograms are stored into the output TList.
110 //
111
112    AliDebug(AliLog::kDebug + 2, "<-");
113
114    Int_t  i;
115    TString hName("");
116    AliRsnFunction *fcn = 0;
117    for (i = 0; i < fFunctions.GetEntries(); i++) {
118       fcn = (AliRsnFunction*)fFunctions.At(i);
119       hName  = prefix;
120       hName += '_';
121       hName += GetName();
122       hName += '_';
123       hName += fcn->GetName();
124       if (fcn->IsUsingTH1()) list->Add(fcn->CreateHistogram(hName.Data(), ""));
125       else list->Add(fcn->CreateHistogramSparse(hName.Data(), ""));
126    }
127
128    AliDebug(AliLog::kDebug + 2, "->");
129 }
130
131 //_____________________________________________________________________________
132 void AliRsnMonitorFunctions::AddFunction(AliRsnFunction *const fcn)
133 {
134 //
135 // Adds a new computing function
136 //
137
138    AliDebug(AliLog::kDebug + 2, "<-");
139
140    Int_t size = fFunctions.GetEntries();
141    new(fFunctions[size]) AliRsnFunction(*fcn);
142    fFunctions.Print();
143
144    AliDebug(AliLog::kDebug + 2, "->");
145 }