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

CalScheme.h

Go to the documentation of this file.
00001 
00002 // CalScheme
00003 //
00004 // Abstract base class for mid-level calibrator class. 
00005 //
00006 // n.tagg1@physics.ox.ac.uk  N Tagg 2004, 
00007 //
00008 //
00009 //
00010 // $Id: CalScheme.h,v 1.9 2005/03/22 12:22:14 tagg Exp $
00012 
00013 #ifndef CALSCHEME_H
00014 #define CALSCHEME_H
00015 
00016 #include <iostream>
00017 #include <sstream>
00018 #include <TObject.h>
00019 #include "GenericThingId.h"
00020 #include "MessageService/Msg.h"
00021 #include "MessageService/MsgStream.h"
00022 #include "Validity/VldContext.h"
00023 #include "Configurable/CfgPromptConfigurable.h"
00024 #include "Conventions/CalDigitType.h"
00025 #include "Plex/PlexStripEndId.h"
00026 #include "RawData/RawChannelId.h"
00027 #include "Plex/PlexCalib.h"
00028 #include "Plex/PlexSEIdAltLItem.h"
00029 #include "ValueErr.h"
00030 
00031 class CalScheme : public TObject, public CfgPromptConfigurable
00032 {
00033  public:
00034   // NB. Use your constructor to create your default configuration, 
00035   // then set it with InitialzeConfig()
00036 
00037   CalScheme();
00038   virtual ~CalScheme();
00039   
00040   // Interface:
00041   // All of these methods are dummy classes that will cause a
00042   // big crash if used. Override these methods to actually do things.
00043 
00044   // Calibration methods.
00045   virtual  DoubleErr GetCalibratedTime(DoubleErr rawtime, FloatErr charge,  const PlexStripEndId& seid) const;         
00046   virtual  FloatErr  GetPhotoElectrons(FloatErr rawcharge, const PlexStripEndId& seid) const;
00047   virtual  FloatErr  GetLinearizedVA(FloatErr rawcharge, const RawChannelId& rcid) const;
00048   virtual  FloatErr  GetDriftCorrected(FloatErr rawcharge, const PlexStripEndId& seid) const;
00049   virtual  FloatErr  GetLinearized(FloatErr sigdrift,      const PlexStripEndId& seid) const;
00050   virtual  FloatErr  GetStripToStripCorrected(FloatErr siglin,           const PlexStripEndId& seid) const;
00051   virtual  FloatErr  GetAttenCorrected(FloatErr sigcorr, FloatErr stripX, const PlexStripEndId& seid) const;
00052   virtual  FloatErr  GetMIP(FloatErr sigmap,                        const PlexStripEndId& seid = PlexStripEndId()) const;
00053 
00054    // Decalibration methods
00055   virtual  DoubleErr DecalTime(DoubleErr caltime, FloatErr charge,  const PlexStripEndId& seid) const;      
00056   virtual  void      DecalGainAndWidth(FloatErr& gain, FloatErr& width, const PlexStripEndId& seid) const;
00057   virtual  void      DecalGainAndWidth(FloatErr& gain, FloatErr& width, const PlexPixelSpotId& psid) const;
00058   virtual  FloatErr  DecalVALinearity(FloatErr adc,                      const RawChannelId& rcid) const;
00059   virtual  FloatErr  DecalDrift(FloatErr undrifted,                    const PlexStripEndId& seid) const;
00060   virtual  FloatErr  DecalLinearity(FloatErr lin,                      const PlexStripEndId& seid) const;
00061   virtual  FloatErr  DecalStripToStrip(FloatErr sigcorr,               const PlexStripEndId& seid) const;
00062   virtual  FloatErr  DecalAttenCorrected(FloatErr sigmap,FloatErr stripX,const PlexStripEndId& seid) const;
00063   virtual  FloatErr  DecalMIP(FloatErr sigmip,                         const PlexStripEndId& seid = PlexStripEndId()) const;
00064 
00065   // Other things, not really calibrations:
00066   virtual  Float_t GetTemperature(Int_t mode = 0) const;
00067 
00068  protected:
00069   // Override this method to do your own things on a context change (i.e. table.NewQuery()).
00070   virtual void      DoReset( const VldContext&  ) {};
00071 
00072   // Configuration system. Override this to do stuff when config changes..
00073   virtual void      ConfigModified(){};              // Perform changes the current configuration.
00074 
00075  public:
00076   // Override this to print out your configuration:
00077   virtual void      PrintConfig( std::ostream& os ) const;
00078   
00080   // Things this class does:
00081   
00082   // Context stuff:
00083   void              Reset( const VldContext& context, Bool_t force=false );
00084   const VldContext& GetContext(void) const { return fContext; };
00085 
00086   // I/O stuff:
00087   void PrintConfig( MsgStream& ms ) const;
00088   void PrintConfig() const; // Prints to default stream.
00089 
00090   void  PrintErrorStats( std::ostream& os ) const;
00091   void  PrintErrorStats( MsgStream& ms ) const;
00092   void  PrintErrorStats() const; // Prints to default stream.
00093 
00094 
00095   friend  std::ostream& operator<<(std::ostream& os, const CalScheme& s);
00096 
00097  private:
00098   VldContext fContext;
00099   void Unimplimented() const;
00100 
00101  public:
00102   typedef enum ESchemeType {
00103     kUnknown   = 0,
00104     kTimeCalibrator,
00105     kPeCalibrator,
00106     kVALinCalibrator,
00107     kLinCalibrator,
00108     kDriftCalibrator,
00109     kStripCalibrator,
00110     kAttenCalibrator,
00111     kMIPCalibrator,
00112     kThermometer,
00113     kNumberOfSchemeTypes
00114   } SchemeType_t;
00115 
00116   static const char* SchemeTypeName(int t) {
00117     static const char* sTypeNames[] = {
00118       "Unknown",
00119       "TimeCalibrator",
00120       "PeCalibrator",
00121       "VALinCalibrator",
00122       "LinCalibrator",
00123       "DriftCalibrator",
00124       "StripCalibrator",
00125       "AttenCalibrator",
00126       "MIPCalibrator",
00127       "Thermometer",
00128       "???"};
00129     return sTypeNames[t%kNumberOfSchemeTypes];
00130   };
00131 
00132   static const char* UnitName(int t) {
00133     static const char* sUnitNames[] = {
00134       "Unknown",
00135       "Seconds",
00136       "PE",
00137       "ADC",
00138       "SigLin",
00139       "SigDrift",
00140       "SigCorr",
00141       "SigMap",
00142       "SigMip",
00143       "C",
00144       "???"};
00145     return sUnitNames[t%kNumberOfSchemeTypes];
00146   };
00147   
00148 
00149   typedef enum EErrorType {
00150     kGeneralErr   = 0,    // Catch-all catagory
00151     kMissingTable = 1, // Table was completely empty for context
00152     kMissingRow   = 2, // Table didn't have requested entry
00153     kFPE          = 3, // Computation generated illegal quantity.
00154     kDataInsufficient = 4,
00155     kBadInput = 5,
00156     kNumberOfErrorTypes
00157   } ErrorType_t;
00158   
00159  protected:
00160 
00161   static void ResetStatistics();
00162   static void IncrementErrors(SchemeType_t, ErrorType_t = kGeneralErr);
00163   static void IncrementErrors(SchemeType_t, ErrorType_t, const GenericThingId& thing);
00164   static void IncrementErrors(SchemeType_t, ErrorType_t, Int_t genericId);
00165   static void IncrementErrors(SchemeType_t, ErrorType_t, const RawChannelId& rcid);
00166   static void IncrementErrors(SchemeType_t, ErrorType_t, const PlexPixelSpotId& psid);
00167   static void IncrementErrors(SchemeType_t, ErrorType_t, const PlexStripEndId& seid);
00168   static void IncrementErrors(SchemeType_t, ErrorType_t, const PlexLedId& led);
00169 
00170   static void IncrementCalls(SchemeType_t);
00171   
00172  private:
00173   static Int_t             fsCalls[kNumberOfSchemeTypes]; // !
00174   static Int_t             fsErrors[kNumberOfSchemeTypes][kNumberOfErrorTypes]; // !
00175   static std::map<GenericThingId,int> fsChannelErrors; // !
00176   
00177   ClassDef(CalScheme,0);
00178 };
00179 
00180 
00181 
00182 #endif

Generated on Mon Feb 15 11:06:27 2010 for loon by  doxygen 1.3.9.1