CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 "boost/bind.hpp"
12 
13 #include "TEveWindow.h"
14 #include "TGComboBox.h"
15 #include "TGLabel.h"
16 #include "TGTextEntry.h"
17 //#include "TGHorizontalFrame.h"
18 
19 // user include files
31 
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(0),
50  m_eveWindow(0),
51  m_vert(0),
52  m_tableWidget(0),
53  m_processList(0)
54 {
55  m_regex.changed_.connect(boost::bind(&FWTriggerTableView::dataChanged,this));
56 
57 
58  m_eveWindow = iParent->MakeFrame(0);
59  TGCompositeFrame *frame = m_eveWindow->GetGUICompositeFrame();
60 
61  m_vert = new TGVerticalFrame(frame);
62  frame->AddFrame(m_vert, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
63 
64  // have to have at least one column when call FWTableWidget constructor
65  m_columns.push_back( Column( "Name" ));
66 
68  m_tableWidget->SetHeaderBackgroundColor( gVirtualX->GetPixel( kWhite ));
69 
70  m_tableWidget->Connect("columnClicked(Int_t,Int_t,Int_t)", "FWTriggerTableView",
71  this, "columnSelected(Int_t,Int_t,Int_t)");
72  m_vert->AddFrame(m_tableWidget, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
73 
74  frame->MapSubwindows();
75  frame->Layout();
76  frame->MapWindow();
77 }
78 
80 {
81  // take out composite frame and delete it directly (without the timeout)
82  TGCompositeFrame *frame = m_eveWindow->GetGUICompositeFrame();
83  frame->RemoveFrame( m_vert );
84  delete m_vert;
85 
86  m_eveWindow->DestroyWindowAndSlot();
87  delete m_tableManager;
88 }
89 
90 void
92 {
93  m_backgroundColor = iColor;
94  m_tableWidget->SetBackgroundColor(gVirtualX->GetPixel(iColor));
95  m_tableWidget->SetLineSeparatorColor( gVirtualX->GetPixel(iColor == kWhite ? kBlack : kWhite));
96 }
97 
98 //
99 // const member functions
100 //
101 
102 /*
103 void
104 FWTriggerTableView::saveImageTo( const std::string& iName ) const
105 {
106  std::string fileName = iName + ".txt";
107  std::ofstream triggers( fileName.c_str() );
108 
109  triggers << m_columns[2].title << " " << m_columns[0].title << "\n";
110  for( unsigned int i = 0, vend = m_columns[0].values.size(); i != vend; ++i )
111  if( m_columns[1].values[i] == "1" )
112  triggers << m_columns[2].values[i] << "\t" << m_columns[0].values[i] << "\n";
113  triggers.close();
114  }*/
115 
116 
118 {
119  for(std::vector<Column>::iterator i = m_columns.begin(); i!= m_columns.end(); ++i)
120  (*i).values.clear();
121 
123  if (fwlite::Event* event = dynamic_cast<fwlite::Event*>(base))
124  fillTable(event);
125 
127 }
128 
129 void
130 FWTriggerTableView::columnSelected (Int_t iCol, Int_t iButton, Int_t iKeyMod)
131 {
132 }
133 
134 
135 //______________________________________________________________________________
136 
137 void
139 {
142  iTo.addKeyValue( kSortColumn, sortColumn );
143  FWConfiguration descendingSort( m_tableWidget->descendingSort());
144  iTo.addKeyValue( kDescendingSort, descendingSort );
145 }
146 
147 void
149 {
150  const FWConfiguration *main = &iFrom;
151 
152  // unnecessary nesting for old version
153  if (version() < 2)
154  {
155  if (typeId() == FWViewType::kTableHLT)
156  main = iFrom.valueForKey( "HLTTriggerTableView" );
157  else
158  main = iFrom.valueForKey( "L1TriggerTableView" );
159  }
160 
161  const FWConfiguration *sortColumn = main->valueForKey( kSortColumn );
162  const FWConfiguration *descendingSort = main->valueForKey( kDescendingSort );
163  if( sortColumn != 0 && descendingSort != 0 )
164  {
165  unsigned int sort = sortColumn->version();
166  bool descending = descendingSort->version();
167  if( sort < (( unsigned int ) m_tableManager->numberOfColumns()))
168  m_tableWidget->sort( sort, descending );
169  }
170 
171  if ( typeId() == FWViewType::kTableHLT )
172  {
173  const FWConfiguration* vp = iFrom.valueForKey("Process" );
174  if ( vp && (vp->value() != m_process.value()))
175  m_process.setFrom(iFrom);
176  }
177 
178  {
179  const FWConfiguration* vp = iFrom.valueForKey("Filter" );
180  if (vp && (vp->value() != m_regex.value()))
181  m_regex.setFrom(iFrom);
182  }
183 }
184 
185 //______________________________________________________________________________
186 
187 void
189 {
190  if (m_combo && m_processList)
191  {
192  m_combo->RemoveAll();
193  int cnt = 0;
194  int id = -1;
195  for (std::vector<std::string>::iterator i = m_processList->begin(); i != m_processList->end(); ++i)
196  {
197  if (m_process.value() == *i ) id = cnt;
198 
199  m_combo->AddEntry((*i).c_str(), cnt);
200  cnt++;
201  }
202 
203  if(id < 0)
204  {
205  // fwLog(fwlog::kWarning) << "FWTriggerTableView: no trigger results with process name "<< m_process.value() << " is available" << std::endl;
206  m_combo->AddEntry(m_process.value().c_str(), cnt);
207  id = cnt;
208  }
209 
210  m_combo->SortByName();
211  m_combo->Select(id, false);
212  }
213 }
214 
215 void
217 {
218  m_process.set(x);
219  dataChanged();
220 }
221 
222 bool
224 {
225  for (std::vector<std::string>::iterator i = m_processList->begin(); i!= m_processList->end(); ++i)
226  {
227  if (*i == m_process.value())
228  return true;
229  }
230  return false;
231 }
232 
233 void
235 {
236  gui.requestTab("Style").addParam(&m_regex);
237 
238  // resize filter frame
239  TGCompositeFrame* parent = gui.getTabContainer();
240  TGFrameElement* el = (TGFrameElement*) parent->GetList()->Last();
241  el->fLayout->SetLayoutHints(kLHintsNormal);
242  el->fFrame->Resize(180);
243 
244  // add combo for processes
245  if (typeId() == FWViewType::kTableHLT)
246  {
247  TGHorizontalFrame* f = new TGHorizontalFrame(gui.getTabContainer());
248  gui.getTabContainer()->AddFrame(f, new TGLayoutHints(kLHintsNormal, 2, 2,2,2 ));
249 
250  m_combo = new TGComboBox(f);
251  f->AddFrame(m_combo);
252  m_combo->Resize(140, 20);
253  f->AddFrame(new TGLabel(f, "Process"), new TGLayoutHints(kLHintsLeft, 8,2,2,2));
254 
255  resetCombo();
257  m_combo->Connect("Selected(const char*)", "FWTriggerTableView", tt, "processChanged(const char*)");
258  }
259 }
260 
261 void
263 {
264  TString format;
265  TString data;
266  FWTextTableCellRenderer* textRenderer;
267 
268  // calculate widths
269  std::vector<size_t> widths(m_tableManager->numberOfColumns());
270 
271  for (int c = 0; c < m_tableManager->numberOfColumns(); ++c )
272  widths[c] = m_columns[c].title.size();
273 
274  for (int c = 0; c < m_tableManager->numberOfColumns(); ++c )
275  {
276  for (int r = 0; r < m_tableManager->numberOfRows(); r++ )
277  {
278  textRenderer = (FWTextTableCellRenderer*) m_tableManager->cellRenderer(r, c); // setup cell renderer
279  size_t ss = textRenderer->data().size();
280  if (widths[c] < ss) widths[c] = ss;
281  }
282  }
283 
284  int rlen = 0;
285  for (size_t c = 0; c < (size_t)m_tableManager->numberOfColumns(); ++c )
286  rlen += widths[c];
287  rlen += (m_tableManager->numberOfColumns() -1 )*3 ;
288  rlen++;
289 
290 
291  printf("\n");
292  int lastCol = m_tableManager->numberOfColumns() -1;
293 
294  for (int c = 0; c < m_tableManager->numberOfColumns(); ++c )
295  {
296  format.Form("%%%ds", (int)widths[c]);
297  data.Form(format,m_columns[c].title.c_str());
298  if (c == lastCol)
299  printf("%s", data.Data());
300  else
301  printf("%s | ", data.Data());
302  }
303  printf("\n");
304 
305  std::string splitter(rlen, '-');
306  std::cout << splitter << std::endl;
307 
308  for (int r = 0; r < m_tableManager->numberOfRows(); r++ )
309  {
310  for (int c = 0; c < m_tableManager->numberOfColumns(); ++c )
311  {
312  format.Form("%%%ds", (int)widths[c]);
313  textRenderer = (FWTextTableCellRenderer*) m_tableManager->cellRenderer(r, c); // setup cell renderer
314  data.Form(format, textRenderer->data().c_str());
315  if (c == lastCol)
316  printf("%s", data.Data());
317  else
318  printf("%s | ", data.Data());
319  }
320  printf("\n");
321  }
322 }
tuple base
Main Program
Definition: newFWLiteAna.py:92
int i
Definition: DBlmapReader.cc:9
void SetBackgroundColor(Pixel_t)
std::vector< Column > m_columns
virtual void setFrom(const FWConfiguration &)
list parent
Definition: dbtoconf.py:74
virtual void fillTable(fwlite::Event *event)=0
FWStringParameter m_regex
ViewerParameterGUI & requestTab(const char *)
void SetHeaderBackgroundColor(Pixel_t)
unsigned int version() const
virtual void addTo(FWConfiguration &) const
string format
Some error handling for the usage.
FWTriggerTableView(TEveWindowSlot *, FWViewType::EType)
sigc::signal< void, T > changed_
virtual int numberOfColumns() const
Number of columns in the table.
void SetLineSeparatorColor(Pixel_t)
TGCompositeFrame * m_vert
int main(int argc, char **argv)
def splitter
Definition: confdb.py:11
bool isProcessValid() const
void setBackgroundColor(Color_t)
FWTableWidget * m_tableWidget
void sort(UInt_t iColumn, bool iDescendingSort)
TEveWindowFrame * m_eveWindow
bool descendingSort() const
Definition: FWTableWidget.h:90
static const std::string kDescendingSort
double f[11][100]
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
const std::string & value(unsigned int iIndex=0) const
const std::string & data()
virtual ~FWTriggerTableView(void)
const edm::EventBase * getCurrentEvent() const
static const std::string kSortColumn
static FWGUIManager * getGUIManager()
void processChanged(const char *)
virtual FWTableCellRendererBase * cellRenderer(int iSortedRowNumber, int iCol) const
FWStringParameter m_process
virtual int numberOfRows() const
Number of rows in the table.
int sortedColumn() const
Definition: FWTableWidget.h:89
ViewerParameterGUI & addParam(const FWParameterBase *)
TGCompositeFrame * getTabContainer()
void columnSelected(Int_t iCol, Int_t iButton, Int_t iKeyMod)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::vector< std::string > * m_processList
virtual void saveImageTo(const std::string &iName) const
virtual void setFrom(const FWConfiguration &iFrom)
tuple cout
Definition: gather_cfg.py:121
FWTriggerTableViewTableManager * m_tableManager
const FWConfiguration * valueForKey(const std::string &iKey) const
virtual void populateController(ViewerParameterGUI &) const
Definition: DDAxes.h:10
static const std::string kColumns
virtual void addTo(FWConfiguration &) const
FWViewType::EType typeId() const
Definition: FWViewBase.h:41