SynchDoubleTriggerNoiseTest.h

00001 #ifndef SYNCH_DOUBLETRIGGERNOISETEST_H
00002 #define SYNCH_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 <Sct/AbcdScans.h>
00015 
00016 using namespace Sct;
00017 using namespace SctCalibrationController::Ipc;
00018 namespace SctCalibrationController {
00019 namespace Scripts {
00020 
00021 class SynchDoubleTriggerNoiseTest  : public TestRequestImpl {
00022 private:
00023    static const bool registeredInTestLibrary;
00024 
00025 public:
00026     static Sct_CalibrationController::TestRequest_ptr instance() {
00027       static SynchDoubleTriggerNoiseTest dtnt;
00028       dtnt.setFitAlgorithm("NONE");
00029       dtnt.setAnalysisAlgorithm("DoubleTriggerNoiseTest");
00030       return dtnt._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), "SynchDoubleTriggerNoiseTest::startTest")
00038 
00039         // Edge detect off
00040         APICALL(api, modifyABCDVar(ST_EDGE_DETECT, 0), "SynchDoubleTriggerNoiseTest::startTest")
00041 
00042         // No masked channels
00043         APICALL(api, modifyABCDVar(ST_SEND_MASK, 0), "SynchDoubleTriggerNoiseTest::startTest")
00044 
00045         // 1 fC threshold
00046         APICALL(api, modifyABCDVar(ST_QTHR, 1.0), "SynchDoubleTriggerNoiseTest::startTest")
00047 
00048     name = "SynchDoubleTriggerNoiseTest";
00049     testVariable = ST_ELAPSED;
00050     nScans = 1;
00051     testPoints.push_back(0.);
00052     }
00053 
00054 
00055     virtual Sct_CalibrationController::ScanRequest_ptr getNextScanRealImpl(unsigned long index) {
00056         Sct_CalibrationController::ScanLibrary_var sl = CalibrationControllerImpl::instance()->getScanLibrary();
00057         Sct_CalibrationController::ScanRequest_ptr request = sl->defaultScan();
00058 
00059     // Create scan
00060         Sct_SctApi::Scan_var s;
00061         APIRETCALL(api, s, createScan(), "SynchDoubleTriggerNoiseTest::getNextScan")
00062         request->setScanCorba(s);
00063 
00064         APICALL(s, setNTrigs(10000), "Failed to set triggers")
00065 
00066         // This doesn't work with group distribution which is the default otherwise
00067     APICALL(s, setOption(Sct_SctApi::Scan::distSlave, 0), "Failed to set distSlave option")
00068 
00069         // Only capture every 2nd trigger
00070     APICALL(s, setOption(Sct_SctApi::Scan::nth, 2), "Failed to set nth option")
00071 
00072         // Capture the second of the two triggers (index 0)
00073     // Note that some data has been taken (e.g. B6 assembly) with nth_rem incorrectly set to 
00074     // 1, which is the intuitive value but is WRONG. The light-leak peaks seen in B3 are only
00075     // visible with nth_rem set to 0 (confirmed by Dave R at SR1).
00076     APICALL(s, setOption(Sct_SctApi::Scan::nth_rem, 0), "Failed to set nth_rem option")
00077 
00078         // Add occupancy-per-event histograms
00079     APICALL(s, setOption(Sct_SctApi::Scan::ope, 1), "Failed to set ope option")
00080 
00081     // Synchronise!
00082     APICALL(s, setOption(Sct_SctApi::Scan::tim, 1), "Failed to set tim option")
00083 
00084     // Adjust trigger
00085         Sct_SctApi::Trigger_var t;
00086         APIRETCALL(s, t, getTrigger1(), "Failed to get trigger1")
00087 
00088         APICALL(t, doubleL1A(110), "Failed to set trigger type")
00089         APICALL(t, setFrequency(1.3), "Failed to set trigger frequency")
00090         APICALL(t, setRandom(2), "Failed to set trigger random")
00091         APICALL(t, setSource(::Sct_SctApi::Trigger::SOURCE_TIM_INTERNAL), "Failed to set trigger random")
00092 
00093     // Increment delay between triggers
00094     APICALL(t, setCommIncr(1, 1), "SynchDoubleTriggerNoiseTest::getNextScan")
00095 
00096     // Configure scan
00097     // Note that while setCommIncr is uses to scan the delay with the 
00098         // pre- 26/7/2005 DSP code, after this it is done through ST_TRIG_DELAY
00099         APICALL(s, configure(ST_TRIG_DELAY1, 110, 140, 1), "Failed to set Scan information")
00100 
00101     return request;
00102     }
00103 
00104     virtual bool canFeedbackRealImpl() {
00105     return false;
00106     }
00107 
00108     virtual void endTestRealImpl() {
00109     api = Sct_SctApi::SctApiIPC::_nil();
00110     }
00111 
00112 private:
00113     SynchDoubleTriggerNoiseTest() {}
00114     Sct_SctApi::SctApiIPC_var api;
00115 };
00116     
00117 }
00118 }
00119 
00120 #endif //SYNCH_DOUBLETRIGGERNOISETEST_H

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