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

ThresholdScan.h

Go to the documentation of this file.
00001 #ifndef THRESHOLDSCAN_H
00002 #define THRESHOLDSCAN_H
00003 
00004 #include "../ipc/Sct_CalibrationController.hh"
00005 
00006 #include "../SctApiException.h"
00007 #include "Sct/LogicErrors.h"
00008 
00009 #include <CommonWithDsp/ABCD/ABCDscans.h>
00010 
00011 using namespace Sct;
00012 
00013 namespace SctCalibrationController {
00014 namespace Scripts {
00015     
00016 class ThresholdScan {
00017 public:
00018     static Sct_SctApi_T_Scan& thresholdScan(Sct_SctApi_T_SctApi& api, unsigned long nTrigs, double calChargefC = -1) {  
00019     Sct_SctApiStatus status;
00020     Sct_SctApi_T_Scan* s = api.defaultScan(&status);
00021     if (status.returnCode != 0)
00022         throw SctApiException(status.returnCode, "thresholdScan", __FILE__, __LINE__);
00023     
00024     s->setNTrigs(&status, nTrigs);
00025     if (status.returnCode != 0)
00026         throw SctApiException(status.returnCode, "thresholdScan", __FILE__, __LINE__);
00027     
00028     Sct_SctApi_T_Trigger* t = s->getTrigger1(&status);
00029     if (status.returnCode != 0)
00030         throw SctApiException(status.returnCode, "thresholdScan", __FILE__, __LINE__);
00031     
00032     t->calL1A(&status, 0x82);
00033     if (status.returnCode != 0)
00034         throw SctApiException(status.returnCode, "thresholdScan", __FILE__, __LINE__);
00035 
00036         if (fabs(calChargefC) > 0.05) {
00037             s->setOption(&status, Sct_SctApi_T_Scan_ScanOptions_loopCalLine, 1);
00038             if (status.returnCode != 0)
00039             throw SctApiException(status.returnCode, "thresholdScan", __FILE__, __LINE__);
00040         }
00041 
00042     double lo = 40.0 * calChargefC;
00043     double hi = 150.0 + 60.0 * calChargefC;
00044 
00045     //Only set to lowLimit if we have some cal charge!
00046     if (calChargefC > 0 && lo < lowLimit || calChargefC < 0) lo = lowLimit;
00047     else if (lo < 0) lo = 0;
00048     if (hi > highLimit || calChargefC < 0) hi = highLimit;
00049         if (hi < lo) hi = lo + 100;
00050 
00051     s->configure(&status, ST_VTHR, lo, hi, 5);
00052     
00053     return *s;
00054     }
00055     
00056 private:
00057     ThresholdScan();    
00058     
00059     static const double lowLimit = 0;
00060     static const double highLimit = 638;
00061 };
00062     
00063 }
00064 }
00065 
00066 #endif //THRESHOLDSCAN_H

Generated on Mon Dec 15 19:36:21 2003 for SCT DAQ/DCS Software by doxygen1.3-rc3