Anp::SnarlTimeTab Class Reference

#include <SnarlTimeTab.h>

Inheritance diagram for Anp::SnarlTimeTab:
Anp::EventTab Anp::Base

List of all members.

Public Member Functions

 SnarlTimeTab ()
virtual ~SnarlTimeTab ()
void Init (TCanvas *canvas)
void Expose ()
void Set (const Event &event, const Record &record)
void ZoomIn ()
void ZoomOut ()
void Config (const Registry &reg)

Private Member Functions

bool Init (const Record &record)
void Reset ()
void NewSnarl (const Record &record)
double GetTime (const Strip &strip, bool addwidth=true) const

Private Attributes

Registry fConfig
std::vector< TObject * > fObjVec
bool fInit
bool fDraw
Header fHeader
double fTdcWidth
double fFirstTime
TCanvas * fCanvas
TPad * fPad1
TPad * fPad2
TH1 * fTimeSnarl
TH1 * fTimeEvent

Detailed Description

Definition at line 20 of file SnarlTimeTab.h.


Constructor & Destructor Documentation

Anp::SnarlTimeTab::SnarlTimeTab (  ) 

Definition at line 21 of file SnarlTimeTab.cxx.

00022    :fInit(false),
00023     fDraw(true),
00024     fTdcWidth(18.83e-9),
00025     fFirstTime(0.0),
00026     fCanvas(0),
00027     fPad1(0),
00028     fPad2(0),
00029     fTimeSnarl(0),
00030     fTimeEvent(0)
00031 {
00032 }

Anp::SnarlTimeTab::~SnarlTimeTab (  )  [virtual]

Definition at line 35 of file SnarlTimeTab.cxx.

References fObjVec, and it.

00036 {
00037    for(std::vector<TObject *>::iterator it = fObjVec.begin(); it != fObjVec.begin(); ++it)
00038    {
00039       TObject *obj = *it;
00040       delete obj;
00041    }
00042 }


Member Function Documentation

void Anp::SnarlTimeTab::Config ( const Registry reg  )  [virtual]

Implements Anp::EventTab.

Definition at line 137 of file SnarlTimeTab.cxx.

References fConfig, Registry::LockValues(), Registry::Merge(), and Registry::UnLockValues().

Referenced by Init(), and NewSnarl().

00138 {
00139    fConfig.UnLockValues();
00140    fConfig.Merge(reg); 
00141    fConfig.LockValues();
00142 }

void Anp::SnarlTimeTab::Expose (  )  [virtual]

Implements Anp::EventTab.

Definition at line 107 of file SnarlTimeTab.cxx.

References cd(), Draw(), fCanvas, fDraw, fInit, fPad1, fPad2, fTimeEvent, and fTimeSnarl.

00108 {
00109    if(!fInit)
00110    {
00111       return;
00112    }
00113 
00114    if(!fPad1 || !fPad2)
00115    {
00116       return;
00117    }
00118    
00119    if(fDraw)
00120    {
00121       fPad1 -> cd();   
00122       if(fTimeSnarl)
00123       {
00124          fTimeSnarl -> Draw("");
00125          fTimeEvent -> Draw("same");
00126       }
00127       
00128       fDraw = false;
00129    }
00130 
00131    fCanvas -> cd();
00132    fCanvas -> Modified();
00133    fCanvas -> Update();
00134 }

double Anp::SnarlTimeTab::GetTime ( const Strip strip,
bool  addwidth = true 
) const [private]

Definition at line 259 of file SnarlTimeTab.cxx.

References fFirstTime, fTdcWidth, and Anp::Strip::Time().

Referenced by NewSnarl(), and Set().

00260 {
00261    if(addwidth)
00262    {
00263       return 1.0e9 * strip.Time() - fFirstTime + 0.5 * fTdcWidth;
00264    }
00265 
00266    return 1.0e9 * strip.Time() - fFirstTime;
00267 }

bool Anp::SnarlTimeTab::Init ( const Record record  )  [private]

Definition at line 145 of file SnarlTimeTab.cxx.

References fHeader, fInit, Anp::Record::GetHeader(), and NewSnarl().

00146 {
00147    if(fInit)
00148    {
00149       cerr << "SnarlTimeTab is already initialized" << endl;
00150       return false;
00151    }
00152 
00153    fInit = true;
00154 
00155    fHeader = record.GetHeader();
00156 
00157    NewSnarl(record);
00158 
00159    return true;
00160 }

