Public Member Functions | Private Attributes | List of all members
evdb::ScanFrame Class Reference

Helper class to setup scroll bars in evdb::ScanWindow. More...

#include <ScanWindow.h>

Public Member Functions

 ScanFrame (TGCompositeFrame *f)
 
virtual ~ScanFrame ()
 
TGGroupFrame * GetFrame () const
 
void SetCanvas (TGCanvas *canvas)
 
void HandleMouseWheel (Event_t *event)
 
void RadioButton ()
 
void ClearFields ()
 
void Record (std::string outfilename, const char *comments)
 
int GetHeight () const
 
int GetWidth () const
 

Private Attributes

TGGroupFrame * fFrame
 
TGCanvas * fCanvas
 
TGLayoutHints * fFrameHints
 
TGLayoutHints * fFieldFrameHints
 
TGLayoutHints * fCatFrameLH
 
std::vector< TGGroupFrame * > fCatFrames
 Mother for a category. More...
 
std::vector< TGHorizontalFrame * > fFieldFrames
 Mother for each field. More...
 
std::vector< TGTextEntry * > fTextBoxes
 Text box fields. More...
 
std::vector< TGLabel * > fNumberLabels
 Label for number fields. More...
 
std::vector< TGNumberEntry * > fNumberBoxes
 Number box fields. More...
 
std::vector< TGRadioButton * > fRadioButtons
 Radio button fields. More...
 
std::vector< TGCheckButton * > fCheckButtons
 Check button fields. More...
 
std::vector< int > fRadioButtonIds
 Ids for the radio buttons. More...
 

Detailed Description

Helper class to setup scroll bars in evdb::ScanWindow.

Definition at line 41 of file ScanWindow.h.

Constructor & Destructor Documentation

evdb::ScanFrame::ScanFrame ( TGCompositeFrame *  f)

Definition at line 37 of file ScanWindow.cxx.

