1 #ifndef ALIANALYSISTASKMUONTREEBUILDER_CXX
2 #define ALIANALYSISTASKMUONTREEBUILDER_CXX
6 #include "AliAnalysisTaskMuonTreeBuilder.h"
7 #include "AliMCEvent.h"
8 #include "AliESDMuonTrack.h"
9 #include "AliESDVertex.h"
11 #include "AliHeader.h"
12 #include "AliESDHeader.h"
13 #include "TParticle.h"
14 #include "TLorentzVector.h"
17 #include "AliAnalysisManager.h"
18 #include "AliESDEvent.h"
19 #include "AliAODEvent.h"
21 #include "AliESDtrack.h"
23 #include "AliESDtrack.h"
24 #include "AliESDInputHandler.h"
26 #include "AliPhysicsSelection.h"
27 #include "AliMultiplicity.h"
29 // Analysis task for muon-dimuon analysis
30 // Works for real and MC events
31 // Works with the corresponding AddTask macro
32 // Includes a flag for physics selection
34 // author: L. Bianchi - Universita' & INFN Torino
36 ClassImp(AliAnalysisTaskMuonTreeBuilder)
38 //__________________________________________________________________________
39 AliAnalysisTaskMuonTreeBuilder::AliAnalysisTaskMuonTreeBuilder() :
55 //___________________________________________________________________________
56 AliAnalysisTaskMuonTreeBuilder::AliAnalysisTaskMuonTreeBuilder(const Char_t* name) :
57 AliAnalysisTaskSE(name),
70 // Constructor. Initialization of Inputs and Outputs
72 Info("AliAnalysisTaskMuonTreeBuilder","Calling Constructor");
74 DefineOutput(1,TTree::Class());
77 //___________________________________________________________________________
78 AliAnalysisTaskMuonTreeBuilder& AliAnalysisTaskMuonTreeBuilder::operator=(const AliAnalysisTaskMuonTreeBuilder& c)
81 // Assignment operator
84 AliAnalysisTaskSE::operator=(c) ;
90 //___________________________________________________________________________
91 AliAnalysisTaskMuonTreeBuilder::AliAnalysisTaskMuonTreeBuilder(const AliAnalysisTaskMuonTreeBuilder& c) :
94 fBeamEnergy(c.fBeamEnergy),
96 fOutputTree(c.fOutputTree),
99 fNumMuonTracks(c.fNumMuonTracks),
100 fNumSPDTracklets(c.fNumSPDTracklets),
101 fNumContributors(c.fNumContributors),
102 fNumDimuons(c.fNumDimuons)
105 // Copy Constructor FIDUCIAL REGIONS?
109 //___________________________________________________________________________
110 AliAnalysisTaskMuonTreeBuilder::~AliAnalysisTaskMuonTreeBuilder() {
114 Info("~AliAnalysisTaskMuonTreeBuilder","Calling Destructor");
117 //___________________________________________________________________________
118 void AliAnalysisTaskMuonTreeBuilder::UserCreateOutputObjects(){
121 // Creating User-Defined Output Objects
124 // TREE OUTPUT----------------------------------------------------------
126 fOutputTree = new TTree("krec","Tree of reconstructed muons");
128 fOutputTree->Branch("IsSelected",&fIsSelected,"IsSelected/O");
129 fOutputTree->Branch("FiredTriggerClasses",fTrigClass,"FiredTriggerClasses/C");
131 fOutputTree->Branch("NumMuonTracks",&fNumMuonTracks,"NumMuonTracks/I");
132 fOutputTree->Branch("NumContributors",&fNumContributors,"NumContributors/I");
133 fOutputTree->Branch("NumSPDTracklets",&fNumSPDTracklets,"NumSPDTraclets/I");
134 fOutputTree->Branch("Vertex",fVertex,"Vertex[3]/D");
135 fOutputTree->Branch("pT",fpT,"pT[10]/D");
136 fOutputTree->Branch("E",fE,"E[10]/D");
137 fOutputTree->Branch("px",fpx,"px[10]/D");
138 fOutputTree->Branch("py",fpy,"py[10]/D");
139 fOutputTree->Branch("pz",fpz,"pz[10]/D");
140 fOutputTree->Branch("pxUncorr",fpxUncorr,"pxUncorr[10]/D");
141 fOutputTree->Branch("pyUncorr",fpyUncorr,"pyUncorr[10]/D");
142 fOutputTree->Branch("pzUncorr",fpzUncorr,"pzUncorr[10]/D");
143 fOutputTree->Branch("y",fy,"y[10]/D");
144 fOutputTree->Branch("eta",feta,"eta[10]/D");
145 fOutputTree->Branch("phi",fphi,"phi[10]/D");
146 fOutputTree->Branch("MatchTrig",fMatchTrig,"MatchTrig[10]/I");
147 fOutputTree->Branch("TrackChi2",fTrackChi2,"TrackChi2[10]/D");
148 fOutputTree->Branch("MatchTrigChi2",fMatchTrigChi2,"MatchTrigChi2[10]/D");
149 fOutputTree->Branch("DCA",fDCA,"DCA[10]/D");
150 fOutputTree->Branch("Charge",fCharge,"Charge[10]/S");
151 fOutputTree->Branch("MuFamily",fMuFamily,"MuFamily[10]/I");
152 fOutputTree->Branch("RAtAbsEnd",fRAtAbsEnd,"RAtAbsEnd[10]/D");
154 fOutputTree->Branch("NumDimuons",&fNumDimuons,"NumDimuons/I");
155 fOutputTree->Branch("DimuConstituent",fDimuonConstituent,"DimuonConstituent[45][2]/I");
156 fOutputTree->Branch("pTdimuon",fpTdimuon,"pTdimuon[45]/D");
157 fOutputTree->Branch("pxdimuon",fpxdimuon,"pxdimuon[45]/D");
158 fOutputTree->Branch("pydimuon",fpydimuon,"pydimuon[45]/D");
159 fOutputTree->Branch("pzdimuon",fpzdimuon,"pzdimuon[45]/D");
160 fOutputTree->Branch("ydimuon",fydimuon,"ydimuon[45]/D");
161 fOutputTree->Branch("Imassdimuon",fiMassdimuon,"iMassdimuon[45]/D");
162 fOutputTree->Branch("costCS",fcostCS,"costCS[45]/D");
163 fOutputTree->Branch("costHE",fcostHE,"costHE[45]/D");
164 fOutputTree->Branch("phiCS",fphiCS,"phiCS[45]/D");
165 fOutputTree->Branch("phiHE",fphiHE,"phiHE[45]/D");
167 fOutputTree->Branch("PDG",fPDG,"PDG[10]/I");
168 fOutputTree->Branch("PDGmother",fPDGmother,"PDGmother[10]/I");
169 fOutputTree->Branch("PDGdimu",fPDGdimu,"PDGdimu[45]/I");
175 //_________________________________________________
176 void AliAnalysisTaskMuonTreeBuilder::UserExec(Option_t *)
186 fNumSPDTracklets=666;
187 fNumContributors=666;
190 fVertex[0]=666.; fVertex[1]=666.; fVertex[2]=666.;
191 for(Int_t i=0; i<10;i++){
205 fMatchTrigChi2[i]=666.;
213 for(Int_t i=0; i<45;i++){
214 fDimuonConstituent[i][0]=666; fDimuonConstituent[i][1]=666;
220 fiMassdimuon[i]=666.;
233 AliESDEvent *fESD = 0x0;
234 AliMCEvent* mcEvent = 0x0;
238 Error("UserExec","NO MC EVENT FOUND!");
243 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
245 fIsSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
247 fNumMuonTracks = fESD->GetNumberOfMuonTracks() ;
248 Int_t loopEnd = fNumMuonTracks;
250 TString cla = fESD->GetFiredTriggerClasses();
251 sprintf(fTrigClass,"%s",cla.Data());
254 if(fNumMuonTracks>0 && fIsMC){
257 fNumContributors = fESD->GetPrimaryVertexSPD()->GetNContributors();
258 fNumSPDTracklets = fESD->GetMultiplicity()->GetNumberOfTracklets();
259 fVertex[0]=fESD->GetPrimaryVertexSPD()->GetX();
260 fVertex[1]=fESD->GetPrimaryVertexSPD()->GetY();
261 fVertex[2]=fESD->GetPrimaryVertexSPD()->GetZ();
262 printf("fVertex : %f - %f - %f\n",fVertex[0],fVertex[1],fVertex[2]);
265 for (Int_t j = 0; j<loopEnd; j++) {
266 AliESDMuonTrack* mu1 = new AliESDMuonTrack(*(fESD->GetMuonTrack(j)));
267 if (!mu1->ContainTrackerData()) {fNumMuonTracks=fNumMuonTracks-1; continue;}
268 Double_t charge1 = mu1->Charge();
269 fCharge[j] = mu1->Charge();
274 fpxUncorr[j] = mu1->PxUncorrected();
275 fpyUncorr[j] = mu1->PyUncorrected();
276 fpzUncorr[j] = mu1->PzUncorrected();
278 feta[j] = mu1->Eta();
279 fphi[j] = Phideg(mu1->Phi());
280 Double_t emu1 = mu1->E();
282 fDCA[j] = mu1->GetDCA();
283 fTrackChi2[j] = mu1->GetChi2();
284 fMatchTrig[j] = mu1->GetMatchTrigger();
285 fMatchTrigChi2[j]= mu1->GetChi2MatchTrigger();
286 fRAtAbsEnd[j]=mu1->GetRAtAbsorberEnd();
288 AliMCParticle* mcTrack = 0x0;
290 if(mu1->GetLabel()==-1) continue;
291 mcTrack = (AliMCParticle*)mcEvent->GetTrack(mu1->GetLabel());
292 fPDG[j] = mcTrack->PdgCode();
293 if (mcTrack->GetMother()==-1) continue;
294 fPDGmother[j] = ((AliMCParticle*)mcEvent->GetTrack(mcTrack->GetMother()))->PdgCode();
295 if (TMath::Abs(fPDG[j])==13) fMuFamily[j] = FindMuFamily(mcTrack,mcEvent);
297 for (Int_t jj = j+1; jj<loopEnd; jj++) {
298 AliESDMuonTrack* mu2 = new AliESDMuonTrack(*(fESD->GetMuonTrack(jj)));
299 if (!mu2->ContainTrackerData()) continue;
301 Double_t pxmu2 = mu2->Px();
302 Double_t pymu2 = mu2->Py();
303 Double_t pzmu2 = mu2->Pz();
304 Double_t emu2 = mu2->E();
305 //Double_t charge2= mu2->Charge();
307 fpTdimuon[numdimu] = TMath::Sqrt((fpx[j]+pxmu2)*(fpx[j]+pxmu2)+(fpy[j]+pymu2)*(fpy[j]+pymu2));
308 fpxdimuon[numdimu] = fpx[j]+pxmu2;
309 fpydimuon[numdimu] = fpy[j]+pymu2;
310 fpzdimuon[numdimu] = fpz[j]+pzmu2;
311 fydimuon[numdimu] = Rap((emu1+emu2),(fpz[j]+pzmu2));
312 fiMassdimuon[numdimu] = Imass(emu1,fpx[j],fpy[j],fpz[j],emu2,pxmu2,pymu2,pzmu2);
313 fcostCS[numdimu]=CostCS(fpx[j],fpy[j],fpz[j],emu1,charge1,pxmu2,pymu2,pzmu2,emu2);
314 fcostHE[numdimu]=CostHE(fpx[j],fpy[j],fpz[j],emu1,charge1,pxmu2,pymu2,pzmu2,emu2);
315 fphiCS[numdimu] = PhiCS(fpx[j],fpy[j],fpz[j],emu1,charge1,pxmu2,pymu2,pzmu2,emu2);
316 fphiHE[numdimu] = PhiHE(fpx[j],fpy[j],fpz[j],emu1,charge1,pxmu2,pymu2,pzmu2,emu2);
318 fDimuonConstituent[numdimu][0]=j; fDimuonConstituent[numdimu][1]=jj;
323 if(mu2->GetLabel()==-1) continue;
324 if(TMath::Abs(fPDG[j])==13 && TMath::Abs(((AliMCParticle*)mcEvent->GetTrack(mu2->GetLabel()))->PdgCode())==13) fPDGdimu[numdimu-1]=FindDimuFamily(mcTrack,(AliMCParticle*)mcEvent->GetTrack(mu2->GetLabel()),mcEvent);
325 else fPDGdimu[numdimu-1]=-3;
336 PostData(1,fOutputTree);
339 //________________________________________________________________________
340 Int_t AliAnalysisTaskMuonTreeBuilder::FindDimuFamily(AliMCParticle* mcTrack1,AliMCParticle* mcTrack2, AliMCEvent* mcEvent) const
342 // finds the family of the dimuon (works only if the 2 muons are real muons (not hadrons))
345 if(mcTrack1->GetMother()==mcTrack2->GetMother()) familynumber = TMath::Abs(((AliMCParticle*)mcEvent->GetTrack(mcTrack1->GetMother()))->PdgCode());
347 Int_t familymu1 = FindMuFamily(mcTrack1,mcEvent);
348 Int_t familymu2 = FindMuFamily(mcTrack2,mcEvent);
349 if(familymu1==5 && familymu2==5) familynumber=5; //bb dimuon
350 else if(familymu1==4 && familymu2==4) familynumber=4; //cc dimuon
351 else if((familymu1==4 && familymu2==5)||(familymu2==4 && familymu1==5)) familynumber=45; //bc dimuon
352 else if (familymu1==-2 || familymu2==-2 || familymu1==-3 || familymu2==-3) familynumber=-2; //hadron dimuon (at least 1 hadron involved)
353 else familynumber=-1;
359 //________________________________________________________________________
360 Int_t AliAnalysisTaskMuonTreeBuilder::FindMuFamily(AliMCParticle* mcTrack, AliMCEvent* mcEvent) const
362 // finds the family of the muon
363 Int_t imother = mcTrack->GetMother();
364 if ( imother<0 ) return -1; // Drell-Yan Muon
366 Int_t igrandma = imother;
368 AliMCParticle* motherPart = (AliMCParticle*)mcEvent->GetTrack(imother);
369 Int_t motherPdg = motherPart->PdgCode();
371 // Track is an heavy flavor muon
372 Int_t absPdg = TMath::Abs(motherPdg);
373 if(absPdg/100==5 || absPdg/1000==5) return 5;
374 if(absPdg/100==4 || absPdg/1000==4){
375 Int_t newMother = -1;
377 Int_t absGrandMotherPdg = TMath::Abs(motherPart->PdgCode());
378 while ( absGrandMotherPdg > 10 ) {
379 igrandma = ((AliMCParticle*)mcEvent->GetTrack(igrandma))->GetMother();
380 if( igrandma < 0 ) break;
381 absGrandMotherPdg = TMath::Abs(((AliMCParticle*)mcEvent->GetTrack(igrandma))->PdgCode());
384 if (absGrandMotherPdg==5) newMother = 5; // Charm from beauty
385 else if (absGrandMotherPdg==4) newMother = 4;
388 //AliWarning("Mother not correctly found! Set to charm!\n");
395 Int_t nPrimaries = mcEvent->Stack()->GetNprimary();
396 // Track is a bkg. muon
397 if (imother<nPrimaries) {
398 return -2; //is a primary
401 return -3; //is a secondary
406 //________________________________________________________________________
407 Double_t AliAnalysisTaskMuonTreeBuilder::Imass(Double_t e1, Double_t px1, Double_t py1, Double_t pz1,
408 Double_t e2, Double_t px2, Double_t py2, Double_t pz2) const
410 // invariant mass calculation
411 Double_t imassrec = TMath::Sqrt((e1+e2)*(e1+e2)-((px1+px2)*(px1+px2)+
412 (py1+py2)*(py1+py2)+(pz1+pz2)*(pz1+pz2)));
416 //________________________________________________________________________
417 Double_t AliAnalysisTaskMuonTreeBuilder::Rap(Double_t e, Double_t pz) const
419 // calculate rapidity
421 if(e>TMath::Abs(pz)){
422 rap = 0.5*TMath::Log((e+pz)/(e-pz));
431 //________________________________________________________________________
432 Double_t AliAnalysisTaskMuonTreeBuilder::Phideg(Double_t phi) const
434 // calculate Phi in range [-180,180]
437 phideg = phi-TMath::Pi();
438 phideg = phideg*57.296;
442 //________________________________________________________________________
443 Double_t AliAnalysisTaskMuonTreeBuilder::CostCS(Double_t px1, Double_t py1, Double_t pz1, Double_t e1,
444 Double_t charge1, Double_t px2, Double_t py2, Double_t pz2, Double_t e2)
446 // Cosine of the theta decay angle (mu+) in the Collins-Soper frame
448 TLorentzVector pMu1CM, pMu2CM, pProjCM, pTargCM, pDimuCM; // In the CM. frame
449 TLorentzVector pMu1Dimu, pMu2Dimu, pProjDimu, pTargDimu; // In the dimuon rest frame
450 TVector3 beta,zaxisCS;
451 Double_t mp=0.93827231;
453 // --- Fill the Lorentz vector for projectile and target in the CM frame
455 pProjCM.SetPxPyPzE(0.,0.,-fBeamEnergy,TMath::Sqrt(fBeamEnergy*fBeamEnergy+mp*mp));
456 pTargCM.SetPxPyPzE(0.,0.,fBeamEnergy,TMath::Sqrt(fBeamEnergy*fBeamEnergy+mp*mp));
458 // --- Get the muons parameters in the CM frame
460 pMu1CM.SetPxPyPzE(px1,py1,pz1,e1);
461 pMu2CM.SetPxPyPzE(px2,py2,pz2,e2);
463 // --- Obtain the dimuon parameters in the CM frame
465 pDimuCM=pMu1CM+pMu2CM;
467 // --- Translate the dimuon parameters in the dimuon rest frame
469 beta=(-1./pDimuCM.E())*pDimuCM.Vect();
470 if(beta.Mag()>=1) return 666.;
475 pMu1Dimu.Boost(beta);
476 pMu2Dimu.Boost(beta);
477 pProjDimu.Boost(beta);
478 pTargDimu.Boost(beta);
480 //Debugging part -------------------------------------
481 Double_t debugProj[4]={0.,0.,0.,0.};
482 Double_t debugTarg[4]={0.,0.,0.,0.};
483 Double_t debugMu1[4]={0.,0.,0.,0.};
484 Double_t debugMu2[4]={0.,0.,0.,0.};
485 pMu1Dimu.GetXYZT(debugMu1);
486 pMu2Dimu.GetXYZT(debugMu2);
487 pProjDimu.GetXYZT(debugProj);
488 pTargDimu.GetXYZT(debugTarg);
489 if (debugProj[0]!=debugProj[0] ||debugProj[1]!=debugProj[1] || debugProj[2]!=debugProj[2] ||debugProj[3]!=debugProj[3]) return 666;
490 if (debugTarg[0]!=debugTarg[0] ||debugTarg[1]!=debugTarg[1] || debugTarg[2]!=debugTarg[2] ||debugTarg[3]!=debugTarg[3]) return 666;
491 if (debugMu1[0]!=debugMu1[0] ||debugMu1[1]!=debugMu1[1] || debugMu1[2]!=debugMu1[2] ||debugMu1[3]!=debugMu1[3]) return 666;
492 if (debugMu2[0]!=debugMu2[0] ||debugMu2[1]!=debugMu2[1] || debugMu2[2]!=debugMu2[2] ||debugMu2[3]!=debugMu2[3]) return 666;
493 //----------------------------------------------------
495 // --- Determine the z axis for the CS angle
496 zaxisCS=(((pProjDimu.Vect()).Unit())-((pTargDimu.Vect()).Unit())).Unit();
498 // --- Determine the CS angle (angle between mu+ and the z axis defined above)
501 if(charge1>0) {cost = zaxisCS.Dot((pMu1Dimu.Vect()).Unit());}
502 else {cost = zaxisCS.Dot((pMu2Dimu.Vect()).Unit());}
507 //________________________________________________________________________
508 Double_t AliAnalysisTaskMuonTreeBuilder::CostHE(Double_t px1, Double_t py1, Double_t pz1, Double_t e1,
509 Double_t charge1, Double_t px2, Double_t py2, Double_t pz2, Double_t e2)
511 // Cosine of the theta decay angle (mu+) in the Helicity frame
513 TLorentzVector pMu1CM, pMu2CM, pDimuCM; // In the CM frame
514 TLorentzVector pMu1Dimu, pMu2Dimu; // In the dimuon rest frame
515 TVector3 beta,zaxisCS;
517 // --- Get the muons parameters in the CM frame
519 pMu1CM.SetPxPyPzE(px1,py1,pz1,e1);
520 pMu2CM.SetPxPyPzE(px2,py2,pz2,e2);
522 // --- Obtain the dimuon parameters in the CM frame
524 pDimuCM=pMu1CM+pMu2CM;
526 // --- Translate the muon parameters in the dimuon rest frame
528 beta=(-1./pDimuCM.E())*pDimuCM.Vect();
529 if(beta.Mag()>=1) return 666.;
532 pMu1Dimu.Boost(beta);
533 pMu2Dimu.Boost(beta);
535 //Debugging part -------------------------------------
536 Double_t debugMu1[4]={0.,0.,0.,0.};
537 Double_t debugMu2[4]={0.,0.,0.,0.};
538 pMu1Dimu.GetXYZT(debugMu1);
539 pMu2Dimu.GetXYZT(debugMu2);
540 if (debugMu1[0]!=debugMu1[0] ||debugMu1[1]!=debugMu1[1] || debugMu1[2]!=debugMu1[2] ||debugMu1[3]!=debugMu1[3]) return 666;
541 if (debugMu2[0]!=debugMu2[0] ||debugMu2[1]!=debugMu2[1] || debugMu2[2]!=debugMu2[2] ||debugMu2[3]!=debugMu2[3]) return 666;
542 //----------------------------------------------------
544 // --- Determine the z axis for the calculation of the polarization angle (i.e. the direction of the dimuon in the CM system)
546 zaxis=(pDimuCM.Vect()).Unit();
548 // --- Calculation of the polarization angle (angle between mu+ and the z axis defined above)
550 if(charge1>0) {cost = zaxis.Dot((pMu1Dimu.Vect()).Unit());}
551 else {cost = zaxis.Dot((pMu2Dimu.Vect()).Unit());}
555 //________________________________________________________________________
556 Double_t AliAnalysisTaskMuonTreeBuilder::PhiCS(Double_t px1, Double_t py1, Double_t pz1, Double_t e1,
557 Double_t charge1, Double_t px2, Double_t py2, Double_t pz2, Double_t e2)
559 // Phi decay angle (mu+) in the Collins-Soper frame
561 TLorentzVector pMu1CM, pMu2CM, pProjCM, pTargCM, pDimuCM; // In the CM frame
562 TLorentzVector pMu1Dimu, pMu2Dimu, pProjDimu, pTargDimu; // In the dimuon rest frame
563 TVector3 beta,yaxisCS, xaxisCS, zaxisCS;
564 Double_t mp=0.93827231;
566 // --- Fill the Lorentz vector for projectile and target in the CM frame
567 pProjCM.SetPxPyPzE(0.,0.,-fBeamEnergy,TMath::Sqrt(fBeamEnergy*fBeamEnergy+mp*mp));
568 pTargCM.SetPxPyPzE(0.,0.,fBeamEnergy,TMath::Sqrt(fBeamEnergy*fBeamEnergy+mp*mp));
570 // --- Get the muons parameters in the CM frame
571 pMu1CM.SetPxPyPzE(px1,py1,pz1,e1);
572 pMu2CM.SetPxPyPzE(px2,py2,pz2,e2);
574 // --- Obtain the dimuon parameters in the CM frame
575 pDimuCM=pMu1CM+pMu2CM;
577 // --- Translate the dimuon parameters in the dimuon rest frame
578 beta=(-1./pDimuCM.E())*pDimuCM.Vect();
579 if(beta.Mag()>=1) return 666.;
584 pMu1Dimu.Boost(beta);
585 pMu2Dimu.Boost(beta);
586 pProjDimu.Boost(beta);
587 pTargDimu.Boost(beta);
589 //Debugging part -------------------------------------
590 Double_t debugProj[4]={0.,0.,0.,0.};
591 Double_t debugTarg[4]={0.,0.,0.,0.};
592 Double_t debugMu1[4]={0.,0.,0.,0.};
593 Double_t debugMu2[4]={0.,0.,0.,0.};
594 pMu1Dimu.GetXYZT(debugMu1);
595 pMu2Dimu.GetXYZT(debugMu2);
596 pProjDimu.GetXYZT(debugProj);
597 pTargDimu.GetXYZT(debugTarg);
598 if (debugProj[0]!=debugProj[0] ||debugProj[1]!=debugProj[1] || debugProj[2]!=debugProj[2] ||debugProj[3]!=debugProj[3]) return 666;
599 if (debugTarg[0]!=debugTarg[0] ||debugTarg[1]!=debugTarg[1] || debugTarg[2]!=debugTarg[2] ||debugTarg[3]!=debugTarg[3]) return 666;
600 if (debugMu1[0]!=debugMu1[0] ||debugMu1[1]!=debugMu1[1] || debugMu1[2]!=debugMu1[2] ||debugMu1[3]!=debugMu1[3]) return 666;
601 if (debugMu2[0]!=debugMu2[0] ||debugMu2[1]!=debugMu2[1] || debugMu2[2]!=debugMu2[2] ||debugMu2[3]!=debugMu2[3]) return 666;
602 //----------------------------------------------------
604 // --- Determine the z axis for the CS angle
605 zaxisCS=(((pProjDimu.Vect()).Unit())-((pTargDimu.Vect()).Unit())).Unit();
606 yaxisCS=(((pProjDimu.Vect()).Unit()).Cross((pTargDimu.Vect()).Unit())).Unit();
607 xaxisCS=(yaxisCS.Cross(zaxisCS)).Unit();
611 phi = TMath::ATan2((pMu1Dimu.Vect()).Dot(yaxisCS),((pMu1Dimu.Vect()).Dot(xaxisCS)));
613 phi = TMath::ATan2((pMu2Dimu.Vect()).Dot(yaxisCS),((pMu2Dimu.Vect()).Dot(xaxisCS)));
615 if (phi>TMath::Pi()) phi=phi-TMath::Pi();
620 //________________________________________________________________________
621 Double_t AliAnalysisTaskMuonTreeBuilder::PhiHE(Double_t px1, Double_t py1, Double_t pz1, Double_t e1,
622 Double_t charge1, Double_t px2, Double_t py2, Double_t pz2, Double_t e2)
624 // Phi decay angle (mu+) in the Helicity frame
625 TLorentzVector pMu1Lab, pMu2Lab, pProjLab, pTargLab, pDimuLab; // In the lab. frame
626 TLorentzVector pMu1Dimu, pMu2Dimu, pProjDimu, pTargDimu; // In the dimuon rest frame
627 TVector3 beta,xaxis, yaxis,zaxis;
628 Double_t mp=0.93827231;
630 // --- Get the muons parameters in the LAB frame
631 pMu1Lab.SetPxPyPzE(px1,py1,pz1,e1);
632 pMu2Lab.SetPxPyPzE(px2,py2,pz2,e2);
634 // --- Obtain the dimuon parameters in the LAB frame
635 pDimuLab=pMu1Lab+pMu2Lab;
636 zaxis=(pDimuLab.Vect()).Unit();
638 // --- Translate the muon parameters in the dimuon rest frame
639 beta=(-1./pDimuLab.E())*pDimuLab.Vect();
640 if(beta.Mag()>=1.) return 666.;
642 pProjLab.SetPxPyPzE(0.,0.,-fBeamEnergy,TMath::Sqrt(fBeamEnergy*fBeamEnergy+mp*mp)); // proiettile
643 pTargLab.SetPxPyPzE(0.,0.,fBeamEnergy,TMath::Sqrt(fBeamEnergy*fBeamEnergy+mp*mp)); // bersaglio
648 pProjDimu.Boost(beta);
649 pTargDimu.Boost(beta);
651 yaxis=((pProjDimu.Vect()).Cross(pTargDimu.Vect())).Unit();
652 xaxis=(yaxis.Cross(zaxis)).Unit();
656 pMu1Dimu.Boost(beta);
657 pMu2Dimu.Boost(beta);
659 //Debugging part -------------------------------------
660 Double_t debugProj[4]={0.,0.,0.,0.};
661 Double_t debugTarg[4]={0.,0.,0.,0.};
662 Double_t debugMu1[4]={0.,0.,0.,0.};
663 Double_t debugMu2[4]={0.,0.,0.,0.};
664 pMu1Dimu.GetXYZT(debugMu1);
665 pMu2Dimu.GetXYZT(debugMu2);
666 pProjDimu.GetXYZT(debugProj);
667 pTargDimu.GetXYZT(debugTarg);
668 if (debugProj[0]!=debugProj[0] ||debugProj[1]!=debugProj[1] || debugProj[2]!=debugProj[2] ||debugProj[3]!=debugProj[3]) return 666;
669 if (debugTarg[0]!=debugTarg[0] ||debugTarg[1]!=debugTarg[1] || debugTarg[2]!=debugTarg[2] ||debugTarg[3]!=debugTarg[3]) return 666;
670 if (debugMu1[0]!=debugMu1[0] ||debugMu1[1]!=debugMu1[1] || debugMu1[2]!=debugMu1[2] ||debugMu1[3]!=debugMu1[3]) return 666;
671 if (debugMu2[0]!=debugMu2[0] ||debugMu2[1]!=debugMu2[1] || debugMu2[2]!=debugMu2[2] ||debugMu2[3]!=debugMu2[3]) return 666;
672 //----------------------------------------------------
676 phi = TMath::ATan2((pMu1Dimu.Vect()).Dot(yaxis),(pMu1Dimu.Vect()).Dot(xaxis));
678 phi = TMath::ATan2((pMu2Dimu.Vect()).Dot(yaxis),(pMu2Dimu.Vect()).Dot(xaxis));
683 //________________________________________________________________________
684 void AliAnalysisTaskMuonTreeBuilder::Terminate(Option_t *)