2 #include "boost/bind.hpp" 44 #include "TGLWidget.h" 46 #include "TEveManager.h" 47 #include "TEveEventManager.h" 48 #include "TEveTrackPropagator.h" 49 #include "TEveBrowser.h" 50 #include "TGeoManager.h" 56 class ModuleCallingContext;
61 class CmsEveMagField :
public TEveMagField
69 CmsEveMagField() : TEveMagField(), fField(-3.8), fFieldMag(3.8) {}
70 ~CmsEveMagField()
override {}
73 void SetFieldByCurrent(Float_t avg_current)
75 fField = -3.8 * avg_current / 18160.0;
80 Float_t GetMaxFieldMag()
const override 85 TEveVector GetField(Float_t x, Float_t y, Float_t z)
const override 87 static const Float_t barrelFac = 1.2 / 3.8;
88 static const Float_t endcapFac = 2.0 / 3.8;
90 const Float_t
R =
sqrt(x*x+y*y);
97 if (R < 300.0
f)
return TEveVector(0, 0, fField);
100 if ((R > 461.0
f && R < 490.5
f) ||
101 (R > 534.5
f && R < 597.5
f) ||
102 (R > 637.0
f && R < 700.0
f))
104 return TEveVector(0, 0, -fField*barrelFac);
107 if ((absZ > 724.0
f && absZ < 786.0
f) ||
108 (absZ > 850.0
f && absZ < 910.0
f) ||
109 (absZ > 975.0
f && absZ < 1003.0
f))
111 const Float_t fac = (z >= 0 ? fField : -fField) * endcapFac / R;
112 return TEveVector(x*fac, y*fac, 0);
115 return TEveVector(0, 0, 0);
140 m_metadataManager.
get())),
141 m_Rint(m_appHelper->app()),
146 m_geomWatcher(this, &
FWFFLooper::remakeGeometry)
148 setup(m_navigator.get(), m_context.get(), m_metadataManager.get());
150 eiManager()->setContext(m_context.get());
156 const char *releaseBase = getenv(
"CMSSW_RELEASE_BASE");
157 const char *workarea = getenv(
"CMSSW_BASE");
158 std::string displayConfigRelFilename =
"/src/Fireworks/FWInterface/macros/ffw.fwc";
159 std::string geometryRelFilename =
"/src/Fireworks/FWInterface/data/cmsGeom10.root";
164 if (releaseBase && access((releaseBase + displayConfigFilename).c_str(), R_OK) == 0)
165 displayConfigFilename = releaseBase + displayConfigRelFilename;
166 if (workarea && access((workarea + displayConfigRelFilename).c_str(), R_OK) == 0)
167 displayConfigFilename = workarea + displayConfigRelFilename;
169 if (releaseBase && access((releaseBase + geometryRelFilename).c_str(), R_OK) == 0)
170 geometryFilename = releaseBase + geometryRelFilename;
171 if (workarea && access((workarea + geometryRelFilename).c_str(), R_OK) == 0)
172 geometryFilename = workarea + geometryRelFilename;
176 if( !geometryFilename.empty())
178 loadDefaultGeometryFile();
180 setGeometryFilename(geometryFilename);
181 setConfigFilename(displayConfigFilename);
183 if( !geometryFilename.empty())
185 loadDefaultGeometryFile();
188 m_MagField =
new CmsEveMagField();
196 startupTasks()->addTask( f );
226 m_pathsGUI->setup(info);
233 f=boost::bind(&TApplication::Terminate,
m_Rint, 0);
234 startupTasks()->addTask(f);
236 startupTasks()->startDoingTasks();
239 gSystem->ProcessEvents();
246 printf(
"FWFFLooper::postEndJob\n");
247 TEveManager::Terminate();
253 if (
loop() && isPlaying())
256 guiManager()->getMainFrame()->enableNavigatorControls();
257 guiManager()->getMainFrame()->enableComplexNavigation(
false);
260 guiManager()->disablePrevious();
264 guiManager()->disableNext();
266 if (!guiManager()->playEventsAction()->isEnabled())
267 guiManager()->playEventsAction()->enable();
279 bool reachedEnd = (forward() && m_isLastEvent) || (!forward() && m_isFirstEvent);
281 if (!reachedEnd ||
loop())
285 forward() ? m_navigator->nextEvent() : m_navigator->previousEvent();
289 m_autoReload =
false;
291 guiManager()->enableActions();
292 guiManager()->getMainFrame()->enableComplexNavigation(
false);
300 m_autoReload =
false;
302 guiManager()->enableActions();
303 guiManager()->getMainFrame()->enableComplexNavigation(
false);
315 m_geomWatcher.check(iSetup);
327 if (m_firstTime ==
true)
329 if (m_context->getGeom() ==
nullptr)
333 guiManager()->updateStatus(
"Loading geometry...");
337 m_context->setGeom(&(getGeom()));
341 setGeometryFilename(
"cmsGeom10.root");
347 setupConfiguration();
351 guiManager()->setFilterButtonText(
"Show paths / CMSSW configuration editor");
355 m_autoReload =
false;
358 float current = 18160.0f;
365 printf(
"Got current from conds in edm %f\n", runCond->
BAvgCurrent);
370 printf(
"Could not extract run-conditions get-result=%d, is-valid=%d\n", res, runCond.
isValid());
379 printf(
"Got current from RunInfoRcd %f\n", sum->
m_avg_current);
386 static_cast<CmsEveMagField*
>(m_MagField)->SetFieldByCurrent(current);
387 context()->getField()->setFFFieldMag(m_MagField->GetMaxFieldMag());
398 m_geomWatcher.check(es);
402 m_pathsGUI->postEvent(event);
418 m_navigator->resetTransition();
423 m_pathsGUI->hasChanges() =
false;
425 m_navigator->setCurrentEvent(&event);
426 if (m_autoReload ==
true)
427 startAutoLoadTimer();
435 if (m_pathsGUI->hasChanges())
442 m_nextEventId = m_navigator->getFirstEventID();
447 m_nextEventId = m_navigator->getFirstEventID();
484 prop->SetMagFieldObj(m_MagField, kFALSE);
508 for (ModuleChanges::iterator
i = m_scheduledChanges.begin(),
509 e = m_scheduledChanges.end();
513 moduleChanger()->changeModule(
i->first,
i->second);
521 m_scheduledChanges.clear();
530 if (m_pathsGUI->IsMapped())
532 guiManager()->setFilterButtonText(
"Show paths / CMSSW configuration editor");
533 m_pathsGUI->UnmapWindow();
537 guiManager()->setFilterButtonText(
"Hide paths / CMSSW configuration editor");
538 m_pathsGUI->MapWindow();
545 m_scheduledChanges[moduleLabel] = ps;
557 TEveGeoManagerHolder _tgeo(const_cast<TGeoManager*>(geom.
product()));
TEveMagField * getMagField()
edm::EDLooperBase::Status endOfLoop(const edm::EventSetup &, unsigned int) override
bool getByLabel(std::string const &label, Handle< PROD > &result) const
T getUntrackedParameter(std::string const &, T const &) const
void setupFieldForPropagator(TEveTrackPropagator *prop)
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
void watchPreModuleEvent(PreModuleEvent::slot_type const &iSlot)
void autoLoadNewEvent() override
void startingNewLoop(unsigned int) override
void watchPostModuleEvent(PostModuleEvent::slot_type const &iSlot)
def setup(process, global_tag, zero_tesla=False)
void attachTo(edm::ActivityRegistry &) override
Override this method if you need to monitor the state of the processing.
char const * what() const override
void remakeGeometry(const DisplayGeomRecord &dgRec)
FWFFLooper(const edm::ParameterSet &)
void loadDefaultGeometryFile(void)
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
void requestChanges(const std::string &, const edm::ParameterSet &)
FWRecoGeom::InfoMap idToName
edm::EDLooperBase::Status duringLoop(const edm::Event &, const edm::EventSetup &, edm::ProcessingController &) override
void display(const std::string &info="")
void setTransitionToEvent(edm::EventID const &iID)
def draw(name, histos, styles=_defaultStyles, legendLabels=[], kwargs)
virtual void stopPlaying()
void setTransitionToPreviousEvent()
ForwardState forwardState() const
Returns the present state of processing.
void beginRun(const edm::Run &, const edm::EventSetup &) override
void get(HolderT &iHolder) const
void checkPosition() override
void stopPlaying() override
boost::function0< void > TaskFunctor
void showEventFilterGUI()
static void setGeoManagerRuntime(TGeoManager *)
void showPathsGUI(const TGWindow *p)
void setTransitionToNextEvent()
T const * product() const
T get(const Candidate &c)
ReverseState reverseState() const