42 #include "TEveManager.h" 43 #include "TEveEventManager.h" 44 #include "TEveTrackPropagator.h" 47 #include "TEveBrowser.h" 54 class CmsEveMagField :
public TEveMagField
62 CmsEveMagField() : TEveMagField(), fField(-3.8), fFieldMag(3.8) {}
63 virtual ~CmsEveMagField() {}
66 void SetFieldByCurrent(Float_t avg_current)
68 fField = -3.8 * avg_current / 18160.0;
73 virtual Float_t GetMaxFieldMag()
const override 78 virtual TEveVector GetField(Float_t
x, Float_t
y, Float_t
z)
const override 80 static const Float_t barrelFac = 1.2 / 3.8;
81 static const Float_t endcapFac = 2.0 / 3.8;
83 const Float_t
R =
sqrt(x*x+y*y);
90 if (R < 300.0
f)
return TEveVector(0, 0, fField);
93 if ((R > 461.0
f && R < 490.5
f) ||
94 (R > 534.5
f && R < 597.5
f) ||
95 (R > 637.0
f && R < 700.0
f))
97 return TEveVector(0, 0, -fField*barrelFac);
100 if ((absZ > 724.0
f && absZ < 786.0
f) ||
101 (absZ > 850.0
f && absZ < 910.0
f) ||
102 (absZ > 975.0
f && absZ < 1003.0
f))
104 const Float_t fac = (z >= 0 ? fField : -fField) * endcapFac / R;
105 return TEveVector(x*fac, y*fac, 0);
108 return TEveVector(0, 0, 0);
126 m_EveManager(0), m_Rint(0),
128 m_AllowStep(
true), m_ShowEvent(
true),
129 m_ContinueButton(0), m_StepButton(0), m_StepLabel(0)
131 printf(
"EveService::EveService CTOR\n");
133 std::cout <<
" gApplication "<< gApplication <<std::endl;
134 std::cout <<
" is batch " << gROOT->IsBatch() <<std::endl;
135 std::cout <<
" display " << gSystem->Getenv(
"DISPLAY") <<std::endl;
137 const char* dummyArgvArray[] = {
"cmsRun"};
138 char** dummyArgv =
const_cast<char**
>(dummyArgvArray);
141 m_Rint =
new TRint(
"App", &dummyArgc, dummyArgv);
142 assert(TApplication::GetApplications()->GetSize());
144 gROOT->SetBatch(kFALSE);
145 std::cout<<
"calling NeedGraphicsLibs()"<<std::endl;
146 TApplication::NeedGraphicsLibs();
150 m_EveManager->AddEvent(
new TEveEventManager(
"Event",
"Event Data"));
168 printf(
"EveService::~EveService DTOR\n");
180 printf(
"EveService::postBeginJob\n");
183 gSystem->ProcessEvents();
188 printf(
"EveService::postEndJob\n");
190 TEveManager::Terminate();
197 float current = 18160.0f;
223 printf(
"RunInfo not available \n");
224 static_cast<CmsEveMagField*
>(
m_MagField)->SetFieldByCurrent(current);
231 printf(
"EveService::postProcessEvent: Starting GUI loop.\n");
245 gEve->GetCurrentEvent()->DestroyElements();
305 MkTxtButton(TGCompositeFrame*
p,
const char* txt, Int_t
width=0,
306 Int_t lo=0, Int_t ro=0, Int_t
to=0, Int_t bo=0)
311 TGTextButton*
b =
new TGTextButton(p, txt);
314 b->ChangeOptions(b->GetOptions() | kFixedWidth);
316 p->AddFrame(b,
new TGLayoutHints(kLHintsNormal, lo,ro,
to,bo));
323 const TString cls(
"EveService");
325 TEveBrowser *browser = gEve->GetBrowser();
326 browser->StartEmbedding(TRootBrowser::kBottom);
328 TGMainFrame *mf =
new TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame);
330 TGHorizontalFrame*
f =
new TGHorizontalFrame(mf);
331 mf->AddFrame(f,
new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
333 MkTxtButton(f,
"Exit", 100, 2, 2)->
334 Connect(
"Clicked()", cls,
this,
"slotExit()");
336 MkTxtButton(f,
"Next Event", 100, 2, 2)->
337 Connect(
"Clicked()", cls,
this,
"slotNextEvent()");
343 m_StepButton->Connect(
"Clicked()", cls,
this,
"slotStep()");
347 mf->AddFrame(
m_StepLabel,
new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));
349 mf->SetCleanup(kDeepCleanup);
354 browser->StopEmbedding(
"EventCtrl");
360 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