NtpEventDisplayTiming Class Reference

#include <NtpEventDisplayTiming.h>

Inheritance diagram for NtpEventDisplayTiming:
NtpEventDisplay

List of all members.

Public Member Functions

 NtpEventDisplayTiming ()
 ~NtpEventDisplayTiming ()
void Initialize ()
void MakePicture (NtpStRecord *ntpRecord, Int_t ievent=0)
void PrintPicture ()
void PrintPictureGIF ()
void PrintPictureEPS ()

Private Member Functions

void DeleteMarkers ()

Private Attributes

TCanvas * fTimeCanvas
TCanvas * fTimeResiduals
TH2D * fTimeHist
TH1D * fTimeRes
TF1 * fTimeFit1
TF1 * fTimeFit2
TString fTitleString
TLatex fTitleLatex
TLine fTimeLine1
TLine fTimeLine2
Int_t fRun
Int_t fSnarl
Int_t fEvent
Int_t fPassFail
Double_t fSeedTime
Double_t fLength
Double_t fWindow
Double_t fInvBeta1
Double_t fVtxTime1
Double_t fInvBeta2
Double_t fVtxTime2
Double_t fMinTime
Double_t fMaxTime
Double_t fMinLength
Double_t fMaxLength
TMarker * fMarker
std::vector< TMarker * > fMarkerList

Detailed Description

Definition at line 20 of file NtpEventDisplayTiming.h.


Constructor & Destructor Documentation

NtpEventDisplayTiming::NtpEventDisplayTiming (  ) 

Definition at line 21 of file NtpEventDisplayTiming.cxx.

References Initialize().

00021                                              :
00022   fTimeCanvas(0),
00023   fTimeResiduals(0),
00024   fTimeHist(0),
00025   fTimeRes(0),
00026   fTimeFit1(0),
00027   fTimeFit2(0),
00028   fMarker(0)
00029 {
00030   this->Initialize();
00031 }

NtpEventDisplayTiming::~NtpEventDisplayTiming (  ) 

Definition at line 33 of file NtpEventDisplayTiming.cxx.

References fTimeCanvas, fTimeFit1, fTimeFit2, fTimeHist, fTimeRes, and fTimeResiduals.

00034 {
00035   if( fTimeCanvas )    delete fTimeCanvas;
00036   if( fTimeResiduals ) delete fTimeResiduals;
00037   if( fTimeHist )      delete fTimeHist;
00038   if( fTimeRes )       delete fTimeRes;
00039   if( fTimeFit1 )      delete fTimeFit1;
00040   if( fTimeFit2 )      delete fTimeFit2;
00041 } 


Member Function Documentation

void NtpEventDisplayTiming::DeleteMarkers (  )  [private]

Definition at line 106 of file NtpEventDisplayTiming.cxx.

References fMarker, fMarkerList, and Munits::m.

Referenced by MakePicture().

00107 {
00108   for( UInt_t m=0; m<fMarkerList.size(); m++ ){
00109     fMarker = (TMarker*)(fMarkerList.at(m));
00110     if( fMarker ) delete fMarker;
00111   }
00112 
00113   fMarkerList.clear();
00114 }

void NtpEventDisplayTiming::Initialize (  ) 

Definition at line 43 of file NtpEventDisplayTiming.cxx.

References fMarkerList, fTimeCanvas, fTimeFit1, fTimeFit2, fTimeHist, fTimeLine1, fTimeLine2, fTimeRes, fTimeResiduals, and fTitleLatex.

