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

NPtGainSummaryWriter.cpp

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 
00008 #include <iomanip>
00009 #include <TF1.h>
00010 
00011 namespace SctData {
00012     namespace TestSummary{
00013     using namespace std;
00014 
00015     void NPtGainSummaryWriter::write(const TestResult& t, ostream& out) const throw(Sct::IoError, Sct::LogicError)
00016     {
00017         t.getNScans();
00018         const NPtGainTestResult& result  = dynamic_cast<const NPtGainTestResult&>(t);
00019         switch ( result.getNScans() ){
00020         case (3) : out << "%ThreePointGain" << endl; break;
00021         case (10) : out << "%ResponseCurve" << endl; break;
00022         default : out <<"%NPtGain"<<endl; break;
00023         }
00024 
00025         out << "#\n#LoopA - Fit"<<endl;
00026         out << "#      func    p0     p1       p2" << endl;
00027         for (short unsigned ichip=0; ichip<nChipModule; ++ichip){
00028         out << "#"<<getChipName(ichip) << endl;
00029         if (result.getChipData(ichip).rc.get()==0){
00030           throw Sct::IllegalStateError("No Response Curve with chip!", __FILE__, __LINE__);
00031         }
00032         shared_ptr<TF1> fit = result.getChipData(ichip).rc->getFunction();
00033         if (!fit.get()) {
00034           throw Sct::IllegalStateError("No Fit with Response Curve!", __FILE__, __LINE__);
00035         }
00036         out << setfill(' ');
00037         out << setw(6) << result.getChipData(ichip).rc->getIndex();
00038         for (short ipar=0; ipar<fit->GetNpar(); ++ipar){
00039             out << "  " << setfill(' ') << setw(6) << fit->GetParameter(ipar);
00040         }
00041         out << endl;
00042         }
00043 
00055         out << "#\n#LoopB - Gain, Offset, Noise at 2.00fC"<<endl;
00056         out << "#     vt50    rms     gain    rms   offset   rms   outnse   innse   rms" << endl;
00057 
00058         for (short unsigned ichip=0; ichip<nChipModule; ++ichip){
00059         Stats<float> vt50(nChannelChip);
00060         Stats<float> gain(nChannelChip);
00061         Stats<float> offset(nChannelChip);
00062         Stats<float> outnse(nChannelChip);
00063         Stats<float> innse(nChannelChip);
00064         
00065         for (unsigned ichan=0; ichan<nChannelChip; ++ichan){
00066             unsigned ichannel = ichan + ichip*nChannelChip;
00067             bool valid=result.getDefects().defectSeverityEncompassingElement(ModuleElement::Channel(ichannel)) == NONE;         
00068 
00069             vt50.modifyAt(ichan).valid = valid;
00070             gain.modifyAt(ichan).valid = valid;
00071             offset.modifyAt(ichan).valid = valid;
00072             outnse.modifyAt(ichan).valid = valid;
00073             innse.modifyAt(ichan).valid = valid;
00074             
00075             vt50.modifyAt(ichan).value = result.getChannelData(ichannel).rc->getFunction()->Eval(result.getSpecialScanPointValue());
00076             gain.modifyAt(ichan).value = result.getChannelData(ichannel).gain;
00077             innse.modifyAt(ichan).value = result.getChannelData(ichannel).noise;
00078             offset.modifyAt(ichan).value = result.getChannelData(ichannel).offset;
00079         }
00080         
00081         out << "#"<<getChipName(ichip) << endl;
00082         out << setfill(' ')  << setw(6) << vt50.mean() << "  " << sqrt(vt50.var()) << "  " 
00083             << setw(6) << gain.mean() << "  " <<  setw(6) << sqrt(gain.var()) << "  " 
00084             << setw(6) << offset.mean() << "  " << setw(6) << sqrt(offset.var()) << "  "
00085             << setw(6) << innse.mean()*gain.mean()/6250. << "  "
00086             << setw(6) << innse.mean() << "  " << setw(6) << sqrt(innse.var()) << endl;
00087         }
00088         
00089 
00090         out << "#\n#LoopC - comment"<<endl;
00091         out << "#";
00092         for (short unsigned ichip=0; ichip<nChipModule/2; ++ichip){
00093         out << getChipName(ichip) << " ";
00094         }
00095         out << endl;
00096 
00097         for (short unsigned ichip=0; ichip<nChipModule/2; ++ichip){
00098         outputDefectOnChip(ichip, result, out);
00099         }
00100         out << endl << "#";
00101         
00102         for (short unsigned ichip=nChipModule/2; ichip<nChipModule; ++ichip){
00103         out << getChipName(ichip) << " ";
00104         }
00105         out << endl;
00106         for (short unsigned ichip=nChipModule/2; ichip<nChipModule; ++ichip){
00107         outputDefectOnChip(ichip, result, out);
00108         }
00109         out << endl << "#";
00110 
00111         SummaryWriter::write(t.getDefects(), out);
00112         
00113     }
00114 
00115     void NPtGainSummaryWriter::outputDefectOnChip(unsigned ichip, const NPtGainTestResult& result, ostream& out) throw() {
00116         auto_ptr<DefectList> defects = result.getDefects().getDefectsEncompassingElement(ModuleElement::Chip(ichip) );
00117         
00118         short unsigned ndefect=0;
00119         for (list<Defect>::const_iterator i = defects->getAllDefects().begin() ;
00120          i != defects->getAllDefects().end(); ++i ) {
00121 
00122           if ( (*i).getModuleElement().isChip() ) {
00123         if (ndefect!=0) out << ",";
00124         ++ndefect;
00125         out << (*i).getPrototype().getName() ;
00126         }
00127         }
00128         if (ndefect==0) out <<  "\"OK\"  " ;
00129     }
00130 
00131     //------------------------------------------------------
00132 
00133     bool NPtGainSummaryWriter::inMap = SummaryManager::instance().addWriter("SctData::NPtGainTestResult", shared_ptr<SummaryWriter>(new NPtGainSummaryWriter()));
00134     }
00135 }

Generated on Thu Feb 3 17:37:38 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5