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


Public Member Functions | |
| AsymMgr (CalCalibShared &ccsShared) | |
| StatusCode | initialize (const string &flavor) |
| const CalibData::CalAsym * | getAsym (const CalUtil::XtalIdx xtalIdx) |
| get Asymmetry calibration information for one xtal | |
| const CalibData::Xpos * | getXpos () |
| get positions in mm from crystal center of each asymmetry data point | |
| StatusCode | evalAsym (const CalUtil::XtalIdx xtalIdx, const CalUtil::AsymType asymType, const float Xpos, float &asym) |
| find light asymmetry value associated with given crystal and longitudinal position | |
| StatusCode | evalPos (const CalUtil::XtalIdx xtalIdx, const CalUtil::AsymType asymType, const float asym, float &Xpos) |
| find crystal longitudinal position (mm from xtal center) associated with given signal asymmetry | |
| StatusCode | getAsymCtr (const CalUtil::XtalIdx xtalIdx, const CalUtil::AsymType asymType, float &asymCtr) |
| get signal asymmetry at crystal center. | |
Private Types | |
| enum | ASYM_DIR { POS2ASYM, ASYM2POS, N_ASYM_DIR } |
| conversion directions between asymmetry & position. More... | |
Private Member Functions | |
| unsigned short | splineIdx (const CalUtil::AsymType asymType, const ASYM_DIR asymDir) |
| calculate spline index for given spline type | |
| StatusCode | genLocalStore () |
| populate all private data fields | |
| StatusCode | loadIdealVals () |
| load ideal calibration constants from local data (avoid calibration database) | |
| bool | validateRangeBase (CalibData::CalAsym const *const asym) |
| validate data ptr from TDS | |
Private Attributes | |
| std::auto_ptr< CalibData::CalAsym > | m_idealAsym |
| store ideal asymmetry splines (same for every xtal) | |
| std::auto_ptr< CalibData::Xpos > | m_idealXpos |
| store position values for ideal asym splines. | |
| CalUtil::CalVec< CalUtil::AsymType, CalUtil::CalVec< CalUtil::XtalIdx, float > > | m_asymCtr |
| store precalcuated asymmetry for deposits @ ctr of xtal. | |
| float | m_csiLength |
| geometry constant | |
Static Private Attributes | |
| const unsigned short | N_SPLINE_TYPES = N_ASYM_DIR*CalUtil::AsymType::N_VALS |
Definition at line 29 of file AsymMgr.h.
|
|
conversion directions between asymmetry & position.
Definition at line 67 of file AsymMgr.h.
00067 {
00068 POS2ASYM,
00069 ASYM2POS,
00070 N_ASYM_DIR
00071 } ASYM_DIR;
|
|
|
initialize asymCtr array Definition at line 24 of file AsymMgr.cxx. References BAD_FLOAT, and m_asymCtr.
00024 : 00025 CalibItemMgr(ICalibPathSvc::Calib_CAL_Asym, 00026 ccsShared, 00027 CalUtil::XtalIdx::N_VALS, 00028 N_SPLINE_TYPES) 00029 { 00031 for (AsymType asymType; asymType.isValid(); asymType++) 00032 fill(m_asymCtr[asymType].begin(), m_asymCtr[asymType].end(), BAD_FLOAT); 00033 } |
|
||||||||||||||||||||
|
find light asymmetry value associated with given crystal and longitudinal position
Definition at line 43 of file AsymMgr.h. References CalibItemMgr::evalSpline(), POS2ASYM, and splineIdx(). Referenced by CalCalibSvc::evalAsym(), and genLocalStore().
00046 {
00047 return evalSpline(splineIdx(asymType, POS2ASYM), xtalIdx, Xpos, asym);
00048 }
|
|
||||||||||||||||||||
|
find crystal longitudinal position (mm from xtal center) associated with given signal asymmetry
Definition at line 51 of file AsymMgr.h. References ASYM2POS, CalibItemMgr::evalSpline(), and splineIdx(). Referenced by CalCalibSvc::evalPos().
00054 {
00055 return evalSpline(splineIdx(asymType, ASYM2POS), xtalIdx, asym, Xpos);
00056 }
|
|
|
populate all private data fields
Implements CalibItemMgr. Definition at line 62 of file AsymMgr.cxx. References ASYM2POS, evalAsym(), extrap(), CalibItemMgr::genSpline(), getAsym(), CalibItemMgr::getRangeBase(), getXpos(), m_asymCtr, m_idealAsym, CalibItemMgr::m_idealMode, CalibItemMgr::m_rngBases, POS2ASYM, splineIdx(), and validateRangeBase().
00062 {
00063 StatusCode sc;
00064
00065 // pointer to asym arrays in calib db
00066 CalVec<AsymType, const vector<ValSig> *> db_asym;
00067 // vector<float> arrays for input into each genSpline
00068 CalVec<AsymType, vector<float> > tmp_asym;
00069 vector<float> tmp_xvals;
00070
00071 // used for description strings
00072 CalVec<AsymType, string> asymSuffix;
00073 asymSuffix[ASYM_LL] = "LL";
00074 asymSuffix[ASYM_LS] = "LS";
00075 asymSuffix[ASYM_SL] = "SL";
00076 asymSuffix[ASYM_SS] = "SS";
00077
00078 for (XtalIdx xtalIdx; xtalIdx.isValid(); xtalIdx++) {
00079 if (!m_idealMode) {
00080 // RETRIEVE & VALIDATE RangeBase object from TDS
00081 CalAsym *asym = (CalAsym*)getRangeBase(xtalIdx.getCalXtalId());
00082 if (!validateRangeBase(asym)) continue;
00083 m_rngBases[xtalIdx] = asym;
00084 } else m_rngBases[xtalIdx] = m_idealAsym.get();
00085
00086 // support missing towers & missing crystals
00087 // keep moving if we're missing a particular calibration
00088 const CalAsym *asym = getAsym(xtalIdx);
00089 if (!asym) continue; //support partial LATs
00090
00091 db_asym[ASYM_LL] = asym->getBig();
00092 db_asym[ASYM_SS] = asym->getSmall();
00093 db_asym[ASYM_LS] = asym->getNSmallPBig();
00094 db_asym[ASYM_SL] = asym->getPSmallNBig();
00095
00096 const Xpos *xpos = getXpos();
00097 if (!xpos) return StatusCode::FAILURE; // shouldn't happen
00098 const vector<float> *xvals = xpos->getVals();
00099 int n = xvals->size();
00100
00102 //-- LINEARLY EXTRAPOLATED END-POINTS --//
00104 //-- LINEAR EXTRAPOLATION x points--//
00105 tmp_xvals.resize (n + 4);
00106 for (int i = 0; i < n; i++)
00107 tmp_xvals[i + 2] = (*xvals)[i];
00108
00109 tmp_xvals[1] = extrap(tmp_xvals[3], tmp_xvals[2]);
00110 tmp_xvals[0] = extrap(tmp_xvals[2], tmp_xvals[1]);
00111 tmp_xvals[n+2] = extrap(tmp_xvals[n], tmp_xvals[n+1]);
00112 tmp_xvals[n+3] = extrap(tmp_xvals[n+1], tmp_xvals[n+2]);
00113
00114 for (AsymType asymType; asymType.isValid(); asymType++) {
00115 // add two points to each end to ensure better
00116 // good spline behavior past the edge of the
00117 // xtal. if you think this isn't such a good
00118 // idea, then think about it for a while
00119 // or ask zach to explain.
00120 // 4 new points total
00121
00122 tmp_asym[asymType].resize(n + 4);
00123
00124 // load original points into middle of new,
00125 // wider vector
00126 for (int i = 0; i < n; i++)
00127 tmp_asym[asymType][i+2] = (*db_asym[asymType])[i].getVal();
00128
00129 // point 1
00130 tmp_asym[asymType][1] = extrap(tmp_asym[asymType][3], tmp_asym[asymType][2]);
00131
00132 // point 0
00133 tmp_asym[asymType][0] = extrap(tmp_asym[asymType][2], tmp_asym[asymType][1]);
00134
00135 // 2nd last point
00136 tmp_asym[asymType][n+2] = extrap(tmp_asym[asymType][n], tmp_asym[asymType][n+1]);
00137
00138 // last point
00139 tmp_asym[asymType][n+3] = extrap(tmp_asym[asymType][n+1], tmp_asym[asymType][n+2]);
00140
00141 // put xtal id string into spline name
00142 ostringstream xtalStr;
00143 xtalStr << '[' << xtalIdx.getCalXtalId() << ']';
00144
00145 string splineName = "asym" + asymSuffix[asymType];
00146 genSpline(splineIdx(asymType, POS2ASYM), xtalIdx, splineName + xtalStr.str(),
00147 tmp_xvals, tmp_asym[asymType]);
00148
00149 splineName = "invAsym" + asymSuffix[asymType];
00150 genSpline(splineIdx(asymType, ASYM2POS), xtalIdx, splineName + xtalStr.str(),
00151 tmp_asym[asymType], tmp_xvals);
00152
00153 //-- ASYM CTR --//
00154 float asymCtr;
00155 sc = evalAsym(xtalIdx, asymType, 0, asymCtr);
00156 if (sc.isFailure()) return sc;
00157 m_asymCtr[asymType][xtalIdx] = asymCtr;
00158 }
00159 }
00160
00161 return StatusCode::SUCCESS;
00162 }
|
|
|
get Asymmetry calibration information for one xtal
Definition at line 36 of file AsymMgr.cxx. References CalibItemMgr::m_rngBases, and CalibItemMgr::updateCalib(). Referenced by genLocalStore(), and CalCalibSvc::getAsym().
00036 {
00037 // make sure we have valid calib data for this event.
00038 StatusCode sc;
00039 sc = updateCalib();
00040 if (sc.isFailure()) return NULL;
00041
00042 return (CalAsym*)m_rngBases[xtalIdx];
00043 }
|
|
||||||||||||||||
|
get signal asymmetry at crystal center. return failure if we don't have data for that channel. Definition at line 274 of file AsymMgr.cxx. References m_asymCtr, CalibItemMgr::m_rngBases, and CalibItemMgr::updateCalib(). Referenced by CalCalibSvc::getAsymCtr().
00274 {
00275 // make sure we have valid calib data for this event.
00276 StatusCode sc;
00277 sc = updateCalib();
00278 if (sc.isFailure()) return sc;
00279
00281 if (m_rngBases[xtalIdx] == 0)
00282 return StatusCode::FAILURE;
00283
00284 asymCtr = m_asymCtr[asymType][xtalIdx];
00285
00286 return StatusCode::SUCCESS;
00287 }
|
|
|
get positions in mm from crystal center of each asymmetry data point
Definition at line 45 of file AsymMgr.cxx. References CalibItemMgr::m_calibBase, CalibItemMgr::m_idealMode, m_idealXpos, and CalibItemMgr::updateCalib(). Referenced by genLocalStore(), CalCalibSvc::getAsymXpos(), and validateRangeBase().
00045 {
00046 // make sure we have valid calib data for this event.
00047 StatusCode sc;
00048 sc = updateCalib();
00049 if (sc.isFailure()) return NULL;
00050
00051 if (m_idealMode) return m_idealXpos.get();
00052 return m_calibBase->getXpos();
00053 }
|
|
|
call chain back to parent class routine as well Definition at line 248 of file AsymMgr.cxx. References CalibItemMgr::initialize(), CalibItemMgr::m_ccsShared, m_csiLength, and CalCalibShared::m_service. Referenced by CalCalibSvc::initialize().
00248 {
00249 StatusCode sc;
00250
00251 // try to find the GlastDevSvc service
00252 IGlastDetSvc* detSvc;
00253 sc = m_ccsShared.m_service->service("GlastDetSvc", detSvc);
00254 if (sc.isFailure() ) {
00255 MsgStream msglog(m_ccsShared.m_service->msgSvc(), m_ccsShared.m_service->name());
00256 msglog << MSG::ERROR << " can't get GlastDetSvc " << endreq;
00257 return sc;
00258 }
00259
00260 double tmp;
00261 sc = detSvc->getNumericConstByName("CsILength", &tmp);
00262 if (sc.isFailure()) {
00263 MsgStream msglog(m_ccsShared.m_service->msgSvc(), m_ccsShared.m_service->name());
00264 msglog << MSG::ERROR << " constant CsILength not defined" << endreq;
00265 return sc;
00266 }
00267 m_csiLength = tmp;
00268
00270 return CalibItemMgr::initialize(flavor);
00271 }
|
|
|
load ideal calibration constants from local data (avoid calibration database)
Implements CalibItemMgr. Definition at line 164 of file AsymMgr.cxx. References IdealCalCalib::asymLrgNeg, IdealCalCalib::asymLrgPos, IdealCalCalib::asymNSPBNeg, IdealCalCalib::asymNSPBPos, IdealCalCalib::asymPSNBNeg, IdealCalCalib::asymPSNBPos, IdealCalCalib::asymSigPct, IdealCalCalib::asymSmNeg, IdealCalCalib::asymSmPos, CalibItemMgr::m_ccsShared, m_csiLength, m_idealAsym, CalCalibShared::m_idealCalib, and m_idealXpos.
00164 {
00165 // linear 'fake' spline needs only 2 points
00166 vector<ValSig> big(2);
00167 vector<ValSig> small(2);
00168 vector<ValSig> nspb(2);
00169 vector<ValSig> psnb(2);
00170
00171 const float error = m_ccsShared.m_idealCalib.asymLrgPos * m_ccsShared.m_idealCalib.asymSigPct;
00172
00173 big[0].m_val = m_ccsShared.m_idealCalib.asymLrgNeg;
00174 big[0].m_sig = error;
00175 big[1].m_val = m_ccsShared.m_idealCalib.asymLrgPos;
00176 big[1].m_sig = error;
00177
00178 small[0].m_val = m_ccsShared.m_idealCalib.asymSmNeg;
00179 small[0].m_sig = error;
00180 small[1].m_val = m_ccsShared.m_idealCalib.asymSmPos;
00181 small[1].m_sig = error;
00182
00183
00184 psnb[0].m_val = m_ccsShared.m_idealCalib.asymPSNBNeg;
00185 psnb[0].m_sig = error;
00186 psnb[1].m_val = m_ccsShared.m_idealCalib.asymPSNBPos;
00187 psnb[1].m_sig = error;
00188
00189 nspb[0].m_val = m_ccsShared.m_idealCalib.asymNSPBNeg;
00190 nspb[0].m_sig = error;
00191 nspb[1].m_val = m_ccsShared.m_idealCalib.asymNSPBPos;
00192 nspb[1].m_sig = error;
00193
00194 m_idealAsym.reset(new CalAsym(&big, &small, &nspb, &psnb));
00195
00196
00197 // 0 is at xtal center
00198 vector<float> xvals(2);
00199
00200 xvals[0] = -1*m_csiLength/2.0;
00201 xvals[1] = m_csiLength/2.0;
00202
00203 m_idealXpos.reset(new Xpos(&xvals));
00204
00205 return StatusCode::SUCCESS;
00206 }
|
|
||||||||||||
|
calculate spline index for given spline type
Definition at line 76 of file AsymMgr.h. References N_ASYM_DIR. Referenced by evalAsym(), evalPos(), and genLocalStore().
00077 {
00078 return asymType.val()*N_ASYM_DIR + asymDir;
00079 }
|
|
|
validate data ptr from TDS
Definition at line 208 of file AsymMgr.cxx. References getXpos(), CalibItemMgr::m_calibPath, CalibItemMgr::m_ccsShared, and CalCalibShared::m_service. Referenced by genLocalStore().
00208 {
00209 if (!asym) return false;
00210
00211 const vector<ValSig> *asym_ll;
00212 const vector<ValSig> *asym_ss;
00213 const vector<ValSig> *asym_ls;
00214 const vector<ValSig> *asym_sl;
00215
00216 if (!(asym_ll = asym->getBig())) {
00217 // no error print out req'd b/c we're supporting LAT configs w/ empty bays
00218 // however, if asym->getBig() is successful & following checks fail
00219 // then we have a problem b/c we have calib data which is only good for
00220 // partial xtal.
00221 return false;
00222 }
00223 if (!(asym_ss = asym->getSmall()) ||
00224 !(asym_ls = asym->getNSmallPBig()) ||
00225 !(asym_sl = asym->getPSmallNBig())) {
00226 // create MsgStream only when needed for performance
00227 MsgStream msglog(m_ccsShared.m_service->msgSvc(), m_ccsShared.m_service->name());
00228 msglog << MSG::ERROR << "can't get calib data for "
00229 << m_calibPath;
00230 msglog << endreq;
00231 return false;
00232 }
00233
00234 // get Xpos vals.
00235 unsigned XposSize= getXpos()->getVals()->size();
00236 if (XposSize != asym_ll->size() ||
00237 XposSize != asym_ss->size() ||
00238 XposSize != asym_ls->size() ||
00239 XposSize != asym_sl->size()) {
00240 // create MsgStream only when needed for performance
00241 MsgStream msglog(m_ccsShared.m_service->msgSvc(), m_ccsShared.m_service->name());
00242 msglog << MSG::ERROR << "Invalid # of vals for " << m_calibPath << endreq;
00243 return false;
00244 }
00245 return true;
00246 }
|
|
|
store precalcuated asymmetry for deposits @ ctr of xtal. measures 'overall' optical asymmetry Definition at line 96 of file AsymMgr.h. Referenced by AsymMgr(), genLocalStore(), and getAsymCtr(). |
|
|
geometry constant
Definition at line 102 of file AsymMgr.h. Referenced by initialize(), and loadIdealVals(). |
|
|
store ideal asymmetry splines (same for every xtal)
Definition at line 89 of file AsymMgr.h. Referenced by genLocalStore(), and loadIdealVals(). |
|
|
store position values for ideal asym splines.
Definition at line 92 of file AsymMgr.h. Referenced by getXpos(), and loadIdealVals(). |
|
|
|
1.3.3