UserDisplayModule Class Reference

#include <UserDisplayModule.h>

Inheritance diagram for UserDisplayModule:
JobCModule

List of all members.

Public Member Functions

 UserDisplayModule ()
virtual ~UserDisplayModule ()
virtual void BeginRun ()
JobCResult Ana (const MomNavigator *mom)

Private Member Functions

void BuildDisplay ()
void UpdateDisplay ()
void AddTrack (const CandTrackHandle *cth)

Private Attributes

TCanvas * fCanvas
TH2D * fUZview
TH2D * fVZview
TPad * fUVview
TPad * fHistPad
SteelOutlinefSteelOutline
TList * fCleanup

Detailed Description

Id
UserDisplayModule.h,v 1.5 2005/06/24 19:33:06 rhatcher Exp

Definition at line 30 of file UserDisplayModule.h.


Constructor & Destructor Documentation

UserDisplayModule::UserDisplayModule (  ) 

Definition at line 33 of file UserDisplayModule.cxx.

References fCleanup.

00034     : fCanvas(0)
00035     , fUZview(0)
00036     , fVZview(0)
00037     , fUVview(0)
00038     , fSteelOutline(0)
00039     , fCleanup(0)
00040 {
00041     fCleanup = new TList;
00042     fCleanup->SetOwner();
00043 }

UserDisplayModule::~UserDisplayModule (  )  [virtual]

Definition at line 45 of file UserDisplayModule.cxx.

References fCleanup, fUVview, fUZview, and fVZview.

00046 {
00047     if (fUZview) delete fUZview;
00048     if (fVZview) delete fVZview;
00049     if (fUVview) delete fUVview;
00050     if (fCleanup) delete fCleanup;
00051 }


Member Function Documentation

void UserDisplayModule::AddTrack ( const CandTrackHandle cth  )  [private]

Definition at line 176 of file UserDisplayModule.cxx.

References Munits::centimeter, fCleanup, fUVview, fUZview, fVZview, CandHandle::GetDaughterIterator(), CandTrackHandle::GetU(), Mint::GetUgliGeomHandle(), CandTrackHandle::GetV(), gMint, UgliGeomHandle::IsValid(), PlaneView::kU, PlaneView::kV, Nav::kWarning, MSG, and UgliGeomHandle::uv2xy().

Referenced by UpdateDisplay().

00177 {
00178     UgliGeomHandle ugh = gMint->GetUgliGeomHandle();
00179     if (! ugh.IsValid()) {
00180         MSG("User",kWarning) << "Got invalid Ugli\n";
00181         return;
00182     }
00183 
00184     // Track daughter list are a set of candidate strips.
00185     TIter titr(cth->GetDaughterIterator());
00186 
00187     while (CandStripHandle* csh = dynamic_cast<CandStripHandle*>(titr())) {
00188         int plane = csh->GetPlane();
00189         int strip = csh->GetStrip();
00190         float charge = csh->GetCharge();
00191 
00192         switch (csh->GetPlaneView()) {
00193         case PlaneView::kU:
00194             fUZview->Fill(plane,strip,charge);
00195             break;
00196         case PlaneView::kV:
00197             fVZview->Fill(plane,strip,charge);
00198             break;
00199         default:                // silently ignore
00200             break;
00201         }
00202 
00203         double radius = 4.0*Munits::centimeter;
00204         double x,y, u = cth->GetU(plane), v = cth->GetV(plane);
00205         ugh.uv2xy(u,v,x,y);
00206 
00207         fUVview->cd();
00208         TEllipse* el = new TEllipse(x,y,radius,radius);
00209         el->Draw();
00210         fCleanup->Add(el);
00211     }
00212 
00213 }

JobCResult UserDisplayModule::Ana ( const MomNavigator mom  )  [virtual]

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 58 of file UserDisplayModule.cxx.

References fCanvas, Mint::GetJobC(), gMint, JobCResult::kAOK, DDS::kError, Nav::kWarning, JobC::Mom, MSG, and UpdateDisplay().

00059 {
00060     if (gMint) {                // paranoia
00061         if (&gMint->GetJobC().Mom != mom) {
00062             MSG("User",kError) << "Module's mom and JobC's mom differ: "
00063                                << (void*)&gMint->GetJobC().Mom << " != "
00064                                << (void*) mom << endl;
00065         }
00066     }
00067 
00068     if (!fCanvas) {
00069         // No canvas - we can't do anything, but otherwise nothing
00070         // to say that there is a problem, so just return "ok".
00071         MSG("User",kWarning) << "I have no canvas!\n";
00072         return JobCResult::kAOK;
00073     }
00074 
00075     this->UpdateDisplay();
00076 
00077     return JobCResult::kAOK;
00078 }