00044 {
00045   gStyle->SetOptStat(0);
00046   gStyle->SetPadBorderMode(0);
00047 
00048   fTimeCanvas = new TCanvas("TimeFitCanvas","TimeFitCanvas",800,800);
00049 
00050   fTimeResiduals = new TCanvas("TimeFitResiduals","TimeFitResiduals",800,800);
00051 
00052   fTimeHist = new TH2D("TimingPlot","",200,0.0,50.0,300,-50.0,250.0);
00053   fTimeHist->SetStats(kFALSE); fTimeHist->SetDirectory(0);
00054   fTimeHist->GetXaxis()->SetTitle("Distance / m");
00055   fTimeHist->GetXaxis()->CenterTitle();
00056   fTimeHist->GetYaxis()->SetTitle("Time / ns");
00057   fTimeHist->GetYaxis()->CenterTitle();
00058 
00059   fTimeRes = new TH1D("TimingResiduals","",200,-100.0,+100.0);
00060   fTimeRes->SetStats(kFALSE); fTimeRes->SetDirectory(0);
00061   fTimeRes->GetXaxis()->SetTitle("Time Residual / ns");
00062   fTimeRes->GetXaxis()->CenterTitle();
00063   fTimeRes->GetYaxis()->SetTitle("Strip Ends");
00064   fTimeRes->GetYaxis()->CenterTitle();
00065   fTimeRes->SetLineColor(4);
00066   fTimeRes->SetFillColor(4);
00067   fTimeRes->SetLineWidth(1);
00068 
00069   fTimeFit1 = new TF1("f1","[0]+[1]*x",0.0,50.0);
00070   fTimeFit1->SetLineWidth(2);
00071   fTimeFit1->SetLineColor(kRed);
00072   fTimeFit1->SetParameter(0,0.0); 
00073   fTimeFit1->SetParameter(1,1.0/0.3); 
00074 
00075   fTimeFit2 = new TF1("f2","[0]+[1]*x",0.0,50.0);
00076   fTimeFit2->SetLineWidth(2);
00077   fTimeFit2->SetLineColor(kBlack);
00078   fTimeFit2->SetParameter(0,0.0);
00079   fTimeFit2->SetParameter(1,1.0/0.3);
00080 
00081   fTitleLatex.SetTextFont(42);
00082   fTitleLatex.SetTextSize(0.04);
00083   fTitleLatex.SetTextAlign(11);
00084 
00085   fTimeLine1.SetLineWidth(3);
00086   fTimeLine1.SetLineColor(kRed); 
00087 
00088   fTimeLine2.SetLineWidth(3);
00089   fTimeLine2.SetLineColor(kBlack);
00090 
00091   fTimeCanvas->Draw();
00092   fTimeHist->Draw();
00093   fTimeFit1->Draw("same");
00094   fTimeFit2->Draw("same");
00095   fTimeCanvas->Update();
00096 
00097   fTimeResiduals->Draw();
00098   fTimeRes->Draw();
00099   fTimeResiduals->Update();
00100 
00101   fMarkerList.clear();
00102 
00103   return;
00104 }

void NtpEventDisplayTiming::MakePicture ( NtpStRecord ntpRecord,
Int_t  ievent = 0 
) [virtual]

Implements NtpEventDisplay.

Definition at line 116 of file NtpEventDisplayTiming.cxx.

References NtpTimingFit::AddEvent(), NtpTimingFit::CalcSeedTime(), DeleteMarkers(), fEvent, fInvBeta1, fInvBeta2, fLength, fMarker, fMarkerList, fMaxLength, fMaxTime, fMinLength, fMinTime, fPassFail, fRun, fSeedTime, fSnarl, fTimeCanvas, fTimeFit1, fTimeHist, fTimeLine1, fTimeRes, fTimeResiduals, fTitleLatex, fTitleString, fVtxTime1, fVtxTime2, fWindow, VldContext::GetDetector(), RecRecordImp< T >::GetHeader(), NtpTimingFit::GetLength(), NtpTimingFit::GetNumPoints(), RecDataHeader::GetRun(), NtpTimingFit::GetS(), RecPhysicsHeader::GetSnarl(), NtpTimingFit::GetT(), RecHeader::GetVldContext(), NtpTimingFit::Instance(), Detector::kNear, Munits::m, max, min, n, NtpTimingFit::Reset(), NtpTimingFit::RunConstrainedFit(), and NtpTimingFit::RunLinearFit().

