StripAttenCalScheme Class Reference

#include <StripAttenCalScheme.h>

Inheritance diagram for StripAttenCalScheme:

CalScheme CfgPromptConfigurable List of all members.

Public Member Functions

 StripAttenCalScheme ()
virtual ~StripAttenCalScheme ()
virtual void DoReset (const VldContext &context)
virtual void ConfigModified ()
virtual void PrintConfig (std::ostream &os) const
virtual FloatErr GetAttenCorrected (FloatErr sigcorr, FloatErr stripX, const PlexStripEndId &seid) const
virtual FloatErr DecalAttenCorrected (FloatErr sigmap, FloatErr stripX, const PlexStripEndId &seid) const

Private Member Functions

 ClassDef (StripAttenCalScheme, 0)

Private Attributes

DbiResultPtr< CalStripAttenfResPtr
Int_t fTask
CalStripAttenfDefaultAtten

Detailed Description

Definition at line 24 of file StripAttenCalScheme.h.


Constructor & Destructor Documentation

StripAttenCalScheme::StripAttenCalScheme (  ) 

Definition at line 24 of file StripAttenCalScheme.cxx.

References Registry::Set().

00025   : fResPtr(),
00026     fDefaultAtten(0)
00027 {
00028   Registry r;
00029   r.Set("defF12",0.333);
00030   r.Set("defL1",1.0); 
00031   r.Set("defL2",7.0);
00032   r.Set("Task",0); 
00033   InitializeConfig(r);
00034 }

StripAttenCalScheme::~StripAttenCalScheme (  )  [virtual]

Definition at line 38 of file StripAttenCalScheme.cxx.

References fDefaultAtten.

00039 {
00040   if(fDefaultAtten) delete fDefaultAtten;
00041 }


Member Function Documentation

StripAttenCalScheme::ClassDef ( StripAttenCalScheme  ,
 
) [private]

void StripAttenCalScheme::ConfigModified (  )  [virtual]

Reimplemented from CalScheme.

Definition at line 59 of file StripAttenCalScheme.cxx.

References fDefaultAtten, fTask, Registry::Get(), CfgPromptConfigurable::GetConfig(), CalScheme::GetContext(), Msg::kError, Detector::kNear, StripEnd::kPositive, MSG, and CalScheme::Reset().

00060 {
00064 
00065   double f12,l1,l2;
00066   bool ok = true;
00067   ok = ok && GetConfig().Get("Task",fTask);
00068   ok = ok && GetConfig().Get("defF12",f12);
00069   ok = ok && GetConfig().Get("defL1",l1);
00070   ok = ok && GetConfig().Get("defL2",l2);
00071   if(!ok) MSG("Calib",Msg::kError) << "Problem setting up StripAttenCalScheme config." << endl;
00072 
00073   if(fDefaultAtten) delete fDefaultAtten;
00074   
00075   // Create a dummy seid. This is because the row constructor calls
00076   // seid.BuildPlnStripEndKey(), which prints out warning messages we don't want.
00077   // Doesn't matter, we don't use this seid for anything.
00078   PlexStripEndId dummy_seid(Detector::kNear,1,1,StripEnd::kPositive);
00079     
00080   // Build the 'default' row.  Uses the default values harvested above to create a
00081   // single DB row, which can do our calibration!
00082   fDefaultAtten = new CalStripAtten(dummy_seid,
00083                                     l1, l2, f12,  // L1, L2, N1/(N1+N2)
00084                                     l1/2., l2/2., f12/2.  // 50% errors
00085                                     );
00086   
00087   // Ensure that the DB has been changed for this event.
00088   Reset(GetContext(),true); 
00089 }

FloatErr StripAttenCalScheme::DecalAttenCorrected ( FloatErr  sigmap,
FloatErr  stripX,
const PlexStripEndId seid 
) const [virtual]

Reimplemented from CalScheme.

Definition at line 186 of file StripAttenCalScheme.cxx.

References MuELoss::a, PlexStripEndId::AsString(), PlexStripEndId::BuildPlnStripEndKey(), MuELoss::e, fDefaultAtten, fResPtr, CalStripAtten::GetAttenuation(), CalScheme::GetContext(), PlexStripEndId::GetEnd(), ValueErr< T >::GetError(), UgliStripHandle::GetHalfLength(), DbiResultPtr< T >::GetNumRows(), DbiResultPtr< T >::GetRowByIndex(), UgliGeomHandle::GetStripHandle(), ValueErr< T >::GetValue(), CalScheme::IncrementErrors(), PlexPlaneId::IsVetoShield(), CalScheme::kAttenCalibrator, CalScheme::kFPE, CalScheme::kMissingRow, StripEnd::kNegative, StripEnd::kPositive, Msg::kWarning, MAXMSG, ValueErr< T >::SetError(), and UgliStripHandle::WlsPigtail().