void UserDisplayModule::BeginRun (  )  [virtual]

Implement for notification of begin of run (meaningful for Daq data only). See GetCurrentRun().

Reimplemented from JobCModule.

Definition at line 53 of file UserDisplayModule.cxx.

References BuildDisplay(), fCanvas, and gMint.

00054 {
00055     if (gMint && !fCanvas) this->BuildDisplay();
00056 }

void UserDisplayModule::BuildDisplay (  )  [private]

Definition at line 80 of file UserDisplayModule.cxx.

References PageDisplay::AddPage(), fCanvas, fHistPad, fSteelOutline, fUVview, fUZview, fVZview, CanvasSignals::GetCanvas(), DataUtil::GetDetector(), Mint::GetDisplay(), Mint::GetJobC(), UgliGeomHandle::GetScintPlnHandleVector(), UgliGeomHandle::GetTransverseExtent(), Mint::GetUgliGeomHandle(), gMint, UgliGeomHandle::IsValid(), PlaneView::kU, PlaneView::kV, Nav::kWarning, JobC::Mom, MSG, Mint::SpawnDisplay(), and PageDisplay::SpawnSinglePage().

Referenced by BeginRun().

00081 {
00082     // Get Ugli for later.  Bail immediately if fail
00083     UgliGeomHandle ugh = gMint->GetUgliGeomHandle();
00084     if (! ugh.IsValid()) {
00085         MSG("User",kWarning) << "Got invalid Ugli\n";
00086         return;
00087     }
00088 
00089 
00090     const int width = 1000, height = 500;
00091 
00092     CanvasSignals* cs = 0;
00093     PageDisplay* pd = gMint->GetDisplay();
00094 
00095     // No pre-existing display, so make one to our size
00096     if (!pd) {
00097         pd = gMint->SpawnDisplay(width,height);
00098         cs = dynamic_cast<CanvasSignals*>
00099             (pd->AddPage("UserCanvas"));
00100     }
00101     // A display exists, so let's add a stand alone window (one could
00102     // also just as well do a PageDisplay::AddPage, but would not have
00103     // to live with whatever size was given in its creation).
00104     else {
00105         cs = dynamic_cast<CanvasSignals*>
00106             (pd->SpawnSinglePage("UserCanvas",width,height));
00107     }
00108 
00109     if (!cs) {
00110         MSG("User",kWarning) << "Failed to get UserCanvas's CanvasSignals\n";
00111         return;
00112     }
00113 
00114     // One can use CanvasSignals to connect to various events,
00115     // eg. zooming or in particular notification of new data.  But
00116     // since we are in a job module, we already get notification in
00117     // Ana(), so just use the CanvasSignals to access the TCanvas;
00118     fCanvas = &cs->GetCanvas();
00119 
00120     // Now fill up the canvas with whatever we want.  This example
00121     // uses simple 2D colored histograms to present 3 views of the
00122     // data.
00123     fCanvas->Divide(2,1);
00124 
00125     // Work out the extents of the histograms.  This implicitly
00126     // assumes FarDet and probably needs to be improved for NearDet,
00127     // but should take into account the missing scint. plane in
00128     // between super modules.
00129     vector<UgliScintPlnHandle> sph = ugh.GetScintPlnHandleVector();
00130     int first_plane = sph.begin()->GetPlaneNumber();
00131     int last_plane = (sph.end()-1)->GetPlaneNumber();
00132     // Assume strip numbers start from 0!
00133     int nstrips = sph.begin()->NumberOfStrips();
00134     
00135     fCanvas->cd(1);
00136     fHistPad = new TPad("fHistPad","UZ and VZ views",0,0,1,1);
00137     fHistPad->Draw();
00138 
00139     fHistPad->cd();
00140     fHistPad->Divide(1,2);
00141 
00142     // U vs. Z view
00143     fHistPad->cd(1);
00144     fUZview = new TH2D("UZview","Strip vs. Plane, U view",
00145                        last_plane-first_plane+1,first_plane,last_plane+1,
00146                        nstrips,0,nstrips);
00147     fUZview->SetStats(false);
00148     fUZview->Draw("COLZ");
00149 
00150     // V vs. Z view
00151     fHistPad->cd(2);
00152     fVZview = new TH2D("VZview","Strip vs. Plane, V view",
00153                        last_plane-first_plane+1,first_plane,last_plane+1,
00154                        nstrips,0,nstrips);
00155     fVZview->SetStats(false);
00156     fVZview->Draw("COLZ");
00157     
00158     // U vs. V view
00159     fCanvas->cd(2);
00160     fUVview = new TPad("UVview","U vs V view",0,0,1,1);
00161     fUVview->SetFillStyle(4000);
00162 
00163     float t[4];
00164     ugh.GetTransverseExtent(PlaneView::kU,t[0],t[1]);
00165     ugh.GetTransverseExtent(PlaneView::kV,t[2],t[3]);
00166     for (int ind=0; ind<4;++ind) t[ind] = TMath::Abs(t[ind]);
00167     int maxind = TMath::LocMax(4,t);
00168     float tsize = TMath::Sqrt(2.0) * t[maxind];
00169 
00170     fUVview->Range(-tsize,-tsize,tsize,tsize);
00171     fUVview->Draw();
00172 
00173     fSteelOutline = new SteelOutline(DataUtil::GetDetector(gMint->GetJobC().Mom));
00174 }

