2 // *** Class AliRsnPair ***
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)
15 #include "Riostream.h"
17 #include "AliRsnLoopEff.h"
19 ClassImp(AliRsnLoopEff)
21 //_____________________________________________________________________________
22 AliRsnLoopEff::AliRsnLoopEff(const char *name, Int_t nSteps, Double_t maxDist) :
30 // Default constructor
33 fVertex[0] = fVertex[1] = fVertex[2] = 0.0;
36 //_____________________________________________________________________________
37 AliRsnLoopEff::AliRsnLoopEff(const AliRsnLoopEff ©) :
39 fAddSteps(copy.fAddSteps),
41 fOutput(copy.fOutput),
42 fMaxDistPV(copy.fMaxDistPV)
48 fVertex[0] = fVertex[1] = fVertex[2] = 0.0;
51 //_____________________________________________________________________________
52 AliRsnLoopEff &AliRsnLoopEff::operator=(const AliRsnLoopEff ©)
55 // Assignment operator
58 AliRsnLoop::operator=(copy);
61 fAddSteps = copy.fAddSteps;
63 fOutput = copy.fOutput;
68 //_____________________________________________________________________________
69 AliRsnLoopEff::~AliRsnLoopEff()
79 //_____________________________________________________________________________
80 void AliRsnLoopEff::CreateOutput()
83 // Create the unique output object of this loop
86 fOutput = new AliRsnListOutput(Form("%s_out", GetName()), AliRsnListOutput::kCFContainer);
89 //_____________________________________________________________________________
90 void AliRsnLoopEff::AddStep(TObject *cuts)
93 // Add a step on reconstruction
99 //_____________________________________________________________________________
100 Bool_t AliRsnLoopEff::Init(const char *prefix, TList *list)
103 // Initialization function.
104 // Loops on all functions and eventual the ntuple, to initialize output objects.
107 if (!fOutputs.IsEmpty()) {
108 AliInfo("Clearing container of this efficiency loop.");
112 Int_t nSteps = (Int_t)fSteps.GetEntries();
115 fOutput->SetSteps(nSteps);
116 fOutput->SetSkipFailed(kFALSE);
117 AliRsnLoop::AddOutput(fOutput);
119 if (AliRsnLoop::Init(Form("%s_%s", prefix, GetName()), list)) {
120 fOutput = (AliRsnListOutput *)fOutputs[0];
128 //_____________________________________________________________________________
129 Int_t AliRsnLoopEff::FindTrack(Int_t label, const AliVEvent *event)
132 // Loops an event and find all tracks which have a label
133 // equal to that passed as first argument.
137 Int_t ntracks = event->GetNumberOfTracks();
140 for (i = 0; i < ntracks; i++) {
141 AliVParticle *track = event->GetTrack(i);
142 if (TMath::Abs(track->GetLabel()) != label) continue;
149 //__________________________________________________________________________________________________
150 Int_t AliRsnLoopEff::GetMatchedDaughter(Int_t label, AliRsnEvent *event)
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
157 if (!event) return -1;
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;
170 //__________________________________________________________________________________________________
171 Double_t AliRsnLoopEff::DistanceFromPV(Double_t x, Double_t y, Double_t z)
174 // Compute distance from current primary vertex
177 AliDebugClass(1, Form("Vertex = %.3f %.3f %.3f -- vprod = %.3f %.3f %.3f", fVertex[0], fVertex[1], fVertex[2], x, y, z));
183 return TMath::Sqrt(x*x + y*y + z*z);