00001 #include <TROOT.h>
00002 #include <TPaveLabel.h>
00003 #include <TRint.h>
00004 #include <TCanvas.h>
00005 #include <TTree.h>
00006 #include <TFile.h>
00007 #include <TSystem.h>
00008 #include <TGeoManager.h>
00009 #include <TGeoMatrix.h>
00010 #include <TCanvas.h>
00011 #include <iostream>
00012 #include <TreeClass.hh>
00013 #include <sstream>
00014 #include "Log.hh"
00015
00016 #include "Run.hh"
00017 #include "Board.hh"
00018 #include "Chip.hh"
00019 #include "Dif.hh"
00020 #include "Chamber.hh"
00021 #include "Event.hh"
00022 #include "Detector.hh"
00023 #include "Centaure.hh"
00024 #include "GassiplexChamber1.hh"
00025 #include "GassiplexChamber4.hh"
00026 #include "HardRockChamber6.hh"
00027 #include "XMLTool.hh"
00028 #include "MicroException.hh"
00029
00030
00031 #include <TApplication.h>
00032 #include <TGClient.h>
00033 #include <TGListBox.h>
00034 #include <TList.h>
00035
00036
00037
00038 using namespace std;
00039
00040
00041
00042 int main(int argc, char **argv)
00043
00044 {
00045
00046 FILELog::ReportingLevel() = FILELog::FromString(INFO);
00047
00048
00049 if ( argc != 2 ) {
00050 FILE_LOG(logERROR) << "usage: geometryDispay streeFile" << endl;
00051 exit(1);
00052 }
00053
00054
00055
00056 string steerName;
00057 steerName.assign(argv[1]);
00058
00059 TApplication *theApp;
00060
00061 argc = 1;
00062 theApp = new TRint("App", &argc, argv);
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 FILE *file = fopen(steerName.c_str(), "r");
00074 if(file == NULL){
00075 FILE_LOG(logERROR) << "Steer file ["<< steerName.c_str() << "] does not exist" << endl;
00076 exit(0);
00077 fclose(file);
00078 }
00079
00080 SteerDesc steerDesc;
00081 XMLTool xml;
00082 xml.parse(steerDesc, steerName);
00083
00084 Detector detector;
00085 detector.build(steerDesc);
00086
00087 Run run(detector);
00088 steerDesc.setRun(run);
00089
00090 fclose(file);
00091
00092 FILE_LOG(logINFO) << run << endl;
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 TCanvas *c1 = new TCanvas("c1","Analyze.mac",620,790);
00105 c1->Range(-1,0,19,30);
00106 string txt = "";
00107
00108
00109 TGeoManager *frame =new TGeoManager("Frame","mM event displayer");
00110
00111 TGeoMaterial *mat = new TGeoMaterial("SomeMaterial",1,1,1);
00112 TGeoMedium *med = new TGeoMedium("SomeMedium",1,mat);
00113
00114
00115 TGeoVolume *world = frame->MakeBox("World", med, 1, 1, 1);
00116 frame->SetMaxVisNodes(9216 * detector.getNumberOfChambers());
00117
00118 int nbChannel = 0;
00119
00120 try {
00121 const ChamberMap_t &chambers = detector.getChambers();
00122 int color = 0;
00123 for (ChamberMap_t::const_iterator chamberIt = chambers.begin(); chamberIt != chambers.end(); ++chamberIt) {
00124 Chamber& chamber = *(chamberIt->second);
00125 const BoardMap_t &boards = chamber.getBoards();
00126
00127 int color = 3;
00128 for (BoardMap_t::const_iterator boardIt = boards.begin(); boardIt != boards.end(); ++boardIt) {
00129 Board& board = *(boardIt->second);
00130 const ChipMap_t &chips = board.getChips();
00131
00132 for (ChipMap_t::const_iterator chipIt = chips.begin(); chipIt != chips.end(); ++chipIt) {
00133 Chip& chip = *(chipIt->second);
00134 const ChannelMap_t &channels = chip.getChannels();
00135
00136 for (ChannelMap_t::const_iterator channelIt = channels.begin(); channelIt != channels.end(); ++channelIt)
00137 {
00138 Channel& channel = *(channelIt->second);
00139
00140
00141
00142 float xHalfLength = .098;
00143 float yHalfLength = .098;
00144 float zHalfLength = .12;
00145
00146 xHalfLength = (float) channel.getXLength() / 2 - .1;
00147 yHalfLength = (float) channel.getYLength() / 2 - .1 ;
00148 zHalfLength = .1;
00149
00150
00151 float x=channel.getX() ;
00152 float y=channel.getY() ;
00153 float z=channel.getZ() ;
00154
00155
00156
00157
00158 string padID="";
00159 stringstream currentpad;
00160 currentpad<<channel.getSoftId();
00161 padID="pad_"+currentpad.str();
00162
00163
00164 TGeoVolume *pad = frame->MakeBox(padID.c_str(),med,zHalfLength,xHalfLength,yHalfLength );
00165
00166 stringstream ch;
00167 ch<<channel.getSoftId();
00168
00169
00170 world->AddNode(pad,1,new TGeoTranslation(z,x,y));
00171 nbChannel++;
00172
00173 color = 2;
00174
00175 if ( channel.getHardId() % 96 == 0 )
00176 { color = 4; }
00177
00178 color = channel.getHardId() % 96;
00179 cout << color << endl;
00180
00181
00182 pad->SetLineColor( color);
00183 pad->SetFillStyle(1001);
00184 }
00185 }
00186 }
00187 }
00188 }
00189 catch ( MicroException e )
00190 {
00191 cout << e.getMessage();
00192 }
00193 frame->SetTopVolume(world);
00194 frame->CloseGeometry();
00195
00196 world->Draw();
00197
00198
00199 theApp->Run();
00200 delete theApp;
00201
00202
00203 return 0;
00204 }