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) <<
" ";
314 std::vector< art::Handle< std::vector<simb::MCTruth> > > mclist;
319 bool listok = (mclist.size()>0);
327 <<
"MC truth information requested for output file" 328 <<
" but no MCTruth objects found in event - " 329 <<
" put garbage numbers into the file";
331 << -999. <<
" " << -999. <<
" " << -999. <<
" " 332 << -999. <<
" " << -999. <<
" " << -999. <<
" " << -999.;
335 if ( listok && isnu==
false) {
337 <<
"Unknown particle source or truth information N/A" 338 <<
" put garbage numbers into the file";
340 << -999. <<
" " << -999. <<
" " << -999. <<
" " 341 << -999. <<
" " << -999. <<
" " << -999.<<
" " << -999.;
344 if (listok && isnu) {
349 << nu.
Nu().
Vx() <<
" " 350 << nu.
Nu().
Vy() <<
" " 351 << nu.
Nu().
Vz() <<
" " 352 << nu.
Nu().
E() <<
" " 360 <<
"MC truth information requested for output file" 361 <<
" but no MCTruth objects found in event - " 362 <<
" put garbage numbers into the file";
364 << -999. <<
" " << -999. <<
" " << -999. <<
" " 365 << -999. <<
" " << -999. <<
" " << -999.;
370 outfile <<
" " << comments << std::endl;
377 TGButton *b = (TGButton *)gTQSender;
378 int id = b->WidgetId();
394 fCommentLabel =
new TGLabel (f,
" Comments:");
395 fCommentEntry =
new TGTextEntry (f);
396 fPrevButton =
new TGTextButton(f,
" <<Prev ");
397 fNextButton =
new TGTextButton(f,
" Next>> ");
398 fRcrdButton =
new TGTextButton(f,
" Record ");
400 fPrevButton->Connect(
"Clicked()",
"evdb::ScanWindow",
this,
"Prev()");
401 fNextButton->Connect(
"Clicked()",
"evdb::ScanWindow",
this,
"Next()");
402 fRcrdButton->Connect(
"Clicked()",
"evdb::ScanWindow",
this,
"Rec()");
405 gClient->GetColorByName(
"pink", c);
406 fRcrdButton->ChangeBackground(c);
408 fButtonBarHintsL =
new TGLayoutHints(kLHintsBottom|kLHintsLeft,
410 fButtonBarHintsC =
new TGLayoutHints(kLHintsBottom|kLHintsLeft,
412 fButtonBarHintsR =
new TGLayoutHints(kLHintsBottom|kLHintsLeft,
414 f->AddFrame(fCommentLabel, fButtonBarHintsL);
415 f->AddFrame(fCommentEntry, fButtonBarHintsC);
416 f->AddFrame(fPrevButton, fButtonBarHintsC);
417 f->AddFrame(fNextButton, fButtonBarHintsC);
418 f->AddFrame(fRcrdButton, fButtonBarHintsR);
425 unsigned int kCanvasWidth = 390;
426 unsigned int kCanvasHeight = 500;
428 fUserFieldsCanvas =
new 429 TGCanvas(f, kCanvasWidth, kCanvasHeight);
431 fUserFieldsCanvasHints =
new TGLayoutHints(kLHintsExpandX|
433 f->AddFrame(fUserFieldsCanvas, fUserFieldsCanvasHints);
435 fScanFrame =
new ScanFrame(fUserFieldsCanvas->GetViewPort());
436 fUserFieldsCanvas->SetContainer(fScanFrame->GetFrame());
437 fScanFrame->GetFrame()->SetCleanup(kDeepCleanup);
443 TGTransientFrame(gClient->GetRoot(), gClient->GetRoot(), 50, 50),
444 fUserFieldsCanvas(0),
462 unsigned int kWidth = 5*50;
465 new TGCompositeFrame(
this, kWidth, kHeight);
467 new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX|kLHintsExpandY);
473 unsigned int kButtonBarWidth = 388;
474 unsigned int kButtonBarHeight = 30;
476 new TGHorizontalFrame(
this, kButtonBarHeight, kButtonBarWidth);
478 new TGLayoutHints(kLHintsBottom|kLHintsLeft);
488 this->Resize(kButtonBarWidth,kHeight+kButtonBarHeight);
489 this->MapSubwindows();
491 this->SetWindowName(
"Scan dialog window");
500 std::string user(gSystem->Getenv(
"USER"));
503 std::string time(cur.AsString(
"s"));
504 time.replace(time.find(
" "), 1,
"_");
513 outfile <<
"Run Subrun Event ";
519 unsigned int maxFields = 1;
520 unsigned int pos = 0;
521 for(
unsigned int c = 0; c < opts->
fCategories.size(); ++c){
533 outfile <<
"Truth:PDG Vtx_x Vtx_y Vtx_Z " 534 <<
"Nu_E CCNC Lepton_E InteractionType ";
536 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
static const unsigned int kHeight
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.
void getManyByType(std::vector< Handle< PROD >> &results) const
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
static const unsigned int kWidth
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.
TGLayoutHints * fButtonBarHintsC