CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWGUIEventFilter.cc
Go to the documentation of this file.
1 #include "TGLabel.h"
2 #include "TG3DLine.h"
3 #include "TGResourcePool.h"
16 
18  TGMainFrame(gClient->GetRoot(), 560, 300),
19 
20 
21  m_origFilterMode(CmsShowNavigator::kOr),
22  m_isOpen(false),
23  m_filtersRemoved(false),
24 
25  m_eventSelectionFrameParent(0),
26  m_eventSelectionFrame(0),
27  m_triggerSelectionFrameParent(0),
28  m_triggerSelectionFrame(0),
29 
30  m_rad1(0),
31  m_rad2(0),
32  m_stateLabel(0),
33  m_disableFilteringBtn(0),
34  m_addBtn(0),
35 
36  m_navigator(n)
37 {
38  SetWindowName("Event Filters");
39 
40  TGVerticalFrame* v1 = new TGVerticalFrame(this);
41  AddFrame(v1, new TGLayoutHints(kLHintsExpandX |kLHintsExpandY));
42 
43 
44  //----------------------- Event selection
45 
46  {
47  m_eventSelectionFrameParent = new TGVerticalFrame(v1, GetWidth(), s_entryHeight, 0);
48  v1->AddFrame(m_eventSelectionFrameParent, new TGLayoutHints(kLHintsExpandX|kLHintsTop, 2, 2, 0,0));
49 
50  // headers
51  TGHorizontalFrame* selH = new TGHorizontalFrame(m_eventSelectionFrameParent);
52  m_eventSelectionFrameParent->AddFrame(selH, new TGLayoutHints(kLHintsExpandX));
53 
54  {
55  TGCompositeFrame *cfr = new TGHorizontalFrame(selH);
56  selH->AddFrame(cfr, new TGLayoutHints(kLHintsExpandX));
57  cfr->AddFrame(new TGLabel(cfr, "Event Filter Expression:"), new TGLayoutHints(kLHintsLeft|kLHintsBottom, 2, 2, 6, 4));
58  }
59  {
60  TGCompositeFrame *cfr = new TGHorizontalFrame(selH, 122, 22, kFixedSize);
61  selH->AddFrame(cfr);
62  cfr->AddFrame(new TGLabel(cfr, "Comment:"), new TGLayoutHints(kLHintsLeft|kLHintsBottom, 2, 2, 2, 0));
63  }
64  {
65  TGCompositeFrame *cfr = new TGHorizontalFrame(selH, 105, 22, kFixedSize);
66  selH->AddFrame(cfr);
67  cfr->AddFrame(new TGLabel(cfr, "Pass:"), new TGLayoutHints(kLHintsLeft|kLHintsBottom, 2, 2, 2, 0));
68  }
69 
70 
71  TGHorizontalFrame* addBtnFrame = new TGHorizontalFrame(v1);
72  v1->AddFrame(addBtnFrame, new TGLayoutHints(kLHintsExpandX));
73  addBtnFrame->AddFrame(new TGHorizontal3DLine(addBtnFrame), new TGLayoutHints(kLHintsExpandX | kLHintsCenterY,4 ,8, 2, 2));
74 
75  m_addBtn = new FWCustomIconsButton(addBtnFrame, fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "plus-sign.png"),
76  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "plus-sign-over.png"),
77  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "plus-sign-disabled.png"));
78 
79  addBtnFrame->AddFrame(m_addBtn, new TGLayoutHints(kLHintsRight/*|kLHintsExpandX|kLHintsExpandY*/, 0, 6, 4, 1));
80  TQObject::Connect(m_addBtn, "Clicked()", "FWGUIEventFilter", this, "newEventEntry()");
81  }
82 
83  //----------------------- TriggerResults selection
84 
85  {
86  m_triggerSelectionFrameParent = new TGVerticalFrame(v1, GetWidth(), s_entryHeight, 0);
87  v1->AddFrame(m_triggerSelectionFrameParent, new TGLayoutHints(kLHintsExpandX|kLHintsTop, 2, 2, 0,0));
88 
89  // headers
90  TGHorizontalFrame* selH = new TGHorizontalFrame(m_triggerSelectionFrameParent);
91  m_triggerSelectionFrameParent->AddFrame(selH, new TGLayoutHints(kLHintsExpandX));
92 
93  {
94  TGCompositeFrame *cfr = new TGHorizontalFrame(selH);
95  selH->AddFrame(cfr, new TGLayoutHints(kLHintsExpandX));
96  cfr->AddFrame(new TGLabel(cfr, "TriggerResults Filter Expression:"), new TGLayoutHints(kLHintsLeft|kLHintsBottom, 2, 2, 6, 04));
97  }
98  {
99  TGCompositeFrame *cfr = new TGHorizontalFrame(selH, 122, 22, kFixedSize);
100  selH->AddFrame(cfr);
101  cfr->AddFrame(new TGLabel(cfr, "Comment:"), new TGLayoutHints(kLHintsLeft|kLHintsBottom, 2, 2, 0, 0));
102  }
103  {
104  TGCompositeFrame *cfr = new TGHorizontalFrame(selH, 105, 22, kFixedSize);
105  selH->AddFrame(cfr);
106  cfr->AddFrame(new TGLabel(cfr, "Pass:"), new TGLayoutHints(kLHintsLeft|kLHintsBottom, 2, 2, 0, 0));
107  }
108 
109  //-------------------- adding new selection
110 
111  TGHorizontalFrame* addBtnFrame = new TGHorizontalFrame(v1);
112  v1->AddFrame(addBtnFrame, new TGLayoutHints(kLHintsExpandX));
113 
114  addBtnFrame->AddFrame(new TGHorizontal3DLine(addBtnFrame), new TGLayoutHints(kLHintsExpandX | kLHintsCenterY,4 ,8, 2, 2));
115  m_addBtn = new FWCustomIconsButton(addBtnFrame, fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "plus-sign.png"),
116  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "plus-sign-over.png"),
117  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "plus-sign-disabled.png"));
118 
119  addBtnFrame->AddFrame(m_addBtn, new TGLayoutHints(kLHintsRight/*|kLHintsExpandX|kLHintsExpandY*/, 0, 6, 4, 1));
120  TQObject::Connect(m_addBtn, "Clicked()", "FWGUIEventFilter", this, "newTriggerEntry()");
121 
122  }
123 
124  //-------------------- logical operations
125 
126  TGHorizontalFrame* headerFrame = new TGHorizontalFrame(v1/*, 360, 61, kHorizontalFrame | kFixedSize*/);
127 
128  {
129  TGHorizontalFrame* xx = new TGHorizontalFrame(v1);
130  fireworks_root_gui::makeLabel(xx, "Combine Expression Width:", 152, 2,2,2,2);
131  m_rad1 = new TGRadioButton(xx, "OR", 81);
132  xx->AddFrame(m_rad1, new TGLayoutHints(kLHintsNormal, 2,10, 0, 0));
133  m_rad1->SetState(kButtonDown);
134  m_rad2 = new TGRadioButton(xx, "AND", 82);
135  xx->AddFrame(m_rad2);
136  m_rad1->Connect("Clicked()", "FWGUIEventFilter", this, "changeFilterMode()");
137  m_rad2->Connect("Clicked()", "FWGUIEventFilter", this, "changeFilterMode()");
138 
139  v1->AddFrame(xx, new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2));
140  }
141  v1->AddFrame(headerFrame, new TGLayoutHints(kLHintsNormal, 1, 1, 1, 1));
142 
143 
144  //-------------------- status
145  {
146  TGHorizontalFrame* hf = new TGHorizontalFrame(v1);
147  v1->AddFrame(hf, new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 20));
148  fireworks_root_gui::makeLabel(hf, "Status:", 37, 2,2,2,2);
149  {
150  TGGC *fTextGC;
151  const TGFont *font = gClient->GetFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
152  if (!font)
153  font = gClient->GetResourcePool()->GetDefaultFont();
154  GCValues_t gval;
155  gval.fMask = kGCBackground | kGCFont | kGCForeground;
156  gval.fFont = font->GetFontHandle();
157  fTextGC = gClient->GetGC(&gval, kTRUE);
158 
159  TGHorizontalFrame *labFrame = new TGHorizontalFrame(hf, 380, 22, kHorizontalFrame | kFixedWidth);
160  hf->AddFrame(labFrame, new TGLayoutHints(kLHintsNormal));
161 
162  m_stateLabel = new TGLabel(labFrame, "x", fTextGC->GetGC());
163  labFrame->AddFrame(m_stateLabel, new TGLayoutHints( kLHintsLeft,2,2,2,2));
164 
165  }
166  }
167  //-------------------- external actions
168 
169  TGHorizontalFrame* btnFrame = new TGHorizontalFrame(v1, 280, 30);
170  v1->AddFrame(btnFrame, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX | kLHintsBottom , 0, 0, 2, 4));
171 
172  TGTextButton* cancel = new TGTextButton(btnFrame," Close ");
173  btnFrame->AddFrame(cancel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY , 20, 20, 2, 4));
174  cancel->Connect("Clicked()","FWGUIEventFilter", this, "CloseWindow()");
175 
176  {
177  TGHorizontalFrame* f = new TGHorizontalFrame(btnFrame);
178  btnFrame->AddFrame(f, new TGLayoutHints(kLHintsRight, 4, 18, 2, 4));
179  m_disableFilteringBtn = new TGTextButton(f, " Disable Filtering ");
180  f->AddFrame(m_disableFilteringBtn, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 4, 10, 2, 4));
181  m_disableFilteringBtn->Connect("Clicked()","FWGUIEventFilter", this, "disableFilters()");
182 
183  m_applyBtn = new TGTextButton(f,"Apply Filters");
184  f->AddFrame(m_applyBtn, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 4, 8, 2, 4));
185  m_applyBtn->Connect("Clicked()","FWGUIEventFilter", this, "apply()");
186  m_applyBtn->SetToolTipText("Enable filtering and apply changes.");
187  }
188 
189 
190 }
191 
193 {
194 }
195 
196 void
198 {
199  TGCompositeFrame* parent = sel->m_triggerProcess.empty() ? m_eventSelectionFrame : m_triggerSelectionFrame;
201  parent->AddFrame(es, new TGLayoutHints(kLHintsExpandX));
202  TQObject::Connect(es, "removeSelector(FWGUIEventSelector*)", "FWGUIEventFilter", this, "deleteEntry(FWGUIEventSelector*)");
203  TQObject::Connect(es, "selectorChanged()", "FWGUIEventFilter", this, "checkApplyButton()");
204 
205  m_guiSelectors.push_back(es);
206 
207 }
208 
209 void
211 {
212  TGButton *btn = (TGButton *) gTQSender;
213 
214  if (btn->WidgetId() == 81)
215  m_rad2->SetState(kButtonUp);
216  else
217  m_rad1->SetState(kButtonUp);
219 }
220 
221 void
222 FWGUIEventFilter::show( std::list<FWEventSelector*>* sels, int filterMode, int filterState)
223 {
224  m_applyBtn->SetForegroundColor(0x000000);
225  m_filtersRemoved = false;
226 
227  m_isOpen = true;
228 
229  m_origFilterMode = filterMode;
230 
231  if (filterMode == CmsShowNavigator::kOr)
232  {
233  m_rad1->SetState(kButtonDown, false);
234  m_rad2->SetState(kButtonUp, false);
235  }
236  else
237  {
238  m_rad2->SetState(kButtonDown, false);
239  m_rad1->SetState(kButtonUp, false);
240  }
241 
243 
244  m_eventSelectionFrame = new TGVerticalFrame(m_eventSelectionFrameParent);
245  m_eventSelectionFrameParent->AddFrame(m_eventSelectionFrame, new TGLayoutHints(kLHintsExpandX));
246 
248  m_triggerSelectionFrameParent->AddFrame(m_triggerSelectionFrame, new TGLayoutHints(kLHintsExpandX));
249 
250  for(std::list<FWEventSelector*>::iterator i = sels->begin(); i != sels->end(); ++i)
251  addSelector(*i);
252 
253  updateFilterStateLabel(filterState);
254 
255  MapSubwindows();
256  Layout();
257  MapRaised();
258 }
259 
260 void
262 {
263  // called on load of configuration
267  }
271  }
272 
273  for (std::list<FWGUIEventSelector*>::iterator i = m_guiSelectors.begin(); i != m_guiSelectors.end(); ++i)
274  delete *i;
275 
276  m_guiSelectors.clear();
277 }
278 
280 // Callbacks
282 
283 void
285 {
286  m_filtersRemoved = true;
287 
288  m_guiSelectors.remove(sel);
289 
290  TGCompositeFrame* p = 0;
291  if (sel->origSelector()->m_triggerProcess.empty())
293  else
295 
296  p->RemoveFrame(sel);
297  Resize(GetWidth(), GetDefaultHeight());
298  Layout();
299  gClient->NeedRedraw(this);
300 }
301 
302 void
304 {
306  s->m_triggerProcess = "HLT";
307  addSelector(s);
308  MapSubwindows();
309 
310  Resize(GetWidth(), GetDefaultHeight());
311 
312  Layout();
313 }
314 
315 void
317 {
319  MapSubwindows();
320  Resize(GetWidth(), GetDefaultHeight());
321  Layout();
322 }
323 
324 void
326 {
328 
330  m_filtersRemoved = false;
331  m_applyBtn->SetForegroundColor(0x000000);
332  fClient->NeedRedraw( this);
333 
334 }
335 
336 void
338 {
339  m_disableFilteringBtn->SetEnabled(x);
340 }
341 
342 void
344 {
346 }
347 
348 int
350 {
351  if (m_rad1->IsOn())
352  return CmsShowNavigator::kOr;
353  else
354  return CmsShowNavigator::kAnd;
355 }
356 
357 void
359 {
360  m_isOpen = false;
365 
366  FWGUIEventSelector* gs;
367  for (std::list<FWGUIEventSelector*>::iterator i = m_guiSelectors.begin(); i != m_guiSelectors.end(); ++i)
368  {
369  gs = *i;
370  delete gs;
371  }
372 
373  m_guiSelectors.clear();
374  UnmapWindow();
376 }
377 
378 
379 void
381 {
382  // set color of apply button if changed
383 
384  bool changed = ( m_filtersRemoved || (getFilterMode() != m_origFilterMode) );
385 
386  if (!changed)
387  {
388  std::list<FWGUIEventSelector*>::iterator i = m_guiSelectors.begin();
389  while (i != m_guiSelectors.end())
390  {
391  if ((*i)->origSelector() == 0 ||
392  (*i)->guiSelector()->m_enabled != (*i)->origSelector()->m_enabled ||
393  (*i)->guiSelector()->m_expression != (*i)->origSelector()->m_expression )
394  {
395  changed = true;
396  break;
397  }
398 
399  ++i;
400  }
401  }
402 
403 
404  m_applyBtn->SetForegroundColor(changed ? 0x40FF80 : 0x000000);
405  gClient->NeedRedraw( m_applyBtn);
406 }
407 
408 void
410 {
411  if (state == CmsShowNavigator::kOn)
412  m_stateLabel->SetText(Form("%d events selected from %d ", m_navigator->getNSelectedEvents(), m_navigator->getNTotalEvents()));
413  else if (state == CmsShowNavigator::kOff)
414  m_stateLabel->SetText("Filtering Disabled ");
415  else
416  m_stateLabel->SetText("Filtering Withdrawn ");
417 
418  Layout();
419 }
420 
421 /*
422  AMT no effect after resize
423 void
424 FWGUIEventFilter::addTo(FWConfiguration& iTo) const
425 {
426  FWConfiguration tmp;
427  {
428  std::stringstream s;
429  s << GetWidth();
430  tmp.addKeyValue("width", s.str());
431  }
432  {
433  std::stringstream s;
434  s << GetHeight();
435  tmp.addKeyValue("height", s.str());
436  }
437 
438  iTo.addKeyValue("EventFilterGUI", tmp, true);
439 
440 }
441 
442 void
443 FWGUIEventFilter::setFrom(const FWConfiguration& iFrom)
444 {
445  const FWConfiguration* conf = iFrom.valueForKey("EventFilterGUI");
446  if (conf) {
447  UInt_t w = atoi(conf->valueForKey("width")->value().c_str());
448  UInt_t h = atoi(conf->valueForKey("height")->value().c_str());
449  Resize(w, h);
450  }
451 }
452 */
453 
455 {
456  // AMT workaround for problems to override root's action for 'Ctrl+s'
457 
458  if (GetBindList()->IsEmpty())
460 
461  TIter next(fBindList);
462  TGMapKey *m;
463  TGFrame *w = 0;
464 
465  while ((m = (TGMapKey *) next())) {
466  if (m->fKeyCode == event->fCode) {
467  w = (TGFrame *) m->fWindow;
468  if (w->HandleKey(event)) return kTRUE;
469  }
470  }
471  return kFALSE;
472 }
static const TString & coreIcondir()
FWEventSelector * origSelector()
int i
Definition: DBlmapReader.cc:9
void bindCSGActionKeys(const TGMainFrame *f) const
list parent
Definition: dbtoconf.py:74
const double w
Definition: UKUtility.cc:23
assert(m_qm.get())
TGTextButton * m_applyBtn
TGRadioButton * m_rad1
std::string m_triggerProcess
void show(std::list< FWEventSelector * > *sels, int filterMode, int state)
FWGUIEventFilter(CmsShowNavigator *)
TGCompositeFrame * m_eventSelectionFrameParent
T x() const
Cartesian x coordinate.
TGCompositeFrame * m_triggerSelectionFrameParent
if(c.getParameter< edm::InputTag >("puppiValueMap").label().size()!=0)
double f[11][100]
void updateFilterStateLabel(int)
CmsShowNavigator * m_navigator
TGCompositeFrame * m_triggerSelectionFrame
CmsShowMainFrame * getMainFrame() const
Definition: FWGUIManager.h:201
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
static const int s_entryHeight
std::vector< std::string > & getProcessList() const
virtual ~FWGUIEventFilter()
static FWGUIManager * getGUIManager()
TGLabel * m_stateLabel
TGRadioButton * m_rad2
FWCustomIconsButton * m_addBtn
TGCompositeFrame * m_eventSelectionFrame
void setupDisableFilteringButton(bool)
Bool_t HandleKey(Event_t *event)
void addSelector(FWEventSelector *sel)
volatile std::atomic< bool > shutdown_flag false
TGTextButton * m_disableFilteringBtn
std::list< FWGUIEventSelector * > m_guiSelectors
TGLabel * makeLabel(TGCompositeFrame *p, const char *txt, int width, int lo=0, int ro=0, int to=2, int bo=0)
Definition: RootGuiUtils.cc:21
void deleteEntry(FWGUIEventSelector *)
virtual void CloseWindow()