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

DoubleTriggerNoiseAlgorithm.cpp

00001 #include "DoubleTriggerNoiseAlgorithm.h"
00002 #include "AnalysisAlgorithmMap.h"
00003 #include "AnalysisService.h"
00004 #include "SctData/DoubleTriggerNoiseTestResult.h"
00005 #include "SctData/StandardDefects.h"
00006 #include "SctData/RawScanResult.h"
00007 #include "SctData/ConfigurationVariable.h"
00008 #include "Sct/UnsupportedOperationError.h"
00009 #include "SctData/OccupancyProjector.h"
00010 #include <CommonWithDsp/ABCD/ABCDscans.h>
00011 #include <TH1.h>
00012 
00013 using namespace std;
00014 using namespace boost;
00015 using namespace SctData;
00016 using namespace Sct;
00017 
00018 namespace SctAnalysis {
00019     
00020     DoubleTriggerNoiseAlgorithm::~DoubleTriggerNoiseAlgorithm() throw() {}
00021 
00022      shared_ptr<AnalysisAlgorithm> DoubleTriggerNoiseAlgorithm::clone(const TestData& testData, const string& moduleName) const throw() {
00023     return shared_ptr<AnalysisAlgorithm>(new DoubleTriggerNoiseAlgorithm(testData, moduleName, *this));
00024     }
00025 
00026     bool DoubleTriggerNoiseAlgorithm::inMap = AnalysisAlgorithmMap::instance().setAlgorithm("DoubleTriggerNoiseTest", auto_ptr<AnalysisAlgorithm>(new DoubleTriggerNoiseAlgorithm()));
00027 
00028     //----------------------------------------------------------------------
00029     
00030     void DoubleTriggerNoiseAlgorithm::loadData() {
00031     loadAllRaws();
00032     }
00033     
00034     bool DoubleTriggerNoiseAlgorithm::canAnalyze() const {
00035     return hasAllRaws();
00036     }
00037     
00038     shared_ptr<SctData::TestResult> DoubleTriggerNoiseAlgorithm::createTestResult() const {
00039     return shared_ptr<TestResult>(new DoubleTriggerNoiseTestResult());
00040     }
00041 
00042     void DoubleTriggerNoiseAlgorithm::analyze() {
00043     shared_ptr<DoubleTriggerNoiseTestResult> result = dynamic_pointer_cast<DoubleTriggerNoiseTestResult>(getTestResult());
00044     const SctData::ConfigurationVariable& scanVariable = getRaw(0)->getHeader().getVariable();
00045     result->setScanVariable(scanVariable);
00046     const ModuleConfiguration config=getRaw(0)->getConfiguration();
00047     
00048     m_scanVariable = SctData::ConfigurationVariableIOHelper::getTypeRep(scanVariable);
00049     
00050     result->setPassed(true);
00051 
00052     OccupancyProjector opr(*getRaw(0) );
00053     for (unsigned int ichip=0; ichip<nChipModule; ++ichip) {
00054       //const ChipConfiguration& chipconfig=config.getChipConfiguration(ichip);
00055       //DefectList& defects = result->getDefects();
00056       auto_ptr<TH1> occ = opr.getOccupancy("temp", ModuleElement::Chip(ichip)) ;
00057       float peak=0; // maximum occupancy over time bins
00058       float peakbin=0; // bin where the maximum occupancy occurs
00059       float peakerr=0; // the errorbar on the peak. 
00060       float av=0;   // average occupancy over time bins
00061       float peakratio=0; // ratio of peak to pedestal
00062       for (unsigned ibin=1; ibin<=occ->GetNbinsX(); ++ibin){
00063         const float value = occ->GetBinContent(ibin);
00064         if (value>peak) {
00065           peak = value;
00066           peakerr = occ->GetBinError(ibin);
00067           peakbin = occ->GetBinCenter(ibin);
00068         }
00069         av+=value;
00070       }
00071       av -= peak; //subtract the peak out of the sum of all
00072       // Find the average: using N-1, since one bin, namely the peak isn't part of the sum
00073       if (occ->GetNbinsX()>0) av/=((static_cast<float>(occ->GetNbinsX()))-1); 
00074       result->setPeakOccupancy(ichip, peak);
00075       result->setPeakOccupancyBin(ichip, peakbin);
00076       result->setPedestalOccupancy(ichip, av);
00077       if (av>0) {
00078         peakratio = peak/av;
00079       } else {
00080         peakratio = 0;
00081       }
00082       result->setPeakRatio(ichip, peakratio);
00083       // Set passed false if the peak is 5 sigma away from the average
00084       if (peak > 5E-4 || peak > (av+peakerr*4.)){
00085         result->setPassed(false);
00086         result->getDefects().addDefect(Defect(StandardDefects::DOUBTR_HI, ModuleElement::Chip(ichip)));
00087       }
00088     }
00089     }
00090 } // end of namespace SctAnalysis

Generated on Fri Sep 16 18:01:50 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5