SynchTriggerNoiseTest.h

00001 #ifndef SYNCHTRIGGERNOISETEST_H
00002 #define SYNCHTRIGGERNOISETEST_H
00003 
00004 #include <cmath>  // For fabs
00005 
00006 #include "../ipc/TestRequest.h"
00007 #include "../ipc/CalibrationController.hh"
00008 #include "../CalibrationControllerImpl.h"
00009 #include "../ipc/ScanRequest.h"
00010 #include "../SctApiAccessException.h"
00011 #include "../SctApiCall.h"
00012 #include "Sct/LogicErrors.h"
00013 
00014 #include <Sct/AbcdScans.h>
00015 
00016 using namespace Sct;
00017 using namespace SctCalibrationController::Ipc;
00018 namespace SctCalibrationController {
00019 namespace Scripts {
00020 
00021 class SynchTriggerNoiseTest  : public TestRequestImpl {
00022 private:
00023    static const bool registeredInTestLibrary;
00024 
00025 public:
00026     static Sct_CalibrationController::TestRequest_ptr instance() {
00027       static SynchTriggerNoiseTest stnt;
00028       stnt.setFitAlgorithm("Threshold");
00029       stnt.setAnalysisAlgorithm("NoiseOccupancyTest");
00030       return stnt._this();
00031     }
00032 
00033     virtual void startTestRealImpl(Sct_SctApi::SctApiIPC_ptr api, string& name, unsigned short& testVariable, unsigned long& nScans, vector<double>& testPoints) {  
00034     this->api = Sct_SctApi::SctApiIPC::_duplicate(api);
00035 
00036         // Compression mode X1X
00037         APICALL(api, modifyABCDVar(ST_COMPRESSION, 1), "SynchTriggerNoiseTest::startTest")
00038 
00039         // Edge detect off
00040         APICALL(api, modifyABCDVar(ST_EDGE_DETECT, 0), "SynchTriggerNoiseTest::startTest")
00041 
00042         // No masked channels
00043         APICALL(api, modifyABCDVar(ST_SEND_MASK, 0), "SynchTriggerNoiseTest::startTest")
00044 
00045     name = "NoiseOccupancyTest";
00046     testVariable = ST_ELAPSED;
00047     nScans = 1;
00048     testPoints.push_back(0.);
00049     }
00050 
00051 
00052     virtual Sct_CalibrationController::ScanRequest_ptr getNextScanRealImpl(unsigned long index) {
00053         Sct_CalibrationController::ScanLibrary_var sl = CalibrationControllerImpl::instance()->getScanLibrary();
00054         Sct_CalibrationController::ScanRequest_ptr request = sl->defaultScan();
00055 
00056     // Create scan
00057         Sct_SctApi::Scan_var s;
00058         APIRETCALL(api, s, createScan(), "SynchTriggerNoiseTest::getNextScan")
00059         request->setScanCorba(s);
00060 
00061         // This doesn't work with group distribution which is the default otherwise
00062     APICALL(s, setOption(Sct_SctApi::Scan::distSlave, 0), "Failed to set distSlave option")
00063       
00064         const unsigned nth_trigger=15;
00065     APICALL(s, setOption(Sct_SctApi::Scan::tim, 1), "Failed to set TIM option")
00066     APICALL(s, setOption(Sct_SctApi::Scan::nth, nth_trigger), "Failed to set nth option")
00067 
00068         // request occupancy per event
00069     APICALL(s, setOption(Sct_SctApi::Scan::ope, 1), "Failed to set ope option")
00070 
00071     // Adjust trigger
00072         Sct_SctApi::Trigger_var t;
00073         APIRETCALL(s, t, getTrigger1(), "Failed to get trigger1")
00074 
00075         APICALL(t, singleL1A(), "Failed to set trigger type")
00076         APICALL(t, setFrequency(40.), "Failed to set trigger frequency")
00077         APICALL(t, setRandom(2), "Failed to set random trigger")
00078         APICALL(t, setSource(::Sct_SctApi::Trigger::SOURCE_TIM_INTERNAL), "Failed to set random trigger")
00079 
00080     // Configure scan - set range in mV relative to trim target (1.0 fC).
00081         APICALL(s, configure(ST_QTHR, 1.1, 0.8, -0.025), "Failed to set Scan information")
00082       
00083         // set the number of triggers
00084         APICALL(s, setNTrigs(200000), "Failed to set triggers")
00085 
00086     return request;
00087     }
00088 
00089     virtual bool canFeedbackRealImpl() {
00090     return false;
00091     }
00092 
00093     virtual void endTestRealImpl() {
00094     api = Sct_SctApi::SctApiIPC::_nil();
00095     }
00096 
00097 private:
00098     SynchTriggerNoiseTest() {}
00099     Sct_SctApi::SctApiIPC_var api;
00100 };
00101     
00102 }
00103 }
00104 
00105 #endif //SYNCHTRIGGERNOISETEST_H

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