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 "Toolbox.hh"
00029 #include "MicroException.hh"
00030 
00031 
00032 #include <TApplication.h>
00033 #include <TGClient.h>
00034 #include <TGListBox.h>
00035 #include <TList.h>
00036 
00037 
00038 
00039 using namespace std;
00040 
00041 
00042 
00043 int main(int argc, char **argv)
00044 
00045 {  
00046 
00047   FILELog::ReportingLevel() = FILELog::FromString(INFO);
00048 
00049   
00050   if ( argc != 3 ) {
00051    FILE_LOG(logERROR)  << "usage: channelDisplay streeFile chamberId " << endl;
00052    exit(1);
00053   }
00054 
00055   string steerName;
00056   steerName.assign(argv[1]);
00057 
00058   string chamberId;
00059   chamberId.assign(argv[2]);
00060   ui32 chamId = atoi(chamberId.c_str());
00061 
00062   TApplication *theApp;
00063 
00064   argc = 1;
00065   theApp = new TRint("App", &argc, argv);
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 
00089     steerDesc.setRun(run);
00090 
00091     fclose(file);
00092 
00093 
00094   
00095   
00096   
00097   
00098   
00099   
00100 
00101 
00102    string txt = "";
00103 
00104    float xLength, yLength = 0.;
00105 
00106    try {
00107     const Chamber &chamber = detector.getChamberById(chamId);
00108     xLength = chamber.getXLength() + chamber.getX();
00109     yLength = chamber.getYLength() + chamber.getY() ;
00110                 cout << "chamber xPos[" << chamber.getX() << "]" << endl;
00111                 cout << "chamber yPos[" << chamber.getY() << "]" << endl;
00112 
00113    
00114    int hMax = 800;
00115    int vMax = 800;
00116    int hMin = 100;
00117    int vMin = 100;
00118    int hCanvas,vCanvas=0;
00119 
00120    if ( yLength > xLength)
00121    {
00122        vCanvas = vMax;
00123        float coef = (float) yLength / (float)xLength;
00124        hCanvas = int(hMax / coef);
00125        if  ( hCanvas < hMin ) { hCanvas = hMin; }
00126    }
00127    else
00128    {
00129        hCanvas = hMax;
00130        float coef = (float) xLength / (float)yLength;
00131        vCanvas = int(vMax / coef);
00132        if  ( vCanvas < vMin ) { vCanvas = vMin; }
00133    }
00134    FILE_LOG(logINFO) << "Canvas size [" << hCanvas << "], [" << vCanvas << "]" << endl;
00135    TCanvas *c1 = new TCanvas("c1","Analyze.mac",vCanvas,hCanvas);
00136 
00137 
00138 
00139     c1->Range(0,0,yLength ,xLength);
00140     int nbChannel = 0;
00141     int color = 0;
00142     const BoardMap_t &boards = chamber.getBoards();
00143     for (BoardMap_t::const_iterator boardIt = boards.begin(); boardIt != boards.end(); ++boardIt)
00144     {
00145       Board& board = *(boardIt->second);
00146       {
00147            
00148            
00149            float x=board.getLeftBottomX();
00150            float y=board.getLeftBottomY();
00151            float z=chamber.getZ() ;
00152 
00153            stringstream currentpad;
00154            currentpad<<board.getId();
00155 
00156            
00157            
00158            float x2 = board.getRightUpperX();
00159            float y2 = board.getRightUpperY();
00160 
00161         
00162         cout << "board.getXLength()[" << board.getXLength() <<"]" <<endl;
00163         cout << "board.getYLength()[" << board.getYLength() <<"]" <<endl;
00164  
00165 
00166                                         cout << "----- draw board id[" << board.getId() << "] posx[" << board.getX()  << "] y[" << board.getY() <<"] " << endl;
00167      
00168     
00169     
00170     
00171     
00172     
00173     
00174     
00175     
00176     
00177     
00178     
00179            TPaveLabel *pl1= new TPaveLabel(y+yLength/2, x +xLength/2, y2+yLength/2, x2+xLength/2,currentpad.str().c_str()); 
00180            pl1->SetFillColor(board.getId() + 3);
00181            pl1->Draw();
00182            if ( chamber.getType().find("GASSIPLEX") == string::npos)
00183            { 
00184                FILE_LOG(logINFO) << "Board id:"<< board.getId() << " use Dif id: " << board.getDif()->getId() << endl;
00185            }
00186          }
00187 
00188     }
00189 
00190     Toolbox::printRepere(chamber.getXrotation(),chamber.getYrotation(),chamber.getZrotation());
00191 
00192      theApp->Run();
00193      delete theApp;
00194      
00195    } 
00196    catch ( MicroException e )
00197    {
00198    FILE_LOG(logERROR) << e.getMessage() << endl;
00199    }
00200 
00201    return 0;
00202 }