2 // *** Class AliRsnPairFunctions ***
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)
19 #include "AliRsnMother.h"
20 #include "AliRsnEvent.h"
21 #include "AliRsnFunction.h"
22 #include "AliRsnCutSet.h"
23 #include "AliRsnValue.h"
25 #include "AliRsnPairFunctions.h"
27 ClassImp(AliRsnPairFunctions)
29 //_____________________________________________________________________________
30 AliRsnPairFunctions::AliRsnPairFunctions(const char *name, AliRsnPairDef *def) :
31 AliRsnPair(name, def),
32 fFunctions("AliRsnFunction", 0)
35 // Default constructor
38 AliDebug(AliLog::kDebug+2,"<-");
39 AliDebug(AliLog::kDebug+2,"->");
42 //_____________________________________________________________________________
43 AliRsnPairFunctions::AliRsnPairFunctions(const AliRsnPairFunctions& copy) :
45 fFunctions(copy.fFunctions)
48 // Default constructor
51 AliDebug(AliLog::kDebug+2,"<-");
52 AliDebug(AliLog::kDebug+2,"->");
55 //_____________________________________________________________________________
56 AliRsnPairFunctions& AliRsnPairFunctions::operator=(const AliRsnPairFunctions& copy)
58 AliRsnPair::operator=(copy);
60 Int_t i, n = copy.fFunctions.GetEntries();
61 for (i = 0; i < n; i++)
63 AliRsnFunction *fcn = (AliRsnFunction*)copy.fFunctions[i];
64 if (fcn) AddFunction(fcn);
70 //_____________________________________________________________________________
71 AliRsnPairFunctions::~AliRsnPairFunctions()
77 AliDebug(AliLog::kDebug+2,"<-");
78 AliDebug(AliLog::kDebug+2,"->");
81 //_____________________________________________________________________________
82 void AliRsnPairFunctions::Compute()
85 // Makes computations using the two passed daughter objects.
86 // Checks all cuts and then computes the corresponding pair object
87 // and then fill the list of required values using it.
90 AliDebug(AliLog::kDebug+2,"<-");
92 TObjArrayIter nextFcn(&fFunctions);
93 AliRsnFunction *fcn = 0x0;
95 while ((fcn = (AliRsnFunction*)nextFcn()))
97 fcn->SetPairDef(fPairDef);
98 fcn->SetPair(&fMother);
99 fcn->SetEvent(fEvent);
103 AliDebug(AliLog::kDebug+2,"->");
106 //_____________________________________________________________________________
107 void AliRsnPairFunctions::Init(const char *prefix, TList *list)
110 // Generates needed histograms, giving them a name based on
111 // the flags defined here, on the pair definition, and attaches
112 // a prefix to it, according to the argument.
114 // All generated histograms are stored into the output TList.
117 AliDebug(AliLog::kDebug+2,"<-");
121 AliRsnFunction *fcn = 0;
122 for (i = 0; i < fFunctions.GetEntries(); i++)
124 fcn = (AliRsnFunction*)fFunctions.At(i);
129 hName += fcn->GetName();
130 if (fcn->IsUsingTH1()) list->Add(fcn->CreateHistogram(hName.Data(), ""));
131 else list->Add(fcn->CreateHistogramSparse(hName.Data(), ""));
134 AliDebug(AliLog::kDebug+2,"->");
137 //_____________________________________________________________________________
138 void AliRsnPairFunctions::AddFunction(AliRsnFunction *const fcn)
141 // Adds a new computing function
144 AliDebug(AliLog::kDebug+2,"<-");
147 Int_t size = fFunctions.GetEntries();
148 new(fFunctions[size]) AliRsnFunction(*fcn);
150 AliDebug(AliLog::kDebug+2,"->");
153 //_____________________________________________________________________________
154 void AliRsnPairFunctions::SetEvent(AliRsnEvent *event)
163 for (i = 0; i < fFunctions.GetEntries(); i++)
165 AliRsnFunction *fcn = (AliRsnFunction*)fFunctions.At(i);
166 fcn->SetEvent(event);