///////////////////////////////////////////////////////////////////// // PixScan.h ///////////////////////////////////////////////////////////////////// // // 17/06/05 Version 1.2 (PM) // Explicit separation of scan loop start and // scan step preparation // Some modification to the proposal to allow // - execution of mask staging a tthe host level // - execution of loops with values dynamically // choosen by PixModuleGroup guring the scan // /* PixScan is a structure describing a scan and containing scan results. It's not responsible for the execution of the scan; this task is performed by PixModuleGroup, which in turns uses PixController methods to activate the DSPs. PixScan however can contain helper funcions used during the execution of a scan (e.g. histogram manipulation and fit). PixScan can be used as a carrier to move scan reults from a processor to another, having the ability to save and retreive data from a permanent storage; it can also implement intelligent caching mechanism to allow a processor to access a large set of histograms minimizing memory occupation. The structure is designed for a three-loop scan. The innermost loop (which implicitly includes the mask stagin as an extra loop) is usually performed by the ROD DSPs. The second loop can be performed by the ROD or by the host while the third loop is usually performed by the host. PixScan defines four groups of modules. The histograms of every group are collected and processed by the corresponding SDSP. Modules not assigned to any group are ignored during the scan. The activity of the modules of a group during a scan is controlled by four parameters: configure : if true the modules are configured at the beginning of the scan trigger : if true the modules receive LVL1 commands strobe : if true the modules receive STROBE commands readout : if true the modules are read-out It's possible to specify a fixed delay between strobe/trigger sequences sent to groups 1,2 and 3,4. Finally, it's possible to split a single event (which is usually made of 16 consecutive LVL1) in two parts of N amd M (N+M<=16) consecutive LVL1 separated by a fixed time gap. Two different settings are possible, one for groups 1,2 and the other for groups 3,4. There is a set of scan attributes and a set of loop attributes. Scan attributes are parameters which are set at the beginning of a scan and remains constant during the entire scan. Loop attributes indicates specific properties of every loop, like the variable being scanned during the loop or the operation to e performed at the end of the loop. PixScan includes a set of hidden attributes; these are not intended to be modified by the user, so no interface is provided; hidden attributes are computed automatically when needed, based on scan and loop attributes, and passed to the PixController. Scan attributes --------------- - Configuration set to use - Concurrent scan or FE by FE - Mask stage mode - Mask stage # of steps - Mask stage # of steps to execute - Inversion between mask stage and innermost loop - Number of events in the innermost loop - Enable self trigger - Trigger/Strobe delay - LVL1 latency - Strobe duration - Module mask (gr 1-4) - Configuration enabled (gr 1-4) - Trigger enabled (gr 1-4) - Strobe enabled (gr 1-4) - Readout enabled (gr 1-4) - Trigger delay gr 1,2-3,4 - Number of consecutive LVL1 in Trigger group A (gr 1,2 3,4) - Number of consecutive LVL1 in Trigger group B (gr 1,2 3,4) - Delay between trigger group 1 and 2 (gr 1,2 3,4) - Type of histogramming routine to be used in the DSPs - Histograms to be filled during the scan - TOT histogams min, max and # of bins - Raw histograms to be kept till the end of the scan - Analog or digital injection - Charge injection capacitor - Column readout frequency - TOT threshold mode - TOT minimum - TOT double hit threshold - TOT or leading edge time stamp - Bias voltage mode - Bias voltage value - Analog voltage mode - Analog voltage value - Digital voltage mode - Digital voltage value Loop attributes --------------- - Parameter being scanned during the loop - Loop execution in the DSP or in the Host - Array of values for the scan parameter or Min, Max and number of steps or sequence not predefined - Operation to be performed at the end of the loop (e.g. s-curve fit or tdac adjust). - Use of DSP for the end loop action This examples illustrates how PixScan used to perform a scan: PixScan *scn; PixModuleGroup *grp; scn->resetScan(); grp->initScan(scn); grp->scanLoopStart(2, scn); while (scn->loop(2)) { grp->prepareStep(2,scn); grp->scanLoopStart(1, scn); while (scn->loop(1)) { grp->prepareStep(1,scn); grp->scanLoopStart(0, scn); while (scn->loop(0)) { grp->prepareStep(0,scn); grp->scanExecute(scn); std::cout << "Completed loop: " << scn->scanIndex(2) << "/"; std::cout << scn->scanIndex(1) << "/" << scn->scanIndex(0) << std::endl; grp->scanTerminate(scn); scn->next(0); } grp->scanLoopEnd(0, scn); scn->next(1); } grp->scanLoopEnd(1, scn); scn->next(2); } grp->scanLoopEnd(2, scn); grp->terminateScan(scn); grp->initScan(scn) has to prepare the module group for the scn. This includes, for egxample, the regulation of the voltages via DCS grp->scanLoopStart(index, scn) prepares the module group for the beginning of a particular loop. This includes any hardware or software setting to be performed once at the beginning of the loop, grp->prepareStep(index, scn) the typical operation to perform in this phase is the setting of the loop scan variable to the appropriate value. For the innermost loop (index = 0) this operation has to be performed only if scn->newScanStep() returns TRUE; in case the mask staging is under the responsability of the host, this method will also setup the appropriate mask when scn->newMaskStep() returns TRUE. grp->scanExecute(scn) executes a step of the scan. If the loop is executed in the DSP this method will setup the ROD and complete an entire loop. grp->scanLoopEnd(index, scn) will perform the end-of-loop actions. Typically this method will upload histograms or fit results from the ROD and store them in the appropriate PixScan structures; it will also compute the results needed for the execution of the subsequent step. grp->terminateScan(scn) executes end od scan actions, like resotring the initial module configuration if needed. */ #ifndef _PIXLIB_PIXSCAN #define _PIXLIB_PIXSCAN #ifdef WIN32 #pragma warning(disable: 4786) #pragma warning(disable: 4800) #endif #include #include #include #include #include "PixController/PixController.h" #include "PixConfDBInterface/PixConfDBInterface.h" #include "Histo/Histo.h" #include "Config/Config.h" #include "scanControl.h" #include "primParams.h" #include "defines.h" // definitions for histo sizes #define NFES 2 #define NCOLS 80 #define NROWS 336 #define NCOLM NFES*NCOLS #define NROWM NROWS namespace PixLib { class Config; class Histo; class PixControllerExc; //! Pix Controller Exception class; an object of this type is thrown in case of a controller error class PixScanExc : public PixControllerExc { public: //! Constructor PixScanExc(ErrorLevel el, std::string name) : PixControllerExc(el, name) {}; //! Destructor virtual ~PixScanExc() {}; private: }; #define MAX_GROUPS 4 #define MAX_SGROUPS 2 #define MAX_LOOPS 3 class PixScanHisto { public: PixScanHisto(); PixScanHisto(Histo &h); PixScanHisto(unsigned int ih, Histo &h); PixScanHisto(unsigned int ix, PixScanHisto &sh); ~PixScanHisto(); void add(unsigned int ix, PixScanHisto &sh); void add(unsigned int ih, Histo &h); void add(unsigned int ih, std::vector< Histo * >&h); bool exists(unsigned int ix); bool histoExists(unsigned int ih); unsigned int size(); unsigned int histoSize(); bool histoMode(); PixScanHisto &operator[](unsigned int ix); Histo &histo(); Histo &histo(unsigned int ih); void clear(); private: std::map *m_histo; std::map *m_map; bool m_histoMode; std::string m_id; bool m_cached; }; class PixScan { friend class PixController; friend class RodPixController; friend class USBPixController; public: enum ScanType { DIGITAL_TEST, ANALOG_TEST, THRESHOLD_SCAN, TOT_CALIB, TDAC_TUNE, GDAC_TUNE, FDAC_TUNE, IF_TUNE, TIMEWALK_MEASURE, INCREMENTAL_TDAC_SCAN, BOC_RX_DELAY_SCAN, BOC_THR_RX_DELAY_SCAN, BOC_V0_RX_DELAY_SCAN, INTIME_THRESH_SCAN, T0_SCAN, CROSSTALK_SCAN, IV_SCAN, DAC_SCAN, MONLEAK, HITBUS_SCALER, SOURCE_SCAN, EUDAQ, TOT_VERIF, NOISE_OCC, INJ_CALIB, TDAC_FAST_TUNE, GDAC_FAST_TUNE, HITOR_SCAN, FE_ST_SOURCE_SCAN, TOT_CALIB_ALT}; enum ModConfigType { PHYSICS = PHYSICS_MODULE_CONFIG, CALIB = SCAN_MODULE_CONFIG, SPARE = SPARE_MODULE_CONFIG }; enum MaskStageMode { SEL_ENA = MASK_STAGEMODE_SEL_ENA, SEL = MASK_STAGEMODE_SEL, ENA = MASK_STAGEMODE_ENA, XTALK = MASK_STAGEMODE_XTALK, SEL_ENA_PRE = MASK_STAGEMODE_SEL_ENA_PRE, SEL_PRE = MASK_STAGEMODE_SEL_PRE, HITB, ENA_HITB, SEL_ENA_HITB, STATIC, HITB_INV }; enum MaskStageSteps { STEPS_1, STEPS_2, STEPS_3, STEPS_4, STEPS_6, STEPS_8, STEPS_32, STEPS_336, STEPS_672, STEPS_26880, STEPS_USER}; enum DspHistoCode { ASM = HISTO_ROUTINE_ASM, C = HISTO_ROUTINE_C }; enum DspHistoDepth { BITS_8 = HISTOGRAM_8BIT, BITS_16 = HISTOGRAM_16BIT, BITS_32 = HISTOGRAM_32BIT }; enum HistogramType { OCCUPANCY = PixController::OCCUPANCY, LVL1 = PixController::LVL1, TOT = PixController::TOT, TOT_MEAN = PixController::TOT_MEAN, TOT_SIGMA = PixController::TOT_SIGMA, SCURVE_MEAN = PixController::SCURVE_MEAN, SCURVE_SIGMA = PixController::SCURVE_SIGMA, SCURVE_CHI2 = PixController::SCURVE_CHI2, HITOCC = PixController::HITOCC, TOTAVERAGE = PixController::TOTAVERAGE, TOTCAL_PARA = PixController::TOTCAL_PARA, TOTCAL_PARB = PixController::TOTCAL_PARB, TOTCAL_PARC = PixController::TOTCAL_PARC, TOTCAL_CHI2 = PixController::TOTCAL_CHI2, DSP_ERRORS = PixController::DSP_ERRORS, CLUSTER_TOT = PixController::CLUSTER_TOT, CLUSTER_SIZE = PixController::CLUSTER_SIZE, CLSIZE_TOT = PixController::CLSIZE_TOT, SEED_TOT = PixController::SEED_TOT, SEED_LVL1 = PixController::SEED_LVL1, NSEEDS = PixController::NSEEDS, TOT0 = PixController::TOT0, TOT1 = PixController::TOT1, TOT2 = PixController::TOT2, TOT3 = PixController::TOT3, TOT4 = PixController::TOT4, TOT5 = PixController::TOT5, TOT6 = PixController::TOT6, TOT7 = PixController::TOT7, TOT8 = PixController::TOT8, TOT9 = PixController::TOT9, TOT10 = PixController::TOT10, TOT11 = PixController::TOT11, TOT12 = PixController::TOT12, TOT13 = PixController::TOT13, TOT14 = PixController::TOT14, TOT15 = PixController::TOT15, TDAC_T, TDAC_THR, GDAC_T, GDAC_THR, FDAC_T, FDAC_TOT, IF_T, IF_TOT, TIMEWALK, RAW_DATA_REF, RAW_DATA_0, RAW_DATA_1, RAW_DATA_DIFF_1, RAW_DATA_DIFF_2, DCS_DATA, MON_LEAK, HB_SCALER_CNT, FIT_PAR0, FIT_PAR1, FIT_PAR2, FIT_PAR3, FIT_PAR4, FIT_CHI2, TDAC_OCC, SUM_OCC, HIT_RATE, TRG_RATE, GDAC_OCC, MAX_HISTO_TYPES }; enum VoltageMode { DEF_VAL, CUSTOM_VAL, OFF_VAL }; enum DcsReadMode { VOLTAGE, CURRENT }; enum ScanParam { NO_PAR = SCAN_NONE, IVDD2 = SCAN_IVDD2, ID = SCAN_ID, IP2 = SCAN_IP2, IP = SCAN_IP, TRIMT = SCAN_TRIMT, IF = SCAN_IF, TRIMF = SCAN_TRIMF, ITH1 = SCAN_ITH1, ITH2 = SCAN_ITH2, IL = SCAN_IL, IL2 = SCAN_IL2, LATENCY = SCAN_LATENCY, TDACS = SCAN_TDACS, FDACS = SCAN_FDACS, GDAC = SCAN_GDAC, TRIGGER_DELAY = SCAN_TRIGGER_DELAY, STROBE_DURATION = SCAN_STROBE_DURATION, VCAL = SCAN_VCAL, STROBE_DELAY = SCAN_STROBE_DELAY, TDACS_VARIATION, BOC_BPH, BOC_VPH0, BOC_VPH1, BOC_VFINE, BOC_BPMPH, BOC_TX_CURR, BOC_TX_MS, BOC_RX_THR, BOC_RX_DELAY, BOC_TX_BPM, BOC_TX_BPMF, BOC_BVPH, DCS_VOLTAGE, CAPMEAS, FEI4_GR, CAPSEL, IREF_PAD, INCR_LAT_TRGDEL, IOMUX_IN};//IOMUX enum EndLoopAction { NO_ACTION, SCURVE_FIT, TDAC_TUNING, GDAC_TUNING, T0_SET, FDAC_TUNING, IF_TUNING, MIN_THRESHOLD, MCCDEL_FIT, TOTCAL_FIT, FDAC_TUNING_ALT, OFFSET_CALIB, TDAC_FAST_TUNING, OCC_SUM, GDAC_FAST_TUNING, TOTCAL_FEI4, CLEAR_IOMUX_BITS};//CLEAR_IOMUX_BITS enum MccBandwidth { SINGLE_40 = MCC_SINGLE_40, DOUBLE_40 = MCC_DOUBLE_40, SINGLE_80 = MCC_SINGLE_80, DOUBLE_80 = MCC_DOUBLE_80 }; enum RunType { NORMAL_SCAN, RAW_PATTERN, RAW_EVENT }; enum CountType {COUNT_TRIGGER, COUNT_DH, COUNT_DR, COUNT_SECS}; enum TriggerType {STROBE_SCAN=0, USBPIX_SELF_TRG=1, EXT_TRG=2, TLU_SIMPLE=3, TLU_DATA_HANDSHAKE=4, USBPIX_REPLICATION_SLAVE=5, STROBE_EXTTRG=6, FE_SELFTRIGGER=7, STROBE_USBPIX_SELF_TRG=8}; private: // Global scan config ModConfigType m_modConfig; bool m_modScanConcurrent; MaskStageMode m_maskStageMode; MaskStageSteps m_maskStageTotalSteps; int m_maskStageSteps; int m_maskStageStepWidth; int m_repetitions; int m_srcCountType; int m_srcTriggerType; bool m_selfTrigger; bool m_strobeLVL1DelayOverride; int m_strobeLVL1Delay; int m_LVL1Latency; int m_strobeDuration; int m_strobeFrequency; int m_strobeMCCDelay; int m_strobeMCCDelayRange; unsigned int m_moduleMask[MAX_GROUPS]; bool m_configEnabled[MAX_GROUPS]; bool m_triggerEnabled[MAX_GROUPS]; bool m_strobeEnabled[MAX_GROUPS]; bool m_readoutEnabled[MAX_GROUPS]; int m_superGroupTrigDelay; int m_consecutiveLvl1TrigA[MAX_SGROUPS]; int m_consecutiveLvl1TrigB[MAX_SGROUPS]; int m_trigABDelay[MAX_SGROUPS]; bool m_lvl1HistoBinned; bool m_histogramFilled[MAX_HISTO_TYPES]; bool m_histogramKept[MAX_HISTO_TYPES]; DspHistoCode m_dspHistogrammingCode; //JW: ROD specific stuff DspHistoDepth m_dspHistoDepth; //JW: ROD specific stuff MccBandwidth m_mccBandwidth; int m_histoTotMin; int m_histoTotMax; int m_histoTotNbin; int m_maxColClusterDist; int m_maxRowClusterDist; int m_maxClusterBcidDepth; int m_upperThreshTimewalk; bool m_digitalInjection; int m_chargeInjCap; int m_columnROFreq; int m_feVCal; int m_feHitbus; int m_totThrMode; int m_totMin; int m_totDHThr; int m_totTimeStampMode; VoltageMode m_biasMode; float m_biasVoltage; VoltageMode m_analogMode; float m_analogVoltage; VoltageMode m_digitalMode; float m_digitalVoltage; bool m_restoreModuleConfig; RunType m_runType; std::vector m_patternSeeds; // JGK: added for DCS scanning: std::string m_readDcsChan; DcsReadMode m_readDcsMode; std::string m_scanDcsChan; //JW: source scan flag and raw data file bool m_isSourceScan; std::string m_sourceRawFile; //SS: testbeam flags bool m_isTestBeam; bool m_skipSourceScanHistos; int m_lowerLVL1DelayIfSlaveBy; int m_TLUTriggerDataDelay; // Loop configuration bool m_loopActive[MAX_LOOPS]; ScanParam m_loopParam[MAX_LOOPS]; bool m_dspProcessing[MAX_LOOPS]; //JW: kann für Processing auf Mikrocontroller benutzt werden... bool m_dspMaskStaging; //JW: ROD specific stuff bool m_innerLoopSwap; std::vector m_loopVarValues[MAX_LOOPS]; std::string m_loopFEI4GR[MAX_LOOPS]; int m_loopVarNSteps[MAX_LOOPS]; float m_loopVarMin[MAX_LOOPS]; float m_loopVarMax[MAX_LOOPS]; bool m_loopVarUniform[MAX_LOOPS]; bool m_loopVarValuesFree[MAX_LOOPS]; EndLoopAction m_loopAction[MAX_LOOPS]; bool m_dspLoopAction[MAX_LOOPS]; //JW: ROD specific stuff bool m_loopOverDcs; bool m_avoidSpecialsCols; bool m_singleDCloop; bool m_configAtStart; // Scan execution int m_loopIndex[MAX_LOOPS]; int m_maskStageIndex; bool m_newMaskStage; bool m_newScanStep; bool m_loopTerminating[MAX_LOOPS]; bool m_loopEnded[MAX_LOOPS]; // Scan specific parameters int m_thresholdTargetValue; int m_totTargetValue; int m_totTargetCharge; float m_minThrNoiseCutNormal; float m_minThrNoiseCutLong; float m_minThrNoiseCutGanged; float m_minThrNoiseCutInterGanged; float m_minThrChi2Cut; // DB related DBInquire* m_dbInquire; PixConfDBInterface *m_db; Config *m_conf; // Histograms int m_nHisto; int m_nHistoSize; std::map m_histo; std::map m_histogramTypes; std::map m_dspHistogramTypes; std::map m_scanTypes; std::vector m_tmpSCmean; std::vector m_tmpSCsigma; std::vector m_tmpSCchi2; unsigned int m_modScurveFit; // S-curve fit quality float m_chicut; int m_nbadchicut; // Private methods void writeHistoLevel(DBInquire *dbi, PixScanHisto &sc, std::string lName, int lvl); void readHistoLevel(DBInquire *dbi, PixScanHisto &sc, std::string lName, int lvl, int idx); void prepareIndexes(HistogramType type, unsigned int mod, int ix2, int ix1, int ix0); public: //! Constructors PixScan(); PixScan(ScanType presetName); PixScan(DBInquire *dbi); PixScan(const PixScan &scn); //! Destructor ~PixScan(); //! Init configuration void initConfig(); //! Load predefined configurations void preset(ScanType presetName); //! Scan attributes ModConfigType getModConfig() { return m_modConfig; }; void setModConfig(ModConfigType cfgTyp) { m_modConfig = cfgTyp; }; bool getModScanConcurrent() { return m_modScanConcurrent; }; void setModScanConcurrent(bool concurr) { m_modScanConcurrent = concurr; }; MaskStageMode getMaskStageMode() { return m_maskStageMode; }; void setMaskStageMode(MaskStageMode stageMode) { m_maskStageMode = stageMode; }; MaskStageSteps getMaskStageTotalSteps() { return m_maskStageTotalSteps; }; void setMaskStageTotalSteps(MaskStageSteps nSteps) { m_maskStageTotalSteps = nSteps; }; int getMaskStageSteps() { return m_maskStageSteps; }; void setMaskStageSteps(int nSteps) { m_maskStageSteps = nSteps; }; int getMaskStageStepWidth() { return m_maskStageStepWidth; }; int getMaskStageIndex(){ return m_maskStageIndex; } int getRepetitions() { return m_repetitions; }; void setRepetitions(int nRep) { m_repetitions = nRep; }; bool getSelfTrigger() { return m_selfTrigger; }; void setSelfTrigger(bool self) { m_selfTrigger = self; }; bool getStrobeLVL1DelayOverride() { return m_strobeLVL1DelayOverride; }; void setStrobeLVL1DelayOveride(bool lvl1StrDelayOverride) { m_strobeLVL1DelayOverride = lvl1StrDelayOverride; }; int getStrobeLVL1Delay() { return m_strobeLVL1Delay; }; void setStrobeLVL1Delay(int lvl1StrDelay) { m_strobeLVL1Delay = lvl1StrDelay; }; int getLVL1Latency() { return m_LVL1Latency; }; void setLVL1Latency(int lvl1Latency) { m_LVL1Latency = lvl1Latency; }; int getStrobeMCCDelay() { return m_strobeMCCDelay; }; void setStrobeMCCDelay(int delay) { m_strobeMCCDelay = delay; }; int getStrobeMCCDelayRange() { return m_strobeMCCDelayRange; }; void setStrobeMCCDelayRange(int delayRange) { m_strobeMCCDelayRange = delayRange; }; int getStrobeDuration() { return m_strobeDuration; }; void setStrobeDuration(int strobeDuration) { m_strobeDuration = strobeDuration; }; int getStrobeFrequency() { return m_strobeFrequency; }; void setStrobeFrequency(int strobeFrequency) { m_strobeFrequency = strobeFrequency; }; unsigned int getModuleMask(int group) { if (group >=0 && group < MAX_GROUPS) { return m_moduleMask[group]; } return 0; }; void setModuleMask(int group, unsigned int mask) { if (group >=0 && group < MAX_GROUPS) { m_moduleMask[group] = mask; } }; bool getConfigEnabled(int group) { if (group >=0 && group < MAX_GROUPS) { return m_configEnabled[group]; } return false; }; void setConfigEnabled(int group, bool ena) { if (group >=0 && group < MAX_GROUPS) { m_configEnabled[group] = ena; } }; bool getTriggerEnabled(int group) { if (group >=0 && group < MAX_GROUPS) { return m_triggerEnabled[group]; } return false; }; void setTriggerEnabled(int group, bool ena) { if (group >=0 && group < MAX_GROUPS) { m_triggerEnabled[group] = ena; } }; bool getStrobeEnabled(int group) { if (group >=0 && group < MAX_GROUPS) { return m_strobeEnabled[group]; } return false; }; void setStrobeEnabled(int group, bool ena) { if (group >=0 && group < MAX_GROUPS) { m_strobeEnabled[group] = ena; } }; bool getReadoutEnabled(int group) { if (group >=0 && group < MAX_GROUPS) { return m_readoutEnabled[group]; } return false; }; void setReadoutEnabled(int group, bool ena) { if (group >=0 && group < MAX_GROUPS) { m_readoutEnabled[group] = ena; } }; int getSuperGroupTrigDelay() { return m_superGroupTrigDelay; }; void setSuperGroupTrigDelay(int delay) { m_superGroupTrigDelay = delay; }; int getConsecutiveLvl1TrigA(int superGroup) { if (superGroup >=0 && superGroup < MAX_SGROUPS) { return m_consecutiveLvl1TrigA[superGroup]; } return 0; }; void setConsecutiveLvl1TrigA(int superGroup, int nLvl1) { if (superGroup >=0 && superGroup < MAX_SGROUPS) { m_consecutiveLvl1TrigA[superGroup] = nLvl1; } }; int getConsecutiveLvl1TrigB(int superGroup) { if (superGroup >=0 && superGroup < MAX_SGROUPS) { return m_consecutiveLvl1TrigB[superGroup]; } return 0; }; void setConsecutiveLvl1TrigB(int superGroup, int nLvl1) { if (superGroup >=0 && superGroup < MAX_SGROUPS) { m_consecutiveLvl1TrigB[superGroup] = nLvl1; } }; bool getLvl1HistoBinned() { return m_lvl1HistoBinned; }; void setLvl1HistoBinned(bool bin) { m_lvl1HistoBinned = bin; }; int getTrigABDelay(int superGroup) { if (superGroup >=0 && superGroup < MAX_SGROUPS) { return m_trigABDelay[superGroup]; } return 0; }; void setTrigABDelay(int superGroup, int delay) { if (superGroup >=0 && superGroup < MAX_SGROUPS) { m_trigABDelay[superGroup] = delay; } }; DspHistoCode getDspHistogrammingCode() { return m_dspHistogrammingCode; }; void setDspHistogrammingCode(DspHistoCode code) { m_dspHistogrammingCode = code; }; DspHistoDepth getDspHistoDepth() { return m_dspHistoDepth; }; void setDspHistoDepth(DspHistoDepth dep) { m_dspHistoDepth = dep; }; MccBandwidth getMccBandwidth() { return m_mccBandwidth; }; void setMccBandwidth(MccBandwidth bw) { m_mccBandwidth = bw; }; bool getHistogramFilled(HistogramType type) { return m_histogramFilled[type]; }; void setHistogramFilled(HistogramType type, bool fill) { m_histogramFilled[type] = fill; }; bool getHistogramKept(HistogramType type) { return m_histogramKept[type]; }; void setHistogramKept(HistogramType type, bool keep) { m_histogramKept[type] = keep; }; int getHistoTotMin() { return m_histoTotMin; }; void setHistoTobtMin(int totMin) { m_histoTotMin = totMin; }; int getHistoTotMax() { return m_histoTotMax; }; void setHistoTotMax(int totMax) { m_histoTotMax = totMax; }; int getHistoTotNbin() { return m_histoTotNbin; }; void setHistoTotNbin(int totNbin) { m_histoTotNbin = totNbin; }; void getClusterPars(int &maxColClusterDist, int &maxRowClusterDist, int &maxClusterBcidDepth, int &upperThreshTimewalk){ maxColClusterDist = m_maxColClusterDist; maxRowClusterDist = m_maxRowClusterDist; maxClusterBcidDepth = m_maxClusterBcidDepth; upperThreshTimewalk = m_upperThreshTimewalk; } void setClusterPars(int maxColClusterDist, int maxRowClusterDist, int maxClusterBcidDepth, int &upperThreshTimewalk){ m_maxColClusterDist = maxColClusterDist; m_maxRowClusterDist = maxRowClusterDist; m_maxClusterBcidDepth = maxClusterBcidDepth; m_upperThreshTimewalk = upperThreshTimewalk; } bool getDigitalInjection() { return m_digitalInjection; }; void setDigitalInjection(bool digiInj) { m_digitalInjection = digiInj; }; int getChargeInjCap() { return m_chargeInjCap; }; void setChargeInjCap(int cap) { m_chargeInjCap = cap; }; int getColumnROFreq() { return m_columnROFreq; }; void setColumnROFreq(int colROFreq) { m_columnROFreq = colROFreq; }; int getFeVCal() { return m_feVCal; }; void setFeVCal(int vcal) { m_feVCal = vcal; }; int getFeHitbus() { return m_feHitbus; }; void setFeHitbus(int hitbus) { m_feHitbus = hitbus; }; int getTotThrMode() { return m_totThrMode; }; void setTotThrMode(int totMode) { m_totThrMode = totMode; }; int getTotMin() { return m_totMin; }; void setTotMin(int totMin) { m_totMin = totMin; }; int getTotDHThr() { return m_totDHThr; }; void setTotDHThr(int totDHThr) { m_totDHThr = totDHThr; }; int getTotTimeStampMode() { return m_totTimeStampMode; }; void setTotTimeStampMode(int totMode) { m_totTimeStampMode = totMode; }; VoltageMode getBiasMode() { return m_biasMode; }; void setBiasMode(VoltageMode mode) { m_biasMode = mode; }; double getBiasVoltage() { return m_biasVoltage; }; void setBiasVoltage(double voltage) { m_biasVoltage = (float)voltage; }; VoltageMode getAnalogMode() { return m_analogMode; }; void setAnalogMode(VoltageMode mode) { m_analogMode = mode; }; double getAnalogVoltage() { return m_analogVoltage; }; void setAnalogVoltage(double voltage) { m_analogVoltage = (float)voltage; }; VoltageMode getDigitalMode() { return m_digitalMode; }; void setDigitalMode(VoltageMode mode) { m_digitalMode = mode; }; double getDigitalVoltage() { return m_digitalVoltage; }; void setDigitalVoltage(double voltage) { m_digitalVoltage = (float)voltage; }; // new DCS scan functionality std::string getDcsChan(){return m_readDcsChan;}; DcsReadMode getDcsMode(){return m_readDcsMode;}; std::string getScanDcsChan(){return m_scanDcsChan;}; bool getRestoreModuleConfig() { return m_restoreModuleConfig; } void setRestoreModuleConfig(bool restore) { m_restoreModuleConfig = restore; } RunType getRunType() { return m_runType; } void setRunType(RunType run) { m_runType = run; } std::vector& getPatternSeeds() { return m_patternSeeds; }; void setPatternSeeds(std::vector values) { m_patternSeeds = values; }; //! Loop attributes bool getLoopActive(int index) { if (index >=0 && index < MAX_LOOPS) { return m_loopActive[index]; } return false; }; void setLoopActive(int index, bool active) { if (index >=0 && index < MAX_LOOPS) { m_loopActive[index] = active; } }; ScanParam getLoopParam(int index) { if (index >=0 && index < MAX_LOOPS) { return m_loopParam[index]; } return NO_PAR; }; void setLoopParam(int index, ScanParam par) { if (index >=0 && index < MAX_LOOPS) { m_loopParam[index] = par; } }; bool getDspProcessing(int index) { if (index >=0 && index < MAX_LOOPS) { return m_dspProcessing[index]; } return false; }; void setDspProcessing(int index, bool dsp) { if (index >=0 && index < MAX_LOOPS) { m_dspProcessing[index] = dsp; } }; bool getDspMaskStaging() { return m_dspMaskStaging; }; void setDspMaskStaging(bool dsp) { m_dspMaskStaging = dsp; }; bool getInnerLoopSwap() { return m_innerLoopSwap; }; void setInnerLoopSwap(bool swp) { m_innerLoopSwap = swp; }; void setLoopFEI4GR(int index, std::string nameGr){ if (index >=0 && index < MAX_LOOPS) { m_loopFEI4GR[index] = nameGr; } } std::string& getLoopFEI4GR(int index){ static std::string tmp="unknown"; if (index >=0 && index < MAX_LOOPS) { return m_loopFEI4GR[index]; } throw PixScanExc(PixControllerExc::ERROR, "Invalid loop index"); return tmp; } std::vector& getLoopVarValues(int index) { static std::vector tmp; if (index >=0 && index < MAX_LOOPS) { return m_loopVarValues[index]; } throw PixScanExc(PixControllerExc::ERROR, "Invalid loop index"); return tmp; }; void setLoopVarValues(int index, double startVal, double endVal, int nSteps) { if (index >=0 && index < MAX_LOOPS) { m_loopVarNSteps[index] = nSteps; m_loopVarMin[index] = (float)startVal; m_loopVarMax[index] = (float)endVal; m_loopVarValues[index].clear(); double v = startVal; double incr = (endVal - startVal)/(nSteps -1); for (int iv=0; iv values) { if (index >=0 && index < MAX_LOOPS) { m_loopVarValues[index] = values; m_loopVarNSteps[index] = values.size(); m_loopVarMin[index] = m_loopVarMax[index] = values[0]; for (unsigned int i=0; i m_loopVarMax[index]) m_loopVarMax[index] = values[i]; } m_loopVarUniform[index] = false; m_loopVarValuesFree[index] = false; } else throw PixScanExc(PixControllerExc::ERROR, "Invalid loop index"); }; int getLoopVarNSteps(int index) { if (index >=0 && index < MAX_LOOPS) { return m_loopVarNSteps[index]; } throw PixScanExc(PixControllerExc::ERROR, "Invalid loop index"); return 0; } float getLoopVarMin(int index) { if (index >=0 && index < MAX_LOOPS) { return m_loopVarMin[index]; } throw PixScanExc(PixControllerExc::ERROR, "Invalid loop index"); return 0; } float getLoopVarMax(int index) { if (index >=0 && index < MAX_LOOPS) { return m_loopVarMax[index]; } throw PixScanExc(PixControllerExc::ERROR, "Invalid loop index"); return 0; } bool getLoopVarValuesFree(int index) { if (index >=0 && index < MAX_LOOPS) { return m_loopVarValuesFree[index]; } throw PixScanExc(PixControllerExc::ERROR, "Invalid loop index"); return false; }; void setLoopVarValuesFree(int index) { if (index >=0 && index < MAX_LOOPS) { m_loopVarValuesFree[index] = true; } else throw PixScanExc(PixControllerExc::ERROR, "Invalid loop index"); }; bool getLoopVarUniform(int index) { if (index >=0 && index < MAX_LOOPS) { return m_loopVarUniform[index]; } throw PixScanExc(PixControllerExc::ERROR, "Invalid loop index"); return false; }; EndLoopAction getLoopAction(int index) { if (index >=0 && index < MAX_LOOPS) { return m_loopAction[index]; } throw PixScanExc(PixControllerExc::ERROR, "Invalid loop index"); return NO_ACTION; }; void setLoopAction(int index, EndLoopAction action) { if (index >=0 && index < MAX_LOOPS) { m_loopAction[index] = action; } else throw PixScanExc(PixControllerExc::ERROR, "Invalid loop index"); }; bool getDspLoopAction(int index) { if (index >=0 && index < MAX_LOOPS) { return m_dspLoopAction[index]; } throw PixScanExc(PixControllerExc::ERROR, "Invalid loop index"); return false; }; void setDspLoopAction(int index, bool dsp) { if (index >=0 && index < MAX_LOOPS) { m_dspLoopAction[index] = dsp; } else throw PixScanExc(PixControllerExc::ERROR, "Invalid loop index"); }; void setLoopOverDcs(bool val){ m_loopOverDcs = val; }; bool getLoopOverDcs(){ return m_loopOverDcs; }; void setAvoidSpecialsCols(bool val){ m_avoidSpecialsCols = val; } bool getAvoidSpecialsCols(){ return m_avoidSpecialsCols; } void setSingleDCloop(bool val){ m_singleDCloop = val; } bool getSingleDCloop(){ return m_singleDCloop; } bool getConfigAtStart(){ return m_configAtStart; } //! Scan control void resetScan(); bool loop(int index); int scanIndex(int index); void next(int index); void terminate(int index); bool newMaskStep(); bool newScanStep(); // Scan specific parameters void setThresholdTargetValue(int val) { m_thresholdTargetValue = val; }; int getThresholdTargetValue() { return m_thresholdTargetValue; }; void setTotTargetValue(int val) { m_totTargetValue = val; }; int getTotTargetValue() { return m_totTargetValue; }; void setTotTargetCharge(int val) { m_totTargetCharge = val; }; int getTotTargetCharge() { return m_totTargetCharge; }; float getMinThrNoiseCutNormal(){ return m_minThrNoiseCutNormal; } float getMinThrNoiseCutLong(){ return m_minThrNoiseCutLong; } float getMinThrNoiseCutGanged(){ return m_minThrNoiseCutGanged; } float getMinThrNoiseCutInterGanged(){ return m_minThrNoiseCutInterGanged; } float getMinThrNoiseCut(int type); float getMinThrChi2Cut(){ return m_minThrChi2Cut; } bool getSourceScanFlag() { return m_isSourceScan; }; bool getTestBeamFlag() { return m_isTestBeam; }; int getLowerLVL1DelayIfSlaveBy() { return m_lowerLVL1DelayIfSlaveBy; }; int getTLUTriggerDataDelay() { return m_TLUTriggerDataDelay; }; bool getSkipSourceScanHistos() { return m_skipSourceScanHistos; }; std::string getSourceRawFile(){ return m_sourceRawFile; } int getSrcCountType(){ return m_srcCountType; } int getSrcTriggerType(){ return m_srcTriggerType; } //! DataBase interaction void writeConfig(DBInquire *dbi); void writeHisto(DBInquire *dbi); void write(DBInquire* dbi); void readConfig(DBInquire *dbi); void readHisto(DBInquire *dbi); void read(DBInquire *dbi); Config &config() { return *m_conf; }; //! Histogram handling void addHisto(Histo &his, HistogramType type, unsigned int mod, int ix2, int ix1, int ix0); void addHisto(std::vector< Histo * >&his, HistogramType type, unsigned int mod, int ix2, int ix1, int ix0); void addHisto(std::vector< Histo * >&his, HistogramType type, unsigned int mod, int ix2, int ix1); void addHisto(std::vector< Histo * >&his, unsigned int nh, HistogramType type, unsigned int mod, int ix2, int ix1); void addHisto(std::vector< Histo * >&his, unsigned int d2, unsigned int d1, HistogramType type, unsigned int mod, int ix2); void downloadHisto(PixController *ctrl, unsigned int mod, HistogramType type); void downloadErrorHisto(PixController *ctrl, unsigned int dsp); void clearHisto(unsigned int mod, HistogramType type); Histo& getHisto(HistogramType type, int module, int idx2, int idx1, int idx0); Histo& getHisto(HistogramType type, int module, int idx2, int idx1, int idx0, int ih); PixScanHisto& getHisto(HistogramType type); std::map &getHistoTypes() { return m_histogramTypes; } std::map &getDspHistoTypes() { return m_dspHistogramTypes; }; std::map &getScanTypes() { return m_scanTypes; }; //! Helper functions void calcThr(PixController *ctrl, unsigned int mod, int ix2, int ix1, bool delay=false); void calcTotCal(PixController *ctrl, unsigned int mod, int ix2, int ix1); void fitSCurve(PixScanHisto &sc, Histo &thr, Histo &noise, Histo& chi2, int ih, int rep); }; } #endif