/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/src/analyse/root/chipDisplay.cpp File Reference

#include <TROOT.h>
#include <TPaveLabel.h>
#include <TRint.h>
#include <TCanvas.h>
#include <TTree.h>
#include <TFile.h>
#include <TSystem.h>
#include <TGeoManager.h>
#include <TGeoMatrix.h>
#include <iostream>
#include <sstream>
#include <Toolbox.hh>
#include "event/Run.hh"
#include "event/Event.hh"
#include "geometry/Board.hh"
#include "geometry/Chip.hh"
#include "geometry/Dif.hh"
#include "geometry/Chamber.hh"
#include "geometry/Detector.hh"
#include "geometry/GassiplexChamber1.hh"
#include "geometry/GassiplexChamber4.hh"
#include "geometry/Hardroc1Chamber.hh"
#include "xml/XMLTool.hh"
#include "tools/MicroException.hh"
#include "tools/Log.hh"
#include <TApplication.h>
#include <TGClient.h>
#include <TGListBox.h>
#include <TList.h>

Include dependency graph for chipDisplay.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 45 of file chipDisplay.cpp.

00047 {  //un-named script to be run in ROOT framework
00048 
00049   FILELog::ReportingLevel() = FILELog::FromString(INFO);
00050 
00051   //----- Control usage and option
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 // test if sterr file exist
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 // create Run, set detector and steerDesc from steer XML file
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());// + chamber.getX();
00111     yLength = int(chamber.getYLength());// + chamber.getY();
00112     if ( chamber.getZrotation() == 90 )
00113      {
00114          int foo = xLength;
00115          xLength = yLength;
00116          yLength = foo;
00117      }
00118 
00119 
00120 
00121 //   TCanvas *c1 = new TCanvas("c1","Analyze.mac",yLength*20,xLength*20);
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      //hCanvas = 1600;
00150      //vCanvas = 1600;
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);// (xmin,ymin,xmax,ymax
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                                         ////cout << " chipId[" << chip.getId() << "] getX()[" << chip.getX() << "]" << endl;
00172                                         //cout << " chipId[" << chip.getId() << "] getY()[" << chip.getY() << "]" << endl;
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            // On inverse x et y pour repere micromegas
00189            TPaveLabel *pl1= new TPaveLabel(y+yLength/2, x+xLength/2,y2+yLength/2,  x2+xLength/2,currentpad.str().c_str()); // x1 x2 y1 y2
00190            if ( chamber.getType().find("STRIP") != string::npos)
00191            { 
00192             pl1->SetTextSize(1);
00193 //            pl1->SetTextAngle(90);
00194            }
00195            //TPaveLabel *pl1= new TPaveLabel(y, x,y2,  x2,""); // x1 x2 y1 y2
00196            if ( chamber.getType().find("GASSIPLEX") != string::npos)
00197            {
00198                // GASSIPLEX
00199                  pl1->SetFillColor(board.getId() + 3);
00200            }
00201            else {
00202                //HARDROC
00203                pl1->SetFillColor(board.getId() + chip.getId() + 2);
00204            }
00205            //pl1->SetFillColor(3);
00206            pl1->Draw();
00207          }
00208        }
00209 
00210     Toolbox::printRepere(chamber.getXrotation(),chamber.getYrotation(),chamber.getZrotation());
00211 
00212 
00213      theApp->Run();
00214      delete theApp;
00215      // run ROOT application
00216    } //end try
00217    catch ( MicroException e )
00218    {
00219    FILE_LOG(logERROR) << e.getMessage() << endl;
00220    }
00221 
00222    return 0;
00223 }


Generated on Mon Jan 7 13:17:11 2013 for MicromegasFramework by  doxygen 1.4.7