PreTriggerNoiseTest.h

00001 #ifndef PRETRIGGERNOISETEST_H
00002 #define PRETRIGGERNOISETEST_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 #include <SctApi/extraScans.h>
00016 
00017 using namespace Sct;
00018 using namespace SctCalibrationController::Ipc;
00019 namespace SctCalibrationController {
00020 namespace Scripts {
00021 
00022 class PreTriggerNoiseTest  : public TestRequestImpl {
00023 private:
00024    static const bool registeredInTestLibrary;
00025 
00026 public:
00027     static Sct_CalibrationController::TestRequest_ptr instance() {
00028       static PreTriggerNoiseTest stnt;
00029       stnt.setFitAlgorithm("NONE");
00030       stnt.setAnalysisAlgorithm("PreTriggerNoiseTest");
00031       return stnt._this();
00032     }
00033 
00034     virtual void startTestRealImpl(Sct_SctApi::SctApiIPC_ptr api, string& name, unsigned short& testVariable, unsigned long& nScans, vector<double>& testPoints) {  
00035     this->api = Sct_SctApi::SctApiIPC::_duplicate(api);
00036 
00037         // Compression mode X1X
00038         APICALL(api, modifyABCDVar(ST_COMPRESSION, 1), "PreTriggerNoiseTest::startTest")
00039 
00040         // Edge detect off
00041         APICALL(api, modifyABCDVar(ST_EDGE_DETECT, 0), "PreTriggerNoiseTest::startTest")
00042 
00043         // No masked channels
00044         APICALL(api, modifyABCDVar(ST_SEND_MASK, 0), "PreTriggerNoiseTest::startTest")
00045 
00046         // No masked channels
00047         APICALL(api, modifyABCDVar(ST_QTHR, 0.9), "PreTriggerNoiseTest::startTest")
00048 
00049     name = "PreTriggerNoiseTest";
00050     testVariable = ST_ELAPSED;
00051     nScans = 1;
00052     testPoints.push_back(0.);
00053     }
00054 
00055 
00056     virtual Sct_CalibrationController::ScanRequest_ptr getNextScanRealImpl(unsigned long index) {
00057         Sct_CalibrationController::ScanLibrary_var sl = CalibrationControllerImpl::instance()->getScanLibrary();
00058         Sct_CalibrationController::ScanRequest_ptr request = sl->defaultScan();
00059 
00060     // Create scan
00061         Sct_SctApi::Scan_var s;
00062         APIRETCALL(api, s, createScan(), "PreTriggerNoiseTest::getNextScan")
00063         request->setScanCorba(s);
00064 
00065         // This doesn't work with group distribution which is the default otherwise
00066     APICALL(s, setOption(Sct_SctApi::Scan::distSlave, 0), "Failed to set distSlave option")
00067       
00068         const unsigned nth_trigger=1;
00069     APICALL(s, setOption(Sct_SctApi::Scan::tim, 1), "Failed to set TIM option")
00070     APICALL(s, setOption(Sct_SctApi::Scan::nth, nth_trigger), "Failed to set nth option")
00071     APICALL(s, setOption(Sct_SctApi::Scan::full, 1), "Failed to set nth option")
00072 
00073         // request occupancy per event
00074     APICALL(s, setOption(Sct_SctApi::Scan::ope, 1), "Failed to set ope option")
00075 
00076     // Configure scan - DELAY in clocks relative to NIM trigger input to TIM
00077         APICALL(s, configure(SCT_TIM_PRE_TRIGGER_DELAY, 110, 140, 3), "Failed to set Scan information")
00078       
00079         // set the number of triggers
00080         APICALL(s, setNTrigs(1000), "Failed to set triggers")
00081 
00082     // Adjust trigger
00083     Sct_SctApi::Trigger_var t;
00084     APIRETCALL(s, t, getTrigger1(), "Failed to get trigger1")
00085         APICALL(t, singleL1A(), "Failed to set trigger type")
00086         APICALL(t, setSource(::Sct_SctApi::Trigger::SOURCE_TIM_EXTERNAL), "Failed to set trigger type")
00087 
00088     return request;
00089     }
00090 
00091     virtual bool canFeedbackRealImpl() {
00092     return false;
00093     }
00094 
00095     virtual void endTestRealImpl() {
00096         // TIM internal triggers
00097     api = Sct_SctApi::SctApiIPC::_nil();
00098     }
00099 
00100 private:
00101     PreTriggerNoiseTest() {}
00102     Sct_SctApi::SctApiIPC_var api;
00103 };
00104     
00105 }
00106 }
00107 
00108 #endif //PRETRIGGERNOISETEST_H

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