00117 {
00118   // sanity check
00119   if( ntpRecord==0 ) return;
00120 
00121   // delete old markers
00122   this->DeleteMarkers();
00123 
00124   // reset residuals
00125   fTimeRes->Reset();
00126 
00127   // get event number
00128   fRun   = ntpRecord->GetHeader().GetRun();
00129   fSnarl = ntpRecord->GetHeader().GetSnarl();
00130   fEvent = ievent;
00131 
00132   fPassFail = 0;
00133   fSeedTime = 0.0;
00134   fLength  = 0.0;
00135   fWindow = 0.0;
00136 
00137   fInvBeta1 = 0.0;
00138   fVtxTime1 = 0.0;
00139 
00140   fInvBeta2 = 0.0;
00141   fVtxTime2 = 0.0;
00142 
00143   // create title
00144   fTitleString="";
00145   fTitleString.Append("Run: ");
00146   fTitleString+=fRun;
00147   fTitleString.Append("  ");
00148   fTitleString.Append("Snarl: ");
00149   fTitleString+=fSnarl;
00150   fTitleString.Append("  ");
00151   fTitleString.Append("Event: ");
00152   fTitleString+=fEvent;
00153 
00154   // add new event
00155   NtpTimingFit::Instance()->Reset();
00156   NtpTimingFit::Instance()->AddEvent(ntpRecord, ievent);
00157 
00158   // run timing fit
00159   fPassFail = NtpTimingFit::Instance()->RunConstrainedFit(fInvBeta1,fVtxTime1);
00160   fPassFail = NtpTimingFit::Instance()->RunLinearFit(fInvBeta2,fVtxTime2);
00161 
00162   // default limits
00163   fMinTime   = -50.0;
00164   fMaxTime   = +250.0;
00165   fMinLength = 0.0;
00166   fMaxLength = 50.0;
00167   fWindow    = 100.0;
00168 
00169   // plot events
00170   if( fPassFail ){
00171 
00172     // track direction
00173     Double_t ibeta = 0.0;
00174     if( fInvBeta1>0 ) ibeta = +1.0;
00175     if( fInvBeta1<0 ) ibeta = -1.0;
00176     
00177     // record seed time
00178     if( ibeta>=0.0 ) NtpTimingFit::Instance()->CalcSeedTime(+1,fSeedTime,fWindow);
00179     else             NtpTimingFit::Instance()->CalcSeedTime(-1,fSeedTime,fWindow);
00180 
00181     // calculate limits
00182     fLength = NtpTimingFit::Instance()->GetLength();
00183     fMinTime = -10.0;
00184     fMaxTime = +10.0+fLength/0.3;
00185     fMinLength = 0.0;
00186     fMaxLength = fLength + 0.1;
00187 
00188     if( ntpRecord->GetHeader().GetVldContext().GetDetector()==Detector::kNear ){
00189       fMinTime -= 20.0; fMaxTime += 20.0;
00190     }
00191 
00192     // create markers
00193     for( UInt_t n=0; n<NtpTimingFit::Instance()->GetNumPoints(); n++ ){
00194       Double_t T = NtpTimingFit::Instance()->GetT(n) - fSeedTime;
00195       Double_t S = NtpTimingFit::Instance()->GetS(n);
00196       Double_t Delta = T - (ibeta/0.3)*S;
00197 
00198       if( T>fMinTime && T<fMaxTime 
00199        && S>fMinLength && S<fMaxLength ){
00200         fMarker = new TMarker(S,T,20);
00201         fMarker->SetMarkerSize(1.0);
00202         fMarker->SetMarkerColor(4);
00203         fMarkerList.push_back(fMarker);
00204       }
00205 
00206       fTimeRes->Fill( Delta );
00207     }
00208   }
00209 
00210   // set limits
00211   Double_t max = 1.0;
00212   for( Int_t n=0; n<fTimeRes->GetXaxis()->GetNbins(); n++ ){
00213     if( fTimeRes->GetBinContent(n+1)>max ){
00214       max = fTimeRes->GetBinContent(n+1);
00215     }
00216   } 
00217   max *= 1.25;
00218 
00219   Int_t bin    = fTimeRes->GetXaxis()->FindBin(-fWindow);
00220   Double_t min = fTimeRes->GetXaxis()->GetBinLowEdge(bin);
00221 
00222   fTimeRes->SetMinimum(0);
00223   fTimeRes->SetMaximum(max);
00224   fTimeRes->GetXaxis()->SetRangeUser(-fWindow,+fWindow);
00225 
00226   fTimeHist->GetYaxis()->SetLimits(fMinTime,fMaxTime);
00227   fTimeHist->GetXaxis()->SetLimits(fMinLength,fMaxLength);
00228 
00229   // draw markers
00230   fTimeCanvas->Clear();
00231   fTimeCanvas->Draw();
00232   fTimeHist->Draw();
00233    
00234   fTitleLatex.DrawLatex(fMinLength,
00235                         fMinTime + 1.015*(fMaxTime-fMinTime),
00236                         fTitleString.Data());
00237 
00238   for( UInt_t m=0; m<fMarkerList.size(); m++ ){
00239     fMarker = (TMarker*)(fMarkerList.at(m));
00240     if( fMarker ) fMarker->Draw();
00241   }
00242   
00243   if( fPassFail ){
00244     fTimeFit1->SetParameter(0,fVtxTime1-fSeedTime);
00245     fTimeFit1->SetParameter(1,fInvBeta1/0.3);
00246     fTimeFit1->Draw("same");
00247 
00248     // (result of unconstrained fit)
00249     // fTimeFit2->SetParameter(0,fVtxTime2-fSeedTime);
00250     // fTimeFit2->SetParameter(1,fInvBeta2/0.3);
00251     // fTimeFit2->Draw("same");
00252   }
00253 
00254   fTimeCanvas->Update();
00255 
00256   // draw residuals
00257   fTimeResiduals->Clear();
00258   fTimeResiduals->Draw();
00259   fTimeRes->Draw();
00260 
00261   fTitleLatex.DrawLatex(min,1.015*max,
00262                         fTitleString.Data());
00263 
00264   if( fPassFail ){
00265     fTimeLine1.DrawLine(fVtxTime1-fSeedTime,0.0,
00266                         fVtxTime1-fSeedTime,0.75*max);
00267     // (result of unconstrained fit)
00268     // fTimeLine2.DrawLine(fVtxTime2-fSeedTime,0.0,
00269     //                     fVtxTime2-fSeedTime,0.75*max);
00270   }
00271 
00272   if( fPassFail ){
00273     std::cout << " Constrained: " << fVtxTime1-fSeedTime << ", Unconstrained: " << fVtxTime2-fSeedTime << std::endl;
00274   }
00275 
00276   fTimeResiduals->Update();
00277   
00278   return;
00279 }

