00001
00002 #include <TROOT.h>
00003 #include <TPaveLabel.h>
00004 #include <TRint.h>
00005 #include <TCanvas.h>
00006 #include <TTree.h>
00007 #include <TFile.h>
00008 #include <TSystem.h>
00009 #include <TGeoManager.h>
00010 #include <TGeoMatrix.h>
00011 #include <TCanvas.h>
00012 #include <iostream>
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 "Hardroc1Chamber.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
00126 cout << "========= Cahmber [" << chamber.getId() << "]" <<endl;
00127
00128
00129
00130
00131 FILE_LOG(logINFO) << endl << "Chamber ID[" << chamber.getId() << "]" << endl;
00132 string result = (chamber.getXrotation() == false) ? "No rotation over X" : "There is a rotation over X";
00133 FILE_LOG(logINFO) << result << endl;
00134 result = (chamber.getYrotation() == false) ? "No rotation over Y" : "There is a rotation over Y";
00135 FILE_LOG(logINFO) << result << endl;
00136
00137
00138 const BoardMap_t &boards = chamber.getBoards();
00139
00140 int color = 3;
00141 for (BoardMap_t::const_iterator boardIt = boards.begin(); boardIt != boards.end(); ++boardIt) {
00142 Board& board = *(boardIt->second);
00143 const ChipMap_t &chips = board.getChips();
00144
00145 for (ChipMap_t::const_iterator chipIt = chips.begin(); chipIt != chips.end(); ++chipIt) {
00146 Chip& chip = *(chipIt->second);
00147 const ChannelMap_t &channels = chip.getChannels();
00148
00149 for (ChannelMap_t::const_iterator channelIt = channels.begin(); channelIt != channels.end(); ++channelIt)
00150 {
00151
00152 Channel& channel = *(channelIt->second);
00153
00154
00155
00156 float xHalfLength = .098;
00157 float yHalfLength = .098;
00158 float zHalfLength = .12;
00159
00160 xHalfLength = (float) channel.getXLength() / 2 - .1;
00161 yHalfLength = (float) channel.getYLength() / 2 - .1 ;
00162 zHalfLength = .1;
00163
00164
00165 float x=channel.getX() ;
00166 float y=channel.getY() ;
00167 float z=channel.getZ() ;
00168
00169
00170
00171
00172 string padID;
00173
00174 padID = channel.getSoftId().toString();
00175
00176
00177 TGeoVolume *pad = frame->MakeBox(padID.c_str(),med,zHalfLength,yHalfLength,xHalfLength );
00178
00179 stringstream ch;
00180
00181
00182
00183 world->AddNode(pad,1,new TGeoTranslation(z,-y,x));
00184 nbChannel++;
00185
00186
00187 color = ( channel.getChip().getBoard().getId()) + 1 ;
00188
00189
00190
00191
00192 pad->SetLineColor( color);
00193 pad->SetFillStyle(1001);
00194 }
00195 }
00196 }
00197 }
00198 }
00199 catch ( MicroException e )
00200 {
00201 cout << e.getMessage();
00202 }
00203 frame->SetTopVolume(world);
00204 frame->CloseGeometry();
00205
00206 world->Draw();
00207
00208
00209 FILE_LOG(logINFO) << "" << endl;
00210 FILE_LOG(logINFO) << " X" << endl;
00211 FILE_LOG(logINFO) << " " << endl;
00212 FILE_LOG(logINFO) << " /\\" << endl;
00213 FILE_LOG(logINFO) << " |" << endl;
00214 FILE_LOG(logINFO) << " |" << endl;
00215 FILE_LOG(logINFO) << " |" << endl;
00216 FILE_LOG(logINFO) << "SYSTEM de COORDONNEES: (0,0) en bas a gauche X---> Y " << endl;
00217 FILE_LOG(logINFO) << " Z sortant." << endl;
00218
00219
00220 theApp->Run();
00221 delete theApp;
00222
00223
00224 return 0;
00225 }