]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/RESONANCES/AliRsnDaughter.cxx
Improved Print() function
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnDaughter.cxx
index cc85cf6b23c4ca81b8195d534a221a0d2c2b9555..be2001aac8d149d58cd27d15c5fd59c66e4e071d 100644 (file)
@@ -15,7 +15,7 @@
  
 //-------------------------------------------------------------------------
 //                      Class AliRsnDaughter
-//  
+//                     ----------------------
 //           A simple object which describes a reconstructed track
 //           with some references to its related generated particle
 //           and some facilities which could help in composing its
@@ -27,7 +27,7 @@
 #include <Riostream.h>
 
 #include <TParticle.h>
-#include <TParticlePDG.h>
+#include <TString.h>
 
 #include "AliESDtrack.h"
 #include "AliRsnDaughter.h"
@@ -36,12 +36,12 @@ ClassImp(AliRsnDaughter)
 
 //--------------------------------------------------------------------------------------------------------
 AliRsnDaughter::AliRsnDaughter()
+{
 // 
 // Default constructor.
 // Its unique argument defines how many PID weights are allowed. 
 // Actually, it should be the same as AliESDtrack::kSPECIES (=5).
-//
-{ 
+// 
        fSign = (Char_t)0;
        fPDG = (UShort_t)0;
        fIndex = (UShort_t)0;
@@ -62,10 +62,10 @@ AliRsnDaughter::AliRsnDaughter()
 }
 //--------------------------------------------------------------------------------------------------------
 AliRsnDaughter::AliRsnDaughter(const AliRsnDaughter &copy) : TObject(copy)
+{
 //
 // Copy constructor
 //
-{
        fSign = copy.fSign;
        fPDG = copy.fPDG;
        fIndex = copy.fIndex;
@@ -88,6 +88,7 @@ AliRsnDaughter::AliRsnDaughter(const AliRsnDaughter &copy) : TObject(copy)
 }
 //--------------------------------------------------------------------------------------------------------
 Bool_t AliRsnDaughter::Adopt(const AliESDtrack* esdTrack, Bool_t checkITSRefit)
+{
 //
 // Copies reconstructed data from an AliESDtrack:
 //
@@ -104,7 +105,6 @@ Bool_t AliRsnDaughter::Adopt(const AliESDtrack* esdTrack, Bool_t checkITSRefit)
 // - if the passed label is negative, track is considered as "fake", and 
 //   this info is kept to allow fake tracks exclusion when doing analysis
 //
-{
        // check for refit in the ITS (if requested)
        if (checkITSRefit) {
                if ( !(esdTrack->GetStatus() & AliESDtrack::kITSrefit) ) {
@@ -138,6 +138,7 @@ Bool_t AliRsnDaughter::Adopt(const AliESDtrack* esdTrack, Bool_t checkITSRefit)
 }
 //--------------------------------------------------------------------------------------------------------
 Bool_t AliRsnDaughter::Adopt(TParticle* particle)
+{
 //
 // Copies data from a generated particle:
 // 
@@ -150,7 +151,6 @@ Bool_t AliRsnDaughter::Adopt(TParticle* particle)
 // When an AliRsnDaughter is copied from a TParticle, it is 
 // considered always good for analysis and never fake.
 //
-{
        // get particle sign form the sign of PDG code
        Int_t pdg = particle->GetPdgCode();
        if (TMath::Abs(pdg) < 20) {
@@ -178,12 +178,62 @@ Bool_t AliRsnDaughter::Adopt(TParticle* particle)
        return kTRUE;
 }
 //--------------------------------------------------------------------------------------------------------
-AliRsnDaughter operator+(AliRsnDaughter t1, AliRsnDaughter t2)
+void AliRsnDaughter::Print(Option_t *option) const
+{
+// 
+// Print informations about track.
+// All options are used to add some specifical information as required:
+// "S" --> charge sign
+// "L" --> track label
+// "I" --> assigned PID (PDG code)
+// "T" --> true PDG code
+// "V" --> coordinates of track vertex
+// "P" --> coordinates of track momentum
+// "M" --> mother label
+// "N" --> mother PDG code
+// "W" --> ESD PID weights
+//
+
+       TString output("Track info: ");
+       TString opt(option);
+       opt.ToUpper();
+       
+       if (opt.Contains("S")) {
+               output.Append(Form("sign = %d -- ", (Int_t)fSign));
+       }
+       if (opt.Contains("L")) {
+               output.Append(Form("label = %d -- ", fLabel));
+       }
+       if (opt.Contains("I")) {
+               output.Append(Form("PDG = %d -- ", fPDG));
+       }
+       if (opt.Contains("T")) {
+               output.Append(Form("true PDG = %d -- ", fTruePDG));
+       }
+       if (opt.Contains("V")) {
+               output.Append(Form("v = %f, %f, %f -- ", fV[0], fV[1], fV[2]));
+       }
+       if (opt.Contains("P")) {
+               output.Append(Form("p = %f, %f, %f -- ", fP[0], fP[1], fP[2]));
+       }
+       if (opt.Contains("M")) {
+               output.Append(Form("mum = %d -- ", fMother));
+       }
+       if (opt.Contains("N")) {
+               output.Append(Form("mum PDG = %d -- ", fMotherPDG));
+       }
+       if (opt.Contains("W")) {
+               output.Append(Form("PID wgts (e, mu, pi, K, p) = %f, %f, %f, %f, %f", fPIDwgt[0], fPIDwgt[1], fPIDwgt[2], fPIDwgt[3], fPIDwgt[4]));
+       }
+       
+       cout << output.Data() << endl;
+}
+//--------------------------------------------------------------------------------------------------------
+AliRsnDaughter AliRsnDaughter::Sum(AliRsnDaughter t1, AliRsnDaughter t2)
+{
 //
-// Sum operator overloading.
 // Builds a new AliRsnDaughter object with the sum of momenta of two particles.
 //
-{
        // create new AliRsnDaughter with default useless values for datamembers
        AliRsnDaughter out;
        
@@ -201,11 +251,11 @@ AliRsnDaughter operator+(AliRsnDaughter t1, AliRsnDaughter t2)
        }
 
        // compute total 4-momentum
-       Double_t Etot  = t1.GetEnergy() + t2.GetEnergy();
+       Double_t etot  = t1.GetEnergy() + t2.GetEnergy();
        Double_t pxTot = t1.GetPx() + t2.GetPx();
        Double_t pyTot = t1.GetPy() + t2.GetPy();
        Double_t pzTot = t1.GetPz() + t2.GetPz();
-       Double_t mass  = TMath::Sqrt(Etot*Etot - pxTot*pxTot - pyTot*pyTot - pzTot*pzTot);
+       Double_t mass  = TMath::Sqrt(etot*etot - pxTot*pxTot - pyTot*pyTot - pzTot*pzTot);
        
        //TLorentzVector v1 = track1.Get4Momentum();
        //TLorentzVector v2 = track2.Get4Momentum();