38  {
40 
41  unsigned int nCategories = opts->fCategories.size();
42 
43  fFrame = new TGGroupFrame(f, "Please complete these fields", kVerticalFrame);
44  fFrameHints = new TGLayoutHints(kLHintsExpandX|
45  kLHintsExpandY,
46  4,4,4,4);
47  f->AddFrame(fFrame, fFrameHints);
48 
49  //
50  // grab the ScanOptions service and loop over the categories to make a
51  // ScanFrame for each
52  //
53  fCatFrameLH = new TGLayoutHints(kLHintsLeft|
54  kLHintsExpandX|
55  kLHintsTop,
56  2,2,2,2);
57  unsigned int pos = 0;
58  for(unsigned int c = 0; c < nCategories; ++c){
59  std::vector<std::string> types;
60  std::vector<std::string> labels;
61 
62  for(unsigned int p = 0; p < opts->fFieldsPerCategory[c]; ++p){
63  types. push_back(opts->fFieldTypes[pos+p]);
64  labels.push_back(opts->fFieldLabels[pos+p]);
65  }
66 
67  pos += opts->fFieldsPerCategory[c];
68 
69  //
70  // Create container for the current category.
71  //
72  TGGroupFrame *catframe = 0;
73  catframe = new TGGroupFrame(fFrame,
74  opts->fCategories[c].c_str(),
75  kRaisedFrame|kVerticalFrame);
76  fCatFrames.push_back(catframe);
77  fFrame->AddFrame(catframe,fCatFrameLH);
78 
79  fFieldFrameHints = new TGLayoutHints(kLHintsExpandX,2,2,2,2);
80 
81  // loop over the fields and determine what to draw
82  for(unsigned int i = 0; i < types.size(); ++i){
83  TGHorizontalFrame* fieldframe = new TGHorizontalFrame(catframe);
84  fFieldFrames.push_back(fieldframe);
85  catframe->AddFrame(fieldframe,fFieldFrameHints);
86 
87  if(types[i] == "Text") {
88  TGLabel *l = new TGLabel(fieldframe, labels[i].c_str());
89  fieldframe->AddFrame(l);
90  fTextBoxes.push_back(new TGTextEntry(fieldframe));
91  fieldframe->AddFrame(fTextBoxes[fTextBoxes.size()-1]);
92  }
93 
94  if(types[i] == "Number"){
95  TGLabel *l = new TGLabel(fieldframe, labels[i].c_str());
96  fieldframe->AddFrame(l);
97  TGNumberEntry*
98  ne = new TGNumberEntry(fieldframe,
99  0,
100  2,
101  -1,
102  TGNumberFormat::kNESInteger);
103  fieldframe->AddFrame(ne);
104 
105  fNumberLabels.push_back(l);
106  fNumberBoxes.push_back(ne);
107  }
108 
109  if(types[i] =="CheckButton"){
110  TGCheckButton* cb = new TGCheckButton(fieldframe,
111  labels[i].c_str(),
112  kInputID);
113  fieldframe->AddFrame(cb);
114  fCheckButtons.push_back(cb);
115  }
116 
117  if(types[i] =="RadioButton"){
118  TGRadioButton* rb = new TGRadioButton(fieldframe,
119  labels[i].c_str(),
120  kInputID);
121  fieldframe->AddFrame(rb);
122  rb->Connect("Clicked()",
123  "evdb::ScanFrame",
124  this,
125  "RadioButton()");
126 
127  fRadioButtons.push_back(rb);
128  fRadioButtonIds.push_back(kInputID);
129  }
130 
131  ++kInputID;
132 
133  }// end loop over types
134  } // end loop over categories
135 
136  fFrame->Connect("ProcessedEvent(Event_t*)",
137  "evdb::ScanFrame",
138  this,
139  "HandleMouseWheel(Event_t*)");
140  }
std::vector< unsigned int > fFieldsPerCategory
names of the various categories for the scan
Definition: ScanOptions.h:41
TGGroupFrame * fFrame
Definition: ScanWindow.h:61
TGLayoutHints * fFieldFrameHints
Definition: ScanWindow.h:64
TGLayoutHints * fCatFrameLH
Definition: ScanWindow.h:65
std::vector< TGTextEntry * > fTextBoxes
Text box fields.
Definition: ScanWindow.h:69
std::vector< TGCheckButton * > fCheckButtons
Check button fields.
Definition: ScanWindow.h:73
static QStrList * l
Definition: config.cpp:1044
std::vector< int > fRadioButtonIds
Ids for the radio buttons.
Definition: ScanWindow.h:74
TGLayoutHints * fFrameHints
Definition: ScanWindow.h:63
std::vector< std::string > fFieldLabels
types of the fields, ie TextEntry, Buttons, NumberEntry, etc
Definition: ScanOptions.h:43
std::vector< std::string > fFieldTypes
number of fields in each category
Definition: ScanOptions.h:42
std::vector< TGNumberEntry * > fNumberBoxes
Number box fields.
Definition: ScanWindow.h:71
std::vector< std::string > fCategories
base file name for scanning
Definition: ScanOptions.h:40
p
Definition: test.py:223
static const char types[][NUM_HTML_LIST_TYPES]
opts
Definition: ECLAPI.py:240
std::vector< TGGroupFrame * > fCatFrames
Mother for a category.
Definition: ScanWindow.h:67
std::vector< TGLabel * > fNumberLabels
Label for number fields.
Definition: ScanWindow.h:70
std::vector< TGRadioButton * > fRadioButtons
Radio button fields.
Definition: ScanWindow.h:72
std::vector< TGHorizontalFrame * > fFieldFrames
Mother for each field.
Definition: ScanWindow.h:68
static int kInputID
Definition: ScanWindow.cxx:32
evdb::ScanFrame::~ScanFrame ( )
virtual

Definition at line 143 of file ScanWindow.cxx.

