00001 #include <TROOT.h>
00002 #include <TRint.h>
00003 #include <TCanvas.h>
00004 #include <TTree.h>
00005 #include <TFile.h>
00006 #include <TSystem.h>
00007 #include <TGeoManager.h>
00008 #include <TGeoMatrix.h>
00009 #include <iostream>
00010 #include <TreeClass.hh>
00011 #include <sstream>
00012 #include "Log.hh"
00013
00014 #include "Run.hh"
00015 #include "Chamber.hh"
00016 #include "Event.hh"
00017 #include "Detector.hh"
00018 #include "Centaure.hh"
00019 #include "DiracLabview.hh"
00020 #include "DiracChamber1.hh"
00021 #include "GassiplexChamber1.hh"
00022 #include "GassiplexChamber4.hh"
00023 #include "HardRockChamber6.hh"
00024 #include "XMLTool.hh"
00025 #include "MicroException.hh"
00026
00027
00028 #include <TApplication.h>
00029 #include <TGClient.h>
00030
00031 #include <TGListBox.h>
00032 #include <TList.h>
00033
00034
00035
00036 using namespace std;
00037
00038
00039
00040 int main(int argc, char **argv)
00041
00042 {
00043
00044 FILELog::ReportingLevel() = FILELog::FromString(INFO);
00045
00046
00047 if ( argc != 4 ) {
00048 FILE_LOG(logERROR) << "usage: EventDisplay streeFile rootFile eventNumber" << endl;
00049 exit(1);
00050 }
00051
00052
00053
00054 string steerName;
00055 steerName.assign(argv[1]);
00056
00057 string rootName;
00058 rootName.assign(argv[2]);
00059
00060 int event = atoi(argv[3]);
00061
00062 TApplication *theApp;
00063
00064 argc = 1;
00065 theApp = new TRint("App", &argc, argv);
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 FILE *file = fopen(steerName.c_str(), "r");
00077 if(file == NULL){
00078 FILE_LOG(logERROR) << "Steer file ["<< steerName.c_str() << "] does not exist" << endl;
00079 exit(0);
00080 fclose(file);
00081 }
00082
00083 SteerDesc steerDesc;
00084 XMLTool xml;
00085 xml.parse(steerDesc, steerName);
00086 Detector detector;
00087
00088 Run run(detector);
00089 if ( !steerDesc.setRun(run))
00090 {
00091 exit(-1);
00092 }
00093 fclose(file);
00094
00095 FILE_LOG(logINFO) << run << endl;
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 gSystem->Load("libMicro.so");
00109 TFile *f = new TFile(rootName.c_str());
00110 if ( f->IsZombie()) {
00111 FILE_LOG(logERROR) << "Root file ["<< rootName.c_str() << "] does not exist" << endl;
00112 exit(-1);
00113 }
00114 TTree *tree = (TTree *) gROOT->FindObject("t1");
00115
00116
00117 gSystem->Load("libGeom");
00118 TGeoManager *frame =new TGeoManager("Frame","mM event displayer");
00119
00120 TGeoMaterial *mat = new TGeoMaterial("SomeMaterial",1,1,1);
00121 TGeoMedium *med = new TGeoMedium("SomeMedium",1,mat);
00122
00123
00124
00125
00126 TGeoVolume *world = frame->MakeBox("World", med, 1, 1, 1);
00127
00128 FILE_LOG(logINFO) << "Number of reoncstruct events: " << tree->GetEntries() << endl;
00129 MTEvent *evt = new MTEvent();
00130 TBranch *branch= tree->GetBranch("MTEvent");
00131 branch->SetAddress(&evt);
00132
00133 tree->GetEntry(event);
00134
00135 Int_t NC=evt->GetNchannel();
00136 frame->SetMaxVisNodes(NC);
00137
00138 float x,y,z;
00139 for(int i=0;i<NC;i++)
00140 {
00141 int nodes = world->CountNodes();
00142
00143 if ( world->CountNodes() < 1000 )
00144 {
00145
00146 MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(i);
00147
00148 float xLength = .098 * 4;
00149 float yLength = .098 * 4;
00150 float zLength = .12;
00151
00152
00153 string padID="";
00154 stringstream currentpad;
00155 currentpad<<i;
00156 padID="pad_"+currentpad.str();
00157
00158 TGeoVolume *pad = frame->MakeBox(padID.c_str(),med,xLength,yLength,zLength );
00159 z=channel->GetZ();
00160 x=channel->GetX();
00161 y=channel->GetY();
00162
00163 int color;
00164 int sMax = 30;
00165 stringstream ch;
00166 ch<<i;
00167
00168
00169 color = channel->GetValue();
00170 color=60+40.*min(1.,(1.*color-20)/sMax);
00171
00172 world->AddNode(pad,1,new TGeoTranslation(x,y,z));
00173 pad->SetLineColor(color);
00174 }
00175 else
00176 {
00177 FILE_LOG(logERROR) << "Too Mnay Nodes !" << endl;
00178
00179 }
00180
00181 }
00182 frame->SetTopVolume(world);
00183 frame->CloseGeometry();
00184
00185 world->Draw();
00186
00187 theApp->Run();
00188 delete theApp;
00189
00190
00191 return 0;
00192 }