00001
00010 #if defined (__GNUG__)
00011 #pragma interface "xrxps.h"
00012 #endif
00013
00014 #ifndef xrxps_h
00015 #define xrxps_h
00016
00017 #include <wx/wxprec.h>
00018
00019 #ifdef __BORLANDC__
00020 #pragma hdrstop
00021 #endif
00022
00023 #ifndef WX_PRECOMP
00024 #include <wx/wx.h>
00025 #endif
00026
00027 #include "xps4xps.h"
00028 #include "utils.h"
00029
00030 extern float E4Background;
00031
00036 class xpRuleXPS : public xpRuleGeneric
00037 { protected:
00038 public:
00041 xpRuleXPS( xpAgent *MyAgent=NULL)
00042 :xpRuleGeneric(MyAgent)
00043 { }
00045 xpRuleXPS(const xpRuleXPS &xr)
00046 { }
00047 };
00048
00052 class xrIsEnergyBE : public xpRuleXPS
00053 {
00054 public:
00056 xrIsEnergyBE( xpAgent *MyAgent=NULL);
00058 xpRuleGeneric Fire(void);
00059 };
00060
00062
00063 class xrIsEnergyKE : public xpRuleXPS
00064 {
00065 public:
00067 xrIsEnergyKE( xpAgent *MyAgent=NULL);
00069 xpRuleGeneric Fire(void);
00070 };
00071
00073
00075 class xrIsXEnergyKnown : public xpRuleXPS
00076 {
00077 public:
00079 xrIsXEnergyKnown( xpAgent *MyAgent=NULL)
00080 :xpRuleXPS(MyAgent)
00081 { Name = _("Exciting energy known"); }
00084 xpRuleGeneric Fire(void)
00085 { xpSpectrumBase *xpS = (xpSpectrumBase *) Agent;
00086 if(xpS)
00087 value = xpS->GetXEnergyKnown();
00088 else
00089 {
00090 value = Unknown; HistoryString << _("No spectrum known");
00091 return *this;
00092 }
00093 if(xboolean::True == value)
00094 HistoryString << _("Excitation energy is given");
00095 else if (xboolean::False == value)
00096 HistoryString << _("Excitation energy is NOT given");
00097 else HistoryString << _("Excitation energy is unknown");
00098 return *this;
00099 }
00100 };
00101
00103
00113 class xrIsEnergyAvailBE : public xpRuleXPS
00114 {
00115 public:
00117 xrIsEnergyAvailBE( xpAgent *MyAgent=NULL)
00118 :xpRuleXPS(MyAgent)
00119 { Name = _("Binding energy available"); }
00121 xpRuleGeneric Fire(void)
00122 {
00123 return xrIsEnergyBE(Agent).Fire()
00124 OR
00125 ( xrIsEnergyKE(Agent).Fire()
00126 AND
00127 xrIsXEnergyKnown(Agent).Fire()
00128 );
00129 }
00130 };
00131
00133
00143 class xrIsEnergyAvailKE : public xpRuleXPS
00144 {
00145 public:
00147 xrIsEnergyAvailKE( xpAgent *MyAgent=NULL)
00148 :xpRuleXPS(MyAgent)
00149 { Name = _("Kinetic energy available"); }
00151 xpRuleGeneric Fire(void)
00152 {
00153 return xrIsEnergyKE(Agent).Fire()
00154 OR
00155 ( xrIsEnergyBE(Agent).Fire()
00156 AND
00157 xrIsXEnergyKnown(Agent).Fire()
00158 );
00159 }
00160 };
00161
00163
00172 class xrIsRegionMeasuredBE : public xpRuleXPS
00173 { protected:
00174 float BELow,
00175 BEHigh;
00176 public:
00178 xrIsRegionMeasuredBE( xpAgent *MyAgent, float Low, float High)
00179 :xpRuleXPS(MyAgent)
00180 { Name << wxString::Format(_("BE region [%s,%s] is measured")
00181 , GetFormatted(Low), GetFormatted(High));
00182 BELow = Low; BEHigh = High;
00183 }
00185 xpRuleGeneric Fire(void)
00186 { xpSpectrumBase *xpS = (xpSpectrumBase *) Agent;
00187 if(xpS )
00188 {
00189 float MyLow, MyHigh, MyE = 0.0f;
00190 if (!( xboolean::Unknown == xpS->GetEnergyBE()) )
00191
00192 MyE = xpS->GetChargingEnergy();
00193 if( xpS->IsEnergyBE())
00194 {
00195 MyLow = xpS->GetMinEnergy()+MyE;
00196 MyHigh = xpS->GetMaxEnergy()+MyE;
00197 }
00198 else if(( xpS->IsEnergyKE()) AND ( xpS->IsXEnergyKnown()))
00199 {
00200 MyLow = xpS->ToBE(xpS->GetMaxEnergy()+MyE);
00201 MyHigh = xpS->ToBE(xpS->GetMinEnergy()+MyE);
00202 }
00203 else
00204 { value = Unknown; HistoryString << _("No energy info given"); return *this;}
00205
00206
00207 value = (xboolean::xbool)
00208 (xpSpectrumBase::IsInRangeE(MyLow,MyHigh, BELow)
00209 &&
00210 xpSpectrumBase::IsInRangeE(MyLow,MyHigh, BEHigh)
00211 );
00212 if(xboolean::True == value)
00213 HistoryString << wxString::Format(_("BE region [%s,%s] is within measured range [%s,%s] ")
00214 , GetFormatted(BELow), GetFormatted(BEHigh), GetFormatted(MyLow), GetFormatted(MyHigh));
00215 else if (xboolean::False == value)
00216 HistoryString << wxString::Format(_("BE region [%s,%s] is NOT within measured range [%s,%s] ")
00217 , GetFormatted(BELow), GetFormatted(BEHigh), GetFormatted(MyLow), GetFormatted(MyHigh) );
00218 else HistoryString << _("Some error occurred");
00219 return *this;
00220 }
00221 else
00222 { value = Unknown; HistoryString << _("No spectrum known");
00223 return *this;
00224 }
00225 }
00226 };
00227
00229
00237 class xrIsRegionMeasuredKE : public xpRuleXPS
00238 { protected:
00239 float KELow,
00240 KEHigh;
00241 public:
00243 xrIsRegionMeasuredKE( xpAgent *MyAgent, float Low, float High)
00244 :xpRuleXPS(MyAgent)
00245 { Name << wxString::Format(_("KE region [%s,%s] is measured")
00246 , GetFormatted(Low), GetFormatted(High));
00247 KELow = Low; KEHigh = High;
00248 }
00250 xpRuleGeneric Fire(void)
00251 { xpSpectrumBase *xpS = (xpSpectrumBase *) Agent;
00252 if(xpS )
00253 {
00254 float MyLow, MyHigh, MyE = 0.0f;
00255 if (!( xboolean::Unknown == xpS->GetEnergyBE()) )
00256
00257 MyE = xpS->GetChargingEnergy();
00258 if( xpS->IsEnergyKE())
00259 {
00260 MyLow = xpS->GetMinEnergy()+MyE;
00261 MyHigh = xpS->GetMaxEnergy()+MyE;
00262 }
00263 else if(( xpS->IsEnergyBE()) AND ( xpS->IsXEnergyKnown()))
00264 {
00265 MyLow = xpS->ToKE(xpS->GetMaxEnergy()+MyE);
00266 MyHigh = xpS->ToKE(xpS->GetMinEnergy()+MyE);
00267 }
00268 else
00269 { value = Unknown; HistoryString << _("No energy info given"); return *this;}
00270
00271
00272 value = (xboolean::xbool)
00273 (
00274 xpSpectrumBase::IsInRangeE(MyLow,MyHigh, KELow)
00275 &&
00276 xpSpectrumBase::IsInRangeE(MyLow,MyHigh, KEHigh)
00277 );
00278 if(xboolean::True == value)
00279 HistoryString << wxString::Format(_("KE region [%s,%s] is within measured range [%s,%s] ")
00280 , GetFormatted(KELow), GetFormatted(KEHigh), GetFormatted(MyLow), GetFormatted(MyHigh) );
00281 else if (xboolean::False == value)
00282 HistoryString << wxString::Format(_("KE region [%s,%s] is NOT within measured range [%s,%s] ")
00283 , GetFormatted(KELow), GetFormatted(KEHigh), GetFormatted(MyLow), GetFormatted(MyHigh) );
00284 else HistoryString << _("Some error occurred");
00285 return *this;
00286 }
00287 else
00288 { value = Unknown; HistoryString << _("No spectrum known");
00289 return *this;
00290 }
00291 }
00292 };
00293
00295
00302 class xrIsPeakInRangeBE : public xpRuleXPS
00303 { protected:
00304 float BELow,
00305 BEHigh;
00306 public:
00309 xrIsPeakInRangeBE( xpAgent *MyAgent, float Low, float High)
00310 :xpRuleXPS(MyAgent)
00311 {
00312 Name << wxString::Format(_("Peak is in BE range [%s,%s] ")
00313 , GetFormatted(Low), GetFormatted(High));
00314 BELow = Low; BEHigh = High;
00315 }
00317 xpRuleGeneric Fire(void)
00318 { xpPeakBase *xpP = (xpPeakBase *) Agent;
00319 if(xpP )
00320 {
00321 float MyEnergy ;
00322
00323 if( xpP->IsEnergyBE())
00324 {
00325 MyEnergy = xpP->GetEnergy(true);
00326 }
00327 else if(( xpP->IsEnergyKE()) AND ( xpP->IsXEnergyKnown()))
00328 {
00329 MyEnergy = xpP->ToBE(xpP->GetEnergy(true));
00330 }
00331 else
00332 { value = Unknown; HistoryString << _("No peak energy info given"); return *this;}
00333
00334 xpSpectrumBase *xpS = xpP->GetSpectrum();
00335
00336 xpRuleGeneric a = xrIsRegionMeasuredBE(xpS,BELow-E4Background,BEHigh+E4Background).Fire();
00337 if(!a.IsTrue())
00338 {
00339 value = a.GetValue();
00340 HistoryString = a.GetHistoryString();
00341 return *this;
00342 }
00343
00344 value = (xboolean::xbool) (xpSpectrumBase::IsInRangeE(BELow, BEHigh, MyEnergy));
00345 if(xboolean::True == value)
00346 HistoryString << wxString::Format(_("Peak energy %s is in BE range [%s,%s] ")
00347 , GetFormatted(xpP->GetEnergy(true)), GetFormatted(BELow), GetFormatted(BEHigh));
00348 else if (xboolean::False == value)
00349 HistoryString << wxString::Format(_("Peak energy %s is NOT in BE range [%s,%s] ")
00350 , GetFormatted(xpP->GetEnergy(true)), GetFormatted(BELow), GetFormatted(BEHigh));
00351 else HistoryString << _("Some error occurred");
00352 return *this;
00353 }
00354 else
00355 { value = Unknown; return *this;}
00356 }
00357 };
00358
00360
00367 class xrIsPeakInRangeKE : public xpRuleXPS
00368 { protected:
00369 float KELow,
00370 KEHigh;
00371 public:
00373 xrIsPeakInRangeKE( xpAgent *MyAgent, float Low, float High)
00374 :xpRuleXPS(MyAgent)
00375 { Name << wxString::Format(_("Peak is in KE range [%s,%s] ")
00376 , GetFormatted(Low), GetFormatted(High));
00377 KELow = Low; KEHigh = High;
00378 }
00380 xpRuleGeneric Fire(void)
00381 { xpPeakBase *xpP = (xpPeakBase *) Agent;
00382 if(xpP )
00383 {
00384 float MyEnergy ;
00385
00386 if( xpP->IsEnergyKE())
00387 {
00388 MyEnergy = xpP->GetEnergy(true);
00389 }
00390 else if(( xpP->IsEnergyBE()) AND ( xpP->IsXEnergyKnown()))
00391 {
00392 MyEnergy = xpP->ToKE(xpP->GetEnergy(true));
00393 }
00394 else
00395 { value = Unknown; HistoryString << _("No peak energy info given"); return *this;}
00396
00397 xpSpectrumBase *xpS = xpP->GetSpectrum();
00398
00399 xpRuleGeneric a = xrIsRegionMeasuredKE(xpS,KELow-E4Background,KEHigh+E4Background).Fire();
00400 if(!a.IsTrue())
00401 {
00402 value = a.GetValue();
00403 HistoryString = a.GetHistoryString();
00404 return *this;
00405 }
00406
00407 value = (xboolean::xbool) (xpSpectrumBase::IsInRangeE(KELow, KEHigh, MyEnergy));
00408 if(xboolean::True == value)
00409 HistoryString << wxString::Format(_("Peak energy %s is in KE range [%s,%s] ")
00410 , GetFormatted(xpP->GetEnergy(true)), GetFormatted(KELow), GetFormatted(KEHigh));
00411 else if (xboolean::False == value)
00412 HistoryString << wxString::Format(_("Peak energy %s is NOT in KE range [%s,%s] ")
00413 , GetFormatted(xpP->GetEnergy(true)), GetFormatted(KELow), GetFormatted(KEHigh));
00414 else HistoryString << _("Some error occurred");
00415 return *this;
00416 }
00417 else
00418 { value = Unknown; return *this;}
00419 }
00420 };
00421
00423
00428 class xrHasPeakInRangeBE : public xpRuleXPS
00429 { protected:
00430 float BELow,
00431 BEHigh;
00432 public:
00434 xrHasPeakInRangeBE( xpAgent *MyAgent, float Low, float High);
00435
00436
00437
00438
00439
00441 xpRuleGeneric Fire(void);
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489 };
00490
00492
00497 class xrHasPeakInRangeKE : public xpRuleXPS
00498 { protected:
00499 float KELow,
00500 KEHigh;
00501 public:
00503 xrHasPeakInRangeKE( xpAgent *MyAgent, float Low, float High);
00505 xpRuleGeneric Fire(void);
00506 };
00507
00508 #endif //xrxps_h