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 
00044         out << "#\n#LoopB - Gain, Offset, Noise at 2.00fC"<<endl;
00045         out << "#     vt50    rms     gain    rms   offset   rms   outnse   innse   rms" << endl;
00046 
00047         for (short unsigned ichip=0; ichip<nChipModule; ++ichip){
00048         Stats<float> vt50(nChannelChip);
00049         Stats<float> gain(nChannelChip);
00050         Stats<float> offset(nChannelChip);
00051         Stats<float> outnse(nChannelChip);
00052         Stats<float> innse(nChannelChip);
00053         
00054         for (unsigned ichan=0; ichan<nChannelChip; ++ichan){
00055             unsigned ichannel = ichan + ichip*nChannelChip;
00056             bool valid=result.getDefects().defectSeverityEncompassingElement(ModuleElement::Channel(ichannel)) == NONE;         
00057 
00058             vt50.modifyAt(ichan).valid = valid;
00059             gain.modifyAt(ichan).valid = valid;
00060             offset.modifyAt(ichan).valid = valid;
00061             outnse.modifyAt(ichan).valid = valid;
00062             innse.modifyAt(ichan).valid = valid;
00063             
00064             vt50.modifyAt(ichan).value = result.getChannelData(ichannel).rc->getFunction()->Eval(result.getSpecialScanPointValue());
00065             gain.modifyAt(ichan).value = result.getChannelData(ichannel).gain;
00066             innse.modifyAt(ichan).value = result.getChannelData(ichannel).noise;
00067             offset.modifyAt(ichan).value = result.getChannelData(ichannel).offset;
00068         }
00069         
00070         out << "#"<<getChipName(ichip) << endl;
00071         out << setfill(' ')  << setw(6) << vt50.mean() << "  " << sqrt(vt50.var()) << "  " 
00072             << setw(6) << gain.mean() << "  " <<  setw(6) << sqrt(gain.var()) << "  " 
00073             << setw(6) << offset.mean() << "  " << setw(6) << sqrt(offset.var()) << "  "
00074             << setw(6) << innse.mean()*gain.mean()/6250. << "  "
00075             << setw(6) << innse.mean() << "  " << setw(6) << sqrt(innse.var()) << endl;
00076         }
00077         
00078 
00079         out << "#\n#LoopC - comment"<<endl;
00080         out << "#";
00081         for (short unsigned ichip=0; ichip<nChipModule/2; ++ichip){
00082         out << getChipName(ichip) << " ";
00083         }
00084         out << endl;
00085 
00086         for (short unsigned ichip=0; ichip<nChipModule/2; ++ichip){
00087         outputDefectOnChip(ichip, result, out);
00088         }
00089         out << endl << "#";
00090         
00091         for (short unsigned ichip=nChipModule/2; ichip<nChipModule; ++ichip){
00092         out << getChipName(ichip) << " ";
00093         }
00094         out << endl;
00095         for (short unsigned ichip=nChipModule/2; ichip<nChipModule; ++ichip){
00096         outputDefectOnChip(ichip, result, out);
00097         }
00098         out << endl << "#";
00099 
00100         out << "#SLOPES: Noise Offset Gain" << endl; 
00101         for (short unsigned ichip=0; ichip<nChipModule; ++ichip){
00102           out << "#"<< getChipName(ichip)<<endl<<"#SLOPE\t";
00103           if (ichip<result.noiseSlope.size()){out << result.noiseSlope[ichip]<<"\t";}else{out << ".\t";}
00104           if (ichip<result.offsetSlope.size()){out << result.offsetSlope[ichip]<<"\t";}else{out << ".\t";}
00105           if (ichip<result.gainSlope.size()){out << result.gainSlope[ichip];}else{out << ".";}
00106           out << endl;
00107         }
00108         SummaryWriter::write(t.getDefects(), out);      
00109     }
00110 
00111     void NPtGainSummaryWriter::outputDefectOnChip(unsigned ichip, const NPtGainTestResult& result, ostream& out) throw() {
00112         auto_ptr<DefectList> defects = result.getDefects().getDefectsEncompassingElement(ModuleElement::Chip(ichip) );
00113         
00114         short unsigned ndefect=0;
00115         for (list<Defect>::const_iterator i = defects->getAllDefects().begin() ;
00116          i != defects->getAllDefects().end(); ++i ) {
00117 
00118           if ( (*i).getModuleElement().isChip() ) {
00119         if (ndefect!=0) out << ",";
00120         ++ndefect;
00121         out << (*i).getPrototype().getName() ;
00122         }
00123         }
00124         if (ndefect==0) out <<  "\"OK\"  " ;
00125     }
00126       
00127       //------------------------------------------------------
00128 
00129     bool NPtGainSummaryWriter::inMap = SummaryManager::instance().addWriter("SctData::NPtGainTestResult", shared_ptr<SummaryWriter>(new NPtGainSummaryWriter()));
00130     }
00131 }

Generated on Thu Feb 10 02:40:11 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5