///////////////////////////////////////////////////////////////////// // PixScanConfig.cxx ///////////////////////////////////////////////////////////////////// // // 4/03/04 Version 1.0 (PM) // Initial release // #include "PixModule/PixModule.h" #include "PixMcc/PixMcc.h" #include "PixFe/PixFe.h" #include "PixController/PixScanConfig.h" #include "PixConfDBInterface/PixConfDBInterface.h" #include "Config/Config.h" #include "Histo/Histo.h" #include using namespace PixLib; PixScanConfig::PixScanConfig() { initConfig(); } PixScanConfig::PixScanConfig(ScanType presetName) { m_db = NULL; m_dbInquire = NULL; initConfig(); } PixScanConfig::PixScanConfig(DBInquire *dbi) : m_dbInquire(dbi) { m_db = m_dbInquire->getDB(); initConfig(); readConfig(dbi); } PixScanConfig::~PixScanConfig() { } void PixScanConfig::preset(ScanType presetName) { } void PixScanConfig::addLoop(std::string varName, double startVal, double endVal, double step, int group) { } void PixScanConfig::addLoop(std::string varName, std::vector values, int group) { } void PixScanConfig::addMaskStageLoop(MaskStagingMode mode, int nStep, int group) { } int PixScanConfig::nLoops() { return 0; } std::string PixScanConfig::loopVarName(int loop, int group) { return ""; } std::vector& PixScanConfig::loopVarValues(int loop, int group) { return m_varValues[group][loop]; } void PixScanConfig::loopRemove(int loop) { } void PixScanConfig::enableStrobe(int group) { if (group>=0 && group=0 && group=0 && group=0 && group=0 && group=0 && group=0 && group=0 && group=0 && group=0 && group=0 && group tf; tf["FALSE"] = 0; tf["TRUE"] = 1; // Group general conf.addGroup("general"); std::map configMap; configMap["PHISICS_MODULE_CONFIG"] = PHYSICS_MODULE_CONFIG; configMap["SCAN_MODULE_CONFIG"] = SCAN_MODULE_CONFIG; configMap["SPARE_MODULE_CONFIG"] = SPARE_MODULE_CONFIG; conf["general"].addList("configSet", m_scanPar.general.configSet, PHYSICS_MODULE_CONFIG, configMap, "Configuration set to use", true); conf["general"].addList("reportErrors", m_scanPar.general.reportErrors, 1, tf, "Toggle to enable data integrity checks on SDSPs",true); conf["general"].addList("globalCtrl", m_scanPar.general.globalCtrl, 0, tf, "Determines whether MDSP or TIM sends triggers", true); std::map concurMap; concurMap["SCAN_CONCURRENT"] = SCAN_CONCURRENT; concurMap["SCAN_ONE_BY_ONE"] = SCAN_ONE_BY_ONE; conf["general"].addList("moduleScanMode", m_scanPar.general.moduleScanMode, SCAN_CONCURRENT, concurMap, "Concurrent or FE by FE", true); std::map scanvarMap; scanvarMap["NO_SCAN"] = NO_SCAN; scanvarMap["SCAN_NONE"] = SCAN_NONE; scanvarMap["SCAN_IVDD2"] = SCAN_IVDD2; scanvarMap["SCAN_ID"] = SCAN_ID; scanvarMap["SCAN_IP2"] = SCAN_IP2; scanvarMap["SCAN_IP"] = SCAN_IP; scanvarMap["SCAN_TRIMT"] = SCAN_TRIMT; scanvarMap["SCAN_IF"] = SCAN_IF; scanvarMap["SCAN_TRIMF"] = SCAN_TRIMF; scanvarMap["SCAN_ITH1"] = SCAN_ITH1; scanvarMap["SCAN_ITH2"] = SCAN_ITH2; scanvarMap["SCAN_IL"] = SCAN_IL; scanvarMap["SCAN_IL2"] = SCAN_IL2; scanvarMap["SCAN_LATENCY"] = SCAN_LATENCY; scanvarMap["SCAN_TDACS"] = SCAN_TDACS; scanvarMap["SCAN_FDACS"] = SCAN_FDACS; scanvarMap["SCAN_GDAC"] = SCAN_GDAC; scanvarMap["SCAN_TRIGGER_DELAY"] = SCAN_TRIGGER_DELAY; scanvarMap["SCAN_STROBE_DURATION"] = SCAN_STROBE_DURATION; scanvarMap["SCAN_VCAL"] = SCAN_VCAL; scanvarMap["SCAN_STROBE_DELAY"] = SCAN_STROBE_DELAY; conf["general"].addList("scanParameter0", m_scanPar.general.scanParameter[0], SCAN_NONE, scanvarMap, "Scan parameter specifier", true); conf["general"].addList("scanParameter1", m_scanPar.general.scanParameter[1], SCAN_NONE, scanvarMap, "Scan parameter specifier", true); conf["general"].addList("uniformPoints0",m_scanPar.general.uniformPoints[0], 1, tf, "1 if scanStart, scanEnd & nBins determine points", true); conf["general"].addList("uniformPoints1",m_scanPar.general.uniformPoints[1],1, tf, "1 if scanStart, scanEnd & nBins determine points", true); conf["general"].addInt("scanStart0", m_scanPar.general.scanStart[0], 0, "Start value for uniform scan", true); conf["general"].addInt("scanStart1", m_scanPar.general.scanStart[1], 0, "Start value for uniform scan", true); conf["general"].addInt("scanEnd0", m_scanPar.general.scanEnd[0], 200, "End value for uniform scan", true); conf["general"].addInt("scanEnd1", m_scanPar.general.scanEnd[1], 0, "End value for uniform scan", true); conf["general"].addInt("nBins0", m_scanPar.general.nBins[0], 201, "# of bins in inner & outer loop", true); conf["general"].addInt("nBins1", m_scanPar.general.nBins[1], 0, "# of bins in inner & outer loop", true); conf["general"].addInt("repetitions", m_scanPar.general.repetitions, 1000, "# of events per bin", true); // conf["general"].addInt("dataPtr0", (unsigned int &)m_scanPar.general.dataPtr[0], 0x0, // "pointers to data for custom scans; (DEFAULT) = at the end of the primitive list", true); // conf["general"].addInt("dataPtr1", (unsigned int &)m_scanPar.general.dataPtr[1], 0x0, // "pointers to data for custom scans; (DEFAULT) = at the end of the primitive list", true); std::map maskmodeMap; maskmodeMap["SCAN_STAGED"] = SCAN_STAGED; maskmodeMap["SCAN_STATIC"] = SCAN_STATIC; conf["general"].addList("maskMode", m_scanPar.general.maskMode, SCAN_STAGED, maskmodeMap, "Staged or static masks", true); conf["general"].addList("stageAdvanceFirst", m_scanPar.general.stageAdvanceFirst, 0, tf, "Innermost loop is the mask stage or bin[0] parameter", true); conf["general"].addInt("maskStages", m_scanPar.general.maskStages, 3, "Number of mask stages to actually execute in scan", true); std::map maskstgmodeMap; maskstgmodeMap["MASK_STAGEMODE_SEL_ENA"] = MASK_STAGEMODE_SEL_ENA; maskstgmodeMap["MASK_STAGEMODE_SEL"] = MASK_STAGEMODE_SEL; maskstgmodeMap["MASK_STAGEMODE_XTALK"] = MASK_STAGEMODE_XTALK; maskstgmodeMap["MASK_STAGEMODE_ENA"] = MASK_STAGEMODE_ENA; maskstgmodeMap["MASK_STAGEMODE_SEL_ENA_PRE"] = MASK_STAGEMODE_SEL_ENA_PRE; maskstgmodeMap["MASK_STAGEMODE_MONLEAK"] = MASK_STAGEMODE_MONLEAK; maskstgmodeMap["MASK_STAGEMODE_SEL_PRE"] = MASK_STAGEMODE_SEL_PRE; maskstgmodeMap["MASK_STAGEMODE_SCALER_N"] = MASK_STAGEMODE_SCALER_N; maskstgmodeMap["MASK_STAGEMODE_SCALER_D"] = MASK_STAGEMODE_SCALER_D; maskstgmodeMap["MASK_STAGEMODE_SCALER_A"] = MASK_STAGEMODE_SCALER_A; conf["general"].addList("maskStageMode", m_scanPar.general.maskStageMode, MASK_STAGEMODE_SEL_ENA, maskstgmodeMap, "Mask staging option i.e. which ctrl bits are staged", true); std::map maskstgpatMap; maskstgpatMap["MASK_SCAN_ALTERNATIVE"] = MASK_SCAN_ALTERNATIVE; maskstgpatMap["MASK_SCAN_32_STEP"] = MASK_SCAN_32_STEP; maskstgpatMap["MASK_SCAN_40_STEP"] = MASK_SCAN_40_STEP; maskstgpatMap["MASK_SCAN_64_STEP"] = MASK_SCAN_64_STEP; maskstgpatMap["MASK_SCAN_80_STEP"] = MASK_SCAN_80_STEP; maskstgpatMap["MASK_SCAN_160_STEP"] = MASK_SCAN_160_STEP; maskstgpatMap["MASK_SCAN_320_STEP"] = MASK_SCAN_320_STEP; maskstgpatMap["MASK_SCAN_2880_STEP"] = MASK_SCAN_2880_STEP; conf["general"].addList("maskStagePattern", m_scanPar.general.maskStagePattern, MASK_SCAN_32_STEP, maskstgpatMap, "Mask stage pattern option", true); // Group histograms conf.addGroup("histograms"); std::map fitprocMap; fitprocMap["NOFIT"] = NOFIT; fitprocMap["DSP"] = DSP; fitprocMap["HOST"] = HOST; std::maphistomodeMap; histomodeMap["NO"] = NO; histomodeMap["KEEP"] = KEEP; histomodeMap["DROP"] = DROP; conf["histograms"].addList("occupancy", m_hOccupancy, KEEP, histomodeMap, "Fill occupancy histograms", true); conf["histograms"].addList("timeProfile", m_hTimeProfile, NO, histomodeMap, "Fill time profile histograms", true); conf["histograms"].addList("tot", m_hTot, NO, histomodeMap, "Fill ToT histograms", true); conf["histograms"].addList("totMean", m_hTotMean, NO, histomodeMap, "Fill ToT mean histograms", true); conf["histograms"].addList("totSigma", m_hTotSigma, NO, histomodeMap, "Fill ToT sigma histograms", true); conf["histograms"].addList("scurves", m_hScurves, DSP, fitprocMap, "Fill Scurve histograms", true); // Group rodSetup conf.addGroup("rodSetup"); // conf["rodSetup"].addInt("base", (unsigned int &)m_scanPar.rodSetup.base, DEFAULT, // "Base of histograms in SDSP memory", false); conf["rodSetup"].addInt("opt0", m_scanPar.rodSetup.opt[0], 1, "Histo options: do occupancy histo", true); conf["rodSetup"].addInt("opt1", m_scanPar.rodSetup.opt[1], 1, "Histo options: do time-slice spectrum", true); conf["rodSetup"].addInt("opt2", m_scanPar.rodSetup.opt[2], 1, "Histo options: bit0=do TOT spectrum bit3=do TOT mean calculation", true); conf["rodSetup"].addInt("extSetup", m_scanPar.rodSetup.extSetup, 2, "Indicates whether MDSP will set up the router & SDSPs or not", false); conf["rodSetup"].addList("errors", m_scanPar.rodSetup.errors, 0, tf, "Toggles histogramming of errors (error task)", false); conf["rodSetup"].addList("errorsMCC", m_scanPar.rodSetup.errorsMCC, 0, tf, "Toggles histogramming of MCC errors (error task)", false); std::map historoutineMap; historoutineMap["HISTO_ROUTINE_C"] = HISTO_ROUTINE_C; historoutineMap["HISTO_ROUTINE_ASM"] = HISTO_ROUTINE_ASM; conf["rodSetup"].addList("histoRoutineType",m_histoRoutineType, HISTO_ROUTINE_C, historoutineMap, "Histogramming routine type", true); conf["rodSetup"].addInt("histoTotResolution",m_histoTotResolution, 8, "Histogram TOT resolution", true); conf["rodSetup"].addInt("histoTotMin",m_histoTotMin, 0, "Histogram TOT min", true); conf["rodSetup"].addInt("histoTotMax",m_histoTotMax, 255, "Histogram TOT max", true); // Group dspDist conf.addGroup("dspDist"); conf["dspDist"].addInt("defineGroups", m_scanPar.dspDist.definedGroups, 1, "Bitfield indicating which groups are included in scan", true); conf["dspDist"].addInt("nDspPairs", m_scanPar.dspDist.nDspPairs, 0, "The # of SDSP pairs", false); conf["dspDist"].addInt("slvBits", m_scanPar.dspDist.slvBits, 1, "Indicates which SDSPs participate in scan", true); conf["dspDist"].addInt("dspPair00", m_scanPar.dspDist.dspPair[0][0], 0, "The DSP pairs", true); conf["dspDist"].addInt("dspPair01", m_scanPar.dspDist.dspPair[0][1], 0, "The DSP pairs", true); conf["dspDist"].addInt("dspPair10", m_scanPar.dspDist.dspPair[1][0], 0, "The DSP pairs", true); conf["dspDist"].addInt("dspPair11", m_scanPar.dspDist.dspPair[1][1], 0, "The DSP pairs", true); conf["dspDist"].addInt("groupSPMap0", m_scanPar.dspDist.groupSPMap[0], 1, "Bitfield indicating which serial port groups use", true); conf["dspDist"].addInt("groupSPMap1", m_scanPar.dspDist.groupSPMap[1], 0, "Bitfield indicating which serial port groups use", true); conf["dspDist"].addInt("groupDSPMap0", m_scanPar.dspDist.groupDSPMap[0], 1, "Bitfields indicating to which SDSP groups send events", true); conf["dspDist"].addInt("groupDSPMap1", m_scanPar.dspDist.groupDSPMap[1], 0, "Bitfields indicating to which SDSP groups send events", true); conf["dspDist"].addInt("groupDSPMap2", m_scanPar.dspDist.groupDSPMap[2], 0, "Bitfields indicating to which SDSP groups send events", true); conf["dspDist"].addInt("groupDSPMap3", m_scanPar.dspDist.groupDSPMap[3], 0, "Bitfields indicating to which SDSP groups send events", true); // Group strobe conf.addGroup("strobe"); conf["strobe"].addInt("duration", m_scanPar.strobe.duration, 500, "Length of strobe in BCO units", true); conf["strobe"].addInt("delay", m_scanPar.strobe.delay, 0, "Strobe delay setting on MCC", true); conf["strobe"].addInt("delayRange", m_scanPar.strobe.delayRange, 5, "Strobe delay range on MCC", true); // Group trigger conf.addGroup("trigger"); conf["trigger"].addInt("accepts", m_scanPar.trigger.accepts, 16, "Number of contiguous triggers in event (1-16)", true); conf["trigger"].addInt("self", m_scanPar.trigger.self, 0, "Selects module self-triggering mode", true); conf["trigger"].addInt("latency", m_scanPar.trigger.latency, 255, "8-bit trigger latency as programmed on FEs", true); conf["trigger"].addInt("calL1ADelay", m_scanPar.trigger.calL1ADelay, 240, "Sets the delay (in BCO units) between CAL and L1A", true); // Group reset conf.addGroup("reset"); conf["reset"].addList("binReset", m_scanPar.reset.binReset, 1, tf, "", true); conf["reset"].addList("softFE", m_scanPar.reset.softFE, 1, tf, "", true); conf["reset"].addList("shortSync", m_scanPar.reset.shortSync, 1, tf, "", true); conf["reset"].addList("mediumSync", m_scanPar.reset.mediumSync, 1, tf, "", true); conf["reset"].addList("longSync", m_scanPar.reset.longSync, 1, tf, "", true); conf["reset"].addList("ECR", m_scanPar.reset.ECR, 1, tf, "", true); conf["reset"].addList("BCR", m_scanPar.reset.BCR, 1, tf, "", true); conf["reset"].addList("moduleInit", m_scanPar.reset.moduleInit, 1, tf, "", true); // Group fe conf.addGroup("fe"); conf["fe"].addInt("vCal", m_scanPar.fe.vCal, 0, "Value for the VCAL DAC", true); std::map cinjectMap; cinjectMap["CINJ_LOW"] = CINJ_LOW; cinjectMap["CINJ_HIGH"] = CINJ_HIGH; conf["fe"].addList("cInject", m_scanPar.fe.cInject, CINJ_LOW, cinjectMap, "Injection capacitor toggle (c-lo/c-high)", true); conf["fe"].addInt("phi", m_scanPar.fe.phi, 2, "Column readout frequency", true); conf["fe"].addInt("totThresholdMode", m_scanPar.fe.totThresholdMode, 0, "Sets TOT threshold mode", true); conf["fe"].addInt("totMinimum", m_scanPar.fe.totMinimum, 0, "TOT minimum", true); conf["fe"].addInt("totTwalk", m_scanPar.fe.totTwalk, 32, "TOT double-hit for digital timewalk correction", true); conf["fe"].addInt("totLeMode", m_scanPar.fe.totLeMode, 0, "TOT or timestamp leading edge option", true); conf["fe"].addInt("hitbus", m_scanPar.fe.hitbus, 0, "", true); conf["fe"].addList("digitalInject", m_scanPar.fe.digitalInject, 0, tf, "Select digital or analog injection", true); // Group mcc conf.addGroup("mcc"); conf["mcc"].addInt("checkRegisters", m_scanPar.mcc.checkRegisters, 0, "Enable periodic checking of MCC warning registers", true); std::map mccbwMap; mccbwMap["MCC_SINGLE_40"] = MCC_SINGLE_40; mccbwMap["MCC_SINGLE_80"] = MCC_SINGLE_80; mccbwMap["MCC_DOUBLE_40"] = MCC_DOUBLE_40; mccbwMap["MCC_DOUBLE_80"] = MCC_DOUBLE_80; conf["mcc"].addList("bandwidth", m_scanPar.mcc.bandwidth, MCC_SINGLE_40, mccbwMap, "MCC output bandwidth", true); conf["mcc"].addList("enableFEContinuityCheck", m_scanPar.mcc.enableFEContinuityCheck, 0, tf, "", true); conf["mcc"].addList("enableFECrosscheck", m_scanPar.mcc.enableFECrosscheck, 0, tf, "", true); // Group fitting conf.addGroup("fitting"); conf["fitting"].addInt("sCurves", m_scanPar.fitting.sCurves, 0, "Fit s-curves to the occupancy histos", true); conf["fitting"].addInt("totCalibration", m_scanPar.fitting.totCalibration, 0, "Fit TOT calibration functions to TOT data", true); conf["fitting"].addInt("tdacTune", m_scanPar.fitting.tdacTune, 0, "Perform TDAC determination based on fit results", true); conf["fitting"].addInt("tdacAlgorithm", m_scanPar.fitting.tdacAlgorithm, 0, "Method for determining TDAC tune", true); conf["fitting"].addInt("fdacTune", m_scanPar.fitting.fdacTune, 0, "Perform FDAC tune based on data from scan", true); conf["fitting"].addInt("calibrationOption", m_scanPar.fitting.calibrationOption, 0, "Standard time, standard charge or custom", true); conf["fitting"].addFloat("chi2Cut", m_scanPar.fitting.chi2Cut, 0.0, "", false); conf["fitting"].addFloat("customScale", m_scanPar.fitting.customScale, 0.0, "", false); conf["fitting"].addFloat("customOffset", m_scanPar.fitting.customOffset, 0.0, "", false); conf["fitting"].addBool("dspFit", m_dspFit, false, "true if the fits are done in the SDSP", true); conf["fitting"].addBool("keepHisto", m_keepHisto, true, "Occupancy/TOT maps are saved", true); // Group modGroups conf.addGroup("modGroups"); conf["modGroups"].addInt("modMask_0", m_groupMask[0], 0xffffffff, "Modules in group 0", true); conf["modGroups"].addBool("strobeEnable_0", m_strobeEnabled[0], true, "Strobe enable group 0", true); conf["modGroups"].addBool("triggerEnable_0", m_triggerEnabled[0], true, "Trigger enable group 0", true); conf["modGroups"].addBool("readoutEnable_0", m_readoutEnabled[0], true, "Readout enable group 0", true); for (unsigned int i=1; i vmodeMap; vmodeMap["DEF_VAL"] = DEF_VAL; vmodeMap["CUSTOM_VAL"] = CUSTOM_VAL; vmodeMap["OFF_VAL"] = OFF_VAL; conf["voltageControl"].addList("biasMode", (int &)m_biasMode, (int)DEF_VAL, vmodeMap, "Bias voltage mode", true); conf["voltageControl"].addFloat("biasValue", m_biasValue, 150.0, "Bias voltage value", true); conf["voltageControl"].addList("avddMode", (int &)m_avddMode, (int)DEF_VAL, vmodeMap, "AVDD voltage mode", true); conf["voltageControl"].addFloat("avddValue", m_avddValue, 1.7, "AVDD voltage value", true); conf["voltageControl"].addList("dvddMode", (int &)m_dvddMode, (int)DEF_VAL, vmodeMap, "DVDD voltage mode", true); conf["voltageControl"].addFloat("dvddValue", m_dvddValue, 2.4, "DVDD voltage value", true); // Select default values conf.reset(); } void PixScanConfig::readConfig(DBInquire *dbi){ // load configuration from the database m_dbInquire = dbi; m_conf->read(m_dbInquire); } void PixScanConfig::writeConfig(DBInquire *dbi){ // save current configuration into the database m_dbInquire = dbi; m_conf->write(m_dbInquire); } ScanControl &PixScanConfig::scanControl() { // Group serial for (int i=0; i vh; m_occup.push_back(vh); m_occup[i].clear(); std::ostringstream mnum; mnum << mod; std::string nam = "Thr_" + mnum.str(); std::string tit = "Threshold mod " + mnum.str(); Histo *h = new Histo(nam, tit, 144, -0.5, 143.5, 320, -0.5, 319.5); m_thr.push_back(h); nam = "Noise_" + mnum.str(); tit = "Noise mod " + mnum.str(); h = new Histo(nam, tit, 144, -0.5, 143.5, 320, -0.5, 319.5); m_noise.push_back(h); nam = "Chi2_" + mnum.str(); tit = "Chi2 mod " + mnum.str(); h = new Histo(nam, tit, 144, -0.5, 143.5, 320, -0.5, 319.5); m_chi2.push_back(h); } } else { if (mod >= m_occup.size()) return; for (i=0; iclear(); m_noise[mod]->clear(); m_chi2[mod]->clear(); } } void PixScanConfig::getHisto(PixController *ctrl, unsigned int mod) { // Clear histograms clearHisto(mod); // Get occupancy histograms if (m_scanPar.rodSetup.opt[0]) { if (mod >= m_occup.size()) return; bool active = false; int dsp = -1; for (unsigned int ndsp=0; ndsp<4; ndsp++) { if (m_groupMask[ndsp] & (0x1<getHisto(PixController::OCCUPANCY, mod, dsp, m_occup); } if (m_hScurves == HOST) { // s-curve fit if (m_occup[mod].size() > 0) { calcThr(ctrl, mod); if (m_hOccupancy == DROP) { for (unsigned int i=0; ifitHistos(); // Get fit results from the controller std::cout << "getting FIT from DSP" << std::endl; ctrl->getFitResults(PixController::SCURVES, mod, dsp, m_thr, m_noise, m_chi2); } } } } void PixScanConfig::calcThr(PixController *ctrl, unsigned int m) { for (int col = 0; col<144; col++) { for (int row = 0; row<320; row++) { bool low = true; bool top = false; bool fl = false; bool fh = false; unsigned int i; double ymax = m_scanPar.general.repetitions; double xmax = m_scanPar.general.nBins[0]; double xl=0,yl=0,xh=xmax,yh=ymax; double step = 1; if (m_scanPar.general.nBins[0]>1) { step = (m_scanPar.general.scanEnd[0]-m_scanPar.general.scanStart[0])/ (m_scanPar.general.nBins[0]-1); } for (i=1; i ymax/2) low = false; if (!fl && his(col,row)>0.18*ymax && hisn(col,row)>0.18*ymax) { fl = true; xl = i; yl = (hisp(col,row)+his(col,row)+hisn(col,row))/3.0; } } else { if (his(col,row)>0.9*ymax && hisn(col,row)>0.9*ymax) top =true; if (!fh && his(col,row)>0.82*ymax && hisn(col,row)>0.82*ymax) { fh = true; xh = i; yh = (hisp(col,row)+his(col,row)+hisn(col,row))/3.0; } } if (top) { int fe; if (row>=160) { fe = 8+(143-col)/18; } else { fe = col/18; } PixModule *mod=ctrl->getModGroup().module(m); if(mod->pixFE(fe)!=0){ ConfFloat &cInj = dynamic_cast(mod->pixFE(fe)->config()["Misc"]["CInjLo"]); ConfFloat &vcalGrad = dynamic_cast(mod->pixFE(fe)->config()["Misc"]["VcalGradient1"]); double a = (yh-yl)/(xh-xl); double b = yl - a*xl; if (a > 0) { double threshold = ((0.5*ymax/a - b/a)*step+m_scanPar.general.scanStart[0])* cInj.value()*vcalGrad.value()/0.160218; double noise = (0.3413*ymax/a)*step*cInj.value()*vcalGrad.value()/0.160218; double chi2 = 0; for (i=(unsigned int)xl; i<(unsigned int)xh+1; i++) { if(ymax!=0){ double ycurr = (*m_occup[m][i])(col,row); double yerr = sqrt(ycurr/ymax*(ymax-ycurr)); if(yerr!=0) { chi2 += pow((ycurr-b-a*(double)i)/yerr,2); } } } m_thr[m]->set(col,row,threshold); m_noise[m]->set(col,row,noise); m_chi2[m]->set(col,row,chi2); //std::cout << col << " " << row << " " << threshold << " " << noise << std::endl; } else { m_thr[m]->set(col,row,0.0); m_noise[m]->set(col,row,0.0); m_chi2[m]->set(col,row,-2.0); } break; } } } } } } void PixScanConfig::writeHisto(DBInquire *dbi){ for (unsigned int m=0; m<32; m++) { bool active = false; for (unsigned int dsp=0; dsp<4; dsp++) { if (m_groupMask[dsp] & (0x1< 0) { DBInquire* modi = dbi->addInquire(modname.str(), modname.str()); DBInquire* occi = modi->addInquire("Occupancy","Occupancy"); for (unsigned int b=0; bgetDB()->makeField(fieldname.str()); occi->getDB()->DBProcess(dbfield,COMMIT,*m_occup[m][b]); occi->pushField(dbfield); } occi->getDB()->DBProcess(occi,COMMITREPLACE); } if (m_scanPar.fitting.sCurves) { DBInquire* modi = dbi->addInquire(modname.str(), modname.str()); DBInquire* scuri = modi->addInquire("S-curve","S-curve"); DBField* dbfield = scuri->getDB()->makeField("threshold"); scuri->getDB()->DBProcess(dbfield,COMMIT,*m_thr[m]); scuri->pushField(dbfield); dbfield = scuri->getDB()->makeField("noise"); scuri->getDB()->DBProcess(dbfield,COMMIT,*m_noise[m]); scuri->pushField(dbfield); dbfield = scuri->getDB()->makeField("chi2"); scuri->getDB()->DBProcess(dbfield,COMMIT,*m_chi2[m]); scuri->pushField(dbfield); scuri->getDB()->DBProcess(scuri,COMMITREPLACE); } } dbi->getDB()->DBProcess(dbi,COMMITREPLACE); } } void PixScanConfig::readHisto(DBInquire* dbi) { recordIterator histo = dbi->findRecord("Histograms/Histograms"); if (histo != dbi->recordEnd()) { recordIterator occup = (*histo)->findRecord("Occupancy/Occupancy"); if (occup != (*histo)->recordEnd()) { } recordIterator scurve = (*histo)->findRecord("S-curve/S-curve"); if (scurve != (*histo)->recordEnd()) { } } } void PixScanConfig::write(DBInquire* dbi){ // write config writeConfig(dbi); // write histograms writeHisto(dbi); } void PixScanConfig::read(DBInquire* dbi){ // read config readConfig(dbi); // read histograms readHisto(dbi); } PixRunConfig::PixRunConfig() { runControlInit(); } PixRunConfig::PixRunConfig(RunType presetName) { m_db = NULL; m_dbInquire = NULL; runControlInit(); } PixRunConfig::PixRunConfig(DBInquire *dbi) : m_dbInquire(dbi) { m_db = m_dbInquire->getDB(); runControlInit(); readDbInquire(); } PixRunConfig::~PixRunConfig() { } void PixRunConfig::preset(RunType presetName) { } void PixRunConfig::enableTrigger(int group) { if (group>=0 && group=0 && group=0 && group=0 && group=0 && group=0 && group=0 && group=0 && groupread(m_dbInquire); } void PixRunConfig::loadConfig(DBInquire *dbi){ // load configuration from the database m_dbInquire = dbi; m_conf->read(m_dbInquire); } void PixRunConfig::saveConfig(DBInquire *dbi){ // save current configuration into the database m_dbInquire = dbi; m_conf->write(m_dbInquire); }