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

PEGainSummary.cxx

Go to the documentation of this file.
00001 
00002 
00004 //#include <cstdio>
00005 #include "PEGain/PEGainSummary.h"
00006 #include "MessageService/MsgService.h"     // MSG text output
00007 
00008 #include <cassert>
00009 #include <cmath>
00010 
00011 ClassImp(PEGainSummary)
00012 
00013 CVSID("$Id: PEGainSummary.cxx,v 1.3 2006/05/27 09:49:04 rhatcher Exp $");
00014 
00015 //......................................................................
00016 
00017 PEGainSummary::PEGainSummary()
00018    :fGotNear(0),fGotFar(0),fEncodedStrip(-1)//,fBestSide(-1)
00019 {
00020 
00021    MSG("PEGain",Msg::kVerbose) << "PEGainSummary::PEGainSummary()\n";
00022 
00023 }
00024 //......................................................................
00025 
00026 PEGainSummary::~PEGainSummary()
00027 {
00028 
00029    MSG("PEGain",Msg::kVerbose) << "PEGainSummary::~PEGainSummary()\n";
00030 
00031 }
00032 //......................................................................
00033 
00034 void PEGainSummary::AddNearEnd(const PulserSummary &ps, const PlexStripEndId &seid)
00035 {
00036    MSG("PEGain",Msg::kVerbose) << "PEGainSummary::AddNearEnd()\n";
00037    
00038    if(fGotNear==1) {
00039       MSG("PEGain",Msg::kWarning) << "I've already got a near end for : "
00040                                   << seid << endl;
00041    }
00042    else {
00043       if(fEncodedStrip==-1) {
00044          fSeid=seid;
00045          fEncodedStrip=seid.BuildPlnStripEndKey();
00046       }
00047       else assert(seid.BuildPlnStripEndKey()==fEncodedStrip);
00048       fNearEnd=ps;
00049       fGotNear=1;
00050    }
00051 }
00052 
00053 void PEGainSummary::AddFarEnd(const PulserSummary &ps, const PlexStripEndId &seid)
00054 {
00055    MSG("PEGain",Msg::kVerbose) << "PEGainSummary::AddFarEnd()\n";
00056    
00057    if(fGotFar==1) {
00058       MSG("PEGain",Msg::kWarning) << "I've already got a far end for : "
00059                                   << seid << endl;
00060    }
00061    else {
00062       if(fEncodedStrip==-1) {
00063          fSeid=seid;
00064          fEncodedStrip=seid.BuildPlnStripEndKey();
00065       }
00066       else assert(seid.BuildPlnStripEndKey()==fEncodedStrip);
00067       fFarEnd=ps;
00068       fGotFar=1;
00069    }
00070 }
00071 
00072 Float_t PEGainSummary::GetNearGain() const
00073 {
00074    MSG("PEGain",Msg::kVerbose) << "PEGainSummary::GetNearGain()\n";
00075    if(fGotNear) {
00076       Float_t tempRms=fNearEnd.GetRMS();
00077       Float_t tempMean=fNearEnd.GetMean();
00078 
00079       return (tempRms*tempRms/tempMean);
00080    }
00081    else return -1;
00082 }
00083 
00084 Float_t PEGainSummary::GetFarGain() const
00085 {
00086    MSG("PEGain",Msg::kVerbose) << "PEGainSummary::GetFarGain()\n";
00087    if(fGotFar) {
00088       Float_t tempRms=fFarEnd.GetRMS();
00089       Float_t tempMean=fFarEnd.GetMean();
00090 
00091       return (tempRms*tempRms/tempMean);
00092    }
00093    return -1;
00094 }
00095 
00096 Float_t PEGainSummary::GetNearError() const
00097 {
00098    MSG("PEGain",Msg::kVerbose) << "PEGainSummary::GetNearError()\n";
00099    if(fGotNear) {
00100       Float_t tempRms=fNearEnd.GetRMS();
00101       Float_t tempMean=fNearEnd.GetMean();
00102       Float_t tempNent=(float)fNearEnd.GetEntries();
00103       if(tempNent>1) {
00104          Float_t tempRmsErr=tempRms/sqrt(2.0*tempNent);
00105          Float_t tempMeanErr=tempRms/sqrt(tempNent-1);
00106          
00107          return sqrt(pow(2.0*tempRms/tempMean,2)*tempRmsErr*tempRmsErr
00108                      +pow(tempRms/tempMean,4)*tempMeanErr*tempMeanErr);
00109       }
00110       
00111    }
00112    return -1;
00113 }
00114 
00115 Float_t PEGainSummary::GetFarError() const
00116 {
00117    MSG("PEGain",Msg::kVerbose) << "PEGainSummary::GetFarError()\n";
00118    if(fGotFar) {
00119       Float_t tempRms=fFarEnd.GetRMS();
00120       Float_t tempMean=fFarEnd.GetMean();
00121       Float_t tempNent=(float)fFarEnd.GetEntries();
00122       if(tempNent>1) {
00123          Float_t tempRmsErr=tempRms/sqrt(2.0*tempNent);
00124          Float_t tempMeanErr=tempRms/sqrt(tempNent-1);
00125          
00126          return sqrt(pow(2.0*tempRms/tempMean,2)*tempRmsErr*tempRmsErr
00127                      +pow(tempRms/tempMean,4)*tempMeanErr*tempMeanErr);
00128       }
00129       
00130    }
00131    return -1;
00132 }
00133 
00134 Int_t PEGainSummary::GetBest() const {
00135    MSG("PEGain",Msg::kVerbose) << "PEGainSummary::SetBest()\n";
00136    if(fGotNear) {
00137       if(fNearEnd.GetEntries()>200) {
00138          if(fGotFar) {
00139             if(fFarEnd.GetEntries()>200) {
00140                // Got two chances;
00141                Int_t nearNent=fNearEnd.GetEntries();
00142                Int_t farNent=fFarEnd.GetEntries();
00143                Float_t nentRatio=float(nearNent)/float(farNent);
00144                if(nentRatio>1.1) {
00145                   //fBestSide=1;
00146                   return 1;
00147                }
00148                if(nentRatio<0.9) {
00149                   //fBestSide=2;
00150                   return 2;
00151                }
00152                Float_t nearMean=fNearEnd.GetMean();
00153                Float_t farMean=fFarEnd.GetMean();
00154                if(nearMean<8000 && nearMean>800) {
00155                    return 1;
00156                }
00157                if(farMean<8000 && farMean>800) {
00158                }
00159                if(fabs(nearMean-5000.0)<fabs(farMean-5000.0)) {
00160                   //fBestSide=1;
00161                   return 1;
00162                }
00163                else {
00164                   //fBestSide=2;
00165                   return 2;
00166                }
00167             }
00168          }
00169          // Only Near
00170          //fBestSide=1;
00171          return 1;
00172       }
00173       
00174    }
00175    else if(fGotFar) {
00176       if(fFarEnd.GetEntries()>200) {
00177          //fBestSide=2;
00178          return 2;
00179       }
00180       // Only Far
00181       
00182    }
00183    //fBestSide=0;
00184    return 0;
00185 }
00186 
00187 
00188 
00189 Float_t PEGainSummary::GetBestGain() const {
00190    MSG("PEGain",Msg::kVerbose) << "PEGainSummary::GetBestGain()\n";
00191    Int_t fBestSide = GetBest();
00192    //   if(fBestSide==-1) SetBest();
00193    if(fBestSide==1) {
00194       return GetNearGain();
00195    }
00196    else if(fBestSide==2) {
00197       return GetFarGain();
00198    }
00199    return -1;
00200 }
00201 
00202 
00203 Float_t PEGainSummary::GetBestError() const
00204 {
00205    MSG("PEGain",Msg::kVerbose) << "PEGainSummary::GetBestError()\n";
00206    Int_t fBestSide=GetBest();
00207    //   if(fBestSide==-1) SetBest();
00208    if(fBestSide==1) {
00209       return GetNearError();
00210    }
00211    else if(fBestSide==2) {
00212       return GetFarError();
00213    }
00214    return -1;
00215    
00216 }
00217    
00218 Float_t PEGainSummary::GetProperNearGain() const
00219 {
00220    return 0.8*GetNearGain();
00221 }
00222 Float_t PEGainSummary::GetProperFarGain() const
00223 {
00224    return 0.8*GetFarGain();
00225 }
00226 Float_t PEGainSummary::GetProperBestGain() const
00227 {
00228    return 0.8*GetBestGain();
00229 }
00230 Float_t PEGainSummary::GetProperNearError() const 
00231 {
00232    return 0.8*GetNearError();
00233 }
00234 Float_t PEGainSummary::GetProperFarError() const
00235 {
00236    return 0.8*GetFarError();
00237 }
00238 Float_t PEGainSummary::GetProperBestError() const
00239 {
00240    return 0.8*GetBestError();
00241 }

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