2 #include "boost/bind.hpp" 33 #include "TEveManager.h" 34 #include "TEveEventManager.h" 35 #include "TEveTrackPropagator.h" 36 #include "TGLWidget.h" 38 #include "TEveBrowser.h" 42 class CmsEveMagField :
public TEveMagField
50 CmsEveMagField() : TEveMagField(), fField(-3.8), fFieldMag(3.8) {}
51 ~CmsEveMagField()
override {}
54 void SetFieldByCurrent(Float_t avg_current)
56 fField = -3.8 * avg_current / 18160.0;
61 Float_t GetMaxFieldMag()
const override 66 TEveVector GetField(Float_t
x, Float_t
y, Float_t
z)
const override 68 static const Float_t barrelFac = 1.2 / 3.8;
69 static const Float_t endcapFac = 2.0 / 3.8;
71 const Float_t
R =
sqrt(x*x+y*y);
78 if (R < 300.0
f)
return TEveVector(0, 0, fField);
81 if ((R > 461.0
f && R < 490.5
f) ||
82 (R > 534.5
f && R < 597.5
f) ||
83 (R > 637.0
f && R < 700.0
f))
85 return TEveVector(0, 0, -fField*barrelFac);
88 if ((absZ > 724.0
f && absZ < 786.0
f) ||
89 (absZ > 850.0
f && absZ < 910.0
f) ||
90 (absZ > 975.0
f && absZ < 1003.0
f))
92 const Float_t fac = (z >= 0 ? fField : -fField) * endcapFac / R;
93 return TEveVector(x*fac, y*fac, 0);
96 return TEveVector(0, 0, 0);
121 m_metadataManager.
get())),
123 m_Rint(m_appHelper.app()),
128 printf(
"FWFFService::FWFFService CTOR\n");
130 setup(m_navigator.get(), m_context.get(), m_metadataManager.get());
132 eiManager()->setContext(m_context.get());
138 const char *releaseBase = getenv(
"CMSSW_RELEASE_BASE");
139 const char *workarea = getenv(
"CMSSW_BASE");
140 std::string displayConfigRelFilename =
"/src/Fireworks/FWInterface/macros/ffw.fwc";
141 std::string geometryRelFilename =
"/src/Fireworks/FWInterface/data/cmsGeom10.root";
146 if (releaseBase && access((releaseBase + displayConfigFilename).c_str(), R_OK) == 0)
147 displayConfigFilename = releaseBase + displayConfigRelFilename;
148 if (workarea && access((workarea + displayConfigRelFilename).c_str(), R_OK) == 0)
149 displayConfigFilename = workarea + displayConfigRelFilename;
151 if (releaseBase && access((releaseBase + geometryRelFilename).c_str(), R_OK) == 0)
152 geometryFilename = releaseBase + geometryRelFilename;
153 if (workarea && access((workarea + geometryRelFilename).c_str(), R_OK) == 0)
154 geometryFilename = workarea + geometryRelFilename;
159 setGeometryFilename(geometryFilename);
160 setConfigFilename(displayConfigFilename);
164 if (!geometryFilename.empty())
167 startupTasks()->addTask(f);
170 m_MagField =
new CmsEveMagField();
184 printf(
"FWFFService::~FWFFService DTOR\n");
197 printf(
"FWFFService::postBeginJob\n");
203 f=boost::bind(&TApplication::Terminate, m_Rint, 0);
204 startupTasks()->addTask(f);
206 startupTasks()->startDoingTasks();
209 gSystem->ProcessEvents();
215 printf(
"FWFFService::postEndJob\n");
217 TEveManager::Terminate();
223 if (
loop() && isPlaying())
226 guiManager()->getMainFrame()->enableNavigatorControls();
228 if (m_navigator->isFirstEvent())
229 guiManager()->disablePrevious();
231 if (m_navigator->isLastEvent())
233 guiManager()->disableNext();
235 if (!guiManager()->playEventsAction()->isEnabled())
236 guiManager()->playEventsAction()->enable();
252 if (m_firstTime ==
true)
254 if (m_context->getGeom() ==
nullptr)
256 guiManager()->updateStatus(
"Loading geometry...");
260 m_context->setGeom(&(getGeom()));
264 setupConfiguration();
269 float current = 18160.0f;
276 printf(
"Got current from conds in edm %f\n", runCond->
BAvgCurrent);
281 printf(
"Could not extract run-conditions get-result=%d, is-valid=%d\n", res, runCond.
isValid());
286 current = sum->m_avg_current;
287 printf(
"Got current from RunInfoRcd %f\n", sum->m_avg_current);
290 static_cast<CmsEveMagField*
>(m_MagField)->SetFieldByCurrent(current);
297 printf(
"FWFFService::postProcessEvent: Starting GUI loop.\n");
300 m_navigator->setCurrentEvent(&event);
334 prop->SetMagFieldObj(m_MagField, kFALSE);
341 printf(
"FWFFService exiting on user request.\n");
void watchPostBeginRun(PostBeginRun::slot_type const &iSlot)
bool getByLabel(std::string const &label, Handle< PROD > &result) const
T getUntrackedParameter(std::string const &, T const &) const
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
FWFFService(const edm::ParameterSet &, edm::ActivityRegistry &)
void postProcessEvent(const edm::Event &, const edm::EventSetup &)
void postBeginRun(const edm::Run &, const edm::EventSetup &)
def setup(process, global_tag, zero_tesla=False)
FWRecoGeom::InfoMap idToName
void setupFieldForPropagator(TEveTrackPropagator *prop)
void watchPostProcessEvent(PostProcessEvent::slot_type const &iSlot)
def draw(name, histos, styles=_defaultStyles, legendLabels=[], kwargs)
TEveMagField * getMagField()
T const * product() const
void display(const std::string &info="")
boost::function0< void > TaskFunctor
void checkPosition() override
T get(const Candidate &c)
void watchPostBeginJob(PostBeginJob::slot_type const &iSlot)
convenience function for attaching to signal