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 <Sct/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       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), "DoubleTriggerNoiseTest::startTest")
00038 
00039         // Edge detect off
00040         APICALL(api, modifyABCDVar(ST_EDGE_DETECT, 0), "DoubleTriggerNoiseTest::startTest")
00041 
00042         // No masked channels
00043         APICALL(api, modifyABCDVar(ST_SEND_MASK, 0), "DoubleTriggerNoiseTest::startTest")
00044 
00045         // 1 fC threshold
00046         APICALL(api, modifyABCDVar(ST_QTHR, 1.0), "DoubleTriggerNoiseTest::startTest")
00047 
00048     name = "DoubleTriggerNoiseTest";
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(), "DoubleTriggerNoiseTest::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     // Adjust trigger
00082         Sct_SctApi::Trigger_var t;
00083         APIRETCALL(s, t, getTrigger1(), "Failed to get trigger1")
00084 
00085         APICALL(t, doubleL1A(110), "Failed to set trigger type")
00086 
00087     // Increment delay between triggers
00088     APICALL(t, setCommIncr(1, 1), "DoubleTriggerNoiseTest::getNextScan")
00089 
00090     // Configure scan
00091     // Note that while setCommIncr is uses to scan the delay with the 
00092         // pre- 26/7/2005 DSP code, after this it is done through ST_TRIG_DELAY
00093         APICALL(s, configure(ST_TRIG_DELAY1, 110, 140, 1), "Failed to set Scan information")
00094 
00095     return request;
00096     }
00097 
00098     virtual bool canFeedbackRealImpl() {
00099     return false;
00100     }
00101 
00102     virtual void endTestRealImpl() {
00103     api = Sct_SctApi::SctApiIPC::_nil();
00104     }
00105 
00106 private:
00107     DoubleTriggerNoiseTest() {}
00108     Sct_SctApi::SctApiIPC_var api;
00109 };
00110     
00111 }
00112 }
00113 
00114 #endif //DOUBLETRIGGERNOISETEST_H

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