37 #include "TEveManager.h"
38 #include "TEveEventManager.h"
39 #include "TEveTrackPropagator.h"
42 #include "TEveBrowser.h"
49 class CmsEveMagField :
public TEveMagField
57 CmsEveMagField() : TEveMagField(), fField(-3.8), fFieldMag(3.8) {}
58 virtual ~CmsEveMagField() {}
61 void SetFieldByCurrent(Float_t avg_current)
63 fField = -3.8 * avg_current / 18160.0;
64 fFieldMag = TMath::Abs(fField);
68 virtual Float_t GetMaxFieldMag()
const
73 virtual TEveVector GetField(Float_t
x, Float_t
y, Float_t
z)
const
75 static const Float_t barrelFac = 1.2 / 3.8;
76 static const Float_t endcapFac = 2.0 / 3.8;
78 const Float_t
R =
sqrt(x*x+y*y);
79 const Float_t absZ = TMath::Abs(z);
85 if (R < 300.0
f)
return TEveVector(0, 0, fField);
88 if ((R > 461.0
f && R < 490.5
f) ||
89 (R > 534.5
f && R < 597.5
f) ||
90 (R > 637.0
f && R < 700.0
f))
92 return TEveVector(0, 0, -fField*barrelFac);
95 if ((absZ > 724.0
f && absZ < 786.0
f) ||
96 (absZ > 850.0
f && absZ < 910.0
f) ||
97 (absZ > 975.0
f && absZ < 1003.0
f))
99 const Float_t fac = (z >= 0 ? fField : -fField) * endcapFac / R;
100 return TEveVector(x*fac, y*fac, 0);
103 return TEveVector(0, 0, 0);
121 m_EveManager(0), m_Rint(0),
123 m_AllowStep(
true), m_ShowEvent(
true),
124 m_ContinueButton(0), m_StepButton(0), m_StepLabel(0)
126 printf(
"EveService::EveService CTOR\n");
128 std::cout <<
" gApplication "<< gApplication <<std::endl;
129 std::cout <<
" is batch " << gROOT->IsBatch() <<std::endl;
130 std::cout <<
" display " << gSystem->Getenv(
"DISPLAY") <<std::endl;
132 const char* dummyArgvArray[] = {
"cmsRun"};
133 char** dummyArgv =
const_cast<char**
>(dummyArgvArray);
136 m_Rint =
new TRint(
"App", &dummyArgc, dummyArgv);
137 assert(TApplication::GetApplications()->GetSize());
139 gROOT->SetBatch(kFALSE);
140 std::cout<<
"calling NeedGraphicsLibs()"<<std::endl;
141 TApplication::NeedGraphicsLibs();
145 m_EveManager->AddEvent(
new TEveEventManager(
"Event",
"Event Data"));
163 printf(
"EveService::~EveService DTOR\n");
175 printf(
"EveService::postBeginJob\n");
178 gSystem->ProcessEvents();
183 printf(
"EveService::postEndJob\n");
185 TEveManager::Terminate();
199 printf(
"Got current from conds in edm %f\n", runCond->BAvgCurrent);
200 current = runCond->BAvgCurrent;
204 printf(
"Could not extract run-conditions get-result=%d, is-valid=%d\n", res, runCond.
isValid());
209 current = sum->m_avg_current;
210 printf(
"Got current from RunInfoRcd %f\n", sum->m_avg_current);
213 static_cast<CmsEveMagField*
>(
m_MagField)->SetFieldByCurrent(current);
220 printf(
"EveService::postProcessEvent: Starting GUI loop.\n");
234 gEve->GetCurrentEvent()->DestroyElements();
294 MkTxtButton(TGCompositeFrame*
p,
const char* txt, Int_t
width=0,
295 Int_t lo=0, Int_t ro=0, Int_t
to=0, Int_t bo=0)
300 TGTextButton*
b =
new TGTextButton(p, txt);
303 b->ChangeOptions(b->GetOptions() | kFixedWidth);
305 p->AddFrame(b,
new TGLayoutHints(kLHintsNormal, lo,ro,
to,bo));
312 const TString cls(
"EveService");
314 TEveBrowser *browser = gEve->GetBrowser();
315 browser->StartEmbedding(TRootBrowser::kBottom);
317 TGMainFrame *mf =
new TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame);
319 TGHorizontalFrame*
f =
new TGHorizontalFrame(mf);
320 mf->AddFrame(f,
new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
322 MkTxtButton(f,
"Exit", 100, 2, 2)->
323 Connect(
"Clicked()", cls,
this,
"slotExit()");
325 MkTxtButton(f,
"Next Event", 100, 2, 2)->
326 Connect(
"Clicked()", cls,
this,
"slotNextEvent()");
332 m_StepButton->Connect(
"Clicked()", cls,
this,
"slotStep()");
336 mf->AddFrame(
m_StepLabel,
new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));
338 mf->SetCleanup(kDeepCleanup);
343 browser->StopEmbedding(
"EventCtrl");
349 printf(
"EveService exiting on user request.\n");
void watchPostBeginRun(PostBeginRun::slot_type const &iSlot)
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
EveService(const edm::ParameterSet &, edm::ActivityRegistry &)
void postProcessEvent(const edm::Event &, const edm::EventSetup &)
TGTextButton * m_ContinueButton
void watchPostProcessEvent(PostProcessEvent::slot_type const &iSlot)
TEveMagField * getMagField()
TGTextButton * m_StepButton
void display(const std::string &info="")
bool getByType(Handle< PROD > &result) const
TEveManager * getManager()
TEveManager * m_EveManager
void createEventNavigationGUI()
void setupFieldForPropagator(TEveTrackPropagator *prop)
void AddElement(TEveElement *el)
void postBeginRun(const edm::Run &, const edm::EventSetup &)
TEveMagField * m_MagField
void AddGlobalElement(TEveElement *el)
void watchPostBeginJob(PostBeginJob::slot_type const &iSlot)
convenience function for attaching to signal