22 #define private public
43 #include "TEveManager.h"
44 #include "TEveEventManager.h"
45 #include "TEveTrackPropagator.h"
48 #include "TEveBrowser.h"
55 class CmsEveMagField :
public TEveMagField
63 CmsEveMagField() : TEveMagField(), fField(-3.8), fFieldMag(3.8) {}
64 virtual ~CmsEveMagField() {}
67 void SetFieldByCurrent(Float_t avg_current)
69 fField = -3.8 * avg_current / 18160.0;
70 fFieldMag = TMath::Abs(fField);
74 virtual Float_t GetMaxFieldMag()
const override
79 virtual TEveVector GetField(Float_t
x, Float_t
y, Float_t
z)
const override
81 static const Float_t barrelFac = 1.2 / 3.8;
82 static const Float_t endcapFac = 2.0 / 3.8;
84 const Float_t
R =
sqrt(x*x+y*y);
85 const Float_t absZ = TMath::Abs(z);
91 if (R < 300.0
f)
return TEveVector(0, 0, fField);
94 if ((R > 461.0
f && R < 490.5
f) ||
95 (R > 534.5
f && R < 597.5
f) ||
96 (R > 637.0
f && R < 700.0
f))
98 return TEveVector(0, 0, -fField*barrelFac);
101 if ((absZ > 724.0
f && absZ < 786.0
f) ||
102 (absZ > 850.0
f && absZ < 910.0
f) ||
103 (absZ > 975.0
f && absZ < 1003.0
f))
105 const Float_t fac = (z >= 0 ? fField : -fField) * endcapFac / R;
106 return TEveVector(x*fac, y*fac, 0);
109 return TEveVector(0, 0, 0);
127 m_EveManager(0), m_Rint(0),
129 m_AllowStep(
true), m_ShowEvent(
true),
130 m_ContinueButton(0), m_StepButton(0), m_StepLabel(0)
132 printf(
"EveService::EveService CTOR\n");
134 std::cout <<
" gApplication "<< gApplication <<std::endl;
135 std::cout <<
" is batch " << gROOT->IsBatch() <<std::endl;
136 std::cout <<
" display " << gSystem->Getenv(
"DISPLAY") <<std::endl;
138 const char* dummyArgvArray[] = {
"cmsRun"};
139 char** dummyArgv =
const_cast<char**
>(dummyArgvArray);
142 m_Rint =
new TRint(
"App", &dummyArgc, dummyArgv);
143 assert(TApplication::GetApplications()->GetSize());
145 gROOT->SetBatch(kFALSE);
146 std::cout<<
"calling NeedGraphicsLibs()"<<std::endl;
147 TApplication::NeedGraphicsLibs();
149 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,34,18)
152 TColor::fgInitDone=
false;
153 TColor::InitializeColors();
154 TStyle::BuildStyles();
155 gROOT->SetStyle(gEnv->GetValue(
"Canvas.Style",
"Modern"));
156 gStyle = gROOT->GetStyle(
"Classic");
161 m_EveManager->AddEvent(
new TEveEventManager(
"Event",
"Event Data"));
179 printf(
"EveService::~EveService DTOR\n");
191 printf(
"EveService::postBeginJob\n");
194 gSystem->ProcessEvents();
199 printf(
"EveService::postEndJob\n");
201 TEveManager::Terminate();
234 printf(
"RunInfo not available \n");
235 static_cast<CmsEveMagField*
>(
m_MagField)->SetFieldByCurrent(current);
242 printf(
"EveService::postProcessEvent: Starting GUI loop.\n");
256 gEve->GetCurrentEvent()->DestroyElements();
316 MkTxtButton(TGCompositeFrame*
p,
const char* txt, Int_t
width=0,
317 Int_t lo=0, Int_t ro=0, Int_t
to=0, Int_t bo=0)
322 TGTextButton*
b =
new TGTextButton(p, txt);
325 b->ChangeOptions(b->GetOptions() | kFixedWidth);
327 p->AddFrame(b,
new TGLayoutHints(kLHintsNormal, lo,ro,
to,bo));
334 const TString cls(
"EveService");
336 TEveBrowser *browser = gEve->GetBrowser();
337 browser->StartEmbedding(TRootBrowser::kBottom);
339 TGMainFrame *mf =
new TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame);
341 TGHorizontalFrame*
f =
new TGHorizontalFrame(mf);
342 mf->AddFrame(f,
new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
344 MkTxtButton(f,
"Exit", 100, 2, 2)->
345 Connect(
"Clicked()", cls,
this,
"slotExit()");
347 MkTxtButton(f,
"Next Event", 100, 2, 2)->
348 Connect(
"Clicked()", cls,
this,
"slotNextEvent()");
354 m_StepButton->Connect(
"Clicked()", cls,
this,
"slotStep()");
358 mf->AddFrame(
m_StepLabel,
new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));
360 mf->SetCleanup(kDeepCleanup);
365 browser->StopEmbedding(
"EventCtrl");
371 printf(
"EveService exiting on user request.\n");
void postEvent(edm::StreamContext const &)
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
EveService(const edm::ParameterSet &, edm::ActivityRegistry &)
void watchPostEvent(PostEvent::slot_type const &iSlot)
TGTextButton * m_ContinueButton
void watchPostGlobalBeginRun(PostGlobalBeginRun::slot_type const &iSlot)
TEveMagField * getMagField()
TGTextButton * m_StepButton
void display(const std::string &info="")
void postGlobalBeginRun(edm::GlobalContext const &)
TEveManager * getManager()
TEveManager * m_EveManager
void createEventNavigationGUI()
void setupFieldForPropagator(TEveTrackPropagator *prop)
void AddElement(TEveElement *el)
TEveMagField * m_MagField
void AddGlobalElement(TEveElement *el)
void watchPostBeginJob(PostBeginJob::slot_type const &iSlot)
convenience function for attaching to signal