NMaskAlgorithm.cpp

00001 #include "NMaskAlgorithm.h"
00002 #include "AnalysisAlgorithmMap.h"
00003 #include "SctData/NMaskTestResult.h"
00004 #include "SctData/RawScanResult.h"
00005 #include "SctData/StandardDefects.h"
00006 #include "SctData/ModuleElement.h"
00007 #include <TH1.h>
00008 #include <TH2.h>
00009 
00010 using namespace std;
00011 using namespace boost;
00012 using namespace SctData;
00013 using namespace Sct;
00014 
00015 namespace SctAnalysis {
00016 
00017 bool NMaskAlgorithm::inMap = AnalysisAlgorithmMap::instance().setAlgorithm("NMaskTest", auto_ptr<AnalysisAlgorithm>(new NMaskAlgorithm()));
00018 
00019 shared_ptr<AnalysisAlgorithm> NMaskAlgorithm::clone(shared_ptr<const TestData> testData, const string& moduleName) const throw() {
00020     return shared_ptr<AnalysisAlgorithm>(new NMaskAlgorithm(testData, moduleName, *this));
00021 }
00022 
00023 void NMaskAlgorithm::loadData() {
00024     loadAllRaws();
00025 }
00026 
00027 bool NMaskAlgorithm::canAnalyze() const {
00028     return hasAllRaws();
00029 }
00030 
00031 shared_ptr<SctData::TestResult> NMaskAlgorithm::createTestResult() const {
00032     return shared_ptr<NMaskTestResult> (new NMaskTestResult());
00033 }
00034 
00035 void NMaskAlgorithm::analyze() {
00036     shared_ptr<NMaskTestResult> result =  dynamic_pointer_cast<NMaskTestResult> ( getTestResult() );
00037 
00038     shared_ptr<const RawScanResult> raw = getRaw(0);
00039     result->setScanVariable(raw->getHeader().getVariable());    
00040     
00041     TH2D& link0 = raw->getScanData(0);
00042     TH2D& link1 = raw->getScanData(1);
00043     int nTriggers = (int)result->getTestPointAt(0);
00044     const ScanPoints& points=raw->getPoints();
00045 
00046     for (unsigned int channel = 0; channel<Sct::nChannelModule; ++channel) {
00047     for (unsigned int bin = 0; bin<points.getNPoints(); ++bin) {
00048         int content = (int) channel < Sct::nChannelLink ? link0.GetBinContent(channel+1, bin+1) : link1.GetBinContent(channel+1-nChannelLink, bin+1);
00049         if (channel%nChannelChip < points[bin]) {
00050         if (content != 0) {
00051             result->getDefects().addDefect(Defect(StandardDefects::OVER, ModuleElement::Channel(channel)));
00052             break;
00053         }
00054         } else {
00055         if (content != nTriggers) {
00056             result->getDefects().addDefect(Defect(StandardDefects::UNDER, ModuleElement::Channel(channel)));
00057             break;
00058         }
00059         }
00060     }
00061     }
00062 
00063 
00064     const unsigned nbadchannels = result->getDefects().nChannelsAffected();
00065     if (nbadchannels > 2){              // >2 problem channels
00066     result->setPassed(false);
00067     result->setProblem(false);
00068     } else if (nbadchannels > 0) {      // 1 or 2 problem channels
00069         result->setPassed(true); 
00070     result->setProblem(true);
00071     } else {
00072         result->setPassed(true);       // no problem channels
00073         result->setProblem(false);
00074     }
00075 
00076 }
00077 } // end of namespace SctAnalysis

Generated on Mon Feb 6 14:01:23 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6