00189 {
00201 
00202   UgliGeomHandle ugli(GetContext());
00203   UgliStripHandle ustrip = ugli.GetStripHandle(seid);
00204   
00205   // Don't clip the MC.. trust that it's checked strip bounds.
00206   // I sometimes want to inject light into the pigtails, so I need the
00207   // flexibility. --Nathaniel, Jan 2006
00208 //   if(fabs(stripX) > ustrip.GetHalfLength()) {
00209 //     MSG("Calib",Msg::kDebug) << "Reconstruction asked for non-physical attenuation correction: "
00210 //                           << seid.AsString() << endl;
00211 //     MSG("Calib",Msg::kDebug) << "halflen=" << ustrip.GetHalfLength()
00212 //                           << "  requested=" << stripX 
00213 //                           << "  ... trimming to physical bounds now..."
00214 //                           << endl;
00215     
00216 //     // Increment error if it's more than 10 cm out.
00217 //     if(fabs(stripX) > ustrip.GetHalfLength()+0.1) 
00218 //       IncrementErrors(kAttenCalibrator,kBadInput);
00219 
00220 //     // Trim it.
00221 //     stripX = TMath::Sign(ustrip.GetHalfLength(),stripX);
00222 //   }
00223 
00224   double halfgreen = ustrip.GetHalfLength() + ustrip.WlsPigtail(seid.GetEnd());
00225   double wlsLen = halfgreen;
00226   if(seid.GetEnd()==StripEnd::kPositive) wlsLen -= stripX;
00227   if(seid.GetEnd()==StripEnd::kNegative) wlsLen += stripX;
00228   // If not +ve or -ve, do nothing.
00229 
00230   const CalStripAtten* atten = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00231   if(atten==0) {
00232     if((fResPtr.GetNumRows()>0)&&(!seid.IsVetoShield())) {
00233       MAXMSG("Calib",Msg::kWarning,10) << "StripAtten Scheme: Cannot find row for stripend "
00234                                        << seid.AsString() << ". Using default." << endl;
00235       IncrementErrors(kAttenCalibrator,kMissingRow,seid);
00236     }
00237     atten = fDefaultAtten;
00238   }
00239 
00240   // The correction is for the center of the strip to the new position
00241   // on the strip.
00242   
00243   float a = atten->GetAttenuation(halfgreen);
00244   FloatErr b = atten->GetAttenuation(wlsLen);
00245   b.SetError( fabs( b.GetValue() - atten->GetAttenuation(wlsLen - stripX.GetError()) ) );
00246 
00247   if(a < 4e-10) {
00248     MAXMSG("Calib",Msg::kWarning,10) 
00249       << "StripAtten Scheme: caught a divide-by-zero error on " << seid.AsString() << endl;
00250     IncrementErrors(kAttenCalibrator,kFPE,seid);
00251     return sigmap * FloatErr(1,0.5);
00252   }
00253   
00254   // New, March 2007. NJT, JL
00255   // Clamp the correction at the near end to be less that a factor of 10
00256   FloatErr ratio = b/a;
00257   if(ratio > 10.) ratio = FloatErr(10.,fabs(10.-ratio.GetValue()));
00258   
00259   return sigmap * ratio;
00260 }

void StripAttenCalScheme::DoReset ( const VldContext context  )  [virtual]

Reimplemented from CalScheme.

Definition at line 45 of file StripAttenCalScheme.cxx.

References VldContext::AsString(), fResPtr, fTask, DbiResultPtr< T >::GetNumRows(), CalScheme::IncrementErrors(), CalScheme::kAttenCalibrator, CalScheme::kMissingTable, Msg::kVerbose, Msg::kWarning, MAXMSG, MSG, and DbiResultPtr< T >::NewQuery().

00046 {
00047   MSG("Calib",Msg::kVerbose) << "StripAttenCalScheme::DoReset(VldContext) Task: " << fTask << endl;
00048 
00049   fResPtr.NewQuery(vc,fTask);
00050   if(fResPtr.GetNumRows()==0) {
00051     MAXMSG("Calib",Msg::kWarning,10) 
00052       << "StripAtten Scheme: No rows found for CALSTRIPATTEN database table"
00053       << vc.AsString() << ".\n";         
00054     IncrementErrors(kAttenCalibrator,kMissingTable);
00055   }
00056 }

FloatErr StripAttenCalScheme::GetAttenCorrected ( FloatErr  sigcorr,
FloatErr  stripX,
const PlexStripEndId seid 
) const [virtual]

Reimplemented from CalScheme.

Definition at line 104 of file StripAttenCalScheme.cxx.

References MuELoss::a, PlexStripEndId::AsString(), PlexStripEndId::BuildPlnStripEndKey(), Munits::cm, MuELoss::e, fDefaultAtten, fResPtr, CalStripAtten::GetAttenuation(), CalScheme::GetContext(), PlexStripEndId::GetEnd(), ValueErr< T >::GetError(), UgliStripHandle::GetHalfLength(), DbiResultPtr< T >::GetNumRows(), DbiResultPtr< T >::GetRowByIndex(), UgliGeomHandle::GetStripHandle(), ValueErr< T >::GetValue(), CalScheme::IncrementErrors(), PlexPlaneId::IsVetoShield(), CalScheme::kAttenCalibrator, CalScheme::kBadInput, Msg::kDebug, CalScheme::kFPE, CalScheme::kMissingRow, StripEnd::kNegative, StripEnd::kPositive, Msg::kWarning, MAXMSG, MSG, ValueErr< T >::SetError(), Particle::Sign(), and UgliStripHandle::WlsPigtail().

