]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnMonitorNtuple.cxx
Introduce a limit on the gain factor (Raphaelle)
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnMonitorNtuple.cxx
CommitLineData
465f48b2 1//
2// *** Class AliRsnMonitorNtuple ***
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#include <TNtuple.h>
17
18#include "AliLog.h"
19
20#include "AliRsnMother.h"
21#include "AliRsnEvent.h"
22#include "AliRsnFunction.h"
23#include "AliRsnCutSet.h"
24#include "AliRsnValue.h"
25
26#include "AliRsnMonitorNtuple.h"
27
28ClassImp(AliRsnMonitorNtuple)
29
30//_____________________________________________________________________________
61da4e32 31AliRsnMonitorNtuple::AliRsnMonitorNtuple(const char *name, AliRsnDaughterDef *def) :
32 AliRsnMonitor(name, def),
465f48b2 33 fValues("AliRsnValue", 0),
34 fNtuple(0x0)
35{
36//
37// Default constructor
38//
39
40 AliDebug(AliLog::kDebug + 2, "<-");
41 AliDebug(AliLog::kDebug + 2, "->");
42}
43
44//_____________________________________________________________________________
45AliRsnMonitorNtuple::AliRsnMonitorNtuple(const AliRsnMonitorNtuple& copy) :
46 AliRsnMonitor(copy),
47 fValues(copy.fValues),
48 fNtuple(copy.fNtuple)
49{
50//
51// Default constructor
52//
53
54 AliDebug(AliLog::kDebug + 2, "<-");
55 AliDebug(AliLog::kDebug + 2, "->");
56}
57
58//_____________________________________________________________________________
59AliRsnMonitorNtuple& AliRsnMonitorNtuple::operator=(const AliRsnMonitorNtuple& copy)
60{
61 AliRsnMonitor::operator=(copy);
62
63 Int_t i, n = copy.fValues.GetEntries();
64 for (i = 0; i < n; i++) {
65 AliRsnValue *fcn = (AliRsnValue*)copy.fValues[i];
66 if (fcn) AddValue(fcn);
67 }
68
69 fNtuple = copy.fNtuple;
70
71 return (*this);
72}
73
74//_____________________________________________________________________________
75AliRsnMonitorNtuple::~AliRsnMonitorNtuple()
76{
77//
78// Destructor
79//
80
81 AliDebug(AliLog::kDebug + 2, "<-");
82 AliDebug(AliLog::kDebug + 2, "->");
83}
84
85//_____________________________________________________________________________
86void AliRsnMonitorNtuple::Compute()
87{
88//
89// Makes computations using the two passed daughter objects.
90// Checks all cuts and then computes the corresponding pair object
91// and then fill the list of required values using it.
92//
93
94 AliDebug(AliLog::kDebug + 2, "<-");
95
96 // compute all values
97 Int_t i, n = fValues.GetEntries();
98 TArrayF values(n);
99 AliRsnValue *value = 0x0;
100 Bool_t computeOK = kFALSE;
101 for (i = 0; i < n; i++) {
102 values[i] = -1E10;
103 value = (AliRsnValue*)fValues[i];
104 switch (value->GetTargetType()) {
105 case AliRsnTarget::kDaughter:
106 computeOK = value->Eval(&fDaughter);
107 break;
108 case AliRsnTarget::kEvent:
109 computeOK = value->Eval(AliRsnTarget::GetCurrentEvent());
110 break;
111 default:
112 AliError(Form("Allowed targets are mothers and events; cannot use axis '%s' which has target '%s'", value->GetName(), value->GetTargetTypeName()));
113 computeOK = kFALSE;
114 }
115 if (computeOK) values[i] = ((Float_t)value->GetComputedValue());
116 }
117
118 fNtuple->Fill(values.GetArray());
119
120 AliDebug(AliLog::kDebug + 2, "->");
121}
122
123//_____________________________________________________________________________
124void AliRsnMonitorNtuple::Init(const char *prefix, TList *list)
125{
126//
127// Generates needed histograms, giving them a name based on
128// the flags defined here, on the pair definition, and attaches
129// a prefix to it, according to the argument.
130//
131// All generated histograms are stored into the output TList.
132//
133
134 AliDebug(AliLog::kDebug + 2, "<-");
135
136 TString nameList("");
137
138 Int_t i, n = fValues.GetEntries();
139 AliRsnValue *val = 0;
140 for (i = 0; i < n; i++) {
141 val = (AliRsnValue*)fValues.At(i);
142 nameList += val->GetName();
143 if (i < n - 1) nameList += ':';
144 }
145
146 if (fNtuple) delete fNtuple;
147 fNtuple = new TNtuple(Form("%sntp%s", prefix, GetName()), "", nameList.Data());
148 if (list) list->Add(fNtuple);
149
150 AliDebug(AliLog::kDebug + 2, "->");
151}
152
153//_____________________________________________________________________________
154Bool_t AliRsnMonitorNtuple::AddValue(AliRsnValue *const val)
155{
156//
157// Adds a new computing function.
158//
159
160 RSNTARGET target = val->GetTargetType();
161 if (target != AliRsnTarget::kMother && target != AliRsnTarget::kEvent) {
162 AliError(Form("Allowed targets are mothers and events; cannot use axis '%s' which has target '%s'", val->GetName(), val->GetTargetTypeName()));
163 return kFALSE;
164 }
165
166 Int_t size = fValues.GetEntries();
167 new(fValues[size]) AliRsnValue(*val);
168
169 return kTRUE;
170}