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

HoughTransNCPi0.cxx

Go to the documentation of this file.
00001 
00002 //
00003 // HoughTransCB
00004 //
00005 // Mark's hough transform.
00006 //
00007 // Created:  M. Dorman -- May, 2005
00008 //
00009 // $Author: dja25 $ 
00010 //
00011 // $Revision: 1.3 $
00012 // 
00013 // $Name:  $
00014 //
00015 // $Id: HoughTransNCPi0.cxx,v 1.3 2008/04/14 15:03:49 dja25 Exp $
00016 //
00018 
00019 #include "HoughTransNCPi0.h"
00020 #include <iostream>
00021 #include <cmath>
00022 #include "TCanvas.h"
00023 
00024 HoughTransNCPi0::HoughTransNCPi0()//:houghSpace("houghSpace","houghSpace",80,-2.0,2.0,80,-4.0,4.0),vtxz(0)
00025 {
00026   houghSpace = new TH2F("houghSpace","houghSpace",80,-2.0,2.0,80,-4.0,4.0);
00027   houghSpace->SetDirectory(0);
00028   vtxz = 0.0;
00029 }
00030 
00031 HoughTransNCPi0::~HoughTransNCPi0(){
00032   // Mark, you need to delete histograms created with new!!!
00033   delete houghSpace; houghSpace=0;
00034 
00035 }
00036 
00037 HoughTransNCPi0::HoughTransNCPi0(Int_t numSamps,Float_t lowGrad,Float_t highGrad)//:
00038 {
00039   
00040   houghSpace = new TH2F("houghSpace","houghSpace",numSamps,lowGrad,highGrad,numSamps,-4.0,4.0);
00041   houghSpace->SetDirectory(0);
00042   vtxz = 0.0;
00043 }
00044 
00045 HoughTransNCPi0::HoughTransNCPi0(Int_t numSamps,Float_t lowGrad,Float_t highGrad,Float_t lowIcept,Float_t highIcept)//:
00046 {
00047   houghSpace = new TH2F("houghSpace","houghSpace",numSamps,lowGrad,highGrad,numSamps,lowIcept,highIcept);
00048   houghSpace->SetDirectory(0);
00049   vtxz = 0.0;
00050 }
00051 
00052 void HoughTransNCPi0::SetVtxz(Float_t vertz)
00053 {
00054   vtxz=vertz;
00055 }
00056 
00057 Float_t HoughTransNCPi0::GetVtxz()
00058 {
00059   return vtxz;
00060 }
00061 
00062 void HoughTransNCPi0::FillHough(NtpSRStrip* stp)
00063 {
00064   FillHough(stp->z,stp->tpos);
00065 }
00066 
00067 void HoughTransNCPi0::FillHough(Float_t zPos, Float_t tPos)
00068 {       
00069   if(zPos<(vtxz)) return;
00070   for(Int_t i=1;i<=houghSpace->GetNbinsX();++i){
00071     Float_t cos=(houghSpace->GetXaxis())->GetBinCenter(i);
00072     Float_t icept=tPos-sqrt(pow((1/cos),2)-1)*(zPos-vtxz);
00073     if(icept>4.0 || icept<-4.0) continue; //max MINOS transverse dimensions
00074     houghSpace->Fill(cos,icept);
00075     // cout << "Filling Hough Space with grad " << gradient << " and icept " << icept << endl;
00076   }
00077 }
00078 void HoughTransNCPi0::FillHoughweight(Float_t zPos, Float_t tPos, Float_t energy)
00079 {
00080   if(zPos<vtxz) return;
00081   for(Int_t i=1;i<houghSpace->GetNbinsX();++i){
00082     Float_t gradient=(houghSpace->GetXaxis())->GetBinCenter(i);
00083     Float_t icept=tPos-gradient*(zPos-vtxz);
00084     Float_t weight= energy;
00085     if(icept>4.0 || icept<-4.0) continue; //max MINOS transverse dimensions
00086     houghSpace->Fill(gradient,icept,weight);
00087     // cout << "Filling Hough Space with grad " << gradient << " and icept " << icept << endl;
00088   }
00089 }
00090 void HoughTransNCPi0::DrawHough()
00091 {
00092   //TFile f("hough.root",new");
00093   houghSpace->Draw("LEGO2");
00094   //  houghSpace->Write();
00095 }
00096 
00097 Int_t HoughTransNCPi0::EntriesHough()
00098 {
00099   Int_t counts = static_cast<Int_t>(houghSpace->Integral());
00100   return counts;
00101 }
00102 
00103 void HoughTransNCPi0::ResetHough()
00104 {
00105   houghSpace->Reset();
00106 }
00107 
00108 void HoughTransNCPi0::DeleteHough()
00109 {
00110   delete houghSpace;
00111 }
00112 
00113 Int_t HoughTransNCPi0::GetPeakHeight()
00114 {
00115   Int_t binmax = static_cast<Int_t>(houghSpace->GetBinContent(houghSpace->GetMaximumBin()));
00116   return binmax;
00117 }
00118 
00119 Int_t HoughTransNCPi0::GetPeakGradBin()
00120 {
00121   Int_t x=0;
00122   Int_t y=0;
00123   Int_t z=0;
00124   houghSpace->GetMaximumBin(x,y,z);
00125   return x;
00126 }
00127 
00128 Int_t HoughTransNCPi0::GetPeakIceptBin()
00129 {
00130   Int_t x=0;
00131   Int_t y=0;
00132   Int_t z=0;
00133   houghSpace->GetMaximumBin(x,y,z);
00134   return y;
00135 }
00136 
00137 Float_t HoughTransNCPi0::GetPeakGradVal()
00138 {
00139   Int_t x=0;
00140   Int_t y=0;
00141   Int_t z=0;
00142   houghSpace->GetMaximumBin(x,y,z);
00143   return (houghSpace->GetXaxis())->GetBinCenter(x);
00144 }
00145 
00146 Float_t HoughTransNCPi0::GetPeakIceptVal()
00147 {
00148   Int_t x=0;
00149   Int_t y=0;
00150   Int_t z=0;
00151   houghSpace->GetMaximumBin(x,y,z);
00152   return (houghSpace->GetYaxis())->GetBinCenter(y);
00153 }
00154 
00155 Float_t HoughTransNCPi0::GetCos() 
00156 {
00157   Int_t binx, biny;
00158   Float_t x = 0.;
00159   Float_t y = 0;
00160   Float_t peak = 0.;
00161   
00162   peak = houghSpace->GetBinContent(houghSpace->GetMaximumBin());
00163   
00164   for (biny=houghSpace->GetYaxis()->GetFirst();biny<=houghSpace->GetYaxis()->GetLast();++biny) {
00165     for (binx=houghSpace->GetXaxis()->GetFirst();binx<=houghSpace->GetXaxis()->GetLast();++binx) {
00166       if (houghSpace->GetBinContent(binx,biny) == peak) {
00167         x = houghSpace->GetXaxis()->GetBinCenter(binx);
00168         y = houghSpace->GetYaxis()->GetBinCenter(biny);
00169         //      continue; 
00170       }
00171     }
00172   }
00173    
00174 
00175   return x;
00176 }
00177 Float_t HoughTransNCPi0::GetGradientweight()
00178 {
00179   Int_t binx, biny;
00180   Float_t x =0.;
00181   Float_t y=0.;
00182   Float_t peak = 0.;
00183   
00184   peak = houghSpace->GetBinContent(houghSpace->GetMaximumBin());
00185   
00186   for (biny=houghSpace->GetYaxis()->GetFirst();biny<=houghSpace->GetYaxis()->GetLast();++biny) {
00187     for (binx=houghSpace->GetXaxis()->GetFirst();binx<=houghSpace->GetXaxis()->GetLast();++binx) {
00188       if (houghSpace->GetBinContent(binx,biny) == peak) {
00189         x = houghSpace->GetXaxis()->GetBinCenter(binx);
00190         y = houghSpace->GetYaxis()->GetBinCenter(biny);
00191         //      continue; 
00192       }
00193     }
00194   }
00195   
00196   
00197   return x;
00198 }
00199 
00200 Float_t HoughTransNCPi0::GetTransverseVtxCoord() 
00201 {
00202   Int_t binx, biny;
00203   Float_t x =0.;
00204   Float_t y =0.;
00205   Float_t peak = 0.;
00206   
00207   peak = houghSpace->GetBinContent(houghSpace->GetMaximumBin());
00208   
00209   for (biny=houghSpace->GetYaxis()->GetFirst();biny<=houghSpace->GetYaxis()->GetLast();++biny) {
00210      for (binx=houghSpace->GetXaxis()->GetFirst();binx<=houghSpace->GetXaxis()->GetLast();++binx) {
00211        if (houghSpace->GetBinContent(binx,biny) == peak) {
00212          x = houghSpace->GetXaxis()->GetBinCenter(binx);
00213          y = houghSpace->GetYaxis()->GetBinCenter(biny);
00214          //     continue; 
00215        }
00216      }
00217   }
00218   
00219   
00220   return y;
00221 }
00222 
00223 Float_t HoughTransNCPi0::GetIntercept() 
00224 {
00225   
00226   Float_t intercept = GetTransverseVtxCoord() - sqrt(pow((1/GetCos()),2)-1)*GetVtxz();
00227   
00228   return intercept;
00229 }
00230 
00231 Float_t HoughTransNCPi0::GetRms(Float_t frac)
00232 {
00233   Int_t bincount = 0;
00234   Int_t mRmsInput[6400];
00235   Int_t cRmsInput[6400];
00236   Float_t peakheight = GetPeakHeight();
00237   Float_t cos = GetCos();
00238   Float_t interc = GetIntercept();
00239   Float_t mpeak = 0;
00240   Float_t cpeak = 0;
00241   Float_t contents = 0;
00242   
00243   for(Int_t mBin=1;mBin<houghSpace->GetNbinsX();++mBin){
00244     for(Int_t cBin=1;cBin<houghSpace->GetNbinsY();++cBin){
00245       if(houghSpace->GetBinContent(mBin,cBin)>=frac*peakheight){
00246         mpeak = (houghSpace->GetXaxis())->GetBinCenter(mBin);
00247         contents = houghSpace->GetBinContent(mBin,cBin);
00248         cpeak = (houghSpace->GetYaxis())->GetBinCenter(cBin);
00249         //cout<< "mpeak " << mpeak << endl;
00250         //cout<< "contents = " << contents << endl;
00251         //cout<< "cpeak " << cpeak << endl;
00252         //cout << "m_av " << grad << endl;
00253         //cout << "c_av " << interc << endl;
00254         
00255         mRmsInput[bincount]=static_cast<Int_t>(mpeak);
00256         cRmsInput[bincount]=static_cast<Int_t>(cpeak); 
00257         bincount++;
00258       }
00259     }
00260   }
00261   if(bincount==0) return 0;
00262   Float_t squaresum = 0;
00263   for (Int_t count=1;count<bincount;++count) {
00264     squaresum+=(pow((mRmsInput[count]-cos),2)+pow((cRmsInput[count]-interc),2));
00265     
00266   }
00267   Float_t Rms = sqrt(squaresum/bincount);
00268   return Rms;
00269 }

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