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