00001 #include "MCVectors.h"
00002 #include "Mint.h"
00003 #include <Midad/Base/Mint.h>
00004 #include <Midad/Base/Jint.h>
00005
00006 #include <MinosObjectMap/MomNavigator.h>
00007 #include <Record/SimSnarlRecord.h>
00008
00009 #include <TParticle.h>
00010 #include <TParticlePDG.h>
00011 #include <TClonesArray.h>
00012 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,3)
00013 #include <TView3D.h>
00014 #else
00015 #include <TView.h>
00016 #endif
00017 #include <TList.h>
00018
00019 #include "pdg_kludge.h"
00020
00021 #include <iostream>
00022 using namespace std;
00023
00024 MCVectors::MCVectors(double x1, double y1, double x2, double y2)
00025 {
00026 pdg_kludge();
00027
00028 fPad = new TPad("MCVectors","MCVectors",x1,y1,x2,y2);
00029 fPad->Draw();
00030 fPad->cd();
00031 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,3)
00032 fView = new TView3D(1,0,0);
00033 #else
00034 fView = new TView(1);
00035 #endif
00036 fView->ShowAxis();
00037 fView->SetAutoRange();
00038 fView->Centered();
00039
00040 fParticles = new TList;
00041 }
00042
00043
00044 MCVectors::~MCVectors()
00045 {
00046 }
00047
00048 #if 0
00049 static void spew_particle(TParticle* p)
00050 {
00051 int mother = p->GetFirstMother();
00052 cerr << Form("%s: Vtx=(%.2f,%.2f,%.2f,%.2f), P=(%.2f,%.2f,%.2f,%.2f) ",
00053 p->GetName(),
00054 p->Vx(),p->Vy(),p->Vz(),p->T(),
00055 p->Px(),p->Py(),p->Pz(),p->Energy())
00056 << "mom = " << mother
00057 << endl;
00058 }
00059 #endif
00060
00061 void MCVectors::Update(Mint* mint)
00062 {
00063 fPad->cd();
00064
00065
00066
00067
00068 fParticles->Delete();
00069
00070 if (!mint) return;
00071 const MomNavigator* mom = mint->GetJint().GetMom();
00072 if (!mom) return;
00073
00074 SimSnarlRecord* ssr =
00075 dynamic_cast<SimSnarlRecord*>(mom->GetFragment("SimSnarlRecord"));
00076 if (!ssr) return;
00077
00078 const TClonesArray* ctca =
00079 dynamic_cast<const TClonesArray*>
00080 (ssr->FindComponent("TClonesArray","StdHep"));
00081 if (!ctca) return;
00082
00083
00084 int ind, siz = ctca->GetEntriesFast();
00085 double x1,y1,z1,x2,y2,z2;
00086 x1=y1=z1=x2=y2=z2=0.0;
00087 TParticle* first = 0;
00088 for (ind=0; ind < siz; ++ind) {
00089 TParticle* tmp = dynamic_cast<TParticle*>((*ctca)[ind]);
00090 if (!tmp) {
00091 cerr << "Non particle: " << (*ctca)[ind]->GetName() << endl;
00092 continue;
00093 }
00094
00095 TParticle* p = new TParticle(*tmp);
00096 fParticles->Add(p);
00097
00098 if (!ind) first = p;
00099
00100 p->SetProductionVertex( 0,0,0,0);
00101
00102 int mother = p->GetFirstMother();
00103 if (mother < 0) p->SetLineColor(2);
00104
00105 p->Draw();
00106 }
00107 fPad->Modified();
00108 fPad->Update();
00109
00110 }
00111
00112
00113 ClassImp(MCVectors)