CMS 3D CMS Logo

FWTriggerTableView.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWTriggerTableView
5 //
6 
7 // system include files
8 #include <fstream>
9 #include <cassert>
10 
11 #include <functional>
12 
13 #include "TEveWindow.h"
14 #include "TGComboBox.h"
15 #include "TGLabel.h"
16 #include "TGTextEntry.h"
17 #include "TVirtualX.h"
18 //#include "TGHorizontalFrame.h"
19 
20 // user include files
32 
34 
35 // configuration keys
36 static const std::string kColumns = "columns";
37 static const std::string kSortColumn = "sortColumn";
38 static const std::string kDescendingSort = "descendingSort";
39 
40 //
41 //
42 // constructors and destructor
43 //
45  : FWViewBase(id, 2),
46  m_regex(this, "Filter", std::string()),
47  m_process(this, "Process", std::string((id == FWViewType::FWViewType::kTableHLT) ? "HLT" : "")),
48  m_tableManager(new FWTriggerTableViewTableManager(this)),
49  m_combo(nullptr),
50  m_eveWindow(nullptr),
51  m_vert(nullptr),
52  m_tableWidget(nullptr),
53  m_processList(nullptr) {
54  m_regex.changed_.connect(std::bind(&FWTriggerTableView::dataChanged, this));
55 
56  m_eveWindow = iParent->MakeFrame(nullptr);
57  TGCompositeFrame* frame = m_eveWindow->GetGUICompositeFrame();
58 
59  m_vert = new TGVerticalFrame(frame);
60  frame->AddFrame(m_vert, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
61 
62  // have to have at least one column when call FWTableWidget constructor
63  m_columns.push_back(Column("Name"));
64 
66  m_tableWidget->SetHeaderBackgroundColor(gVirtualX->GetPixel(kWhite));
67 
68  m_tableWidget->Connect(
69  "columnClicked(Int_t,Int_t,Int_t)", "FWTriggerTableView", this, "columnSelected(Int_t,Int_t,Int_t)");
70  m_vert->AddFrame(m_tableWidget, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
71 
72  frame->MapSubwindows();
73  frame->Layout();
74  frame->MapWindow();
75 }
76 
78  // take out composite frame and delete it directly (without the timeout)
79  TGCompositeFrame* frame = m_eveWindow->GetGUICompositeFrame();
80  frame->RemoveFrame(m_vert);
81  delete m_vert;
82 
83  m_eveWindow->DestroyWindowAndSlot();
84  delete m_tableManager;
85 }
86 
88  m_backgroundColor = iColor;
89  m_tableWidget->SetBackgroundColor(gVirtualX->GetPixel(iColor));
90  m_tableWidget->SetLineSeparatorColor(gVirtualX->GetPixel(iColor == kWhite ? kBlack : kWhite));
91 }
92 
93 //
94 // const member functions
95 //
96 
97 /*
98 void
99 FWTriggerTableView::saveImageTo( const std::string& iName ) const
100 {
101  std::string fileName = iName + ".txt";
102  std::ofstream triggers( fileName.c_str() );
103 
104  triggers << m_columns[2].title << " " << m_columns[0].title << "\n";
105  for( unsigned int i = 0, vend = m_columns[0].values.size(); i != vend; ++i )
106  if( m_columns[1].values[i] == "1" )
107  triggers << m_columns[2].values[i] << "\t" << m_columns[0].values[i] << "\n";
108  triggers.close();
109  }*/
110 
112  for (std::vector<Column>::iterator i = m_columns.begin(); i != m_columns.end(); ++i)
113  (*i).values.clear();
114 
115  edm::EventBase* base = const_cast<edm::EventBase*>(FWGUIManager::getGUIManager()->getCurrentEvent());
116  if (fwlite::Event* event = dynamic_cast<fwlite::Event*>(base))
117  fillTable(event);
118 
120 }
121 
122 void FWTriggerTableView::columnSelected(Int_t iCol, Int_t iButton, Int_t iKeyMod) {}
123 
124 //______________________________________________________________________________
125 
129  iTo.addKeyValue(kSortColumn, sortColumn);
130  FWConfiguration descendingSort(m_tableWidget->descendingSort());
131  iTo.addKeyValue(kDescendingSort, descendingSort);
132 }
133 
135  const FWConfiguration* main = &iFrom;
136 
137  // unnecessary nesting for old version
138  if (version() < 2) {
139  if (typeId() == FWViewType::kTableHLT)
140  main = iFrom.valueForKey("HLTTriggerTableView");
141  else
142  main = iFrom.valueForKey("L1TriggerTableView");
143  }
144 
145  const FWConfiguration* sortColumn = main->valueForKey(kSortColumn);
146  const FWConfiguration* descendingSort = main->valueForKey(kDescendingSort);
147  if (sortColumn != nullptr && descendingSort != nullptr) {
148  unsigned int sort = sortColumn->version();
149  bool descending = descendingSort->version();
150  if (sort < ((unsigned int)m_tableManager->numberOfColumns()))
151  m_tableWidget->sort(sort, descending);
152  }
153 
154  if (typeId() == FWViewType::kTableHLT) {
155  const FWConfiguration* vp = iFrom.valueForKey("Process");
156  if (vp && (vp->value() != m_process.value()))
157  m_process.setFrom(iFrom);
158  }
159 
160  {
161  const FWConfiguration* vp = iFrom.valueForKey("Filter");
162  if (vp && (vp->value() != m_regex.value()))
163  m_regex.setFrom(iFrom);
164  }
165 }
166 
167 //______________________________________________________________________________
168 
170  if (m_combo && m_processList) {
171  m_combo->RemoveAll();
172  int cnt = 0;
173  int id = -1;
174  for (std::vector<std::string>::iterator i = m_processList->begin(); i != m_processList->end(); ++i) {
175  if (m_process.value() == *i)
176  id = cnt;
177 
178  m_combo->AddEntry((*i).c_str(), cnt);
179  cnt++;
180  }
181 
182  if (id < 0) {
183  // fwLog(fwlog::kWarning) << "FWTriggerTableView: no trigger results with process name "<< m_process.value() << " is available" << std::endl;
184  m_combo->AddEntry(m_process.value().c_str(), cnt);
185  id = cnt;
186  }
187 
188  m_combo->SortByName();
189  m_combo->Select(id, false);
190  }
191 }
192 
194  m_process.set(x);
195  dataChanged();
196 }
197 
199  for (std::vector<std::string>::iterator i = m_processList->begin(); i != m_processList->end(); ++i) {
200  if (*i == m_process.value())
201  return true;
202  }
203  return false;
204 }
205 
207  gui.requestTab("Style").addParam(&m_regex);
208 
209  // resize filter frame
210  TGCompositeFrame* parent = gui.getTabContainer();
211  TGFrameElement* el = (TGFrameElement*)parent->GetList()->Last();
212  el->fLayout->SetLayoutHints(kLHintsNormal);
213  el->fFrame->Resize(180);
214 
215  // add combo for processes
216  if (typeId() == FWViewType::kTableHLT) {
217  TGHorizontalFrame* f = new TGHorizontalFrame(gui.getTabContainer());
218  gui.getTabContainer()->AddFrame(f, new TGLayoutHints(kLHintsNormal, 2, 2, 2, 2));
219 
220  m_combo = new TGComboBox(f);
221  f->AddFrame(m_combo);
222  m_combo->Resize(140, 20);
223  f->AddFrame(new TGLabel(f, "Process"), new TGLayoutHints(kLHintsLeft, 8, 2, 2, 2));
224 
225  resetCombo();
227  m_combo->Connect("Selected(const char*)", "FWTriggerTableView", tt, "processChanged(const char*)");
228  }
229 }
230 
231 void FWTriggerTableView::saveImageTo(const std::string& /*iName*/) const {
232  TString format;
233  TString data;
234  FWTextTableCellRenderer* textRenderer;
235 
236  // calculate widths
237  std::vector<size_t> widths(m_tableManager->numberOfColumns());
238 
239  for (int c = 0; c < m_tableManager->numberOfColumns(); ++c)
240  widths[c] = m_columns[c].title.size();
241 
242  for (int c = 0; c < m_tableManager->numberOfColumns(); ++c) {
243  for (int r = 0; r < m_tableManager->numberOfRows(); r++) {
244  textRenderer = (FWTextTableCellRenderer*)m_tableManager->cellRenderer(r, c); // setup cell renderer
245  size_t ss = textRenderer->data().size();
246  if (widths[c] < ss)
247  widths[c] = ss;
248  }
249  }
250 
251  int rlen = 0;
252  for (size_t c = 0; c < (size_t)m_tableManager->numberOfColumns(); ++c)
253  rlen += widths[c];
254  rlen += (m_tableManager->numberOfColumns() - 1) * 3;
255  rlen++;
256 
257  printf("\n");
258  int lastCol = m_tableManager->numberOfColumns() - 1;
259 
260  for (int c = 0; c < m_tableManager->numberOfColumns(); ++c) {
261  format.Form("%%%ds", (int)widths[c]);
262  data.Form(format, m_columns[c].title.c_str());
263  if (c == lastCol)
264  printf("%s", data.Data());
265  else
266  printf("%s | ", data.Data());
267  }
268  printf("\n");
269 
270  std::string splitter(rlen, '-');
271  std::cout << splitter << std::endl;
272 
273  for (int r = 0; r < m_tableManager->numberOfRows(); r++) {
274  for (int c = 0; c < m_tableManager->numberOfColumns(); ++c) {
275  format.Form("%%%ds", (int)widths[c]);
276  textRenderer = (FWTextTableCellRenderer*)m_tableManager->cellRenderer(r, c); // setup cell renderer
277  data.Form(format, textRenderer->data().c_str());
278  if (c == lastCol)
279  printf("%s", data.Data());
280  else
281  printf("%s | ", data.Data());
282  }
283  printf("\n");
284  }
285 }
FWTriggerTableViewTableManager.h
splitter
Definition: splitter.py:1
FWTriggerTableView.h
FWTriggerTableViewTableManager::cellRenderer
FWTableCellRendererBase * cellRenderer(int iSortedRowNumber, int iCol) const override
Definition: FWTriggerTableViewTableManager.cc:43
FWTableWidget::SetBackgroundColor
void SetBackgroundColor(Pixel_t) override
Definition: FWTableWidget.cc:173
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
mps_fire.i
i
Definition: mps_fire.py:428
FWTriggerTableView::addTo
void addTo(FWConfiguration &) const override
Definition: FWTriggerTableView.cc:126
FWTriggerTableView::m_eveWindow
TEveWindowFrame * m_eveWindow
Definition: FWTriggerTableView.h:82
FWViewType::EType
EType
Definition: FWViewType.h:31
groupFilesInBlocks.tt
int tt
Definition: groupFilesInBlocks.py:144
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
ViewerParameterGUI
Definition: CmsShowViewPopup.h:49
FWTriggerTableView::m_regex
FWStringParameter m_regex
Definition: FWTriggerTableView.h:64
FWTriggerTableView::processChanged
void processChanged(const char *)
Definition: FWTriggerTableView.cc:193
gather_cfg.cout
cout
Definition: gather_cfg.py:144
FWTriggerTableView
Definition: FWTriggerTableView.h:31
FWTriggerTableView::m_backgroundColor
Color_t m_backgroundColor
Definition: FWTriggerTableView.h:87
FWTableWidget::sort
void sort(UInt_t iColumn, bool iDescendingSort)
Definition: FWTableWidget.cc:161
FWGenericParameter::set
void set(T iValue)
Definition: FWGenericParameter.h:70
FWTriggerTableView::~FWTriggerTableView
~FWTriggerTableView(void) override
Definition: FWTriggerTableView.cc:77
DDAxes::x
FWTriggerTableView::resetCombo
void resetCombo() const
Definition: FWTriggerTableView.cc:169
FWTextTableCellRenderer
Definition: FWTextTableCellRenderer.h:32
FWTriggerTableViewTableManager::dataChanged
void dataChanged()
Definition: FWTriggerTableViewTableManager.cc:60
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
FWJobMetadataManager.h
FWViewBase::typeId
FWViewType::EType typeId() const
Definition: FWViewBase.h:42
FWGenericParameter::changed_
sigc::signal< void, T > changed_
Definition: FWGenericParameter.h:75
FWColorManager.h
FWTableWidget
Definition: FWTableWidget.h:35
FWTriggerTableView::m_process
FWStringParameter m_process
Definition: FWTriggerTableView.h:65
FWTableWidget.h
dqm-mbProfile.format
format
Definition: dqm-mbProfile.py:16
FWTriggerTableView::populateController
void populateController(ViewerParameterGUI &) const override
Definition: FWTriggerTableView.cc:206
FWTriggerTableView::m_tableWidget
FWTableWidget * m_tableWidget
Definition: FWTriggerTableView.h:85
FWTriggerTableViewTableManager::numberOfColumns
int numberOfColumns() const override
Number of columns in the table.
Definition: FWTriggerTableViewTableManager.cc:25
FWConfiguration::valueForKey
const FWConfiguration * valueForKey(const std::string &iKey) const
Definition: FWConfiguration.cc:122
confdb.splitter
def splitter(iterator, n)
Definition: confdb.py:13
FWTableWidget::sortedColumn
int sortedColumn() const
Definition: FWTableWidget.h:87
kSortColumn
static const std::string kSortColumn
Definition: FWTriggerTableView.cc:37
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FWTriggerTableView::isProcessValid
bool isProcessValid() const
Definition: FWTriggerTableView.cc:198
FWConfiguration::value
const std::string & value(unsigned int iIndex=0) const
Definition: FWConfiguration.cc:115
FWTriggerTableView::setBackgroundColor
void setBackgroundColor(Color_t)
Definition: FWTriggerTableView.cc:87
kDescendingSort
static const std::string kDescendingSort
Definition: FWTriggerTableView.cc:38
ViewerParameterGUI::getTabContainer
TGCompositeFrame * getTabContainer()
Definition: CmsShowViewPopup.cc:240
FWTriggerTableView::columnSelected
void columnSelected(Int_t iCol, Int_t iButton, Int_t iKeyMod)
Definition: FWTriggerTableView.cc:122
FWGenericParameter::setFrom
void setFrom(const FWConfiguration &iFrom) override
Definition: FWGenericParameter.h:62
FWTriggerTableView::m_columns
std::vector< Column > m_columns
Definition: FWTriggerTableView.h:67
FWTextTableCellRenderer::data
const std::string & data()
Definition: FWTextTableCellRenderer.h:56
FWTriggerTableView::m_processList
std::vector< std::string > * m_processList
Definition: FWTriggerTableView.h:89
FWTriggerTableView::m_vert
TGCompositeFrame * m_vert
Definition: FWTriggerTableView.h:83
fwLog.h
FWViewType::kTableHLT
Definition: FWViewType.h:41
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
FWConfiguration::version
unsigned int version() const
Definition: FWConfiguration.h:49
FWEventItem.h
FWGUIManager::getGUIManager
static FWGUIManager * getGUIManager()
Definition: FWGUIManager.cc:685
main
Definition: main.py:1
FWTriggerTableViewTableManager::numberOfRows
int numberOfRows() const override
Number of rows in the table.
Definition: FWTriggerTableViewTableManager.cc:18
alignCSCRings.r
r
Definition: alignCSCRings.py:93
FWTableWidget::descendingSort
bool descendingSort() const
Definition: FWTableWidget.h:88
FWGenericParameter::value
T value() const
Definition: FWGenericParameter.h:50
FWTriggerTableView::Column
Definition: FWTriggerTableView.h:35
FWConfiguration::addKeyValue
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
Definition: FWConfiguration.cc:58
std
Definition: JetResolutionObject.h:76
FWTableWidget::SetLineSeparatorColor
void SetLineSeparatorColor(Pixel_t)
Definition: FWTableWidget.cc:209
fwlite::Event
Definition: Event.h:87
FWTriggerTableViewTableManager
Definition: FWTriggerTableViewTableManager.h:31
FWConfigurableParameterizable::addTo
void addTo(FWConfiguration &) const override
Definition: FWConfigurableParameterizable.cc:67
FWTriggerTableView::dataChanged
void dataChanged(void)
Definition: FWTriggerTableView.cc:111
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
FWConfigurableParameterizable::version
unsigned int version() const
Definition: FWConfigurableParameterizable.h:37
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
Event.h
edm::EventBase
Definition: EventBase.h:46
genVertex_cff.x
x
Definition: genVertex_cff.py:12
CmsShowViewPopup.h
format
FWTriggerTableView::fillTable
virtual void fillTable(fwlite::Event *event)=0
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
FWTableWidget::SetHeaderBackgroundColor
void SetHeaderBackgroundColor(Pixel_t)
Definition: FWTableWidget.cc:188
FWTriggerTableView::saveImageTo
void saveImageTo(const std::string &iName) const override
Definition: FWTriggerTableView.cc:231
FWTriggerTableViewManager.h
FWConfiguration
Definition: FWConfiguration.h:31
FWTriggerTableView::FWTriggerTableView
FWTriggerTableView(TEveWindowSlot *, FWViewType::EType)
Definition: FWTriggerTableView.cc:44
FWTriggerTableView::m_tableManager
FWTriggerTableViewTableManager * m_tableManager
Definition: FWTriggerTableView.h:68
event
Definition: event.py:1
FWViewBase
Definition: FWViewBase.h:36
FWViewType
Definition: FWViewType.h:22
newFWLiteAna.base
base
Definition: newFWLiteAna.py:92
FWTriggerTableView::setFrom
void setFrom(const FWConfiguration &) override
Definition: FWTriggerTableView.cc:134
class-composition.parent
parent
Definition: class-composition.py:88
ViewerParameterGUI::addParam
ViewerParameterGUI & addParam(const FWParameterBase *)
Definition: CmsShowViewPopup.cc:212
FWTriggerTableView::m_combo
TGComboBox * m_combo
Definition: FWTriggerTableView.h:79
kColumns
static const std::string kColumns
Definition: FWTriggerTableView.cc:36
FWGUIManager.h
FWConfiguration.h
ViewerParameterGUI::requestTab
ViewerParameterGUI & requestTab(const char *)
Definition: CmsShowViewPopup.cc:197