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 <iostream> 00008 #include <iomanip> 00009 #include <boost/lexical_cast.hpp> 00010 00011 using namespace std; 00012 using namespace boost; 00013 using namespace SctData; 00014 00015 namespace SctDataDisplay { 00016 00017 shared_ptr<TCanvas> Displayer::createCanvas(string name, string title) { 00018 unsigned int i=0; 00019 string rname; 00020 TCanvas* old = 0; 00021 do { 00022 ++i; 00023 rname = name + lexical_cast<string>(i); 00024 old = dynamic_cast<TCanvas*>(gROOT->GetListOfCanvases()->FindObject(rname.c_str())); 00025 } while(old != 0); 00026 shared_ptr<TCanvas> canvas = shared_ptr<TCanvas>(new TCanvas(rname.c_str(), title.c_str())); 00027 if ( DisplayManager::batchMode() ) canvas->SetBatch(); 00028 return canvas; 00029 } 00030 00031 void Displayer::divideCanvas(unsigned int n, TCanvas& canvas) { 00032 unsigned int x = (unsigned int)(ceil(sqrt((double)n))); 00033 unsigned int y = (unsigned int)(ceil((double)n/x)); 00034 canvas.Divide(x, y); 00035 } 00036 00037 00038 void Displayer::printDefectList(const DefectList& list, std::ostream& os) { 00039 const DefectList::DefectCollection& defects = list.getAllDefects(); 00040 00041 for (DefectList::DefectCollection::const_iterator i=defects.begin(); i!=defects.end(); ++i) { 00042 os << setfill(' ') << setw(20) << i->getPrototype().getName() 00043 << "\tStart channel: " << i->getModuleElement().getFirst() 00044 << "\t# of channels: " << i->getModuleElement().getNChannels() 00045 << "\t" << i->getPrototype().getDescription() << std::endl; 00046 } 00047 os << "[ total number of defects = " << defects.size() << " ]" << std::endl; 00048 os << std::endl; 00049 } 00050 00051 }