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

PipelineAlgorithm.cpp

00001 #include "PipelineAlgorithm.h"
00002 #include "AnalysisAlgorithmMap.h"
00003 #include "SctData/PipelineTestResult.h"
00004 #include "SctData/StandardDefects.h"
00005 #include "SctData/OccupancyProjector.h"
00006 #include <TH1.h>
00007 #include <TH2.h>
00008 
00009 using namespace std;
00010 using namespace boost;
00011 using namespace SctData;
00012 using namespace Sct;
00013 
00014 namespace SctAnalysis {
00015     
00016     bool PipelineAlgorithm::inMap = AnalysisAlgorithmMap::instance().setAlgorithm("PipelineTest", auto_ptr<AnalysisAlgorithm>(new PipelineAlgorithm()));
00017     
00018     shared_ptr<AnalysisAlgorithm> PipelineAlgorithm::clone(const TestData& testData, const string& moduleName) const throw() {
00019     return shared_ptr<AnalysisAlgorithm>(new PipelineAlgorithm(testData, moduleName, *this));
00020     }
00021 
00022     shared_ptr<TestResult> PipelineAlgorithm::createTestResult() const {
00023     return shared_ptr<TestResult>(new PipelineTestResult());
00024     }
00025     
00026     void PipelineAlgorithm::loadData() {
00027     loadAllRaws();
00028     }
00029     
00030     bool PipelineAlgorithm::canAnalyze() const {
00031     return PipelineAlgorithm::hasAllRaws();
00032     }
00033     
00034     void PipelineAlgorithm::analyze() {
00035     shared_ptr<PipelineTestResult> result = dynamic_pointer_cast<PipelineTestResult>(getTestResult());
00036     result->setScanVariable(getRaw(0)->getHeader().getVariable());  
00037     shared_ptr<const RawScanResult> rawa=getRaw(0);
00038     shared_ptr<const RawScanResult> rawb=getRaw(1);
00039     
00040     bool pass = true;
00041 
00042     // quick check:
00043     if (rawa->getScanData(0).GetNbinsY() != rawb->getScanData(0).GetNbinsY() ||
00044         rawa->getScanData(1).GetNbinsY() != rawb->getScanData(1).GetNbinsY() ){
00045         ostringstream os;
00046         os << "PipelineAlgorithm different y-extent of scans " << rawa->getHeader().getScanNumber()
00047            << " and " << rawb->getHeader().getScanNumber() <<ends;
00048         throw IllegalStateError(os.str(), __FILE__, __LINE__);
00049     }
00050 
00051     DefectList& defects=result->getDefects();
00052 
00054     for (unsigned ichip=0; ichip<nChipModule; ++ichip){
00055 
00056         bool stuck[nChannelChip], dead[nChannelChip];
00057 
00058         // loop to find stuck and dead channels and report stuck and dead cells
00059         for (unsigned ichInChip=0; ichInChip<nChannelChip; ++ichInChip){
00060         // initialise
00061         stuck[ichInChip]=false;
00062         dead[ichInChip]=false;
00063 
00064         // find the real channel number
00065         unsigned ichannel=ichip*nChannelChip+ichInChip;
00066 
00067         TH2& hista = rawa->getScanData(ichip/nChipLink);
00068         TH2& histb = rawb->getScanData(ichip/nChipLink);
00069         unsigned nstuckcell=0, ndeadcell=0;
00070 
00071         unsigned nPipeline=hista.GetNbinsY();
00072         
00073         // find number of stuck and dead cells for this channel
00074         for ( unsigned delay=0; delay < nPipeline; ++delay){
00075             double vala = hista.GetBinContent(ichannel%nChannelLink+1, delay+1);
00076             double valb = histb.GetBinContent(ichannel%nChannelLink+1, delay+1);
00077             if(vala<0.95) ++ndeadcell;   // cell is dead val=0
00078             if(valb>0.05) ++nstuckcell;  // cell is stuck val >0
00079         }
00080 
00081         if (nstuckcell==nPipeline){                 // channel stuck
00082           defects.addDefect(Defect(StandardDefects::STUCKON, 
00083                        ModuleElement::Channel(ichannel)));
00084           
00085         } else if (nstuckcell!=0) {                // cell stuck
00086             defects.addDefect(Defect(StandardDefects::STUCK_CELL, 
00087                          ModuleElement::Channel(ichannel)));
00088             pass = false;
00089         }
00090         
00091         if (ndeadcell==nPipeline){                 // channel dead
00092           defects.addDefect(Defect(StandardDefects::DEAD,
00093                        ModuleElement::Channel(ichannel)));
00094 
00095             dead[ichInChip]=true;
00096         } else  if (ndeadcell!=0) {               // cell dead
00097             defects.addDefect(Defect(StandardDefects::DEAD_CELL, 
00098                          ModuleElement::Channel(ichannel)));
00099             pass = false;
00100         }
00101         } // end of first loop over channels in chip
00102 
00103     } // end of loop over chips
00104     
00105     // Fails if there are any defects...
00106     result->setPassed( defects.defectSeverityAffectingElement(ModuleElement::Module())==NONE );
00107     }
00108 } // end of namespace SctAnalysis

Generated on Fri Jan 14 12:47:05 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5