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

NoiseOccupancyDisplayer.cpp

00001 #include "NoiseOccupancyDisplayer.h"
00002 #include "DisplayManager.h"
00003 #include "DisplayInfo.h"
00004 
00005 #include "SctData/NoiseOccupancyTestResult.h"
00006 #include "SctData/DefectList.h"
00007 
00008 #include "TF1.h"
00009 #include "TGraph.h"
00010 #include "TCanvas.h"
00011 #include "TLatex.h"
00012 
00013 #include <iomanip>
00014 #include <string>
00015 #include <boost/shared_ptr.hpp>
00016 
00017 using namespace std;
00018 using namespace SctData;
00019 using namespace Sct;
00020 using namespace boost;
00021 
00022 namespace SctDataDisplay {
00023 
00024 
00025 class NoiseOccupancyDisplayData : public DisplayData {
00026 public:
00027     vector<shared_ptr<TCanvas> > canvas;
00028     shared_ptr<const NoiseOccupancyTestResult> test;
00029 };        
00030     
00031 bool NoiseOccupancyDisplayer::inMap = DisplayManager::addToMap("SctData::NoiseOccupancyTestResult", shared_ptr<Displayer>(new NoiseOccupancyDisplayer()));
00032     
00033     
00034 shared_ptr<DisplayData> NoiseOccupancyDisplayer::display(shared_ptr<const Sct::Serializable> serial, const DisplayInfo& info, std::ostream& os) { 
00035     shared_ptr<NoiseOccupancyDisplayData> data (new NoiseOccupancyDisplayData());    
00036     data->test = dynamic_pointer_cast<const NoiseOccupancyTestResult>(serial);
00037     
00038     //Now print out defects:
00039     //os << endl << "Defects: " << endl;
00040     //printDefectList(data->test->getDefects(), os);
00041     //os << endl;
00042 
00043     if (info.displayChips.size() > 0) displayChips(*data, info, os);
00044     
00045     return data;
00046 }
00047 
00048 void NoiseOccupancyDisplayer::displayChips(NoiseOccupancyDisplayData& data, const DisplayInfo& info, std::ostream& os) {
00049     shared_ptr<TCanvas> c = createCanvas(data.test->getUniqueID() + "_chipNO", "Noise Occupancy plots for " + data.test->getModuleName());
00050     data.canvas.push_back(c);
00051     divideCanvas(info.displayChips.size(), *c);
00052     
00053     for (unsigned int i=0; i<info.displayChips.size(); ++i) {
00054         const ChipNOResult& r = data.test->getChipResult(info.displayChips[i]);
00055     os << "Chip " << i << " noise: " << r.getNoise() << "  Fit params: ";
00056     for (int j=0; j<r.fit->GetNpar(); ++j) os << r.fit->GetParameter(j) << "   ";
00057     os << endl;
00058         c->cd(i+1);
00059     gPad->SetLeftMargin(0.15);
00060     gPad->SetBottomMargin(0.15);
00061     gPad->SetTopMargin(0.03);
00062     gPad->SetRightMargin(0.03);
00063 
00064     if (r.graph.get()){
00065       if (r.graph->GetN()!=0){
00066         r.graph->Draw("ap");
00067         if (r.graph->GetHistogram()){
00068           r.graph->GetHistogram()->SetXTitle("Threshold^2 (fC^2)");
00069           r.graph->GetHistogram()->SetYTitle("Ln Occupancy");
00070           r.graph->GetHistogram()->GetXaxis()->SetLabelSize(0.06);
00071           r.graph->GetHistogram()->GetYaxis()->SetLabelSize(0.06);
00072           r.graph->GetHistogram()->GetXaxis()->SetTitleSize(0.06);
00073           r.graph->GetHistogram()->GetYaxis()->SetTitleSize(0.06);
00074         }
00075         try{
00076           std::ostringstream text;
00077           text << std::scientific << std::setprecision(1) << r.mean;
00078           TLatex* l=new TLatex();
00079           l->SetTextAlign(11);
00080           l->SetTextSize(0.07);
00081           l->DrawLatex(1.1,log(r.mean*1.5),text.str().c_str());
00082         }catch(Sct::Throwable& e){
00083           std::cerr << e.what();
00084         }
00085       }
00086     }
00087     if (r.fit.get()) {
00088       r.fit->SetLineWidth(1);
00089       r.fit->SetLineColor(2);
00090       r.fit->SetFillStyle(0);
00091       r.fit->Draw("lsame");
00092     }   
00093     }
00094 
00095 }
00096 }

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