void Anp::SnarlTimeTab::Init ( TCanvas *  canvas  )  [virtual]

Implements Anp::EventTab.

Definition at line 73 of file SnarlTimeTab.cxx.

References cd(), Config(), Divide(), fCanvas, fConfig, fPad1, and fPad2.

Referenced by Set().

00074 {
00075    if(!canvas)
00076    {
00077       cerr << "SnarlTimeTab::Expose(): null TCanvas pointer" << endl;
00078       return;
00079    }
00080    if(fPad1 || fPad2 || fCanvas)
00081    {
00082       cerr << "SnarlTimeTab::Expose(): pads have been already initialized" << endl;
00083       return;
00084    }
00085 
00086    fCanvas = canvas;
00087 
00088    fCanvas -> Divide(0, 2);
00089 
00090    fPad1 = dynamic_cast<TPad *> (canvas -> cd(1));
00091    fPad2 = dynamic_cast<TPad *> (canvas -> cd(2));
00092    
00093    if(!fPad1 || !fPad2)
00094    {
00095       cerr << "SnarlTimeTab::Expose(): failed to create new pads" << endl;
00096       fCanvas = 0;
00097       fPad1 = 0;
00098       fPad2 = 0;
00099       return;
00100    }
00101 
00102    Draw::Config(fPad1, "Time", fConfig);
00103    Draw::Config(fPad2, "Time", fConfig);
00104 }

void Anp::SnarlTimeTab::NewSnarl ( const Record record  )  [private]

Definition at line 174 of file SnarlTimeTab.cxx.

References Config(), fConfig, fFirstTime, fTdcWidth, fTimeEvent, fTimeSnarl, Anp::Record::GetHeader(), GetTime(), init(), Anp::Header::IsFar(), Anp::Header::IsNear(), max, min, Anp::Read(), Anp::Record::StripBeg(), and Anp::Record::StripEnd().

Referenced by Init(), and Set().

00175 {
00176    if(fTimeSnarl)
00177    {      
00178       delete fTimeSnarl;
00179       fTimeSnarl = 0;
00180    }
00181    if(fTimeEvent)
00182    {      
00183       delete fTimeEvent;
00184       fTimeEvent = 0;
00185    }
00186 
00187    fFirstTime = 0.0;
00188 
00189    static int TdcBorder = 10;
00190    static bool init = false;
00191    if(!init)
00192    {
00193       if(record.GetHeader().IsNear())
00194       {
00195          fTdcWidth = Draw::Read("NearTdcWidth", fTdcWidth, fConfig);
00196          TdcBorder = Draw::Read("NearTdcBorder", TdcBorder, fConfig);
00197       }
00198       else if(record.GetHeader().IsFar())
00199       {
00200          fTdcWidth = Draw::Read("FarTdcWidth", fTdcWidth, fConfig);
00201          TdcBorder = Draw::Read("FarTdcBorder", TdcBorder, fConfig);
00202       }
00203       init = true;
00204    }
00205 
00206    double min = -1.0, max = -1.0;
00207 
00208    for(StripIter strip = record.StripBeg(); strip != record.StripEnd(); ++strip)
00209    {
00210       const double time = GetTime(*strip, false);
00211       if(min < 0.0 || max < 0.0)
00212       {
00213          min = time;
00214          max = time;
00215       }
00216 
00217       if(time < min)
00218       {
00219          min = time;
00220       }
00221       if(time > max)
00222       {
00223          max = time;
00224       }      
00225    }
00226 
00227    fFirstTime = min;
00228 
00229    min = - double(TdcBorder) * fTdcWidth;
00230    max = max - fFirstTime + double(TdcBorder) * fTdcWidth;
00231 
00232    int nbin = 1;
00233    if(min < max && fTdcWidth > 0.0)
00234    {
00235       const double timebin = std::ceil((max-min)/fTdcWidth);
00236       
00237       if(timebin < 1e6)
00238       {
00239          nbin = static_cast<int>(std::ceil((max-min)/fTdcWidth));
00240       }
00241    }
00242 
00243    fTimeSnarl = new TH1D("snarl_time", "snarl_time", nbin, min, max);
00244    fTimeEvent = new TH1D("event_time", "event_time", nbin, min, max);
00245 
00246    fTimeSnarl -> SetDirectory(0);
00247    fTimeEvent -> SetDirectory(0);
00248 
00249    Draw::Config(fTimeSnarl, "Snarl", fConfig);
00250    Draw::Config(fTimeEvent, "Event", fConfig);
00251 
00252    for(StripIter strip = record.StripBeg(); strip != record.StripEnd(); ++strip)
00253    {
00254       fTimeSnarl -> Fill(GetTime(*strip), strip -> SigCor());
00255    }
00256 }

