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

DoubleTriggerNoiseTest.h

00001 #ifndef DOUBLETRIGGERNOISETEST_H
00002 #define DOUBLETRIGGERNOISETEST_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 <CommonWithDsp/ABCD/ABCDscans.h>
00015 
00016 using namespace Sct;
00017 using namespace SctCalibrationController::Ipc;
00018 namespace SctCalibrationController {
00019 namespace Scripts {
00020 
00021 class DoubleTriggerNoiseTest  : public TestRequestImpl {
00022 private:
00023    static const bool registeredInTestLibrary;
00024 
00025 public:
00026     static Sct_CalibrationController::TestRequest_ptr instance() {
00027       static DoubleTriggerNoiseTest dtnt;
00028       return dtnt._this();
00029     }
00030 
00031     virtual void startTestRealImpl(Sct_SctApi::SctApiIPC_ptr api, string& name, unsigned short& testVariable, unsigned long& nScans, vector<double>& testPoints) {  
00032     this->api = Sct_SctApi::SctApiIPC::_duplicate(api);
00033 
00034         // Compression mode X1X
00035         APICALL(api, modifyABCDVar(ST_COMPRESSION, 1), "DoubleTriggerNoiseTest::startTest")
00036 
00037         // Edge detect off
00038         APICALL(api, modifyABCDVar(ST_EDGE_DETECT, 0), "DoubleTriggerNoiseTest::startTest")
00039 
00040         // No masked channels
00041         APICALL(api, modifyABCDVar(ST_SEND_MASK, 0), "DoubleTriggerNoiseTest::startTest")
00042 
00043         // 1 fC threshold
00044         APICALL(api, modifyABCDVar(ST_QTHR, 1.0), "DoubleTriggerNoiseTest::startTest")
00045 
00046     name = "DoubleTriggerNoiseTest";
00047     testVariable = ST_ELAPSED;
00048     nScans = 1;
00049     testPoints.push_back(0.);
00050     }
00051 
00052 
00053     virtual Sct_CalibrationController::ScanRequest_ptr getNextScanRealImpl(unsigned long index) {
00054         Sct_CalibrationController::ScanLibrary_var sl = CalibrationControllerImpl::instance()->getScanLibrary();
00055         Sct_CalibrationController::ScanRequest_ptr request = sl->defaultScan();
00056 
00057     // Create scan
00058         Sct_SctApi::Scan_var s;
00059         APIRETCALL(api, s, createScan(), "DoubleTriggerNoiseTest::getNextScan")
00060         request->setScanCorba(s);
00061 
00062         APICALL(s, setNTrigs(10000), "Failed to set triggers")
00063 
00064         // This doesn't work with group distribution which is the default otherwise
00065     APICALL(s, setOption(Sct_SctApi::Scan::distSlave, 0), "Failed to set distSlave option")
00066 
00067         // Only capture every 2nd trigger
00068     APICALL(s, setOption(Sct_SctApi::Scan::nth, 2), "Failed to set nth option")
00069 
00070         // Capture the second of the two triggers (index 0)
00071     // Note that some data has been taken (e.g. B6 assembly) with
00072     // nth_rem incorrectly set to 1 which is the intuitive value but is WRONG. The light-leak
00073     //   peaks seen in B3 are only with nth_rem set to 0 (confirmed by Dave R at SR1).
00074     APICALL(s, setOption(Sct_SctApi::Scan::nth_rem, 0), "Failed to set nth_rem option")
00075 
00076     // Adjust trigger
00077         Sct_SctApi::Trigger_var t;
00078         APIRETCALL(s, t, getTrigger1(), "Failed to get trigger1")
00079 
00080         APICALL(t, doubleL1A(120), "Failed to set trigger type")
00081 
00082     // Increment delay between triggers
00083     APICALL(t, setCommIncr(1, 1), "DoubleTriggerNoiseTest::getNextScan")
00084 
00085     // Configure scan
00086         APICALL(s, configure(ST_ELAPSED, 120, 165, 1), "Failed to set Scan information")
00087 
00088     return request;
00089     }
00090 
00091     virtual bool canFeedbackRealImpl() {
00092     return false;
00093     }
00094 
00095     virtual void endTestRealImpl() {
00096     api = Sct_SctApi::SctApiIPC::_nil();
00097     }
00098 
00099 private:
00100     DoubleTriggerNoiseTest() {}
00101     Sct_SctApi::SctApiIPC_var api;
00102 };
00103     
00104 }
00105 }
00106 
00107 #endif //DOUBLETRIGGERNOISETEST_H

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