00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00015
00016 #include <TParticlePDG.h>
00017
00018 #include "MessageService/MsgService.h"
00019 #include "MCApplication/MCAppParticle.h"
00020
00021 ClassImp(MCAppParticle)
00022
00023 CVSID("$Id: MCAppParticle.cxx,v 1.11 2009/06/22 04:11:21 kasahara Exp $");
00024
00025 std::ostream& operator << (std::ostream& os, const MCAppParticle& mp)
00026 { return mp.Print(os); }
00027
00028
00029 MCAppParticle::MCAppParticle(Int_t id,Int_t pdg, Int_t statuscode,
00030 Double_t px, Double_t py, Double_t pz, Double_t e,
00031 Double_t vx, Double_t vy, Double_t vz, Double_t tof,
00032 TMCProcess process)
00033 : fID(id), fTParticle(pdg,statuscode,-1,-1,-1,-1,
00034 px,py,pz,e,vx,vy,vz,tof), fProcess(process),
00035 fPrintPreface(""), fPrintOption("") {
00036
00037
00038 }
00039
00040
00041 MCAppParticle::MCAppParticle(Int_t id,TParticle* particle, TMCProcess process)
00042 : fID(id), fTParticle(), fProcess(process),
00043 fPrintPreface(""),fPrintOption("") {
00044
00045
00046
00047 if ( particle ) fTParticle = *particle;
00048
00049 }
00050
00051
00052 MCAppParticle::MCAppParticle() : fID(-1), fTParticle(), fProcess(kPNoProcess),
00053 fPrintPreface(""), fPrintOption("") {
00054
00055
00056 }
00057
00058
00059
00060 MCAppParticle::~MCAppParticle() {
00061
00062
00063 }
00064
00065
00066 std::ostream& MCAppParticle::Print(std::ostream& os) const {
00067
00068
00069
00070
00071
00072 os << GetPrintPreface().c_str() << GetID() << ")";
00073 os << GetPdgCode() << "/" << fTParticle.GetName()
00074 << " s: " << GetStatusCode() << "/"
00075 << GetStatusCodeName().c_str()
00076 << " v: " << fTParticle.Vx()
00077 << " " << fTParticle.Vy()
00078 << " " << fTParticle.Vz()
00079 << " t: " << fTParticle.T()
00080 << " p: " << fTParticle.Px()
00081 << " " << fTParticle.Py()
00082 << " " << fTParticle.Pz()
00083 << " P:" << GetParentID(0)
00084 << "," << GetParentID(1)
00085 << " C:" << GetChildID(0)
00086 << " to " << GetChildID(GetNChildren()-1)
00087 << "." << endl;
00088
00089 if ( !strcmp(GetPrintOption().c_str(),"full") ) {
00090 Int_t nd = GetNChildren();
00091 if ( nd > 0 ) {
00092 os << GetPrintPreface().c_str() << " " << nd;
00093 if ( nd == 1 ) os << " Child:" << endl;
00094 else os << " Children:" << endl;
00095
00096 for ( Int_t id = 0; id < nd; id++ ) {
00097 MCAppParticle* cdpart = const_cast<MCAppParticle*>(GetChild(id));
00098 std::string saveoption = cdpart->GetPrintOption();
00099 std::string savepreface = cdpart->GetPrintPreface();
00100 cdpart -> SetPrintOption(GetPrintOption());
00101 cdpart -> SetPrintPreface(GetPrintPreface() + " ");
00102 os << *(cdpart);
00103 cdpart -> SetPrintOption(saveoption);
00104 cdpart -> SetPrintPreface(savepreface);
00105 }
00106 }
00107 }
00108
00109
00110 return os;
00111
00112 }
00113
00114
00115 void MCAppParticle::Print(Option_t* ) const {
00116
00117
00118
00119
00120 Print(std::cout);
00121 return;
00122
00123 }
00124
00125
00126 const MCAppParticle* MCAppParticle::GetChild(UInt_t id) const {
00127
00128
00129 if ( id >= fChildren.size() ) return 0;
00130
00131 const MCAppParticle* child = fChildren[id];
00132
00133 return child;
00134
00135 }
00136
00137
00138
00139 const MCAppParticle* MCAppParticle::GetParent(UInt_t id) const {
00140
00141
00142 if ( id >= fParents.size() ) return 0;
00143
00144 const MCAppParticle* parent = fParents[id];
00145
00146 return parent;
00147
00148 }
00149
00150
00151 const MCAppParticle* MCAppParticle::GetSibling(UInt_t id) const {
00152
00153
00154
00155
00156
00157 if ( id >= fSiblings.size() ) return 0;
00158
00159 const MCAppParticle* sibling = fSiblings[id];
00160
00161 return sibling;
00162
00163 }
00164
00165
00166 void MCAppParticle::AddChild(const MCAppParticle* child) {
00167
00168
00169 if ( !child ) {
00170 MSG("MCApp",Msg::kWarning)
00171 << "MCAppParticle::AddChild received null child ptr" << endl;
00172 return;
00173 }
00174
00175 fChildren.push_back(child);
00176
00177 }
00178
00179
00180 void MCAppParticle::AddParent(const MCAppParticle* parent) {
00181
00182
00183 if ( !parent ) {
00184 MSG("MCApp",Msg::kWarning)
00185 << "MCAppParticle::AddParent received null parent ptr" << endl;
00186 return;
00187 }
00188
00189 fParents.push_back(parent);
00190
00191 }
00192
00193
00194 void MCAppParticle::AddSibling(const MCAppParticle* sibling) {
00195
00196
00197
00198
00199
00200 if ( !sibling ) {
00201 MSG("MCApp",Msg::kWarning)
00202 << "MCAppParticle::AddSibling received null sibling ptr" << endl;
00203 return;
00204 }
00205
00206 fSiblings.push_back(sibling);
00207
00208 }
00209
00210
00211 Double_t MCAppParticle::GetCharge() {
00212 return ( fTParticle.GetPDG() ) ? fTParticle.GetPDG() -> Charge() : 0;
00213 }
00214
00215
00216 void MCAppParticle::ProductionVertex(TLorentzVector& lv) const {
00217 lv.SetXYZT(0,0,0,0);
00218 fTParticle.ProductionVertex(lv);
00219 }
00220
00221
00222 void MCAppParticle::ProductionMomentum(TLorentzVector& lv) const {
00223 lv.SetPxPyPzE(0,0,0,0);
00224 fTParticle.Momentum(lv);
00225 }
00226
00227
00228 void MCAppParticle::GetPolarisation(TVector3& vec) {
00229 vec.SetXYZ(0,0,0);
00230 fTParticle.GetPolarisation(vec);
00231 }
00232
00233
00234 Int_t MCAppParticle::GetParentID(UInt_t i) const {
00235 const MCAppParticle* parent = GetParent(i);
00236 if ( parent ) return parent->GetID();
00237 else return -1;
00238 }
00239
00240
00241 Int_t MCAppParticle::GetChildID(UInt_t i) const {
00242 const MCAppParticle* child = GetChild(i);
00243 if ( child ) return child->GetID();
00244 else return -1;
00245 }
00246
00247
00248 Int_t MCAppParticle::GetSiblingID(UInt_t i) const {
00249 const MCAppParticle* sibling = GetSibling(i);
00250 if ( sibling ) return sibling->GetID();
00251 else return -1;
00252 }