2 #include <TLorentzVector.h>
3 #include <TClonesArray.h>
5 #include "AliMCEventHandler.h"
6 #include "AliMCEvent.h"
8 #include "AliAODMCParticle.h"
9 #include "AliESDEvent.h"
10 #include "AliESDMuonTrack.h"
11 #include "AliESDMuonCluster.h"
12 #include "AliAODTrack.h"
13 #include "AliAODMuonTrack.h"
14 #include "AliMCMuonTrack.h"
16 ClassImp(AliMCMuonTrack)
18 const Double_t AliMCMuonTrack::fgkSigmaCut = 10.;
20 //-----------------------------------------------------------------------------
21 AliMCMuonTrack::AliMCMuonTrack() :
33 // default constructor
35 for (Int_t i=0; i<fgkNParentsMax; i++) {
37 fParentPDGCode[i] = 0;
39 for (Int_t i=0; i<4; i++) {
45 //-----------------------------------------------------------------------------
46 AliMCMuonTrack::AliMCMuonTrack(AliAODTrack *trkAOD, TClonesArray *mcClArr, Bool_t full) :
47 AliAODMuonTrack(trkAOD),
58 // default constructor
60 AliAODMCParticle *pMC = this->FindTrackRef(trkAOD, mcClArr);
61 if (pMC) this->SetMCInfo(pMC, mcClArr);
64 //-----------------------------------------------------------------------------
65 AliMCMuonTrack::AliMCMuonTrack(AliESDMuonTrack *trkESD, AliESDEvent *esd, AliMCEventHandler *mcH, Bool_t full) :
66 AliAODMuonTrack(trkESD),
77 // default constructor
79 TParticle *pMC = this->FindTrackRef(trkESD, esd, mcH); // do nothing when running on official train
80 if (pMC) this->SetMCInfo(pMC, mcH);
81 // MC infomation is not implement when running on the official train for they depend on the MUON module.
82 // In the case of private running, one can get the information from ESD by uncommenting the definitions
83 // of FindTrackRef() and CovESDtoMuonTrack()
84 // and including the following head files in both AliMCMuonTrack.h and this file,
85 // #include "AliMUONRecoCheck.h"
86 // #include "AliMUONVTrackStore.h"
87 // #include "AliMUONVClusterStore.h"
88 // #include "AliMUONTrackParam.h"
89 // #include "AliMUONTrack.h"
90 // #include "AliMUONVCluster.h"
91 // #include "AliMUONESDInterface.h"
96 //-----------------------------------------------------------------------------
97 AliMCMuonTrack::~AliMCMuonTrack()
104 //-----------------------------------------------------------------------------
105 AliAODMCParticle* AliMCMuonTrack::FindTrackRef(AliAODTrack *trkAOD, TClonesArray *mcClArr)
107 AliAODMCParticle *pMC = 0;
108 fTrackIndex = trkAOD->GetLabel();
110 pMC = (AliAODMCParticle*)mcClArr->At(fTrackIndex);
114 //-----------------------------------------------------------------------------
115 TParticle* AliMCMuonTrack::FindTrackRef(AliESDMuonTrack *trkESD, AliESDEvent *esd, AliMCEventHandler *mcH)
117 TParticle *pMCRef = 0;
119 /*AliMUONTrack *trkMuon = CovESDtoMuonTrack(*trkESD);
120 AliMUONRecoCheck rc(esd,mcH);
121 AliMUONVTrackStore* trkRefArr = rc.TrackRefs(-1);
122 TIter next(trkRefArr->CreateIterator());
123 AliMUONTrack* trkRef = 0;
124 while ((trkRef=static_cast<AliMUONTrack*>(next()))) {
125 Bool_t trkCompArr[10];
126 Int_t nMatchClusters = trkMuon->CompatibleTrack(trkRef, fgkSigmaCut, trkCompArr);
127 Double_t matchClusterFrac = ((Double_t)nMatchClusters) / ((Double_t)trkMuon->GetNClusters());
128 if ((trkCompArr[0] || trkCompArr[1] || trkCompArr[2] || trkCompArr[3]) &&
129 (trkCompArr[6] || trkCompArr[7] || trkCompArr[8] || trkCompArr[9]) && matchClusterFrac>0.5) {
130 fTrackIndex = trkRef->GetUniqueID();
131 trkRefArr->Remove(*trkRef);
135 if (fTrackIndex>=0) pMCRef = mcH->MCEvent()->Stack()->Particle(fTrackIndex);*/
140 //-----------------------------------------------------------------------------
141 void AliMCMuonTrack::SetMCInfo(AliAODMCParticle *pMC, TClonesArray *mcClArr)
143 fPGen.SetPxPyPzE(pMC->Px(), pMC->Py(), pMC->Pz(), pMC->E());
144 fTrackPDGCode = pMC->GetPdgCode();
145 if (TMath::Abs(fTrackPDGCode)!=13) {
150 Int_t lineM = pMC->GetMother();
157 ((AliAODMCParticle*)mcClArr->At(lineM))->IsPrimary();
163 this->FillHistoryParents(lineM, mcClArr);
164 fSource = this->SelectHFMuon();
168 //-----------------------------------------------------------------------------
169 void AliMCMuonTrack::SetMCInfo(TParticle *pMC, AliMCEventHandler *mcH)
171 fPGen.SetPxPyPzE(pMC->Px(), pMC->Py(), pMC->Pz(), pMC->Energy());
172 fTrackPDGCode = pMC->GetPdgCode();
173 if (TMath::Abs(fTrackPDGCode)!=13) {
178 Int_t lineM = pMC->GetFirstMother();
184 AliStack *stack = mcH->MCEvent()->Stack();
185 if (lineM>=stack->GetNprimary()) {
190 this->FillHistoryParents(lineM, stack);
191 fSource = this->SelectHFMuon();
195 //-----------------------------------------------------------------------------
196 void AliMCMuonTrack::FillHistoryParents(Int_t lineM, TClonesArray *mcClArr)
198 Int_t countP=-1, pdg=0;
199 Int_t parents[10], parLine[10];
200 AliAODMCParticle *mother = 0;
202 mother = (AliAODMCParticle*)mcClArr->At(lineM);
203 pdg = mother->GetPdgCode();
204 if(pdg==92 || pdg==21 || TMath::Abs(pdg)<10 || IsDiquark(pdg)) break;
205 parents[++countP] = pdg;
206 parLine[countP] = lineM;
207 lineM = mother->GetMother();
209 for(Int_t i=0; i<=countP; i++){
210 fParentIndex[i] = parLine[countP-i];
211 fParentPDGCode[i] = parents[countP-i];
213 fNParents = countP + 1;
215 if (fIsFull && lineM>=0) this->FillHistoryQuarks(lineM, mcClArr);
219 //-----------------------------------------------------------------------------
220 void AliMCMuonTrack::FillHistoryParents(Int_t lineM, AliStack *stack)
222 Int_t countP=-1, pdg=0;
223 Int_t parents[10], parLine[10];
224 TParticle *mother = 0;
226 mother = stack->Particle(lineM);
227 pdg = mother->GetPdgCode();
228 if(pdg==92 || pdg==21 || TMath::Abs(pdg)<10 || IsDiquark(pdg)) break;
229 parents[++countP] = pdg;
230 parLine[countP] = lineM;
231 lineM = mother->GetFirstMother();
233 for(Int_t i=0; i<=countP; i++){
234 fParentIndex[i] = parLine[countP-i];
235 fParentPDGCode[i] = parents[countP-i];
237 fNParents = countP + 1;
239 if (fIsFull && lineM>=0) this->FillHistoryQuarks(lineM, stack);
243 //-----------------------------------------------------------------------------
244 void AliMCMuonTrack::FillHistoryQuarks(Int_t lineM, TClonesArray *mcClArr)
246 // method in $ALICE_ROOT/MUON/AliMUONTrackLight.cxx
248 Int_t countP=-1, pdg=0;
249 AliAODMCParticle *mother = 0;
251 mother = (AliAODMCParticle*)mcClArr->At(lineM);
252 pdg = mother->GetPdgCode();
253 fQuarkIndex[++countP] = lineM;
254 fQuarkPDGCode[countP] = pdg;
255 lineM = mother->GetMother();
258 // for PYTHIA checking
260 for(Int_t par=0; par<4; par++) {
261 if(TMath::Abs(this->GetQuarkPDGCode(par))<6) { countP=par; break; }
263 if(this->GetQuarkIndex(countP)>-1 && (this->GetParentFlavour(0)==4 || this->GetParentFlavour(0)==5)) {
264 if(this->GetParentFlavour(0)!=TMath::Abs(this->GetQuarkPDGCode(countP))) {
265 AliWarning(Form("quark flavour of parent and that of quark do not correspond: %d %d --> correcting\n",
266 this->GetParentFlavour(0), TMath::Abs(this->GetQuarkPDGCode(countP))));
268 pdg = this->GetQuarkPDGCode(countP);
269 Int_t line = this->GetQuarkIndex(countP);
270 this->ResetQuarkInfo();
271 while(TMath::Abs(pdg)!=this->GetParentFlavour(0)) {
272 pdg = ((AliAODMCParticle*)mcClArr->At(++line))->GetPdgCode();
275 mother = (AliAODMCParticle*)mcClArr->At(line);
276 pdg = mother->GetPdgCode();
277 fQuarkIndex[countP] = line;
278 fQuarkPDGCode[countP++] = pdg;
279 line = mother->GetMother();
286 //-----------------------------------------------------------------------------
287 void AliMCMuonTrack::FillHistoryQuarks(Int_t lineM, AliStack *stack)
289 // method in $ALICE_ROOT/MUON/AliMUONTrackLight.cxx
291 Int_t countP=-1, pdg=0;
292 TParticle *mother = 0;
294 mother = stack->Particle(lineM);
295 pdg = mother->GetPdgCode();
296 fQuarkIndex[++countP] = lineM;
297 fQuarkPDGCode[countP] = pdg;
298 lineM = mother->GetFirstMother();
301 // for PYTHIA checking
303 for(Int_t par=0; par<4; par++) {
304 if(TMath::Abs(this->GetQuarkPDGCode(par))<6) { countP=par; break; }
306 if(this->GetQuarkIndex(countP)>-1 && (this->GetParentFlavour(0)==4 || this->GetParentFlavour(0)==5)) {
307 if(this->GetParentFlavour(0)!=TMath::Abs(this->GetQuarkPDGCode(countP))) {
308 AliWarning(Form("quark flavour of parent and that of quark do not correspond: %d %d --> correcting\n",
309 this->GetParentFlavour(0), TMath::Abs(this->GetQuarkPDGCode(countP))));
311 pdg = this->GetQuarkPDGCode(countP);
312 Int_t line = this->GetQuarkIndex(countP);
313 this->ResetQuarkInfo();
314 while(TMath::Abs(pdg)!=this->GetParentFlavour(0)) {
315 pdg = stack->Particle(++line)->GetPdgCode();
318 mother = stack->Particle(line);
319 pdg = mother->GetPdgCode();
320 fQuarkIndex[countP] = line;
321 fQuarkPDGCode[countP++] = pdg;
322 line = mother->GetFirstMother();
329 //-----------------------------------------------------------------------------
330 /*AliMUONTrack* AliMCMuonTrack::CovESDtoMuonTrack(AliESDMuonTrack &trkESD)
332 // method in $ALICE_ROOT/PWG3/muondep/AliAnalysisTaskESDMCLabelAddition.cxx
333 AliMUONTrack *trkMuon = new AliMUONTrack();
334 if(!trkESD.ClustersStored()) return trkMuon;
336 AliMUONTrackParam param;
337 AliMUONESDInterface::GetParamAtFirstCluster(trkESD, param);
338 AliMUONESDInterface::GetParamCov(trkESD, param);
339 AliMUONVClusterStore *cStore = AliMUONESDInterface::NewClusterStore();
340 AliMUONVCluster *cluster = cStore->CreateCluster(0,0,0);
342 AliESDMuonCluster *esdCluster = (AliESDMuonCluster*)trkESD.GetClusters().First();
344 AliMUONESDInterface::ESDToMUON(*esdCluster, *cluster);
345 param.SetZ(cluster->GetZ());
346 trkMuon->AddTrackParamAtCluster(param, *cluster, kTRUE);
347 esdCluster = (AliESDMuonCluster*)trkESD.GetClusters().After(esdCluster);
350 delete cluster; cluster = 0;
351 delete cStore; cStore = 0;
355 //-----------------------------------------------------------------------------
356 Int_t AliMCMuonTrack::SelectHFMuon()
358 Int_t flv = GetParentFlavour(0);
359 if (flv!=4 && flv!=5) return 2;
361 Bool_t isRes = kFALSE;
362 Int_t i=0, nparents=this->GetNParents();
363 while (i<nparents && !isRes) {
364 isRes = IsMotherAResonance(i++);
368 if (flv==5) return 0;
372 //-----------------------------------------------------------------------------
373 Bool_t AliMCMuonTrack::IsDiquark(Int_t pdg)
375 // copy from $ALICE_ROOT/MUON/AliMUONTrackLight.cxx
376 pdg = TMath::Abs(pdg);
377 if(pdg>1000 && (pdg%100)<10) return kTRUE;
381 //-----------------------------------------------------------------------------
382 void AliMCMuonTrack::ResetQuarkInfo()
384 for(Int_t pos=1; pos<4; pos++) {
385 fQuarkIndex[pos] = -1;
386 fQuarkPDGCode[pos] = 0;
391 //-----------------------------------------------------------------------------
392 Int_t AliMCMuonTrack::GetParentFlavour(Int_t i) const
394 Int_t pdg = GetParentPDGCode(i);
395 pdg = TMath::Abs(pdg/100);
400 //-----------------------------------------------------------------------------
401 Bool_t AliMCMuonTrack::IsMotherAResonance(Int_t i) const
403 // copy from $ALICE_ROOT/MUON/AliMUONTrackLight.cxx
404 Int_t pdg = GetParentPDGCode(i);
406 return (!((id-id%10)%110));