144  {
145  unsigned int i;
146 
147  for(i=0; i<fCheckButtons.size(); ++i){
148  if( fCheckButtons[i] ) delete fCheckButtons[i];
149  }
150  for(i=0; i<fRadioButtons.size(); ++i){
151  if( fRadioButtons[i] ) delete fRadioButtons[i];
152  }
153  for (i=0; i<fNumberLabels.size(); ++i) {
154  if (fNumberLabels[i]) delete fNumberLabels[i];
155  }
156  for(i=0; i<fNumberBoxes.size(); ++i){
157  if( fNumberBoxes[i] ) delete fNumberBoxes[i];
158  }
159  for(i=0; i<fTextBoxes.size(); ++i){
160  if( fTextBoxes[i] ) delete fTextBoxes[i];
161  }
162  for(i=0; i<fFieldFrames.size(); ++i){
163  if( fFieldFrames[i] ) delete fFieldFrames[i];
164  }
165  for(i=0; i<fCatFrames.size(); ++i){
166  if( fCatFrames[i] ) delete fCatFrames[i];
167  }
168  delete fCatFrameLH;
169  delete fFieldFrameHints;
170  delete fFrameHints;
171  delete fFrame;
172  }
TGGroupFrame * fFrame
Definition: ScanWindow.h:61
TGLayoutHints * fFieldFrameHints
Definition: ScanWindow.h:64
TGLayoutHints * fCatFrameLH
Definition: ScanWindow.h:65
std::vector< TGTextEntry * > fTextBoxes
Text box fields.
Definition: ScanWindow.h:69
std::vector< TGCheckButton * > fCheckButtons
Check button fields.
Definition: ScanWindow.h:73
TGLayoutHints * fFrameHints
Definition: ScanWindow.h:63
std::vector< TGNumberEntry * > fNumberBoxes
Number box fields.
Definition: ScanWindow.h:71
std::vector< TGGroupFrame * > fCatFrames
Mother for a category.
Definition: ScanWindow.h:67
std::vector< TGLabel * > fNumberLabels
Label for number fields.
Definition: ScanWindow.h:70
std::vector< TGRadioButton * > fRadioButtons
Radio button fields.
Definition: ScanWindow.h:72
std::vector< TGHorizontalFrame * > fFieldFrames
Mother for each field.
Definition: ScanWindow.h:68

Member Function Documentation

void evdb::ScanFrame::ClearFields ( )

Definition at line 221 of file ScanWindow.cxx.

222  {
224 
225  unsigned int txtctr = 0;
226  unsigned int numctr = 0;
227  unsigned int radctr = 0;
228  unsigned int chkctr = 0;
229  for(unsigned int t = 0; t < scanopt->fFieldTypes.size(); ++t){
230 
231  if(scanopt->fFieldTypes[t] == "Text"){
232  if(txtctr < fTextBoxes.size() ){
233  fTextBoxes[txtctr]->Clear();
234  }
235  ++txtctr;
236  }
237  else if(scanopt->fFieldTypes[t] == "Number"){
238  if(numctr < fNumberBoxes.size() ){
239  fNumberBoxes[numctr]->SetNumber(0);
240  }
241  ++numctr;
242  }
243  else if(scanopt->fFieldTypes[t] == "RadioButton"){
244  if(radctr < fRadioButtons.size() ){
245  fRadioButtons[radctr]->SetState(kButtonUp);
246  }
247  ++radctr;
248  }
249  else if(scanopt->fFieldTypes[t] == "CheckButton"){
250  if(chkctr < fCheckButtons.size() ){
251  fCheckButtons[chkctr]->SetState(kButtonUp);
252  }
253  ++chkctr;
254  }
255 
256  }// end loop over input field types
257 
258  }
std::vector< TGTextEntry * > fTextBoxes
Text box fields.
Definition: ScanWindow.h:69
std::vector< TGCheckButton * > fCheckButtons
Check button fields.
Definition: ScanWindow.h:73
std::vector< std::string > fFieldTypes
number of fields in each category
Definition: ScanOptions.h:42
std::vector< TGNumberEntry * > fNumberBoxes
Number box fields.
Definition: ScanWindow.h:71
std::vector< TGRadioButton * > fRadioButtons
Radio button fields.
Definition: ScanWindow.h:72
TGGroupFrame* evdb::ScanFrame::GetFrame ( ) const
inline

