23 #include "Riostream.h"
25 #ifndef Gw_AgataEventDisplay
29 #ifndef Gw_AgataEventContainer
33 #ifndef Gw_AgataGeometryTransformer
37 #ifndef Gw_AgataHitDisplay
41 #ifndef Gw_AgataTrackDisplay
46 #ifndef ROOT_TEveGeoNode
47 #include "TEveGeoNode.h"
50 #ifndef ROOT_TEveManager
51 #include "TEveManager.h"
54 #ifndef ROOT_TEveBrowser
55 #include "TEveBrowser.h"
58 #ifndef ROOT_TGeoManager
59 #include "TGeoManager.h"
66 #ifndef ROOT_TGeoVolume
67 #include "TGeoVolume.h"
74 #ifndef ROOT_TGLViewer
75 #include "TGLViewer.h"
82 #ifndef ROOT_TGTextView
83 #include "TGTextView.h"
86 #ifndef ROOT_TGTextEntry
87 #include "TGTextEntry.h"
122 if (fgInstance == 0x0)
129 AgataEventDisplay::AgataEventDisplay()
132 fQuadHitList(new TList()),
133 fLineTrackList(new TList()),
144 fQuadHitList->SetOwner(
true);
145 fLineTrackList->SetOwner(
true);
147 if ( gGeoManager == NULL ) {
149 new TGeoManager(
"Agata",
"Creating Geometry AGATA");
151 TGeoMaterial *mat =
new TGeoMaterial(
"Vacuum",0,0,0);
152 TGeoMedium *med =
new TGeoMedium(
"Vacuum",1,mat);
154 fTopVolume = gGeoManager->MakeBox(
"World",med,100,100,100);
163 delete fAgataContainer;
165 delete fLineTrackList;
171 fRefreshButton->Delete();
178 TGeoVolume* vol = 0x0;
179 if (agataGeo && !fgAgataGeoDone) {
180 TGeoRotation* rot =
new TGeoRotation();
185 fgAgataGeoDone =
true;
189 if (passiveGeo && !fgPassiveGeoDone) {
194 TGeoTranslation trans(-18*TMath::Sin(42*TMath::DegToRad()), 0., -18*TMath::Cos(42*TMath::DegToRad()));
197 TGeoHMatrix *hm =
new TGeoHMatrix(transfo);
202 fgPassiveGeoDone =
true;
208 fgPassiveGeoDone =
true;
211 if (fgFloorGeoDone) {
212 TGeoTranslation* trans2 =
new TGeoTranslation();
218 trans2->SetDx(-260.);
225 fgPassiveGeoDone =
true;
230 if (danteGeo && !fgDanteGeoDone) {
231 TGeoRotation* rot =
new TGeoRotation();
236 fgDanteGeoDone =
true;
240 if (prismaGeo && !fgPrismaGeoDone) {
244 fgPrismaGeoDone =
true;
269 gEve->FullRedraw3D(kTRUE);
274 TEveManager::Create();
275 gEve->AddEvent(
this);
278 TGeoNode* topNode = gGeoManager->GetTopNode();
279 TGeoManager::SetVerboseLevel(0);
280 if (topNode == 0x0) {
284 TEveGeoTopNode* out =
new TEveGeoTopNode(gGeoManager, topNode);
285 gEve->AddGlobalElement(out);
291 std::map<const Char_t*, const Char_t*>::iterator it;
297 quadHits->SetDefWidth(fQuadDefWidth);
298 quadHits->SetDefHeight(fQuadDefHeight);
299 quadHits->SetPickable(
true);
300 fQuadHitList->Add(quadHits);
304 for (it = fMapStyle.begin(); it != fMapStyle.end(); ++it) {
305 TString sType(it->first);
306 if (sType.Contains(type)) {
307 TString sStyle(it->second);
313 lineTracks->SetDefWidth(fBoxDefWidth);
314 lineTracks->SetDefHeight(fBoxDefHeight);
315 lineTracks->SetPickable(
true);
316 fLineTrackList->Add(lineTracks);
322 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,24,0)
323 TGLViewer* v = gEve->GetDefaultGLViewer();
325 TGLViewer* v = gEve->GetGLViewer();
328 v->SetClearColor(kWhite);
330 gEve->FullRedraw3D(kTRUE);
341 TEveBrowser* browser = gEve->GetBrowser();
342 browser->StartEmbedding(TRootBrowser::kLeft);
344 TGMainFrame* frmMain =
new TGMainFrame(gClient->GetRoot(), 1000, 600);
345 frmMain->SetWindowName(
"XX GUI");
346 frmMain->SetCleanup(kDeepCleanup);
348 TGHorizontalFrame *eventFrame =
new TGHorizontalFrame(frmMain);
350 TString icondir( Form(
"%s/icons/", gSystem->Getenv(
"ROOTSYS")) );
351 TGPictureButton*
b = 0x0;
353 b =
new TGPictureButton(eventFrame, gClient->GetPicture(icondir +
"ReloadPage.gif"));
354 eventFrame->AddFrame(b);
355 b->SetToolTipText(
"First Event");
356 b->Connect(
"Clicked()",
"Gw::AgataEventDisplay",
this,
"FirstEvent()");
358 b =
new TGPictureButton(eventFrame, gClient->GetPicture(icondir +
"GoBack.gif"));
359 eventFrame->AddFrame(b);
360 b->SetToolTipText(
"Previous Event");
361 b->Connect(
"Clicked()",
"Gw::AgataEventDisplay",
this,
"PrevEvent()");
363 b =
new TGPictureButton(eventFrame, gClient->GetPicture(icondir +
"GoForward.gif"));
364 eventFrame->AddFrame(b);
365 b->SetToolTipText(
"Next Event");
366 b->Connect(
"Clicked()",
"Gw::AgataEventDisplay",
this,
"NextEvent()");
368 fRefreshButton =
new TGCheckButton(eventFrame,
"Refresh", 1);
369 fRefreshButton->SetState(kButtonDown);
370 eventFrame->AddFrame(fRefreshButton,
new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 0, 5, 0));
371 frmMain->AddFrame(eventFrame,
new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 0, 5, 5));
373 TGVerticalFrame *infoFrameView =
new TGVerticalFrame(frmMain);
374 fEventEntry =
new TGTextEntry(infoFrameView);
375 infoFrameView->AddFrame(fEventEntry,
new TGLayoutHints(kLHintsLeft | kLHintsCenterY |
376 kLHintsExpandX, 2, 10, 0, 10));
378 TGLabel* infoName =
new TGLabel(infoFrameView,
"Selection:");
379 infoFrameView->AddFrame(infoName,
new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 0, 5, 5));
381 fInfoView =
new TGTextView(infoFrameView, 300, 400);
382 fInfoView->ShowBottom();
383 infoFrameView->AddFrame(fInfoView,
new TGLayoutHints(kLHintsLeft | kLHintsCenterY |
384 kLHintsExpandX, 2, 10, 0, 0));
386 TGTextButton* clearInfo =
new TGTextButton(infoFrameView,
"&Clear");
387 clearInfo->Connect(
"Clicked()",
"Gw::AgataEventDisplay",
this,
"ClearInfoView()");
388 clearInfo->SetToolTipText(
"Clear Info View");
389 infoFrameView->AddFrame(clearInfo,
new TGLayoutHints(kLHintsLeft | kLHintsCenterY,15,5,3,4));
391 frmMain->AddFrame(infoFrameView,
new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 0, 5, 5));
392 frmMain->MapSubwindows();
394 frmMain->MapWindow();
395 browser->StopEmbedding();
396 browser->SetTabTitle(
"Info", 0);
400 quadHits->SetEmitSignals(
true);
401 quadHits->Connect(
"SecSelected(TEveDigitSet*, Int_t )",
"Gw::AgataEventDisplay",
this,
"UpdateHitInfo(TEveDigitSet*, Int_t)");
404 lineTracks->SetEmitSignals(
true);
405 lineTracks->Connect(
"SecSelected(TEveDigitSet*, Int_t )",
"Gw::AgataEventDisplay",
this,
"UpdateTrackInfo(TEveDigitSet*, Int_t)");
415 fInfoView->AddLine( Form(
"%s # %3d with energy: %3d\n", quadHits->GetName(), idx, quadHits->
GetSelectedValue()) );
423 std::pair<Int_t, Int_t> p;
426 fInfoView->AddLine( Form(
"%s # %2d:", lineTracks->GetName(), p.first) );
427 fInfoView->AddLine( Form(
" associated hit# %2d\n", p.second) );
428 fInfoView->AddLine( Form(
" and energy: %3d\n", lineTracks->
GetSelectedValue()) );
436 fInfoView->ShowBottom();
451 gEve->AddElement(quadHits);
455 gEve->AddElement(lineTracks);
471 fLog <<
warning <<
"Reseting iterator by calling FirstEvent method" <<
nline;
529 if (!fGUIFlag || (fGUIFlag && fRefreshButton->IsOn())) {
534 TClonesArray* hitList = 0x0;
539 if (hitList == 0x0) {
540 fLog <<
debug << Form(
"Track not available for this event in type %s", type) <<
dolog;
543 Int_t nHits = hitList->GetEntries();
544 printf(
"%s Tracks display %d\n", type, nHits);
545 for (Int_t i = 0; i < nHits; ++i) {
547 TObject* obj = hitList->At(i);
549 tHit =
dynamic_cast<TrackHit*
> ( obj );
552 Float_t eTot = tHit->
GetE();
561 for (Int_t j = 0; j < tHit->
GetNbHits(); ++j) {
568 if (x == 0.0 && y == 0.0 && z == 0.0)
continue;
572 lineTracks->
AddTracklet(e, xOld, yOld, zOld, x, y, z);
575 lineTracks->
AddTracklet(eTot, xOld, yOld, zOld, x, y, z,
true);
586 if (hitList == 0x0) {
587 fLog <<
debug << Form(
"Hit not available for this event in type %s", type) <<
dolog;
590 Int_t nHits = hitList->GetEntries();
592 for (Int_t i = 0; i < nHits; ++i) {
594 TObject* obj = hitList->At(i);
596 sHit =
dynamic_cast<StdHit*
> ( obj );
599 Float_t x = sHit->
GetX();
600 Float_t y = sHit->
GetY();
601 Float_t z = sHit->
GetZ();
602 Float_t e = sHit->
GetE();
604 quadHits->
AddHit(e, x, y, z);
605 quadHits->QuadId(
new TNamed(Form(
"hit %d", i),
"Hit Only"));
610 quadHits->RefitPlex();
611 lineTracks->RefitPlex();
613 gEve->FullRedraw3D(kFALSE);
AgataEventContainer class that contains agata event to be displayed.
const Char_t * RegisterBranch(Option_t *type="")
Register branch, return name of type.
printf("******************************************************************** \n")
virtual Float_t GetY() const
void AgataTrackDisplay(Int_t nEvents=100)
Macro that generates gamma rays from a given level scheme and generated randomly associated positions...
static const Char_t * GetTypeName(Int_t idx)
Get type name.
AgataTrackDisplay a class to display tracks on event.
LogMessage & error(LogMessage &)
const Char_t * RegisterBranch(Option_t *type="")
Register branch.
LogMessage & warning(LogMessage &)
AgataEventDisplay a class to work on a specific event display.
void ResetTracks()
Reset tracks.
BaseEventDisplay base class to work on event display.
virtual Float_t GetZ() const
Int_t GetSelectedValue()
Get current digit value.
LogMessage & nline(LogMessage &)
virtual ~AgataEventDisplay()
void UpdateTrackInfo(TEveDigitSet *qs, Int_t idx)
Update tracks info.
TClonesArray * GetHitList(Int_t ievent, Option_t *type="Agata", Bool_t warn=true)
get array
void SetStyle(TString s)
Set style (rec/cone)
virtual Float_t GetX() const
Setter position & energy.
Int_t GetSelectedValue()
Get selected digit value.
void BuildDefaultGeometry(Bool_t danteGeo=true, Bool_t prismaGeo=true, Bool_t agataGeo=true, Bool_t passiveGeo=true)
void AddHit(Float_t e, Float_t x, Float_t y, Float_t z)
Add hit.
void AddTracklet(Float_t e, Float_t x1, Float_t y1, Float_t z1, Float_t x2, Float_t y2, Float_t z2, Bool_t eTot=false)
Add Track.
void ClearInfoView()
Clear info view.
std::pair< Int_t, Int_t > GetIndexes(Int_t index)
Get index pair.
StdHit * GetHit(Int_t i=0) const
Get Hit number i of the track (already added with NewHit !!)
Int_t GetNofBranches() const
Get number of bracnhes.
void AddNewTrack()
Add new track, resetting counter.
Int_t GetNbHits() const
It returns the number of hits for this tracked particle.
LogMessage & dolog(LogMessage &)
void ClearEvents()
clear list or delete when dynamical memory allocation
void SetMaxEnergy(Float_t e)
Set Max energy.
TClonesArray * GetTrackList(Int_t ievent, Option_t *type="Agata", Bool_t warn=true)
get array
static Bool_t fgIsDisplayed
LogMessage & debug(LogMessage &)
void UpdateElements()
Update elements to be displayed.
virtual Float_t GetE() const
virtual void AddGeometry(TGeoVolume *volume, TGeoMatrix *matrix=gGeoIdentity)
void ResetHits()
Reset hits.
virtual std::string & GetProcessName()
To get the Process name.
void SetMaxEnergy(Float_t e)
Set Max energy.
void SetTrackStyle(const Char_t *s, Option_t *type="Agata")
Set track style (rec/cone)
virtual Float_t GetE() const
void UpdateHitInfo(TEveDigitSet *qs, Int_t idx)
Update hits info.
virtual void SetProcessMethod(const char *)
To set the current method.
AgataHitDisplay a class to display hits on event.
Int_t GetNofEvents() const
get Number of events