void NtpEventDisplayTiming::PrintPicture (  )  [virtual]

Implements NtpEventDisplay.

Definition at line 281 of file NtpEventDisplayTiming.cxx.

References PrintPictureEPS(), and PrintPictureGIF().

00282 {
00283   // print both GIF and EPS
00284   this->PrintPictureGIF();
00285   this->PrintPictureEPS();
00286 }

void NtpEventDisplayTiming::PrintPictureEPS (  ) 

Definition at line 303 of file NtpEventDisplayTiming.cxx.

References fEvent, fRun, fSnarl, fTimeCanvas, and outfile.

Referenced by PrintPicture().

00304 {
00305   if( fTimeCanvas ){
00306     TString outfile("timedisplay");
00307     outfile.Append(".");
00308     outfile+=fRun;
00309     outfile.Append(".");
00310     outfile+=fSnarl;
00311     outfile.Append(".");
00312     outfile+=fEvent;
00313     outfile.Append(".gif");
00314     fTimeCanvas->SaveAs(outfile.Data());
00315   }
00316 }

void NtpEventDisplayTiming::PrintPictureGIF (  ) 

Definition at line 288 of file NtpEventDisplayTiming.cxx.

References fEvent, fRun, fSnarl, fTimeCanvas, and outfile.

Referenced by PrintPicture().

