00001
00002
00003
00004
00005 #include "GaudiKernel/Algorithm.h"
00006
00007 #include "GaudiKernel/MsgStream.h"
00008 #include "GaudiKernel/AlgFactory.h"
00009 #include "GaudiKernel/IDataProviderSvc.h"
00010 #include "GaudiKernel/DataObject.h"
00011 #include "GaudiKernel/SmartDataPtr.h"
00012 #include "GaudiKernel/DataSvc.h"
00013
00014
00015 #include "GuiSvc/IGuiSvc.h"
00016 #include "gui/DisplayControl.h"
00017 #include "gui/GuiMgr.h"
00018
00019
00020
00021 #include "GlastEvent/TopLevel/EventModel.h"
00022 #include "GlastEvent/MonteCarlo/McParticle.h"
00023 #include "GlastEvent/MonteCarlo/McVertex.h"
00024
00026
00027 class McDisplay : public Algorithm {
00028
00029 public:
00030 McDisplay(const std::string& name, ISvcLocator* pSvcLocator);
00031 StatusCode initialize();
00032 StatusCode execute();
00033 StatusCode finalize();
00034
00035
00037 class DisplayMcEvent;
00038
00040 class PrintMcEvent;
00041
00042 private:
00043 bool m_display_enabled;
00044 bool m_print_enabled;
00045 const McVertex* m_root;
00046 };
00047
00048
00049 static const AlgFactory<McDisplay> Factory;
00050 const IAlgFactory& McDisplayFactory = Factory;
00051
00052
00053 McDisplay::McDisplay(const std::string& name, ISvcLocator* pSvcLocator)
00054 :Algorithm(name, pSvcLocator)
00055 {
00056 declareProperty("display_enabled", m_display_enabled="true");
00057 declareProperty("print_enabled", m_print_enabled="true");
00058
00059 }
00060
00062
00063 {
00064
00065 public:
00066 McVertexRep( const McVertex * vert);
00067 void update(){}
00068 };
00069 McVertexRep::McVertexRep(const McVertex * vert) {
00070 if( vert->finalPosition().mag() != 0 ) {
00071
00072 bool neutral = (vert->mcParticle()->particleID())==22;
00073 setColor( neutral? "white" : "black");
00074 moveTo(vert->initialPosition());
00075 lineTo(vert->finalPosition());
00076 }
00077
00078 SmartRefVector<McParticle>::const_iterator i;
00079 for( i = vert->daughterMcParticles().begin(); i != vert->daughterMcParticles().end();i++){
00080 const McVertex* v = (*i)->mcVertex();
00081 append(McVertexRep(v));
00082 }
00083
00084 }
00086 class McDisplay::DisplayMcEvent : public gui::DisplayRep {
00087 public:
00088
00089 DisplayMcEvent(IDataProviderSvc* dps): m_dps(dps){}
00090
00091 void update() {
00092 McVertexCol* vertList = SmartDataPtr<McVertexCol>(m_dps, EventModel::MC::McVertexCol);
00093
00094 if(vertList) {
00095 setColor("black");
00096 const McVertex* launch = *vertList->begin();
00097 markerAt(launch->initialPosition());
00098 McVertexRep rep(launch );
00099 append(rep);
00100 }
00101 }
00102 private:
00103 IDataProviderSvc* m_dps;
00104 };
00106 class McDisplay::PrintMcEvent : public gui::Command {
00107 public:
00108
00109 PrintMcEvent(IDataProviderSvc* dps): m_dps(dps){}
00110
00111 void execute() {
00112 McVertexList * vertList = SmartDataPtr<McVertexList>(m_dps, "/Event/MC/McVertices");
00113
00114 if(vertList) {
00115 std::cout << "print not enabled yet" << std::endl;
00116
00117 }
00118 }
00119 private:
00120 IDataProviderSvc* m_dps;
00121 };
00122
00123
00126 StatusCode McDisplay::initialize() {
00127 using namespace gui;
00128 MsgStream log(msgSvc(), name());
00129 log << MSG::INFO << "initialize" << endreq;
00130
00131
00132
00133 IGuiSvc* guiSvc=0;
00134
00135 if ( service("GuiSvc", guiSvc).isFailure() ){
00136 log << MSG::WARNING << "GuiSvc not found, so no event display" << endreq;
00137 } else {
00138
00139
00140 DisplayControl& display = guiSvc->guiMgr()->display();
00141
00142 display.add( new DisplayMcEvent(eventSvc()), "McEvent", m_display_enabled);
00143
00144
00145 PrintControl& printer = guiSvc->guiMgr()->printer();
00146 printer.add(new PrintMcEvent(eventSvc()), "McEvent", m_print_enabled);
00147 }
00148 return StatusCode::SUCCESS;
00149 }
00150
00151 StatusCode McDisplay::execute() {
00152 return StatusCode::SUCCESS;
00153 }
00154
00155 StatusCode McDisplay::finalize() {
00156
00157 return StatusCode::SUCCESS;
00158 }
00159