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

VaLinearityCalScheme.cxx

Go to the documentation of this file.
00001 
00002 // $Id: VaLinearityCalScheme.cxx,v 1.4 2005/08/19 03:03:58 tagg Exp $
00003 //
00004 // Scheme to linearize PIN channels on VA (far detector)
00005 // Interface to G. Barr's CalVaLinearity table.
00006 //
00007 // Can in principle be applied to any VA channel, but usually
00008 // only PIN-diodes are linearized this way.
00009 //
00010 //
00011 // n.tagg1@physics.ox.ac.uk
00013 #include "VaLinearityCalScheme.h"
00014 
00015 #include "Calibrator.h"
00016 #include "MessageService/MsgService.h"
00017 #include "Plex/PlexSEIdAltL.h"
00018 #include "Plex/PlexStripEndId.h"
00019 #include "DatabaseInterface/DbiValidityRec.h"
00020 #include "Validity/VldRange.h"
00021 
00022 ClassImp(VaLinearityCalScheme)
00023 CVSID("$Id: VaLinearityCalScheme.cxx,v 1.4 2005/08/19 03:03:58 tagg Exp $");
00024 
00025 //......................................................................
00026 VaLinearityCalScheme::VaLinearityCalScheme()
00027 {
00031   MSG("Calib",Msg::kVerbose) << "VaLinearityCalScheme::VaLinearityCalScheme" 
00032                              << endl;
00033   Registry r;
00034   r.Set("Task","PinsOnly");
00035   InitializeConfig(r);
00036 }
00037 
00038 //......................................................................
00039 void VaLinearityCalScheme::DoReset( const VldContext& vc )
00040 {
00044 
00045   MSG("Calib",Msg::kVerbose) << "VaLinearityCalScheme::DoReset()" << endl;
00046 
00047   fResPtr.NewQuery(vc,fTask);
00048   if(fResPtr.GetNumRows()==0) {
00049     MAXMSG("Calib",Msg::kWarning,10) 
00050       << "VaLinearity Scheme: No rows in CALVALINEARITY database table"
00051       << vc.AsString() << ".\n";         
00052     IncrementErrors(kVALinCalibrator,kMissingTable);
00053   }
00054 }
00055 
00056 //......................................................................
00057 void VaLinearityCalScheme::ConfigModified()
00058 {
00062   bool ok = true;
00063   const char* taskname;
00064   ok = ok && GetConfig().Get("Task",taskname);
00065 
00066   if     (0==strcasecmp(taskname,"PinsOnly" )) fTask = 0;
00067   else if(0==strcasecmp(taskname,"All"))       fTask = 1;
00068   else ok = false;
00069 
00070   if(!ok) MSG("Calib",Msg::kError) << "Problem setting up VaLinearityCalScheme config." << endl;
00071   
00072   // Ensure that the DB has been changed for this event.
00073   Reset(GetContext(),true); 
00074 }
00075 
00076 
00077 //......................................................................
00078 void VaLinearityCalScheme::PrintConfig( std::ostream& os ) const
00079 {
00080   os << " VaLinearityCalScheme " << endl;
00081   os << " Task: " << GetConfig().GetCharString("Task");
00082 }
00083 
00084 
00085 
00086 
00087 //......................................................................
00088 FloatErr  VaLinearityCalScheme::GetLinearizedVA(FloatErr rawcharge, 
00089                                                 const RawChannelId& rcid) const
00090 {
00102 
00103   // Reject stupid inputs:
00104   if(rcid.IsNull()) return rawcharge;
00105   if(rcid.GetElecType()!=ElecType::kVA) return rawcharge;
00106 
00107   // Get Row ID:
00108   UInt_t idx = CalVaLinearity::Rcid2Index(rcid);
00109   
00110   const CalVaLinearity* row = fResPtr.GetRowByIndex(idx);
00111 
00112   if(row==0) {
00113     if(fResPtr.GetNumRows()>0) {
00114       MAXMSG("Calib",Msg::kWarning,10) 
00115         << "VaLinearityCalScheme: No database row for RawChannelId" << rcid.AsString() 
00116         << "  Idx:" << Form("%08x",idx) << std::endl;      
00117       IncrementErrors(kVALinCalibrator,kMissingRow,rcid);
00118     }
00119     return rawcharge * FloatErr(1,0.5);
00120   }
00121   
00122   return row->Linearize(rawcharge);
00123 }
00124 
00125 
00126 //......................................................................
00127 FloatErr VaLinearityCalScheme::DecalVALinearity(FloatErr lincharge, 
00128                                                 const RawChannelId& rcid) const
00129 {
00142 
00143   // Reject stupid inputs:
00144   if(rcid.IsNull()) return lincharge;
00145   if(rcid.GetElecType()!=ElecType::kVA) return lincharge;
00146   
00147 
00148   // Get Row ID:
00149   UInt_t idx = CalVaLinearity::Rcid2Index(rcid);
00150   
00151   const CalVaLinearity* row = fResPtr.GetRowByIndex(idx);
00152 
00153   if(row==0) {
00154     if(fResPtr.GetNumRows()>0) {
00155       MAXMSG("Calib",Msg::kWarning,10) 
00156         << "VaLinearityCalScheme: No database row for RawChannelId" << rcid.AsString() 
00157         << "  Idx:" << Form("%08x",idx) << std::endl;      
00158       IncrementErrors(kVALinCalibrator,kMissingRow,rcid);
00159     }
00160     return lincharge * FloatErr(1,0.5);
00161   }
00162   
00163   return row->UnLinearize(lincharge);
00164 }

Generated on Fri Mar 28 15:41:48 2008 for loon by  doxygen 1.3.9.1