Definition at line 48 of file ScanWindow.h.

48 { return fFrame; }
TGGroupFrame * fFrame
Definition: ScanWindow.h:61
int evdb::ScanFrame::GetHeight ( ) const

Definition at line 175 of file ScanWindow.cxx.

176  {
177  if (fFrame) return fFrame->GetHeight();
178  else return 0;
179  }
TGGroupFrame * fFrame
Definition: ScanWindow.h:61
int evdb::ScanFrame::GetWidth ( ) const

Definition at line 182 of file ScanWindow.cxx.

183  {
184  if (fFrame) return fFrame->GetWidth();
185  else return 0;
186  }
TGGroupFrame * fFrame
Definition: ScanWindow.h:61
void evdb::ScanFrame::HandleMouseWheel ( Event_t *  event)

Definition at line 190 of file ScanWindow.cxx.

191  {
192  // Handle mouse wheel to scroll.
193 
194  if (event->fType != kButtonPress && event->fType != kButtonRelease)
195  return;
196 
197  Int_t page = 0;
198  if (event->fCode == kButton4 || event->fCode == kButton5) {
199  if (fCanvas==0) return;
200  if (fCanvas->GetContainer()->GetHeight())
201 
202  page = Int_t(Float_t(fCanvas->GetViewPort()->GetHeight() *
203  fCanvas->GetViewPort()->GetHeight()) /
204  fCanvas->GetContainer()->GetHeight());
205  }
206 
207  if (event->fCode == kButton4) {
208  //scroll up
209  Int_t newpos = fCanvas->GetVsbPosition() - page;
210  if (newpos < 0) newpos = 0;
211  fCanvas->SetVsbPosition(newpos);
212  }
213  if (event->fCode == kButton5) {
214  // scroll down
215  Int_t newpos = fCanvas->GetVsbPosition() + page;
216  fCanvas->SetVsbPosition(newpos);
217  }
218  }
TGCanvas * fCanvas
Definition: ScanWindow.h:62
Event finding and building.
void evdb::ScanFrame::RadioButton ( )

Definition at line 375 of file ScanWindow.cxx.

376  {
377  TGButton *b = (TGButton *)gTQSender;
378  int id = b->WidgetId();
379 
380  if(fRadioButtonIds.size() < 2) return;
381 
382  if(id >= fRadioButtonIds[0] && id <= fRadioButtonIds[fRadioButtonIds.size()-1]){
383  for(unsigned int i = 0; i < fRadioButtonIds.size(); ++i)
384  if(fRadioButtons[i]->WidgetId() != id) fRadioButtons[i]->SetState(kButtonUp);
385  }
386 
387  return;
388  }
std::vector< int > fRadioButtonIds
Ids for the radio buttons.
Definition: ScanWindow.h:74
static bool * b
Definition: config.cpp:1043
std::vector< TGRadioButton * > fRadioButtons
Radio button fields.
Definition: ScanWindow.h:72
void evdb::ScanFrame::Record ( std::string  outfilename,
const char *  comments 
)

Definition at line 261 of file ScanWindow.cxx.

