]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnPair.cxx
Added a new cut on comparison of daughters' momenta (needed for Deltas)
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnPair.cxx
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
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 "AliRsnValue.h"
24 #include "AliRsnCutManager.h"
25
26 #include "AliRsnPair.h"
27
28 ClassImp(AliRsnPair)
29
30 //_____________________________________________________________________________
31 AliRsnPair::AliRsnPair(const char *name, AliRsnPairDef *def) :
32    TNamed(name, ""),
33    fOnlyTrue(kFALSE),
34    fCheckDecay(kFALSE),
35    fIsMixed(kFALSE),
36    fCount(0),
37    fPairDef(def),
38    fCutManager(Form("cutMgr_%s", name)),
39    fMother()
40 {
41 //
42 // Default constructor
43 //
44 }
45
46 //_____________________________________________________________________________
47 AliRsnPair::AliRsnPair(const AliRsnPair& copy) :
48    TNamed(copy),
49    fOnlyTrue(copy.fOnlyTrue),
50    fCheckDecay(copy.fCheckDecay),
51    fIsMixed(copy.fIsMixed),
52    fCount(copy.fCount),
53    fPairDef(copy.fPairDef),
54    fCutManager(copy.fCutManager),
55    fMother(copy.fMother)
56 {
57 //
58 // Default constructor
59 //
60 }
61
62 //_____________________________________________________________________________
63 AliRsnPair& AliRsnPair::operator=(const AliRsnPair& copy)
64 {
65    fOnlyTrue = copy.fOnlyTrue;
66    fCheckDecay = copy.fCheckDecay;
67    fIsMixed = copy.fIsMixed;
68    fCount = copy.fCount;
69    fPairDef = copy.fPairDef;
70    fMother = copy.fMother;
71    fCutManager = copy.fCutManager;
72
73    return (*this);
74 }
75
76 //_____________________________________________________________________________
77 AliRsnPair::~AliRsnPair()
78 {
79 //
80 // Destructor
81 //
82 }
83
84 //_____________________________________________________________________________
85 void AliRsnPair::Print(Option_t* /*option*/) const
86 {
87 //
88 // Prints info about pair
89 //
90
91    AliInfo(Form("PDG    %d %d", AliPID::ParticleCode(fPairDef->GetPID(0)), AliPID::ParticleCode(fPairDef->GetPID(1))));
92    AliInfo(Form("Masses %f %f", fPairDef->GetMass(0), fPairDef->GetMass(1)));
93 }
94
95 //_____________________________________________________________________________
96 Bool_t AliRsnPair::Fill
97 (AliRsnDaughter *daughter0, AliRsnDaughter *daughter1)
98 {
99 //
100 // Sets the two passed daughters to the AliRsnMother data member of this object
101 // which is used to perform all computations to fill the value list.
102 // This operation is done successfully only when the first passed object matches
103 // the required object type (track/V0) and the required charge for first element in pair def,
104 // and the second passed object does the same w.r. to the second element in pair def.
105 // Moreover, all cuts are checked and the operation fails if a cut check is unsuccessful.
106 // Finally, if a true pair is required, this is checked at the end.
107 //
108
109    AliDebug(AliLog::kDebug + 2, "<-");
110
111    // first of all, compute the 4-momenta of the daughters
112    // and that of the mother, according to current pair def
113    // this could be needed for some cuts
114    fMother.SetDaughters(daughter0, fPairDef->GetMass(0), daughter1, fPairDef->GetMass(1));
115
116    // check for correct type-charge match for first element
117    if (daughter0->RefType() != fPairDef->GetDaughterType(0)) return kFALSE;
118    if (daughter0->ChargeChar() != fPairDef->GetCharge(0)) return kFALSE;
119
120    // check for correct type-charge match for second element
121    if (daughter1->RefType() != fPairDef->GetDaughterType(1)) return kFALSE;
122    if (daughter1->ChargeChar() != fPairDef->GetCharge(1)) return kFALSE;
123
124    // cuts on track #1 & common
125    AliRsnTarget::SwitchToFirst();
126    if (!fCutManager.PassDaughter1Cuts(daughter0)) {
127       AliDebug(AliLog::kDebug + 2, "Specific cuts for track #1 not passed");
128       return kFALSE;
129    }
130    if (!fCutManager.PassCommonDaughterCuts(daughter0)) {
131       AliDebug(AliLog::kDebug + 2, "Common cuts for track #1 not passed");
132       return kFALSE;
133    }
134
135    // cuts on track #2 & common
136    AliRsnTarget::SwitchToSecond();
137    if (!fCutManager.PassDaughter2Cuts(daughter1)) {
138       AliDebug(AliLog::kDebug + 2, "Specific cuts for track #2 not passed");
139       return kFALSE;
140    }
141    if (!fCutManager.PassCommonDaughterCuts(daughter1)) {
142       AliDebug(AliLog::kDebug + 2, "Common cuts for track #2 not passed");
143       return kFALSE;
144    }
145
146    // point again to first event as reference
147    // and for checking the pair cuts
148    AliRsnTarget::SwitchToFirst();
149    if (!fCutManager.PassMotherCuts(&fMother)) return kFALSE;
150
151    // if required a true pair, check this here and eventually return a fail message
152    if (fOnlyTrue) {
153       // are the daughters really secondaries (in MC)?
154       Int_t m0, m1;
155       if (!fMother.CommonMother(m0, m1)) return kFALSE;
156       if (m0 < 0 || m1 < 0) return kFALSE;
157
158       AliDebug(AliLog::kDebug + 2, "Checking a true pair...");
159
160       // if they do, is this mother the correct type?
161       Int_t mpdg0 = TMath::Abs(daughter0->GetMotherPDG());
162       Int_t mpdg1 = TMath::Abs(daughter1->GetMotherPDG());
163       Int_t mpdg  = TMath::Abs(fPairDef->GetMotherPDG());
164       if (mpdg0 != mpdg) {
165          AliDebug(AliLog::kDebug + 2, Form("Mother of d0 is %d instead of %d", mpdg0, mpdg));
166          return kFALSE;
167       }
168       if (mpdg1 != mpdg) {
169          AliDebug(AliLog::kDebug + 2, Form("Mother of d1 is %d instead of %d", mpdg1, mpdg));
170          return kFALSE;
171       }
172
173       // do they match the expected decay channel (that is, are they the expected types)?
174       if (fCheckDecay) {
175          AliDebug(AliLog::kDebug, "Checking decay tree...");
176          Int_t pdg0 = TMath::Abs(daughter0->GetPDG());
177          Int_t pdg1 = TMath::Abs(daughter1->GetPDG());
178          if (AliPID::ParticleCode(fPairDef->GetPID(0)) != pdg0) {
179             AliDebug(AliLog::kDebug + 2, Form("PDG0 is %d instead of %d", pdg0, fPairDef->GetPID(0)));
180             return kFALSE;
181          }
182          if (AliPID::ParticleCode(fPairDef->GetPID(1)) != pdg1) {
183             AliDebug(AliLog::kDebug + 2, Form("PDG1 is %d instead of %d", pdg1, fPairDef->GetPID(1)));
184             return kFALSE;
185          }
186          AliDebug(AliLog::kDebug, "Decay tree accepted");
187       }
188
189       // ok... if we arrive here that must really be a true pair! :-)
190       AliDebug(AliLog::kDebug + 2, "Pair accepted");
191    }
192
193    AliDebug(AliLog::kDebug + 2, "->");
194
195    // if pair is accepted, increment counter
196    ++fCount;
197
198    return kTRUE;
199 }
200
201 //_____________________________________________________________________________
202 void AliRsnPair::Compute()
203 {
204 //
205 // Virtual method to compute pair quantities of interest
206 //
207
208    AliWarning("Implement this method in derived classes");
209 }
210
211 //_____________________________________________________________________________
212 void AliRsnPair::Init(const char* /*prefix*/, TList* /*list*/)
213 {
214 //
215 // Virtual method to compute pair quantities of interest
216 //
217
218    AliWarning("Implement this method in derived classes");
219 }