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