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

ThresholdFitAlgorithm.cpp

Go to the documentation of this file.
00001 #include "ThresholdFitAlgorithm.h"
00002 #include "FitAlgorithmMap.h"
00003 #include "FitterMode.h"
00004 #include "SctData/mVThresholdVariable.h"
00005 #include "SctData/ModuleDefect.h"
00006 #include "SctData/ErfcFitObject.h"
00007 #include <TH1.h>
00008 
00009 using namespace SctData;
00010 
00011 namespace SctFitter {
00012     
00013 bool ThresholdFitAlgorithm::putInMap() throw() {    
00014     return FitAlgorithmMap::instance().setAlgorithm(mVThresholdVariable::instance().getVariableName(), auto_ptr<FitAlgorithm>(new ThresholdFitAlgorithm));
00015 }
00016     
00017 bool ThresholdFitAlgorithm::inMap = putInMap();
00018 
00019 ThresholdFitAlgorithm::ThresholdFitAlgorithm() throw() {
00020     FitterMode& mode = getMode();
00021     mode.fitNone(); 
00022     mode.fitChips(); 
00023     mode.fitChannels() ; 
00024     mode.doSummary(false); 
00025 }
00026 
00027 auto_ptr<FitObject> ThresholdFitAlgorithm::getPrototype() const throw() {
00028     return auto_ptr<FitObject> (new ErfcFitObject());
00029 }
00030 
00031 void ThresholdFitAlgorithm::guessParameters(const TH1& hist, FitObject& fitOb) const throw (LogicError, MathsError) {
00032     fitOb.setParameter(0, hist.GetMaximum() ) ;
00033     fitOb.fixParameter(0, true);
00034     fitOb.setParameter(1, findLevel(hist,0.5,false)) ;                 // 50% level
00035     double p2 = findLevel(hist, 0.82, false) - fitOb.getParameter(1);    // level 1-sigma away from 50%
00036     if (p2<0.) p2=-p2;  
00037     fitOb.setParameter(2, p2 ) ;
00038 
00039     int lbin=findBin(hist, 0.99, false); if ((lbin-1)>=1) lbin--;
00040     int ubin=findBin(hist, 0.01, false); if ((ubin+1)<hist.GetNbinsX()) ubin++;
00041     fitOb.setVarMin(0 , hist.GetBinLowEdge( lbin ) );    // Lower edge of bin before first bin < 99%
00042     fitOb.setVarMax(0 , hist.GetBinLowEdge( ubin+1 ) );    // Upper edge of bin after first bin <1% 
00043 }
00044 
00045 void ThresholdFitAlgorithm::checkForDefects(const TH1& hist, const ModuleElement& element, ModuleDefectList& defects) const throw (LogicError) {
00046     double maxVal = hist.GetMaximum();
00047     double minVal = hist.GetMinimum();
00048     
00049     //Prevent ROOT calculating this millions of times!
00050     TH1* h_nonconst = const_cast<TH1*>(&hist);
00051     h_nonconst->SetMaximum(maxVal);
00052     h_nonconst->SetMinimum(minVal);
00053 
00054     if ( maxVal < ModuleDefect::DEAD.getParameter() ){
00055     defects.addDefect(ModuleDefect::DEAD, element);
00056     } else if( maxVal < ModuleDefect::UNDER.getParameter() ){
00057     defects.addDefect(ModuleDefect::UNDER,element);
00058     } else if( maxVal > ModuleDefect::OVER.getParameter() ){
00059     defects.addDefect(ModuleDefect::OVER,element);
00060     }
00061     if( minVal > ModuleDefect::STUCKON.getParameter() ){
00062     defects.addDefect(ModuleDefect::STUCKON, element);
00063     } 
00064     
00065 }
00066 
00067 void ThresholdFitAlgorithm::createSummaryHistograms(FitScanResult& fits) const throw() {
00068     /*
00069     string name = getUniqueID() + "Mean";
00070     string title = getClassName() + "." + getUniqueID() + " Mean";
00072     TH1D* rooth = new TH1D(name.c_str(), title.c_str(), 30, 0, 20);
00073     if (!rooth) throw InvalidArgument("FitScanResult::createSummaryHistograms() couldn't make histogram");
00074     for (vector<FitObject*>::iterator is = m_channelFits.begin(); is!= m_channelFits.end(); ++is ) {
00075     rooth->Fill( (*is)->getParameter(1) );
00076     }
00077 */
00078 }
00079     
00080 }

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