00107 {
00117   // This bit ripped from the old StripCalibrator:
00118   // Change from 'stripX' to 'length of green fibre'
00119 
00120   UgliGeomHandle ugli(GetContext());
00121   UgliStripHandle ustrip = ugli.GetStripHandle(seid);
00122 
00123   float outside = fabs(stripX) - ustrip.GetHalfLength();
00124   if(outside>0) {
00125     if(outside > 10.0*Munits::cm) {
00126       MSG("Calib",Msg::kDebug) 
00127         << "Reconstruction asked for non-physical attenuation correction: "
00128         << seid.AsString()
00129         << endl
00130         << "halflen=" << ustrip.GetHalfLength()
00131         << "  requested=" << stripX 
00132         << "  ... trimming to physical bounds now..."
00133         << endl;
00134       IncrementErrors(kAttenCalibrator,kBadInput);
00135     }
00136     // Trim it.
00137     stripX = TMath::Sign(ustrip.GetHalfLength(),stripX);
00138   }
00139   
00140   double halfgreen = ustrip.GetHalfLength() + ustrip.WlsPigtail(seid.GetEnd());
00141   double wlsLen = halfgreen;
00142   if(seid.GetEnd()==StripEnd::kPositive) wlsLen -= stripX;
00143   if(seid.GetEnd()==StripEnd::kNegative) wlsLen += stripX;
00144   // If not +ve or -ve, do nothing.
00145 
00146   const CalStripAtten* atten = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00147   if(atten==0) {
00148     if((fResPtr.GetNumRows()>0)&&(!seid.IsVetoShield())) {
00149       MAXMSG("Calib",Msg::kWarning,10) << "StripAtten Scheme: Cannot find row for stripend "
00150                                        << seid.AsString() << ". Using default." << endl;
00151       IncrementErrors(kAttenCalibrator,kMissingRow,seid);
00152     }
00153     atten = fDefaultAtten;
00154   }
00155 
00156   // The correction is for the center of the strip to the new position
00157   // on the strip.
00158   
00159   float    a = atten->GetAttenuation(halfgreen);
00160   FloatErr b = atten->GetAttenuation(wlsLen);
00161   b.SetError( fabs( b.GetValue() - atten->GetAttenuation(wlsLen - stripX.GetError()) ) );
00162 
00163   if ( b < 4.0e-10 ) {  
00164     // The value of "b" gets raised to the 4-th power in
00165     // the error calculation of a/b. We cut below 4.0e-10 because it
00166     // is ~(1.175e-38)^(1/4) where that is the smallest representable
00167     // value for a Float_t; smaller values underflow to zero and are
00168     // then used as a denominator.
00169     MAXMSG("Calib",Msg::kWarning,10) 
00170       << "StripAtten Scheme: caught a divide-by-zero error on " 
00171       << seid.AsString() << endl;
00172     IncrementErrors(kAttenCalibrator,kFPE,seid);
00173     return sigcorr * FloatErr(1,0.5);
00174   }
00175 
00176   // New, March 2007. NJT, JL
00177   // Clamp the correction at the near end to be less that a factor of 10
00178   FloatErr ratio = a/b;
00179   if(ratio < 0.1) ratio = FloatErr(0.1,fabs(0.1-ratio.GetValue()));
00180   
00181   return sigcorr * ratio;
00182 }

void StripAttenCalScheme::PrintConfig ( std::ostream &  os  )  const [virtual]

Reimplemented from CalScheme.

Definition at line 92 of file StripAttenCalScheme.cxx.

References fDefaultAtten, fTask, CalStripAtten::GetFrac1(), CalStripAtten::GetLambda1(), and CalStripAtten::GetLambda2().

00093 {
00094   os << " (NEW attenuation calibration scheme) " << endl;
00095   os << "  Task = " << fTask << endl;
00096   os << "  Default attenuation is " 
00097      << "F12 = " << fDefaultAtten->GetFrac1() << "\t"
00098      << "Lambda1 = " << fDefaultAtten->GetLambda1() << "\t"
00099      << "Lambda2 = " << fDefaultAtten->GetLambda2() << endl;
00100 }


Member Data Documentation

CalStripAtten* StripAttenCalScheme::fDefaultAtten [private]

Definition at line 42 of file StripAttenCalScheme.h.

Referenced by ConfigModified(), DecalAttenCorrected(), GetAttenCorrected(), PrintConfig(), and ~StripAttenCalScheme().

DbiResultPtr<CalStripAtten> StripAttenCalScheme::fResPtr [private]

Definition at line 40 of file StripAttenCalScheme.h.

Referenced by DecalAttenCorrected(), DoReset(), and GetAttenCorrected().

Int_t StripAttenCalScheme::fTask [private]

Definition at line 41 of file StripAttenCalScheme.h.

Referenced by ConfigModified(), DoReset(), and PrintConfig().


The documentation for this class was generated from the following files:
Generated on Wed Oct 1 22:53:39 2014 for loon by  doxygen 1.4.7