00001 #include "TimeHist.h"
00002 #include "Mint.h"
00003 #include "MintView.h"
00004 #include "ZoomPad.h"
00005 #include <Midad/Util/Range.h>
00006
00007 #include <Conventions/Munits.h>
00008
00009 #include <CandDigit/CandDigitHandle.h>
00010 #include <CandDigit/CandDigitListHandle.h>
00011
00012 #include <DataUtil/CDL2STL.h>
00013 using namespace DataUtil;
00014
00015 #include <TH1F.h>
00016
00017 #include <sigc++/sigc++.h>
00018 #include <sigc++/class_slot.h>
00019 using namespace SigC;
00020
00021 #include <vector>
00022 using namespace std;
00023
00024 TimeHist::TimeHist()
00025 : fPad(0)
00026 , fHist(0)
00027 {
00028 fPad = new ZoomPad("TimeHistPad","Time Hist Pad");
00029 fPad->SetScales(1.0e9,1.0);
00030 fPad->Draw();
00031
00032 TVirtualPad* old_pad = gPad;
00033
00034 fPad->cd();
00035 fHist = new TH1F("TimeHist","Digit Times (ns)",100,0,100);
00036 fHist->Draw();
00037
00038 gPad = old_pad;
00039 }
00040
00041
00042 TimeHist::~TimeHist()
00043 {
00044 }
00045
00046 void TimeHist::Draw(Option_t*)
00047 {
00048 fPad->Draw();
00049 }
00050 void TimeHist::SetMint(Mint* mint)
00051 {
00052 this->MintView::SetMint(mint);
00053
00054 mint->GetTimeRange().modified.connect(slot_class(*this,&TimeHist::Refresh));
00055
00056 }
00057
00058 void TimeHist::UpdatePad()
00059 {
00060 fPad->Modified();
00061 fPad->Update();
00062 }
00063
00064 void TimeHist::Refresh()
00065 {
00066
00067
00068 fHist->Reset();
00069 fHist->SetFillColor(2);
00070 fHist->SetFillStyle(1001);
00071
00072 const CandDigitListHandle *cdlh = this->GetMint().GetDigits();
00073 if (! cdlh) return;
00074
00075 RangeDouble& r = this->GetMint().GetTimeRange();
00076 fHist->SetBins(100,r.Min()/Munits::ns, r.Max()/Munits::ns);
00077
00078 vector<const CandDigitHandle*> dc = CDL2STLvector<const CandDigitHandle>(*cdlh);
00079
00080 int siz = dc.size();
00081 for (int ind=0; ind < siz; ++ind) {
00082 fHist->Fill(dc[ind]->GetTime()/Munits::ns,dc[ind]->GetCharge());
00083 }
00084 this->UpdatePad();
00085 }