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. *
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 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 // Compact information for the muon generated tracks in the MUON arm
20 // useful at the last stage of the analysis chain
21 // provides a link between the reconstructed track and the generated particle
22 // stores kinematical information at gen. and rec. level and
23 // the decay history of the muon, allowing the identification of the
26 // To be used together with AliMUONPairLight
28 // This class was prepared by INFN Cagliari, July 2006
29 // (authors: H.Woehri, A.de Falco)
30 //-----------------------------------------------------------------------------
32 #include "AliMUONTrackLight.h"
33 #include "AliMUONTrack.h"
34 #include "AliMUONConstants.h"
36 #include "AliESDMuonTrack.h"
37 #include "AliRunLoader.h"
39 #include "AliHeader.h"
40 #include "AliMUONTrackExtrap.h"
42 #include "TDatabasePDG.h"
43 #include "TClonesArray.h"
44 #include "TParticle.h"
47 ClassImp(AliMUONTrackLight)
49 //===================================================================
51 AliMUONTrackLight::AliMUONTrackLight()
59 fTrackPythiaLine(-999),
65 /// default constructor
66 fPgen.SetPxPyPzE(0.,0.,0.,0.);
67 fPrec.SetPxPyPzE(0.,0.,0.,0.);
68 for (Int_t i=0; i<3; i++) fXYZ[i]=-999;
69 for (Int_t npar = 0; npar < fgkNParentsMax; npar++){
70 fParentPDGCode[npar] = -1;
71 fParentPythiaLine[npar] = -1;
73 for (Int_t i = 0; i < 4; i++){
74 fQuarkPDGCode[i] = -1;
75 fQuarkPythiaLine[i] = -1;
79 //============================================
80 AliMUONTrackLight::AliMUONTrackLight(const AliMUONTrackLight &muonCopy)
82 fPrec(muonCopy.fPrec),
83 fIsTriggered(muonCopy.fIsTriggered),
84 fCharge(muonCopy.fCharge),
85 fChi2(muonCopy.fChi2),
86 fCentr(muonCopy.fCentr),
87 fPgen(muonCopy.fPgen),
88 fTrackPythiaLine(muonCopy.fTrackPythiaLine),
89 fTrackPDGCode(muonCopy.fTrackPDGCode),
90 fOscillation(muonCopy.fOscillation),
91 fNParents(muonCopy.fNParents),
92 fWeight(muonCopy.fWeight)
95 for (Int_t i=0; i<3; i++) fXYZ[i]=muonCopy.fXYZ[i];
96 for (Int_t npar = 0; npar < fgkNParentsMax; npar++){
97 fParentPDGCode[npar] = muonCopy.fParentPDGCode[npar];
98 fParentPythiaLine[npar] = muonCopy.fParentPythiaLine[npar];
100 for (Int_t i = 0; i < 4; i++){
101 fQuarkPDGCode[i] = muonCopy.fQuarkPDGCode[i];
102 fQuarkPythiaLine[i] = muonCopy.fQuarkPythiaLine[i];
106 //============================================
107 AliMUONTrackLight::AliMUONTrackLight(AliESDMuonTrack* muonTrack)
110 fIsTriggered(kFALSE),
115 fTrackPythiaLine(-999),
117 fOscillation(kFALSE),
122 //AliMUONTrackLight();
123 FillFromESD(muonTrack);
126 //============================================
127 AliMUONTrackLight::~AliMUONTrackLight()
132 //============================================
134 void AliMUONTrackLight::FillFromAliMUONTrack(AliMUONTrack *trackReco,Double_t zvert){
135 /// this method sets the muon reconstructed momentum according to the value given by AliMUONTrack
136 AliMUONTrackParam trPar(*((AliMUONTrackParam*) (trackReco->GetTrackParamAtHit()->First())));
137 // AliMUONTrackParam *trPar = trackReco->GetTrackParamAtVertex();
138 AliMUONTrackExtrap::ExtrapToVertex(&trPar,0.,0.,0.);
139 this->SetCharge(Int_t(TMath::Sign(1.,trPar.GetInverseBendingMomentum())));
140 this->SetPxPyPz(trPar.Px(),trPar.Py(), trPar.Pz());
141 this->SetTriggered(trackReco->GetMatchTrigger());
143 Double_t xyz[3] = { trPar.GetNonBendingCoor(),
144 trPar.GetBendingCoor(),
146 this->SetVertex(xyz);
149 //============================================
150 void AliMUONTrackLight::FillFromESD(AliESDMuonTrack* muonTrack,Double_t zvert){
151 /// computes prec and charge from ESD track
152 Double_t mumass = TDatabasePDG::Instance()->GetParticle(13)->Mass();
153 Double_t thetaX = muonTrack->GetThetaX();
154 Double_t thetaY = muonTrack->GetThetaY();
155 Double_t tanthx = TMath::Tan(thetaX);
156 Double_t tanthy = TMath::Tan(thetaY);
157 Double_t pYZ = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum());
158 Double_t pz = - pYZ / TMath::Sqrt(1.0 + tanthy * tanthy);
159 Double_t px = pz * tanthx;
160 Double_t py = pz * tanthy;
161 fCharge = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum()));
162 Double_t energy = TMath::Sqrt(mumass * mumass + px*px + py*py + pz*pz);
163 fPrec.SetPxPyPzE(px,py,pz,energy);
165 fXYZ[0] = muonTrack->GetNonBendingCoor();
166 fXYZ[1] = muonTrack->GetBendingCoor();
167 if (zvert==-9999) fXYZ[2] = muonTrack->GetZ();
168 else fXYZ[2] = zvert;
169 // get the chi2 per d.o.f.
170 fChi2 = muonTrack->GetChi2()/ (2.0 * muonTrack->GetNHit() - 5);
171 fIsTriggered = muonTrack->GetMatchTrigger();
174 //============================================
175 void AliMUONTrackLight::SetPxPyPz(Double_t px, Double_t py, Double_t pz){
176 /// set the reconstructed 4-momentum, assuming the particle is a muon
177 Double_t mumass = TDatabasePDG::Instance()->GetParticle(13)->Mass();
178 Double_t energy = TMath::Sqrt(mumass * mumass + px*px + py*py + pz*pz);
179 fPrec.SetPxPyPzE(px,py,pz,energy);
182 //============================================
183 TParticle* AliMUONTrackLight::FindRefTrack(AliMUONTrack* trackReco, TClonesArray* trackRefArray, AliRunLoader *runLoader){
184 /// find the MC particle that corresponds to a given rec track
186 const Double_t kSigma2Cut = 16; // 4 sigmas cut, kSigma2Cut = 4*4
187 Int_t nTrackRef = trackRefArray->GetEntriesFast();
189 for (Int_t iref = 0; iref < nTrackRef; iref++) {
190 AliMUONTrack *trackRef = (AliMUONTrack *)trackRefArray->At(iref);
191 // check if trackRef is compatible with trackReco:
192 //routine returns for each chamber a yes/no information if the
193 //hit of rec. track and hit of referenced track are compatible
194 Bool_t *compTrack = trackRef->CompatibleTrack(trackReco,kSigma2Cut);
195 Int_t iTrack = this->TrackCheck(compTrack); //returns number of validated conditions
198 Int_t trackID = trackRef->GetTrackID();
199 this->SetTrackPythiaLine(trackID);
200 part = ((AliStack *)(((AliHeader *) runLoader->GetHeader())->Stack()))->Particle(trackID);
201 fTrackPDGCode = part->GetPdgCode();
205 printf ("<AliMUONTrackLight::FindRefTrack> ERROR: more than one particle compatible to the reconstructed track.\n");
207 printf ("j=%d \n",j);
212 //============================================
213 Int_t AliMUONTrackLight::TrackCheck(Bool_t *compTrack){
214 /// Apply reconstruction requirements
215 /// Return number of validated conditions
216 /// If all the tests are verified then TrackCheck = 4 (good track)
218 Int_t hitsInLastStations = 0;
220 // apply reconstruction requirements
221 if (compTrack[0] || compTrack[1]) iTrack++; // at least one hit in st. 0
222 if (compTrack[2] || compTrack[3]) iTrack++; // at least one hit in st. 1
223 if (compTrack[4] || compTrack[5]) iTrack++; // at least one hit in st. 2
224 for (Int_t ch = 6; ch < AliMUONConstants::NTrackingCh(); ch++) {
225 if (compTrack[ch]) hitsInLastStations++;
227 if (hitsInLastStations > 2) iTrack++; // at least 3 hits in st. 3 & 4
231 //============================================
232 void AliMUONTrackLight::FillMuonHistory(AliRunLoader *runLoader, TParticle *part){
233 /// scans the muon history to determine parents pdg code and pythia line
234 // kept for backward compatibility
235 // see the overloaded method FillMuonHistory(AliStack *stack, TParticle *part)
236 AliStack *stack = runLoader->GetHeader()->Stack();
237 FillMuonHistory(stack,part);
240 //============================================
241 void AliMUONTrackLight::FillMuonHistory(AliStack *stack, TParticle *part){
242 /// scans the muon history to determine parents pdg code and pythia line
244 Int_t parents[10], parLine[10];
245 Int_t lineM = part->GetFirstMother();//line in the Pythia output of the particle's mother
248 Int_t status=-1, pdg=-1;
251 mother = stack->Particle(lineM); //direct mother of rec. track
252 pdg = mother->GetPdgCode();//store PDG code of first mother
253 // break if a string, gluon, quark or diquark is found
254 if(pdg == 92 || pdg == 21 || TMath::Abs(pdg) < 10 || IsDiquark(pdg)) break;
255 parents[++countP] = pdg;
256 parLine[countP] = lineM;
257 status = mother->GetStatusCode();//get its status code to check if oscillation occured
258 if(IsB0(parents[countP]) && status == 12) this->SetOscillation(kTRUE);
259 lineM = mother->GetFirstMother();
261 //store all the fragmented parents in an array:
262 for(int i = 0; i <= countP; i++){
263 this->SetParentPDGCode(i,parents[countP-i]);
264 this->SetParentPythiaLine(i,parLine[countP-i]);
266 fNParents = countP+1;
269 //and store the lines of the string and further quarks in another array:
271 mother = stack->Particle(lineM);
272 pdg = mother->GetPdgCode();
273 //now, get information before the fragmentation
274 this->SetQuarkPythiaLine(++countP, lineM);//store the line of the string in index 0
275 this->SetQuarkPDGCode(countP, pdg);//store the pdg of the quarks in index 1,2
276 lineM = mother->GetFirstMother();
279 //check if in case of HF production, the string points to the correct end
280 //and correct it in case of need:
282 for(int par = 0; par < 4; par++){
283 if(TMath::Abs(this->GetQuarkPDGCode(par)) < 6){
284 countP = par; //get the quark just before hadronisation
288 if(this->GetQuarkPythiaLine(countP) > -1 && (this->GetParentFlavour(0)==4 || this->GetParentFlavour(0)==5)){
289 if(this->GetParentFlavour(0) != TMath::Abs(this->GetQuarkPDGCode(countP))){
291 printf("quark flavour of parent and that of quark do not correspond: %d %d --> correcting\n", this->GetParentFlavour(0), TMath::Abs(this->GetQuarkPDGCode(countP)));
292 Int_t pdg = this->GetQuarkPDGCode(countP), line = this->GetQuarkPythiaLine(countP);
293 this->ResetQuarkInfo();
294 while(TMath::Abs(pdg) != this->GetParentFlavour(0)){//pdg of q,g in Pythia listing following the wrong string end
295 //must coincide with the flavour of the last fragmented mother
297 pdg = stack->Particle(++line)->GetPdgCode();
299 //now, we have the correct string end and the correct line
300 //continue to fill again all parents and corresponding lines
302 mother = stack->Particle(line);//get again the mother
303 pdg = mother->GetPdgCode();
304 this->SetQuarkPythiaLine(countP, line);
305 this->SetQuarkPDGCode(countP++, pdg);
306 line = mother->GetFirstMother();
308 this->PrintInfo("h");
313 //====================================
314 void AliMUONTrackLight::ResetQuarkInfo(){
315 /// resets parton information
316 for(int pos = 1; pos < 4; pos++){//[0] is the string
317 this->SetQuarkPDGCode(pos,-1);
318 this->SetQuarkPythiaLine(pos,-1);
322 //====================================
323 Bool_t AliMUONTrackLight::IsB0(Int_t intTest) const {
324 /// checks if the particle is a B0
325 Int_t bMes0[2] = {511,531};//flavour code of B0d and B0s
326 Bool_t answer = kFALSE;
327 for(int i = 0; i < 2; i++){
328 if(TMath::Abs(intTest) == bMes0[i]){
335 //====================================
336 Bool_t AliMUONTrackLight::IsMotherAResonance(Int_t index) const {
337 /// checks if mother is a resonance
338 Int_t intTest = GetParentPDGCode(index);
339 // the resonance pdg code is built this way
340 // x00ffn where x=0,1,.. (1S,2S... states), f=quark flavour
341 Int_t id=intTest%100000;
342 return (!((id-id%10)%110));
344 //====================================
345 Int_t AliMUONTrackLight::GetParentFlavour(Int_t idParent) const {
346 /// returns the flavour of parent idParent (idParent=0 is the oldest
347 /// hadronized parent)
348 Int_t pdg = GetParentPDGCode(idParent);
349 Int_t quark = TMath::Abs(pdg/100);
350 if(quark > 9) quark = quark/10;
354 //====================================
355 void AliMUONTrackLight::PrintInfo(Option_t* opt){
356 /// prints information about the track:
357 /// - "H" muon's decay history
358 /// - "K" muon kinematics
359 /// - "A" all variables
360 TString options(opt);
363 if(options.Contains("H") || options.Contains("A")){ //muon decay history
364 char *name= new char[100];
365 TString pdg = "", line = "";
366 for(int i = 3; i >= 0; i--){
367 if(this->GetQuarkPythiaLine(i)>= 0){
368 sprintf(name, "%4d --> ", this->GetQuarkPythiaLine(i));
370 sprintf(name, "%4d --> ", this->GetQuarkPDGCode(i));
374 for(int i = 0; i < fNParents; i++){
375 if(this->GetParentPythiaLine(i)>= 0){
376 sprintf(name, "%7d --> ", this->GetParentPythiaLine(i));
378 sprintf(name, "%7d --> ", this->GetParentPDGCode(i));
382 sprintf(name, "%4d", this->GetTrackPythiaLine()); line += name;
383 sprintf(name, "%4d", this->GetTrackPDGCode()); pdg += name;
385 printf("\nmuon's decay history:\n");
386 printf(" PDG: %s\n", pdg.Data());
387 printf("line: %s\n", line.Data());
389 if(options.Contains("K") || options.Contains("A")){ //muon kinematic
391 Int_t charge = this->GetCharge();
392 Double_t *vtx = this->GetVertex();
393 TLorentzVector momRec = this->GetPRec();
394 TLorentzVector momGen = this->GetPGen();
395 printf("the track's charge is %d\n", charge);
396 printf("Primary vertex: Vx = %1.3f, Vy = %1.3f, Vz = %1.3f\n", vtx[0], vtx[1], vtx[2]);
397 printf("Generated: Px = %1.3f, Py = %1.3f, Pz = %1.3f\n", momGen.Px(), momGen.Py(), momGen.Pz());
398 printf("Reconstructed: Px = %1.3f, Py = %1.3f, Pz = %1.3f\n", momRec.Px(), momRec.Py(), momRec.Pz());
399 printf("Rec. variables: pT %1.3f, pseudo-rapidity %1.3f, theta %1.3f (%1.3f degree), phi %1.3f (%1.3f degree)\n",
400 momRec.Pt(), momRec.Eta(), momRec.Theta(), 180./TMath::Pi() * momRec.Theta(),
401 momRec.Phi(), 180./TMath::Pi() * momRec.Phi());
404 //====================================
405 Bool_t AliMUONTrackLight::IsParentPionOrKaon(Int_t idparent){
406 /// checks if a muon comes from a pion or kaon or a particle that decays into one of these two
407 Int_t pdg = this->GetParentPDGCode(idparent);
408 if (TMath::Abs(pdg)==211 || //pi+
409 TMath::Abs(pdg)==321 || //K+
410 TMath::Abs(pdg)==213 || //rho+
411 TMath::Abs(pdg)==311 || //K0
412 TMath::Abs(pdg)==313 || //K*0
413 TMath::Abs(pdg)==323 //K*+
419 //====================================
420 Bool_t AliMUONTrackLight::IsDiquark(Int_t pdg){
421 /// check if the provided pdg code corresponds to a diquark
422 pdg = TMath::Abs(pdg);
423 if((pdg > 1000) && (pdg%100 < 10)) return kTRUE;