2 // *** Class AliRsnMonitorNtuple ***
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)
11 // authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
12 // M. Vala (email: martin.vala@cern.ch)
20 #include "AliRsnMother.h"
21 #include "AliRsnEvent.h"
22 #include "AliRsnFunction.h"
23 #include "AliRsnCutSet.h"
24 #include "AliRsnValue.h"
26 #include "AliRsnMonitorNtuple.h"
28 ClassImp(AliRsnMonitorNtuple)
30 //_____________________________________________________________________________
31 AliRsnMonitorNtuple::AliRsnMonitorNtuple(const char *name, AliRsnDaughterDef *def) :
32 AliRsnMonitor(name, def),
33 fValues("AliRsnValue", 0),
37 // Default constructor
40 AliDebug(AliLog::kDebug + 2, "<-");
41 AliDebug(AliLog::kDebug + 2, "->");
44 //_____________________________________________________________________________
45 AliRsnMonitorNtuple::AliRsnMonitorNtuple(const AliRsnMonitorNtuple& copy) :
47 fValues(copy.fValues),
51 // Default constructor
54 AliDebug(AliLog::kDebug + 2, "<-");
55 AliDebug(AliLog::kDebug + 2, "->");
58 //_____________________________________________________________________________
59 AliRsnMonitorNtuple& AliRsnMonitorNtuple::operator=(const AliRsnMonitorNtuple& copy)
61 AliRsnMonitor::operator=(copy);
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);
69 fNtuple = copy.fNtuple;
74 //_____________________________________________________________________________
75 AliRsnMonitorNtuple::~AliRsnMonitorNtuple()
81 AliDebug(AliLog::kDebug + 2, "<-");
82 AliDebug(AliLog::kDebug + 2, "->");
85 //_____________________________________________________________________________
86 void AliRsnMonitorNtuple::Compute()
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.
94 AliDebug(AliLog::kDebug + 2, "<-");
97 Int_t i, n = fValues.GetEntries();
99 AliRsnValue *value = 0x0;
100 Bool_t computeOK = kFALSE, globalOK = kTRUE;
101 for (i = 0; i < n; i++) {
103 value = (AliRsnValue*)fValues[i];
104 switch (value->GetTargetType()) {
105 case AliRsnTarget::kDaughter:
106 computeOK = value->Eval(fDaughter);
108 case AliRsnTarget::kEvent:
109 computeOK = value->Eval(fDaughter->GetOwnerEvent());
112 AliError(Form("Allowed targets are mothers and events; cannot use axis '%s' which has target '%s'", value->GetName(), value->GetTargetTypeName()));
116 values[i] = ((Float_t)value->GetComputedValue());
121 if (globalOK) fNtuple->Fill(values.GetArray());
123 AliDebug(AliLog::kDebug + 2, "->");
126 //_____________________________________________________________________________
127 void AliRsnMonitorNtuple::Init(const char *prefix, TList *list)
130 // Generates needed histograms, giving them a name based on
131 // the flags defined here, on the pair definition, and attaches
132 // a prefix to it, according to the argument.
134 // All generated histograms are stored into the output TList.
137 AliDebug(AliLog::kDebug + 2, "<-");
139 TString nameList("");
141 Int_t i, n = fValues.GetEntries();
142 AliRsnValue *val = 0;
143 for (i = 0; i < n; i++) {
144 val = (AliRsnValue*)fValues.At(i);
145 nameList += val->GetName();
146 if (i < n - 1) nameList += ':';
149 if (fNtuple) delete fNtuple;
150 fNtuple = new TNtuple(Form("%sntp%s", prefix, GetName()), "", nameList.Data());
151 if (list) list->Add(fNtuple);
153 AliDebug(AliLog::kDebug + 2, "->");
156 //_____________________________________________________________________________
157 Bool_t AliRsnMonitorNtuple::AddValue(AliRsnValue *const val)
160 // Adds a new computing function.
163 RSNTARGET target = val->GetTargetType();
164 if (target != AliRsnTarget::kMother && target != AliRsnTarget::kEvent) {
165 AliError(Form("Allowed targets are mothers and events; cannot use axis '%s' which has target '%s'", val->GetName(), val->GetTargetTypeName()));
169 Int_t size = fValues.GetEntries();
170 new(fValues[size]) AliRsnValue(*val);