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

|
|
Definition at line 62 of file PEGainCalScheme.h. |
|
|
Definition at line 60 of file PEGainCalScheme.h. |
|
|
Definition at line 61 of file PEGainCalScheme.h. |
|
|
Configure defaults. Definition at line 19 of file PEGainCalScheme.cxx. References Registry::Set(). 00019 : 00020 fDefaultRowQIE(0), 00021 fDefaultRowVA(0) 00022 { 00026 Registry r; 00027 r.Set("GuessOtherSpots",1); 00028 r.Set("GuessOtherPixels",1); 00029 r.Set("DefaultGainVA",60.); 00030 r.Set("DefaultGainQIE",100.); 00031 r.Set("DefaultWidthVA",30.); 00032 r.Set("DefaultWidthQIE",50.); 00033 r.Set("TuneGainFactor",1.0); 00034 r.Set("UseCache",1); 00035 InitializeConfig(r); 00036 00037 fLastKey= new DbiResultKey(fResPtr.GetKey()); 00038 }
|
|
|
Definition at line 40 of file PEGainCalScheme.cxx. References fDefaultRowQIE, fDefaultRowVA, and ResetCache(). 00041 {
00042 ResetCache();
00043 if(fDefaultRowQIE) delete fDefaultRowQIE; fDefaultRowQIE = 0;
00044 if(fDefaultRowVA ) delete fDefaultRowVA; fDefaultRowVA= 0;
00045 }
|
|
||||||||||||
|
|
|
|
Reimplemented from CalScheme. Definition at line 90 of file PEGainCalScheme.cxx. References fDefaultGainQIE, fDefaultGainVA, fDefaultRowQIE, fDefaultRowVA, fDefaultWidthQIE, fDefaultWidthVA, fGuessOtherPixels, fGuessOtherSpots, fTuneGainFactor, fUseCache, Registry::Get(), CfgPromptConfigurable::GetConfig(), and MSG. 00091 {
00092 MSG("Calib",Msg::kWarning) << "PEGainCalScheme is now unsupported; please update your scripts!" << endl;
00093
00094 bool ok = true;
00095 ok = ok && GetConfig().Get("GuessOtherSpots",fGuessOtherSpots);
00096 ok = ok && GetConfig().Get("GuessOtherPixels",fGuessOtherPixels);
00097 ok = ok && GetConfig().Get("DefaultGainVA",fDefaultGainVA);
00098 ok = ok && GetConfig().Get("DefaultGainQIE",fDefaultGainQIE);
00099 ok = ok && GetConfig().Get("DefaultWidthVA",fDefaultWidthVA);
00100 ok = ok && GetConfig().Get("DefaultWidthQIE",fDefaultWidthQIE);
00101 ok = ok && GetConfig().Get("TuneGainFactor",fTuneGainFactor);
00102 ok = ok && GetConfig().Get("UseCache",fUseCache);
00103 if(!ok) MSG("Calib",Msg::kWarning) << "PEGainCalScheme couldn't configure properly!" << endl;
00104
00105 if(fDefaultRowQIE) delete fDefaultRowQIE; fDefaultRowQIE = 0;
00106 if(fDefaultRowVA ) delete fDefaultRowVA; fDefaultRowVA= 0;
00107
00108 // 50% error on gains:
00109 fDefaultRowQIE = new CalADCtoPE(0,0,fDefaultGainQIE,fDefaultGainQIE*0.5, fDefaultWidthQIE);
00110 fDefaultRowVA = new CalADCtoPE(0,0,fDefaultGainVA ,fDefaultGainVA*0.5, fDefaultWidthVA );
00111
00112 if(fTuneGainFactor!=1.0)
00113 MSG("Calib",Msg::kWarning) << "-- WARNING -- TuneGainFactor is set to " << fTuneGainFactor
00114 << " This is for calibration study only and should not be used for analysis!"
00115 << std::endl;
00116
00117 }
|
|
||||||||||||||||
|
Inverse-calibration for use by Monte-Carlo Purpose: Get PMT gain and width of single PE response Input: Pixel spot id. Output: Gain and and width of 1-pe response in ADCs Reimplemented from CalScheme. Definition at line 181 of file PEGainCalScheme.cxx. References FloatErr, CalADCtoPE::GetGain(), CalADCtoPE::GetGainErr(), GetRow(), CalADCtoPE::GetSPEWidth(), and ValueErr< T >::Set(). 00183 {
00193
00194 const CalADCtoPE* row = GetRow(psid);
00195
00196 gain.Set(row->GetGain() * fTuneGainFactor,
00197 row->GetGainErr());
00198 width = row->GetSPEWidth() * fTuneGainFactor;
00199 // Protect against bad values:
00200 if(width<=0) width = gain*(float)0.5;
00201 }
|
|
||||||||||||||||
|
Inverse-calibration for use by Monte-Carlo Purpose: Get PMT gain and width of single PE response Input: Strip end Output: Gain and and width of 1-pe response in ADCs Reimplemented from CalScheme. Definition at line 156 of file PEGainCalScheme.cxx. References FloatErr, CalADCtoPE::GetGain(), CalADCtoPE::GetGainErr(), GetRow(), CalADCtoPE::GetSPEWidth(), and ValueErr< T >::Set(). 00158 {
00168
00169
00170 const CalADCtoPE* row = GetRow(seid);
00171
00172 gain.Set(row->GetGain() * fTuneGainFactor,
00173 row->GetGainErr());
00174 width = row->GetSPEWidth() * fTuneGainFactor;
00175 // Protect against bad values:
00176 if(width<=0) width = gain*(float)0.5;
00177 }
|
|
|
Reimplemented from CalScheme. Definition at line 61 of file PEGainCalScheme.cxx. References VldContext::AsString(), fLastKey, fResPtr, DbiResultPtr< T >::GetKey(), DbiResultPtr< T >::GetNumRows(), CalScheme::IncrementErrors(), DbiResultKey::IsEqualTo(), MAXMSG, DbiResultPtr< T >::NewQuery(), and ResetCache(). 00062 {
00063 fResPtr.NewQuery(context,0);
00064 if(fResPtr.GetNumRows()==0) {
00065 MAXMSG("Calib",Msg::kWarning,10)
00066 << "PEGainCalScheme: No rows in database table with validity context "
00067 << context.AsString() << " No calibration will be applied." << endl;
00068 IncrementErrors(kPeCalibrator,kMissingTable);
00069 }
00070
00071
00072 if(fUseCache) {
00073 const DbiResultKey* newKey = fResPtr.GetKey();
00074
00075 if(fLastKey!=0)
00076 if(!(fLastKey->IsEqualTo(newKey) ) ) ResetCache();
00077
00078 if(fLastKey) delete fLastKey;
00079 fLastKey = new DbiResultKey(newKey);
00080 } else {
00081 // Not using cache.
00082 ResetCache(); // Do it every time.
00083 }
00084
00085
00086
00087 }
|
|
||||||||||||
|
Purpose: Apply PE calibration In: raw adc strip end Out: number of pes. Reimplemented from CalScheme. Definition at line 137 of file PEGainCalScheme.cxx. References FloatErr, CalADCtoPE::GetGain(), CalADCtoPE::GetGainErr(), and GetRow(). 00139 {
00148
00149 const CalADCtoPE* row = GetRow(seid);
00150
00151 return rawcharge / FloatErr(row->GetGain() * fTuneGainFactor,
00152 row->GetGainErr() );
00153 }
|
|
|
Definition at line 383 of file PEGainCalScheme.cxx. References PlexStripEndId::AsString(), PlexStripEndId::BuildPlnStripEndKey(), fResPtr, fSpotCache, fStripCache, CalScheme::GetContext(), VldContext::GetDetector(), DbiResultPtr< T >::GetNumRows(), DbiResultPtr< T >::GetRowByIndex(), PlexHandle::GetStripEndId(), GuessGainAndWidth(), CalScheme::IncrementErrors(), PlexPixelSpotId::IsValid(), MAXMSG, and RowIsGood(). 00384 {
00385 //
00386 // Look for the info in the cache, look for the gain in the DB,
00387 // or attempt to reconstruct the gain from the DB if it's not there.
00388 //
00389 if(! psid.IsValid()) {
00390 //MAXMSG("Calib",Msg::kWarning,10)
00391 // << "PEGainCalScheme: Requested pixelspot " << psid.AsString() << " is invalid. \n";
00392 IncrementErrors(kPeCalibrator,kBadInput,psid);
00393 if(GetContext().GetDetector()==Detector::kNear) return fDefaultRowQIE;
00394 else return fDefaultRowVA;
00395 }
00396
00397 if(fUseCache) {
00398
00399 SpotCache_t::iterator it = fSpotCache.find(psid);
00400 if(it != fSpotCache.end()) return it->second;
00401
00402 // Look up the data. Cache it if it's good and return.
00403 PlexHandle plex(GetContext());
00404 PlexStripEndId seid = plex.GetStripEndId(psid);
00405
00406 const CalADCtoPE* row = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00407 if(RowIsGood(row)) {
00408 fSpotCache[psid] = row;
00409 fStripCache[seid] = row;
00410 return row;
00411 };
00412
00413 // The DB data isn't good.
00414 if(fResPtr.GetNumRows()>0) {
00415 MAXMSG("Calib",Msg::kWarning,10)
00416 << "PEGainCalScheme: No database row for StripEnd " << seid.AsString() << "\n";
00417 IncrementErrors(kPeCalibrator,kMissingRow,seid);
00418 }
00419
00420 const CalADCtoPE* newrow = GuessGainAndWidth(psid);
00421 fStripCache[seid] = newrow;
00422 fSpotCache[psid] = newrow;
00423
00424 return newrow;
00425 } else {
00426 // Look up the data. Cache it if it's good and return.
00427 PlexHandle plex(GetContext());
00428 PlexStripEndId seid = plex.GetStripEndId(psid);
00429
00430 const CalADCtoPE* row = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00431 if(RowIsGood(row)) return row;
00432
00433 // The DB data isn't good.
00434 if(fResPtr.GetNumRows()>0) {
00435 MAXMSG("Calib",Msg::kWarning,10)
00436 << "PEGainCalScheme: No database row for StripEnd " << seid.AsString() << "\n";
00437 IncrementErrors(kPeCalibrator,kMissingRow,seid);
00438 }
00439
00440 const CalADCtoPE* guess = GuessGainAndWidth(psid);
00441 return guess;
00442 }
00443
00444 return NULL;
00445 }
|
|
|
Definition at line 311 of file PEGainCalScheme.cxx. References PlexStripEndId::AsString(), PlexStripEndId::BuildPlnStripEndKey(), fResPtr, fSpotCache, fStripCache, CalScheme::GetContext(), VldContext::GetDetector(), DbiResultPtr< T >::GetNumRows(), PlexHandle::GetPixelSpotId(), DbiResultPtr< T >::GetRowByIndex(), GuessGainAndWidth(), CalScheme::IncrementErrors(), PlexStripEndId::IsValid(), MAXMSG, and RowIsGood(). Referenced by DecalGainAndWidth(), and GetPhotoElectrons(). 00312 {
00313 //
00314 // Look for the info in the cache, look for the gain in the DB,
00315 // or attempt to reconstruct the gain from the DB if it's not there.
00316 //
00317
00318 if(!seid.IsValid()) {
00319 MAXMSG("Calib",Msg::kWarning,10)
00320 << "PEGainCalScheme: Requested stripend " << seid.AsString() << " is invalid. \n";
00321 IncrementErrors(kPeCalibrator,kBadInput,seid);
00322 if(GetContext().GetDetector()==Detector::kNear) return fDefaultRowQIE;
00323 else return fDefaultRowVA;
00324 }
00325
00326 if(fUseCache) {
00327 StripCache_t::iterator it = fStripCache.find(seid);
00328 if(it != fStripCache.end()) return it->second;
00329
00330 // Look up the data. Cache it if it's good and return.
00331 PlexHandle plex(GetContext());
00332 PlexPixelSpotId psid = plex.GetPixelSpotId(seid);
00333
00334 const CalADCtoPE* row = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00335 if(RowIsGood(row)) {
00336 fStripCache[seid] = row;
00337 fSpotCache[psid] = row;
00338 return row;
00339 };
00340
00341 // The DB data isn't good.
00342 if(fResPtr.GetNumRows()>0) {
00343 MAXMSG("Calib",Msg::kWarning,10)
00344 << "PEGainCalScheme: No database row for StripEnd " << seid.AsString() << "\n";
00345 IncrementErrors(kPeCalibrator,kMissingRow,seid);
00346 }
00347
00348
00349 // Fallback: make a guess.
00350 const CalADCtoPE* newrow = GuessGainAndWidth(psid);
00351 fStripCache[seid] = newrow;
00352 fSpotCache[psid] = newrow;
00353
00354 return newrow;
00355
00356 } else {
00357 // NOT using the cache
00358
00359 // Look up the data. Cache it if it's good and return.
00360 PlexHandle plex(GetContext());
00361 PlexPixelSpotId psid = plex.GetPixelSpotId(seid);
00362
00363 const CalADCtoPE* row = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00364 if(RowIsGood(row)) {
00365 return row;
00366 }
00367 // The DB data isn't good.
00368 if(fResPtr.GetNumRows()>0) {
00369 MAXMSG("Calib",Msg::kWarning,10)
00370 << "PEGainCalScheme: No database row for StripEnd " << seid.AsString() << "\n";
00371 IncrementErrors(kPeCalibrator,kMissingRow,seid);
00372 }
00373
00374 // Fallback: make a guess.
00375 const CalADCtoPE* guess = GuessGainAndWidth(psid);
00376 return guess;
00377
00378 }
00379
00380 return NULL;
00381 }
|
|
|
Returns a guess as to the correct gain and width for the psid, assuming the data for the psid is not nonexistant or not good. Uses neihboring spots if they exist and are good, or try neighboring pixels, or try returning the defaults. Definition at line 214 of file PEGainCalScheme.cxx. References PlexStripEndId::BuildPlnStripEndKey(), fCacheStorage, fResPtr, CalScheme::GetContext(), VldContext::GetDetector(), PlexMuxBoxId::GetElecType(), CalADCtoPE::GetGain(), PlexPixelSpotId::GetPixel(), DbiResultPtr< T >::GetRowByIndex(), CalADCtoPE::GetSPEWidth(), PlexHandle::GetStripEndId(), CalScheme::IncrementErrors(), PlexStripEndId::IsValid(), PlexPixelSpotId::IsValid(), MAXMSG, MSG, PlexPixelSpotId::SetPixel(), and PlexPixelSpotId::SetSpot(). Referenced by GetRow(). 00215 {
00222
00223 CalADCtoPE* output = fDefaultRowVA;
00224
00225 if(!psid.IsValid()) {
00226 MAXMSG("Calib",Msg::kWarning,20) << "Attempted to find gain on invalid pixel. Return VA defaults." << endl;
00227 return output;
00228 if(GetContext().GetDetector()==Detector::kNear) return fDefaultRowQIE;
00229 else return fDefaultRowVA;
00230 }
00231
00232 if(fGuessOtherSpots) {
00233 // Find the average gain from other spots on this pixel.
00234
00235 double gaintot=0;
00236 double widthtot=0;
00237 double pixtot=0;
00238
00239 PlexHandle plex(GetContext());
00240 for(int spot=0;spot<65;spot++) {
00241 PlexPixelSpotId trialspot = psid;
00242 trialspot.SetSpot(spot);
00243 PlexStripEndId seid = plex.GetStripEndId(psid);
00244 if(seid.IsValid()) {
00245 const CalADCtoPE* row = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00246 if(row) {
00247 pixtot+=1;
00248 gaintot+=row->GetGain();
00249 widthtot+=row->GetSPEWidth();
00250 }
00251 }
00252 }
00253 if(pixtot>0) {
00254 double gain = gaintot/pixtot;
00255 double width= widthtot/pixtot;
00256 output = new CalADCtoPE(0,0, gain, gain*0.1, width); // Assume 10% error on gain.
00257 fCacheStorage.push_back(output);
00258 return output;
00259 }
00260
00261 }
00262
00263 if(fGuessOtherPixels) {
00264 // Find the average gain of the next and previous pixel numbers.
00265
00266 double gaintot=0;
00267 double widthtot=0;
00268 double pixtot=0;
00269 PlexHandle plex(GetContext());
00270
00271 for(int pixel=psid.GetPixel()-1; pixel<psid.GetPixel()+1; pixel+=2) {
00272 PlexPixelSpotId trialspot = psid;
00273 trialspot.SetPixel(pixel);
00274 PlexStripEndId seid = plex.GetStripEndId(psid);
00275 if(seid.IsValid()) {
00276 const CalADCtoPE* row = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00277 if(row) {
00278 pixtot+=1;
00279 gaintot+=row->GetGain();
00280 widthtot+=row->GetSPEWidth();
00281 }
00282 }
00283 }
00284 if(pixtot>0) {
00285 double gain = gaintot/pixtot;
00286 double width= widthtot/pixtot;
00287 output = new CalADCtoPE(0,0, gain, gain*0.2, width); // Assume 20% error on gain.
00288 fCacheStorage.push_back(output);
00289 return output;
00290 }
00291
00292 }
00293
00294
00295 // Ok, that didn't work. Try returning the defaults.
00296 if(psid.GetElecType()==ElecType::kQIE) {
00297 return fDefaultRowQIE;
00298 }
00299 if(psid.GetElecType()==ElecType::kVA) {
00300 return fDefaultRowVA;
00301 }
00302
00303 IncrementErrors(kPeCalibrator,kGeneralErr);
00304 MSG("Calib",Msg::kError) << "Unknown electronics type on pixel " << psid << endl;
00305
00306 if(GetContext().GetDetector()==Detector::kNear) return fDefaultRowQIE;
00307 return fDefaultRowVA;
00308 }
|
|
|
Prints out the current configuration status Should be overridden by implimentation. Reimplemented from CalScheme. Definition at line 120 of file PEGainCalScheme.cxx. References fDefaultGainQIE, fDefaultGainVA, fDefaultWidthQIE, and fDefaultWidthVA. 00121 {
00122 if(fGuessOtherSpots)
00123 os << " Will attempt to guess unknown gains from neighboring spots." << endl;
00124 if(fGuessOtherPixels)
00125 os << " Will attempt to guess unknown gains from neighboring pixels." << endl;
00126
00127 os << " Default Gain (VA) = " << fDefaultGainVA << " ADCs " << endl;
00128 os << " Default Gain (QIE) = " << fDefaultGainQIE << " ADCs " << endl;
00129 os << " Default Width (VA) = " << fDefaultWidthVA << " ADCs " << endl;
00130 os << " Default Width (QIE) = " << fDefaultWidthQIE << " ADCs " << endl;
00131 }
|
|
|
Definition at line 48 of file PEGainCalScheme.cxx. References fCacheStorage, fSpotCache, and fStripCache. Referenced by DoReset(), and ~PEGainCalScheme(). 00049 {
00050 // Deletes and wipes any cached info.
00051 fSpotCache.clear();
00052 fStripCache.clear();
00053 for(UInt_t i=0;i<fCacheStorage.size();i++) {
00054 delete fCacheStorage[i];
00055 }
00056 fCacheStorage.clear();
00057
00058 }
|
|
|
Definition at line 204 of file PEGainCalScheme.cxx. References CalADCtoPE::GetGain(). Referenced by GetRow(). 00205 {
00206 if(!row) return false;
00207 if(row->GetGain() <= 0.0) return false;
00208 return true;
00209 }
|
|
|
Definition at line 65 of file PEGainCalScheme.h. Referenced by GuessGainAndWidth(), and ResetCache(). |
|
|
Definition at line 41 of file PEGainCalScheme.h. Referenced by ConfigModified(), and PrintConfig(). |
|
|
Definition at line 40 of file PEGainCalScheme.h. Referenced by ConfigModified(), and PrintConfig(). |
|
|
Definition at line 47 of file PEGainCalScheme.h. Referenced by ConfigModified(), and ~PEGainCalScheme(). |
|
|
Definition at line 48 of file PEGainCalScheme.h. Referenced by ConfigModified(), and ~PEGainCalScheme(). |
|
|
Definition at line 43 of file PEGainCalScheme.h. Referenced by ConfigModified(), and PrintConfig(). |
|
|
Definition at line 42 of file PEGainCalScheme.h. Referenced by ConfigModified(), and PrintConfig(). |
|
|
Definition at line 39 of file PEGainCalScheme.h. Referenced by ConfigModified(). |
|
|
Definition at line 38 of file PEGainCalScheme.h. Referenced by ConfigModified(). |
|
|
Definition at line 36 of file PEGainCalScheme.h. Referenced by DoReset(). |
|
|
Definition at line 35 of file PEGainCalScheme.h. Referenced by DoReset(), GetRow(), and GuessGainAndWidth(). |
|
|
Definition at line 63 of file PEGainCalScheme.h. Referenced by GetRow(), and ResetCache(). |
|
|
Definition at line 64 of file PEGainCalScheme.h. Referenced by GetRow(), and ResetCache(). |
|
|
Definition at line 44 of file PEGainCalScheme.h. Referenced by ConfigModified(). |
|
|
Definition at line 45 of file PEGainCalScheme.h. Referenced by ConfigModified(). |
1.3.9.1