// // // // purpose: Establish connection to online_ccdb, read current values // of the DAC settings for each ADC125 channel of each FDC // Crate (identified by ROC number). It also read for each // channel the sigma of the pedestal and calculates a sparsification // factor based on the sparsification factor. // SPARSIFICATIONVALUE_i = SIGMA_i * SPARSIFICATIONFACTOR // i = ROC/SLOT/CHANNEL // // protection agains runaway DAC values is included. // // online_ccdb tables: XXX = FDC or CDC // /XXX/dac_values row for each channel // /XXX/baseline single row for all channels // // #include #include #include #include #include #include #include using namespace std; using namespace ccdb; extern int Thresholds[20][72]; extern int DAC_Values[20][72]; inline string create_connection_string() { /* creates example connection string to ccdb demo sqlite database*/ string ccdb_home(getenv("CCDB_CONNECTION")); return ccdb_home; } inline int GetDACfromdatabase(int ROC, char *detector){ char DET[128]; if (detector[0] == 'c'){ sprintf(DET,"CDC"); } else { sprintf(DET,"FDC"); } MySQLCalibration *calib = new MySQLCalibration(100); string connection_str = create_connection_string(); if (!connection_str.size()) { cout<<"ERROR: CCDB_CONNECTION not defined!"<Connect(connection_str); if (!result) { cout<<"ERROR: CCDB connection failed!"< > bl; char table[128]; sprintf(table, "/%s/baseline",DET); calib->GetCalib(bl, table); //double targetbaseline = bl[0][0]; //double baselinefactor = bl[0][1]; double sparsificationfactor = bl[0][2]; vector < vector > data; sprintf(table, "/%s/dac_values",DET); calib->GetCalib(data, table); for(unsigned int row = 0; row < data.size(); row++) { int R = (int) data[row][0]; if (R==ROC) { int slot = (int)data[row][1]; int ch = (int)data[row][2]; // -1 if (slot>10){ slot -= 5; } else { slot -= 3; } int DACValue = (int) data[row][4]; DAC_Values[slot][ch] = DACValue; double mean = data[row][5]; double sig = data[row][6]; Thresholds[slot][ch] = (int)(mean + sparsificationfactor*sig + 0.5); if (Thresholds[slot][ch]<60){ Thresholds[slot][ch] = 60; } else if (Thresholds[slot][ch]> 4095) Thresholds[slot][ch] = 4095; } } return 1; }