PlotPeds Class Reference

#include <PlotPeds.h>

List of all members.

Public Member Functions

 PlotPeds (const char *device_name)
bool Start (VldTimeStamp vts=VldTimeStamp::GetBOT())
bool Next (VldTimeStamp end_of_time=VldTimeStamp::GetEOT())
void DoAll ()

Private Member Functions

bool Update ()

Private Attributes

PlotPedsImpimp

Detailed Description

Definition at line 11 of file PlotPeds.h.


Constructor & Destructor Documentation

PlotPeds::PlotPeds ( const char *  device_name  ) 

Definition at line 42 of file PlotPeds.cxx.

References PlotPedsImp::abs_total, PlotPedsImp::canvas, PlotPedsImp::channels, imp, PlotPedsImp::init_seqno, and PlotPedsImp::total.

00043     : imp(*(new PlotPedsImp(name)))
00044 {
00045     imp.canvas = 0;
00046     imp.channels = 0;
00047     imp.total = 0;
00048     imp.abs_total = 0;
00049     imp.init_seqno=0;
00050 }


Member Function Documentation

void PlotPeds::DoAll (  ) 

Definition at line 200 of file PlotPeds.cxx.

References Next(), and Start().

00201 {
00202     VldTimeStamp end_of_time = VldTimeStamp(2005,3,23,0,0,0);
00203     this->Start(VldTimeStamp(2004,12,01,0,0,0));
00204     int nzero = 0;
00205     while (nzero < 3) {
00206         if (this->Next(end_of_time)) nzero = 0;
00207         else ++nzero;
00208     }
00209 }

bool PlotPeds::Next ( VldTimeStamp  end_of_time = VldTimeStamp::GetEOT()  ) 

Definition at line 183 of file PlotPeds.cxx.

References PlotPedsImp::drp, VldRange::GetTimeEnd(), DbiResultPtr< T >::GetValidityRec(), DbiValidityRec::GetVldRange(), imp, DbiResultPtr< T >::NextQuery(), and Update().

Referenced by DoAll().

00184 {
00185     int nrows = imp.drp.NextQuery();
00186     if (!nrows) {
00187         const DbiValidityRec* vr = imp.drp.GetValidityRec();
00188         VldTimeStamp vts = vr->GetVldRange().GetTimeEnd();
00189         if (vts >= end_of_time) {
00190             cerr << "Reached end of time\n";
00191             return false;
00192         }
00193         cerr << "In gap, not at EOT: " << vts << endl;
00194         return this->Next();
00195     }
00196 
00197     return this->Update();
00198 }

bool PlotPeds::Start ( VldTimeStamp  vts = VldTimeStamp::GetBOT()  ) 

Definition at line 173 of file PlotPeds.cxx.

References det, PlotPedsImp::drp, imp, SimFlag::kData, Detector::kNear, DbiResultPtr< T >::NewQuery(), and Update().

Referenced by DoAll().

00174 {
00175     Detector::Detector_t det = Detector::kNear;
00176     SimFlag::SimFlag_t   sim = SimFlag::kData;
00177     VldContext vc(det,sim,vts);
00178 
00179     imp.drp.NewQuery(vc,0,true);
00180     return this->Update();
00181 }

bool PlotPeds::Update (  )  [private]

Definition at line 52 of file PlotPeds.cxx.

References PlotPedsImp::abs_max, PlotPedsImp::abs_min, PlotPedsImp::abs_total, PlotPedsImp::canvas, PlotPedsImp::channels, PlotPedsImp::drp, Form(), BeamMonSwicPeds::GetDeviceName(), BeamMonSwicPeds::GetMeans(), BeamMonSwicPeds::GetNsamples(), DbiResultPtr< T >::GetNumRows(), DbiResultPtr< T >::GetRow(), DbiValidityRec::GetSeqNo(), DbiResultPtr< T >::GetValidityRec(), DbiValidityRec::GetVldRange(), imp, PlotPedsImp::init_seqno, max, min, PlotPedsImp::name, PlotPedsImp::p, and PlotPedsImp::total.

Referenced by Next(), and Start().

