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

ThresholdScan.h

00001 #ifndef THRESHOLDSCAN_H
00002 #define THRESHOLDSCAN_H
00003 
00004 #include <cmath>  // For fabs
00005 
00006 #include "../ipc/Sct_CalibrationController.hh"
00007 #include "../CalibrationControllerImpl.h"
00008 #include "../ipc/ScanRequest.h"
00009 #include "../SctApiAccessException.h"
00010 #include "../SctApiCall.h"
00011 #include "Sct/LogicErrors.h"
00012 
00013 #include <CommonWithDsp/ABCD/ABCDscans.h>
00014 
00015 using namespace Sct;
00016 using namespace SctCalibrationController::Ipc;
00017 namespace SctCalibrationController {
00018 namespace Scripts {
00019     
00020 class ThresholdScan  : public ScanRequestImpl {
00021 public:
00022     static ScanRequestImpl& thresholdScan(unsigned long nTrigs, double calChargefC = -1, double offset=0) {
00023       static ThresholdScan request;
00024       Sct_SctApi_T_SctApi* api = CalibrationControllerImpl::instance().getApi();
00025       Sct_SctApi_T_Scan* s = 0;
00026       APIRETCALL(api, s, createScan(&st), "Failed to create scan")
00027 
00028     request.setScan(s);
00029 
00030         APICALL(s, setNTrigs(&st, nTrigs), "Failed to set triggers")
00031     
00032         Sct_SctApi_T_Trigger* t = 0;
00033       APIRETCALL(s, t, getTrigger1(&st), "Failed to get Trigger1")
00034     
00035         APICALL(t, calL1A(&st, 0x82), "Failed to set trigger type")
00036 
00037         if (fabs(calChargefC) > 0.05) {
00038             APICALL(s, setOption(&st, Sct_SctApi_T_Scan_ScanOptions_loopCalLine, 1), "Failed to set loopCalLine")
00039         }
00040 
00041     double lo = 40.0 * calChargefC + offset/2.;
00042     double hi = 150.0 + 70.0 * calChargefC + offset;
00043 
00044     //Only set to lowLimit if we have some cal charge!
00045     if ((calChargefC > 0 && lo < lowLimit) || calChargefC < 0) lo = lowLimit;
00046     else if (lo < 0) lo = 0;
00047     if (hi > highLimit || calChargefC < 0) hi = highLimit;
00048         if (hi < lo) hi = lo + 100;
00049     
00050         APICALL(s, configure(&st, ST_VTHR, lo, hi, 5), "Failed to set Scan information")
00051 
00052     return request;
00053     }
00054     
00055 private:
00056     ThresholdScan(){;}  
00057     
00058     static const double lowLimit = 0;
00059     static const double highLimit = 633;
00060 };
00061     
00062 }
00063 }
00064 
00065 #endif //THRESHOLDSCAN_H

Generated on Thu Jul 15 09:51:01 2004 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5