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

NPtGainSummaryWriter.cpp

Go to the documentation of this file.
00001 #include "SummaryManager.h"
00002 #include "NPtGainSummaryWriter.h"
00003 
00004 #include "SctData/NPtGainTestResult.h"
00005 #include "SctData/ResponseCurve.h"
00006 #include "SctData/Stat.h"
00007 #include "SctData/ModuleDefect.h"
00008 
00009 #include <iomanip>
00010 #include <TF1.h>
00011 
00012 namespace SctData {
00013     namespace TestSummary{
00014     using namespace std;
00015 
00016     void NPtGainSummaryWriter::write(const TestResult& t, ostream& out) const throw(Sct::IoError, Sct::LogicError)
00017     {
00018         t.getNScans();
00019         const NPtGainTestResult& result  = dynamic_cast<const NPtGainTestResult&>(t);
00020         switch ( result.getNScans() ){
00021         case (3) : out << "%ThreePointGain" << endl; break;
00022         case (10) : out << "%ResponseCurve" << endl; break;
00023         default : out <<"%NPtGain"<<endl; break;
00024         }
00025 
00026         out << "#\n#LoopA - Fit"<<endl;
00027         out << "#      func    p0     p1       p2" << endl;
00028         for (short unsigned ichip=0; ichip<nChipModule; ++ichip){
00029         out << "#"<<getChipName(ichip) << endl;
00030         shared_ptr<TF1> fit = result.getChipData(ichip).rc->getFunction();
00031         out << setfill(' ');
00032         out << setw(6) << result.getChipData(ichip).rc->getIndex();
00033         for (short ipar=0; ipar<fit->GetNpar(); ++ipar){
00034             out << "  " << setfill(' ') << setw(6) << fit->GetParameter(ipar);
00035         }
00036         out << endl;
00037         }
00038 
00050         out << "#\n#LoopB - Gain, Offset, Noise at 2.00fC"<<endl;
00051         out << "#     vt50    rms     gain    rms   offset   rms   outnse   innse   rms" << endl;
00052 
00053         for (short unsigned ichip=0; ichip<nChipModule; ++ichip){
00054         Stats<float> vt50(nChannelChip);
00055         Stats<float> gain(nChannelChip);
00056         Stats<float> offset(nChannelChip);
00057         Stats<float> outnse(nChannelChip);
00058         Stats<float> innse(nChannelChip);
00059         
00060         for (unsigned ichan=0; ichan<nChannelChip; ++ichan){
00061             unsigned ichannel = ichan + ichip*nChannelChip;
00062             bool valid=!result.getDefects().defectEncompassingElement(Channel(ichannel));           
00063 
00064             vt50.modifyAt(ichan).valid = valid;
00065             gain.modifyAt(ichan).valid = valid;
00066             offset.modifyAt(ichan).valid = valid;
00067             outnse.modifyAt(ichan).valid = valid;
00068             innse.modifyAt(ichan).valid = valid;
00069             
00070             vt50.modifyAt(ichan).value = result.getChannelData(ichannel).rc->getFunction()->Eval(result.getSpecialScanPointValue());
00071             gain.modifyAt(ichan).value = result.getChannelData(ichannel).gain;
00072             innse.modifyAt(ichan).value = result.getChannelData(ichannel).noise;
00073             offset.modifyAt(ichan).value = result.getChannelData(ichannel).offset;
00074         }
00075         
00076         out << "#"<<getChipName(ichip) << endl;
00077         out << setfill(' ')  << setw(6) << vt50.mean() << "  " << sqrt(vt50.var()) << "  " 
00078             << setw(6) << gain.mean() << "  " <<  setw(6) << sqrt(gain.var()) << "  " 
00079             << setw(6) << offset.mean() << "  " << setw(6) << sqrt(offset.var()) << "  "
00080             << setw(6) << innse.mean()*gain.mean()/6250. << "  "
00081             << setw(6) << innse.mean() << "  " << setw(6) << sqrt(innse.var()) << endl;
00082         }
00083         
00084 
00085         out << "#\n#LoopC - comment"<<endl;
00086         out << "#";
00087         for (short unsigned ichip=0; ichip<nChipModule/2; ++ichip){
00088         out << getChipName(ichip) << " ";
00089         }
00090         out << endl;
00091 
00092         for (short unsigned ichip=0; ichip<nChipModule/2; ++ichip){
00093         outputDefectOnChip(ichip, result, out);
00094         }
00095         out << endl << "#";
00096         
00097         for (short unsigned ichip=nChipModule/2; ichip<nChipModule; ++ichip){
00098         out << getChipName(ichip) << " ";
00099         }
00100         out << endl;
00101         for (short unsigned ichip=nChipModule/2; ichip<nChipModule; ++ichip){
00102         outputDefectOnChip(ichip, result, out);
00103         }
00104         out << endl << "#";
00105 
00106         SummaryWriter::write(t.getDefects(), out);
00107         
00108     }
00109 
00110     void NPtGainSummaryWriter::outputDefectOnChip(unsigned ichip, const NPtGainTestResult& result, ostream& out) throw() {
00111         shared_ptr<ModuleDefectList> defects = result.getDefects().getDefectsEncompassingElement(Chip(ichip) );
00112         
00113         short unsigned ndefect=0;
00114         for (unsigned idefect=0; idefect<defects->getAllDefects().size() ; ++idefect ){
00115         shared_ptr<const ModuleDefect> def = defects->getAllDefects()[idefect];
00116         if ( def->isChipDefect() ) {
00117             if (ndefect!=0) out << ",";
00118             ++ndefect;
00119             out << defects->getAllDefects()[idefect]->getName() ;
00120         }
00121         }
00122         if (ndefect==0) out <<  "\"OK\"  " ;
00123     }
00124 
00125     //------------------------------------------------------
00126 
00127     bool NPtGainSummaryWriter::inMap = SummaryManager::instance().addWriter("SctData::NPtGainTestResult", shared_ptr<SummaryWriter>(new NPtGainSummaryWriter()));
00128     }
00129 }

Generated on Mon Dec 15 19:36:09 2003 for SCT DAQ/DCS Software by doxygen1.3-rc3