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() :
54 for(Int_t i=0; i<45; i++){
55 if(i<3) fVertex[i]=-666;
71 fMatchTrigChi2[i]=-666;
91 for(Int_t j=0; j<2; j++){fDimuonConstituent[i][j]=-666;}
94 snprintf(fTrigClass,100," ");
97 //___________________________________________________________________________
98 AliAnalysisTaskMuonTreeBuilder::AliAnalysisTaskMuonTreeBuilder(const Char_t* name) :
99 AliAnalysisTaskSE(name),
112 // Constructor. Initialization of Inputs and Outputs
114 Info("AliAnalysisTaskMuonTreeBuilder","Calling Constructor");
116 for(Int_t i=0; i<45; i++){
117 if(i<3) fVertex[i]=-666;
133 fMatchTrigChi2[i]=-666;
146 fiMassdimuon[i]=-666;
153 for(Int_t j=0; j<2; j++){fDimuonConstituent[i][j]=-666;}
156 snprintf(fTrigClass,100," ");
158 DefineOutput(1,TTree::Class());
161 //___________________________________________________________________________
162 AliAnalysisTaskMuonTreeBuilder& AliAnalysisTaskMuonTreeBuilder::operator=(const AliAnalysisTaskMuonTreeBuilder& c)
165 // Assignment operator
168 AliAnalysisTaskSE::operator=(c) ;
174 //___________________________________________________________________________
175 AliAnalysisTaskMuonTreeBuilder::AliAnalysisTaskMuonTreeBuilder(const AliAnalysisTaskMuonTreeBuilder& c) :
176 AliAnalysisTaskSE(c),
178 fBeamEnergy(c.fBeamEnergy),
180 fOutputTree(c.fOutputTree),
183 fNumMuonTracks(c.fNumMuonTracks),
184 fNumSPDTracklets(c.fNumSPDTracklets),
185 fNumContributors(c.fNumContributors),
186 fNumDimuons(c.fNumDimuons)
189 // Copy Constructor FIDUCIAL REGIONS?
191 for(Int_t i=0; i<45; i++){
192 if(i<3) fVertex[i]=-666;
208 fMatchTrigChi2[i]=-666;
221 fiMassdimuon[i]=-666;
228 for(Int_t j=0; j<2; j++){fDimuonConstituent[i][j]=-666;}
231 snprintf(fTrigClass,100," ");
234 //___________________________________________________________________________
235 AliAnalysisTaskMuonTreeBuilder::~AliAnalysisTaskMuonTreeBuilder() {
239 Info("~AliAnalysisTaskMuonTreeBuilder","Calling Destructor");
242 //___________________________________________________________________________
243 void AliAnalysisTaskMuonTreeBuilder::UserCreateOutputObjects(){
246 // Creating User-Defined Output Objects
249 // TREE OUTPUT----------------------------------------------------------
251 fOutputTree = new TTree("krec","Tree of reconstructed muons");
253 fOutputTree->Branch("IsSelected",&fIsSelected,"IsSelected/O");
254 fOutputTree->Branch("FiredTriggerClasses",fTrigClass,"FiredTriggerClasses/C");
256 fOutputTree->Branch("NumMuonTracks",&fNumMuonTracks,"NumMuonTracks/I");
257 fOutputTree->Branch("NumContributors",&fNumContributors,"NumContributors/I");
258 fOutputTree->Branch("NumSPDTracklets",&fNumSPDTracklets,"NumSPDTraclets/I");
259 fOutputTree->Branch("Vertex",fVertex,"Vertex[3]/D");
260 fOutputTree->Branch("pT",fpT,"pT[10]/D");
261 fOutputTree->Branch("E",fE,"E[10]/D");
262 fOutputTree->Branch("px",fpx,"px[10]/D");
263 fOutputTree->Branch("py",fpy,"py[10]/D");
264 fOutputTree->Branch("pz",fpz,"pz[10]/D");
265 fOutputTree->Branch("pxUncorr",fpxUncorr,"pxUncorr[10]/D");
266 fOutputTree->Branch("pyUncorr",fpyUncorr,"pyUncorr[10]/D");
267 fOutputTree->Branch("pzUncorr",fpzUncorr,"pzUncorr[10]/D");
268 fOutputTree->Branch("y",fy,"y[10]/D");
269 fOutputTree->Branch("eta",feta,"eta[10]/D");
270 fOutputTree->Branch("phi",fphi,"phi[10]/D");
271 fOutputTree->Branch("MatchTrig",fMatchTrig,"MatchTrig[10]/I");
272 fOutputTree->Branch("TrackChi2",fTrackChi2,"TrackChi2[10]/D");
273 fOutputTree->Branch("MatchTrigChi2",fMatchTrigChi2,"MatchTrigChi2[10]/D");
274 fOutputTree->Branch("DCA",fDCA,"DCA[10]/D");
275 fOutputTree->Branch("Charge",fCharge,"Charge[10]/S");
276 fOutputTree->Branch("MuFamily",fMuFamily,"MuFamily[10]/I");
277 fOutputTree->Branch("RAtAbsEnd",fRAtAbsEnd,"RAtAbsEnd[10]/D");
279 fOutputTree->Branch("NumDimuons",&fNumDimuons,"NumDimuons/I");
280 fOutputTree->Branch("DimuConstituent",fDimuonConstituent,"DimuonConstituent[45][2]/I");
281 fOutputTree->Branch("pTdimuon",fpTdimuon,"pTdimuon[45]/D");
282 fOutputTree->Branch("pxdimuon",fpxdimuon,"pxdimuon[45]/D");
283 fOutputTree->Branch("pydimuon",fpydimuon,"pydimuon[45]/D");
284 fOutputTree->Branch("pzdimuon",fpzdimuon,"pzdimuon[45]/D");
285 fOutputTree->Branch("ydimuon",fydimuon,"ydimuon[45]/D");
286 fOutputTree->Branch("Imassdimuon",fiMassdimuon,"iMassdimuon[45]/D");
287 fOutputTree->Branch("costCS",fcostCS,"costCS[45]/D");
288 fOutputTree->Branch("costHE",fcostHE,"costHE[45]/D");
289 fOutputTree->Branch("phiCS",fphiCS,"phiCS[45]/D");
290 fOutputTree->Branch("phiHE",fphiHE,"phiHE[45]/D");
292 fOutputTree->Branch("PDG",fPDG,"PDG[10]/I");
293 fOutputTree->Branch("PDGmother",fPDGmother,"PDGmother[10]/I");
294 fOutputTree->Branch("PDGdimu",fPDGdimu,"PDGdimu[45]/I");
300 //_________________________________________________
301 void AliAnalysisTaskMuonTreeBuilder::UserExec(Option_t *)
311 fNumSPDTracklets=666;
312 fNumContributors=666;
315 fVertex[0]=666.; fVertex[1]=666.; fVertex[2]=666.;
316 for(Int_t i=0; i<10;i++){
330 fMatchTrigChi2[i]=666.;
338 for(Int_t i=0; i<45;i++){
339 fDimuonConstituent[i][0]=666; fDimuonConstituent[i][1]=666;
345 fiMassdimuon[i]=666.;
358 AliESDEvent *fESD = 0x0;
359 AliMCEvent* mcEvent = 0x0;
363 Error("UserExec","NO MC EVENT FOUND!");
368 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
370 AliError("Cannot get input event");
374 fIsSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
376 fNumMuonTracks = fESD->GetNumberOfMuonTracks() ;
377 Int_t loopEnd = fNumMuonTracks;
379 TString cla = fESD->GetFiredTriggerClasses();
380 snprintf(fTrigClass,100,"%s",cla.Data());
383 if(fNumMuonTracks>0 && fIsMC){
386 fNumContributors = fESD->GetPrimaryVertexSPD()->GetNContributors();
387 fNumSPDTracklets = fESD->GetMultiplicity()->GetNumberOfTracklets();
388 fVertex[0]=fESD->GetPrimaryVertexSPD()->GetX();
389 fVertex[1]=fESD->GetPrimaryVertexSPD()->GetY();
390 fVertex[2]=fESD->GetPrimaryVertexSPD()->GetZ();
391 printf("fVertex : %f - %f - %f\n",fVertex[0],fVertex[1],fVertex[2]);
394 for (Int_t j = 0; j<loopEnd; j++) {
395 AliESDMuonTrack* mu1 = new AliESDMuonTrack(*(fESD->GetMuonTrack(j)));
396 if (!mu1->ContainTrackerData()) {fNumMuonTracks=fNumMuonTracks-1; continue;}
397 Double_t charge1 = mu1->Charge();
398 fCharge[j] = mu1->Charge();
403 fpxUncorr[j] = mu1->PxUncorrected();
404 fpyUncorr[j] = mu1->PyUncorrected();
405 fpzUncorr[j] = mu1->PzUncorrected();
407 feta[j] = mu1->Eta();
408 fphi[j] = Phideg(mu1->Phi());
409 Double_t emu1 = mu1->E();
411 fDCA[j] = mu1->GetDCA();
412 fTrackChi2[j] = mu1->GetChi2();
413 fMatchTrig[j] = mu1->GetMatchTrigger();
414 fMatchTrigChi2[j]= mu1->GetChi2MatchTrigger();
415 fRAtAbsEnd[j]=mu1->GetRAtAbsorberEnd();
417 AliMCParticle* mcTrack = 0x0;
419 if(mu1->GetLabel()==-1) continue;
420 mcTrack = (AliMCParticle*)mcEvent->GetTrack(mu1->GetLabel());
421 fPDG[j] = mcTrack->PdgCode();
422 if (mcTrack->GetMother()==-1) continue;
423 fPDGmother[j] = ((AliMCParticle*)mcEvent->GetTrack(mcTrack->GetMother()))->PdgCode();
424 if (TMath::Abs(fPDG[j])==13) fMuFamily[j] = FindMuFamily(mcTrack,mcEvent);
426 for (Int_t jj = j+1; jj<loopEnd; jj++) {
427 AliESDMuonTrack* mu2 = new AliESDMuonTrack(*(fESD->GetMuonTrack(jj)));
428 if (!mu2->ContainTrackerData()) continue;
430 Double_t pxmu2 = mu2->Px();
431 Double_t pymu2 = mu2->Py();
432 Double_t pzmu2 = mu2->Pz();
433 Double_t emu2 = mu2->E();
434 //Double_t charge2= mu2->Charge();
436 fpTdimuon[numdimu] = TMath::Sqrt((fpx[j]+pxmu2)*(fpx[j]+pxmu2)+(fpy[j]+pymu2)*(fpy[j]+pymu2));
437 fpxdimuon[numdimu] = fpx[j]+pxmu2;
438 fpydimuon[numdimu] = fpy[j]+pymu2;
439 fpzdimuon[numdimu] = fpz[j]+pzmu2;
440 fydimuon[numdimu] = Rap((emu1+emu2),(fpz[j]+pzmu2));
441 fiMassdimuon[numdimu] = Imass(emu1,fpx[j],fpy[j],fpz[j],emu2,pxmu2,pymu2,pzmu2);
442 fcostCS[numdimu]=CostCS(fpx[j],fpy[j],fpz[j],emu1,charge1,pxmu2,pymu2,pzmu2,emu2);
443 fcostHE[numdimu]=CostHE(fpx[j],fpy[j],fpz[j],emu1,charge1,pxmu2,pymu2,pzmu2,emu2);
444 fphiCS[numdimu] = PhiCS(fpx[j],fpy[j],fpz[j],emu1,charge1,pxmu2,pymu2,pzmu2,emu2);
445 fphiHE[numdimu] = PhiHE(fpx[j],fpy[j],fpz[j],emu1,charge1,pxmu2,pymu2,pzmu2,emu2);
447 fDimuonConstituent[numdimu][0]=j; fDimuonConstituent[numdimu][1]=jj;
452 if(mu2->GetLabel()==-1) continue;
453 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);
454 else fPDGdimu[numdimu-1]=-3;
465 PostData(1,fOutputTree);
468 //________________________________________________________________________
469 Int_t AliAnalysisTaskMuonTreeBuilder::FindDimuFamily(AliMCParticle* mcTrack1,AliMCParticle* mcTrack2, AliMCEvent* mcEvent) const
471 // finds the family of the dimuon (works only if the 2 muons are real muons (not hadrons))
474 if(mcTrack1->GetMother()==mcTrack2->GetMother()) familynumber = TMath::Abs(((AliMCParticle*)mcEvent->GetTrack(mcTrack1->GetMother()))->PdgCode());
476 Int_t familymu1 = FindMuFamily(mcTrack1,mcEvent);
477 Int_t familymu2 = FindMuFamily(mcTrack2,mcEvent);
478 if(familymu1==5 && familymu2==5) familynumber=5; //bb dimuon
479 else if(familymu1==4 && familymu2==4) familynumber=4; //cc dimuon
480 else if((familymu1==4 && familymu2==5)||(familymu2==4 && familymu1==5)) familynumber=45; //bc dimuon
481 else if (familymu1==-2 || familymu2==-2 || familymu1==-3 || familymu2==-3) familynumber=-2; //hadron dimuon (at least 1 hadron involved)
482 else familynumber=-1;
488 //________________________________________________________________________
489 Int_t AliAnalysisTaskMuonTreeBuilder::FindMuFamily(AliMCParticle* mcTrack, AliMCEvent* mcEvent) const
491 // finds the family of the muon
492 Int_t imother = mcTrack->GetMother();
493 if ( imother<0 ) return -1; // Drell-Yan Muon
495 Int_t igrandma = imother;
497 AliMCParticle* motherPart = (AliMCParticle*)mcEvent->GetTrack(imother);
498 Int_t motherPdg = motherPart->PdgCode();
500 // Track is an heavy flavor muon
501 Int_t absPdg = TMath::Abs(motherPdg);
502 if(absPdg/100==5 || absPdg/1000==5) return 5;
503 if(absPdg/100==4 || absPdg/1000==4){
504 Int_t newMother = -1;
506 Int_t absGrandMotherPdg = TMath::Abs(motherPart->PdgCode());
507 while ( absGrandMotherPdg > 10 ) {
508 igrandma = ((AliMCParticle*)mcEvent->GetTrack(igrandma))->GetMother();
509 if( igrandma < 0 ) break;
510 absGrandMotherPdg = TMath::Abs(((AliMCParticle*)mcEvent->GetTrack(igrandma))->PdgCode());
513 if (absGrandMotherPdg==5) newMother = 5; // Charm from beauty
514 else if (absGrandMotherPdg==4) newMother = 4;
517 //AliWarning("Mother not correctly found! Set to charm!\n");
524 Int_t nPrimaries = mcEvent->Stack()->GetNprimary();
525 // Track is a bkg. muon
526 if (imother<nPrimaries) {
527 return -2; //is a primary
530 return -3; //is a secondary
535 //________________________________________________________________________
536 Double_t AliAnalysisTaskMuonTreeBuilder::Imass(Double_t e1, Double_t px1, Double_t py1, Double_t pz1,
537 Double_t e2, Double_t px2, Double_t py2, Double_t pz2) const
539 // invariant mass calculation
540 Double_t imassrec = TMath::Sqrt((e1+e2)*(e1+e2)-((px1+px2)*(px1+px2)+
541 (py1+py2)*(py1+py2)+(pz1+pz2)*(pz1+pz2)));
545 //________________________________________________________________________
546 Double_t AliAnalysisTaskMuonTreeBuilder::Rap(Double_t e, Double_t pz) const
548 // calculate rapidity
550 if(e>TMath::Abs(pz)){
551 rap = 0.5*TMath::Log((e+pz)/(e-pz));
560 //________________________________________________________________________
561 Double_t AliAnalysisTaskMuonTreeBuilder::Phideg(Double_t phi) const
563 // calculate Phi in range [-180,180]
566 phideg = phi-TMath::Pi();
567 phideg = phideg*57.296;
571 //________________________________________________________________________
572 Double_t AliAnalysisTaskMuonTreeBuilder::CostCS(Double_t px1, Double_t py1, Double_t pz1, Double_t e1,
573 Double_t charge1, Double_t px2, Double_t py2, Double_t pz2, Double_t e2)
575 // Cosine of the theta decay angle (mu+) in the Collins-Soper frame
577 TLorentzVector pMu1CM, pMu2CM, pProjCM, pTargCM, pDimuCM; // In the CM. frame
578 TLorentzVector pMu1Dimu, pMu2Dimu, pProjDimu, pTargDimu; // In the dimuon rest frame
579 TVector3 beta,zaxisCS;
580 Double_t mp=0.93827231;
582 // --- Fill the Lorentz vector for projectile and target in the CM frame
584 pProjCM.SetPxPyPzE(0.,0.,-fBeamEnergy,TMath::Sqrt(fBeamEnergy*fBeamEnergy+mp*mp));
585 pTargCM.SetPxPyPzE(0.,0.,fBeamEnergy,TMath::Sqrt(fBeamEnergy*fBeamEnergy+mp*mp));
587 // --- Get the muons parameters in the CM frame
589 pMu1CM.SetPxPyPzE(px1,py1,pz1,e1);
590 pMu2CM.SetPxPyPzE(px2,py2,pz2,e2);
592 // --- Obtain the dimuon parameters in the CM frame
594 pDimuCM=pMu1CM+pMu2CM;
596 // --- Translate the dimuon parameters in the dimuon rest frame
598 beta=(-1./pDimuCM.E())*pDimuCM.Vect();
599 if(beta.Mag()>=1) return 666.;
604 pMu1Dimu.Boost(beta);
605 pMu2Dimu.Boost(beta);
606 pProjDimu.Boost(beta);
607 pTargDimu.Boost(beta);
609 //Debugging part -------------------------------------
610 Double_t debugProj[4]={0.,0.,0.,0.};
611 Double_t debugTarg[4]={0.,0.,0.,0.};
612 Double_t debugMu1[4]={0.,0.,0.,0.};
613 Double_t debugMu2[4]={0.,0.,0.,0.};
614 pMu1Dimu.GetXYZT(debugMu1);
615 pMu2Dimu.GetXYZT(debugMu2);
616 pProjDimu.GetXYZT(debugProj);
617 pTargDimu.GetXYZT(debugTarg);
618 if (debugProj[0]!=debugProj[0] ||debugProj[1]!=debugProj[1] || debugProj[2]!=debugProj[2] ||debugProj[3]!=debugProj[3]) return 666;
619 if (debugTarg[0]!=debugTarg[0] ||debugTarg[1]!=debugTarg[1] || debugTarg[2]!=debugTarg[2] ||debugTarg[3]!=debugTarg[3]) return 666;
620 if (debugMu1[0]!=debugMu1[0] ||debugMu1[1]!=debugMu1[1] || debugMu1[2]!=debugMu1[2] ||debugMu1[3]!=debugMu1[3]) return 666;
621 if (debugMu2[0]!=debugMu2[0] ||debugMu2[1]!=debugMu2[1] || debugMu2[2]!=debugMu2[2] ||debugMu2[3]!=debugMu2[3]) return 666;
622 //----------------------------------------------------
624 // --- Determine the z axis for the CS angle
625 zaxisCS=(((pProjDimu.Vect()).Unit())-((pTargDimu.Vect()).Unit())).Unit();
627 // --- Determine the CS angle (angle between mu+ and the z axis defined above)
630 if(charge1>0) {cost = zaxisCS.Dot((pMu1Dimu.Vect()).Unit());}
631 else {cost = zaxisCS.Dot((pMu2Dimu.Vect()).Unit());}
636 //________________________________________________________________________
637 Double_t AliAnalysisTaskMuonTreeBuilder::CostHE(Double_t px1, Double_t py1, Double_t pz1, Double_t e1,
638 Double_t charge1, Double_t px2, Double_t py2, Double_t pz2, Double_t e2)
640 // Cosine of the theta decay angle (mu+) in the Helicity frame
642 TLorentzVector pMu1CM, pMu2CM, pDimuCM; // In the CM frame
643 TLorentzVector pMu1Dimu, pMu2Dimu; // In the dimuon rest frame
644 TVector3 beta,zaxisCS;
646 // --- Get the muons parameters in the CM frame
648 pMu1CM.SetPxPyPzE(px1,py1,pz1,e1);
649 pMu2CM.SetPxPyPzE(px2,py2,pz2,e2);
651 // --- Obtain the dimuon parameters in the CM frame
653 pDimuCM=pMu1CM+pMu2CM;
655 // --- Translate the muon parameters in the dimuon rest frame
657 beta=(-1./pDimuCM.E())*pDimuCM.Vect();
658 if(beta.Mag()>=1) return 666.;
661 pMu1Dimu.Boost(beta);
662 pMu2Dimu.Boost(beta);
664 //Debugging part -------------------------------------
665 Double_t debugMu1[4]={0.,0.,0.,0.};
666 Double_t debugMu2[4]={0.,0.,0.,0.};
667 pMu1Dimu.GetXYZT(debugMu1);
668 pMu2Dimu.GetXYZT(debugMu2);
669 if (debugMu1[0]!=debugMu1[0] ||debugMu1[1]!=debugMu1[1] || debugMu1[2]!=debugMu1[2] ||debugMu1[3]!=debugMu1[3]) return 666;
670 if (debugMu2[0]!=debugMu2[0] ||debugMu2[1]!=debugMu2[1] || debugMu2[2]!=debugMu2[2] ||debugMu2[3]!=debugMu2[3]) return 666;
671 //----------------------------------------------------
673 // --- Determine the z axis for the calculation of the polarization angle (i.e. the direction of the dimuon in the CM system)
675 zaxis=(pDimuCM.Vect()).Unit();
677 // --- Calculation of the polarization angle (angle between mu+ and the z axis defined above)
679 if(charge1>0) {cost = zaxis.Dot((pMu1Dimu.Vect()).Unit());}
680 else {cost = zaxis.Dot((pMu2Dimu.Vect()).Unit());}
684 //________________________________________________________________________
685 Double_t AliAnalysisTaskMuonTreeBuilder::PhiCS(Double_t px1, Double_t py1, Double_t pz1, Double_t e1,
686 Double_t charge1, Double_t px2, Double_t py2, Double_t pz2, Double_t e2)
688 // Phi decay angle (mu+) in the Collins-Soper frame
690 TLorentzVector pMu1CM, pMu2CM, pProjCM, pTargCM, pDimuCM; // In the CM frame
691 TLorentzVector pMu1Dimu, pMu2Dimu, pProjDimu, pTargDimu; // In the dimuon rest frame
692 TVector3 beta,yaxisCS, xaxisCS, zaxisCS;
693 Double_t mp=0.93827231;
695 // --- Fill the Lorentz vector for projectile and target in the CM frame
696 pProjCM.SetPxPyPzE(0.,0.,-fBeamEnergy,TMath::Sqrt(fBeamEnergy*fBeamEnergy+mp*mp));
697 pTargCM.SetPxPyPzE(0.,0.,fBeamEnergy,TMath::Sqrt(fBeamEnergy*fBeamEnergy+mp*mp));
699 // --- Get the muons parameters in the CM frame
700 pMu1CM.SetPxPyPzE(px1,py1,pz1,e1);
701 pMu2CM.SetPxPyPzE(px2,py2,pz2,e2);
703 // --- Obtain the dimuon parameters in the CM frame
704 pDimuCM=pMu1CM+pMu2CM;
706 // --- Translate the dimuon parameters in the dimuon rest frame
707 beta=(-1./pDimuCM.E())*pDimuCM.Vect();
708 if(beta.Mag()>=1) return 666.;
713 pMu1Dimu.Boost(beta);
714 pMu2Dimu.Boost(beta);
715 pProjDimu.Boost(beta);
716 pTargDimu.Boost(beta);
718 //Debugging part -------------------------------------
719 Double_t debugProj[4]={0.,0.,0.,0.};
720 Double_t debugTarg[4]={0.,0.,0.,0.};
721 Double_t debugMu1[4]={0.,0.,0.,0.};
722 Double_t debugMu2[4]={0.,0.,0.,0.};
723 pMu1Dimu.GetXYZT(debugMu1);
724 pMu2Dimu.GetXYZT(debugMu2);
725 pProjDimu.GetXYZT(debugProj);
726 pTargDimu.GetXYZT(debugTarg);
727 if (debugProj[0]!=debugProj[0] ||debugProj[1]!=debugProj[1] || debugProj[2]!=debugProj[2] ||debugProj[3]!=debugProj[3]) return 666;
728 if (debugTarg[0]!=debugTarg[0] ||debugTarg[1]!=debugTarg[1] || debugTarg[2]!=debugTarg[2] ||debugTarg[3]!=debugTarg[3]) return 666;
729 if (debugMu1[0]!=debugMu1[0] ||debugMu1[1]!=debugMu1[1] || debugMu1[2]!=debugMu1[2] ||debugMu1[3]!=debugMu1[3]) return 666;
730 if (debugMu2[0]!=debugMu2[0] ||debugMu2[1]!=debugMu2[1] || debugMu2[2]!=debugMu2[2] ||debugMu2[3]!=debugMu2[3]) return 666;
731 //----------------------------------------------------
733 // --- Determine the z axis for the CS angle
734 zaxisCS=(((pProjDimu.Vect()).Unit())-((pTargDimu.Vect()).Unit())).Unit();
735 yaxisCS=(((pProjDimu.Vect()).Unit()).Cross((pTargDimu.Vect()).Unit())).Unit();
736 xaxisCS=(yaxisCS.Cross(zaxisCS)).Unit();
740 phi = TMath::ATan2((pMu1Dimu.Vect()).Dot(yaxisCS),((pMu1Dimu.Vect()).Dot(xaxisCS)));
742 phi = TMath::ATan2((pMu2Dimu.Vect()).Dot(yaxisCS),((pMu2Dimu.Vect()).Dot(xaxisCS)));
744 if (phi>TMath::Pi()) phi=phi-TMath::Pi();
749 //________________________________________________________________________
750 Double_t AliAnalysisTaskMuonTreeBuilder::PhiHE(Double_t px1, Double_t py1, Double_t pz1, Double_t e1,
751 Double_t charge1, Double_t px2, Double_t py2, Double_t pz2, Double_t e2)
753 // Phi decay angle (mu+) in the Helicity frame
754 TLorentzVector pMu1Lab, pMu2Lab, pProjLab, pTargLab, pDimuLab; // In the lab. frame
755 TLorentzVector pMu1Dimu, pMu2Dimu, pProjDimu, pTargDimu; // In the dimuon rest frame
756 TVector3 beta,xaxis, yaxis,zaxis;
757 Double_t mp=0.93827231;
759 // --- Get the muons parameters in the LAB frame
760 pMu1Lab.SetPxPyPzE(px1,py1,pz1,e1);
761 pMu2Lab.SetPxPyPzE(px2,py2,pz2,e2);
763 // --- Obtain the dimuon parameters in the LAB frame
764 pDimuLab=pMu1Lab+pMu2Lab;
765 zaxis=(pDimuLab.Vect()).Unit();
767 // --- Translate the muon parameters in the dimuon rest frame
768 beta=(-1./pDimuLab.E())*pDimuLab.Vect();
769 if(beta.Mag()>=1.) return 666.;
771 pProjLab.SetPxPyPzE(0.,0.,-fBeamEnergy,TMath::Sqrt(fBeamEnergy*fBeamEnergy+mp*mp)); // proiettile
772 pTargLab.SetPxPyPzE(0.,0.,fBeamEnergy,TMath::Sqrt(fBeamEnergy*fBeamEnergy+mp*mp)); // bersaglio
777 pProjDimu.Boost(beta);
778 pTargDimu.Boost(beta);
780 yaxis=((pProjDimu.Vect()).Cross(pTargDimu.Vect())).Unit();
781 xaxis=(yaxis.Cross(zaxis)).Unit();
785 pMu1Dimu.Boost(beta);
786 pMu2Dimu.Boost(beta);
788 //Debugging part -------------------------------------
789 Double_t debugProj[4]={0.,0.,0.,0.};
790 Double_t debugTarg[4]={0.,0.,0.,0.};
791 Double_t debugMu1[4]={0.,0.,0.,0.};
792 Double_t debugMu2[4]={0.,0.,0.,0.};
793 pMu1Dimu.GetXYZT(debugMu1);
794 pMu2Dimu.GetXYZT(debugMu2);
795 pProjDimu.GetXYZT(debugProj);
796 pTargDimu.GetXYZT(debugTarg);
797 if (debugProj[0]!=debugProj[0] ||debugProj[1]!=debugProj[1] || debugProj[2]!=debugProj[2] ||debugProj[3]!=debugProj[3]) return 666;
798 if (debugTarg[0]!=debugTarg[0] ||debugTarg[1]!=debugTarg[1] || debugTarg[2]!=debugTarg[2] ||debugTarg[3]!=debugTarg[3]) return 666;
799 if (debugMu1[0]!=debugMu1[0] ||debugMu1[1]!=debugMu1[1] || debugMu1[2]!=debugMu1[2] ||debugMu1[3]!=debugMu1[3]) return 666;
800 if (debugMu2[0]!=debugMu2[0] ||debugMu2[1]!=debugMu2[1] || debugMu2[2]!=debugMu2[2] ||debugMu2[3]!=debugMu2[3]) return 666;
801 //----------------------------------------------------
805 phi = TMath::ATan2((pMu1Dimu.Vect()).Dot(yaxis),(pMu1Dimu.Vect()).Dot(xaxis));
807 phi = TMath::ATan2((pMu2Dimu.Vect()).Dot(yaxis),(pMu2Dimu.Vect()).Dot(xaxis));
812 //________________________________________________________________________
813 void AliAnalysisTaskMuonTreeBuilder::Terminate(Option_t *)