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

MIPCalScheme.cxx

Go to the documentation of this file.
00001 
00002 // $Id: MIPCalScheme.cxx,v 1.9 2005/03/22 12:29:52 tagg Exp $
00003 //
00004 // Prototype MIP Calibrator class
00005 //
00006 // rjn@hep.ucl.ac.uk
00007 // Rebuild n.tagg1@physics.ox.ac.uk 07/04
00008 //
00009 // Jeff Hartnell (Oct/04):
00010 // Added new MIPCalMethod config scheme to allow better usage 
00011 // of task in database 
00013 #include "MIPCalScheme.h"
00014 #include "MessageService/MsgService.h"
00015 #include "Plex/PlexSEIdAltL.h"
00016 #include "Plex/PlexStripEndId.h"
00017 #include "DatabaseInterface/DbiValidityRec.h"
00018 #include "Validity/VldRange.h"
00019 
00020 ClassImp(MIPCalScheme)
00021 CVSID("$Id: MIPCalScheme.cxx,v 1.9 2005/03/22 12:29:52 tagg Exp $");
00022 
00023 //......................................................................
00024 MIPCalScheme::MIPCalScheme()
00025 {
00026  MSG("Calib",Msg::kVerbose) << "MIPCalScheme::MIPCalScheme" 
00027                                    << endl;
00028  Registry r;
00029  r.Set("defaultSigCorPerMip",565.0);
00030  r.Set("MIPCalMethod","TrackWindow");
00031  InitializeConfig(r);
00032 }
00033 
00034 //......................................................................
00035 FloatErr  MIPCalScheme::GetMIP(FloatErr sigcor,
00036                            const PlexStripEndId& seid) const
00037 {
00050   
00051   // If there is more than one row in the table, look up the seid
00052   // Otherwise, assume that the first row applies to the whole detector.
00053 
00054   const CalMIPCalibration* mipcal;
00055   
00056 
00057   if(fResPtr.GetNumRows()==1) {
00058     // There is only one row. Use it.
00059     mipcal = fResPtr.GetRow(0);
00060   } else { 
00061     if(!seid.IsValid()) {
00062       // We've been given no particular strip end. Use the first row
00063       mipcal = fResPtr.GetRow(0);
00064     } else {
00065       // Use the row for this particular strip end.
00066       mipcal = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00067     }
00068   }
00069 
00070   if(mipcal ==0) {
00071     if(fResPtr.GetNumRows()>0) {
00072       MAXMSG("Calib",Msg::kWarning,10) 
00073         << "MIPCalScheme: No database row for StripEnd " << seid.AsString() << "\n";
00074       
00075       IncrementErrors(kMIPCalibrator,kMissingRow,seid);
00076     }
00077     
00078     return sigcor / (float)fDefaultSigCorPerMip;
00079   }
00080   
00081   return sigcor / mipcal->GetScale();
00082 }
00083 
00084 
00085 //......................................................................
00086 FloatErr MIPCalScheme::DecalMIP(FloatErr mip,   
00087                             const PlexStripEndId& seid) const
00088 {
00101   
00102   // If there is more than one row in the table, look up the seid
00103   // Otherwise, assume that the first row applies to the whole detector.
00104 
00105   const CalMIPCalibration* mipcal;
00106   
00107   if(fResPtr.GetNumRows()==1) {                
00108     // Return the only row
00109     mipcal = fResPtr.GetRow(0);
00110   } else {
00111     if(!seid.IsValid()) {
00112       // We've been handed 'no row in particular'. Use the first one.
00113       mipcal = fResPtr.GetRow(0);
00114     } else {
00115       // Use the row given.
00116       mipcal = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00117     }
00118   }
00119 
00120   if(mipcal ==0) {
00121     if(fResPtr.GetNumRows()>0) {
00122       MAXMSG("Calib",Msg::kWarning,10) 
00123         << "MIPCalScheme: No database row for StripEnd " << seid.AsString() << "\n";
00124       
00125       IncrementErrors(kMIPCalibrator,kMissingRow,seid);
00126     }
00127 
00128     return mip * (float)fDefaultSigCorPerMip;
00129   }
00130   
00131   
00132   return mip * mipcal->GetScale();
00133 }
00134 
00135 //.....................................................................
00136 void MIPCalScheme::DoReset( const VldContext& context )
00137 {
00138   MSG("Calib",Msg::kVerbose) << "MIPCalScheme::DoReset()" << endl;
00139   
00140   fResPtr.NewQuery(context,fTask);
00141   
00142   if(fResPtr.GetNumRows()==0) {
00143     MAXMSG("Calib",Msg::kWarning,10) 
00144       << "No rows in database table with validity context "
00145       << context.AsString() << "  No calibration will be applied." << endl;
00146     IncrementErrors(kMIPCalibrator,kMissingTable);
00147   }  
00148 }
00149 
00150 //.....................................................................
00151 void MIPCalScheme::ConfigModified()
00152 {                                               
00156   bool ok = true;
00157   ok=ok && GetConfig().Get("defaultSigCorPerMip",fDefaultSigCorPerMip);
00158 
00159   const char* str_source;
00160   ok=ok && GetConfig().Get("MIPCalMethod",str_source);
00161   if(strncasecmp(str_source,"cosmic",6)==0) fTask=0;
00162   else if(strncasecmp(str_source,"paul",4)==0) fTask=1;
00163   else if(strncasecmp(str_source,"ps",2)==0) fTask=2;
00164   else if(strncasecmp(str_source,"alt",3)==0) fTask=3;
00165   else if(strncasecmp(str_source,"TrackWindow",6)==0) fTask=10;
00166   else {
00167     MSG("Calib",Msg::kError) 
00168       <<"I don't understand the MIPCalMethod setting: "
00169       <<str_source<<endl;
00170     MSG("Calib",Msg::kError)
00171       <<"Valid settings are: TrackWindow, Cosmics, Paul's Cosmics, PS muons, and Alternative PS muons"<<endl;
00172     MSG("Calib",Msg::kError) 
00173       <<"Defaulting to MIPCalMethod=window"<<endl;
00174     fTask=10;
00175   }
00176 
00177   if(!ok) MSG("Calib",Msg::kError)
00178     <<"Problem configuring MIPCalScheme."<<endl;
00179 
00180   // Force a re-query of the DB for this event.
00181   this->Reset(GetContext(),true); 
00182 }
00183 
00184 //.....................................................................
00185 void MIPCalScheme::PrintConfig( std::ostream& os ) const
00186 {
00187   os<<"  Using MIPCalMethod="<<GetConfig().GetCharString("MIPCalMethod")
00188     <<" (DB task="<<fTask<<")"<<endl
00189     <<"  Default SigCor/SigMap per MIP="<<fDefaultSigCorPerMip<<endl;
00190 }
00191 
00192 

Generated on Tue Nov 3 23:20:04 2009 for loon by  doxygen 1.3.9.1