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

DmxChiSqrStat.cxx

Go to the documentation of this file.
00001 
00002 //$Id: DmxChiSqrStat.cxx,v 1.28 2002/10/03 21:22:48 brebel Exp $
00003 //
00004 //DmxChiSqrStat.cxx
00005 //
00006 //DmxChiSqrStat is a Statistic class returning a Chi^2 statistic
00007 //
00008 //Author:  B. Rebel 6/2000
00010 
00011 #include <iostream>
00012 #include "DeMux/DmxChiSqrStat.h"
00013 #include "MessageService/MsgService.h"
00014 #include "MessageService/MsgFormat.h"
00015 #include "DeMux/DmxRMSStat.h"
00016 #include "TMath.h"
00017 
00018 ClassImp(DmxChiSqrStat)
00019 
00020 //______________________________________________________________________
00021 //CVSID("$Id: DmxChiSqrStat.cxx,v 1.28 2002/10/03 21:22:48 brebel Exp $");
00022 
00023 //----------------------------------------------------------------------
00024 DmxChiSqrStat::DmxChiSqrStat() 
00025 {
00026 }
00027 
00028 //----------------------------------------------------------------------
00029 DmxChiSqrStat::DmxChiSqrStat(Float_t *SignalW, Float_t *SignalE, Float_t CoG) :
00030   fChi2(0.),
00031   fRms(-1.),
00032   fPredictor(0.)
00033 {
00034 
00035   Float_t sumW = 0.;
00036   Float_t sumE = 0.;
00037 
00038   //sum up the signal on sides W and E 
00039 
00040   for(Int_t i = 0; i < 192; i++ ){
00041     sumE += SignalE[i];
00042     sumW += SignalW[i];
00043   }
00044   
00045   //check to see if we can initialize the predictor as sumE / sumW.  if not
00046   //set it = 0.
00047   
00048   if(sumW > 0.) { fPredictor = sumE / sumW; }
00049     
00050   //MSG("DmxHyp", Msg::kInfo) << "predictor\t" << fPredictor << endl;
00051 
00052   //MSG("DmxHyp", Msg::kInfo) << "DmxChiSqrStat calculating goodness of fit" 
00053   //        << endl << endl;
00054 
00055 
00056   //this loop finds the chi^2 statistic for the signal and strip information
00057   //passed to the constructor.  the statistic is
00058   //
00059   //   chi^2 = SUM[ (RW_i - E_i)^2 / (W_i^2 + E_i^2) ]
00060   //
00061   //where R is fPredictor and W_i, E_i is the signal for strip i. 
00062 
00063   if( fPredictor > 0. ){
00064     for(Int_t j = 0; j < 192; j++){
00065       if(SignalW[j] > 0. || SignalE[j] > 0.){
00066         fChi2 += (((fPredictor * SignalW[j]) - SignalE[j]) * ((fPredictor * SignalW[j]) - SignalE[j])) / 
00067           ((SignalW[j] * SignalW[j]) + (SignalE[j] * SignalE[j]));
00068         //MSG("DmxHyp", Msg::kInfo) <<"strip = " << j << "\tchi^2 = " << fChi2 << "\tpredicter = " 
00069         //  << fPredictor << "\tW = " << SignalW[j] 
00070         //  << "\tE = " << SignalE[j] << endl;
00071       }
00072     }
00073   }
00074   else{ fChi2 = 10000.; }
00075   //MSG("DmxHyp", Msg::kInfo) << "chi^2 = " << fChi2 <<endl;
00076 
00077   //find the tiebreaker
00078   DmxRMSStat rms = DmxRMSStat(SignalW, SignalE, CoG);
00079    
00080   fRms = rms.GetGoodness();
00081 
00082   return;
00083 
00084 }
00085 
00086 //-----------------------------------------------------------------------
00087 DmxChiSqrStat::~DmxChiSqrStat()
00088 {
00089   //MSG("Dmx", Msg::kVerbose) << "deleting DmxChiSqrObject" << endl;
00090 }
00091 
00092 
00093 //-----------------------------------------------------------------------
00094 Float_t DmxChiSqrStat::GetGoodness() const
00095 {
00096   
00097   return fChi2;
00098 }
00099 
00100 //-----------------------------------------------------------------------
00101 Float_t DmxChiSqrStat::GetPredictor() const
00102 {
00103   return fPredictor;
00104 }
00105 
00106 //-----------------------------------------------------------------------
00107 //the following method returns the rms of the reconstruction for use
00108 //as a tiebreaker if the chi^2 stat is the same for two signal/strip 
00109 //combinations
00110 
00111 Float_t DmxChiSqrStat::GetTieBreaker() const 
00112 {
00113   return fRms;
00114 }
00115 
00116 //------------------------------------------------------------------------
00117 void DmxChiSqrStat::SetPredictor(Float_t predictor)
00118 {
00119   fPredictor = predictor;
00120 }
00121  
00122   
00123   
00124 
00125 
00126 
00127 
00128 
00129 
00130 

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