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();
197 bool res = iRun.
getByLabel(
"conditionsInEdm", runCond);
200 printf(
"Got current from conds in edm %f\n", runCond->BAvgCurrent);
201 current = runCond->BAvgCurrent;
205 printf(
"Could not extract run-conditions get-result=%d, is-valid=%d\n", res, runCond.
isValid());
210 current = sum->m_avg_current;
211 printf(
"Got current from RunInfoRcd %f\n", sum->m_avg_current);
216 printf(
"RunInfo not available \n");
218 static_cast<CmsEveMagField*
>(
m_MagField)->SetFieldByCurrent(current);
225 printf(
"EveService::postProcessEvent: Starting GUI loop.\n");
239 gEve->GetCurrentEvent()->DestroyElements();
299 MkTxtButton(TGCompositeFrame*
p,
const char* txt, Int_t
width=0,
300 Int_t lo=0, Int_t ro=0, Int_t
to=0, Int_t bo=0)
305 TGTextButton*
b =
new TGTextButton(p, txt);
308 b->ChangeOptions(b->GetOptions() | kFixedWidth);
310 p->AddFrame(b,
new TGLayoutHints(kLHintsNormal, lo,ro,
to,bo));
317 const TString cls(
"EveService");
319 TEveBrowser *browser = gEve->GetBrowser();
320 browser->StartEmbedding(TRootBrowser::kBottom);
322 TGMainFrame *mf =
new TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame);
324 TGHorizontalFrame*
f =
new TGHorizontalFrame(mf);
325 mf->AddFrame(f,
new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
327 MkTxtButton(f,
"Exit", 100, 2, 2)->
328 Connect(
"Clicked()", cls,
this,
"slotExit()");
330 MkTxtButton(f,
"Next Event", 100, 2, 2)->
331 Connect(
"Clicked()", cls,
this,
"slotNextEvent()");
337 m_StepButton->Connect(
"Clicked()", cls,
this,
"slotStep()");
341 mf->AddFrame(
m_StepLabel,
new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));
343 mf->SetCleanup(kDeepCleanup);
348 browser->StopEmbedding(
"EventCtrl");
354 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