2 // *** Class AliRsnPairNtuple ***
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 "AliRsnCutStd.h"
25 #include "AliRsnValue.h"
27 #include "AliRsnPairNtuple.h"
29 ClassImp(AliRsnPairNtuple)
31 //_____________________________________________________________________________
32 AliRsnPairNtuple::AliRsnPairNtuple(const char *name, AliRsnPairDef *def) :
33 AliRsnPair(name, def),
34 fValues("AliRsnValue", 0),
38 // Default constructor
41 AliDebug(AliLog::kDebug+2,"<-");
42 AliDebug(AliLog::kDebug+2,"->");
45 //_____________________________________________________________________________
46 AliRsnPairNtuple::AliRsnPairNtuple(const AliRsnPairNtuple& copy) :
48 fValues(copy.fValues),
52 // Default constructor
55 AliDebug(AliLog::kDebug+2,"<-");
56 AliDebug(AliLog::kDebug+2,"->");
59 //_____________________________________________________________________________
60 AliRsnPairNtuple& AliRsnPairNtuple::operator=(const AliRsnPairNtuple& copy)
62 AliRsnPair::operator=(copy);
64 Int_t i, n = copy.fValues.GetEntries();
65 for (i = 0; i < n; i++)
67 AliRsnValue *fcn = (AliRsnValue*)copy.fValues[i];
68 if (fcn) AddValue(fcn);
71 fNtuple = copy.fNtuple;
76 //_____________________________________________________________________________
77 AliRsnPairNtuple::~AliRsnPairNtuple()
83 AliDebug(AliLog::kDebug+2,"<-");
84 AliDebug(AliLog::kDebug+2,"->");
87 //_____________________________________________________________________________
88 void AliRsnPairNtuple::Compute()
91 // Makes computations using the two passed daughter objects.
92 // Checks all cuts and then computes the corresponding pair object
93 // and then fill the list of required values using it.
96 AliDebug(AliLog::kDebug+2,"<-");
99 Int_t i, n = fValues.GetEntries();
101 AliRsnValue *value = 0x0;
102 for (i = 0; i < n; i++)
105 value = (AliRsnValue*)fValues[i];
106 if (value->Eval(&fMother, fPairDef, fEvent)) values[i] = (Float_t)value->GetValue();
109 fNtuple->Fill(values.GetArray());
111 AliDebug(AliLog::kDebug+2,"->");
114 //_____________________________________________________________________________
115 void AliRsnPairNtuple::Init(const char *prefix, TList *list)
118 // Generates needed histograms, giving them a name based on
119 // the flags defined here, on the pair definition, and attaches
120 // a prefix to it, according to the argument.
122 // All generated histograms are stored into the output TList.
125 AliDebug(AliLog::kDebug+2,"<-");
127 TString nameList("");
129 Int_t i, n = fValues.GetEntries();
130 AliRsnValue *val = 0;
131 for (i = 0; i < n; i++)
133 val = (AliRsnValue*)fValues.At(i);
134 nameList += val->GetName();
135 if (i < n - 1) nameList += ':';
138 if (fNtuple) delete fNtuple;
139 fNtuple = new TNtuple(Form("%sntp%s", prefix, GetName()), "", nameList.Data());
140 if (list) list->Add(fNtuple);
142 AliDebug(AliLog::kDebug+2,"->");
145 //_____________________________________________________________________________
146 void AliRsnPairNtuple::AddValue(AliRsnValue *const val)
149 // Adds a new computing function
152 AliDebug(AliLog::kDebug+2,"<-");
153 Int_t size = fValues.GetEntries();
154 new(fValues[size]) AliRsnValue(*val);
155 AliDebug(AliLog::kDebug+2,"->");