Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

StripToStripCalScheme.cxx

Go to the documentation of this file.
00001 
00002 // $Id: StripToStripCalScheme.cxx,v 1.11 2007/03/29 19:56:13 tagg Exp $
00003 //
00004 // The 'new' strip-to-strip calibration scheme.
00005 //
00006 // Applies the numbers from the CALSTRIPTOSTRIP table.
00007 // These numbers are such that they take out ALL variations between
00008 // strips, normalized to the center of the strip.
00009 //
00010 // i.e. for an event in the center of the strip, this calibration should
00011 // remove all strip-to-strip effects.
00012 //
00013 // In other words, this calibration takes out:
00014 // 1) Gain
00015 // 2) All fibre attenuation from pixel to middle of strip
00016 // 3) Scintillator light output variation strip-to-strip.
00017 //
00018 // This constrasts with the MuonSigCorrCalScheme,
00019 // which takes out:
00020 // 1) Gain
00021 // 2) Corrections to mapper data
00022 //
00023 // n.tagg1@physics.ox.ac.uk
00025 #include "StripToStripCalScheme.h"
00026 
00027 #include "Calibrator.h"
00028 #include "MessageService/MsgService.h"
00029 #include "Plex/PlexSEIdAltL.h"
00030 #include "Plex/PlexStripEndId.h"
00031 #include "DatabaseInterface/DbiValidityRec.h"
00032 #include "Validity/VldRange.h"
00033 
00034 ClassImp(StripToStripCalScheme)
00035 CVSID("$Id: StripToStripCalScheme.cxx,v 1.11 2007/03/29 19:56:13 tagg Exp $");
00036 
00037 //......................................................................
00038 StripToStripCalScheme::StripToStripCalScheme()
00039 {
00043   MSG("Calib",Msg::kVerbose) << "StripToStripCalScheme::StripToStripCalScheme" 
00044                                   << endl;
00045   Registry r;
00046   r.Set("TemperatureCalibration","off");
00047   r.Set("MuonSource","Cosmics");
00048   r.Set("SpectrometerFudge",1.0);
00049   InitializeConfig(r);
00050 
00051   // Hard code these for now.
00052   fRefTemp = 18.0;       // reference temperature
00053   fTempCorFactor = -0.0008;  // frac diff in light output with temperature
00054 
00055 }
00056 
00057 //......................................................................
00058 void StripToStripCalScheme::DoReset( const VldContext& vc )
00059 {
00063 
00064   MSG("Calib",Msg::kVerbose) << "StripToStripCalScheme::DoReset(VldContext) Task: " << fMuonTask << endl;
00065 
00066   fResPtr.NewQuery(vc,fMuonTask);
00067   if(fResPtr.GetNumRows()==0) {
00068     MAXMSG("Calib",Msg::kWarning,10) 
00069       << "StripToStrip Scheme: No rows in CALSTRIPTOSTRIP database table"
00070       << vc.AsString() << ".\n";         
00071     IncrementErrors(kStripCalibrator,kMissingTable);
00072   }
00073 }
00074 
00075 //......................................................................
00076 void StripToStripCalScheme::ConfigModified()
00077 {
00081 
00082   const char* str_tempcal;
00083   const char* str_source;
00084 
00085 
00086   bool ok = true;
00087   ok = ok && GetConfig().Get("TemperatureCalibration",str_tempcal);
00088   ok = ok && GetConfig().Get("MuonSource",str_source);
00089   ok = ok && GetConfig().Get("SpectrometerFudge",fSpectrometerFudge);
00090   if(!ok) MSG("Calib",Msg::kError) << "Problem setting up StripToStripCalScheme config." << endl;
00091   
00092   // Interpret strings.
00093   if(strcasecmp(str_tempcal,"on")==0) fDoTempCal = true;
00094   else fDoTempCal = false;
00095   
00096   if(strncasecmp(str_source,"cosmic",6)==0) fMuonTask = 0;
00097   else if(strncasecmp(str_source,"paul",4)==0) fMuonTask = 1;
00098   else if(strncasecmp(str_source,"ps",2)==0) fMuonTask = 2;
00099   else if(strncasecmp(str_source,"alt",3)==0) fMuonTask = 3;
00100   else {
00101     MSG("Calib",Msg::kError) << "I don't understand the MuonSource setting " << str_source << endl;
00102     MSG("Calib",Msg::kError) << "Valid settings are: Cosmics, Paul's Cosmics, PS muons, and Alternative PS muons"<< endl;
00103     MSG("Calib",Msg::kError) << "Defaulting to cosmics"<< endl;
00104     fMuonTask=0;
00105   }
00106 
00107   // Ensure that the DB has been changed for this event.
00108   Reset(GetContext(),true); 
00109 }
00110 
00111 //......................................................................
00112 void StripToStripCalScheme::PrintConfig( std::ostream& os ) const
00113 {
00114   os << " (NEW Strip-to-strip calibration scheme) " << endl;
00115   os << "  Muon Source = " << fMuonTask << " = " 
00116      << GetConfig().GetCharString("MuonSource") << endl;
00117   os << " Temperature calibration is " << ((fDoTempCal)?"on":"off") << endl;
00118   if(fDoTempCal) {
00119     os << "  Temp Correction Factor = 1 / [ 1 - " 
00120        << fTempCorFactor << "*(" 
00121        << fRefTemp << " - temp) ]" << endl;
00122   }
00123   if(fSpectrometerFudge!=1.0) {
00124       os << "  Spectrometer fudged by ratio: " << fSpectrometerFudge << endl;
00125   }
00126 }
00127 
00128 
00129 //......................................................................
00130 FloatErr StripToStripCalScheme::GetStripToStripCorrected(FloatErr siglin, 
00131                                                        const PlexStripEndId& seid) const
00132 {
00133   
00145 
00146   MSG("Calib",Msg::kVerbose) << "StripToStripCalScheme on " << siglin 
00147                              << " siglin in seid " << seid.BuildPlnStripEndKey() <<"\n";
00148   // Now need to get the row which corresponds to the stripendnum.
00149 
00150   FloatErr correction = 1.0;
00151   if(fDoTempCal)
00152     correction = GetTemperatureCorrection();
00153 
00154   // Don't complain about veto shield entries; just do it.
00155   if(seid.IsVetoShield()) return  siglin * correction;
00156 
00157   if(seid.IsNearSpect()) correction *= fSpectrometerFudge;
00158 
00159   const CalStripToStrip* muoncal = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00160   
00161   if(muoncal ==0) {                             
00162     if(fResPtr.GetNumRows()>0) {
00163       MAXMSG("Calib",Msg::kWarning,10) 
00164        << "StripToStripCalScheme: No database row for StripEnd " 
00165        << seid.AsString("c") << " key " << seid.BuildPlnStripEndKey() << "\n";
00166      
00167      IncrementErrors(kStripCalibrator,kMissingRow,seid);
00168    }
00169 
00170     return siglin * correction * FloatErr(1,0.5); // Add 50% error 
00171  }
00172 
00173   
00174   return correction * siglin / FloatErr(muoncal->GetResponse(), muoncal->GetResponseErr());
00175 }
00176 
00177 //......................................................................
00178 FloatErr StripToStripCalScheme::DecalStripToStrip(FloatErr sigcorr,
00179                                                 const PlexStripEndId& seid) const
00180 {
00191 
00192   MSG("Calib",Msg::kVerbose) << "StripToStripCalScheme decal on " << sigcorr 
00193                              << " siglin in seid " << seid.AsString() <<"\n";
00194   
00195   FloatErr correction = 1.0;
00196   if(fDoTempCal)
00197     correction = GetTemperatureCorrection();
00198 
00199   // Don't complain about veto shield entries; just do it.
00200   if(seid.IsVetoShield()) return  sigcorr / correction;
00201 
00202   if(seid.IsNearSpect()) correction *= fSpectrometerFudge;
00203 
00204   // Now need to get the row which corresponds to the stripendnum.
00205   const CalStripToStrip* muoncal = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00206   
00207   if(muoncal ==0) {
00208     if(fResPtr.GetNumRows()>0) {
00209       MAXMSG("Calib",Msg::kWarning,10) 
00210         << "StripToStripCalScheme: No database row for StripEnd " << seid.BuildPlnStripEndKey() << "\n";
00211       
00212      IncrementErrors(kStripCalibrator,kMissingRow,seid);
00213     }
00214     
00215     return sigcorr / correction * FloatErr(1,0.5); // Add 50% for unknown.
00216   }
00217   
00218   return sigcorr / correction * FloatErr(muoncal->GetResponse(), muoncal->GetResponseErr());
00219 }
00220 
00221 //......................................................................
00222 FloatErr StripToStripCalScheme::GetTemperatureCorrection() const
00223 {
00224   //======================================================================
00225   // Purpose: Do temperature correction
00226   //======================================================================
00227   
00228   float temp = Calibrator::Instance().GetTemperature();
00229   
00230   float correction = 1 - fTempCorFactor * (fRefTemp - temp);
00231   
00232   return 1./correction;
00233 
00234   MSG("Calib",Msg::kVerbose) << "Got Temperature Correction of: " 
00235                              << correction << endl;
00236 
00237 }
00238 
00239 

Generated on Fri Mar 28 15:40:16 2008 for loon by  doxygen 1.3.9.1