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

|
|
Definition at line 64 of file PEGainAggCalScheme.h. |
|
|
Definition at line 62 of file PEGainAggCalScheme.h. |
|
|
Definition at line 63 of file PEGainAggCalScheme.h. |
|
|
Configure defaults. Definition at line 19 of file PEGainAggCalScheme.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 r.Set("UseLinearized",1); 00036 InitializeConfig(r); 00037 00038 fLastKey= new DbiResultKey(fResPtr.GetKey()); 00039 }
|
|
|
Definition at line 41 of file PEGainAggCalScheme.cxx. References fDefaultRowQIE, fDefaultRowVA, and ResetCache(). 00042 {
00043 ResetCache();
00044 if(fDefaultRowQIE) delete fDefaultRowQIE; fDefaultRowQIE = 0;
00045 if(fDefaultRowVA ) delete fDefaultRowVA; fDefaultRowVA= 0;
00046 }
|
|
||||||||||||
|
|
|
|
Reimplemented from CalScheme. Definition at line 94 of file PEGainAggCalScheme.cxx. References fDefaultGainQIE, fDefaultGainVA, fDefaultRowQIE, fDefaultRowVA, fDefaultWidthQIE, fDefaultWidthVA, fGuessOtherPixels, fGuessOtherSpots, fTuneGainFactor, fUseCache, fUseLinearized, Registry::Get(), CfgPromptConfigurable::GetConfig(), and MSG. 00095 {
00096 bool ok = true;
00097 ok = ok && GetConfig().Get("GuessOtherSpots",fGuessOtherSpots);
00098 ok = ok && GetConfig().Get("GuessOtherPixels",fGuessOtherPixels);
00099 ok = ok && GetConfig().Get("DefaultGainVA",fDefaultGainVA);
00100 ok = ok && GetConfig().Get("DefaultGainQIE",fDefaultGainQIE);
00101 ok = ok && GetConfig().Get("DefaultWidthVA",fDefaultWidthVA);
00102 ok = ok && GetConfig().Get("DefaultWidthQIE",fDefaultWidthQIE);
00103 ok = ok && GetConfig().Get("TuneGainFactor",fTuneGainFactor);
00104 ok = ok && GetConfig().Get("UseCache",fUseCache);
00105 ok = ok && GetConfig().Get("UseLinearized",fUseLinearized);
00106
00107 if(!ok) MSG("Calib",Msg::kWarning) << "PEGainAggCalScheme couldn't configure properly!" << endl;
00108
00109 if(fDefaultRowQIE) delete fDefaultRowQIE; fDefaultRowQIE = 0;
00110 if(fDefaultRowVA ) delete fDefaultRowVA; fDefaultRowVA= 0;
00111
00112 // 50% error on gains:
00113 fDefaultRowQIE = new CalADCtoPEs(0,0,fDefaultGainQIE,fDefaultGainQIE*0.5, fDefaultWidthQIE, fDefaultWidthQIE*0.3);
00114 fDefaultRowVA = new CalADCtoPEs(0,0,fDefaultGainVA ,fDefaultGainVA*0.5, fDefaultWidthVA, fDefaultWidthVA*0.3 );
00115
00116 if(fTuneGainFactor!=1.0)
00117 MSG("Calib",Msg::kWarning) << "-- WARNING -- TuneGainFactor is set to " << fTuneGainFactor
00118 << " This is for calibration study only and should not be used for analysis!"
00119 << std::endl;
00120
00121 }
|
|
||||||||||||||||
|
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 188 of file PEGainAggCalScheme.cxx. References FloatErr, CalADCtoPEs::GetGain(), CalADCtoPEs::GetGainErr(), GetRow(), CalADCtoPEs::GetSPEWidth(), and ValueErr< T >::Set(). 00190 {
00200
00201 const CalADCtoPEs* row = GetRow(psid);
00202
00203 gain.Set(row->GetGain() * fTuneGainFactor,
00204 row->GetGainErr());
00205 width = row->GetSPEWidth() * fTuneGainFactor;
00206 // Protect against bad values:
00207 if(width<=0) width = gain*(float)0.5;
00208 }
|
|
||||||||||||||||
|
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 163 of file PEGainAggCalScheme.cxx. References FloatErr, CalADCtoPEs::GetGain(), CalADCtoPEs::GetGainErr(), GetRow(), CalADCtoPEs::GetSPEWidth(), and ValueErr< T >::Set(). 00165 {
00175
00176
00177 const CalADCtoPEs* row = GetRow(seid);
00178
00179 gain.Set(row->GetGain() * fTuneGainFactor,
00180 row->GetGainErr());
00181 width = row->GetSPEWidth() * fTuneGainFactor;
00182 // Protect against bad values:
00183 if(width<=0) width = gain*(float)0.5;
00184 }
|
|
|
Reimplemented from CalScheme. Definition at line 62 of file PEGainAggCalScheme.cxx. References VldContext::AsString(), fLastKey, fResPtr, fUseLinearized, VldContext::GetDetector(), DbiResultPtr< T >::GetKey(), DbiResultPtr< T >::GetNumRows(), CalScheme::IncrementErrors(), DbiResultKey::IsEqualTo(), MAXMSG, DbiResultPtr< T >::NewQuery(), and ResetCache(). 00063 {
00064 Int_t task = 0;
00065 if(fUseLinearized && context.GetDetector()==Detector::kNear) task = 1;
00066
00067 fResPtr.NewQuery(context,task);
00068 if(fResPtr.GetNumRows()==0) {
00069 MAXMSG("Calib",Msg::kWarning,10)
00070 << "PEGainAggCalScheme: No rows in database table with validity context "
00071 << context.AsString() << " No calibration will be applied." << endl;
00072 IncrementErrors(kPeCalibrator,kMissingTable);
00073 }
00074
00075
00076 if(fUseCache) {
00077 const DbiResultKey* newKey = fResPtr.GetKey();
00078
00079 if(fLastKey!=0)
00080 if(!(fLastKey->IsEqualTo(newKey) ) ) ResetCache();
00081
00082 if(fLastKey) delete fLastKey;
00083 fLastKey = new DbiResultKey(newKey);
00084 } else {
00085 // Not using cache.
00086 ResetCache(); // Do it every time.
00087 }
00088
00089
00090
00091 }
|
|
||||||||||||
|
Purpose: Apply PE calibration In: raw adc strip end Out: number of pes. Reimplemented from CalScheme. Definition at line 144 of file PEGainAggCalScheme.cxx. References FloatErr, CalADCtoPEs::GetGain(), CalADCtoPEs::GetGainErr(), and GetRow(). 00146 {
00155
00156 const CalADCtoPEs* row = GetRow(seid);
00157
00158 return rawcharge / FloatErr(row->GetGain() * fTuneGainFactor,
00159 row->GetGainErr() );
00160 }
|
|
|
Definition at line 390 of file PEGainAggCalScheme.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(). 00391 {
00392 //
00393 // Look for the info in the cache, look for the gain in the DB,
00394 // or attempt to reconstruct the gain from the DB if it's not there.
00395 //
00396 if(! psid.IsValid()) {
00397 //MAXMSG("Calib",Msg::kWarning,10)
00398 // << "PEGainAggCalScheme: Requested pixelspot " << psid.AsString() << " is invalid. \n";
00399 IncrementErrors(kPeCalibrator,kBadInput,psid);
00400 if(GetContext().GetDetector()==Detector::kNear) return fDefaultRowQIE;
00401 else return fDefaultRowVA;
00402 }
00403
00404 if(fUseCache) {
00405
00406 SpotCache_t::iterator it = fSpotCache.find(psid);
00407 if(it != fSpotCache.end()) return it->second;
00408
00409 // Look up the data. Cache it if it's good and return.
00410 PlexHandle plex(GetContext());
00411 PlexStripEndId seid = plex.GetStripEndId(psid);
00412
00413 const CalADCtoPEs* row = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00414 if(RowIsGood(row)) {
00415 fSpotCache[psid] = row;
00416 fStripCache[seid] = row;
00417 return row;
00418 };
00419
00420 // The DB data isn't good.
00421 if(fResPtr.GetNumRows()>0) {
00422 MAXMSG("Calib",Msg::kWarning,10)
00423 << "PEGainAggCalScheme: No database row for StripEnd " << seid.AsString() << "\n";
00424 IncrementErrors(kPeCalibrator,kMissingRow,seid);
00425 }
00426
00427 const CalADCtoPEs* newrow = GuessGainAndWidth(psid);
00428 fStripCache[seid] = newrow;
00429 fSpotCache[psid] = newrow;
00430
00431 return newrow;
00432 } else {
00433 // Look up the data. Cache it if it's good and return.
00434 PlexHandle plex(GetContext());
00435 PlexStripEndId seid = plex.GetStripEndId(psid);
00436
00437 const CalADCtoPEs* row = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00438 if(RowIsGood(row)) return row;
00439
00440 // The DB data isn't good.
00441 if(fResPtr.GetNumRows()>0) {
00442 MAXMSG("Calib",Msg::kWarning,10)
00443 << "PEGainAggCalScheme: No database row for StripEnd " << seid.AsString() << "\n";
00444 IncrementErrors(kPeCalibrator,kMissingRow,seid);
00445 }
00446
00447 const CalADCtoPEs* guess = GuessGainAndWidth(psid);
00448 return guess;
00449 }
00450
00451 return NULL;
00452 }
|
|
|
Definition at line 318 of file PEGainAggCalScheme.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(). 00319 {
00320 //
00321 // Look for the info in the cache, look for the gain in the DB,
00322 // or attempt to reconstruct the gain from the DB if it's not there.
00323 //
00324
00325 if(!seid.IsValid()) {
00326 MAXMSG("Calib",Msg::kWarning,10)
00327 << "PEGainAggCalScheme: Requested stripend " << seid.AsString() << " is invalid. \n";
00328 IncrementErrors(kPeCalibrator,kBadInput,seid);
00329 if(GetContext().GetDetector()==Detector::kNear) return fDefaultRowQIE;
00330 else return fDefaultRowVA;
00331 }
00332
00333 if(fUseCache) {
00334 StripCache_t::iterator it = fStripCache.find(seid);
00335 if(it != fStripCache.end()) return it->second;
00336
00337 // Look up the data. Cache it if it's good and return.
00338 PlexHandle plex(GetContext());
00339 PlexPixelSpotId psid = plex.GetPixelSpotId(seid);
00340
00341 const CalADCtoPEs* row = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00342 if(RowIsGood(row)) {
00343 fStripCache[seid] = row;
00344 fSpotCache[psid] = row;
00345 return row;
00346 };
00347
00348 // The DB data isn't good.
00349 if(fResPtr.GetNumRows()>0) {
00350 MAXMSG("Calib",Msg::kWarning,10)
00351 << "PEGainAggCalScheme: No database row for StripEnd " << seid.AsString() << "\n";
00352 IncrementErrors(kPeCalibrator,kMissingRow,seid);
00353 }
00354
00355
00356 // Fallback: make a guess.
00357 const CalADCtoPEs* newrow = GuessGainAndWidth(psid);
00358 fStripCache[seid] = newrow;
00359 fSpotCache[psid] = newrow;
00360
00361 return newrow;
00362
00363 } else {
00364 // NOT using the cache
00365
00366 // Look up the data. Cache it if it's good and return.
00367 PlexHandle plex(GetContext());
00368 PlexPixelSpotId psid = plex.GetPixelSpotId(seid);
00369
00370 const CalADCtoPEs* row = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00371 if(RowIsGood(row)) {
00372 return row;
00373 }
00374 // The DB data isn't good.
00375 if(fResPtr.GetNumRows()>0) {
00376 MAXMSG("Calib",Msg::kWarning,10)
00377 << "PEGainAggCalScheme: No database row for StripEnd " << seid.AsString() << "\n";
00378 IncrementErrors(kPeCalibrator,kMissingRow,seid);
00379 }
00380
00381 // Fallback: make a guess.
00382 const CalADCtoPEs* guess = GuessGainAndWidth(psid);
00383 return guess;
00384
00385 }
00386
00387 return NULL;
00388 }
|
|
|
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 221 of file PEGainAggCalScheme.cxx. References PlexStripEndId::BuildPlnStripEndKey(), fCacheStorage, fResPtr, CalScheme::GetContext(), VldContext::GetDetector(), PlexMuxBoxId::GetElecType(), CalADCtoPEs::GetGain(), PlexPixelSpotId::GetPixel(), DbiResultPtr< T >::GetRowByIndex(), CalADCtoPEs::GetSPEWidth(), PlexHandle::GetStripEndId(), CalScheme::IncrementErrors(), PlexStripEndId::IsValid(), PlexPixelSpotId::IsValid(), MAXMSG, MSG, PlexPixelSpotId::SetPixel(), and PlexPixelSpotId::SetSpot(). Referenced by GetRow(). 00222 {
00229
00230 CalADCtoPEs* output = fDefaultRowVA;
00231
00232 if(!psid.IsValid()) {
00233 MAXMSG("Calib",Msg::kWarning,20) << "Attempted to find gain on invalid pixel. Return VA defaults." << endl;
00234 return output;
00235 if(GetContext().GetDetector()==Detector::kNear) return fDefaultRowQIE;
00236 else return fDefaultRowVA;
00237 }
00238
00239 if(fGuessOtherSpots) {
00240 // Find the average gain from other spots on this pixel.
00241
00242 double gaintot=0;
00243 double widthtot=0;
00244 double pixtot=0;
00245
00246 PlexHandle plex(GetContext());
00247 for(int spot=0;spot<65;spot++) {
00248 PlexPixelSpotId trialspot = psid;
00249 trialspot.SetSpot(spot);
00250 PlexStripEndId seid = plex.GetStripEndId(psid);
00251 if(seid.IsValid()) {
00252 const CalADCtoPEs* row = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00253 if(row) {
00254 pixtot+=1;
00255 gaintot+=row->GetGain();
00256 widthtot+=row->GetSPEWidth();
00257 }
00258 }
00259 }
00260 if(pixtot>0) {
00261 double gain = gaintot/pixtot;
00262 double width= widthtot/pixtot;
00263 output = new CalADCtoPEs(0,0,0, gain, gain*0.1, width); // Assume 10% error on gain.
00264 fCacheStorage.push_back(output);
00265 return output;
00266 }
00267
00268 }
00269
00270 if(fGuessOtherPixels) {
00271 // Find the average gain of the next and previous pixel numbers.
00272
00273 double gaintot=0;
00274 double widthtot=0;
00275 double pixtot=0;
00276 PlexHandle plex(GetContext());
00277
00278 for(int pixel=psid.GetPixel()-1; pixel<psid.GetPixel()+1; pixel+=2) {
00279 PlexPixelSpotId trialspot = psid;
00280 trialspot.SetPixel(pixel);
00281 PlexStripEndId seid = plex.GetStripEndId(psid);
00282 if(seid.IsValid()) {
00283 const CalADCtoPEs* row = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00284 if(row) {
00285 pixtot+=1;
00286 gaintot+=row->GetGain();
00287 widthtot+=row->GetSPEWidth();
00288 }
00289 }
00290 }
00291 if(pixtot>0) {
00292 double gain = gaintot/pixtot;
00293 double width= widthtot/pixtot;
00294 output = new CalADCtoPEs(0,0,0, gain, gain*0.2, width); // Assume 20% error on gain.
00295 fCacheStorage.push_back(output);
00296 return output;
00297 }
00298
00299 }
00300
00301
00302 // Ok, that didn't work. Try returning the defaults.
00303 if(psid.GetElecType()==ElecType::kQIE) {
00304 return fDefaultRowQIE;
00305 }
00306 if(psid.GetElecType()==ElecType::kVA) {
00307 return fDefaultRowVA;
00308 }
00309
00310 IncrementErrors(kPeCalibrator,kGeneralErr);
00311 MSG("Calib",Msg::kError) << "Unknown electronics type on pixel " << psid << endl;
00312
00313 if(GetContext().GetDetector()==Detector::kNear) return fDefaultRowQIE;
00314 return fDefaultRowVA;
00315 }
|
|
|
Prints out the current configuration status Should be overridden by implimentation. Reimplemented from CalScheme. Definition at line 124 of file PEGainAggCalScheme.cxx. References fDefaultGainQIE, fDefaultGainVA, fDefaultWidthQIE, and fDefaultWidthVA. 00125 {
00126 if(fUseLinearized)
00127 os << " Will use linearity-corrected tables for the ND" << endl;
00128
00129 if(fGuessOtherSpots)
00130 os << " Will attempt to guess unknown gains from neighboring spots." << endl;
00131 if(fGuessOtherPixels)
00132 os << " Will attempt to guess unknown gains from neighboring pixels." << endl;
00133
00134 os << " Default Gain (VA) = " << fDefaultGainVA << " ADCs " << endl;
00135 os << " Default Gain (QIE) = " << fDefaultGainQIE << " ADCs " << endl;
00136 os << " Default Width (VA) = " << fDefaultWidthVA << " ADCs " << endl;
00137 os << " Default Width (QIE) = " << fDefaultWidthQIE << " ADCs " << endl;
00138 }
|
|
|
Definition at line 49 of file PEGainAggCalScheme.cxx. References fCacheStorage, fSpotCache, and fStripCache. Referenced by DoReset(), and ~PEGainAggCalScheme(). 00050 {
00051 // Deletes and wipes any cached info.
00052 fSpotCache.clear();
00053 fStripCache.clear();
00054 for(UInt_t i=0;i<fCacheStorage.size();i++) {
00055 delete fCacheStorage[i];
00056 }
00057 fCacheStorage.clear();
00058
00059 }
|
|
|
Definition at line 211 of file PEGainAggCalScheme.cxx. References CalADCtoPEs::GetGain(). Referenced by GetRow(). 00212 {
00213 if(!row) return false;
00214 if(row->GetGain() <= 0.0) return false;
00215 return true;
00216 }
|
|
|
Definition at line 67 of file PEGainAggCalScheme.h. Referenced by GuessGainAndWidth(), and ResetCache(). |
|
|
Definition at line 42 of file PEGainAggCalScheme.h. Referenced by ConfigModified(), and PrintConfig(). |
|
|
Definition at line 41 of file PEGainAggCalScheme.h. Referenced by ConfigModified(), and PrintConfig(). |
|
|
Definition at line 49 of file PEGainAggCalScheme.h. Referenced by ConfigModified(), and ~PEGainAggCalScheme(). |
|
|
Definition at line 50 of file PEGainAggCalScheme.h. Referenced by ConfigModified(), and ~PEGainAggCalScheme(). |
|
|
Definition at line 44 of file PEGainAggCalScheme.h. Referenced by ConfigModified(), and PrintConfig(). |
|
|
Definition at line 43 of file PEGainAggCalScheme.h. Referenced by ConfigModified(), and PrintConfig(). |
|
|
Definition at line 40 of file PEGainAggCalScheme.h. Referenced by ConfigModified(). |
|
|
Definition at line 39 of file PEGainAggCalScheme.h. Referenced by ConfigModified(). |
|
|
Definition at line 37 of file PEGainAggCalScheme.h. Referenced by DoReset(). |
|
|
Definition at line 36 of file PEGainAggCalScheme.h. Referenced by DoReset(), GetRow(), and GuessGainAndWidth(). |
|
|
Definition at line 65 of file PEGainAggCalScheme.h. Referenced by GetRow(), and ResetCache(). |
|
|
Definition at line 66 of file PEGainAggCalScheme.h. Referenced by GetRow(), and ResetCache(). |
|
|
Definition at line 45 of file PEGainAggCalScheme.h. Referenced by ConfigModified(). |
|
|
Definition at line 46 of file PEGainAggCalScheme.h. Referenced by ConfigModified(). |
|
|
Definition at line 47 of file PEGainAggCalScheme.h. Referenced by ConfigModified(), and DoReset(). |
1.3.9.1