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