00289 {
00290  if( fTimeCanvas ){
00291     TString outfile("timedisplay");
00292     outfile.Append(".");
00293     outfile+=fRun;
00294     outfile.Append(".");
00295     outfile+=fSnarl;
00296     outfile.Append(".");
00297     outfile+=fEvent;
00298     outfile.Append(".eps");
00299     fTimeCanvas->SaveAs(outfile.Data());
00300   }
00301 }


Member Data Documentation

Definition at line 55 of file NtpEventDisplayTiming.h.

Referenced by MakePicture(), PrintPictureEPS(), and PrintPictureGIF().

Definition at line 62 of file NtpEventDisplayTiming.h.

Referenced by MakePicture().

Definition at line 65 of file NtpEventDisplayTiming.h.

Referenced by MakePicture().

Double_t NtpEventDisplayTiming::fLength [private]

Definition at line 59 of file NtpEventDisplayTiming.h.

Referenced by MakePicture().

TMarker* NtpEventDisplayTiming::fMarker [private]

Definition at line 73 of file NtpEventDisplayTiming.h.

Referenced by DeleteMarkers(), and MakePicture().

std::vector<TMarker*> NtpEventDisplayTiming::fMarkerList [private]

Definition at line 75 of file NtpEventDisplayTiming.h.

Referenced by DeleteMarkers(), Initialize(), and MakePicture().

Definition at line 71 of file NtpEventDisplayTiming.h.

Referenced by MakePicture().

Double_t NtpEventDisplayTiming::fMaxTime [private]

Definition at line 69 of file NtpEventDisplayTiming.h.

Referenced by MakePicture().

Definition at line 70 of file NtpEventDisplayTiming.h.

Referenced by MakePicture().

Double_t NtpEventDisplayTiming::fMinTime [private]

Definition at line 68 of file NtpEventDisplayTiming.h.

Referenced by MakePicture().

Definition at line 56 of file NtpEventDisplayTiming.h.

Referenced by MakePicture().

Int_t NtpEventDisplayTiming::fRun [private]

Definition at line 53 of file NtpEventDisplayTiming.h.

Referenced by MakePicture(), PrintPictureEPS(), and PrintPictureGIF().

Definition at line 58 of file NtpEventDisplayTiming.h.

Referenced by MakePicture().

Definition at line 54 of file NtpEventDisplayTiming.h.

Referenced by MakePicture(), PrintPictureEPS(), and PrintPictureGIF().

Definition at line 44 of file NtpEventDisplayTiming.h.

Referenced by Initialize(), MakePicture(), and ~NtpEventDisplayTiming().

Definition at line 45 of file NtpEventDisplayTiming.h.

Referenced by Initialize(), and ~NtpEventDisplayTiming().

Definition at line 42 of file NtpEventDisplayTiming.h.

Referenced by Initialize(), MakePicture(), and ~NtpEventDisplayTiming().

Definition at line 50 of file NtpEventDisplayTiming.h.

Referenced by Initialize(), and MakePicture().

Definition at line 51 of file NtpEventDisplayTiming.h.

Referenced by Initialize().

Definition at line 43 of file NtpEventDisplayTiming.h.

Referenced by Initialize(), MakePicture(), and ~NtpEventDisplayTiming().

Definition at line 40 of file NtpEventDisplayTiming.h.

Referenced by Initialize(), MakePicture(), and ~NtpEventDisplayTiming().

Definition at line 48 of file NtpEventDisplayTiming.h.

Referenced by Initialize(), and MakePicture().

Definition at line 47 of file NtpEventDisplayTiming.h.

Referenced by MakePicture().

Definition at line 63 of file NtpEventDisplayTiming.h.

Referenced by MakePicture().

Definition at line 66 of file NtpEventDisplayTiming.h.

Referenced by MakePicture().

Double_t NtpEventDisplayTiming::fWindow [private]

Definition at line 60 of file NtpEventDisplayTiming.h.

Referenced by MakePicture().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1