Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:37

0001 #include "TGLViewer.h"
0002 #include "TEveManager.h"
0003 
0004 #include "Fireworks/Core/interface/FWEventAnnotation.h"
0005 #include "Fireworks/Core/interface/FWGUIManager.h"
0006 #include "Fireworks/Core/interface/BuilderUtils.h"
0007 #include "Fireworks/Core/interface/FWConfiguration.h"
0008 
0009 #include "DataFormats/FWLite/interface/Event.h"
0010 
0011 FWEventAnnotation::FWEventAnnotation(TGLViewerBase* view) : TGLAnnotation(view, "Event Info", 0.05, 0.95), m_level(1) {
0012   SetRole(TGLOverlayElement::kViewer);
0013   SetUseColorSet(true);
0014   fAllowClose = false;
0015 }
0016 
0017 FWEventAnnotation::~FWEventAnnotation() {}
0018 
0019 //______________________________________________________________________________
0020 
0021 void FWEventAnnotation::setLevel(long x) {
0022   if (x != m_level) {
0023     m_level = x;
0024     fParent->Changed();
0025     gEve->Redraw3D();
0026   }
0027   updateOverlayText();
0028 }
0029 
0030 void FWEventAnnotation::setEvent() { updateOverlayText(); }
0031 
0032 void FWEventAnnotation::updateOverlayText() {
0033   fText = "CMS Experiment at LHC, CERN";
0034 
0035   const edm::EventBase* event = FWGUIManager::getGUIManager()->getCurrentEvent();
0036 
0037   if (event && m_level) {
0038     fText += "\nData recorded: ";
0039     fText += fireworks::getLocalTime(*event);
0040     fText += "\nRun/Event: ";
0041     fText += event->id().run();
0042     fText += " / ";
0043     fText += event->id().event();
0044     if (m_level > 1) {
0045       fText += "\nLumi section: ";
0046       fText += event->luminosityBlock();
0047     }
0048     if (m_level > 2) {
0049       fText += "\nOrbit/Crossing: ";
0050       fText += event->orbitNumber();
0051       fText += " / ";
0052       fText += event->bunchCrossing();
0053     }
0054   }
0055 
0056   if (m_level) {
0057     fParent->Changed();
0058     gEve->Redraw3D();
0059   }
0060 }
0061 
0062 void FWEventAnnotation::Render(TGLRnrCtx& rnrCtx) {
0063   if (m_level)
0064     TGLAnnotation::Render(rnrCtx);
0065 }
0066 
0067 //______________________________________________________________________________
0068 
0069 void FWEventAnnotation::addTo(FWConfiguration& iTo) const {
0070   std::stringstream s;
0071   s << fTextSize;
0072   iTo.addKeyValue("EventInfoTextSize", FWConfiguration(s.str()));
0073 
0074   std::stringstream x;
0075   x << fPosX;
0076   iTo.addKeyValue("EventInfoPosX", FWConfiguration(x.str()));
0077 
0078   std::stringstream y;
0079   y << fPosY;
0080   iTo.addKeyValue("EventInfoPosY", FWConfiguration(y.str()));
0081 }
0082 
0083 void FWEventAnnotation::setFrom(const FWConfiguration& iFrom) {
0084   const FWConfiguration* value;
0085 
0086   value = iFrom.valueForKey("EventInfoTextSize");
0087   if (value)
0088     fTextSize = atof(value->value().c_str());
0089 
0090   value = iFrom.valueForKey("EventInfoPosX");
0091   if (value)
0092     fPosX = atof(value->value().c_str());
0093 
0094   value = iFrom.valueForKey("EventInfoPosY");
0095   if (value)
0096     fPosY = atof(value->value().c_str());
0097 }