Updated for changes in the framework to make to make
[u/mrichter/AliRoot.git] / MUON / AliMUONPairLight.cxx
CommitLineData
55fd51b0 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * SigmaEffect_thetadegrees *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpeateose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
3d1463c8 18//-----------------------------------------------------------------------------
55fd51b0 19//This class was prepared by INFN Cagliari, July 2006
20//(authors: H.Woehri, A.de Falco)
21//
22// Compact information for the generated muon pairs in the MUON arm
23// useful at the last stage of the analysis chain
24// Pairs are built with two AliMUONTrackLight objects
25// Using the class AliMUONTrackLight this class combines the decay
26// information ("history") of the reconstructed tracks and fills
27// a series of flags for the formed reconstructed dimuon:
28// fIsCorrelated, fCreationProcess, fIsFeedDown, ...
29// for information about the dimuon, use PrintInfo with the appropriate
30// printflag
31// To be used together with AliMUONTrackLight
3d1463c8 32//-----------------------------------------------------------------------------
55fd51b0 33
34
35//MUON classes
36#include "AliMUONPairLight.h"
37//Root classes
38#include "TString.h"
39
40ClassImp(AliMUONPairLight)
41
42//====================================
43AliMUONPairLight::AliMUONPairLight() :
44 TObject(),
45 fMu0(),
46 fMu1(),
47 fCreationProcess(-999),
48 fIsCorrelated(kFALSE),
49 fCauseOfCorrelation (-1),
50 fIsFeedDown(kFALSE)
51{
52 /// default constructor
53 ;
54}
55
56//====================================
57
58AliMUONPairLight::AliMUONPairLight(AliMUONPairLight &dimuCopy)
59 : TObject(dimuCopy),
60 fMu0(dimuCopy.fMu0),
0060b2f7 61 fMu1(dimuCopy.fMu1),
55fd51b0 62 fCreationProcess(dimuCopy.fCreationProcess),
63 fIsCorrelated(dimuCopy.fIsCorrelated),
64 fCauseOfCorrelation (dimuCopy.fCauseOfCorrelation),
65 fIsFeedDown(dimuCopy.fIsFeedDown)
66{
67/// copy constructor
68/// fMu0 = AliMUONTrackLight(dimuCopy.fMu0);
69/// fMu1 = AliMUONTrackLight(dimuCopy.fMu1);
70/// fIsCorrelated = dimuCopy.fIsCorrelated;
71/// fCauseOfCorrelation = dimuCopy.fCauseOfCorrelation;
72/// fCreationProcess = dimuCopy.fCreationProcess;
73/// fIsFeedDown = dimuCopy.fIsFeedDown;
74 ;
75}
76
77//====================================
78
79AliMUONPairLight::~AliMUONPairLight(){
80 /// destructor
81}
82
83//====================================
84
85Bool_t AliMUONPairLight::IsAResonance(){
86 /// checks if muon pair comes from a resonance decay
87 if (!fIsCorrelated) return kFALSE; //if muons not correlated, cannot be a resonance
88 //if muons are correlated, check if the PDG of the
89 //common mother is a resonance
b88403f3 90 Int_t nparents0 = fMu0.GetNParents();
91 Int_t nparents1 = fMu1.GetNParents();
55fd51b0 92
b88403f3 93 Int_t minP = TMath::Min(nparents0, nparents1);
94 for (Int_t i = 0 ; i < minP; i++) {
95 if (fMu0.IsMotherAResonance(nparents0-1-i) && fMu1.IsMotherAResonance(nparents1-1-i) &&
96 fMu0.GetParentPythiaLine(nparents0-1-i)==fMu1.GetParentPythiaLine(nparents1-1-i)) {
97 if (nparents0-1-i) SetFeedDown(nparents0-1-i);
98 return kTRUE;
99 }
100 }
101 return kFALSE;
55fd51b0 102}
103
104//====================================
105
106AliMUONTrackLight* AliMUONPairLight::GetMuon(Int_t index) {
107 /// return muon 0 or 1
108 if (index==0) return &fMu0;
109 else if (index==1) return &fMu1;
110 else{ printf ("Index can be either 0 or 1\n"); return 0;}
111 // else return &fMu1;
112}
113
114//====================================
115
116Int_t AliMUONPairLight::GetMuonMotherPDG(Int_t imuon, Int_t mother) {
117 /// return muon mother pdg code
118 if (imuon==0) return fMu0.GetParentPDGCode(mother);
119 else if (imuon==1) return fMu1.GetParentPDGCode(mother);
120 else { printf ("Index must be only 0 or 1\n"); return -999; }
121}
122
123//====================================
124void AliMUONPairLight::SetProcess(){
125 /// finds the process related to the muon pair (open charm/beauty, resonance,
126 /// uncorrelated...)
b88403f3 127
55fd51b0 128 AliMUONTrackLight *mu1 = &fMu0;
129 AliMUONTrackLight *mu2 = &fMu1;
130
55fd51b0 131 // check if the two muons are correlated
132 // first check if they come from the same hadron (resonance or beauty/charm meson)
133 Int_t npar1 = mu1->GetNParents();
134 Int_t npar2 = mu2->GetNParents();
55fd51b0 135 for (Int_t imoth1 = npar1-1; imoth1>=0; imoth1--) {
136 Int_t lineMo1 = mu1->GetParentPythiaLine(imoth1);
55fd51b0 137 for (Int_t imoth2 = npar2-1; imoth2>=0; imoth2--) {
138 Int_t lineMo2 = mu2->GetParentPythiaLine(imoth2);
139 if(lineMo1 == lineMo2) {
b88403f3 140 //reject "diquark" mothers
141 if(mu1->IsDiquark(mu1->GetParentPDGCode(imoth1)))return;
142// if(IsDiquark(mu1->GetParentPDGCode(imoth1))) return;
55fd51b0 143 this->SetCorrelated(kTRUE);
144 this->SetCauseOfCorrelation(mu1->GetParentPDGCode(imoth1));
145 if(!IsAResonance()) fCreationProcess = 3;
146 else fCreationProcess = -1;
b88403f3 147 return;
55fd51b0 148 }
149 }
150 }
55fd51b0 151 // if Open Beauty/Charm we can have 3 creation processes
152 // (pair creation [0], gluon splitting [1] or flavour excitation [2])
55fd51b0 153 // 1.) gluon splitting: gluon (stored with index 2, id=21) must be the same
b88403f3 154 Int_t flavPar1 = mu1->GetParentFlavour(0);
155 Int_t flavPar2 = mu2->GetParentFlavour(0);
156 for (Int_t imoth1 = 0; imoth1 < 4; imoth1++) {
157 Int_t lineMo1 = mu1->GetQuarkPythiaLine(imoth1);
158 for (Int_t imoth2 = 0; imoth2 < 4; imoth2++) {
159 Int_t lineMo2 = mu2->GetQuarkPythiaLine(imoth2);
160 if(lineMo1 == lineMo2 && mu1->GetQuarkPDGCode(imoth1) == 21) {
161 //now, check also that the string fragmented into two hadrons
162 //of the same flavour (string usually splits into many hadrons
163 //among which there are mostly soft particles)
164 if(flavPar1 == flavPar2){
165 this->SetCorrelated(kTRUE);
166 if(GetCauseOfCorrelation() == -1)
167 this->SetCauseOfCorrelation(mu1->GetQuarkPDGCode(imoth1));
168
169 fCreationProcess = 1;
170 return;
171 }
172 }
55fd51b0 173 }
55fd51b0 174 }
55fd51b0 175 Int_t line1 = mu1->GetQuarkPythiaLine(2); //[2] ... very first quark
176 Int_t line2 = mu2->GetQuarkPythiaLine(2);
b88403f3 177
178 Int_t line6or7[2] = {-1, -1}; //holds the index of quark in line 6 or 7
179 Int_t flavourLine6or7[2] = {-1, -1};
180 // 2.) pair creation: if pythia line 6 of one track *and* pythia line 7 of second track
181 // are filled with a Q and Qbar
182 for (Int_t imoth1 = 3; imoth1>=0; imoth1--) {
183 Int_t lineMo1 = mu1->GetQuarkPythiaLine(imoth1);
184 Int_t flavour1 = TMath::Abs(mu1->GetQuarkPDGCode(imoth1));
185 if(lineMo1 == 6 || lineMo1 == 7){ //track 0 has a mother in line 6 or 7
186 line6or7[0] = imoth1;
187 flavourLine6or7[0] = flavour1;
188 }
189 for (Int_t imoth2 = 3; imoth2>=0; imoth2--) {
190 Int_t lineMo2 = mu2->GetQuarkPythiaLine(imoth2);
191 Int_t flavour2 = TMath::Abs(mu2->GetQuarkPDGCode(imoth2));
192 if(lineMo2 == 6 || lineMo2 == 7){ //track 1 has a mother in line 6 or 7
193 line6or7[1] = imoth2;
194 flavourLine6or7[1] = flavour2;
195 }
196 if((line6or7[0] > 0 && line6or7[1] > 0) && //both tracks must have an entry in line 6 or 7
197 (flavourLine6or7[0] == 4 || flavourLine6or7[0] == 5) && //this entry must be a c or b quark
198 (flavourLine6or7[1] == 4 || flavourLine6or7[1] == 5) && // == " ==
199 (flavPar1 == flavPar2)){ //make sure that the first hadronised parents of the 2 tracks are of the same flavour
200 this->SetCorrelated(kTRUE);
201 fCreationProcess = 0;
202 return;
203 }
55fd51b0 204 }
205 }
206
b88403f3 207
55fd51b0 208 // 3.)flavour excitation:
b88403f3 209 Int_t line2or3[2] = {-1, -1}; //holds the index of g/q in line 2 or 3
210 Int_t flavourLine2or3[2] = {-1, -1};
211 for (Int_t imoth1 = 3; imoth1>=0; imoth1--) {
212 Int_t lineMo1 = mu1->GetQuarkPythiaLine(imoth1);
213 Int_t flavour1 = TMath::Abs(mu1->GetQuarkPDGCode(imoth1));
214 if(lineMo1 == 2 || lineMo1 == 3){ //track 0 has a mother in line 2 or 3
215 line2or3[0] = imoth1;
216 flavourLine2or3[0] = flavour1;
217 }
218 for (Int_t imoth2 = 3; imoth2>=0; imoth2--) {
219 Int_t lineMo2 = mu2->GetQuarkPythiaLine(imoth2);
220 Int_t flavour2 = TMath::Abs(mu2->GetQuarkPDGCode(imoth2));
221 if(lineMo2 == 2 || lineMo2 == 3){ //track 1 has a mother in line 2 or 3
222 line2or3[1] = imoth2;
223 flavourLine2or3[1] = flavour2;
224 }
225 if(((line6or7[0] > 0 && (flavourLine6or7[0] == 4 || flavourLine6or7[0] == 5)) && //first track has Q in line 6 or 7
226 (line2or3[1] > 0 && (flavourLine2or3[1] == 21 || flavourLine2or3[1] < 10))) || //second track has a g/q in line 2 or 3
227 ((line6or7[1] > 0 && (flavourLine6or7[1] == 4 || flavourLine6or7[1] == 5)) && //or the same,
228 (line2or3[0] > 0 && (flavourLine2or3[0] == 21 || flavourLine2or3[0] < 10)))){ // swapping the track's indices
229 //now, check also that the string fragmented into two hadrons
230 //of the same flavour (string usually splits into many hadrons
231 //among which there are mostly soft particles)
232 if(flavPar1 == flavPar2){
233 this->SetCorrelated(kTRUE);
234 fCreationProcess = 2;
235 return;
236 }
237 }
238 }
239 }
240
241 //now flag (rare) processes in which only the incoming parton in line 2 or 3
242 //radiates a gluon which produces a QQbar pair:
243 //exclude the light quarks
244 if(line1 == line2 && (line1 == 2 || line1 == 3)){
245 if((TMath::Abs(mu1->GetQuarkPDGCode(1)) == 4 && TMath::Abs(mu2->GetQuarkPDGCode(1)) == 4) ||
246 (TMath::Abs(mu1->GetQuarkPDGCode(1)) == 5 && TMath::Abs(mu2->GetQuarkPDGCode(1)) == 5)){
247
248 //now, check also that the string fragmented into two hadrons
249 //of the same flavour (string usually splits into many hadrons
250 //among which there are mostly soft particles)
251 if(flavPar1 == flavPar2){
252
253 this->SetCorrelated(kTRUE);
254 fCreationProcess = 1;
255 if(GetCauseOfCorrelation() == -1){
256 this->SetCauseOfCorrelation(mu1->GetQuarkPDGCode(1));
257 }
258 return;
259 }
260 }
55fd51b0 261 }
262}
263
264//====================================
265void AliMUONPairLight::SetMuons(AliMUONTrackLight mu0, AliMUONTrackLight mu1){
266 /// set the two muons
267 fMu0 = mu0;
268 fMu1 = mu1;
269 this->SetProcess();
270}
271
272//====================================
273void AliMUONPairLight::PrintInfo(Option_t* opt){
274 /// print information about muon pairs
275 /// Options:
276 /// - "H" single muons' decay histories
277 /// - "K" dimuon kinematics
278 /// - "F" dimuon flags
279 /// - "A" all variables
280 TString options(opt);
281 options.ToUpper();
282
283 if(options.Contains("H") || options.Contains("A")){//muon decay histories
284
285 AliMUONTrackLight *mu1 = &fMu0;
286 AliMUONTrackLight *mu2 = &fMu1;
287
288 printf("========= History =======================\n");
289 printf("first muon");
290 mu1->PrintInfo("H");
291 printf("second muon");
292 mu2->PrintInfo("H");
293 printf("=========================================\n");
294 }
295 if(options.Contains("F") || options.Contains("A")){//flags
296 printf("the flags set for this muon pair are:\n");
297 printf("=====================================\n");
298 if(this->IsOneTrackNotAMuon()) printf("(*) one rec. track is not a muon\n");
299 fIsCorrelated ? printf("(*) it is a correlated pair\n") : printf("(*) it is not a correlated pair\n");
300 if(IsOpenCharm()) printf("(*) correlated open charm: ");
301 if(IsOpenBeauty()) printf("(*) correlated open beauty: ");
302 if(IsOpenCharm() || IsOpenBeauty()){
303 switch(fCreationProcess){
304 case 0:
305 printf("pair creation");
306 break;
307 case 1:
308 printf("gluon splitting");
309 break;
310 case 2:
311 printf("flavour excitation");
312 break;
313 case 3:
314 printf("both muons come from same fragmented mother");
315 break;
316 }
317 if(this->GetMuon(0)->GetOscillation() || this->GetMuon(1)->GetOscillation())
318 printf("... where oscillation occured\n");
319 else{
320 if(IsOpenBeauty())
321 printf(" (no oscillation)\n");
322 else
323 printf("\n");
324 }
325 }
b88403f3 326 IsAResonance() ? printf("(*) it is a resonance: %d\n", this->GetMuonMotherPDG(0, fIsFeedDown)) : printf("(*) it is not a resonance\n");
327 fIsFeedDown ? printf("(*) mother has feed-down: %d --> %d\n", this->GetMuonMotherPDG(0,fMu0.GetNParents()-2), this->GetMuonMotherPDG(0,fMu0.GetNParents()-1)) : printf("(*) no feed-down\n");
55fd51b0 328 printf("=====================================\n");
329 }
330 if(options.Contains("K") || options.Contains("A")){//dimuon kinematics
331 Double_t *vtx = this->GetMuon(0)->GetVertex();
332 TLorentzVector momRec = this->GetPRec();
333 TLorentzVector momGen = this->GetPGen();
334 printf("the dimuon charge is %d\n", this->GetCharge());
335 printf("primary Vertex: Vx = %1.3f, Vy = %1.3f, Vz = %1.3f\n", vtx[0], vtx[1], vtx[2]);
336 printf("Generated: Px = %1.3f, Py = %1.3f, Pz = %1.3f\n", momGen.Px(), momGen.Py(), momGen.Pz());
337 printf("Reconstructed: Px = %1.3f, Py = %1.3f, Pz = %1.3f\n", momRec.Px(), momRec.Py(), momRec.Pz());
338 //rapidity, pT, angles, ...
339 printf("Rec. variables: pT %1.3f, pseudo-rapidity %1.3f, openingAngle %1.3f (%1.3f degree), theta %1.3f (%1.3f degree), phi %1.3f (%1.3f degree)\n",
340 momRec.Pt(), momRec.Eta(),
341 TMath::Pi()/180.*this->GetOpeningAngle(), this->GetOpeningAngle(),
342 momRec.Theta(), 180./TMath::Pi() * momRec.Theta(),
343 momRec.Phi(), 180./TMath::Pi() * momRec.Phi());
344 }
345}
346
b88403f3 347//====================================
55fd51b0 348Double_t AliMUONPairLight::GetOpeningAngle() {
b88403f3 349 /// opening angle between the two muons in the lab frame (in degrees)
55fd51b0 350 TLorentzVector pRecMu0 = fMu0.GetPRec();
351 TLorentzVector pRecMu1 = fMu1.GetPRec();
352 TVector3 pRecMu03 = pRecMu0.Vect();
353 TVector3 pRecMu13 = pRecMu1.Vect();
354 Double_t scalar = pRecMu03.Dot(pRecMu13);
355 Double_t modMu0 = pRecMu03.Mag();
356 Double_t modMu1 = pRecMu13.Mag();
357 Double_t theta = (TMath::ACos(scalar/(modMu0*modMu1)))*(180./TMath::Pi());
358 return theta;
359}