]>
Commit | Line | Data |
---|---|---|
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 | ||
19 | ClassImp(AliRsnLoopEff) | |
20 | ||
21 | //_____________________________________________________________________________ | |
f34f960b | 22 | AliRsnLoopEff::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 | //_____________________________________________________________________________ | |
61f275d1 | 37 | AliRsnLoopEff::AliRsnLoopEff(const AliRsnLoopEff ©) : |
c865cb1d | 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 | //_____________________________________________________________________________ | |
61f275d1 | 52 | AliRsnLoopEff &AliRsnLoopEff::operator=(const AliRsnLoopEff ©) |
c865cb1d | 53 | { |
b63357a0 | 54 | // |
55 | // Assignment operator | |
56 | // | |
57 | ||
c865cb1d | 58 | AliRsnLoop::operator=(copy); |
e6f3a909 | 59 | if (this == ©) |
61f275d1 | 60 | return *this; |
c865cb1d | 61 | fAddSteps = copy.fAddSteps; |
62 | fSteps = copy.fSteps; | |
f34f960b | 63 | fOutput = copy.fOutput; |
c865cb1d | 64 | |
65 | return (*this); | |
66 | } | |
67 | ||
68 | //_____________________________________________________________________________ | |
69 | AliRsnLoopEff::~AliRsnLoopEff() | |
70 | { | |
71 | // | |
72 | // Destructor | |
73 | // | |
74 | ||
75 | fSteps.Delete(); | |
f34f960b | 76 | delete fOutput; |
c865cb1d | 77 | } |
78 | ||
79 | //_____________________________________________________________________________ | |
80 | void AliRsnLoopEff::CreateOutput() | |
81 | { | |
82 | // | |
83 | // Create the unique output object of this loop | |
84 | // | |
85 | ||
f34f960b | 86 | fOutput = new AliRsnListOutput(Form("%s_out", GetName()), AliRsnListOutput::kCFContainer); |
c865cb1d | 87 | } |
88 | ||
89 | //_____________________________________________________________________________ | |
90 | void AliRsnLoopEff::AddStep(TObject *cuts) | |
91 | { | |
92 | // | |
93 | // Add a step on reconstruction | |
94 | // | |
95 | ||
96 | fSteps.AddLast(cuts); | |
97 | } | |
98 | ||
99 | //_____________________________________________________________________________ | |
100 | Bool_t AliRsnLoopEff::Init(const char *prefix, TList *list) | |
101 | { | |
102 | // | |
103 | // Initialization function. | |
104 | // Loops on all functions and eventual the ntuple, to initialize output objects. | |
105 | // | |
106 | ||
f34f960b | 107 | if (!fOutputs.IsEmpty()) { |
108 | AliInfo("Clearing container of this efficiency loop."); | |
109 | fOutputs.Delete(); | |
110 | } | |
61f275d1 | 111 | |
f34f960b | 112 | Int_t nSteps = (Int_t)fSteps.GetEntries(); |
113 | nSteps += fAddSteps; | |
114 | ||
115 | fOutput->SetSteps(nSteps); | |
116 | fOutput->SetSkipFailed(kFALSE); | |
117 | AliRsnLoop::AddOutput(fOutput); | |
61f275d1 | 118 | |
f34f960b | 119 | if (AliRsnLoop::Init(Form("%s_%s", prefix, GetName()), list)) { |
61f275d1 | 120 | fOutput = (AliRsnListOutput *)fOutputs[0]; |
f34f960b | 121 | return kTRUE; |
122 | } else { | |
123 | fOutput = 0x0; | |
124 | return kFALSE; | |
125 | } | |
c865cb1d | 126 | } |
127 | ||
128 | //_____________________________________________________________________________ | |
b63357a0 | 129 | Int_t AliRsnLoopEff::FindTrack(Int_t label, const AliVEvent *event) |
c865cb1d | 130 | { |
131 | // | |
132 | // Loops an event and find all tracks which have a label | |
133 | // equal to that passed as first argument. | |
134 | // | |
135 | ||
136 | Int_t i = 0; | |
137 | Int_t ntracks = event->GetNumberOfTracks(); | |
138 | TArrayI array(100); | |
139 | ||
140 | for (i = 0; i < ntracks; i++) { | |
141 | AliVParticle *track = event->GetTrack(i); | |
142 | if (TMath::Abs(track->GetLabel()) != label) continue; | |
143 | return i; | |
144 | } | |
61f275d1 | 145 | |
c865cb1d | 146 | return -1; |
147 | } | |
f34f960b | 148 | |
149 | //__________________________________________________________________________________________________ | |
150 | Int_t AliRsnLoopEff::GetMatchedDaughter(Int_t label, AliRsnEvent *event) | |
151 | { | |
152 | // | |
153 | // Searches an object among all possible daughters which matches the corresponding label | |
154 | // and if it is found, assigns to the daughter and returns it | |
155 | // | |
156 | ||
157 | if (!event) return -1; | |
61f275d1 | 158 | |
f34f960b | 159 | AliRsnDaughter out; |
61f275d1 | 160 | |
f34f960b | 161 | Int_t i, imax = event->GetAbsoluteSum(); |
162 | for (i = 0; i < imax; i++) { | |
163 | event->SetDaughter(out, i); | |
164 | if (out.IsOK() && out.GetLabel() == label) return i; | |
165 | } | |
61f275d1 | 166 | |
f34f960b | 167 | return -1; |
168 | } | |
169 | ||
170 | //__________________________________________________________________________________________________ | |
171 | Double_t AliRsnLoopEff::DistanceFromPV(Double_t x, Double_t y, Double_t z) | |
172 | { | |
173 | // | |
174 | // Compute distance from current primary vertex | |
175 | // | |
176 | ||
177 | AliDebugClass(1, Form("Vertex = %.3f %.3f %.3f -- vprod = %.3f %.3f %.3f", fVertex[0], fVertex[1], fVertex[2], x, y, z)); | |
178 | ||
179 | x -= fVertex[0]; | |
180 | y -= fVertex[1]; | |
181 | z -= fVertex[2]; | |
61f275d1 | 182 | |
f34f960b | 183 | return TMath::Sqrt(x*x + y*y + z*z); |
184 | } | |
185 | ||
61f275d1 | 186 |