]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnPair.cxx
bugfix
[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)) 
133   {
134     AliDebug(AliLog::kDebug+2, "Specific cuts for track #1 not passed");
135     return kFALSE;
136   }
137   if (!fCutManager.PassCommonDaughterCuts(daughter0))
138   {
139     AliDebug(AliLog::kDebug+2, "Common cuts for track #1 not passed");
140     return kFALSE;
141   }
142   
143   // cuts on track #2 & common
144   fCutManager.SetEvent(ev1);
145   if (!fCutManager.PassDaughter2Cuts(daughter1))
146   {
147     AliDebug(AliLog::kDebug+2, "Specific cuts for track #2 not passed");
148     return kFALSE;
149   }
150   if (!fCutManager.PassCommonDaughterCuts(daughter1))
151   {
152     AliDebug(AliLog::kDebug+2, "Common cuts for track #2 not passed");
153     return kFALSE;
154   }
155   
156   // point to first event as reference
157   fEvent = ev0;
158   
159   // define pair & check
160   fMother.SetDaughters(daughter0, fPairDef->GetMass(0), daughter1, fPairDef->GetMass(1));
161   fCutManager.SetEvent(fEvent);
162   if (!fCutManager.PassMotherCuts(&fMother)) return kFALSE;
163   
164   // if required a true pair, check this here and eventually return a fail message
165   if (fOnlyTrue)
166   {
167     // are we in a MonteCarlo?
168     if (!daughter0->GetParticle() || !daughter1->GetParticle()) return kFALSE;
169     
170     // are the daughters really secondaries (in MC)?
171     Int_t m0 = daughter0->GetParticle()->GetFirstMother();
172     Int_t m1 = daughter1->GetParticle()->GetFirstMother();
173     if (m0 < 0 || m1 < 0) return kFALSE;
174     
175     // if they are, do they come from the same mother?
176     if (m0 != m1) return kFALSE;
177     
178     // if they do, is this mother the correct type?
179     if (daughter0->GetMotherPDG() != fPairDef->GetMotherPDG()) return kFALSE;
180     if (daughter1->GetMotherPDG() != fPairDef->GetMotherPDG()) return kFALSE;
181     
182     // do they match the expected decay channel (that is, are they the expected types)?
183     Int_t pdg0 = TMath::Abs(daughter0->GetParticle()->GetPdgCode());
184     Int_t pdg1 = TMath::Abs(daughter1->GetParticle()->GetPdgCode());
185     if (AliPID::ParticleCode(fPairDef->GetPID(0)) != pdg0) return kFALSE;
186     if (AliPID::ParticleCode(fPairDef->GetPID(1)) != pdg1) return kFALSE;
187     
188     // ok... if we arrive here that must really be a true pair! :-)
189   }
190
191   AliDebug(AliLog::kDebug+2,"->");
192   
193   return kTRUE;
194 }
195
196 //_____________________________________________________________________________
197 void AliRsnPair::Compute()
198 {
199 //
200 // Virtual method to compute pair quantities of interest
201 //
202
203   AliWarning("Implement this method in derived classes");
204 }
205
206 //_____________________________________________________________________________
207 void AliRsnPair::Init(const char* /*prefix*/, TList* /*list*/)
208 {
209 //
210 // Virtual method to compute pair quantities of interest
211 //
212
213   AliWarning("Implement this method in derived classes");
214 }