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 <Toolbox.hh>
00015
00016 #include "event/Run.hh"
00017 #include "event/Event.hh"
00018
00019 #include "geometry/Board.hh"
00020 #include "geometry/Chip.hh"
00021 #include "geometry/Dif.hh"
00022 #include "geometry/Chamber.hh"
00023 #include "geometry/Detector.hh"
00024 #include "geometry/GassiplexChamber1.hh"
00025 #include "geometry/GassiplexChamber4.hh"
00026 #include "geometry/Hardroc1Chamber.hh"
00027
00028 #include "xml/XMLTool.hh"
00029
00030 #include "tools/MicroException.hh"
00031 #include "tools/Log.hh"
00032
00033
00034 #include <TApplication.h>
00035 #include <TGClient.h>
00036 #include <TGListBox.h>
00037 #include <TList.h>
00038
00039
00040
00041 using namespace std;
00042
00043
00044
00045 int main(int argc, char **argv)
00046
00047 {
00048
00049 FILELog::ReportingLevel() = FILELog::FromString(INFO);
00050
00051
00052 if ( argc != 3 ) {
00053 FILE_LOG(logERROR) << "usage: channelDisplay streeFile chamberId " << endl;
00054 exit(1);
00055 }
00056
00057 string steerName;
00058 steerName.assign(argv[1]);
00059
00060 string chamberId;
00061 chamberId.assign(argv[2]);
00062 ui32 chamId = atoi(chamberId.c_str());
00063
00064 TApplication *theApp;
00065
00066 argc = 1;
00067 theApp = new TRint("App", &argc, argv);
00068
00069
00070
00071
00072
00073
00074
00075 FILE *file = fopen(steerName.c_str(), "r");
00076 if(file == NULL){
00077 FILE_LOG(logERROR) << "Steer file ["<< steerName.c_str() << "] does not exist" << endl;
00078 exit(0);
00079 fclose(file);
00080 }
00081
00082 SteerDesc steerDesc;
00083 XMLTool xml;
00084 xml.parse(steerDesc, steerName);
00085
00086 Detector detector;
00087 detector.build(steerDesc);
00088
00089 Run run(detector);
00090
00091 steerDesc.setRun(run);
00092
00093 fclose(file);
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 string txt = "";
00105
00106 int xLength, yLength = 0;
00107
00108 try {
00109 const Chamber &chamber = detector.getChamberById(chamId);
00110 xLength = int(chamber.getXLength());
00111 yLength = int(chamber.getYLength());
00112 if ( chamber.getZrotation() == 90 )
00113 {
00114 int foo = xLength;
00115 xLength = yLength;
00116 yLength = foo;
00117 }
00118
00119
00120
00121
00122 int hMax = 1000;
00123 int vMax = 1000;
00124 int hMin = 100;
00125 int vMin = 100;
00126 int hCanvas,vCanvas;
00127
00128 if ( yLength > xLength)
00129 {
00130 vCanvas = vMax;
00131 float coef = (float) yLength / (float)xLength;
00132 cout << "--yLength["<< yLength << "]" << endl;
00133 cout << "--xLength["<< xLength << "]" << endl;
00134 cout << "--coef["<< coef << "]" << endl;
00135 hCanvas = int(hMax / coef);
00136 if ( hCanvas < hMin ) { hCanvas = hMin; }
00137
00138 }
00139 else
00140 {
00141 hCanvas = hMax;
00142 float coef = (float)xLength / (float)yLength;
00143 cout << "--yLength["<< yLength << "]" << endl;
00144 cout << "--xLength["<< xLength << "]" << endl;
00145 cout << "--coef["<< coef << "]" << endl;
00146 vCanvas = int(vMax / coef);
00147 if ( vCanvas < vMin ) { vCanvas = vMin; }
00148 }
00149
00150
00151
00152
00153 FILE_LOG(logINFO) << "Canvas size hCanvas[" << hCanvas << "], vCanvas[" << vCanvas << "]" << endl;
00154 TCanvas *c1 = new TCanvas("c1","Analyze.mac",vCanvas,hCanvas);
00155
00156
00157 FILE_LOG(logINFO) << "Chamber size xLength[" << xLength << "], yLenght[" << yLength << "]" << endl;
00158
00159 c1->Range(0,0,yLength,xLength);
00160 int nbChannel = 0;
00161 int color = 0;
00162 const BoardMap_t &boards = chamber.getBoards();
00163 for (BoardMap_t::const_iterator boardIt = boards.begin(); boardIt != boards.end(); ++boardIt)
00164 {
00165 Board& board = *(boardIt->second);
00166 const ChipMap_t &chips = board.getChips();
00167 for (ChipMap_t::const_iterator chipIt = chips.begin(); chipIt != chips.end(); ++chipIt)
00168 {
00169 Chip& chip = *(chipIt->second);
00170
00171
00172
00173 float x=chip.getLeftBottomX();
00174 float y=chip.getLeftBottomY();
00175 float z=chamber.getZ() ;
00176
00177 stringstream currentpad;
00178 currentpad<<chip.getId();
00179
00180 float x2=chip.getRightUpperX();
00181 float y2=chip.getRightUpperY();
00182
00183
00184 FILE_LOG(logDEBUG1) << "-----chip id[" << chip.getId()<< "]" << endl;
00185 FILE_LOG(logDEBUG1) << "x[" << x << "], x2[" << x2 << "]" << endl;
00186 FILE_LOG(logDEBUG1) << "y[" << y << "], y2[" << y2 << "]" << endl;
00187
00188
00189 TPaveLabel *pl1= new TPaveLabel(y+yLength/2, x+xLength/2,y2+yLength/2, x2+xLength/2,currentpad.str().c_str());
00190 if ( chamber.getType().find("STRIP") != string::npos)
00191 {
00192 pl1->SetTextSize(1);
00193
00194 }
00195
00196 if ( chamber.getType().find("GASSIPLEX") != string::npos)
00197 {
00198
00199 pl1->SetFillColor(board.getId() + 3);
00200 }
00201 else {
00202
00203 pl1->SetFillColor(board.getId() + chip.getId() + 2);
00204 }
00205
00206 pl1->Draw();
00207 }
00208 }
00209
00210 Toolbox::printRepere(chamber.getXrotation(),chamber.getYrotation(),chamber.getZrotation());
00211
00212
00213 theApp->Run();
00214 delete theApp;
00215
00216 }
00217 catch ( MicroException e )
00218 {
00219 FILE_LOG(logERROR) << e.getMessage() << endl;
00220 }
00221
00222 return 0;
00223 }