36 #include "TEveManager.h"
37 #include "TEveEventManager.h"
38 #include "TEveTrackPropagator.h"
41 #include "TEveBrowser.h"
48 class CmsEveMagField :
public TEveMagField
56 CmsEveMagField() : TEveMagField(), fField(-3.8), fFieldMag(3.8) {}
57 virtual ~CmsEveMagField() {}
60 void SetFieldByCurrent(Float_t avg_current)
62 fField = -3.8 * avg_current / 18160.0;
63 fFieldMag = TMath::Abs(fField);
67 virtual Float_t GetMaxFieldMag()
const override
72 virtual TEveVector GetField(Float_t
x, Float_t
y, Float_t
z)
const override
74 static const Float_t barrelFac = 1.2 / 3.8;
75 static const Float_t endcapFac = 2.0 / 3.8;
77 const Float_t
R =
sqrt(x*x+y*y);
78 const Float_t absZ = TMath::Abs(z);
84 if (R < 300.0
f)
return TEveVector(0, 0, fField);
87 if ((R > 461.0
f && R < 490.5
f) ||
88 (R > 534.5
f && R < 597.5
f) ||
89 (R > 637.0
f && R < 700.0
f))
91 return TEveVector(0, 0, -fField*barrelFac);
94 if ((absZ > 724.0
f && absZ < 786.0
f) ||
95 (absZ > 850.0
f && absZ < 910.0
f) ||
96 (absZ > 975.0
f && absZ < 1003.0
f))
98 const Float_t fac = (z >= 0 ? fField : -fField) * endcapFac / R;
99 return TEveVector(x*fac, y*fac, 0);
102 return TEveVector(0, 0, 0);
120 m_EveManager(0), m_Rint(0),
122 m_AllowStep(
true), m_ShowEvent(
true),
123 m_ContinueButton(0), m_StepButton(0), m_StepLabel(0)
125 printf(
"EveService::EveService CTOR\n");
127 std::cout <<
" gApplication "<< gApplication <<std::endl;
128 std::cout <<
" is batch " << gROOT->IsBatch() <<std::endl;
129 std::cout <<
" display " << gSystem->Getenv(
"DISPLAY") <<std::endl;
131 const char* dummyArgvArray[] = {
"cmsRun"};
132 char** dummyArgv =
const_cast<char**
>(dummyArgvArray);
135 m_Rint =
new TRint(
"App", &dummyArgc, dummyArgv);
136 assert(TApplication::GetApplications()->GetSize());
138 gROOT->SetBatch(kFALSE);
139 std::cout<<
"calling NeedGraphicsLibs()"<<std::endl;
140 TApplication::NeedGraphicsLibs();
144 m_EveManager->AddEvent(
new TEveEventManager(
"Event",
"Event Data"));
162 printf(
"EveService::~EveService DTOR\n");
174 printf(
"EveService::postBeginJob\n");
177 gSystem->ProcessEvents();
182 printf(
"EveService::postEndJob\n");
184 TEveManager::Terminate();
196 bool res = iRun.
getByLabel(
"conditionsInEdm", runCond);
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);
215 printf(
"RunInfo not available \n");
217 static_cast<CmsEveMagField*
>(
m_MagField)->SetFieldByCurrent(current);
224 printf(
"EveService::postProcessEvent: Starting GUI loop.\n");
238 gEve->GetCurrentEvent()->DestroyElements();
298 MkTxtButton(TGCompositeFrame*
p,
const char* txt, Int_t
width=0,
299 Int_t lo=0, Int_t ro=0, Int_t
to=0, Int_t bo=0)
304 TGTextButton*
b =
new TGTextButton(p, txt);
307 b->ChangeOptions(b->GetOptions() | kFixedWidth);
309 p->AddFrame(b,
new TGLayoutHints(kLHintsNormal, lo,ro,
to,bo));
316 const TString cls(
"EveService");
318 TEveBrowser *browser = gEve->GetBrowser();
319 browser->StartEmbedding(TRootBrowser::kBottom);
321 TGMainFrame *mf =
new TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame);
323 TGHorizontalFrame*
f =
new TGHorizontalFrame(mf);
324 mf->AddFrame(f,
new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
326 MkTxtButton(f,
"Exit", 100, 2, 2)->
327 Connect(
"Clicked()", cls,
this,
"slotExit()");
329 MkTxtButton(f,
"Next Event", 100, 2, 2)->
330 Connect(
"Clicked()", cls,
this,
"slotNextEvent()");
336 m_StepButton->Connect(
"Clicked()", cls,
this,
"slotStep()");
340 mf->AddFrame(
m_StepLabel,
new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));
342 mf->SetCleanup(kDeepCleanup);
347 browser->StopEmbedding(
"EventCtrl");
353 printf(
"EveService exiting on user request.\n");
void watchPostBeginRun(PostBeginRun::slot_type const &iSlot)
bool getByLabel(std::string const &label, Handle< PROD > &result) const
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="")
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