void Anp::SnarlTimeTab::Reset (  )  [private]

Definition at line 163 of file SnarlTimeTab.cxx.

References fDraw, and fTimeEvent.

Referenced by Set().

00164 {
00165    fDraw = true;
00166 
00167    if(fTimeEvent)
00168    {
00169       fTimeEvent -> Reset();
00170    }
00171 }

void Anp::SnarlTimeTab::Set ( const Event event,
const Record record 
) [virtual]

Implements Anp::EventTab.

Definition at line 45 of file SnarlTimeTab.cxx.

References Anp::Event::EventIndex(), fHeader, fInit, fTimeEvent, Anp::Record::GetHeader(), GetTime(), Init(), NewSnarl(), Reset(), Anp::Record::StripBeg(), and Anp::Record::StripEnd().

00046 {  
00047    if(!fInit)
00048    {
00049       Init(record);
00050    }
00051    else
00052    {
00053       Reset();
00054    }
00055 
00056    if(fHeader != record.GetHeader())
00057    {
00058       NewSnarl(record);
00059    }
00060 
00061    for(StripIter strip = record.StripBeg(); strip != record.StripEnd(); ++strip)
00062    {
00063       if(!strip -> MatchEvt(event.EventIndex()))
00064       {
00065          continue;
00066       }
00067 
00068       fTimeEvent -> Fill(GetTime(*strip), strip -> SigCor());
00069    }
00070 }   

void Anp::SnarlTimeTab::ZoomIn (  )  [virtual]

Reimplemented from Anp::EventTab.

Definition at line 270 of file SnarlTimeTab.cxx.

00271 {
00272 }

void Anp::SnarlTimeTab::ZoomOut (  )  [virtual]

Reimplemented from Anp::EventTab.

Definition at line 275 of file SnarlTimeTab.cxx.

00276 {
00277 }


Member Data Documentation

TCanvas* Anp::SnarlTimeTab::fCanvas [private]

Definition at line 59 of file SnarlTimeTab.h.

Referenced by Expose(), and Init().

Definition at line 47 of file SnarlTimeTab.h.

Referenced by Config(), Init(), and NewSnarl().

bool Anp::SnarlTimeTab::fDraw [private]

Definition at line 52 of file SnarlTimeTab.h.

Referenced by Expose(), and Reset().

Definition at line 57 of file SnarlTimeTab.h.

Referenced by GetTime(), and NewSnarl().

Definition at line 54 of file SnarlTimeTab.h.

Referenced by Init(), and Set().

bool Anp::SnarlTimeTab::fInit [private]

Definition at line 51 of file SnarlTimeTab.h.

Referenced by Expose(), Init(), and Set().

std::vector<TObject *> Anp::SnarlTimeTab::fObjVec [private]

Definition at line 49 of file SnarlTimeTab.h.

Referenced by ~SnarlTimeTab().

TPad* Anp::SnarlTimeTab::fPad1 [private]

Definition at line 61 of file SnarlTimeTab.h.

Referenced by Expose(), and Init().

TPad* Anp::SnarlTimeTab::fPad2 [private]

Definition at line 62 of file SnarlTimeTab.h.

Referenced by Expose(), and Init().

double Anp::SnarlTimeTab::fTdcWidth [private]

Definition at line 56 of file SnarlTimeTab.h.

Referenced by GetTime(), and NewSnarl().

Definition at line 65 of file SnarlTimeTab.h.

Referenced by Expose(), NewSnarl(), Reset(), and Set().

Definition at line 64 of file SnarlTimeTab.h.

Referenced by Expose(), and NewSnarl().


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

Generated on 18 Jan 2018 for loon by  doxygen 1.6.1