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

NPtGainDisplayer.cpp

00001 #include "NPtGainDisplayer.h"
00002 #include "DisplayManager.h"
00003 #include "DisplayInfo.h"
00004 
00005 #include "SctData/NPtGainTestResult.h"
00006 #include "SctData/FitScanResult.h"
00007 #include "SctData/ResponseCurve.h"
00008 #include "Sct/SctParameters.h"
00009 
00010 #include <TGraph.h>
00011 #include <TCanvas.h>
00012 #include <TF1.h>
00013 #include <TPolyLine.h>
00014 
00015 #include <algorithm>
00016 
00017 using namespace Sct;
00018 using namespace SctData;
00019 using namespace std;
00020 using namespace boost;
00021 
00022 namespace SctDataDisplay {
00023 
00024 class NPtGainDisplayData : public DisplayData {
00025 public:
00026     vector<shared_ptr<TCanvas> > canvas;
00027     shared_ptr<const NPtGainTestResult> test;
00028     vector<shared_ptr<TF1> > funcs;
00029     vector<shared_ptr<TGraph> > graphs;
00030     vector<shared_ptr<TPolyLine> > lines;
00031 };        
00032     
00033 bool NPtGainDisplayer::inMap = DisplayManager::addToMap("SctData::NPtGainTestResult", shared_ptr<Displayer>(new NPtGainDisplayer()));
00034     
00035     
00036 shared_ptr<DisplayData> NPtGainDisplayer::display(shared_ptr<const Sct::Serializable> serial, const DisplayInfo& info, std::ostream& os) {
00037     shared_ptr<NPtGainDisplayData> data (new NPtGainDisplayData());
00038     data->test = dynamic_pointer_cast<const NPtGainTestResult>(serial);
00039         
00040     //Construct gain, noise and offset graphs
00041     shared_ptr<TGraph> gain (new TGraph(nChannelModule));
00042     shared_ptr<TGraph> noise (new TGraph(nChannelModule));
00043     shared_ptr<TGraph> offset (new TGraph(nChannelModule));
00044     data->graphs.push_back(gain);
00045     data->graphs.push_back(noise);
00046     data->graphs.push_back(offset);
00047 
00048     for (unsigned int i=0; i<nChannelModule; ++i) {
00049         const NPtGainTestResultData& chanData = data->test->getChannelData(i);
00050         gain->SetPoint(i, i, chanData.gain);
00051         noise->SetPoint(i, i, chanData.noise);
00052         offset->SetPoint(i, i, chanData.offset);
00053     }
00054 
00055     plotData("Gain", 0, 80, *data, *gain);
00056     plotData("Noise", 0, 2500, *data, *noise);
00057     plotData("Offset", 0, 200, *data, *offset);
00058 
00059     if (info.displayChips.size() > 0)
00060     displayChips(*data, info, os);
00061     
00062     if (info.displayChannels.size() > 0)
00063     displayChannels(*data, info, os);
00064     
00065     os << "Defects:" << std::endl;
00066     printDefectList(data->test->getDefects(), os);
00067     
00068     return data;
00069 }
00070 
00071 void NPtGainDisplayer::plotData(string name, double min, double max, NPtGainDisplayData& data, TGraph& graph) {
00072     shared_ptr<TCanvas> c = createCanvas(data.test->getModuleName() + name, name + " for " + data.test->getModuleName());
00073     data.canvas.push_back(c);
00074     graph.SetMaximum(max);
00075     graph.SetMinimum(min);
00076     graph.SetTitle(name.c_str());
00077     graph.GetXaxis()->SetLimits(0, nChannelModule);
00078     graph.GetXaxis()->SetTitle("Channel Number");
00079     graph.Draw("alp");
00080     for (unsigned int i=0; i<nChipModule; ++i) {
00081         shared_ptr<TPolyLine> p (new TPolyLine(2));
00082         data.lines.push_back(p);
00083         p->SetLineStyle(2);
00084         p->SetPoint(0, nChannelChip*i-0.5, min);
00085         p->SetPoint(1, nChannelChip*i-0.5, max);
00086         p->Draw();
00087     }
00088 }
00089 
00090 void NPtGainDisplayer::displayChips(NPtGainDisplayData& data, const DisplayInfo& info, std::ostream& os) {
00091     shared_ptr<TCanvas> c = createCanvas(data.test->getModuleName() + "_chip", data.test->getModuleName() + " Chip Fits");
00092     data.canvas.push_back(c);
00093     divideCanvas(info.displayChips.size(), *c);
00094     for (unsigned int i = 0; i < info.displayChips.size(); ++i) {
00095         c->cd(i + 1);
00096     displayData(data, data.test->getChipData(info.displayChips[i]));
00097     }
00098     
00099     //Print out chip fit parameters
00100     os << "Chip parameters" << endl;
00101     for (unsigned int i = 0; i < 12; ++i) {
00102         shared_ptr<TF1> f = data.test->getChipData(i).rc->getFunction();
00103         os << f->GetParameter(0) << "  " << f->GetParameter(1) << "  " << f->GetParameter(2) << endl;
00104     }    
00105 }
00106 
00107 void NPtGainDisplayer::displayChannels(NPtGainDisplayData& data, const DisplayInfo& info, std::ostream& os) {
00108     shared_ptr<TCanvas> c;
00109     unsigned int nMax = min((unsigned int)25, info.displayChannels.size());
00110     int j=0;
00111     
00112     for (unsigned int i=0; i<info.displayChannels.size(); ++i, ++j) {   
00113         if (j%nMax == 0) {
00114         c = createCanvas("channelRC" + data.test->getModuleName(), "Channel Response Curves for module " + data.test->getModuleName());
00115         data.canvas.push_back(c);
00116         divideCanvas(nMax, *c);
00117             j=0;
00118         }   
00119         c->cd(i%nMax + 1);
00120     displayData(data, data.test->getChannelData(info.displayChannels[i]));
00121     }
00122 }
00123 
00124 void NPtGainDisplayer::displayData(NPtGainDisplayData& data, const NPtGainTestResultData& testData) {
00125     TGraph & g = *testData.graph;
00126     g.SetMarkerStyle(20);
00127     g.Draw("ap");
00128     g.GetHistogram()->SetXTitle("Q_th / fC");
00129     g.GetHistogram()->SetYTitle("V_th / mV");
00130     shared_ptr<TF1> f = testData.rc->getFunction();
00131     f->SetRange(0, 8);
00132     f->SetFillStyle(0);
00133     f->Draw("same");
00134     data.funcs.push_back(f);
00135 }
00136 
00137 
00138 }

Generated on Thu Jul 15 09:50:49 2004 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5