263  {
265 
266  // get the event information
268 
269  std::ofstream outfile(outfilename.c_str(), std::ios_base::app);
270 
271  outfile << evt->run() << " " << evt->subRun() << " " << evt->id().event() << " ";
272 
273  // loop over the input fields
274  unsigned int txtctr = 0;
275  unsigned int numctr = 0;
276  unsigned int radctr = 0;
277  unsigned int chkctr = 0;
278  for(unsigned int t = 0; t < scanopt->fFieldTypes.size(); ++t){
279 
280  if(scanopt->fFieldTypes[t] == "Text"){
281  if(txtctr < fTextBoxes.size() ){
282  outfile << fTextBoxes[txtctr]->GetText() << " ";
283  fTextBoxes[txtctr]->Clear();
284  }
285  ++txtctr;
286  }
287  else if(scanopt->fFieldTypes[t] == "Number"){
288  if(numctr < fNumberBoxes.size() ){
289  outfile << fNumberBoxes[numctr]->GetNumber() << " ";
290  fNumberBoxes[numctr]->SetNumber(0);
291  }
292  ++numctr;
293  }
294  else if(scanopt->fFieldTypes[t] == "RadioButton"){
295  if(radctr < fRadioButtons.size() ){
296  outfile << (fRadioButtons[radctr]->GetState() == kButtonDown) << " ";
297  fRadioButtons[radctr]->SetState(kButtonUp);
298  }
299  ++radctr;
300  }
301  else if(scanopt->fFieldTypes[t] == "CheckButton"){
302  if(chkctr < fCheckButtons.size() ){
303  outfile << (fCheckButtons[chkctr]->GetState() == kButtonDown) << " ";
304  fCheckButtons[chkctr]->SetState(kButtonUp);
305  }
306  ++chkctr;
307  }
308 
309  }// end loop over input field types
310 
311  // do we need to get the truth information?
312  if(scanopt->fIncludeMCInfo){
313 
314  std::vector< art::Handle< std::vector<simb::MCTruth> > > mclist;
315 
316  try {
317  evt->getManyByType(mclist);
318 
319  bool listok = (mclist.size()>0);
320  bool isnu = false;
321  if (listok) {
322  isnu = (mclist[0]->at(0).Origin()==simb::kBeamNeutrino);
323  }
324 
325  if (listok==false) {
326  mf::LogWarning("ScanWindow")
327  << "MC truth information requested for output file"
328  << " but no MCTruth objects found in event - "
329  << " put garbage numbers into the file";
330  outfile
331  << -999. << " " << -999. << " " << -999. << " "
332  << -999. << " " << -999. << " " << -999. << " " << -999.;
333  }
334 
335  if ( listok && isnu==false) {
336  mf::LogWarning("ScanWindow")
337  << "Unknown particle source or truth information N/A"
338  << " put garbage numbers into the file";
339  outfile
340  << -999. << " " << -999. << " " << -999. << " "
341  << -999. << " " << -999. << " " << -999.<< " " << -999.;
342  }
343 
344  if (listok && isnu) {
345  // get the event vertex and energy information,
346  const simb::MCNeutrino& nu = mclist[0]->at(0).GetNeutrino();
347 
348  outfile << nu.Nu().PdgCode() << " "
349  << nu.Nu().Vx() << " "
350  << nu.Nu().Vy() << " "
351  << nu.Nu().Vz() << " "
352  << nu.Nu().E() << " "
353  << nu.CCNC() << " "
354  << nu.Lepton().E() << " "
355  << nu.InteractionType();
356  }
357  }
358  catch(cet::exception &e){
359  mf::LogWarning("ScanWindow")
360  << "MC truth information requested for output file"
361  << " but no MCTruth objects found in event - "
362  << " put garbage numbers into the file";
363  outfile
364  << -999. << " " << -999. << " " << -999. << " "
365  << -999. << " " << -999. << " " << -999.;
366  }
367  }//end if using MC information
368 
369  // end this line for the event
370  outfile << " " << comments << std::endl;
371  }
double E(const int i=0) const
Definition: MCParticle.h:232
int PdgCode() const
Definition: MCParticle.h:211
int CCNC() const
Definition: MCNeutrino.h:148
const art::Event * GetEvent() const
Definition: EventHolder.cxx:45
const simb::MCParticle & Nu() const
Definition: MCNeutrino.h:146
std::vector< TGTextEntry * > fTextBoxes
Text box fields.
Definition: ScanWindow.h:69
std::vector< TGCheckButton * > fCheckButtons
Check button fields.
Definition: ScanWindow.h:73
std::vector< std::string > fFieldTypes
number of fields in each category
Definition: ScanOptions.h:42
int InteractionType() const
Definition: MCNeutrino.h:150
std::vector< TGNumberEntry * > fNumberBoxes
Number box fields.
Definition: ScanWindow.h:71
const double e
const simb::MCParticle & Lepton() const
Definition: MCNeutrino.h:147
static EventHolder * Instance()
Definition: EventHolder.cxx:15
void getManyByType(std::vector< Handle< PROD >> &results) const
Definition: DataViewImpl.h:558
SubRunNumber_t subRun() const
Definition: DataViewImpl.cc:89
RunNumber_t run() const
Definition: DataViewImpl.cc:82
double Vx(const int i=0) const
Definition: MCParticle.h:220
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
double Vz(const int i=0) const
Definition: MCParticle.h:222
EventNumber_t event() const
Definition: EventID.h:116
TCEvent evt
Definition: DataStructs.cxx:7
Event generator information.
Definition: MCNeutrino.h:18
vector< string > comments
std::vector< TGRadioButton * > fRadioButtons
Radio button fields.
Definition: ScanWindow.h:72
EventID id() const
Definition: Event.cc:37
double Vy(const int i=0) const
Definition: MCParticle.h:221
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
Beam neutrinos.
Definition: MCTruth.h:23
void evdb::ScanFrame::SetCanvas ( TGCanvas *  canvas)
inline

