Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MCTree.cxx

Go to the documentation of this file.
00001 #include "MCTree.h"
00002 #include <Midad/Gui/GuiTree.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 <TClonesArray.h>
00011 
00012 #include <string>
00013 using namespace std;
00014 
00015 #include <sigc++/sigc++.h>
00016 using namespace SigC;
00017 
00018 #include "pdg_kludge.h"
00019 
00020 
00021 
00022 MCTree::MCTree(GuiTree* gtv)
00023     : fTree(gtv)
00024 {
00025     pdg_kludge();
00026 }
00027 MCTree::~MCTree()
00028 {
00029     cerr << "MCTree::~MCTree()\n";
00030 }
00031 
00032 
00033 void MCTree::Update(Mint* mint)
00034 {
00035     if (!fTree) return;
00036     fTree->DeleteAllItems();
00037 
00038     if (!mint) return;
00039     const MomNavigator* mom = mint->GetJint().GetMom();
00040     if (!mom) return;
00041 
00042     SimSnarlRecord* ssr = 
00043         dynamic_cast<SimSnarlRecord*>(mom->GetFragment("SimSnarlRecord"));
00044     if (!ssr) return;
00045 
00046     this->AddSimSnarl(ssr);
00047 }
00048 
00049 static const char* tool_tip(TParticle* p)
00050 {
00051     return Form("%s: Vtx=(%.2f,%.2f,%.2f,%.2f),  P=(%.2f,%.2f,%.2f,%.2f)",
00052                 p->GetName(),
00053                 p->Vx(),p->Vy(),p->Vz(),p->T(),
00054                 p->Px(),p->Py(),p->Pz(),p->Energy());
00055 }
00056 
00057 static void bark(TParticle* p)
00058 {
00059     cerr << tool_tip(p) << endl;
00060 }
00061 
00062 void MCTree::AddSimSnarl(SimSnarlRecord* ssr)
00063 {
00064     const TClonesArray* ctca = 
00065         dynamic_cast<const TClonesArray*>
00066         (ssr->FindComponent("TClonesArray","StdHep"));
00067     if (!ctca) return;
00068 
00069     vector<GuiTreeEntry*> entries;
00070 
00071     int ind, siz = ctca->GetEntriesFast();
00072     for (ind=0; ind < siz; ++ind) {
00073         TParticle* part = dynamic_cast<TParticle*>((*ctca)[ind]);
00074         if (!part) {
00075             cerr << "Non particle: " << (*ctca)[ind]->GetName() << endl;
00076             continue;
00077         }
00078 
00079         GuiTreeEntry *entry = 0;
00080         int mother = part->GetFirstMother();
00081         if (mother != -1) entry = entries[mother];
00082 
00083         cerr << "Mother=" << mother << " ind=" << ind
00084              << " " << part->GetName() 
00085              << endl;
00086         GuiTreeEntry* e=0;
00087         if (part->GetStatusCode() >= 200) 
00088             e = fTree->AddEntry(entry,Form("(%s)",part->GetName()));
00089         else
00090             e = fTree->AddEntry(entry,part->GetName());
00091         e->on_mouse_over.connect(bind(slot(bark),part));
00092         fTree->SetToolTipItem(e,tool_tip(part));
00093 
00094         entries.push_back(e);
00095         fTree->OpenItem(e);
00096     }
00097 
00098     
00099 }

Generated on Mon Feb 15 11:06:58 2010 for loon by  doxygen 1.3.9.1