]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnPair.cxx
Update
[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   {
128     AliDebug(AliLog::kDebug+2, "Specific cuts for track #1 not passed");
129     return kFALSE;
130   }
131   if (!fCutManager.PassCommonDaughterCuts(daughter0))
132   {
133     AliDebug(AliLog::kDebug+2, "Common cuts for track #1 not passed");
134     return kFALSE;
135   }
136   
137   // cuts on track #2 & common
138   AliRsnTarget::SwitchToSecond();
139   if (!fCutManager.PassDaughter2Cuts(daughter1))
140   {
141     AliDebug(AliLog::kDebug+2, "Specific cuts for track #2 not passed");
142     return kFALSE;
143   }
144   if (!fCutManager.PassCommonDaughterCuts(daughter1))
145   {
146     AliDebug(AliLog::kDebug+2, "Common cuts for track #2 not passed");
147     return kFALSE;
148   }
149   
150   // point again to first event as reference
151   // and for checking the pair cuts
152   AliRsnTarget::SwitchToFirst();
153   if (!fCutManager.PassMotherCuts(&fMother)) return kFALSE;
154   
155   // if required a true pair, check this here and eventually return a fail message
156   if (fOnlyTrue)
157   {
158     // are the daughters really secondaries (in MC)?
159     Int_t m0, m1;
160     if (!fMother.CommonMother(m0, m1)) return kFALSE;
161     if (m0 < 0 || m1 < 0) return kFALSE;
162     
163     AliDebug(AliLog::kDebug+2, "Checking a true pair...");
164     
165     // if they do, is this mother the correct type?
166     Int_t mpdg0 = TMath::Abs(daughter0->GetMotherPDG());
167     Int_t mpdg1 = TMath::Abs(daughter1->GetMotherPDG());
168     Int_t mpdg  = TMath::Abs(fPairDef->GetMotherPDG());
169     if (mpdg0 != mpdg) 
170     {
171       AliDebug(AliLog::kDebug+2, Form("Mother of d0 is %d instead of %d", mpdg0, mpdg)); 
172       return kFALSE;
173     }
174     if (mpdg1 != mpdg) 
175     {
176       AliDebug(AliLog::kDebug+2, Form("Mother of d1 is %d instead of %d", mpdg1, mpdg));
177       return kFALSE;
178     }
179     
180     // do they match the expected decay channel (that is, are they the expected types)?
181     if (fCheckDecay)
182     {
183       AliDebug(AliLog::kDebug, "Checking decay tree...");
184       Int_t pdg0 = TMath::Abs(daughter0->GetPDG());
185       Int_t pdg1 = TMath::Abs(daughter1->GetPDG());
186       if (AliPID::ParticleCode(fPairDef->GetPID(0)) != pdg0) 
187       {
188         AliDebug(AliLog::kDebug+2, Form("PDG0 is %d instead of %d", pdg0, fPairDef->GetPID(0))); 
189         return kFALSE;
190       }
191       if (AliPID::ParticleCode(fPairDef->GetPID(1)) != pdg1) 
192       {
193         AliDebug(AliLog::kDebug+2, Form("PDG1 is %d instead of %d", pdg1, fPairDef->GetPID(1)));
194         return kFALSE;
195       }
196       AliDebug(AliLog::kDebug, "Decay tree accepted");
197     }
198     
199     // ok... if we arrive here that must really be a true pair! :-)
200     AliDebug(AliLog::kDebug+2, "Pair accepted");
201   }
202
203   AliDebug(AliLog::kDebug+2,"->");
204   
205   // if pair is accepted, increment counter
206   ++fCount;
207   
208   return kTRUE;
209 }
210
211 //_____________________________________________________________________________
212 void AliRsnPair::Compute()
213 {
214 //
215 // Virtual method to compute pair quantities of interest
216 //
217
218   AliWarning("Implement this method in derived classes");
219 }
220
221 //_____________________________________________________________________________
222 void AliRsnPair::Init(const char* /*prefix*/, TList* /*list*/)
223 {
224 //
225 // Virtual method to compute pair quantities of interest
226 //
227
228   AliWarning("Implement this method in derived classes");
229 }