Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Related Pages

Displayer.cpp

00001 #include "Displayer.h"
00002 #include "SctData/DefectList.h"
00003 #include "DisplayManager.h"
00004 #include <cmath>
00005 #include <TCanvas.h>
00006 #include <TROOT.h>
00007 #include <TStyle.h>
00008 #include <iostream>
00009 #include <iomanip>
00010 #include <boost/lexical_cast.hpp>
00011 
00012 using namespace std;
00013 using namespace boost;
00014 using namespace SctData;
00015 
00016 namespace SctDataDisplay {
00017 
00018 shared_ptr<TCanvas> Displayer::createCanvas(string name, string title) {
00019     unsigned int i=0;
00020     string rname;
00021     TCanvas* old = 0;
00022     do {
00023         ++i;
00024         rname = name + "_" + lexical_cast<string>(i);
00025     old = dynamic_cast<TCanvas*>(gROOT->GetListOfCanvases()->FindObject(rname.c_str()));
00026     } while(old != 0);
00027     int offset=gROOT->GetListOfCanvases()->GetSize()*20;
00028     gROOT->SetStyle("Plain");
00029     gStyle->SetOptStat(0);
00030     gStyle->SetTitleX(0.5);
00031     gStyle->SetTitleY(0.99);
00032     gStyle->SetTitleFontSize(0.07);
00033    
00034     shared_ptr<TCanvas> canvas = shared_ptr<TCanvas>(new TCanvas(rname.c_str(), title.c_str(), 
00035                                  offset, offset, 900, 650));
00036     if ( DisplayManager::batchMode() ) canvas->SetBatch();
00037     return canvas;
00038 }
00039 
00040 void Displayer::divideCanvas(unsigned int n, TCanvas& canvas) {
00041     unsigned int x = (unsigned int)(ceil(sqrt((double)n)));
00042     unsigned int y = (unsigned int)(ceil((double)n/x));
00043     canvas.Divide(x, y, 0.0001, 0.0001);
00044 }
00045 
00046 
00047 void Displayer::printDefectList(const DefectList& list, std::ostream& os) {
00048   const DefectList::DefectCollection& defects = list.getAllDefects();
00049     
00050   for (DefectList::DefectCollection::const_iterator i=defects.begin(); i!=defects.end(); ++i) {
00051     os << setfill(' ') << setw(20) << i->getPrototype().getName()
00052        <<  "\tStart channel: " << i->getModuleElement().getFirst()
00053        << "\t# of channels: " << i->getModuleElement().getNChannels()
00054        << "\t" << i->getPrototype().getDescription() << std::endl;
00055   }
00056   os << "[ total number of defects = " <<  defects.size() << " ]" << std::endl;
00057   os << std::endl;
00058 }
00059 
00060 }

Generated on Fri Jan 14 12:47:02 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5