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

PulserPinScale.cxx

Go to the documentation of this file.
00001 
00002 // $Id: PulserPinScale.cxx,v 1.4 2004/11/15 13:03:07 west Exp $
00003 //
00004 // PulserPinScale
00005 //
00006 // Dbi object for raw drift point info
00007 //
00008 // Author: Phil Adamson 7/2004
00009 //
00010 // $Log: PulserPinScale.cxx,v $
00011 // Revision 1.4  2004/11/15 13:03:07  west
00012 // gcc 3.4: Replace DbiReader/DbiWriter.cxx -> .tpl and move after CVSID
00013 //
00014 // Revision 1.3  2004/11/04 22:17:37  phil.adamson
00015 // Minor fix for new calib
00016 //
00017 // Revision 1.2  2004/11/04 09:16:08  west
00018 // Add dummy versions of missing ctors and dtors
00019 //
00020 // Revision 1.1  2004/11/04 04:22:11  phil.adamson
00021 // Extra bits for new calibration
00022 //
00023 //
00025 
00026 #include "MessageService/MsgService.h"
00027 #include "PulserCalibration/PulserPinScale.h"
00028 #include "DatabaseInterface/DbiResultSet.h"
00029 #include "DatabaseInterface/DbiValidityRec.h"
00030 #include "TGraphErrors.h"
00031 #include "TF1.h"
00032 
00033 
00034 ClassImp(PulserPinScale)
00035 
00036   //........
00037 
00038 CVSID("$Id: PulserPinScale.cxx,v 1.4 2004/11/15 13:03:07 west Exp $");
00039   
00040 #include "DatabaseInterface/DbiResultPtr.tpl"
00041   template class DbiResultPtr<PulserPinScale>;
00042 #include "DatabaseInterface/DbiWriter.tpl"
00043   template class DbiWriter<PulserPinScale>;
00044 
00045 //  To be replaced: dummy ctor and dtor just to allow linking.
00046 PulserPinScale::PulserPinScale() {}
00047 PulserPinScale::~PulserPinScale() {}
00048 
00049 PulserPinScale::PulserPinScale(PulserGainPin &high, PulserGainPin &low, 
00050                                int aggNo)
00051 {
00052   fAggregateNo = aggNo;
00053   // Do fit here
00054   assert(high.GetNumPoints()==low.GetNumPoints());
00055   const Float_t *x_high=high.GetMean();
00056   const Float_t *ex_high=high.GetError();
00057   const Float_t *y_low = low.GetMean();  
00058   const Float_t *ey_low = low.GetError();  
00059 
00060   TGraphErrors g(high.GetNumPoints(),x_high,y_low,ex_high,ey_low);
00061   float xmin=300;
00062   float xmax = 8000;
00063 
00064   for (int i=0;i<high.GetNumPoints();i++) {
00065     if (y_low[i] < 300 && x_high[i]>300) xmin =x_high[i]+1;
00066     if (y_low[i] > 8000 && x_high[i] < 8000) {
00067       xmax = x_high[i]-1;
00068       break;
00069     }
00070   }
00071 
00072   TF1 f("line","[0]*x",xmin,xmax);
00073   g.Fit("line","QR");
00074   MSG("Pulser",Msg::kDebug)<<"Aggregate "<<aggNo<<" fit slope "<<f.GetParameter(0)<<endl;
00075 
00076   fHighGainScale = 1;
00077   fLowGainScale = 1.0/f.GetParameter(0);
00078 
00079 }
00080 
00081 
00082 PulserPinScale::PulserPinScale(float high, float low, int aggNo)
00083 {
00084   fHighGainScale = high;
00085   fLowGainScale = low;
00086   fAggregateNo = aggNo;
00087 }
00088 
00089 void PulserPinScale::Fill(DbiResultSet& rs,
00090                           const DbiValidityRec* /* vrec */)
00091 {
00092   rs >> fAggregateNo >> fHighGainScale >> fLowGainScale;
00093 
00094 } 
00095 
00096 void PulserPinScale::Store(DbiOutRowStream& ors,
00097                           const DbiValidityRec* /* vrec */) const
00098 {
00099     ors << fAggregateNo 
00100         << fHighGainScale 
00101         << fLowGainScale;
00102 }
00103 
00104 
00105 Float_t PulserPinScale::ScalePins(Float_t high, Float_t low) const
00106 {
00107   if (fHighGainScale<=0||high<0) {
00108     return fLowGainScale*low;
00109   }
00110   if (fLowGainScale<=0||low<0) {
00111     return fHighGainScale*high;
00112   }
00113   if (high>8000) {
00114     return fLowGainScale*low;
00115   }
00116   if (low<500 || low > 8000) {
00117     return fHighGainScale*high;
00118   }
00119   if (high< 500) {
00120     return fLowGainScale*low;
00121   }
00122   return 0.5*(fLowGainScale*low + fHighGainScale*high);
00123 
00124 }

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