17 #include <TRootEmbeddedCanvas.h>
18 #include <RQ_OBJECT.h>
21 RQ_OBJECT(
"fgtEvDisFrame")
23 enum { kEvent, kTimeBin, kDisc, kQuad, kNum = 4 };
26 TRootEmbeddedCanvas *mEcanvas;
28 TGLayoutHints *mLayHintMain, *mLayHintPlot, *mLayHintOptions, *mLayHintNum;
29 TGLayoutHints *mLayHintButton, *mLayHintRad;
32 TGHorizontalFrame *mMainHortzFrame;
33 TGVerticalFrame *mOptFrame;
34 TGVerticalFrame *mNumFrame;
35 TGHorizontalFrame *mNumFrameInner[kNum];
36 TGHorizontalFrame *mButtonFrame;
39 TGNumberEntry *mNumEntry[kNum];
40 TGLabel *mNumLabel[kNum];
41 TGGroupFrame *mRadioFrame;
42 TGRadioButton *mRad1, *mRad2;
45 TGTextButton *mDrawButton;
46 TGTextButton *mExitButton;
49 TGCompositeFrame *mMessFrame;
53 std::string mLastName;
54 std::stringstream mSS;
58 TH2F *hPlast, *hRlast;
63 fgtEvDisFrame(
const TGWindow *p,UInt_t w,UInt_t h,
const Char_t *filename );
69 void GetHists(
const std::string& name, TH2F* &hP, TH2F* &hR );
73 Int_t numinit[] = { 0, 2, 0, 0, 0 };
74 const Char_t *numlabel[50] = {
"Event",
"Time Bin",
"Disc",
"Quad",
"Side" };
76 fgtEvDisFrame::fgtEvDisFrame(
const TGWindow *p,UInt_t w,UInt_t h,
const Char_t *filename )
77 : hPlast(0), hRlast(0) {
79 mTFile =
new TFile( filename,
"READ" );
80 if( !mTFile || !mTFile->IsOpen() ){
81 cerr <<
"ERROR opening file '" << filename <<
"'" << endl;
86 gROOT->SetStyle(
"Plain");
89 mMain =
new TGMainFrame(p,w,h);
92 mMainHortzFrame =
new TGHorizontalFrame(mMain, 1000, 2000);
93 mLayHintMain =
new TGLayoutHints(kLHintsCenterY|kLHintsCenterX|kLHintsTop|kLHintsLeft|kLHintsExpandX|kLHintsExpandY,10,10,10,1);
94 mMain->AddFrame( mMainHortzFrame, mLayHintMain );
97 mEcanvas =
new TRootEmbeddedCanvas(
"Ecanvas",mMainHortzFrame,700,600);
100 gStyle->SetOptStat(0);
101 TCanvas *canPtr = mEcanvas->GetCanvas();
102 canPtr->SetBorderSize(0);
105 gPad->SetBorderMode(0);
106 gPad->SetTopMargin(0.01);
107 gPad->SetRightMargin(0.16);
108 gPad->SetLeftMargin(0.1);
110 gPad->SetBorderMode(0);
111 gPad->SetTopMargin(0.01);
112 gPad->SetRightMargin(0.16);
113 gPad->SetLeftMargin(0.15);
116 mLayHintPlot =
new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX|kLHintsExpandY,10,10,10,10);
117 mMainHortzFrame->AddFrame(mEcanvas, mLayHintPlot);
121 mOptFrame =
new TGVerticalFrame( mMainHortzFrame, 50, 50 );
122 mLayHintOptions =
new TGLayoutHints(kLHintsTop|kLHintsRight|kLHintsExpandY,10,10,10,10);
123 mMainHortzFrame->AddFrame(mOptFrame, mLayHintOptions );
126 mNumFrame =
new TGVerticalFrame(mOptFrame, 200, 300);
127 mLayHintNums =
new TGLayoutHints(kLHintsCenterY|kLHintsExpandX, 2, 2, 2, 2);
128 mOptFrame->AddFrame(mNumFrame, mLayHintNums );
130 for( Int_t i = 0; i < kNum; ++i ){
132 mNumFrameInner[i] =
new TGHorizontalFrame(mNumFrame, 200, 30);
133 mNumFrame->AddFrame(mNumFrameInner[i], mLayHintNums);
136 mNumLabel[i] =
new TGLabel(mNumFrameInner[i], numlabel[i] );
137 mNumFrameInner[i]->AddFrame(mNumLabel[i], mLayHintNums);
140 mNumEntry[i] =
new TGNumberEntry(mNumFrameInner[i], numinit[i], 12, i + 20,(TGNumberFormat::EStyle) 0);
141 mNumFrameInner[i]->AddFrame(mNumEntry[i], mLayHintNums);
144 mNumEntry[i]->Connect(
"ValueSet(Long_t)",
"fgtEvDisFrame",
this,
"DoDraw()");
147 mNumEntry[kEvent] ->SetLimits(TGNumberFormat::kNELLimitMin, 0, 100 );
148 mNumEntry[kTimeBin]->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, 4 );
149 mNumEntry[kDisc] ->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, 5 );
150 mNumEntry[kQuad] ->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, 3 );
153 mButtonFrame =
new TGHorizontalFrame(mOptFrame,200,40);
154 mDrawButton =
new TGTextButton(mButtonFrame,
"&Draw");
155 mDrawButton->Connect(
"Clicked()",
"fgtEvDisFrame",
this,
"DoDraw()");
156 mButtonFrame->AddFrame(mDrawButton,
new TGLayoutHints(kLHintsCenterX,5,5,3,4));
158 mExitButton =
new TGTextButton(mButtonFrame,
"&Exit",
"gApplication->Terminate(0)");
159 mButtonFrame->AddFrame(mExitButton,
new TGLayoutHints(kLHintsCenterX,5,5,3,4));
160 mOptFrame->AddFrame( mButtonFrame,
new TGLayoutHints(kLHintsCenterX,5,5,3,4));
163 mMessFrame =
new TGCompositeFrame( mOptFrame, 100, 100, kSunkenFrame);
164 mOptFrame->AddFrame( mMessFrame,
new TGLayoutHints(kLHintsLeft|kLHintsLeft|kLHintsExpandX,3,3,3,3) );
165 mMessLabel =
new TGLabel( mMessFrame,
"initializing the class" );
166 mMessLabel->SetTextJustify( kTextCenterY|kTextLeft );
167 mMessFrame->AddFrame( mMessLabel,
new TGLayoutHints( kLHintsTop|kLHintsExpandX, 2,2,2,2 ));
169 mRadioFrame =
new TGGroupFrame( mNumFrame,
"Octant" );
170 mNumFrame->AddFrame( mRadioFrame, mLayHintNums );
172 mRad1 =
new TGRadioButton(mRadioFrame,
"&Long Side", 81);
173 mRad2 =
new TGRadioButton(mRadioFrame,
"&Short Side", 82);
174 mRad1->SetState(kButtonDown);
175 mRad2->SetState(kButtonUp);
177 mLayHintRad =
new TGLayoutHints( kLHintsCenterX, 2,2,2,2 );
178 mRadioFrame->AddFrame( mRad1, mLayHintRad );
179 mRadioFrame->AddFrame( mRad2, mLayHintRad );
180 mRad1->Connect(
"Clicked()",
"fgtEvDisFrame",
this,
"HandleButtons()");
181 mRad2->Connect(
"Clicked()",
"fgtEvDisFrame",
this,
"HandleButtons()");
185 mMain->SetWindowName(
"Offline FGT Event Display");
191 mMain->MapSubwindows();
194 mMain->Resize(mMain->GetDefaultSize());
196 cout <<
"Mapping main window" << endl;
204 void fgtEvDisFrame::DoDraw() {
205 TCanvas *canPtr = mEcanvas->GetCanvas();
210 <<
"_e" << mNumEntry[kEvent]->GetIntNumber()
211 <<
"_t" << mNumEntry[kTimeBin]->GetIntNumber()
212 <<
"_d" << mNumEntry[kDisc]->GetIntNumber()
213 <<
"_q" << mNumEntry[kQuad]->GetIntNumber()
214 << ( mRad1->GetState() ?
'L' :
'S' );
215 std::string name = mSS.str();
217 if( name != mLastName ){
218 mMessLabel->SetText(
"drawing" );
220 TH2F *hP = 0, *hR = 0;
221 GetHists( name, hP, hR );
224 gStyle->SetPalette(1);
225 hP->GetYaxis()->SetBinLabel( 1,
"inner" );
226 hP->GetYaxis()->SetBinLabel( 2,
"outer" );
229 hP->GetYaxis()->SetLabelSize(0.06);
230 hP->GetXaxis()->SetTitle(
"strip number");
231 hP->SetTitle(
"#phi Strips");
232 hP->SetMinimum( -500 );
233 hP->SetMaximum( 1500 );
238 hR->SetTitle(
"Radial Strips");
239 hR->GetXaxis()->SetBinLabel( 1,
"#phi in [0,#pi/4]" );
240 hR->GetYaxis()->CenterTitle();
241 hR->GetYaxis()->SetTitleOffset(1.5);
242 hR->GetYaxis()->SetTitle(
"strip number");
243 hR->GetXaxis()->SetLabelSize(0.06);
244 hR->SetMinimum( -500 );
245 hR->SetMaximum( 1500 );
253 <<
"e" << mNumEntry[kEvent]->GetIntNumber()
254 <<
" t" << mNumEntry[kTimeBin]->GetIntNumber()
255 <<
" d" << mNumEntry[kDisc]->GetIntNumber()
256 <<
" q" << mNumEntry[kQuad]->GetIntNumber()
257 <<
' ' << ( mRad1->GetState() ?
'L' :
'S' );
259 mMessLabel->SetText( mSS.str().data() );
274 <<
"e" << mNumEntry[kEvent]->GetIntNumber()
275 <<
" t" << mNumEntry[kTimeBin]->GetIntNumber()
276 <<
" d" << mNumEntry[kDisc]->GetIntNumber()
277 <<
" q" << mNumEntry[kQuad]->GetIntNumber()
278 <<
' ' << ( mRad1->GetState() ?
'L' :
'S' );
280 mMessLabel->SetText( mSS.str().data() );
286 fgtEvDisFrame::~fgtEvDisFrame() {
292 void fgtEvDisFrame::HandleButtons(){
297 TGButton *btn = (TGButton *) gTQSender;
298 id = btn->WidgetId();
303 mRad2->SetState(kButtonUp);
307 mRad1->SetState(kButtonUp);
314 void fgtEvDisFrame::FixTitle(){
318 TPaveText *title = (TPaveText*)(gPad->GetPrimitive(
"title"));
320 title->SetX1NDC( 0.045 );
321 title->SetX2NDC( 0.55 );
322 title->SetY1NDC( 0.91 ) ;
323 title->SetY2NDC( 0.999 );
324 title->SetBorderSize(0);
325 title->SetTextAlign( 12 );
326 title->SetTextColor(kBlue);
331 void fgtEvDisFrame::GetHists(
const std::string& name, TH2F* &hP, TH2F* &hR ){
342 hP = (TH2F*)mTFile->Get( (name +
"_P").data() );
343 hR = (TH2F*)mTFile->Get( (name +
"_R").data() );
346 void fgtOfflineEventDisplay(
const Char_t *filename ) {