00053 {
00054     const DbiValidityRec* vr = imp.drp.GetValidityRec();
00055     int seqno = vr->GetSeqNo();
00056     int nrows = imp.drp.GetNumRows();
00057 
00058     cerr << nrows << " rows, seqno=" << seqno 
00059          << " vldrange = " << endl << vr->GetVldRange() << endl;
00060 
00061     if (!nrows) {
00062         cerr << "No rows\n";
00063         return false;
00064     }
00065 
00066 
00067     const int nseqno = 100;
00068     if (!imp.canvas) {
00069 
00070         imp.init_seqno = seqno;
00071 
00072         imp.canvas = new TCanvas("canvas",Form("Peds for %s",imp.name.c_str()),
00073                                   500,400);
00074         imp.channels = new TH2F(Form("channels_%c_%s",imp.name[0],imp.name.c_str()+2),
00075                                  Form("Channels for %s",imp.name.c_str()),
00076                                  nseqno,seqno,seqno+nseqno,96,0,96);
00077         imp.total = new TH1F(Form("total_%c_%s",imp.name[0],imp.name.c_str()+2),
00078                               Form("Total for %s",imp.name.c_str()),
00079                               400,-20.0,20.0);
00080         imp.abs_total = new TH1F(Form("abs_total_%c_%s",imp.name[0],imp.name.c_str()+2),
00081                               Form("Abs Total for %s",imp.name.c_str()),
00082                               200,0.0,20.0);
00083         imp.abs_min = new TH1F(Form("abs_min_%c_%s",imp.name[0],imp.name.c_str()+2),
00084                                Form("Abs min for %s",imp.name.c_str()),
00085                                100,0.0,1.0);
00086         imp.abs_max = new TH1F(Form("abs_max_%c_%s",imp.name[0],imp.name.c_str()+2),
00087                                Form("Abs max for %s",imp.name.c_str()),
00088                                100,0.0,1.0);
00089         
00090         imp.canvas->Divide(1,2);
00091         imp.canvas->cd(1);
00092         imp.channels->Draw("COLZ");
00093         gPad->SetLogz();
00094 
00095         imp.canvas->cd(2);
00096         TVirtualPad* pad = gPad;
00097         pad->Divide(4,1);
00098 
00099         pad->cd(1);
00100         imp.p[0] = gPad;
00101         gPad->SetLogy();
00102         imp.total->Draw();
00103 
00104         pad->cd(2);
00105         imp.p[1] = gPad;
00106         gPad->SetLogy();
00107         imp.abs_total->Draw();
00108 
00109         pad->cd(3);
00110         imp.p[2] = gPad;
00111         gPad->SetLogy();
00112         imp.abs_min->Draw();
00113         
00114         pad->cd(4);
00115         imp.p[3] = gPad;
00116         gPad->SetLogy();
00117         imp.abs_max->Draw();
00118 
00119         cerr << "Canvas created\n";
00120     }
00121 
00122     const BeamMonSwicPeds* the_peds = 0;
00123     for (int ind=0; ind<nrows; ++ind) {
00124         const BeamMonSwicPeds* peds = imp.drp.GetRow(ind);
00125         string name = peds->GetDeviceName();
00126         if (name != imp.name) continue;
00127         the_peds = peds;
00128         break;
00129     }
00130     if (!the_peds) {
00131         cerr << "Could not find any device \"" << imp.name << "\" out of " << nrows << endl;
00132         return false;
00133     }
00134         
00135     vector<float> means = the_peds->GetMeans();
00136     int nsamples = the_peds->GetNsamples();
00137 
00138     double tot=0;
00139     double min=0, max=0;
00140     for (int ind=0; ind<96; ++ind) {
00141         imp.channels->Fill(seqno,ind,means[ind]);
00142         tot += means[ind];
00143         if (!ind) min=max=fabs(means[ind]);
00144         if (min > means[ind]) min = fabs(means[ind]);
00145         if (max < means[ind]) max = fabs(means[ind]);
00146     }
00147 
00148     imp.total->Fill(tot);
00149     imp.abs_total->Fill(fabs(tot));
00150     imp.abs_min->Fill(min);
00151     imp.abs_max->Fill(max);
00152 
00153     // what does it take to make the damn thing update?
00154     imp.canvas->cd(1);
00155     gPad->Modified();
00156 
00157     for (int ind=0; ind<4; ++ind)
00158         imp.p[ind]->Modified();
00159 
00160     imp.canvas->cd();
00161     imp.canvas->Modified();
00162     imp.canvas->Update();
00163 
00164     // Give GUI a chance to update.
00165     while (gClient->HandleInput());
00166 
00167     cerr << "seqno=" << seqno << " "
00168          << nsamples << " samples, total peds = " << tot << endl;
00169 
00170     return true;
00171 }


Member Data Documentation

Definition at line 12 of file PlotPeds.h.

Referenced by Next(), PlotPeds(), Start(), and Update().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1