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 // $Id: FWTriggerTableView.cc,v 1.16.8.1 2013/04/09 00:51:49 amraktad Exp $
6 //
7 
8 // system include files
9 #include <fstream>
10 #include <cassert>
11 
12 #include "TEveWindow.h"
13 #include "TGComboBox.h"
14 #include "TGLabel.h"
15 #include "TGTextEntry.h"
16 //#include "TGHorizontalFrame.h"
17 
18 // user include files
30 
31 
33 
34 // configuration keys
35 static const std::string kColumns = "columns";
36 static const std::string kSortColumn = "sortColumn";
37 static const std::string kDescendingSort = "descendingSort";
38 
39 //
40 //
41 // constructors and destructor
42 //
44  : FWViewBase(id, 2),
45  m_regex(this,"Filter",std::string()),
46  m_process(this,"Process",std::string((id == FWViewType::FWViewType::kTableHLT) ? "HLT" : "")),
47  m_tableManager(new FWTriggerTableViewTableManager(this)),
48  m_combo(0),
49  m_eveWindow(0),
50  m_vert(0),
51  m_tableWidget(0),
52  m_processList(0)
53 {
54  m_regex.changed_.connect(boost::bind(&FWTriggerTableView::dataChanged,this));
55 
56 
57  m_eveWindow = iParent->MakeFrame(0);
58  TGCompositeFrame *frame = m_eveWindow->GetGUICompositeFrame();
59 
60  m_vert = new TGVerticalFrame(frame);
61  frame->AddFrame(m_vert, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
62 
63  // have to have at least one column when call FWTableWidget constructor
64  m_columns.push_back( Column( "Name" ));
65 
67  m_tableWidget->SetHeaderBackgroundColor( gVirtualX->GetPixel( kWhite ));
68 
69  m_tableWidget->Connect("columnClicked(Int_t,Int_t,Int_t)", "FWTriggerTableView",
70  this, "columnSelected(Int_t,Int_t,Int_t)");
71  m_vert->AddFrame(m_tableWidget, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
72 
73  frame->MapSubwindows();
74  frame->Layout();
75  frame->MapWindow();
76 }
77 
79 {
80  // take out composite frame and delete it directly (without the timeout)
81  TGCompositeFrame *frame = m_eveWindow->GetGUICompositeFrame();
82  frame->RemoveFrame( m_vert );
83  delete m_vert;
84 
85  m_eveWindow->DestroyWindowAndSlot();
86  delete m_tableManager;
87 }
88 
89 void
91 {
92  m_backgroundColor = iColor;
93  m_tableWidget->SetBackgroundColor(gVirtualX->GetPixel(iColor));
94  m_tableWidget->SetLineSeparatorColor( gVirtualX->GetPixel(iColor == kWhite ? kBlack : kWhite));
95 }
96 
97 //
98 // const member functions
99 //
100 
101 /*
102 void
103 FWTriggerTableView::saveImageTo( const std::string& iName ) const
104 {
105  std::string fileName = iName + ".txt";
106  std::ofstream triggers( fileName.c_str() );
107 
108  triggers << m_columns[2].title << " " << m_columns[0].title << "\n";
109  for( unsigned int i = 0, vend = m_columns[0].values.size(); i != vend; ++i )
110  if( m_columns[1].values[i] == "1" )
111  triggers << m_columns[2].values[i] << "\t" << m_columns[0].values[i] << "\n";
112  triggers.close();
113  }*/
114 
115 
117 {
118  for(std::vector<Column>::iterator i = m_columns.begin(); i!= m_columns.end(); ++i)
119  (*i).values.clear();
120 
122  if (fwlite::Event* event = dynamic_cast<fwlite::Event*>(base))
123  fillTable(event);
124 
126 }
127 
128 void
129 FWTriggerTableView::columnSelected (Int_t iCol, Int_t iButton, Int_t iKeyMod)
130 {
131 }
132 
133 
134 //______________________________________________________________________________
135 
136 void
138 {
141  iTo.addKeyValue( kSortColumn, sortColumn );
142  FWConfiguration descendingSort( m_tableWidget->descendingSort());
143  iTo.addKeyValue( kDescendingSort, descendingSort );
144 }
145 
146 void
148 {
149  const FWConfiguration *main = &iFrom;
150 
151  // unnecessary nesting for old version
152  if (version() < 2)
153  {
154  if (typeId() == FWViewType::kTableHLT)
155  main = iFrom.valueForKey( "HLTTriggerTableView" );
156  else
157  main = iFrom.valueForKey( "L1TriggerTableView" );
158  }
159 
160  const FWConfiguration *sortColumn = main->valueForKey( kSortColumn );
161  const FWConfiguration *descendingSort = main->valueForKey( kDescendingSort );
162  if( sortColumn != 0 && descendingSort != 0 )
163  {
164  unsigned int sort = sortColumn->version();
165  bool descending = descendingSort->version();
166  if( sort < (( unsigned int ) m_tableManager->numberOfColumns()))
167  m_tableWidget->sort( sort, descending );
168  }
169 
170  if ( typeId() == FWViewType::kTableHLT )
171  {
172  const FWConfiguration* vp = iFrom.valueForKey("Process" );
173  if ( vp && (vp->value() != m_process.value()))
174  m_process.setFrom(iFrom);
175  }
176 
177  {
178  const FWConfiguration* vp = iFrom.valueForKey("Filter" );
179  if (vp && (vp->value() != m_regex.value()))
180  m_regex.setFrom(iFrom);
181  }
182 }
183 
184 //______________________________________________________________________________
185 
186 void
188 {
189  if (m_combo && m_processList)
190  {
191  m_combo->RemoveAll();
192  int cnt = 0;
193  int id = -1;
194  for (std::vector<std::string>::iterator i = m_processList->begin(); i != m_processList->end(); ++i)
195  {
196  if (m_process.value() == *i ) id = cnt;
197 
198  m_combo->AddEntry((*i).c_str(), cnt);
199  cnt++;
200  }
201 
202  if(id < 0)
203  {
204  // fwLog(fwlog::kWarning) << "FWTriggerTableView: no trigger results with process name "<< m_process.value() << " is available" << std::endl;
205  m_combo->AddEntry(m_process.value().c_str(), cnt);
206  id = cnt;
207  }
208 
209  m_combo->SortByName();
210  m_combo->Select(id, false);
211  }
212 }
213 
214 void
216 {
217  m_process.set(x);
218  dataChanged();
219 }
220 
221 bool
223 {
224  for (std::vector<std::string>::iterator i = m_processList->begin(); i!= m_processList->end(); ++i)
225  {
226  if (*i == m_process.value())
227  return true;
228  }
229  return false;
230 }
231 
232 void
234 {
235  gui.requestTab("Style").addParam(&m_regex);
236 
237  // resize filter frame
238  TGCompositeFrame* parent = gui.getTabContainer();
239  TGFrameElement* el = (TGFrameElement*) parent->GetList()->Last();
240  el->fLayout->SetLayoutHints(kLHintsNormal);
241  el->fFrame->Resize(180);
242 
243  // add combo for processes
244  if (typeId() == FWViewType::kTableHLT)
245  {
246  TGHorizontalFrame* f = new TGHorizontalFrame(gui.getTabContainer());
247  gui.getTabContainer()->AddFrame(f, new TGLayoutHints(kLHintsNormal, 2, 2,2,2 ));
248 
249  m_combo = new TGComboBox(f);
250  f->AddFrame(m_combo);
251  m_combo->Resize(140, 20);
252  f->AddFrame(new TGLabel(f, "Process"), new TGLayoutHints(kLHintsLeft, 8,2,2,2));
253 
254  resetCombo();
256  m_combo->Connect("Selected(const char*)", "FWTriggerTableView", tt, "processChanged(const char*)");
257  }
258 }
259 
260 void
261 FWTriggerTableView::saveImageTo(const std::string& /*iName*/) const
262 {
263  TString format;
264  TString data;
265  FWTextTableCellRenderer* textRenderer;
266 
267  // calculate widths
268  std::vector<size_t> widths(m_tableManager->numberOfColumns());
269 
270  for (int c = 0; c < m_tableManager->numberOfColumns(); ++c )
271  widths[c] = m_columns[c].title.size();
272 
273  for (int c = 0; c < m_tableManager->numberOfColumns(); ++c )
274  {
275  for (int r = 0; r < m_tableManager->numberOfRows(); r++ )
276  {
277  textRenderer = (FWTextTableCellRenderer*) m_tableManager->cellRenderer(r, c); // setup cell renderer
278  size_t ss = textRenderer->data().size();
279  if (widths[c] < ss) widths[c] = ss;
280  }
281  }
282 
283  int rlen = 0;
284  for (size_t c = 0; c < (size_t)m_tableManager->numberOfColumns(); ++c )
285  rlen += widths[c];
286  rlen += (m_tableManager->numberOfColumns() -1 )*3 ;
287  rlen++;
288 
289 
290  printf("\n");
291  int lastCol = m_tableManager->numberOfColumns() -1;
292 
293  for (int c = 0; c < m_tableManager->numberOfColumns(); ++c )
294  {
295  format.Form("%%%ds", (int)widths[c]);
296  data.Form(format,m_columns[c].title.c_str());
297  if (c == lastCol)
298  printf("%s", data.Data());
299  else
300  printf("%s | ", data.Data());
301  }
302  printf("\n");
303 
304  std::string splitter(rlen, '-');
305  std::cout << splitter << std::endl;
306 
307  for (int r = 0; r < m_tableManager->numberOfRows(); r++ )
308  {
309  for (int c = 0; c < m_tableManager->numberOfColumns(); ++c )
310  {
311  format.Form("%%%ds", (int)widths[c]);
312  textRenderer = (FWTextTableCellRenderer*) m_tableManager->cellRenderer(r, c); // setup cell renderer
313  data.Form(format, textRenderer->data().c_str());
314  if (c == lastCol)
315  printf("%s", data.Data());
316  else
317  printf("%s | ", data.Data());
318  }
319  printf("\n");
320  }
321 }
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:91
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:90
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:42