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

TrimRangeDisplayer.cpp

00001 #include "TrimRangeDisplayer.h"
00002 #include "DisplayManager.h"
00003 #include "DisplayInfo.h"
00004 
00005 #include "SctData/TrimRangeTestResult.h"
00006 #include "SctData/FitScanResult.h"
00007 #include "Sct/SctParameters.h"
00008 
00009 #include <TGraph.h>
00010 #include <TCanvas.h>
00011 #include <TH2.h>
00012 #include <TF1.h>
00013 #include <TLatex.h>
00014 
00015 #include <iomanip>
00016 #include <algorithm>
00017 
00018 using namespace Sct;
00019 using namespace SctData;
00020 using namespace std;
00021 using namespace boost;
00022 
00023 namespace SctDataDisplay {
00024     
00025 class TrimDisplayData : public DisplayData {
00026 public:
00027     vector<shared_ptr<TCanvas> > canvas;
00028 };   
00029     
00030 bool TrimRangeDisplayer::inMap = DisplayManager::addToMap("SctData::TrimRangeTestResult", shared_ptr<Displayer>(new TrimRangeDisplayer()));    
00031     
00032 shared_ptr<DisplayData> TrimRangeDisplayer::display(shared_ptr<const Sct::Serializable> serial, const DisplayInfo& info, std::ostream& os) {    
00033     shared_ptr<TrimDisplayData> data (new TrimDisplayData());
00034     shared_ptr<const TrimRangeTestResult> result = dynamic_pointer_cast<const TrimRangeTestResult>(serial);
00035 
00036     shared_ptr<TCanvas> c = createCanvas(result->getModuleName() + "_TrimData", result->getModuleName() + " Trim Range Fits");
00037     data->canvas.push_back(c);
00038     c->Divide(4, 3);
00039     for (unsigned int ichip = 0; ichip < nChipModule; ++ichip) {
00040         c->cd(ichip + 1);
00041     char name[100]; sprintf(name,"Chip_%d",ichip);
00042     TH2D* hist = new TH2D(name,name,10,0,300,10,0,16);
00043     hist->Draw();
00044 
00045     int range=result->chipTrim[ichip]->range;
00046     char txt[10];
00047     sprintf(txt,"R%d",range);
00048     TLatex* lab=new TLatex();
00049     lab->SetTextSize(0.1);
00050     lab->DrawLatex(0,0,txt);
00051 
00052     for (unsigned ichannel=0; ichannel<nChannelChip; ++ichannel){
00053         if (result->chipTrimData[ichip]!=0){
00054         Stat<TrimRangeTestResult::TrimData> trim = result->chipTrimData[ichip]->channelData.getAt(ichannel);
00055         TGraph* g = new TGraph();
00056         g->SetMarkerColor(ichannel);
00057         g->SetMarkerStyle(21);
00058         g->SetMarkerSize(0.5);
00059         g->Set(trim.value.graph.size());
00060         for (unsigned ipt=0; ipt<trim.value.graph.size(); ++ipt){
00061             g->SetPoint(ipt,trim.value.graph[ipt].first, trim.value.graph[ipt].second);
00062         }
00063         g->SetLineColor(ichannel);
00064         g->SetLineWidth(1);
00065         if (g->GetN()!=0 ){
00066             g->Draw("LP");
00067         }
00068         }
00069     }
00070     }
00071   
00072     shared_ptr<TCanvas> c2 = createCanvas(result->getModuleName() + "_Trims", result->getModuleName() + " Trims");
00073     data->canvas.push_back(c2);
00074     c2->Divide(1, 4);
00075     for (unsigned int ilink = 0; ilink < nLinkModule; ++ilink) {
00076     TGraph* g1 = new TGraph();
00077     TGraph* g2 = new TGraph();
00078     g1->SetMarkerColor(2);
00079     g1->SetMarkerStyle(21);
00080     g1->SetMarkerSize(1);
00081     g2->SetMarkerColor(2);
00082     g2->SetMarkerStyle(21);
00083     g2->SetMarkerSize(1);
00084 
00085     // find number of trimmed channels:
00086     int npoints=0;
00087     for (unsigned ichip=ilink*nChipLink; ichip<(ilink+1)*nChipLink; ++ichip){
00088         if (result->chipTrim[ichip]==0){
00089         cerr << " no trim at chip "<< ichip << endl; continue;
00090         }
00091         npoints += result->chipTrim[ichip]->channelTrim.n();
00092     }
00093     
00094     g1->Set(npoints);
00095     g2->Set(npoints);
00096 
00097     int ipoint=0;
00098     for (unsigned ichannel=ilink*nChannelLink; ichannel<(ilink+1)*nChannelLink; ++ichannel){
00099 
00100         if (result->chipTrim[ichannel/128]==0){
00101         continue;
00102         }
00103 
00104         Stat<TrimRangeTestResult::Trim> trim = result->chipTrim[ichannel/128]
00105         ->channelTrim.getAt(ichannel%128);
00106 
00107         if (trim.valid){
00108         g1->SetPoint(ipoint,ichannel%nChannelLink,trim.value.trim);
00109         g2->SetPoint(ipoint,ichannel%nChannelLink,trim.value.vthr);
00110         ++ipoint;
00111         }
00112     }
00113     
00114     char name[100]; sprintf(name,"Link_%d_t",ilink);
00115     TH2D* hist1 = new TH2D(name,name,768,-0.5,767.5,16,-0.5,15.5);
00116     sprintf(name,"Link_%d_v",ilink);
00117     TH2D* hist2 = new TH2D(name,name,768,-0.5,767.5,3,0.,300.);
00118     c2->cd(ilink*2 + 1);
00119     hist1->Draw();
00120     g1->Draw("P");
00121     c2->cd(ilink*2 + 2);
00122     hist2->Draw("");
00123     g2->Draw("P");
00124     for (unsigned ichip=ilink*nChipLink; ichip<(ilink+1)*nChipLink; ++ichip){
00125         int range=result->chipTrim[ichip]->range;
00126         char txt[10];
00127         sprintf(txt,"R%d",range);
00128         TLatex* lab=new TLatex();
00129         lab->SetTextSize(0.1);
00130         lab->DrawLatex(nChannelChip*(ichip%nChipLink)+nChannelChip/2,10,txt);
00131     }
00132 
00133     }    
00134     
00135     //Now print out defects:
00136     os << endl << "Defects: " << endl;
00137     printDefectList(result->getDefects(), os);
00138 
00139     return data;
00140 }
00141 }

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