11 #include "TGDimension.h" 12 #include "TGNumberEntry.h" 14 #include "TGScrollBar.h" 19 #include "TTimeStamp.h" 41 unsigned int nCategories = opts->
fCategories.size();
43 fFrame =
new TGGroupFrame(f,
"Please complete these fields", kVerticalFrame);
58 for(
unsigned int c = 0; c < nCategories; ++c){
59 std::vector<std::string> types;
60 std::vector<std::string> labels;
72 TGGroupFrame *catframe = 0;
73 catframe =
new TGGroupFrame(
fFrame,
75 kRaisedFrame|kVerticalFrame);
82 for(
unsigned int i = 0; i < types.size(); ++i){
83 TGHorizontalFrame* fieldframe =
new TGHorizontalFrame(catframe);
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));
94 if(types[i] ==
"Number"){
95 TGLabel *l =
new TGLabel(fieldframe, labels[i].c_str());
96 fieldframe->AddFrame(l);
98 ne =
new TGNumberEntry(fieldframe,
102 TGNumberFormat::kNESInteger);
103 fieldframe->AddFrame(ne);
109 if(types[i] ==
"CheckButton"){
110 TGCheckButton* cb =
new TGCheckButton(fieldframe,
113 fieldframe->AddFrame(cb);
117 if(types[i] ==
"RadioButton"){
118 TGRadioButton* rb =
new TGRadioButton(fieldframe,
121 fieldframe->AddFrame(rb);
122 rb->Connect(
"Clicked()",
136 fFrame->Connect(
"ProcessedEvent(Event_t*)",
139 "HandleMouseWheel(Event_t*)");
194 if (event->fType != kButtonPress && event->fType != kButtonRelease)
198 if (event->fCode == kButton4 || event->fCode == kButton5) {
200 if (
fCanvas->GetContainer()->GetHeight())
202 page = Int_t(Float_t(
fCanvas->GetViewPort()->GetHeight() *
203 fCanvas->GetViewPort()->GetHeight()) /
204 fCanvas->GetContainer()->GetHeight());
207 if (event->fCode == kButton4) {
209 Int_t newpos =
fCanvas->GetVsbPosition() - page;
210 if (newpos < 0) newpos = 0;
211 fCanvas->SetVsbPosition(newpos);
213 if (event->fCode == kButton5) {
215 Int_t newpos =
fCanvas->GetVsbPosition() + page;
216 fCanvas->SetVsbPosition(newpos);
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){
262 const char* comments)
269 std::ofstream outfile(outfilename.c_str(), std::ios_base::app);
271 outfile << evt->
run() <<
" " << evt->
subRun() <<
" " << evt->
id().
event() <<
" ";
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){
282 outfile <<
fTextBoxes[txtctr]->GetText() <<
" ";
296 outfile << (
fRadioButtons[radctr]->GetState() == kButtonDown) <<
" ";
303 outfile << (
fCheckButtons[chkctr]->GetState() == kButtonDown) <<
" ";
315 auto const mclist = evt->
getMany<std::vector<simb::MCTruth>>();
317 bool listok = (mclist.size()>0);
325 <<
"MC truth information requested for output file" 326 <<
" but no MCTruth objects found in event - " 327 <<
" put garbage numbers into the file";
329 << -999. <<
" " << -999. <<
" " << -999. <<
" " 330 << -999. <<
" " << -999. <<
" " << -999. <<
" " << -999.;
333 if ( listok && isnu==
false) {
335 <<
"Unknown particle source or truth information N/A" 336 <<
" put garbage numbers into the file";
338 << -999. <<
" " << -999. <<
" " << -999. <<
" " 339 << -999. <<
" " << -999. <<
" " << -999.<<
" " << -999.;
342 if (listok && isnu) {
347 << nu.
Nu().
Vx() <<
" " 348 << nu.
Nu().
Vy() <<
" " 349 << nu.
Nu().
Vz() <<
" " 350 << nu.
Nu().
E() <<
" " 358 <<
"MC truth information requested for output file" 359 <<
" but no MCTruth objects found in event - " 360 <<
" put garbage numbers into the file";
362 << -999. <<
" " << -999. <<
" " << -999. <<
" " 363 << -999. <<
" " << -999. <<
" " << -999.;
368 outfile <<
" " << comments << std::endl;
375 TGButton *b = (TGButton *)gTQSender;
376 int id = b->WidgetId();
392 fCommentLabel =
new TGLabel (f,
" Comments:");
393 fCommentEntry =
new TGTextEntry (f);
394 fPrevButton =
new TGTextButton(f,
" <<Prev ");
395 fNextButton =
new TGTextButton(f,
" Next>> ");
396 fRcrdButton =
new TGTextButton(f,
" Record ");
398 fPrevButton->Connect(
"Clicked()",
"evdb::ScanWindow",
this,
"Prev()");
399 fNextButton->Connect(
"Clicked()",
"evdb::ScanWindow",
this,
"Next()");
400 fRcrdButton->Connect(
"Clicked()",
"evdb::ScanWindow",
this,
"Rec()");
403 gClient->GetColorByName(
"pink", c);
404 fRcrdButton->ChangeBackground(c);
406 fButtonBarHintsL =
new TGLayoutHints(kLHintsBottom|kLHintsLeft,
408 fButtonBarHintsC =
new TGLayoutHints(kLHintsBottom|kLHintsLeft,
410 fButtonBarHintsR =
new TGLayoutHints(kLHintsBottom|kLHintsLeft,
412 f->AddFrame(fCommentLabel, fButtonBarHintsL);
413 f->AddFrame(fCommentEntry, fButtonBarHintsC);
414 f->AddFrame(fPrevButton, fButtonBarHintsC);
415 f->AddFrame(fNextButton, fButtonBarHintsC);
416 f->AddFrame(fRcrdButton, fButtonBarHintsR);
423 unsigned int kCanvasWidth = 390;
424 unsigned int kCanvasHeight = 500;
426 fUserFieldsCanvas =
new 427 TGCanvas(f, kCanvasWidth, kCanvasHeight);
429 fUserFieldsCanvasHints =
new TGLayoutHints(kLHintsExpandX|
431 f->AddFrame(fUserFieldsCanvas, fUserFieldsCanvasHints);
433 fScanFrame =
new ScanFrame(fUserFieldsCanvas->GetViewPort());
434 fUserFieldsCanvas->SetContainer(fScanFrame->GetFrame());
435 fScanFrame->GetFrame()->SetCleanup(kDeepCleanup);
441 TGTransientFrame(gClient->GetRoot(), gClient->GetRoot(), 50, 50),
442 fUserFieldsCanvas(0),
460 unsigned int kWidth = 5*50;
461 unsigned int kHeight = 7*50;
463 new TGCompositeFrame(
this, kWidth, kHeight);
465 new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX|kLHintsExpandY);
471 unsigned int kButtonBarWidth = 388;
472 unsigned int kButtonBarHeight = 30;
474 new TGHorizontalFrame(
this, kButtonBarHeight, kButtonBarWidth);
476 new TGLayoutHints(kLHintsBottom|kLHintsLeft);
486 this->Resize(kButtonBarWidth,kHeight+kButtonBarHeight);
487 this->MapSubwindows();
489 this->SetWindowName(
"Scan dialog window");
498 std::string user(gSystem->Getenv(
"USER"));
501 std::string time(cur.AsString(
"s"));
502 time.replace(time.find(
" "), 1,
"_");
511 outfile <<
"Run Subrun Event ";
517 unsigned int maxFields = 1;
518 unsigned int pos = 0;
519 for(
unsigned int c = 0; c < opts->
fCategories.size(); ++c){
531 outfile <<
"Truth:PDG Vtx_x Vtx_y Vtx_Z " 532 <<
"Nu_E CCNC Lepton_E InteractionType ";
534 outfile <<
"comments" << std::endl;
double E(const int i=0) const
std::vector< unsigned int > fFieldsPerCategory
names of the various categories for the scan
TGTextButton * fNextButton
SubRunNumber_t subRun() const
static void Set(int which)
const art::Event * GetEvent() const
const simb::MCParticle & Nu() const
TGLayoutHints * fFieldFrameHints
void Record(std::string outfilename, const char *comments)
TGLayoutHints * fCatFrameLH
std::string fScanFileBase
true if MC information is to be included in scan output
std::vector< TGTextEntry * > fTextBoxes
Text box fields.
std::vector< TGCheckButton * > fCheckButtons
Check button fields.
std::string fOutFileName
Output file name for scan results.
Manage all things related to colors for the event display.
TGTextEntry * fCommentEntry
Singleton to hold the current art::Event for the event display.
std::vector< int > fRadioButtonIds
Ids for the radio buttons.
TGLayoutHints * fFrameHints
void BuildUserFields(TGCompositeFrame *f)
A window containing dialog boxes for handscans.
std::vector< std::string > fFieldLabels
types of the fields, ie TextEntry, Buttons, NumberEntry, etc
std::vector< std::string > fFieldTypes
number of fields in each category
int InteractionType() const
TGLayoutHints * fButtonBarHints
std::vector< TGNumberEntry * > fNumberBoxes
Number box fields.
TGLayoutHints * fUserFieldsHints
void HandleMouseWheel(Event_t *event)
TGLayoutHints * fButtonBarHintsL
const simb::MCParticle & Lepton() const
TGCanvas * fUserFieldsCanvas
Scrollable frame for all user defined fields.
static EventHolder * Instance()
std::vector< std::string > fCategories
base file name for scanning
Holds information about what action to take next.
TGHorizontalFrame * fButtonBar
Frame to hold the buttons at the bottom of the window.
double Vx(const int i=0) const
ScanFrame * fScanFrame
The frame containing the scanner check boxes etc.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
void BuildButtonBar(TGHorizontalFrame *f)
double Vz(const int i=0) const
TGTextButton * fPrevButton
EventNumber_t event() const
std::vector< TGGroupFrame * > fCatFrames
Mother for a category.
TGTextButton * fRcrdButton
std::vector< TGLabel * > fNumberLabels
Label for number fields.
TGCompositeFrame * fUserFieldsFrame
Event generator information.
TGLayoutHints * fButtonBarHintsR
std::vector< TGRadioButton * > fRadioButtons
Radio button fields.
double Vy(const int i=0) const
cet::coded_exception< error, detail::translate > exception
Event finding and building.
ScanFrame(TGCompositeFrame *f)
std::vector< TGHorizontalFrame * > fFieldFrames
Mother for each field.
std::vector< Handle< PROD > > getMany(SelectorBase const &selector=MatchAllSelector{}) const
TGLayoutHints * fButtonBarHintsC