DeltaT Class Reference

#include <DeltaT.h>

Inheritance diagram for DeltaT:
Plotter

List of all members.

Public Member Functions

 DeltaT ()
virtual ~DeltaT ()
void Book (PlotterManager &pm)
 Implement this to book histograms or o.w. one time setup.
bool Fill (PlotterManager &pm)
void NewFile (const char *filename)
 Implement to get notice of when a new tree is loaded.

Private Attributes

Knot fKnot
TFile * fFile

Detailed Description

Definition at line 9 of file DeltaT.h.


Constructor & Destructor Documentation

DeltaT::DeltaT (  ) 

Definition at line 19 of file DeltaT.cxx.

00020     : fFile(0)
00021 {
00022 }

DeltaT::~DeltaT (  )  [virtual]

Definition at line 24 of file DeltaT.cxx.

References fFile.

00025 {
00026     if (fFile) delete fFile; fFile = 0;
00027 }


Member Function Documentation

void DeltaT::Book ( PlotterManager  )  [virtual]

Implement this to book histograms or o.w. one time setup.

Reimplemented from Plotter.

Definition at line 40 of file DeltaT.cxx.

References HistMan::Book(), PlotterManager::GetHistMan(), PlotterManager::GetSwicDevNames(), and missing().

00041 {
00042 
00043     vector<const char*> devs = pm.GetSwicDevNames();
00044     size_t siz = devs.size();
00045 
00046     HistMan& hm = pm.GetHistMan();
00047 
00048     TH2D* devhist[3];
00049 
00050     int i=0;
00051     devhist[i++] = hm.Book<TH2D>("dae_vme_dt","DAE-VME time difference",
00052                                  siz,0,siz, 400,0,4);
00053     devhist[i++] = hm.Book<TH2D>("dae_dt_prev","DAE time to previous spill",
00054                                  siz,0,siz, 240,0,240);
00055     devhist[i++] = hm.Book<TH2D>("vme_dt_prev","VME time to previous spill",
00056                                  siz,0,siz, 240,0,240);
00057     devhist[i++] = hm.Book<TH2D>("dae_vme_dt_prev","DAE-VME-(DAE time to prev spill)",
00058                                  siz,0,siz, 400,0,4);
00059 
00060     TH1D* missing =
00061         hm.Book<TH1D>("missing","Number of times the device is missing",
00062                       siz,0,siz);
00063 
00064     hm.Book<TH1D>("earliest_dae_vme_dt","Delta between earliest DAE and VME",
00065                   1000,-5,5);
00066 
00067     for (size_t bin=0; bin<siz; ++bin) {
00068         for (int ind=0; ind<i; ++ind) {
00069             devhist[ind]->GetXaxis()->SetBinLabel(bin+1,devs[bin]);
00070         }
00071         missing->GetXaxis()->SetBinLabel(bin+1,devs[bin]);
00072     }
00073 
00074 
00075 }

bool DeltaT::Fill ( PlotterManager  )  [virtual]

Implement this to get notified each time a new event is read in. Return true to stop analyzing this event.

Reimplemented from Plotter.

Definition at line 76 of file DeltaT.cxx.

References MuELoss::e, HistMan::Fill1d(), HistMan::Fill2d(), fKnot, Knot::GetDevice(), Knot::GetEntry(), Knot::GetEntryNumber(), PlotterManager::GetHistMan(), PlotterManager::GetKnot(), PlotterManager::GetSwicDevNames(), Swic::GetVmeTimestamp(), AcnetDevice::ndata, Swic::SetAcnetDevice(), and AcnetDevice::timestamp.

00077 {
00078     Knot& k = pm.GetKnot();
00079     HistMan& hm = pm.GetHistMan();
00080 
00081     vector<const char*> devs = pm.GetSwicDevNames();
00082     size_t siz = devs.size();
00083     
00084     int entry = k.GetEntryNumber();
00085     if (entry > 0)  fKnot.GetEntry(entry-1);
00086 
00087     double early_dae = -1.0, early_vme = -1.0;
00088 
00089     Swic swic1, swic2;
00090     for (size_t dev=0; dev<siz; ++dev) {
00091         const AcnetDevice* ad1 = k.GetDevice(devs[dev]);
00092         if (!ad1->ndata) {
00093             hm.Fill1d("missing",dev,1);
00094             continue;
00095         }
00096 
00097         swic1.SetAcnetDevice(*ad1);
00098 
00099         double diff0 = ad1->timestamp-swic1.GetVmeTimestamp();
00100         if (fabs(diff0)<1e-6) diff0=0.0;
00101         hm.Fill2d("dae_vme_dt",dev,diff0);
00102 
00103         // Track earliest DAE & VME timestamp.
00104         if (ad1->timestamp > 1.0)
00105             if (early_dae < 0.0 || ad1->timestamp < early_dae)
00106                 early_dae = ad1->timestamp;
00107         double vme_timestamp = swic1.GetVmeTimestamp();
00108         if (vme_timestamp > 1.0)
00109             if (early_vme < 0.0 || vme_timestamp < early_vme)
00110                 early_vme = vme_timestamp;
00111         
00112         // Need to pass the first spill before comparing to previous....
00113         if (entry < 1) continue;
00114 
00115         const AcnetDevice* ad2 = fKnot.GetDevice(devs[dev]);
00116         if (!ad2->ndata) continue;
00117 
00118         swic2.SetAcnetDevice(*ad2);
00119 
00120         double diff1 = ad1->timestamp-ad2->timestamp;
00121         if (fabs(diff1)<1e-6) diff1=0.0;
00122         hm.Fill2d("dae_dt_prev",dev,diff1);
00123 
00124         double diff2 = swic1.GetVmeTimestamp()-swic2.GetVmeTimestamp();
00125         if (fabs(diff2)<1e-6) diff2=0.0;
00126         hm.Fill2d("vme_dt_prev",dev,diff2);
00127 
00128         double diff3 = diff0-diff1;
00129         if (diff0 < 0 || diff0 > 4) {
00130             hm.Fill2d("dae_vme_dt_prev",dev,diff3);
00131         }
00132     }
00133     hm.Fill1d("earliest_dae_vme_dt",early_dae-early_vme);
00134     return true;
00135 }

void DeltaT::NewFile ( const char *   )  [virtual]

Implement to get notice of when a new tree is loaded.

Reimplemented from Plotter.

Definition at line 29 of file DeltaT.cxx.

References fFile, fKnot, and Knot::SetTree().

00030 {
00031     if (fFile) delete fFile; fFile = 0;
00032     fFile = new TFile(filename);
00033 
00034     TObject* o = fFile->FindObjectAny("bd");
00035     TTree* bd = dynamic_cast<TTree*>(o);
00036     assert(bd);
00037     fKnot.SetTree(*bd);
00038 }


Member Data Documentation

TFile* DeltaT::fFile [private]

Definition at line 11 of file DeltaT.h.

Referenced by NewFile(), and ~DeltaT().

Knot DeltaT::fKnot [private]

Definition at line 10 of file DeltaT.h.

Referenced by Fill(), and NewFile().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1