00001 #include "StrobeDelayAlgorithm.h" 00002 #include "AnalysisAlgorithmMap.h" 00003 #include "SctData/StrobeDelayTestResult.h" 00004 #include "SctData/FitScanResult.h" 00005 #include "SctData/FitObject.h" 00006 #include "SctData/TopHatFitObject.h" 00007 #include "SctData/DefectList.h" 00008 #include "SctData/StandardDefects.h" 00009 #include <string> 00010 00011 using namespace std; 00012 using namespace boost; 00013 using namespace SctData; 00014 using namespace Sct; 00015 00016 namespace SctAnalysis { 00017 00018 bool StrobeDelayAlgorithm::inMap = AnalysisAlgorithmMap::instance().setAlgorithm("StrobeDelayTest", auto_ptr<AnalysisAlgorithm>(new StrobeDelayAlgorithm())); 00019 00020 shared_ptr<AnalysisAlgorithm> StrobeDelayAlgorithm::clone(const TestData& testData, const string& moduleName) const throw(){ 00021 return shared_ptr<AnalysisAlgorithm>(new StrobeDelayAlgorithm(testData, moduleName, *this)); 00022 } 00023 00024 shared_ptr<TestResult> StrobeDelayAlgorithm::createTestResult() const { 00025 return shared_ptr<StrobeDelayTestResult> (new StrobeDelayTestResult()) ; 00026 } 00027 00028 void StrobeDelayAlgorithm::loadData() { 00029 loadAllFits(); 00030 } 00031 00032 bool StrobeDelayAlgorithm::canAnalyze() const { 00033 return hasAllFits(); 00034 } 00035 00036 void StrobeDelayAlgorithm::analyze() { 00037 const double fraction=0.4; 00038 StrobeDelayTestResult& result = *dynamic_pointer_cast<StrobeDelayTestResult>(getTestResult()); 00039 const FitScanResult& fitted = *getFit(0); 00040 result.setScanVariable(fitted.getHeader().getVariable()); 00041 00042 bool pass = true; 00043 result.setNOptima(nChipModule); 00044 for (short unsigned int ichip=0; ichip<nChipModule; ++ichip ) { 00045 const DefectSeverity& severity = result.getDefects().defectSeverityAffectingElement(ModuleElement::Chip(ichip)); 00046 if (severity>=SERIOUS) pass=false; 00047 FitObject& fit = fitted.getChipFit(ichip); 00048 try { 00049 dynamic_cast<TopHatFitObject&> (fit); 00050 } catch(std::exception& e) { 00051 throw InvariantViolatedError("StrobeDelayAlgorithm::optimize ERROR not a TopHat function", __FILE__, __LINE__); 00052 } 00053 double rise=fit.getParameter(1), fall=fit.getParameter(3); 00054 result.setOptimum(ichip, rise + fraction*(fall-rise)); 00055 if (rise < 0 || fall < StandardDefects::SD_LO.getParameter()) { 00056 result.getDefects().addDefect(Defect(StandardDefects::SD_LO, ModuleElement::Chip(ichip))); 00057 pass = false; 00058 } 00059 if (rise > StandardDefects::SD_HI.getParameter() || fall > 63) { 00060 result.getDefects().addDefect(Defect(StandardDefects::SD_HI, ModuleElement::Chip(ichip))); 00061 pass = false; 00062 } 00063 } 00064 result.setPassed(pass); 00065 } 00066 00067 00068 }