]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnLoopEff.cxx
Added another version of cut for pp (small differences in PID)
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnLoopEff.cxx
CommitLineData
c865cb1d 1//
2// *** Class AliRsnPair ***
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
f34f960b 15#include "Riostream.h"
16#include "AliLog.h"
c865cb1d 17#include "AliRsnLoopEff.h"
18
19ClassImp(AliRsnLoopEff)
20
21//_____________________________________________________________________________
f34f960b 22AliRsnLoopEff::AliRsnLoopEff(const char *name, Int_t nSteps, Double_t maxDist) :
c865cb1d 23 AliRsnLoop(name),
24 fAddSteps(nSteps),
f34f960b 25 fSteps(0),
26 fOutput(0),
27 fMaxDistPV(maxDist)
c865cb1d 28{
29//
30// Default constructor
31//
f34f960b 32
33 fVertex[0] = fVertex[1] = fVertex[2] = 0.0;
c865cb1d 34}
35
36//_____________________________________________________________________________
37AliRsnLoopEff::AliRsnLoopEff(const AliRsnLoopEff& copy) :
38 AliRsnLoop(copy),
39 fAddSteps(copy.fAddSteps),
f34f960b 40 fSteps(copy.fSteps),
110620ce 41 fOutput(copy.fOutput),
42 fMaxDistPV(copy.fMaxDistPV)
c865cb1d 43{
44//
45// Copy constructor
46//
f34f960b 47
48 fVertex[0] = fVertex[1] = fVertex[2] = 0.0;
c865cb1d 49}
50
51//_____________________________________________________________________________
52AliRsnLoopEff& AliRsnLoopEff::operator=(const AliRsnLoopEff& copy)
53{
54 AliRsnLoop::operator=(copy);
55
56 fAddSteps = copy.fAddSteps;
57 fSteps = copy.fSteps;
f34f960b 58 fOutput = copy.fOutput;
c865cb1d 59
60 return (*this);
61}
62
63//_____________________________________________________________________________
64AliRsnLoopEff::~AliRsnLoopEff()
65{
66//
67// Destructor
68//
69
70 fSteps.Delete();
f34f960b 71 delete fOutput;
c865cb1d 72}
73
74//_____________________________________________________________________________
75void AliRsnLoopEff::CreateOutput()
76{
77//
78// Create the unique output object of this loop
79//
80
f34f960b 81 fOutput = new AliRsnListOutput(Form("%s_out", GetName()), AliRsnListOutput::kCFContainer);
c865cb1d 82}
83
84//_____________________________________________________________________________
85void AliRsnLoopEff::AddStep(TObject *cuts)
86{
87//
88// Add a step on reconstruction
89//
90
91 fSteps.AddLast(cuts);
92}
93
94//_____________________________________________________________________________
95Bool_t AliRsnLoopEff::Init(const char *prefix, TList *list)
96{
97//
98// Initialization function.
99// Loops on all functions and eventual the ntuple, to initialize output objects.
100//
101
f34f960b 102 if (!fOutputs.IsEmpty()) {
103 AliInfo("Clearing container of this efficiency loop.");
104 fOutputs.Delete();
105 }
106
107 Int_t nSteps = (Int_t)fSteps.GetEntries();
108 nSteps += fAddSteps;
109
110 fOutput->SetSteps(nSteps);
111 fOutput->SetSkipFailed(kFALSE);
112 AliRsnLoop::AddOutput(fOutput);
113
114 if (AliRsnLoop::Init(Form("%s_%s", prefix, GetName()), list)) {
115 fOutput = (AliRsnListOutput*)fOutputs[0];
116 return kTRUE;
117 } else {
118 fOutput = 0x0;
119 return kFALSE;
120 }
c865cb1d 121}
122
123//_____________________________________________________________________________
124Int_t AliRsnLoopEff::FindTrack(Int_t label, AliVEvent *event)
125{
126//
127// Loops an event and find all tracks which have a label
128// equal to that passed as first argument.
129//
130
131 Int_t i = 0;
132 Int_t ntracks = event->GetNumberOfTracks();
133 TArrayI array(100);
134
135 for (i = 0; i < ntracks; i++) {
136 AliVParticle *track = event->GetTrack(i);
137 if (TMath::Abs(track->GetLabel()) != label) continue;
138 return i;
139 }
140
141 return -1;
142}
f34f960b 143
144//__________________________________________________________________________________________________
145Int_t AliRsnLoopEff::GetMatchedDaughter(Int_t label, AliRsnEvent *event)
146{
147//
148// Searches an object among all possible daughters which matches the corresponding label
149// and if it is found, assigns to the daughter and returns it
150//
151
152 if (!event) return -1;
153
154 AliRsnDaughter out;
155
156 Int_t i, imax = event->GetAbsoluteSum();
157 for (i = 0; i < imax; i++) {
158 event->SetDaughter(out, i);
159 if (out.IsOK() && out.GetLabel() == label) return i;
160 }
161
162 return -1;
163}
164
165//__________________________________________________________________________________________________
166Double_t AliRsnLoopEff::DistanceFromPV(Double_t x, Double_t y, Double_t z)
167{
168//
169// Compute distance from current primary vertex
170//
171
172 AliDebugClass(1, Form("Vertex = %.3f %.3f %.3f -- vprod = %.3f %.3f %.3f", fVertex[0], fVertex[1], fVertex[2], x, y, z));
173
174 x -= fVertex[0];
175 y -= fVertex[1];
176 z -= fVertex[2];
177
178 return TMath::Sqrt(x*x + y*y + z*z);
179}
180
181