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