#include <IntNonlinMgr.h>
Inheritance diagram for IntNonlinMgr:


Public Member Functions | |
| IntNonlinMgr (CalCalibShared &ccsShared) | |
| const std::vector< float > * | getInlAdc (const CalUtil::RngIdx rngIdx) |
| get adc points for given cidac2adc curve | |
| const std::vector< float > * | getInlCIDAC (const CalUtil::RngIdx rngIdx) |
| get cidac points for given ciadc2adc curve | |
| StatusCode | evalCIDAC (const CalUtil::RngIdx rngIdx, const float adc, float &cidac) |
| evaluate cidac signal for given cidac2adc curve and adc value | |
| StatusCode | evalADC (const CalUtil::RngIdx rngIdx, const float cidac, float &adc) |
| evaluate adc level for given cidac2adc curve and cidac value | |
Private Types | |
| enum | SPLINE_TYPE { INL_SPLINE, INV_INL_SPLINE, N_SPLINE_TYPES } |
| enumerate spline function types for this calib_type More... | |
Private Member Functions | |
| StatusCode | genLocalStore () |
| generate locally stored spline functions & other data | |
| StatusCode | loadIdealVals () |
| load ideal calibration values (in lieu of measured calibrations) | |
| bool | validateRangeBase (CalibData::IntNonlin const *const intNonlin) |
| check calibration data for signle crystal | |
Private Attributes | |
| CalUtil::CalVec< CalUtil::RngIdx, std::vector< float > > | m_CIDACs |
| Local copy of CIDAC values for each channel in consistent format. | |
| CalUtil::CalArray< CalUtil::RngNum, std::auto_ptr< CalibData::IntNonlin > > | m_idealINL |
| ideal intNonlin calibration data (same for all xtals) | |
Definition at line 30 of file IntNonlinMgr.h.
|
|
enumerate spline function types for this calib_type
Definition at line 52 of file IntNonlinMgr.h.
00052 {
00053 INL_SPLINE,
00054 INV_INL_SPLINE,
00055 N_SPLINE_TYPES
00056 };
|
|
|
Definition at line 19 of file IntNonlinMgr.cxx.
00019 : 00020 CalibItemMgr(ICalibPathSvc::Calib_CAL_IntNonlin, 00021 ccsShared, 00022 CalUtil::RngIdx::N_VALS, 00023 N_SPLINE_TYPES) 00024 { 00025 } |
|
||||||||||||||||
|
evaluate adc level for given cidac2adc curve and cidac value
Definition at line 238 of file IntNonlinMgr.cxx. References CalibItemMgr::evalSpline(), INV_INL_SPLINE, and CalibItemMgr::m_splineYMax. Referenced by CalCalibSvc::evalADC().
00238 {
00239 if (evalSpline(INV_INL_SPLINE, rngIdx, cidac, adc).isFailure())
00240 return StatusCode::FAILURE;
00241
00242 // ceiling check
00243 adc = min(m_splineYMax[INV_INL_SPLINE][rngIdx],adc);
00244
00245 #if 0
00246 cout << "evalADC() cidac " << cidac
00247 << " adc " << adc
00248 << " " << adc/cidac
00249 << endl;
00250 #endif
00251
00252 return StatusCode::SUCCESS;
00253 }
|
|
||||||||||||||||
|
evaluate cidac signal for given cidac2adc curve and adc value
Definition at line 228 of file IntNonlinMgr.cxx. References CalibItemMgr::evalSpline(), INL_SPLINE, and CalibItemMgr::m_splineYMax. Referenced by CalCalibSvc::evalCIDAC().
00228 {
00229 if (evalSpline(INL_SPLINE, rngIdx, adc, cidac).isFailure())
00230 return StatusCode::FAILURE;
00231
00232 // ceiling check
00233 cidac = min(m_splineYMax[INL_SPLINE][rngIdx],cidac);
00234
00235 return StatusCode::SUCCESS;
00236 }
|
|
|
generate locally stored spline functions & other data
Implements CalibItemMgr. Definition at line 63 of file IntNonlinMgr.cxx. References extrap(), CalibItemMgr::genSpline(), CalibItemMgr::getRangeBase(), INL_SPLINE, INV_INL_SPLINE, CalibItemMgr::m_calibBase, CalibItemMgr::m_ccsShared, m_CIDACs, m_idealINL, CalibItemMgr::m_idealMode, CalibItemMgr::m_rngBases, CalCalibShared::m_service, and validateRangeBase().
00063 {
00064 for (RngIdx rngIdx; rngIdx.isValid(); rngIdx++) {
00065 const vector<float> *adc;
00066 const RngNum rng = rngIdx.getRng();
00067
00068 //-- IDEAL MODE --//
00069 if (m_idealMode) {
00070 adc = m_idealINL[rng].get()->getValues();
00071 const vector<float> *cidac = m_idealINL[rng].get()->getSdacs();
00072
00073 m_CIDACs[rngIdx].resize(cidac->size());
00074 copy(cidac->begin(),
00075 cidac->end(),
00076 m_CIDACs[rngIdx].begin());
00077
00078 m_rngBases[rngIdx] = m_idealINL[rng].get();
00079 }
00080
00081 //-- NORMAL (NON-IDEAL) MODE -//
00082 else {
00083 CalibData::IntNonlin const*const intNonlin
00084 = (CalibData::IntNonlin *)getRangeBase(rngIdx.getCalXtalId());
00085 // support partial LAT
00086 if (!intNonlin) continue;
00087 if (!validateRangeBase(intNonlin)) continue;
00088 m_rngBases[rngIdx] = intNonlin;
00089
00090 // quick check that ADC data is present
00091 adc = intNonlin->getValues();
00092 // support partial LAT
00093 if (!adc) continue;
00094
00095 //-- PHASE 1: populate CIDAC values (needed for spline generation )
00096 //-- 1st choice, use per-channel 'sdac' info if present
00097 const vector<float> *cidac = intNonlin->getSdacs();
00098 if (cidac) {
00099 m_CIDACs[rngIdx].resize(cidac->size());
00100 copy(cidac->begin(),
00101 cidac->end(),
00102 m_CIDACs[rngIdx].begin());
00103 }
00104
00105 //-- 2nd choise, fall back to global 'DacCol' info
00106 else {
00107 //get collection of associated DAC vals
00108 CalibData::DacCol const*const intNonlinDacCol =
00109 m_calibBase->getDacCol((CalXtalId::AdcRange)rng);
00110
00111 const vector<unsigned> *globalCIDACs;
00112 globalCIDACs = intNonlinDacCol->getDacs();
00113
00114 // if we've gotten this far, then we need
00115 // the data to be present. can't have ADC
00116 // values for a channel w/ no matchin DAC
00117 // info
00118 if (!globalCIDACs) {
00119 // create MsgStream only when needed (for performance)
00120 MsgStream msglog(m_ccsShared.m_service->msgSvc(), m_ccsShared.m_service->name());
00121 msglog << MSG::ERROR << "ADC data w/ no matching CIDAC data (either per-channel or global) ADC channel: "
00122 << rngIdx.val()
00123 << endreq;
00124 return StatusCode::FAILURE;
00125 }
00126
00127 m_CIDACs[rngIdx].resize(globalCIDACs->size());
00128 copy(globalCIDACs->begin(),
00129 globalCIDACs->end(),
00130 m_CIDACs[rngIdx].begin());
00131 }
00132 }
00133
00134 //-- check that we have enough points
00135 const vector<float> &cidac = m_CIDACs[rngIdx];
00136 if (cidac.size() < adc->size()) {
00137 MsgStream msglog(m_ccsShared.m_service->msgSvc(), m_ccsShared.m_service->name());
00138 msglog << MSG::ERROR << "Not enough CIDAC points for ADC channel: " << rngIdx.val()
00139 << endreq;
00140 return StatusCode::FAILURE;
00141 }
00142
00143 //-- PHASE 2: generate splines
00144 vector<float> sp_cidac;
00145 vector<float> sp_adc;
00146
00147 int n = min(adc->size(),cidac.size());
00148
00149 // we need extra point for low end extrapolation
00150 sp_cidac.resize(n+1);
00151 sp_adc.resize(n+1);
00152
00153 // create float vector for input to genSpline()
00154 // leave point at beginning of vector for low end extrapolation
00155 copy(adc->begin(), adc->begin() + n, sp_adc.begin()+1);
00156 copy(cidac.begin(), cidac.begin() + n, sp_cidac.begin()+1);
00157
00158 // EXTRAPOLATE
00159 sp_cidac[0] = -200;
00160 sp_adc[0] = extrap(sp_cidac[2], sp_cidac[1], sp_cidac[0],
00161 sp_adc[2], sp_adc[1]);
00162
00163 // put rng id string into spline name
00164 ostringstream rngStr;
00165 rngStr << '[' << rngIdx.getCalXtalId()
00166 << ']';
00167
00168 genSpline(INL_SPLINE, rngIdx, "INL" + rngStr.str(),
00169 sp_adc, sp_cidac);
00170 genSpline(INV_INL_SPLINE, rngIdx, "invINL" + rngStr.str(),
00171 sp_cidac, sp_adc);
00172 }
00173
00174 return StatusCode::SUCCESS;
00175 }
|
|
|
get adc points for given cidac2adc curve
Definition at line 27 of file IntNonlinMgr.cxx. References CalibItemMgr::m_rngBases, and CalibItemMgr::updateCalib(). Referenced by CalCalibSvc::getInlAdc().
00027 {
00028 // make sure we have valid calib data for this event.
00029 StatusCode sc;
00030 sc = updateCalib();
00031 if (sc.isFailure()) return NULL;
00032
00033 CalibData::IntNonlin const*const inl = (CalibData::IntNonlin*)m_rngBases[rngIdx];
00034
00035 if (!inl) return NULL;
00036
00037 return inl->getValues();
00038
00039 }
|
|
|
get cidac points for given ciadc2adc curve
Definition at line 41 of file IntNonlinMgr.cxx. References m_CIDACs, and CalibItemMgr::updateCalib(). Referenced by CalCalibSvc::getInlCIDAC().
00041 {
00042 // make sure we have valid calib data for this event.
00043 StatusCode sc;
00044 sc = updateCalib();
00045 if (sc.isFailure()) return NULL;
00046
00047 // return 0 if array is empty
00048 if (m_CIDACs[rngIdx].size() == 0)
00049 return NULL;
00050
00051 return &(m_CIDACs[rngIdx]);
00052 }
|
|
|
load ideal calibration values (in lieu of measured calibrations)
Implements CalibItemMgr. Definition at line 177 of file IntNonlinMgr.cxx. References IdealCalCalib::ciULD, IdealCalCalib::inlADCPerCIDAC, CalibItemMgr::m_ccsShared, CalCalibShared::m_idealCalib, m_idealINL, CalCalibShared::m_service, and IdealCalCalib::pedVals.
00177 {
00178 const unsigned short maxADC = 4095;
00179
00180 //-- SANITY CHECKS --//
00181 if (m_ccsShared.m_idealCalib.inlADCPerCIDAC.size() != RngNum::N_VALS) {
00182 // create MsgStream only when needed (for performance)
00183 MsgStream msglog(m_ccsShared.m_service->msgSvc(), m_ccsShared.m_service->name());
00184 msglog << MSG::ERROR << "Bad # of ADCPerCIDAC vals in ideal CalCalib xml file"
00185 << endreq;
00186 return StatusCode::FAILURE;
00187 }
00188
00189 // ideal mode just uses straigt line so we only
00190 // need 2 points per spline
00191 vector<float> idealADCs(2);
00192 vector<float> idealCIDACs(2);
00193 for (RngNum rng; rng.isValid(); rng++) {
00194 // inl spline is pedestal subtracted.
00195 const float pedestal = m_ccsShared.m_idealCalib.pedVals[rng.val()];
00196 float maxADCPed = maxADC - pedestal;
00197
00198 // optionally clip MAX ADC in HEX1 range to ULD value supplied by tholdci
00199 if (rng == HEX1)
00200 maxADCPed = min<float>(maxADCPed, m_ccsShared.m_idealCalib.ciULD[HEX1.val()]);
00201
00202 idealADCs[0] = 0;
00203 idealADCs[1] = maxADCPed;
00204
00205 idealCIDACs[0] = 0;
00206 idealCIDACs[1] =
00207 maxADCPed / m_ccsShared.m_idealCalib.inlADCPerCIDAC[rng.val()];
00208
00209 m_idealINL[rng].reset(new CalibData::IntNonlin(&idealADCs, 0, &idealCIDACs));
00210 }
00211
00212 return StatusCode::SUCCESS;
00213 }
|
|
|
check calibration data for signle crystal
Definition at line 216 of file IntNonlinMgr.cxx. Referenced by genLocalStore().
00216 {
00217 if (!intNonlin) return false;
00218
00219 //get vector of vals
00220 const vector<float> *intNonlinVec = intNonlin->getValues();
00221 if (!intNonlinVec)
00222 return false;
00223
00224 return true;
00225 }
|
|
|
Local copy of CIDAC values for each channel in consistent format. TDS data can either store CIDAC values as integers or floats, either per channel or global, depending on the version of the calibration file.... This allows me to keep a homogenous array of all floats, one set for every channel, regardless of the original data format. Definition at line 68 of file IntNonlinMgr.h. Referenced by genLocalStore(), and getInlCIDAC(). |
|
|
ideal intNonlin calibration data (same for all xtals)
Definition at line 71 of file IntNonlinMgr.h. Referenced by genLocalStore(), and loadIdealVals(). |
1.3.3