23 #include <Riostream.h>
26 #ifndef ROOT_KeySymbols
27 #include "KeySymbols.h"
38 #ifndef ROOT_TContextMenu
39 #include "TContextMenu.h"
46 #ifndef ROOT_TGToolTip
47 #include "TGToolTip.h"
66 #ifndef ROOT_TVirtualX
67 #include "TVirtualX.h"
74 #ifndef Gw_BaseLSPlayer
78 #ifndef Gw_BaseNucleus
86 #ifndef Gw_NuclearLevel
94 #ifndef Gw_EnsdfLevelSchemeReader
98 #ifndef Gw_RadLevelSchemeReader
112 TNamed(
"BaseLSPlayer",
"Default"),
115 fBox(new TBox(0, fgDefaultWidth, 0, fgDefaultWidth)),
117 fSelectedLevels(new
Cascade()),
118 fSelectedCascades(new TList()),
119 fNucleiList(new TList()),
120 fLevelScheme(levelScheme),
121 fDrawStyle(kUnknown),
123 fInfoTip(new TGToolTip(fBox,
"", 350)),
126 fIsLSSelected(false),
127 fCColorSelectedLink(
BasePeak::gGateColor.k0),
137 fAxis->SetLineWidth(2);
138 fAxis->SetNdivisions(510);
139 fAxis->SetLabelSize(0.04);
159 TString name(select->ClassName());
161 if ( name.CompareTo(
"Gw::Link") == 0 ) {
162 Link* link =
static_cast<Link*
> ( select );
166 if ( name.CompareTo(
"Gw::Level") == 0 ) {
170 if ( select->InheritsFrom(
"Gw::GammaLink") ) {
178 if ( select->InheritsFrom(
"Gw::NuclearLevel") ) {
181 fInfoTip->SetText(Form(
"Energy: %6.1f\nSpin: %s+\nHalf-Live: %6.1f",
186 fInfoTip->SetText(Form(
"Energy: %6.1f\nSpin: %s-\nHalf-Live: %6.1f",
199 TCanvas *localCanvas = canvas;
202 if ( canvas == 0x0 ) {
203 if ( TVirtualPad::Pad() )
204 localCanvas = TVirtualPad::Pad()->GetCanvas();
210 localCanvas->Connect(
"ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
213 "HandleMovement(Int_t, Int_t, Int_t, TObject*)");
219 return localCanvas != 0x0;
227 TCanvas *localCanvas = canvas;
230 if ( canvas == 0x0 ) {
231 if ( TVirtualPad::Pad() ) {
232 localCanvas = TVirtualPad::Pad()->GetCanvas();
238 TQObject::Disconnect(localCanvas,
"HandleMovement(Int_t, Int_t, Int_t, TObject*)",
this);
244 return localCanvas != 0x0;
252 TVirtualPad* pad = TVirtualPad::Pad();
255 if (eventType == kButton1Up) {
271 if (eventType == kMouseMotion) {
273 fLastX = eventX; fLastY = eventY;
275 if ( select->InheritsFrom(
"Gw::BaseLSPlayer") ||
276 select->InheritsFrom(
"Gw::Cascade") ||
277 select->InheritsFrom(
"Gw::LevelScheme") ) {
278 pad->SetCursor(kPointer);
281 if ( select->InheritsFrom(
"Gw::Link") ) {
282 Link* link =
static_cast<Link*
>(select);
284 pad->SetCursor(kPointer);
287 if ( select->InheritsFrom(
"Gw::Level") ) {
290 pad->SetCursor(kPointer);
294 if ( select->InheritsFrom(
"Gw::Link") || select->InheritsFrom(
"Gw::Level")) {
302 if( eventType == kKeyPress) {
304 Int_t keysym = eventY;
306 Bool_t keyPress =
false;
307 switch ((EKeySym) keysym ) {
341 if ( select->InheritsFrom(
"Gw::Link") && keyPress) {
342 Link* link =
static_cast<Link*
>(select);
348 link->SetFillColor(color);
353 while ( (obj = next()) )
354 link =
static_cast<Link*
> ( obj );
358 if ( (EKeySym)keysym == kKey_s) {
360 if ( select->InheritsFrom(
"Gw::Level") ) {
372 while ( (obj = next()) )
373 level =
static_cast<Level*
> ( obj );
378 if ( select->InheritsFrom(
"Gw::Cascade") ) {
381 for (Int_t i = 0; i < cas->GetSize(); ++i) {
382 link =
static_cast<Link*
> (cas->At(i));
390 for (Int_t i = 0; i < cas->GetSize(); ++i) {
391 link =
static_cast<Link*
> (cas->At(i));
400 while ( (obj = next()) )
401 cas =
static_cast<Cascade*
> ( obj );
406 if ( (EKeySym)keysym == kKey_g)
409 if ( (EKeySym)keysym == kKey_P)
412 if ( (EKeySym)keysym == kKey_t) {
420 fAxis->SetLineColor(1);
421 fAxis->SetLabelColor(1);
425 if ( (EKeySym)keysym == kKey_i) {
433 if ( (EKeySym)keysym == kKey_a) {
444 if ( (EKeySym)keysym == kKey_h) {
445 cout <<
"Keys used to interact with LSPlayer: " <<
endl;
446 cout <<
"\t s: select a link/level/cascade " <<
endl;
447 cout <<
"\t 1/x: select a link for a gate on x-axis " <<
endl;
448 cout <<
"\t 2/y: select a link for a gate on y-axis " <<
endl;
449 cout <<
"\t 3/z: select a link for a gate on z-axis " <<
endl;
450 cout <<
"\t 4 : select a link for a gate on t-axis " <<
endl;
451 cout <<
"\t a: select the whole level scheme " <<
endl;
452 cout <<
"\t g: Show gates " <<
endl;
453 cout <<
"\t P: Draw total projection " <<
endl;
454 cout <<
"\t i: Toggle on/off information tips that appears when passing over an object" <<
endl;
455 cout <<
"\t t: Toggle on/off active LS menu on canvas " <<
endl;
456 cout <<
"\t l: Popup dialog box for Add Link method " <<
endl;
457 cout <<
"\t e: Popup dialog box for Add Level method " <<
endl;
458 cout <<
"\t f: Popup dialog box for Add First Level method " <<
endl;
459 cout <<
"\t G: Popup dialog box for Add Ground Level method " <<
endl;
460 cout <<
"\t w: Popup dialog box for writing level scheme in a root file " <<
endl;
461 cout <<
"\t p: Popup dialog box for making projection from registered correlated space " <<
endl;
464 if ( (EKeySym)keysym == kKey_l)
467 if ( (EKeySym)keysym == kKey_e)
470 if ( (EKeySym)keysym == kKey_f)
473 if ( (EKeySym)keysym == kKey_G)
476 if ( (EKeySym)keysym == kKey_w)
479 if ( (EKeySym)keysym == kKey_p)
496 TVirtualPad* pad = TVirtualPad::Pad();
505 if ( !opt.Contains(
"+") )
508 TObject *obj; Int_t i = 0;
510 TIter next(TVirtualPad::Pad()->GetListOfPrimitives());
511 while ( (obj = next()) )
512 if ( obj->InheritsFrom(
"Gw::Link") ) {
514 Link* link =
static_cast<Link*
> (obj);
532 TVirtualPad* pad = TVirtualPad::Pad();
541 if ( !opt.Contains(
"+") )
544 TObject *obj; Int_t i = 0;
546 TIter next(TVirtualPad::Pad()->GetListOfPrimitives());
547 while ( (obj = next()) )
548 if ( obj->InheritsFrom(
"Gw::Level") ) {
568 TVirtualPad* pad = TVirtualPad::Pad();
577 if ( !opt.Contains(
"+") )
580 TObject *obj; Int_t i = 0;
582 TIter next(TVirtualPad::Pad()->GetListOfPrimitives());
583 while ( (obj = next()) )
584 if ( obj->InheritsFrom(
"Gw::Cascade") ) {
620 Double_t xmin, xmax, ymin, ymax;
621 Double_t xminOld = 0.;
622 Double_t xmaxOld = 0.;
624 Double_t ymaxOld = 0.;
626 Double_t xRminOld, xRmaxOld, yRminOld, yRmaxOld;
627 Bool_t p1 =
false, p2 =
false, pL =
false;
635 if (!style.Contains(
"-t"))
638 if ( levels->GetSize() == 0 )
return;
649 if (!style.Contains(
"-le"))
652 if (!style.Contains(
"-b"))
655 if (!style.Contains(
"-l"))
659 level = (
Level *)levels->First();
660 xmin = level->GetX1(); xmax = level->GetX2(); ymin = level->GetY1(); ymax = level->GetY2();
663 while ( (level = (
Level *)iter()) ) {
664 if ( level->GetX1() < xmin ) xmin = level->GetX1();
665 if ( level->GetX2() > xmax ) xmax = level->GetX2();
666 if ( level->GetY1() < ymin ) ymin = level->GetY1();
667 if ( level->GetY1() > ymax ) ymax = level->GetY1();
670 Double_t xRmin =
GetXRmin(xmin, xmax);
671 Double_t xRmax =
GetXRmax(xmin, xmax);
673 Double_t yRmin =
GetYRmin(ymin, ymax);
674 Double_t yRmax =
GetYRmax(ymin, ymax);
677 if ( xmin > xmax || ymin > ymax ) {
678 fLog <<
error << Form(
" Problem when computing pad range, xmin > xmax or ymin > ymax") <<
dolog;
682 if ( TVirtualPad::Pad() != 0 ) {
683 TVirtualPad::Pad()->GetRange(xRminOld, yRminOld, xRmaxOld, yRmaxOld);
685 xminOld =
GetXMin(xRminOld, xRmaxOld);
686 xmaxOld =
GetXMax(xRminOld, xRmaxOld);
689 ymaxOld =
GetYMax(yRminOld, yRmaxOld);
691 if (xRmin < xRminOld || xRmax > xRmaxOld)
694 if (yRmin < yRminOld || yRmax > xRmaxOld)
705 TVirtualPad::Pad()->Range(xRmin, yRminOld, xRmax, yRmaxOld);
710 fAxis->SetWmax(ymaxOld);
714 TVirtualPad::Pad()->Range(xRminOld, yRmin, xRmaxOld, yRmax);
720 fAxis->SetWmax(ymax);
724 TVirtualPad::Pad()->Range(xRmin, yRmin, xRmax, yRmax);
730 fAxis->SetWmax(ymax);
734 name->SetX(0.55); name->SetY(0.95);
750 for (Int_t i = 0; i < list->GetEntries(); ++i) {
752 Link* link =
static_cast<Link*
> ( list->At(i) );
754 Double_t xi = link->GetX()[1];
755 Double_t xf = link->GetX()[5];;
756 Double_t x, y, offset1 = 0., offset2 = 0., prop;
759 offset1 = TMath::Max(TMath::Abs(link->
GetIL()->GetX2() - link->
GetIL()->GetX1())/30.,
761 offset2 = TMath::Min(2.5*offset1, TMath::Abs(link->
GetIL()->GetX2() - link->
GetIL()->GetX1())/2.);
765 offset1 = TMath::Abs(link->
GetIL()->GetX2() - link->
GetIL()->GetX1())/70.;
773 x = xi; y = link->GetY()[1];
774 link->SetPoint(0,x-offset1,y);
775 link->SetPoint(1,x,y);
776 link->SetPoint(2,x+offset1,y);
777 link->SetPoint(8,x-offset1,y);
779 x = xi + prop*(xf-xi);
780 y = link->
GetIL()->GetY1() - prop*(link->
GetIL()->GetY1() - link->
GetFL()->GetY1());
781 link->SetPoint(3,x+offset1,y);
782 link->SetPoint(4,x+offset2,y);
783 link->SetPoint(6,x-offset2,y);
784 link->SetPoint(7,x-offset1,y);
786 x = xf; y = link->
GetFL()->GetY1();
787 link->SetPoint(5,x,y);
796 TString fname(filename);
799 if ( fname.EndsWith(
".ags") ) {
805 if ( fname.EndsWith(
".ens") ) {
852 fLastY1Zoom = (Int_t)y1;
854 if (TVirtualPad::Pad() != 0) {
855 Double_t xRmin, yRmin, xRmax, yRmax;
856 TVirtualPad::Pad()->GetRange(xRmin, yRmin, xRmax, yRmax);
867 fLastY2Zoom = (Int_t)y2;
869 if (TVirtualPad::Pad() != 0) {
870 Double_t xRmin, yRmin, xRmax, yRmax;
871 TVirtualPad::Pad()->GetRange(xRmin, yRmin, xRmax, yRmax);
882 TVirtualPad* pad = TVirtualPad::Pad();
884 static Int_t eventYOld = 0;
885 static Bool_t buttonMotion =
false;
886 if (eventType == kMouseMotion) {
888 pad->SetCursor(kHand);
891 if (eventType == kButton1Down) {
892 fLastX = eventX; fLastY1 = eventY;
893 gVirtualX->SetLineColor(-1);
896 if (eventType == kButton1Motion) {
897 gVirtualX->DrawBox(fLastX-10, fLastY1, fLastX+10, eventYOld, TVirtualX::kHollow);
898 gVirtualX->DrawBox(fLastX-10, fLastY1, fLastX+10, eventY, TVirtualX::kHollow);
904 if (eventType == kButton1Up && buttonMotion) {
906 fLastY1 = (Int_t)gPad->AbsPixeltoY(fLastY1);
907 fLastY2 = (Int_t)gPad->AbsPixeltoY(fLastY2);
909 if (fLastY1 > fLastY2) {
925 pad->Range(pad->GetX1(), yRmin, pad->GetX2(), yRmax);
927 buttonMotion =
false;
934 TVirtualPad* pad = TVirtualPad::Pad();
951 SetX1(xmin-(xmax-xmin)*0.1); SetX2(xmin-(xmax-xmin)*0.1);
952 pad->Range(xRmin, yRmin, xRmax, yRmax);
964 TVirtualPad* pad = TVirtualPad::Pad();
967 SetWmin(fLastY1Zoom);
968 SetWmax(fLastY2Zoom);
978 pad->Range(pad->GetX1(), yRmin, pad->GetX2(), yRmax);
virtual Int_t CollectLevels(Option_t *o="")
Collect selected leveks.
TLatex & GetNameLatex()
to get Name latex object
virtual void DeSelected()
unselected link
TContextMenu * fContextMenu
static Color_t GetDefaultColor(EDefaultColor d)
virtual void RefreshPoints()
virtual void Paint(Option_t *option="")
void SetY2(Double_t y2)
Set Y2.
void SetCCascade(Cascade *cascade)
set current cascade
static Float_t GetYMin(Float_t yRmin, Float_t yRmax)
virtual void DeSelected()
unselected link
virtual void PopupAddFirstLevel()
Popup AddFirstLevel menu.
virtual Bool_t IsDrawStyle(EDrawStyle style)
get style
virtual void SetTipText(TObject *select)
set text for tool tip info
A cascade is a list of links.
virtual Bool_t IsSelected()
return selection
virtual void Select()
Select all objects.
LogMessage & error(LogMessage &)
LogMessage & warning(LogMessage &)
static Float_t GetYMax(Float_t yRmin, Float_t yRmax)
void SetCLevel(Level *level)
set current level
A RadLevelSchemeReader class to read radware level scheme files.
virtual void DoStyle(EDrawStyle style)
do style
Cascade * fSelectedLevels
pointer to the selected links
virtual EDefaultColor GetDefaultColor()
return default color
header file for a NuclearLevel
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance to object.
virtual void DeSelected()
unselected link
virtual Level * GetIL()
to get the initial level
LogMessage & nline(LogMessage &)
virtual Level * GetFL()
to get the final level
EDrawStyle fDrawStyle
pointer on level scheme
header file for a GammaLink
virtual void DeSelect()
Deselect all objects.
virtual Int_t ReadAGS(const Char_t *filename, Option_t *opt="152Dy")
for backward compatibility
static GateColor gGateColor
virtual void Selected()
Selected link.
static Float_t GetXMin(Float_t xRmin, Float_t xRmax)
Get size from range.
virtual Int_t ImportLevelScheme(const Char_t *, Option_t *)
to init this level scheme from an existing formatted file (ENSDF, Radware ..)
Color_t fCColorSelectedLink
virtual Int_t Import(LevelScheme &levelScheme)
imported level scheme file
virtual void PopupWriteLS()
Popup write LS menu.
virtual void PopupDoProject()
Popup DoProject menu.
virtual void ShowGate(Option_t *="gate")
Collect gates.
A link between two levels.
void HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject *select)
Handle Movement.
TList * fNucleiList
pointer to the selected levels
static Float_t GetYRmin(Float_t ymin, Float_t ymax)
virtual Data_T Get() const
get the value, can be overloaded
LogMessage & info(LogMessage &)
manipulator to modify the LogMessage
virtual void PopupAddLevel()
Popup AddLevel menu.
Parity & GetParity()
get the parity and modify it if it is needed
Measure< Float_t > & GetEnergy()
static Int_t GetDefaultToggleColor()
get default color for axis toggle
static Float_t GetYRmax(Float_t ymin, Float_t ymax)
Bool_t Disconnect(TCanvas *c=0x0)
Connect the Canvas to this to collect events.
static Float_t GetXRmax(Float_t xmin, Float_t xmax)
static Color_t GetDefaultColor()
virtual Int_t CollectCascades(Option_t *o="")
Collect selected cascades.
LogMessage & dolog(LogMessage &)
static Bool_t IsMovable()
const Char_t * GetString() const
To get the spin as a string.
bool IsParity(Parity::EParity) const
virtual Measure< Float_t > & GetEnergy()
to get/modify the gamma-ray energy and its error
virtual Bool_t IsSelected()
return selection
static Float_t GetXAxis(Float_t xmin, Float_t xmax)
Get position of axis in X.
Bool_t Connect(TCanvas *c=0x0)
Connect the Canvas to this to collect events.
LogMessage & debug(LogMessage &)
static Float_t GetYLabels(Float_t ymin, Float_t ymax)
Get position of labels in Y.
virtual Bool_t IsSelected()
return selection
BaseLSPlayer(LevelScheme *levelScheme)
default constructor
virtual Measure< Float_t > & GetStrength()
to get the strength and modify it if it is needed
virtual void SetLabelColor(EDefaultColor color)
Set color label.
void SetRange(Int_t ymin, Int_t ymax, Int_t xmin, Int_t xmax)
Set range axis.
header file for a BaseNucleus
void SetY1(Double_t y1)
Set Y1.
header file for a general 1D peak
ADF::LogMessage & endl(ADF::LogMessage &log)
static Bool_t IsMovable()
static Float_t GetXRmin(Float_t xmin, Float_t xmax)
Get range from size.
A BasePeak is defined by a height, intensity and a dimension of the peak.
TList & GetLevelList()
to get the list of levels
virtual void PopupAddLink()
Popup AddLink menu.
virtual void DrawProjTot(Option_t *="")
Draw projection total.
Spin & GetSpin()
to get the spin and modify it if it is needed
virtual UShort_t GetLambda() const
returns the numeric part of the multipolarity
virtual void Selected()
Selected link.
TList & GetCascadeList()
to get the list of cascades
A GammaLink binds two nuclear levels.
virtual void SetProcessMethod(const char *)
To set the current method.
LevelScheme * fLevelScheme
Measure< Float_t > & GetT()
virtual void PopupAddGroundLevel()
Popup AddGroundLevel.
static Float_t fgDefaultSize[]
size of the level scheme per default
LSaxis extented class of TGaxis, allows zooming.
virtual bool IsE() const
true if this transition is electric
TList * fSelectedCascades
pointer to the selected levels
void SetCLink(Link *link)
set current link
void ExecuteEvent(Int_t eventType, Int_t eventX, Int_t eventY)
Handle Movement.
virtual Int_t CollectLinks(Option_t *o="")
Collect selected links.
virtual void Selected()
Selected link.
static Float_t GetXMax(Float_t xRmin, Float_t xRmax)
A EnsdfLevelSchemeReader class to read radware level scheme files.
virtual Int_t ReadENSDF(const Char_t *, Option_t *)
for backward compatibility
static Int_t fgDefaultToggleColor
default color of axis when toggle is on
static Float_t fgDefaultWidth
default width for level, box etc...
virtual void Draw(Option_t *opt="")
to draw this level scheme
BaseLSPlayer to work on level scheme.
TList & GetLinkList()
to get the list of links
Base class describing a general level.