Definition at line 50 of file ScanWindow.h.

50 { fCanvas = canvas; }
TGCanvas * fCanvas
Definition: ScanWindow.h:62

Member Data Documentation

TGCanvas* evdb::ScanFrame::fCanvas
private

Definition at line 62 of file ScanWindow.h.

TGLayoutHints* evdb::ScanFrame::fCatFrameLH
private

Definition at line 65 of file ScanWindow.h.

std::vector<TGGroupFrame*> evdb::ScanFrame::fCatFrames
private

Mother for a category.

Definition at line 67 of file ScanWindow.h.

std::vector<TGCheckButton*> evdb::ScanFrame::fCheckButtons
private

Check button fields.

Definition at line 73 of file ScanWindow.h.

TGLayoutHints* evdb::ScanFrame::fFieldFrameHints
private

Definition at line 64 of file ScanWindow.h.

std::vector<TGHorizontalFrame*> evdb::ScanFrame::fFieldFrames
private

Mother for each field.

Definition at line 68 of file ScanWindow.h.

TGGroupFrame* evdb::ScanFrame::fFrame
private

Definition at line 61 of file ScanWindow.h.

TGLayoutHints* evdb::ScanFrame::fFrameHints
private

Definition at line 63 of file ScanWindow.h.

std::vector<TGNumberEntry*> evdb::ScanFrame::fNumberBoxes
private

Number box fields.

Definition at line 71 of file ScanWindow.h.

std::vector<TGLabel*> evdb::ScanFrame::fNumberLabels
private

Label for number fields.

Definition at line 70 of file ScanWindow.h.

std::vector<int> evdb::ScanFrame::fRadioButtonIds
private

Ids for the radio buttons.

Definition at line 74 of file ScanWindow.h.

std::vector<TGRadioButton*> evdb::ScanFrame::fRadioButtons
private

Radio button fields.

Definition at line 72 of file ScanWindow.h.

std::vector<TGTextEntry*> evdb::ScanFrame::fTextBoxes
private

Text box fields.

Definition at line 69 of file ScanWindow.h.


The documentation for this class was generated from the following files: