123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- #include <iostream>
- using namespace std;
- #include "TObject.h"
- #include "TParticle.h"
- #include "UParticle.h"
- //____________________________________________________________________
- //
- // UParticle
- //
- // Class for particle description.
- //
- //--------------------------------------------------------------------
- UParticle::UParticle()
- {
- // Default constructor
- fIndex = fPdg = fStatus = fParent = fParentDecay = fMate = fDecay = 0;
- fChild[0] = fChild[1] = 0;
- fPx = fPy = fPz = fE = 0.;
- fX = fY = fZ = fT = 0.;
- fWeight = 0.;
- }
- //--------------------------------------------------------------------
- //--------------------------------------------------------------------
- UParticle::UParticle(Int_t index, Int_t pdg, Int_t status,
- Int_t parent, Int_t parentDecay,
- Int_t mate, Int_t decay, Int_t child[2],
- Double_t px, Double_t py, Double_t pz, Double_t e,
- Double_t x, Double_t y, Double_t z, Double_t t,
- Double_t weight)
- {
- // Standard constructor
- fIndex = index;
- fPdg = pdg;
- fStatus = status;
- fParent = parent;
- fParentDecay = parentDecay;
- fMate = mate;
- fDecay = decay;
- fChild[0] = child[0];
- fChild[1] = child[1];
- fPx = px;
- fPy = py;
- fPz = pz;
- fE = e;
- fX = x;
- fY = y;
- fZ = z;
- fT = t;
- fWeight = weight;
- }
- //--------------------------------------------------------------------
- //--------------------------------------------------------------------
- UParticle::UParticle(Int_t index, Int_t pdg, Int_t status,
- Int_t parent, Int_t parentDecay,
- Int_t mate, Int_t decay, Int_t child[2],
- TLorentzVector mom, TLorentzVector pos,
- Double_t weight)
- {
- // Standard constructor
- fIndex = index;
- fPdg = pdg;
- fStatus = status;
- fParent = parent;
- fParentDecay = parentDecay;
- fMate = mate;
- fDecay = decay;
- fChild[0] = child[0];
- fChild[1] = child[1];
- fPx = mom.Px();
- fPy = mom.Py();
- fPz = mom.Pz();
- fE = mom.E();
- fX = pos.X();
- fY = pos.Y();
- fZ = pos.Z();
- fT = pos.T();
- fWeight = weight;
- }
- //--------------------------------------------------------------------
- //--------------------------------------------------------------------
- UParticle::UParticle(const UParticle& right)
- {
- // Copy constructor
- *this = right;
- }
- //--------------------------------------------------------------------
- //--------------------------------------------------------------------
- UParticle::UParticle(const TParticle &right)
- {
- // Copy constructor from the TParticle
- *this = right;
- }
- //--------------------------------------------------------------------
- //--------------------------------------------------------------------
- UParticle::~UParticle()
- {
- // Destructor
- }
- //--------------------------------------------------------------------
- //--------------------------------------------------------------------
- const UParticle& UParticle::operator = (const UParticle& right)
- {
- // Assignment operator
- fIndex = right.fIndex;
- fPdg = right.fPdg;
- fStatus = right.fStatus;
- fParent = right.fParent;
- fParentDecay = right.fParentDecay;
- fMate = right.fMate;
- fDecay = right.fDecay;
- fChild[0] = right.fChild[0];
- fChild[1] = right.fChild[1];
- fPx = right.fPx;
- fPy = right.fPy;
- fPz = right.fPz;
- fE = right.fE;
- fX = right.fX;
- fY = right.fY;
- fZ = right.fZ;
- fT = right.fT;
- fWeight = right.fWeight;
- return (*this);
- }
- //--------------------------------------------------------------------
- //--------------------------------------------------------------------
- const UParticle& UParticle::operator = (const TParticle &right)
- {
- // Assignment operator from the TParticle
- fIndex = 0;
- fPdg = right.GetPdgCode();
- fStatus = right.GetStatusCode();
- fParent = right.GetFirstMother();
- fParentDecay = 0;
- fMate = 0;
- fDecay = 0;
- fChild[0] = right.GetFirstDaughter();
- fChild[1] = right.GetLastDaughter();
- fPx = right.Px();
- fPy = right.Py();
- fPz = right.Pz();
- fE = right.Energy();
- fX = right.Vx();
- fY = right.Vy();
- fZ = right.Vz();
- fT = right.T();
- fWeight = right.GetWeight();
- return (*this);
- }
- //--------------------------------------------------------------------
- //--------------------------------------------------------------------
- const Bool_t UParticle::operator == (const UParticle& right) const
- {
- // If equal operator
- return (
- fIndex == right.fIndex &&
- fPdg == right.fPdg &&
- fStatus == right.fStatus &&
- fParent == right.fParent &&
- fParentDecay == right.fParentDecay &&
- fMate == right.fMate &&
- fDecay == right.fDecay &&
- fChild[0] == right.fChild[0] &&
- fChild[1] == right.fChild[1] &&
- ((TMath::Abs((fPx-right.fPx)/fPx)<0.0001) ||
- (TMath::Abs(fPx)<1e-16&&TMath::Abs(right.fPx)<1e-16)) &&
- ((TMath::Abs((fPy-right.fPy)/fPy)<0.0001) ||
- (TMath::Abs(fPy)<1e-16&&TMath::Abs(right.fPy)<1e-16)) &&
- ((TMath::Abs((fPz-right.fPz)/fPz)<0.0001) ||
- (TMath::Abs(fPz)<1e-16&&TMath::Abs(right.fPz)<1e-16)) &&
- ((TMath::Abs((fE-right.fE)/fE)<0.0001) ||
- (TMath::Abs(fE)<1e-16&&TMath::Abs(right.fE)<1e-16)) &&
- ((TMath::Abs((fX-right.fX)/fX)<0.0001) ||
- (TMath::Abs(fX)<1e-16&&TMath::Abs(right.fX)<1e-16)) &&
- ((TMath::Abs((fY-right.fY)/fY)<0.0001) ||
- (TMath::Abs(fY)<1e-16&&TMath::Abs(right.fY)<1e-16)) &&
- ((TMath::Abs((fZ-right.fZ)/fZ)<0.0001) ||
- (TMath::Abs(fZ)<1e-16&&TMath::Abs(right.fZ)<1e-16)) &&
- ((TMath::Abs((fT-right.fT)/fT)<0.0001) ||
- (TMath::Abs(fT)<1e-16&&TMath::Abs(right.fT)<1e-16)) &&
- ((TMath::Abs((fWeight-right.fWeight)/fWeight)<0.0001) ||
- (TMath::Abs(fWeight)<1e-16&&TMath::Abs(right.fWeight)<1e-16))
- );
- }
- //--------------------------------------------------------------------
- //--------------------------------------------------------------------
- void UParticle::Print(Option_t* option)
- {
- // Print the data members to the standard output
- cout << "------------------------------------------------" << endl
- << "-I- Particle -I-" << endl
- << "Index : " << fIndex << endl
- << "PDG code : " << fPdg << endl
- << "Status code : " << fStatus << endl
- << "Parent index : " << fParent << endl
- << "Parent decay index : " << fParentDecay << endl
- << "Last collision partner : " << fMate << endl
- << "Decay index : " << fDecay << endl
- << "First child index : " << fChild[0] << endl
- << "Last child index : " << fChild[1] << endl
- << "Momentum (px, py, pz) (GeV) : (" << fPx << ", " << fPy << ", " << fPz << ")" << endl
- << "Energy (GeV) : " << fE << endl
- << "Position (x, y, z) (fm) : (" << fX << ", " << fY << ", " << fZ << ")" << endl
- << "Creation time (fm) : " << fT << endl
- << "Weight : " << fWeight << endl
- << "------------------------------------------------" << endl;
- }
- //--------------------------------------------------------------------
- ClassImp(UParticle);
|