void UserDisplayModule::UpdateDisplay (  )  [private]

Definition at line 222 of file UserDisplayModule.cxx.

References AddTrack(), clear_hist(), SteelOutline::Draw(), fCanvas, fCleanup, fHistPad, fSteelOutline, fUVview, fUZview, fVZview, CandHandle::GetNDaughters(), Mint::GetTracks(), and gMint.

Referenced by Ana().

00223 {
00224     static TText* no_tracks = 0;
00225 
00226     if (! no_tracks) {
00227         no_tracks = new TText(0.,0.,"No Tracks");
00228         no_tracks->SetTextSizePixels(100);
00229         no_tracks->SetTextColor(2);
00230     }
00231 
00232     clear_hist(fUZview);
00233     clear_hist(fVZview);
00234     fUVview->Clear();
00235     fCleanup->Delete();
00236 
00237     fUVview->cd();
00238     fSteelOutline->Draw();
00239 
00240     // Get whatever tracks Mint has as current.
00241     const CandTrackListHandle* ctlh = gMint->GetTracks();
00242 
00243     if (ctlh && ctlh->GetNDaughters()) {
00244         typedef vector<const CandTrackHandle*> TrackVector_t;
00245         TrackVector_t tv = CDL2STLvector<const CandTrackHandle>(*ctlh);
00246         for (unsigned int ind = 0; ind < tv.size(); ++ind) {
00247             this->AddTrack(tv[ind]);
00248         }
00249     }
00250     else no_tracks->Draw();
00251 
00252 
00253     fUVview->Modified();
00254     fHistPad->cd(1);
00255     gPad->Modified();
00256     fHistPad->cd(2);
00257     gPad->Modified();
00258     fCanvas->Modified();
00259     fCanvas->Update();
00260 }


Member Data Documentation

TCanvas* UserDisplayModule::fCanvas [private]

Definition at line 51 of file UserDisplayModule.h.

Referenced by Ana(), BeginRun(), BuildDisplay(), and UpdateDisplay().

TList* UserDisplayModule::fCleanup [private]

Definition at line 55 of file UserDisplayModule.h.

Referenced by AddTrack(), UpdateDisplay(), UserDisplayModule(), and ~UserDisplayModule().

TPad * UserDisplayModule::fHistPad [private]

Definition at line 53 of file UserDisplayModule.h.

Referenced by BuildDisplay(), and UpdateDisplay().

Definition at line 54 of file UserDisplayModule.h.

Referenced by BuildDisplay(), and UpdateDisplay().

TPad* UserDisplayModule::fUVview [private]

Definition at line 53 of file UserDisplayModule.h.

Referenced by AddTrack(), BuildDisplay(), UpdateDisplay(), and ~UserDisplayModule().

TH2D* UserDisplayModule::fUZview [private]

Definition at line 52 of file UserDisplayModule.h.

Referenced by AddTrack(), BuildDisplay(), UpdateDisplay(), and ~UserDisplayModule().

TH2D * UserDisplayModule::fVZview [private]

Definition at line 52 of file UserDisplayModule.h.

Referenced by AddTrack(), BuildDisplay(), UpdateDisplay(), and ~UserDisplayModule().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1