--- eventviewer/ground/macros/EventViewer.c 2005/12/06 10:12:56 1.1.1.1 +++ eventviewer/ground/macros/EventViewer.c 2006/03/13 08:53:18 1.4 @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------- // -// EventViewer.c version 8.00 (2005-11-24) +// EventViewer.c version 9.03 (2006-03-10) // // Shows PAMELA events - Emiliano Mocchiutti // @@ -10,21 +10,33 @@ // // Standard use: // -// root[0] .L ShowEvent.c -// root[1] ShowEvent("/home/dati/filesFromYoda/DW_050112_00600/"); +// bash> EventViewer // // For further informations use: // -// root[3] ShowEvent(); +// EventViewer --help // // or // -// root[4] ShowEvent("help"); +// EventViewer --version // //------------------------------------------------------------------------------------------------------------------------------------------------------- // // Changelog: // +// 9.02 - 9.03 (2006-03-10): Figure still editable during searching, fixed. Fixed CPU consuming. +// +// 9.01 - 9.02 (2006-03-09): Now reads tracker software output from v3r02. Small bugs fixed (figure not editable now and complete text inside the GUI if there are only files with the same name). +// +// 9.00 - 9.01 (2006-03-03): Many bugs fixed and some correction in the behaviour in some cases (many thanks to Silvio for help in developing and debugging!). +// +// 8.02 - 9.00 (2006-02-17): Added the Graphic User Interface, fixed some old bugs, many new features (on fly load and unload files and selection files, stop searching +// while in selection mode, on fly level0/best level switching, fork the application/no text output flag,... ) +// +// 8.01 - 8.02 (2006-02-16): Don't show positions not used in determine the track. Shows S4 mip values in standard mode (not scientific notation). +// +// 8.00 - 8.01 (2006-01-10): Added tracker measured positions used to determine the track. +// // 7.03 - 8.00 (2005-11-24): many changes to compile the macro. The code is still very redundant and heavy but some bugs were fixed and now it should be more stable. // Do not require anymore the AcFunctions.h header, a clone has been written (aclev1class.h). // @@ -162,6 +174,18 @@ #include #include // +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// #include #include #include @@ -258,6 +282,758 @@ gSystem->Unload(libload.str().c_str()); #endif } + +// +// GUI +// + +class PAMevcontrol : public TGMainFrame { + + private: + TGHProgressBar *fHProg1; + TGTextEntry *fText2; + TGTextEntry *fText4; + TGComboBox *fCombo; + TCanvas *thefigure; + struct Variables *cvar; + + public: + PAMevcontrol(const TGWindow *p,UInt_t w,UInt_t h,struct Variables & var, TCanvas &figure); + virtual ~PAMevcontrol(); + void chktof(); + void chkac(); + void chktrk(); + void chkcalo(); + void chks4(); + void chknd(); + void chkinfo(); + void chknames(); + void chkpalette(); + void radiocolor(); + void radiobw(); + void radiotrack(); + void forcel0(); + void next(); + void prev(); + void stop(); + void SetFilename(); + void SetFilter(); + void jumpto(); + void radioevent(); + void radioprog(); + void saveas(); + void CompleteText(); + void Close(); + void increment(float val); + void DIALOG(Int_t ty, TString warn); + void clearselfi(); + void upgrnamfi(); + void Terminate(); + ClassDef(PAMevcontrol,0); +}; + +PAMevcontrol::PAMevcontrol(const TGWindow *p,UInt_t w,UInt_t h,Variables & var, TCanvas &figure) : TGMainFrame(p, w, h){ + // + SetCleanup(kDeepCleanup); + DontCallClose(); + Connect("CloseWindow()","PAMevcontrol",this,"Terminate()"); + // + cvar = &var; + thefigure = &figure; + // + TGCompositeFrame *cframe1 = new TGCompositeFrame(this, 280, 60, kVerticalFrame); + TGCompositeFrame *cframe2 = new TGCompositeFrame(this, 280, 60, kVerticalFrame); + TGCompositeFrame *cframe3 = new TGCompositeFrame(this, 280, 60, kVerticalFrame); + TGCompositeFrame *cframe4 = new TGCompositeFrame(this, 280, 60, kVerticalFrame); + TGGroupFrame *gf = new TGGroupFrame(cframe1, "Appearance"); + TGGroupFrame *inputf = new TGGroupFrame(cframe2, "Input"); + TGGroupFrame *jumpf = new TGGroupFrame(cframe3, "Jump to"); + TGGroupFrame *savef = new TGGroupFrame(cframe4, "Save figure as"); + // + TGHorizontalFrame *htexts = new TGHorizontalFrame(savef,400,800); + TGHorizontalFrame *htextsl = new TGHorizontalFrame(cframe4,400,800); + TGHorizontalFrame *htext = new TGHorizontalFrame(inputf,400,800); + TGHorizontalFrame *htext2 = new TGHorizontalFrame(inputf,400,800); + TGHorizontalFrame *htext3 = new TGHorizontalFrame(jumpf,400,800); + TGHorizontalFrame *htext4 = new TGHorizontalFrame(jumpf,400,80); + TGHorizontalFrame *hframe = new TGHorizontalFrame(this,400,800); + TGHorizontalFrame *hframe1 = new TGHorizontalFrame(gf, 280, 50); + TGHorizontalFrame *hframe2 = new TGHorizontalFrame(gf, 280, 40); + TGHorizontalFrame *hframe3 = new TGHorizontalFrame(gf, 280, 40); + TGHorizontalFrame *hframe4 = new TGHorizontalFrame(gf,280,10); + TGVerticalFrame *hframe5 = new TGVerticalFrame(hframe4, 280, 40); + TGHorizontalFrame *hfrprog = new TGHorizontalFrame(this,400,800); + // + TGTextEntry *fText = new TGTextEntry(htext, new TGTextBuffer(20),-1); + fText->SetText(cvar->thefilename.Data()); + TGTextButton *Load = new TGTextButton(htext,"Load"); + Load->Connect("Pressed()","TGTextEntry",fText,"ReturnPressed()"); + fText->Connect("ReturnPressed()", "PAMevcontrol", this,"SetFilename()"); + fText->Connect("TabPressed()", "PAMevcontrol", this,"CompleteText()"); + htext->AddFrame(fText, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY, 0, 5, 5, 5)); + htext->AddFrame(Load, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,0,5,5,5)); + inputf->AddFrame(new TGLabel(inputf, new TGHotString("Filename:"))); + inputf->AddFrame(htext, new TGLayoutHints(kLHintsExpandX)); + // + fText2 = new TGTextEntry(htext2, new TGTextBuffer(20),-1); + fText2->SetText(cvar->thefilter.Data()); + TGTextButton *Load2 = new TGTextButton(htext2,"Load"); + Load2->Connect("Clicked()","TGTextEntry",fText2,"ReturnPressed()"); + fText2->Connect("ReturnPressed()", "PAMevcontrol", this,"SetFilter()"); + fText2->Connect("TabPressed()", "PAMevcontrol", this,"CompleteText()"); + htext2->AddFrame(fText2, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY, 0, 5, 5, 5)); + htext2->AddFrame(Load2, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,0,5,5,5)); + inputf->AddFrame(new TGLabel(inputf, new TGHotString("Selection file:"))); + inputf->AddFrame(htext2, new TGLayoutHints(kLHintsExpandX)); + // + cframe2->AddFrame(inputf,new TGLayoutHints(kLHintsExpandX,5,5,5,5)); + // + TGCheckButton *fchktof = new TGCheckButton(hframe1, "TOF"); + fchktof->Connect("Clicked()","PAMevcontrol", this,"chktof()"); + if ( cvar->TOF ) fchktof->SetState(kButtonDown); + hframe1->AddFrame(fchktof, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,0,5,5,5)); + // + TGCheckButton *fchkac = new TGCheckButton(hframe1, "AC"); + fchkac->Connect("Clicked()","PAMevcontrol", this,"chkac()"); + if ( cvar->AC ) fchkac->SetState(kButtonDown); + hframe1->AddFrame(fchkac, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,5,25,5,5)); + // + TGCheckButton *fchktrk = new TGCheckButton(hframe1, "Tracker"); + fchktrk->Connect("Clicked()","PAMevcontrol",this,"chktrk()"); + if ( cvar->TRK ) fchktrk->SetState(kButtonDown); + hframe1->AddFrame(fchktrk, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,10,5,5,5)); + // + gf->AddFrame(hframe1, new TGLayoutHints(kLHintsExpandX)); + // + TGCheckButton *fchks4 = new TGCheckButton(hframe2, "S4"); + fchks4->Connect("Clicked()","PAMevcontrol",this,"chks4()"); + if ( cvar->S4 ) fchks4->SetState(kButtonDown); + hframe2->AddFrame(fchks4, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,0,15,5,5)); + // + TGCheckButton *fchknd = new TGCheckButton(hframe2, "ND"); + fchknd->Connect("Clicked()","PAMevcontrol",this,"chknd()"); + if ( cvar->ND ) fchknd->SetState(kButtonDown); + hframe2->AddFrame(fchknd, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,5,25,5,5)); + // + TGCheckButton *fchkcalo = new TGCheckButton(hframe2, "Calorimeter"); + fchkcalo->Connect("Clicked()","PAMevcontrol",this,"chkcalo()"); + if ( cvar->CALO ) fchkcalo->SetState(kButtonDown); + hframe2->AddFrame(fchkcalo, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,10,2,5,5)); + // + gf->AddFrame(hframe2, new TGLayoutHints(kLHintsExpandX)); + // + TGCheckButton *fchkinfo = new TGCheckButton(hframe3, "Infos"); + fchkinfo->Connect("Clicked()","PAMevcontrol",this,"chkinfo()"); + if ( cvar->INFOS ) fchkinfo->SetState(kButtonDown); + hframe3->AddFrame(fchkinfo, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,0,5,5,5)); + // + TGCheckButton *fchknames = new TGCheckButton(hframe3, "Names"); + fchknames->Connect("Clicked()","PAMevcontrol",this,"chknames()"); + if ( cvar->VINFOS ) fchknames->SetState(kButtonDown); + hframe3->AddFrame(fchknames, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,5,5,5,5)); + TGCheckButton *fchkpalette = new TGCheckButton(hframe3, "Palette"); + fchkpalette->Connect("Clicked()","PAMevcontrol",this,"chkpalette()"); + if ( cvar->PALETTE) fchkpalette->SetState(kButtonDown); + hframe3->AddFrame(fchkpalette, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,10,5,5,5)); + gf->AddFrame(hframe3, new TGLayoutHints(kLHintsExpandX)); + // + TGVButtonGroup *group = new TGVButtonGroup(hframe4); + TGRadioButton *bwc0; + TGRadioButton *bwc1; + bwc0 = new TGRadioButton(group, "Colour"); + bwc1 = new TGRadioButton(group, "B/W"); + if ( cvar->bw ){ + bwc1->SetState(kButtonDown); + } else { + bwc0->SetState(kButtonDown); + }; + bwc0->Connect("Pressed()", "PAMevcontrol",this,"radiocolor()"); + bwc1->Connect("Pressed()", "PAMevcontrol",this,"radiobw()"); + hframe4->AddFrame(group,new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,1,5,5,5)); + // + // + TGCheckButton *ftrks4 = new TGCheckButton(hframe5, "Track in S4/ND"); + ftrks4->Connect("Clicked()","PAMevcontrol",this,"radiotrack()"); + if ( cvar->tracknds4) ftrks4->SetState(kButtonDown); + hframe5->AddFrame(ftrks4, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,5,2,5,5)); + TGCheckButton *ffl0 = new TGCheckButton(hframe5, "Force LEVEL0"); + ffl0->Connect("Clicked()","PAMevcontrol",this,"forcel0()"); + if ( cvar->fl0 ) ffl0->SetState(kButtonDown); + hframe5->AddFrame(ffl0, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,5,2,5,5)); + // + hframe4->AddFrame(hframe5, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,10,5,5,5)); + gf->AddFrame(hframe4, new TGLayoutHints(kLHintsExpandX)); + // + cframe1->AddFrame(gf, new TGLayoutHints(kLHintsExpandX)); + // + TGHButtonGroup *jgroup = new TGHButtonGroup(htext4); + TGRadioButton *jbwc0; + TGRadioButton *jbwc1; + jbwc0 = new TGRadioButton(jgroup, "event "); + jbwc1 = new TGRadioButton(jgroup, "progressive"); + jbwc1->SetState(kButtonDown); + jbwc0->Connect("Pressed()", "PAMevcontrol",this,"radioevent()"); + jbwc1->Connect("Pressed()", "PAMevcontrol",this,"radioprog()"); + htext4->AddFrame(jgroup,new TGLayoutHints(kLHintsExpandX,1,1,0,0)); + // + TGTextEntry *fText3 = new TGTextEntry(htext3, new TGTextBuffer(6),-1); + TGTextButton *Jump = new TGTextButton(htext3,"go"); + Jump->Connect("Clicked()","TGTextEntry",fText3,"ReturnPressed()"); + fText3->Connect("ReturnPressed()", "PAMevcontrol", this,"jumpto()"); + htext3->AddFrame(new TGLabel(htext3, new TGHotString("number")), new TGLayoutHints(kLHintsExpandX,0,0,1,1)); + htext3->AddFrame(fText3, new TGLayoutHints(kLHintsExpandX, 0, 8, 0, 0)); + htext3->AddFrame(Jump, new TGLayoutHints(kLHintsExpandX,0,0,0,0)); + jumpf->AddFrame(htext4, new TGLayoutHints(kLHintsExpandX,0,0,1,1)); // + jumpf->AddFrame(htext3, new TGLayoutHints(kLHintsExpandX,0,0,0,1)); // + // + cframe3->AddFrame(jumpf,new TGLayoutHints(kLHintsExpandX,5,5,5,5)); + // + fText4 = new TGTextEntry(htexts, new TGTextBuffer(18),-1); + TGTextButton *save = new TGTextButton(htextsl,"save"); + save->Connect("Clicked()","TGTextEntry",fText4,"ReturnPressed()"); + fText4->Connect("ReturnPressed()", "PAMevcontrol", this,"saveas()"); + fText4->Connect("TabPressed()", "PAMevcontrol", this,"CompleteText()"); + htexts->AddFrame(fText4, new TGLayoutHints(kLHintsExpandX, 0, 8, 1, 1)); + // + fCombo = new TGComboBox(htexts, 98); + fCombo->AddEntry(".ps", 0); + fCombo->AddEntry(".eps", 1); + fCombo->AddEntry(".gif", 2); + fCombo->AddEntry(".jpg", 3); + fCombo->AddEntry(".tiff", 4); + fCombo->AddEntry(".xpm", 5); + fCombo->AddEntry(".pdf", 6); + fCombo->AddEntry(".xml", 7); + fCombo->AddEntry(".png", 8); + fCombo->AddEntry(".svg", 9); + fCombo->AddEntry(".root", 10); + fCombo->AddEntry(".C", 11); + fCombo->Select(0); + fCombo->Resize(50,23); + // htexts->AddFrame(fCombo, new TGLayoutHints(kLHintsCenterX | kLHintsTop | kLHintsLeft | kLHintsCenterY | kLHintsExpandX, 0, 8, 1, 1)); + htexts->AddFrame(fCombo, new TGLayoutHints(kLHintsExpandY | kLHintsRight, 2, 2, 2, 1)); + // + htextsl->AddFrame(save, new TGLayoutHints(kLHintsExpandX,0,0,2,1)); + savef->AddFrame(htexts, new TGLayoutHints(kLHintsExpandX,0,0,2,5)); + // savef->AddFrame(htextsl, new TGLayoutHints(kLHintsExpandX,5,2,5,2)); + savef->AddFrame(htextsl, new TGLayoutHints(kLHintsExpandX,8,0,5,2)); + // + cframe4->AddFrame(savef,new TGLayoutHints(kLHintsExpandX,5,5,5,5)); + // + fHProg1 = new TGHProgressBar(hfrprog, TGProgressBar::kFancy, 260); + fHProg1->SetBarColor("green"); + fHProg1->ShowPosition(); + hfrprog->AddFrame(fHProg1, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY | kLHintsExpandX,5,5,5,5)); + // + // + TGTextButton *prev = new TGTextButton(hframe,"< &Back"); + prev->Connect("Clicked()","PAMevcontrol",this,"prev()"); + hframe->AddFrame(prev, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4)); + // + TGTextButton *exit = new TGTextButton(hframe,"E&xit"); + exit->Connect("Clicked()","PAMevcontrol",this,"Terminate()"); + //,"gApplication->Terminate(0)"); + exit->SetToolTipText("Quit the event viewer"); + hframe->AddFrame(exit, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4)); + // + TGTextButton *stop = new TGTextButton(hframe,"&Stop"); + stop->Connect("Clicked()","PAMevcontrol",this,"stop()"); + hframe->AddFrame(stop, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4)); + // + TGTextButton *next = new TGTextButton(hframe,"&Next >"); + next->Connect("Clicked()","PAMevcontrol",this,"next()"); + hframe->AddFrame(next, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4)); + // + // + // AddFrame(htext, new TGLayoutHints(kLHintsExpandX,2,2,15,1)); + AddFrame(cframe2, new TGLayoutHints(kLHintsExpandX,1,1,1,1)); + AddFrame(cframe1, new TGLayoutHints(kLHintsExpandX,1,1,1,1)); + AddFrame(cframe3, new TGLayoutHints(kLHintsExpandX,1,1,1,1)); + AddFrame(cframe4, new TGLayoutHints(kLHintsExpandX,1,1,1,1)); + AddFrame(hfrprog, new TGLayoutHints(kLHintsExpandX,1,1,1,1)); + AddFrame(hframe, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,1,1,1,1)); + // Set a name to the main frame + SetWindowName("PAMELA Event Viewer control panel"); + // Map all subwindows of main frame + MapSubwindows(); + // Initialize the layout algorithm + Resize(GetDefaultSize()); + // Map main frame + MapWindow(); +} + +void PAMevcontrol::DIALOG(Int_t ty, TString warn){ + // + // ty = 0 -> INFO, ty = 1 -> WARNING, ty = 3 -> ERROR + // + Int_t retval; + TString title; + EMsgBoxIcon mb_icon = kMBIconStop; + if ( ty == 0 ){ + title="INFO"; + mb_icon = kMBIconAsterisk; + }; + if ( ty == 1 ){ + title="WARNING!"; + mb_icon = kMBIconExclamation; + }; + if ( ty == 2 ){ + title="ERROR!!"; + mb_icon = kMBIconStop; + }; + new TGMsgBox(gClient->GetRoot(), this, title.Data(), warn.Data(), mb_icon, kMBOk, &retval); +} + + +void PAMevcontrol::SetFilename() { + TGTextEntry *entry = (TGTextEntry*)gTQSender; + TString text = entry->GetText(); + cvar->thefilename=text.Data(); + cvar->nevents = 0; + cvar->firstevno = 0; + cvar->lastevno = 0; + cvar->restart = true; + cvar->waitforever = false; +} + +void PAMevcontrol::SetFilter() { + TGTextEntry *entry = (TGTextEntry*)gTQSender; + TString text = entry->GetText(); + cvar->thefilter=text.Data(); + cvar->i--; + cvar->selex = false; + cvar->nevents = 0; + cvar->firstevno = 0; + cvar->lastevno = 0; + cvar->refresh = true; +} + +void PAMevcontrol::CompleteText() { + TGTextEntry *entry = (TGTextEntry*)gTQSender; + TString text = entry->GetText(); + Int_t curspos = entry->GetCursorPosition(); + Int_t ncurspos = 0; + TString textrem; + stringcopy(textrem,text,curspos,text.Length()); + text.Resize(curspos); + if ( !strcmp(text.Data(),"") ) { + stringstream ntext; + ntext.str(""); + ntext << gSystem->ExpandPathName("$HOME"); + text = ntext.str().c_str(); + curspos=ntext.str().length(); + }; + char *test = gSystem->ExpandPathName(text.Data()); + const char *dir = gSystem->DirName(test); + const char *base = gSystem->BaseName(test); + TString lbase = base; + Int_t lenbase = lbase.Length(); + TSystemDirectory *tsd = new TSystemDirectory("",dir); + TSystemFile *file; + TList *lsmatch = new TList; + Int_t numf = 0; + Int_t numgo = 0; + Int_t charmac = 0; + TString tbase; + Int_t k = 0; + stringstream newtext; + TSystemFile *mfile; + TSystemFile nfile; + TList *lsf = new TList; + const char *ctbase; + if ( !tsd->GetListOfFiles() ){ + gVirtualX->Bell(0); + goto end; + }; + lsf = tsd->GetListOfFiles(); + file = (TSystemFile*)lsf->First(); + // + while( (TSystemFile*)lsf->After(file) ){ + numf++; + file = (TSystemFile*)lsf->After(file); + if ( !strncmp(file->GetName(),base,lenbase) ){ + numgo++; + lsmatch->AddLast(file); + const char *ctbase = file->GetName(); + tbase = ctbase; + charmac = tbase.Length(); + }; + }; + newtext.str(""); + if ( numgo > 0 ){ + mfile = (TSystemFile*)lsmatch->First(); + ctbase = mfile->GetName(); + while ( (!strcmp(ctbase,"..") || !strcmp(ctbase,".")) && (TSystemFile*)lsmatch->After(mfile) ) { + mfile = (TSystemFile*)lsmatch->After(mfile); + ctbase = mfile->GetName(); + }; + tbase = ctbase; + base = ctbase; + charmac = tbase.Length();; + while( (TSystemFile*)lsmatch->After(mfile) ){ + mfile = (TSystemFile*)lsmatch->After(mfile); + ctbase = mfile->GetName(); + while ( (!strcmp(ctbase,"..") || !strcmp(ctbase,".")) && (TSystemFile*)lsmatch->After(mfile) ) { + mfile = (TSystemFile*)lsmatch->After(mfile); + ctbase = mfile->GetName(); + }; + tbase = ctbase; + k = 0; + for ( Int_t i=lenbase; i<=tbase.Length(); i++){ + if ( !strncmp(tbase.Data(),base,i) && strcmp(tbase.Data(),base) ){ + k = i; + }; + }; + if ( k <= charmac){ + charmac = k; + }; + }; + gVirtualX->Bell(0); + }; + if ( !charmac ) { + gVirtualX->Bell(0); + goto end; + }; + tbase.Resize(charmac); + if ( !strcmp(dir,"") || !strcmp(dir,"/") ){ + newtext << "/" << tbase.Data(); + } else { + newtext << dir << "/" << tbase.Data(); + }; + nfile = TSystemFile(tbase.Data(),dir); + if ( nfile.IsDirectory() && numgo == 1 ) newtext << "/"; + ncurspos = newtext.str().length(); + if ( textrem.Length() ) newtext << textrem.Data(); + entry->SetText(newtext.str().c_str()); + entry->SetCursorPosition(ncurspos); + end: + lsf->Clear(); + lsmatch->Clear(); +} + +void PAMevcontrol::saveas() { + TString text = fText4->GetText(); + Int_t sel=fCombo->GetSelected(); + TString ty; + switch (sel){ + case (0): + ty = ".ps"; + break; + case (1): + ty = ".eps"; + break; + case (2): + ty = ".gif"; + break; + case (3): + ty = ".jpg"; + break; + case (4): + ty = ".tiff"; + break; + case (5): + ty = ".xpm"; + break; + case (6): + ty = ".pdf"; + break; + case (7): + ty = ".xml"; + break; + case (8): + ty = ".png"; + break; + case (9): + ty = ".svg"; + break; + case (10): + ty = ".root"; + break; + case (11): + ty = ".C"; + break; + }; + if ( sel == 0 ) ty = ".ps"; + stringstream name; + if ( strcmp(text.Data(),"") ){ + name.str(""); + name << text.Data(); + name << ty.Data(); + thefigure->SaveAs(name.str().c_str()); + name.str(""); + name << " Saved as "; + name << text.Data(); + name << ty.Data(); + DIALOG(0,name.str().c_str()); + printf(" Saved as %s%s \n",text.Data(),ty.Data()); + }; +} + +void PAMevcontrol::increment(float val) { + fHProg1->SetPosition(val); + fHProg1->DoRedraw(); + gSystem->ProcessEvents(); +} + +void PAMevcontrol::forcel0() { + if ( cvar->fl0 ) { + cvar->fl0 = false; + } else { + cvar->fl0 = true; + }; + cvar->alrforc = false; + cvar->i--; + cvar->nevents = 0; + cvar->firstevno = 0; + cvar->lastevno = 0; + cvar->refresh = true; +} + +void PAMevcontrol::clearselfi(){ + fText2->SetText(""); +} + +void PAMevcontrol::upgrnamfi(){ + fText4->SetText(cvar->svas.Data()); + fText4->SetCursorPosition(fText4->GetMaxLength()); +} + +void PAMevcontrol::jumpto() { + TGTextEntry *entry = (TGTextEntry*)gTQSender; + TString text = entry->GetText(); + Int_t j; + j = atoi(text.Data()); + if ( cvar->jumprog ){ + if ( j < 1 || j > cvar->nevents ) { + printf("\n You can choose between 1 and %i \n",(int)cvar->nevents); + stringstream warning; + warning.str(""); + warning << "You can choose between 1 and "; + warning << (int)cvar->nevents; + DIALOG(1,warning.str().c_str()); + } else { + stringstream warning; + warning.str(""); + warning << "Jumping to progressive number "; + warning << j; + DIALOG(0,warning.str().c_str()); + printf("\n Jumping to progressive number %i\n\n",j); + cvar->i = j-2; + cvar->goon = true; + }; + } else { + if ( j < cvar->firstevno || j > cvar->lastevno ) { + printf("\n You can choose between %i and %i \n",cvar->firstevno,cvar->lastevno); + stringstream warning; + warning.str(""); + warning << "You can choose between "; + warning << cvar->firstevno; + warning << " and "; + warning << cvar->lastevno; + DIALOG(1,warning.str().c_str()); + } else { + stringstream warning; + warning.str(""); + warning << "Jumping to event number "; + warning << j; + DIALOG(0,warning.str().c_str()); + printf("\n Jumping to event number %i\n\n",j); + cvar->jumpto = j; + cvar->jumpen = true; + cvar->goon = true; + }; + }; + entry->SetText(""); +} + +void PAMevcontrol::radioevent() { + cvar->jumprog = false; +} + +void PAMevcontrol::radioprog() { + cvar->jumprog = true; +} + +void PAMevcontrol::radiocolor() { + if ( !cvar->goon ){ + if ( cvar->bw ) { + cvar->bw = 0; + cvar->i--; + cvar->goon = true; + }; + }; +} + +void PAMevcontrol::radiobw() { + if ( !cvar->goon ){ + if ( !cvar->bw ) { + cvar->bw = 1; + cvar->i--; + cvar->goon = true; + }; + }; +} + +void PAMevcontrol::radiotrack() { + if ( cvar->tracknds4 ) { + cvar->tracknds4 = 0; + } else { + cvar->tracknds4 = 1; + }; + cvar->i--; + cvar->goon = true; +} + +void PAMevcontrol::chktof() { + if ( cvar->TOF ) { + cvar->TOF = 0; + } else { + cvar->TOF = 1; + }; + cvar->i--; + cvar->nevents = 0; + cvar->firstevno = 0; + cvar->lastevno = 0; + cvar->refresh = true; +} + +void PAMevcontrol::chkac() { + if ( cvar->AC ) { + cvar->AC = 0; + } else { + cvar->AC = 1; + }; + cvar->i--; + cvar->nevents = 0; + cvar->firstevno = 0; + cvar->lastevno = 0; + cvar->refresh = true; +} + +void PAMevcontrol::chktrk() { + if ( cvar->TRK ) { + cvar->TRK = 0; + } else { + cvar->TRK = 1; + }; + cvar->i--; + cvar->nevents = 0; + cvar->firstevno = 0; + cvar->lastevno = 0; + cvar->refresh = true; +} + +void PAMevcontrol::chkcalo() { + if ( cvar->CALO ) { + cvar->CALO = 0; + } else { + cvar->CALO = 1; + }; + cvar->i--; + cvar->nevents = 0; + cvar->firstevno = 0; + cvar->lastevno = 0; + cvar->refresh = true; +} + +void PAMevcontrol::chks4() { + if ( cvar->S4 ) { + cvar->S4 = 0; + } else { + cvar->S4 = 1; + }; + cvar->i--; + cvar->nevents = 0; + cvar->firstevno = 0; + cvar->lastevno = 0; + cvar->refresh = true; +} + +void PAMevcontrol::chknd() { + if ( cvar->ND ) { + cvar->ND = 0; + } else { + cvar->ND = 1; + }; + cvar->i--; + cvar->nevents = 0; + cvar->firstevno = 0; + cvar->lastevno = 0; + cvar->refresh = true; +} + +void PAMevcontrol::chkinfo() { + if ( cvar->INFOS ) { + cvar->INFOS = 0; + } else { + cvar->INFOS = 1; + }; + cvar->i--; + cvar->goon = true; +} + +void PAMevcontrol::chknames() { + if ( cvar->VINFOS ) { + cvar->VINFOS = 0; + } else { + cvar->VINFOS = 1; + }; + cvar->i--; + cvar->goon = true; +} + +void PAMevcontrol::chkpalette() { + if ( cvar->PALETTE ) { + cvar->PALETTE = 0; + } else { + cvar->PALETTE = 1; + }; + cvar->i--; + cvar->goon = true; +} + +void PAMevcontrol::next() { + if ( cvar->i == cvar->nevents-1 ) { + printf("This is the last event, you can't go forward! \n"); + DIALOG(1,"This is the last event!"); + } else { + cvar->goon = true; + cvar->doflag = 1; + }; +} + +void PAMevcontrol::stop() { + DIALOG(1,"Stop searching"); + cvar->doflag = 3; +} + +void PAMevcontrol::prev() { + if ( cvar->i > 0 ) { + printf("WARNING: going backward!\n\n"); + cvar->doflag = 2; + cvar->goon = true; + } else { + printf("This is the first event, you can't go backward! \n"); + DIALOG(1,"This is the first event!"); + }; +} + +void PAMevcontrol::Close() { + Cleanup(); + CloseWindow(); +} + +void PAMevcontrol::Terminate() { + Close(); + gApplication->Terminate(0); +} + +PAMevcontrol::~PAMevcontrol() { + // Clean up used widgets: frames, buttons, layouthints + Cleanup(); + delete this; +} + //********************************************************************************** // LEVEL0 SUBROUTINES // //********************************************************************************** @@ -373,7 +1149,12 @@ gDirectory->Delete(yevent.str().c_str()); TH2F *Xview = new TH2F(xevent.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5); TH2F *Yview = new TH2F(yevent.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5); - Int_t colo = 38; + Int_t colo; + if ( var.bw ){ + colo = 17; + } else { + colo = 38; + }; Xview->SetFillColor(colo); Yview->SetFillColor(colo); if ( l == 0 ) { @@ -398,7 +1179,7 @@ } void ShowND(Int_t evno, TTree *otr, Variables & var){ - Int_t tmpSize; + Int_t tmpSize; Int_t yUpperTrig = 0; Int_t yUpperBk = 0; Int_t yBottomBk = 0; @@ -786,8 +1567,8 @@ }; // // Draw crosses - // - if ( ncro ) { + // + if ( ncro && var.AC ) { trplv->cd(); trplv->Range(0.,0.,2076.,3100.); for ( Int_t i = 0; instrip; } -void ShowTRKL1(Int_t evno, TTree *ttr1, Variables & var){ +void ShowTRKL1(Int_t evno, TTree *ttr1, Variables & var, PAMevcontrol *pamgui){ // Int_t syncro = 1; Int_t itr = evno; @@ -2956,6 +3737,7 @@ settrklev1(ttr1,trk); if ( itr >= trnevents ){ printf(" WARNING: no more tracker level1 data.\n"); + pamgui->DIALOG(1," No more tracker level1 data "); nodata = 1; goto goon; }; @@ -2966,27 +3748,36 @@ if ( pktnum != ev2.pkt_num1 || obt != ev2.obt1 ){ if ( pktnum > ev2.pkt_num1 || obt > ev2.obt1 ){ itr++; - if ( syncro ) printf(" WARNING: lost sync! try to recover... \n"); + if ( syncro ){ + printf(" WARNING: lost sync! try to recover... \n"); + pamgui->DIALOG(1," Lost sync! try to recover "); + }; syncro = 0; goto trkcalosync; }; if ( pktnum < ev2.pkt_num1 || obt < ev2.obt1 ){ printf(" WARNING: no tracker level2 data. \n"); + pamgui->DIALOG(1," No more tracker level2 data "); nodata = 1; goto goon; }; }; // - if ( !syncro ) printf(" ...synchronization recovered! \n"); + if ( !syncro ) { + printf(" ...synchronization recovered! \n"); + pamgui->DIALOG(0," Synchronization recovered! "); + }; syncro = 1; // goon: struct Trklev1 ev; ev.good1 = (Bool_t)ev2.good1; ev.nev1 = ev2.nev1; + ev.whic_calib1 = ev2.whic_calib1; + ev.swcode1 = ev2.swcode1; ev.pkt_type1 = ev2.pkt_type1; ev.pkt_num1 = ev2.pkt_num1; ev.obt1 = ev2.obt1; - ev.which_calib1 = ev2.which_calib1; + ev.cpu_crc1 = (Bool_t)ev2.cpu_crc1; ev.nclstr1 = ev2.nclstr1; ev.totcllength = ev2.totcllength; for ( Int_t ii = 0 ; ii<8500; ii++){ @@ -3002,6 +3793,7 @@ ev.indmax[ii] = (Int_t)ev2.indmax[ii]; }; for ( Int_t ii = 0 ; ii<12 ; ii++){ + ev.crc1[ii] = ev2.crc1[ii]; for ( Int_t ij = 0 ; ij<24 ; ij++){ ev.cnev[ij][ii] = ev2.cnev[ii][ij]; }; @@ -3152,7 +3944,7 @@ linea = new TLine(-7.05,10.,7.05,10.); linea1y = new TLine(0.,10.,0.,30.); }; - linea->SetLineWidth(4); + linea->SetLineWidth(2); linea->SetLineColor(linecol); linea->Draw(); if ( l%2 ) { @@ -3292,33 +4084,35 @@ // // Draw crosses // - trplv->cd(); - trplv->Range(-7.05,-8.1,7.05,8.1); - for ( Int_t i = 0; i<6; i++){ - if ( mask[i] ){ - // - Float_t cdx = (0.55/mag[i])*var.sfx; - Float_t cdy = (0.55/mag[i])*var.sfy; - Float_t lwx = (0.019)*var.sfy; - Float_t lwy = (0.019)*var.sfx; - // - linea = new TLine(yh1[i]-lwx/2.,xh[i]-cdy,yh1[i]-lwx/2.,xh[i]+cdy); - linea->SetLineWidth((int)lwx); - linea->SetLineColor(sigcol1); - linea->Draw(); - linea = new TLine(yh1[i]-cdx,xh[i]-lwy/2.,yh1[i]+cdx,xh[i]-lwy/2.); - linea->SetLineWidth((int)lwy); - linea->SetLineColor(sigcol1); - linea->Draw(); - // - linea = new TLine(yh2[i]-lwx/2.,xh[i]-cdy,yh2[i]-lwx/2.,xh[i]+cdy); - linea->SetLineWidth((int)lwx); - linea->SetLineColor(sigcol2); - linea->Draw(); - linea = new TLine(yh2[i]-cdy,xh[i]-lwy/2.,yh2[i]+cdx,xh[i]-lwy/2.); - linea->SetLineWidth((int)lwy); - linea->SetLineColor(sigcol2); - linea->Draw(); + if ( var.AC ) { + trplv->cd(); + trplv->Range(-7.05,-8.1,7.05,8.1); + for ( Int_t i = 0; i<6; i++){ + if ( mask[i] ){ + // + Float_t cdx = (0.55/mag[i])*var.sfx; + Float_t cdy = (0.55/mag[i])*var.sfy; + Float_t lwx = (0.019)*var.sfy; + Float_t lwy = (0.019)*var.sfx; + // + linea = new TLine(yh1[i]-lwx/2.,xh[i]-cdy,yh1[i]-lwx/2.,xh[i]+cdy); + linea->SetLineWidth((int)lwx); + linea->SetLineColor(sigcol1); + linea->Draw(); + linea = new TLine(yh1[i]-cdx,xh[i]-lwy/2.,yh1[i]+cdx,xh[i]-lwy/2.); + linea->SetLineWidth((int)lwy); + linea->SetLineColor(sigcol1); + linea->Draw(); + // + linea = new TLine(yh2[i]-lwx/2.,xh[i]-cdy,yh2[i]-lwx/2.,xh[i]+cdy); + linea->SetLineWidth((int)lwx); + linea->SetLineColor(sigcol2); + linea->Draw(); + linea = new TLine(yh2[i]-cdy,xh[i]-lwy/2.,yh2[i]+cdx,xh[i]-lwy/2.); + linea->SetLineWidth((int)lwy); + linea->SetLineColor(sigcol2); + linea->Draw(); + }; }; }; } @@ -4004,7 +4798,7 @@ // } -void ShowTOFL1(Int_t j, TTree *toftr, Variables & var){ +void ShowTOFL1(Int_t j, TTree *toftr, Variables & var, PAMevcontrol *pamgui){ // for (Int_t i=0 ; i<5; i++){ var.beta[i] = 0.; @@ -4020,25 +4814,34 @@ Int_t obt = 0; trkcalosync: if ( itr >= trnevents ){ printf(" WARNING: no more tof level1 data.\n"); + pamgui->DIALOG(1," No more tof level1 data "); return; + } else { + if ( !var.nosig ) toftr->GetEntry(itr); }; - if ( !var.nosig ) toftr->GetEntry(itr); pktnum = var.headc; obt = var.etime; if ( pktnum != ntof.pkt_num || obt != ntof.obt ){ if ( pktnum > ntof.pkt_num || obt > ntof.obt ){ itr++; - if ( syncro ) printf(" WARNING: lost sync! try to recover... \n"); + if ( syncro ){ + printf(" WARNING: lost sync! try to recover... \n"); + pamgui->DIALOG(1," Lost sync! try to recover "); + }; syncro = 0; goto trkcalosync; }; if ( pktnum < ntof.pkt_num || obt < ntof.obt ){ printf(" WARNING: no tof level1 data. \n"); + pamgui->DIALOG(1," No more tof level1 data "); return; }; }; // - if ( !syncro ) printf(" ...synchronization recovered! \n"); + if ( !syncro ){ + printf(" ...synchronization recovered! \n"); + pamgui->DIALOG(0," Synchronization recovered! "); + }; syncro = 1; // if ( !var.nosig ) { @@ -4635,7 +5438,7 @@ // LEVEL2 SUBROUTINES // //********************************************************************************** -void ShowTRACK(Int_t evno, TTree *ttr, Variables & var){ +void ShowTRACK(Int_t evno, TTree *ttr, Variables & var, PAMevcontrol *pamgui){ // var.rig = 0.; var.chi2 = 0.; @@ -4650,6 +5453,7 @@ Int_t obt = 0; trkcalosync: if ( itr >= trnevents ){ printf(" WARNING: no more tracker level2 data.\n"); + pamgui->DIALOG(1," No more tracker level2 data "); return; }; if ( !var.nosig ) ttr->GetEntry(itr); @@ -4658,17 +5462,24 @@ if ( pktnum != trk.pkt_num || obt != trk.obt ){ if ( pktnum > trk.pkt_num || obt > trk.obt ){ itr++; - if ( syncro ) printf(" WARNING: lost sync! try to recover... \n"); + if ( syncro ) { + printf(" WARNING: lost sync! try to recover... \n"); + pamgui->DIALOG(1," Lost sync! try to recover "); + }; syncro = 0; goto trkcalosync; }; if ( pktnum < trk.pkt_num || obt < trk.obt ){ printf(" WARNING: no tracker level2 data. \n"); + pamgui->DIALOG(1," No more tracker level2 data "); return; }; }; // - if ( !syncro ) printf(" ...synchronization recovered! \n"); + if ( !syncro ){ + printf(" ...synchronization recovered! \n"); + pamgui->DIALOG(0," Synchronization recovered! "); + }; // if ( trk.ntrk > 0 ){ Int_t l = 0; @@ -4802,17 +5613,53 @@ // // Plane View // - TPolyLine *trackp1 = new TPolyLine(50,ptx1,pty1); - trackp1->SetLineColor(trcol); - trackp1->SetLineWidth(1); - trackp1->Draw(); - //printf("sto stapando trk ntrk %i image %i trcol %i \n",trk.ntrk,trk.image[l],trcol); - TPolyLine *trackp2 = new TPolyLine(50,ptx2,pty2); - trackp2->SetLineColor(trcol); - trackp2->SetLineWidth(1); - trackp2->SetLineStyle(3); - trackp2->Draw(); + if ( var.AC ){ + TPolyLine *trackp1 = new TPolyLine(50,ptx1,pty1); + trackp1->SetLineColor(trcol); + trackp1->SetLineWidth(1); + trackp1->Draw(); + TPolyLine *trackp2 = new TPolyLine(50,ptx2,pty2); + trackp2->SetLineColor(trcol); + trackp2->SetLineWidth(1); + trackp2->SetLineStyle(3); + trackp2->Draw(); + }; + // + // Dots on measured points + // + TEllipse *elli; + Float_t x; + Float_t y; + Float_t z1; + Float_t z2; + Int_t dcol; + if ( var.bw ){ + dcol = 12; + } else { + dcol = 2; + }; + for (Int_t g = 0; g<6; g++){ + if ( trk.xgood[l][g] ) { + x = trk.xm[l][g]*var.sfx/100. + var.xxvc; + z1 = (trk.zm[l][g]+11.2)*var.sfy/100. + var.yxvc; + elli = new TEllipse(x,z1,0.004,0.004,0.,-180.); + elli->SetFillStyle(1001); + elli->SetFillColor(dcol); + elli->Draw(); + }; + if ( trk.ygood[l][g] ) { + y = trk.ym[l][g]*var.sfx/100. + var.xyvc; + z2 = (trk.zm[l][g]+11.2)*var.sfy/100. + var.yyvc; + elli = new TEllipse(y,z2,0.004,0.004,0.,-180.); + elli->SetFillStyle(1001); + elli->SetFillColor(dcol); + elli->Draw(); + }; + }; + // + // } else { + pamgui->DIALOG(1," Failed in determining the track! "); printf(" WARNING: failed in determining the track! \n"); }; l++; @@ -5074,10 +5921,14 @@ void ShowPalette(Int_t bw){ - Float_t xp = 0.33; + Float_t xp = 0.40; Float_t yp = 0.02; - Float_t xw = 0.35; + Float_t xw = 0.2325; Float_t yh = 0.19; + // Float_t xp = 0.33; + //Float_t yp = 0.02; + //Float_t xw = 0.35; + //Float_t yh = 0.19; Double_t xx[5] = {xp, xp+xw, xp+xw, xp, xp}; Double_t yy[5] = {yp, yp, yp+yh, yp+yh, yp}; TPolyLine *fpale = new TPolyLine(5,xx,yy); @@ -5088,14 +5939,17 @@ txt->SetTextSize(0.01); txt->DrawLatex(xp+0.005,yp+yh-0.015,"PALETTE"); txt->DrawLatex(xp+0.005,yp+yh-0.04,"TOF, CALO, S4 [MIP]:"); - Float_t xwc = (xp+0.01)/6.; + // Float_t xwc = (xp+0.01)/6.; + Float_t xwc = (xw-0.01)/6.; + Float_t axwc = xwc+0.02; Float_t yhc = 0.03; Int_t colo = 0; Float_t yc = 0.135; TPolyLine *fc1[6]; if ( bw ){ for ( Int_t j=0; j<6; j++){ - Float_t xc = 0.335+(j*xwc); + // Float_t xc = 0.335+(j*xwc); + Float_t xc = 0.005+xp+(j*xwc); Double_t xx[5] = {xc, xc+xwc, xc+xwc, xc, xc}; Double_t yy[5] = {yc, yc, yc+yhc, yc+yhc, yc}; fc1[j] = new TPolyLine(5,xx,yy); @@ -5146,7 +6000,7 @@ Float_t yc = 0.08; TPolyLine *fc2[6]; for ( Int_t j=0; j<6; j++){ - Float_t xc = 0.335+(j*xwc); + Float_t xc = 0.005+xp+(j*xwc); Double_t xx[5] = {xc, xc+xwc, xc+xwc, xc, xc}; Double_t yy[5] = {yc, yc, yc+yhc, yc+yhc, yc}; fc2[j] = new TPolyLine(5,xx,yy); @@ -5197,8 +6051,8 @@ yc = 0.025; TPolyLine *fc3[3]; for ( Int_t j=0; j<3; j++){ - Float_t xc = 0.335+(j*xwc); - Double_t xx[5] = {xc, xc+xwc, xc+xwc, xc, xc}; + Float_t xc = 0.005+xp+(j*axwc); + Double_t xx[5] = {xc, xc+axwc, xc+axwc, xc, xc}; Double_t yy[5] = {yc, yc, yc+yhc, yc+yhc, yc}; fc3[j] = new TPolyLine(5,xx,yy); fc3[j]->SetLineColor(1); @@ -5229,7 +6083,7 @@ }; } else { for ( Int_t j=0; j<6; j++){ - Float_t xc = 0.335+(j*xwc); + Float_t xc = 0.005+xp+(j*xwc); Double_t xx[5] = {xc, xc+xwc, xc+xwc, xc, xc}; Double_t yy[5] = {yc, yc, yc+yhc, yc+yhc, yc}; fc1[j] = new TPolyLine(5,xx,yy); @@ -5280,7 +6134,7 @@ Float_t yc = 0.08; TPolyLine *fc2[6]; for ( Int_t j=0; j<6; j++){ - Float_t xc = 0.335+(j*xwc); + Float_t xc = 0.005+xp+(j*xwc); Double_t xx[5] = {xc, xc+xwc, xc+xwc, xc, xc}; Double_t yy[5] = {yc, yc, yc+yhc, yc+yhc, yc}; fc2[j] = new TPolyLine(5,xx,yy); @@ -5331,8 +6185,8 @@ yc = 0.025; TPolyLine *fc3[3]; for ( Int_t j=0; j<3; j++){ - Float_t xc = 0.335+(j*xwc); - Double_t xx[5] = {xc, xc+xwc, xc+xwc, xc, xc}; + Float_t xc = 0.005+xp+(j*axwc); + Double_t xx[5] = {xc, xc+axwc, xc+axwc, xc, xc}; Double_t yy[5] = {yc, yc, yc+yhc, yc+yhc, yc}; fc3[j] = new TPolyLine(5,xx,yy); fc3[j]->SetLineColor(1); @@ -5394,45 +6248,16 @@ x1->Draw(); }; } -// -// -// -void ShowHelp(){ - char input[256]; - printf("\n USE:\n\n The only input needed is the path to the directory (\"filename\") created by YODA\n for the data file you want to analyze.\n Standard use:\n root[0] .L ShowEvent.c\n root[1] ShowEvent(\"/home/dati/filesFromYoda/DW_050112_00600/\");\n \n\n\n\n\n\n"); - printf("Press to continue\n"); - cin.getline(input,256); - printf(" FEATURES:\n\n ShowEvent(TString filename, Int_t fromevent = 0, Int_t toevent = 0,\n TString selfile = \"\", Int_t FORCELEVEL = -1,\n Int_t ctrlword = 509, Int_t BW=0, TString outDir = \"\",\n TString calcalibfile = \"\")\n Input variables\n * fromevent = the first event to be shown (0 means \"show all\")\n"); - printf(" * toevent = the last event to be shown (NB: if fromevent differs from zero\n and toevent is equal zero only one event will be shown,\n number \"fromevent\")\n\n\n\n"); - printf("Press to continue\n"); - cin.getline(input,256); - printf(" * ctrword is an integer which can be used as a mask to customize the figure:\n ctrword bit: 10 9 8 7 6 5 4 3 2 1 \n detector : special TOF AC TRK CALO S4 ND infos names legenda\n Examples:\n ctrword = 509 = 0111111101 : all detectors+infos are printed(DEFAULT)\n ctrword = 511 = 0111111111 : show all\n ctrword = 505 = 0111111001 : don't print infos on figure\n ctrword = 507 = 0111111011 : show detector names+legenda (no infos)\n ctrword = 8 = 0000001000 : show only ND\n ctrword = 1019 = 1111111011 : show all but infos without signals\n\n"); - printf("Press to continue\n"); - cin.getline(input,256); - printf("\n\n When the \"special\" bit is set NO SIGNAL will be shown in the detectors.\n It can be used to draw a draft of the PAMELA apparatus without any event.\n "); - printf(" * selfile = selection file. Can be used to select events.\n Default is \"\" that is no selection applied.\n"); - printf(" * FORCELEVEL = to force a certain level visualization.\n For the moment only level0 can be forced.\n"); - printf(" * BW = 0 flag to display black and white figures.\n Default is 0, colours, set it to 1 to have BW visualization.\n"); - printf(" * outDir = directory where to place figures (if you want to print them).\n Default is \"filename\".\n\n"); - printf("Press to continue\n"); - cin.getline(input,256); - printf(" * calcalibfile = the calorimeter needs a calibration to display events. If a\n calibration is not in the file you want to analylze put \n here the path to a directory created by YODA for a data \n file with calorimeter calibration. Default is \"filename\".\n"); - printf("\n\n For further informations read the README.ShowEvent file.\n"); - return; -} // // MAIN ROUTINE // void ShowEvent(TString filename="help", TString selfile="", Int_t ctrlword = 509, Int_t FORCELEV = -1, Int_t fromevent = 0, Int_t toevent = 0, TString outDir = ""){ - gROOT->GetListOfCanvases()->Delete(); - gDirectory->GetList()->Delete(); TString calcalibfile = ""; TString startingdir = gSystem->WorkingDirectory(); const char* startingdir2 = gSystem->WorkingDirectory(); TString path; stringcopy(path,startingdir2); - Int_t BW = 0; #if defined (__CINT__) emicheckLib(); const char *pamlib=gSystem->Getenv("PAM_LIB"); @@ -5456,127 +6281,319 @@ stringstream calfile; calfile.str(""); calfile << pam_calib << "/CaloADC2MIP.root"; + Int_t selection = 0; + Bool_t firsttime = true; + // + // + restart: + gROOT->GetListOfCanvases()->Delete(); + gDirectory->GetList()->Delete(); + // + struct Variables var; + Bool_t loadselfs = true; + Bool_t popup = false; + PAMevcontrol *pamgui = 0; + var.restart = false; + var.waitforever = false; + var.jumprog = true; + var.jumpen = false; + // Int_t njumpen = 0; struct Levels level; // const char *name= filename; if ( filename == "" || !strcmp(name,"help") ){ - ShowHelp(); - return; + // ShowHelp(); + // return; + var.waitforever = true; }; // + Float_t mip[2][22][96]; + Int_t okcalo = 0; + TTree *ctree = 0; + TFile *chfile; + CalorimeterCalibration *ccalo = 0; + Long64_t cnevents = 0; // + var.goon = false; + var.refresh = false; + var.fl0 = false; + + if ( FORCELEV == 0 ) var.fl0 = true; // - if ( FORCELEV != -1 ) printf("\n WARNING: FORCING LEVEL%i DATA \n\n",FORCELEV); + // Define some variables // - // LOAD SELECTION FILE + Int_t OBT = 0; + Int_t DOBT = 0; + Int_t ifout = 0; + Int_t OOBT = 0; // - Int_t selection = 0; + // here windows dimension (based on the computer screen size) and position and dimension of figures + // + Int_t xw, yw; + UInt_t ww, hw; + gVirtualX->GetWindowSize(gClient->GetRoot()->GetId(),xw,yw,ww,hw); + Float_t winx = (float)ww*0.80; + Float_t winy = (float)hw*0.80; // 95 + Float_t winrap = winx/winy; + TCanvas *figure = new TCanvas("PAMELA event viewer", "PAMELA event viewer",(int)winx,(int)winy); + // GetCanvas->SetBit(kNotEditable); + // + var.bw = 0; + // var.xxvc = 0.17; + var.xxvc = 0.20; + var.yxvc = 0.44; + // var.xyvc = 0.83; + var.xyvc = 0.815; + var.yyvc = 0.44; + // + var.sfx = 0.81/winrap; + var.sfy = 0.81; + // + //var.nds4 = 0.4; + var.nds4 = var.sfx; + var.xcat = 0.515; + //var.xcat = 0.56; + var.ycat = 0.74; + // + var.tracknds4 = 1; + // + var.thefilename = filename.Data(); + var.thefilter = selfile.Data(); + // + // book the canvas + // + TLatex *text=new TLatex(); + stringstream testo; + stringstream testo2; + stringstream testo3; + figure->Range(0.,0.,1.,1.); + gStyle->SetOptDate(0); + gStyle->SetOptStat(0); + gStyle->SetLabelSize(0); + gStyle->SetNdivisions(1,"X"); + gStyle->SetNdivisions(1,"Y"); + // + stringstream libload; + Int_t doflag = 1; + Int_t thefirst = 1; + Int_t trackdone1 = 0; + Int_t trackdone2 = 0; + Int_t seldone = 0; + Float_t headc = 0.; + Float_t headcold = 0.; + Int_t i = 0; + Int_t isOK = 0; + Int_t jumpto = 0; + struct Calib calib; + Int_t b[4]; + Int_t si = 0; + var.selex = false; + var.alrforc = false; + // + // from here to refresh + // + refresh: + // + selfile = var.thefilter.Data(); + if ( calcalibfile == "" ) calcalibfile = filename; + if ( outDir == "" ) outDir = filename; + // + if ( var.fl0 == true ) { + FORCELEV = 0; + } else { + if ( var.refresh ) FORCELEV = -1; + }; + // + // clear levels! + // + level.calo = -10; + level.calol2 = -10; + level.tof = -10; + level.track = -10; + level.track2 = -10; + level.s4 = -10; + level.ac = -10; + level.nd = -10; + // + TString fififile = getFilename(filename); + const char *file = fififile; + // + // + // + if ( !var.refresh ){ + var.SHOWDEC = 0; + var.TOF = 0; + var.AC = 0; + var.TRK = 0; + var.CALO = 0; + var.S4 = 0; + var.ND = 0; + var.INFOS = 0; + var.VINFOS = 0; + var.PALETTE = 0; + if ( ctrlword & (1<<0) ) { + var.PALETTE = 1; + printf("Show Palette\n"); + }; + if ( ctrlword & (1<<1) ) { + var.VINFOS = 1; + printf("Show Verbose Text Informations\n"); + }; + if ( ctrlword & (1<<2) ) { + var.INFOS = 1; + printf("Show Text Informations\n"); + }; + if ( ctrlword & (1<<3) ) { + var.ND = 1; + }; + if ( ctrlword & (1<<4) ) { + var.S4 = 1; + }; + if ( ctrlword & (1<<5) ) { + var.CALO = 1; + }; + if ( ctrlword & (1<<6) ) { + var.TRK = 1; + }; + if ( ctrlword & (1<<7) ) { + var.AC = 1; + }; + if ( ctrlword & (1<<8) ) { + var.TOF = 1; + }; + if ( ctrlword & (1<<9) ) { + var.SHOWDEC = 1; + fromevent = 1; + toevent = 1; + printf("\n ** WARNING! YOU HAVE CHOSEN TO SHOW ONLY DETECTORS AND NO SIGNALS! **\n\n"); + gSystem->Exec("sleep 5"); + }; + }; + // + // Pop up the GUI + // + if ( !popup ) { + pamgui = new PAMevcontrol(gClient->GetRoot(),400,800,var,*figure); + popup = true; + }; + if ( firsttime ){ + firsttime = false; + if ( filename == "" ) pamgui->DIALOG(0," Insert the filename and press load to start "); + }; + // + while( var.waitforever ) { + if ( !gROOT->GetListOfCanvases()->FindObject(figure) ) { + pamgui->Close(); + gSystem->ProcessEvents(); + gApplication->Terminate(0); + }; + gSystem->ProcessEvents(); + gSystem->Sleep(10); + }; + if ( var.restart ){ + filename = var.thefilename.Data(); + pamgui->Close(); + goto restart; + }; + // + // + // + if ( FORCELEV != -1 ) { + printf("\n WARNING: FORCING LEVEL%i DATA \n\n",FORCELEV); + if ( !var.alrforc ) { + pamgui->DIALOG(1," Forcing LEVEL0 data "); + var.alrforc = true; + }; + }; + // + // LOAD SELECTION FILE + // if ( selfile == "" ){ + if ( !var.selex && selection ) pamgui->DIALOG(0," Selection file unloaded "); + var.selex = true; selection = 0; +#if !defined (__CINT__) + if ( !var.refresh ) { + gROOT->Reset(); + stringstream paminc; + paminc.str(""); + const char *testinc = gSystem->Getenv("PAM_INC"); + if ( !testinc ) { + const char *pam_calib = pathtocalibration(); + paminc << pam_calib << "../include/"; + } else { + paminc << testinc; + }; + stringstream carica; + carica.str(""); + carica << paminc.str().c_str() << "/eventviewer.h"; + gROOT->LoadMacro(carica.str().c_str()); + }; +#endif } else { #if !defined (__CINT__) - // - // if running the compiled program we must load header files for the selection macros! - // - gROOT->Reset(); - stringstream paminc; - paminc.str(""); - const char *testinc = gSystem->Getenv("PAM_INC"); - if ( testinc == "" ){ + // + // if running the compiled program we must load header files for the selection macros! + // + // if ( !var.refresh ) { + if ( loadselfs ) { + loadselfs = false; + gROOT->Reset(); + stringstream paminc; + paminc.str(""); + const char *testinc = gSystem->Getenv("PAM_INC"); + if ( !testinc ){ const char *pam_calib = pathtocalibration(); paminc << pam_calib << "../include/"; - } else { + } else { paminc << testinc; + }; + stringstream carica; + carica.str(""); + carica << paminc.str().c_str() << "/eventviewer.h"; + gROOT->LoadMacro(carica.str().c_str()); + carica.str(""); + carica << paminc.str().c_str() << "/trklev1struct.h"; + gROOT->LoadMacro(carica.str().c_str()); + carica.str(""); + carica << paminc.str().c_str() << "/ctrkstruct.h"; + gROOT->LoadMacro(carica.str().c_str()); + carica.str(""); + carica << paminc.str().c_str() << "/ctrkinclude.h"; + gROOT->LoadMacro(carica.str().c_str()); + carica.str(""); + carica << paminc.str().c_str() << "/ctofstruct.h"; + gROOT->LoadMacro(carica.str().c_str()); + carica.str(""); + carica << paminc.str().c_str() << "/ctofinclude.h"; + gROOT->LoadMacro(carica.str().c_str()); }; - stringstream carica; - carica.str(""); - carica << paminc.str().c_str() << "/eventviewer.h"; - gROOT->LoadMacro(carica.str().c_str()); - carica.str(""); - carica << paminc.str().c_str() << "/trklev1struct.h"; - gROOT->LoadMacro(carica.str().c_str()); - carica.str(""); - carica << paminc.str().c_str() << "/ctrkstruct.h"; - gROOT->LoadMacro(carica.str().c_str()); - carica.str(""); - carica << paminc.str().c_str() << "/ctrkinclude.h"; - gROOT->LoadMacro(carica.str().c_str()); - carica.str(""); - carica << paminc.str().c_str() << "/ctofstruct.h"; - gROOT->LoadMacro(carica.str().c_str()); - carica.str(""); - carica << paminc.str().c_str() << "/ctofinclude.h"; - gROOT->LoadMacro(carica.str().c_str()); #endif // // load the selection macro // selection = gROOT->LoadMacro(selfile); if ( selection ){ + stringstream dialog; + dialog.str(""); + dialog << var.thefilter.Data(); + dialog << " : no such file!"; + pamgui->DIALOG(2,dialog.str().c_str()); printf("\n\n ERROR! cannot read the selection file you give me as input! \n"); selection = 0; printf("\n WARNING! no selection file loaded! \n\n"); + pamgui->DIALOG(1," No selection file loaded! "); + pamgui->clearselfi(); } else { printf("\n\n Selection file loaded \n\n The first event will be shown anyway. \n\n"); + if ( !var.selex ) pamgui->DIALOG(0," Selection file successfully loaded "); + var.selex = true; selection = 1; }; }; // + // LOAD FILES // - // LOAD FILES - // - Int_t SHOWDEC = 0; - Int_t TOF = 0; - Int_t AC = 0; - Int_t TRK = 0; - Int_t CALO = 0; - Int_t S4 = 0; - Int_t ND = 0; - Int_t INFOS = 0; - Int_t VINFOS = 0; - Int_t PALETTE = 0; - // - if ( ctrlword & (1<<0) ) { - PALETTE = 1; - printf("Show Palette\n"); - }; - if ( BW ) printf(" --> Black and White visualization! \n"); - if ( ctrlword & (1<<1) ) { - VINFOS = 1; - printf("Show Verbose Text Informations\n"); - }; - if ( ctrlword & (1<<2) ) { - INFOS = 1; - printf("Show Text Informations\n"); - }; - if ( ctrlword & (1<<3) ) { - ND = 1; - }; - if ( ctrlword & (1<<4) ) { - S4 = 1; - }; - if ( ctrlword & (1<<5) ) { - CALO = 1; - }; - if ( ctrlword & (1<<6) ) { - TRK = 1; - }; - if ( ctrlword & (1<<7) ) { - AC = 1; - }; - if ( ctrlword & (1<<8) ) { - TOF = 1; - }; - if ( ctrlword & (1<<9) ) { - SHOWDEC = 1; - fromevent = 1; - toevent = 1; - printf("\n ** WARNING! YOU HAVE CHOSEN TO SHOW ONLY DETECTORS AND NO SIGNALS! **\n\n"); - gSystem->Exec("sleep 5"); - }; - // - TString fififile = getFilename(filename); - const char *file = fififile; // Int_t trk1noev = 0; Int_t trk2noev = 0; @@ -5594,10 +6611,43 @@ TFile *tofFileL1 = 0; TTree *toftr = 0; // + // check if user has given as input a correct path + // + ifstream myfile; + stringstream hfile; + TString textslash; + Int_t minus = 0; + stringcopy(textslash,filename,filename.Length()-1,filename.Length()); + if ( !strcmp(textslash.Data(),"/") ){ + minus = 1; + } else { + minus = 0; + }; + TString textrem; + stringcopy(textrem,filename,filename.Length()-minus-15,filename.Length()-minus); + hfile.str(""); + hfile << filename.Data(); + hfile << "/Physics/"; + hfile << textrem.Data(); + hfile << ".Physics.Header.root"; + myfile.open(hfile.str().c_str()); + if ( !myfile ){ + printf("ERROR: no Header file, exiting...\n"); + hfile << " - No header file! "; + pamgui->DIALOG(2,hfile.str().c_str()); + var.waitforever = true; + goto refresh; + }; + myfile.close(); + // + // ok, open header file + // headerFile = emigetFile(filename, "Physics", "Header"); if ( !headerFile ){ printf("ERROR: no Header file, exiting...\n"); - return; + pamgui->DIALOG(2," No header file! "); + var.waitforever = true; + goto refresh; }; TTree *otr = (TTree*)headerFile->Get("Pscu"); printf("Get the Header informations\n"); @@ -5605,7 +6655,9 @@ triggerFile = emigetFile(filename, "Trigger"); if ( !triggerFile ){ printf("ERROR: no Trigger file, exiting...\n"); - return; + pamgui->DIALOG(2," No trigger file! "); + var.waitforever = true; + goto refresh; }; otr->AddFriend("Trigger", triggerFile); printf("Get the Trigger informations\n"); @@ -5620,89 +6672,98 @@ TTree *ctrk = 0; TFile *trackcalibFile2 = 0; TFile *trackerFile2b = 0; - if ( TRK ) { - if ( FORCELEV == 0 ){ - trackerFile2 = emigetFile(filename, "Tracker"); - if ( !trackerFile2 ){ - printf("WARNING: no Tracker file! \n"); - TRK = 0; - } else { - otr->AddFriend("Tracker", trackerFile2); - printf("Show the Tracker detector, LEVEL0 data \n"); - TRKLEV = 0; - }; - } else { - trackerFile = emigetFile(filename, "Physics.Level2", "Tracker"); + if ( var.TRK ) { + if ( FORCELEV == 0 ){ + trackerFile2 = emigetFile(filename, "Tracker"); + if ( !trackerFile2 ){ + printf("WARNING: no Tracker file! \n"); + pamgui->DIALOG(1," No tracker file! "); + var.TRK = 0; + } else { + otr->AddFriend("Tracker", trackerFile2); + printf("Show the Tracker detector, LEVEL0 data \n"); + TRKLEV = 0; + }; + } else { + trackerFile = emigetFile(filename, "Physics.Level2", "Tracker"); + if ( !trackerFile ){ + // + trackhead = emigetFile(filename, "CalibTrk1", "Header"); + ctrk = (TTree*)trackhead->Get("Pscu"); + // + trackerFile = emigetFile(filename, "Physics.Level1", "Tracker"); + trackcalibFile1 = emigetFile(filename, "CalibTrk1"); + trackcalibFile2 = emigetFile(filename, "CalibTrk2"); + // + if ( !trackerFile || !trackcalibFile1 || !trackcalibFile2 || !trackhead ){ + trackerFile = emigetFile(filename, "Tracker"); if ( !trackerFile ){ - // - trackhead = emigetFile(filename, "CalibTrk1", "Header"); - ctrk = (TTree*)trackhead->Get("Pscu"); - // - trackerFile = emigetFile(filename, "Physics.Level1", "Tracker"); - trackcalibFile1 = emigetFile(filename, "CalibTrk1"); - trackcalibFile2 = emigetFile(filename, "CalibTrk2"); - // - if ( !trackerFile || !trackcalibFile1 || !trackcalibFile2 || !trackhead ){ - trackerFile = emigetFile(filename, "Tracker"); - if ( !trackerFile ){ - printf("WARNING: no Tracker file! \n"); - TRK = 0; - } else { - otr->AddFriend("Tracker", trackerFile); - printf("Show the Tracker detector, LEVEL0 data \n"); - TRKLEV = 0; - }; - } else { - ttr1 = (TTree*)trackerFile->Get("TrkLevel1"); - ctrk->AddFriend("CalibTrk1", trackcalibFile1); - ctrk->AddFriend("CalibTrk2", trackcalibFile2); - printf("Show the Tracker detector, LEVEL1 data \n"); - TRKLEV = 1; - trk1noev = ttr1->GetEntries(); - }; + printf("WARNING: no Tracker file! \n"); + pamgui->DIALOG(1," No tracker file! "); + var.TRK = 0; } else { - ttr = (TTree*)trackerFile->Get("TrkLevel2"); - trk2noev = ttr->GetEntries(); - printf("Get the track informations (LEVEL2 Tracker data!)\n"); - STRACK = 1; - // - trackhead = emigetFile(filename, "CalibTrk2", "Header"); - ctrk = (TTree*)trackhead->Get("Pscu"); - // - trackerFile2b = emigetFile(filename, "Physics.Level1", "Tracker"); - trackcalibFile1 = emigetFile(filename, "CalibTrk1"); - trackcalibFile2 = emigetFile(filename, "CalibTrk2"); - // - if ( !trackerFile2b || !trackcalibFile1 || !trackcalibFile2 || !trackhead ){ - printf(" WARNING: no LEVEL1 Tracker data, load LEVEL0 data \n"); - trackerFile2b = emigetFile(filename, "Tracker"); - if ( !trackerFile2b ){ - printf("WARNING: no Tracker file! \n"); - TRK = 0; - } else { - otr->AddFriend("Tracker", trackerFile2b); - printf("Show the Tracker detector, LEVEL0 data \n"); - TRKLEV = 0; - }; - } else { - ttr1 = (TTree*)trackerFile2b->Get("TrkLevel1"); - ctrk->AddFriend("CalibTrk1", trackcalibFile1); - ctrk->AddFriend("CalibTrk2", trackcalibFile2); - printf("Show the Tracker detector, LEVEL1 data \n"); - TRKLEV = 1; - trk1noev = ttr1->GetEntries(); - }; - }; - }; + otr->AddFriend("Tracker", trackerFile); + printf("Show the Tracker detector, LEVEL0 data \n"); + TRKLEV = 0; + }; + } else { + ttr1 = (TTree*)trackerFile->Get("TrkLevel1"); + ctrk->AddFriend("CalibTrk1", trackcalibFile1); + ctrk->AddFriend("CalibTrk2", trackcalibFile2); + printf("Show the Tracker detector, LEVEL1 data \n"); + TRKLEV = 1; + trk1noev = ttr1->GetEntries(); + }; + } else { + ttr = (TTree*)trackerFile->Get("TrkLevel2"); + trk2noev = ttr->GetEntries(); + printf("Get the track informations (LEVEL2 Tracker data!)\n"); + STRACK = 1; + // + trackhead = emigetFile(filename, "CalibTrk2", "Header"); + ctrk = (TTree*)trackhead->Get("Pscu"); + // + trackerFile2b = emigetFile(filename, "Physics.Level1", "Tracker"); + trackcalibFile1 = emigetFile(filename, "CalibTrk1"); + trackcalibFile2 = emigetFile(filename, "CalibTrk2"); + // + if ( !trackerFile2b || !trackcalibFile1 || !trackcalibFile2 || !trackhead ){ + printf(" WARNING: no LEVEL1 Tracker data, load LEVEL0 data \n"); + trackerFile2b = emigetFile(filename, "Tracker"); + if ( !trackerFile2b ){ + printf("WARNING: no Tracker file! \n"); + pamgui->DIALOG(1," No tracker file! "); + var.TRK = 0; + } else { + otr->AddFriend("Tracker", trackerFile2b); + printf("Show the Tracker detector, LEVEL0 data \n"); + TRKLEV = 0; + }; + } else { + ttr1 = (TTree*)trackerFile2b->Get("TrkLevel1"); + ctrk->AddFriend("CalibTrk1", trackcalibFile1); + ctrk->AddFriend("CalibTrk2", trackcalibFile2); + printf("Show the Tracker detector, LEVEL1 data \n"); + TRKLEV = 1; + trk1noev = ttr1->GetEntries(); + }; + }; + }; + level.track = TRKLEV; + level.track2 = STRACK; + } else { + level.track = -10; + level.track2 = -10; }; // Int_t CALOLEV = 0; - if ( CALO ) { + if ( var.CALO ) { if ( FORCELEV == 0 ){ caloFile = emigetFile(filename, "Calorimeter"); if ( !caloFile ){ printf("WARNING: no calorimeter file! \n"); - CALO = 0; + pamgui->DIALOG(1," No calorimeter file! "); + var.CALO = 0; } else { otr->AddFriend("Calorimeter", caloFile); printf("Show the Calorimeter detector, LEVEL0 data \n"); @@ -5714,7 +6775,8 @@ caloFile = emigetFile(filename, "Calorimeter"); if ( !caloFile ){ printf("WARNING: no calorimeter file! \n"); - CALO = 0; + pamgui->DIALOG(1," No calorimeter file! "); + var.CALO = 0; } else { otr->AddFriend("Calorimeter", caloFile); printf("Show the Calorimeter detector, try to generate LEVEL1 data \n"); @@ -5726,25 +6788,35 @@ CALOLEV = 1; }; }; + level.calo = CALOLEV; + level.calol2 = -10; + } else { + level.calo = -10; + level.calol2 = -10; }; // - if ( ND ) { + if ( var.ND ) { neutronFile = emigetFile(filename, "Neutron"); if ( !neutronFile ){ printf("WARNING: no neutron detector file! \n"); - ND = 0; + pamgui->DIALOG(1," No neutron detector file! "); + var.ND = 0; } else { otr->AddFriend("Neutron", neutronFile); printf("Show the Neutron detector, LEVEL0 data \n"); }; + level.nd = 0; + } else { + level.nd = -10; }; // - if ( AC ) { + if ( var.AC ) { if ( FORCELEV == 0 ){ acFile = emigetFile(filename, "Anticounter"); if ( !acFile ){ printf("WARNING: no AC file! \n"); - AC = 0; + pamgui->DIALOG(1," No anticounters file! "); + var.AC = 0; } else { otr->AddFriend("Anticounter", acFile); printf("Show the Anticoincidence detector, LEVEL 0 data\n"); @@ -5756,7 +6828,8 @@ acFile = emigetFile(filename, "Anticounter"); if ( !acFile ){ printf("WARNING: no AC file! \n"); - AC = 0; + pamgui->DIALOG(1," No anticounters file! "); + var.AC = 0; } else { otr->AddFriend("Anticounter", acFile); printf("Show the Anticoincidence detector, LEVEL 0 data\n"); @@ -5768,13 +6841,17 @@ ACLEV = 1; }; }; + level.ac = ACLEV; + } else { + level.ac = -10; }; Int_t S4LEV = 0; - if ( S4 ) { + if ( var.S4 ) { s4File = emigetFile(filename, "S4"); if ( !s4File ){ printf("WARNING: no S4 file! \n"); - S4 = 0; + pamgui->DIALOG(1," No S4 file! "); + var.S4 = 0; } else { otr->AddFriend("S4", s4File); if ( FORCELEV != 0 ){ @@ -5785,18 +6862,22 @@ S4LEV = 0; }; }; + level.s4 = S4LEV; + } else { + level.s4 = -10; }; // Int_t TOFLEV = 0; - if ( TOF ) { + if ( var.TOF ) { if ( FORCELEV != 0 ){ tofFileL1 = emigetFile(filename, "Physics.Level1","TofTrigger"); if ( !tofFileL1 ){ tofFile = emigetFile(filename, "Tof"); if ( !tofFile ){ printf("WARNING: no TOF file! \n"); + pamgui->DIALOG(1," No TOF file! "); printf("Show the Time of Flight detector, LEVEL0 (trigger board) data\n"); - // TOF = 0; + // var.TOF = 0; TOFLEV = 0; } else { otr->AddFriend("Tof", tofFile); @@ -5813,6 +6894,9 @@ printf("Show the Time of Flight detector, LEVEL0 data\n"); TOFLEV = 0; }; + level.tof = TOFLEV; + } else { + level.tof = -10; }; // printf("\n"); @@ -5827,112 +6911,73 @@ if (nevents<=0) { headerFile->Close(); triggerFile->Close(); - if ( TRK ) trackerFile->Close(); - if ( CALO )caloFile->Close(); - if ( ND ) neutronFile->Close(); - if ( AC ) acFile->Close(); - if ( TOF ) tofFile->Close(); - if ( S4 ) s4File->Close(); + if ( var.TRK ) trackerFile->Close(); + if ( var.CALO )caloFile->Close(); + if ( var.ND ) neutronFile->Close(); + if ( var.AC ) acFile->Close(); + if ( var.TOF ) tofFile->Close(); + if ( var.S4 ) s4File->Close(); printf("The file is empty, exiting...\n"); - return; + pamgui->DIALOG(0," The file contains no physics data! "); + var.waitforever = true; + goto refresh; } // - // Define some variables - // - Int_t OBT = 0; - Int_t DOBT = 0; - Int_t ifout = 0; - Int_t OOBT = 0; - // - if ( calcalibfile == "" ) calcalibfile = filename; - if ( outDir == "" ) outDir = filename; - // - struct Variables var; - // - if ( SHOWDEC ){ + if ( var.SHOWDEC ){ var.nosig = 1; } else { var.nosig = 0; }; // - // here windows dimension (based on the computer screen size) and position and dimension of figures - // - Int_t xw, yw; - UInt_t ww, hw; - gVirtualX->GetWindowSize(gClient->GetRoot()->GetId(),xw,yw,ww,hw); - Float_t winx = (float)ww*0.95; - Float_t winy = (float)hw*0.95; - Float_t winrap = winx/winy; - var.bw = 0; - if ( BW ) var.bw = 1; - var.xxvc = 0.17; - var.yxvc = 0.44; - var.xyvc = 0.83; - var.yyvc = 0.44; - // - var.sfx = 0.82/winrap; - var.sfy = 0.82; - // - var.nds4 = 0.4; - //var.nds4 = 0.85/winrap; - var.xcat = 0.5; - var.ycat = 0.74; - // - var.tracknds4 = 1; - // // READ the CALORIMETER ADC to MIP conversion table (if trying to generate level1 data) // - Float_t mip[2][22][96]; - Int_t okcalo = 0; - TTree *ctree = 0; - TFile *chfile; - CalorimeterCalibration *ccalo = 0; - Long64_t cnevents = 0; - if ( !CALOLEV && CALO ){ + if ( !var.refresh ){ + if ( !CALOLEV && var.CALO ){ chfile = new TFile(calfile.str().c_str(),"READ","Calorimeter CALIBRATION data"); if ( chfile->IsZombie() ){ - printf(" WARNING: no calorimeter calibration file! \n Using 26 as conversion factor for all strips. \n"); - okcalo = 0; + printf(" WARNING: no calorimeter calibration file! \n Using 26 as conversion factor for all strips. \n"); + okcalo = 0; } else { - okcalo = 1; - ctree = (TTree*)chfile->Get("CaloADC"); - ctree->SetBranchAddress("Event", &ccalo); - // - cnevents = ctree->GetEntries(); - ctree->GetEntry(cnevents-1); + okcalo = 1; + ctree = (TTree*)chfile->Get("CaloADC"); + ctree->SetBranchAddress("Event", &ccalo); + // + cnevents = ctree->GetEntries(); + ctree->GetEntry(cnevents-1); }; // if ( okcalo ) { - for (Int_t m = 0; m < 2 ; m++ ){ - for (Int_t k = 0; k < 22; k++ ){ - for (Int_t l = 0; l < 96; l++ ){ - if ( (ccalo->fp[1][m][k][l] > 20. && ccalo->fp[1][m][k][l] < 32.) || ccalo->mask[m][k][l] == 1. ) { - if ( ccalo->mip[m][k][l] != 0. ){ - mip[m][k][l] = ccalo->mip[m][k][l]; - } else { - mip[m][k][l] = 26. ; - }; - } else { - mip[m][k][l] = 26. ; - }; - }; + for (Int_t m = 0; m < 2 ; m++ ){ + for (Int_t k = 0; k < 22; k++ ){ + for (Int_t l = 0; l < 96; l++ ){ + if ( (ccalo->fp[1][m][k][l] > 20. && ccalo->fp[1][m][k][l] < 32.) || ccalo->mask[m][k][l] == 1. ) { + if ( ccalo->mip[m][k][l] != 0. ){ + mip[m][k][l] = ccalo->mip[m][k][l]; + } else { + mip[m][k][l] = 26. ; + }; + } else { + mip[m][k][l] = 26. ; }; + }; }; + }; } else { - for (Int_t m = 0; m < 2 ; m++ ){ - for (Int_t k = 0; k < 22; k++ ){ + for (Int_t m = 0; m < 2 ; m++ ){ + for (Int_t k = 0; k < 22; k++ ){ for (Int_t l = 0; l < 96; l++ ){ - mip[m][k][l] = 26. ; + mip[m][k][l] = 26. ; }; }; - }; + }; }; chfile->Close(); + }; }; // // Check that given input are inside the boundary conditions // - if ( fromevent > toevent && toevent ){ + if ( fromevent > toevent && toevent ){ printf("It must be fromevent < toevent \n"); return; }; @@ -5958,31 +7003,6 @@ }; }; // - // book the canvas - // - TCanvas *figure = new TCanvas("PAMELA event viewer", "PAMELA event viewer",(int)winx,(int)winy); - TLatex *text=new TLatex(); - stringstream testo; - stringstream testo2; - stringstream testo3; - figure->Range(0.,0.,1.,1.); - gStyle->SetOptDate(0); - gStyle->SetOptStat(0); - gStyle->SetLabelSize(0); - gStyle->SetNdivisions(1,"X"); - gStyle->SetNdivisions(1,"Y"); - // - stringstream libload; - Int_t doflag = 1; - Int_t thefirst = 1; - Int_t trackdone1 = 0; - Int_t trackdone2 = 0; - Int_t seldone = 0; - Float_t headc = 0.; - Float_t headcold = 0.; - Int_t i = minevent; - Int_t OK = 0; - Int_t jumpto = 0; // otr->SetBranchAddress("Header", &eh); otr->GetEntry(maxevent); @@ -5991,13 +7011,17 @@ otr->GetEntry(minevent); ph = eh->GetPscuHeader(); Int_t firstevno = (int)ph->GetCounter(); - struct Calib calib; - Int_t b[4]; - Int_t si = 0; + if ( !var.refresh ) i = minevent; + var.refresh = false; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // MAIN LOOP STARTS HERE: run over all the events ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - while ( i < maxevent+1 ){ + // while ( i < maxevent+1 ){ + while ( 1 ){ + // + // update progress bar + // + if ( popup ) pamgui->increment((float)(i+1)*100./(float)nevents); // // clear canvas and variables // @@ -6026,21 +7050,33 @@ ph = eh->GetPscuHeader(); Int_t cjumpto = (int)ph->GetCounter(); if ( cjumpto == jumpto ) jumpto = 0; - if ( jumpto && i == maxevent ) { - i = si; - printf(" WARNING: NO EVENT WITH EVENT NUMBER %i \n",jumpto); - jumpto = 0; + if ( jumpto && (i == maxevent || i == si) ) { + if ( var.jumpen && i == maxevent ) { + i = -1; + var.jumpen = false; + } else { + i = si; + printf(" WARNING: NO EVENT WITH EVENT NUMBER %i \n",jumpto); + stringstream dialog; + dialog.str(""); + dialog << " No event with event number "; + dialog << jumpto; + pamgui->DIALOG(1,dialog.str().c_str()); + jumpto = 0; + }; }; }; // - OK = 0; - if ( !selection || ( i == minevent && !seldone) ){ - OK = 1; + isOK = 0; + if ( !selection || ( i == minevent && !seldone) || ( i == minevent || i == maxevent )){ + if ( i == minevent && selection && seldone && doflag==2) pamgui->DIALOG(1," Stop searching, first event reached "); + if ( i == maxevent && selection ) pamgui->DIALOG(1," Stop searching, last event reached "); + isOK = 1; seldone = 1; } else { - OK = 0; + isOK = 0; #if defined (__CINT__) - OK = filter(i,otr,ttr,level); + isOK = filter(i,otr,ttr,level); #endif #if !defined (__CINT__) stringstream cintcom; @@ -6061,7 +7097,7 @@ cintcom << "struct Levels &level = (struct Levels &)0x" << hex; cintcom << &level; gROOT->ProcessLine(cintcom.str().c_str()); - OK = gApplication->ProcessLine("filter((Int_t)a,(TTree *)otr,(TTree *)ttr,(Levels &)level);"); + isOK = gApplication->ProcessLine("filter((Int_t)a,(TTree *)otr,(TTree *)ttr,(Levels &)level);"); #endif seldone = 1; printf("Scanning data: %d%c done",100*(i-minevent)/(maxevent-minevent),37); @@ -6070,8 +7106,12 @@ // // if the event is selected go on // - if ( OK && !jumpto ) { + if ( isOK && !jumpto ) { + if ( var.doflag == 3 ) selection = 1; printf("\n"); + // + figure->SetEditable(kTRUE); + // figure->Clear(); figure->SetFillColor(10); figure->cd(); @@ -6123,7 +7163,7 @@ // // show TOF // - if ( TOF ){ + if ( var.TOF ){ figure->cd(); if ( TOFLEV == 0 ){ ShowTOF(i,otr,var); @@ -6134,14 +7174,14 @@ level.tof = 0; }; if ( TOFLEV == 1 ){ - ShowTOFL1(i,toftr,var); + ShowTOFL1(i,toftr,var,pamgui); level.tof = 1; }; }; // // show anticounters // - if ( AC ){ + if ( var.AC ){ figure->cd(); if ( ACLEV == 0 ){ ShowAC(i,otr,var,0); @@ -6155,7 +7195,7 @@ // // show S4 // - if ( S4 ){ + if ( var.S4 ){ figure->cd(); if ( S4LEV == 0 ){ ShowS4L0(i,otr,var); @@ -6170,7 +7210,7 @@ // // show neutron detector // - if ( ND ){ + if ( var.ND ){ figure->cd(); ShowND(i,otr,var); level.nd = 0; @@ -6178,7 +7218,7 @@ // // show tracker // - if ( TRK ){ + if ( var.TRK ){ // // if we have level2 data show the track // @@ -6220,7 +7260,9 @@ }; level.track2 = 1; figure->cd(); - ShowTRACK(i,ttr,var); + ShowTRACK(i,ttr,var,pamgui); + } else { + level.track2 = 0; }; // // show level1 data @@ -6271,7 +7313,7 @@ }; }; }; - ShowTRKL1(i,ttr1,var); + ShowTRKL1(i,ttr1,var,pamgui); }; // // if everything fails, show at least level0 data @@ -6284,7 +7326,7 @@ // // show calorimeter // - if ( CALO ){ + if ( var.CALO ){ figure->cd(); // // if we have LEVEL1 data @@ -6344,7 +7386,7 @@ // // SHOW INFOS // - if ( INFOS ){ + if ( var.INFOS ){ figure->cd(); text->SetTextAngle(0); text->SetTextFont(32); @@ -6404,7 +7446,7 @@ text->DrawLatex(0.33,txthi,testo3.str().c_str()); txthi -= 0.03; testo3.str(""); - testo3 << "S4: " << setprecision(2); + testo3 << "S4: ";// << setprecision(2); testo3 << var.s4sig << " [MIP] TOF: #beta(1,...,5) = ("; testo3 << setprecision(3) << var.beta[0]; testo3 << ","; @@ -6419,8 +7461,8 @@ text->DrawLatex(0.33,txthi,testo3.str().c_str()); txthi -= 0.03; testo3.str(""); - testo3 << "ND: Trigger: neutrons = " << var.trup; - testo3 << " - Background: upper = " << var.bkup; + testo3 << "ND: Trig: " << var.trup; + testo3 << " - Bckgr: upper = " << var.bkup; testo3 << " lower = " << var.bkbo; text->DrawLatex(0.33,txthi,testo3.str().c_str()); txthi -= 0.03; @@ -6429,7 +7471,7 @@ text->SetTextAngle(90); text->DrawLatex(var.xyvc+0.17*var.sfx,var.yyvc+0.075*var.sfy,"CPU SIDE"); text->DrawLatex(var.xyvc-0.17*var.sfx,var.yyvc+0.075*var.sfy,"VME SIDE"); - if ( AC || TRK ){ + if ( var.AC ){ text->SetTextAngle(90); text->DrawLatex(var.xcat-0.235*var.sfx,var.ycat-0.025*var.sfy,"VME SIDE"); text->DrawLatex(var.xcat+0.235*var.sfx,var.ycat-0.025*var.sfy,"CPU SIDE"); @@ -6464,49 +7506,79 @@ // text->SetTextSize(0.015); text->SetTextFont(2); - DrawX(var.xxvc-0.23*var.sfx,var.yxvc-0.508*var.sfy,0.005,var); + DrawX(var.xxvc-0.25*var.sfx,var.yxvc-0.328*var.sfy,0.005,var); //508 text->SetTextFont(32); - text->DrawLatex(var.xxvc-0.246*var.sfx,var.yxvc-0.508*var.sfy,"y"); + text->DrawLatex(var.xxvc-0.266*var.sfx,var.yxvc-0.328*var.sfy,"y"); TArrow *arr; - arr = new TArrow(var.xxvc-0.23*var.sfx,var.yxvc-0.508*var.sfy,var.xxvc-0.19*var.sfx,var.yxvc-0.508*var.sfy); + arr = new TArrow(var.xxvc-0.25*var.sfx,var.yxvc-0.328*var.sfy,var.xxvc-0.21*var.sfx,var.yxvc-0.328*var.sfy); arr->SetArrowSize(0.005); arr->Draw(); - text->DrawLatex(var.xxvc-0.19*var.sfx,var.yxvc-0.515*var.sfy,"x"); - arr = new TArrow(var.xxvc-0.23*var.sfx,var.yxvc-0.508*var.sfy,var.xxvc-0.23*var.sfx,var.yxvc-0.468*var.sfy); + text->DrawLatex(var.xxvc-0.21*var.sfx,var.yxvc-0.335*var.sfy,"x"); + arr = new TArrow(var.xxvc-0.25*var.sfx,var.yxvc-0.328*var.sfy,var.xxvc-0.25*var.sfx,var.yxvc-0.288*var.sfy); arr->SetArrowSize(0.005); arr->Draw(); - text->DrawLatex(var.xxvc-0.246*var.sfx,var.yxvc-0.468*var.sfy,"z"); + text->DrawLatex(var.xxvc-0.266*var.sfx,var.yxvc-0.288*var.sfy,"z"); // text->SetTextSize(0.015); text->SetTextFont(2); - DrawX(var.xyvc+0.22*var.sfx,var.yyvc-0.508*var.sfy,0.005,var); + DrawX(var.xyvc+0.24*var.sfx,var.yyvc-0.328*var.sfy,0.005,var); text->SetTextFont(32); - text->DrawLatex(var.xyvc+0.23*var.sfx,var.yyvc-0.508*var.sfy,"x"); - arr = new TArrow(var.xyvc+0.22*var.sfx,var.yyvc-0.508*var.sfy,var.xyvc+0.18*var.sfx,var.yyvc-0.508*var.sfy); + text->DrawLatex(var.xyvc+0.25*var.sfx,var.yyvc-0.328*var.sfy,"x"); + arr = new TArrow(var.xyvc+0.24*var.sfx,var.yyvc-0.328*var.sfy,var.xyvc+0.2*var.sfx,var.yyvc-0.328*var.sfy); arr->SetArrowSize(0.005); arr->Draw(); - text->DrawLatex(var.xyvc+0.17*var.sfx,var.yyvc-0.511*var.sfy,"y"); - arr = new TArrow(var.xyvc+0.22*var.sfx,var.yyvc-0.508*var.sfy,var.xyvc+0.22*var.sfx,var.yyvc-0.468*var.sfy); + text->DrawLatex(var.xyvc+0.19*var.sfx,var.yyvc-0.335*var.sfy,"y"); + arr = new TArrow(var.xyvc+0.24*var.sfx,var.yyvc-0.328*var.sfy,var.xyvc+0.24*var.sfx,var.yyvc-0.288*var.sfy); arr->SetArrowSize(0.005); arr->Draw(); - text->DrawLatex(var.xyvc+0.23*var.sfx,var.yyvc-0.468*var.sfy,"z"); + text->DrawLatex(var.xyvc+0.25*var.sfx,var.yyvc-0.288*var.sfy,"z"); text->SetTextSize(0.01); + // +/* text->SetTextSize(0.015); */ +/* text->SetTextFont(2); */ +/* DrawX(var.xxvc-0.23*var.sfx,var.yxvc-0.508*var.sfy,0.005,var); */ +/* text->SetTextFont(32); */ +/* text->DrawLatex(var.xxvc-0.246*var.sfx,var.yxvc-0.508*var.sfy,"y"); */ +/* TArrow *arr; */ +/* arr = new TArrow(var.xxvc-0.23*var.sfx,var.yxvc-0.508*var.sfy,var.xxvc-0.19*var.sfx,var.yxvc-0.508*var.sfy); */ +/* arr->SetArrowSize(0.005); */ +/* arr->Draw(); */ +/* text->DrawLatex(var.xxvc-0.19*var.sfx,var.yxvc-0.515*var.sfy,"x"); */ +/* arr = new TArrow(var.xxvc-0.23*var.sfx,var.yxvc-0.508*var.sfy,var.xxvc-0.23*var.sfx,var.yxvc-0.468*var.sfy); */ +/* arr->SetArrowSize(0.005); */ +/* arr->Draw(); */ +/* text->DrawLatex(var.xxvc-0.246*var.sfx,var.yxvc-0.468*var.sfy,"z"); */ +/* // */ +/* text->SetTextSize(0.015); */ +/* text->SetTextFont(2); */ +/* DrawX(var.xyvc+0.22*var.sfx,var.yyvc-0.508*var.sfy,0.005,var); */ +/* text->SetTextFont(32); */ +/* text->DrawLatex(var.xyvc+0.23*var.sfx,var.yyvc-0.508*var.sfy,"x"); */ +/* arr = new TArrow(var.xyvc+0.22*var.sfx,var.yyvc-0.508*var.sfy,var.xyvc+0.18*var.sfx,var.yyvc-0.508*var.sfy); */ +/* arr->SetArrowSize(0.005); */ +/* arr->Draw(); */ +/* text->DrawLatex(var.xyvc+0.17*var.sfx,var.yyvc-0.511*var.sfy,"y"); */ +/* arr = new TArrow(var.xyvc+0.22*var.sfx,var.yyvc-0.508*var.sfy,var.xyvc+0.22*var.sfx,var.yyvc-0.468*var.sfy); */ +/* arr->SetArrowSize(0.005); */ +/* arr->Draw(); */ +/* text->DrawLatex(var.xyvc+0.23*var.sfx,var.yyvc-0.468*var.sfy,"z"); */ +/* text->SetTextSize(0.01); */ }; // // SHOW PALETTE // - if ( PALETTE ) ShowPalette(var.bw); + if ( var.PALETTE ) ShowPalette(var.bw); // // SHOW VERBOSE INFOS // - if ( VINFOS ){ + if ( var.VINFOS ){ figure->cd(); text->SetTextAngle(0); text->SetTextFont(32); text->SetTextColor(1); text->SetTextSize(0.01); text->SetTextAlign(12); - if ( AC ){ + if ( var.AC ){ // // Plane view // @@ -6544,7 +7616,7 @@ text->DrawLatex(var.xyvc-0.170*var.sfx,var.yyvc+0.39*var.sfy,"CAT2"); text->DrawLatex(var.xyvc+0.13*var.sfx,var.yyvc+0.39*var.sfy,"CAT1"); }; - if ( CALO ){ + if ( var.CALO ){ text->SetTextSize(0.020); text->SetTextAngle(90); text->DrawLatex(var.xxvc-0.22*var.sfx,var.yxvc-0.290*var.sfy,"Calorimeter"); @@ -6552,7 +7624,7 @@ text->SetTextSize(0.01); text->SetTextAngle(0); }; - if ( TRK ){ + if ( var.TRK ){ text->SetTextSize(0.020); text->SetTextAngle(90); text->DrawLatex(var.xxvc-0.22*var.sfx,var.yxvc+0.080*var.sfy,"Tracker"); @@ -6560,15 +7632,15 @@ text->SetTextSize(0.01); text->SetTextAngle(0); }; - if ( ND ){ + if ( var.ND ){ text->SetTextSize(0.020); - text->SetTextAngle(90); - text->DrawLatex(var.xxvc-0.22*var.sfx,var.yxvc-0.430*var.sfy,"ND"); - text->DrawLatex(var.xyvc+0.22*var.sfx,var.yyvc-0.430*var.sfy,"ND"); + // text->SetTextAngle(90); + text->DrawLatex(var.xxvc-0.25*var.sfx,var.yxvc-0.530*var.sfy,"ND"); + text->DrawLatex(var.xyvc+0.22*var.sfx,var.yyvc-0.530*var.sfy,"ND"); text->SetTextSize(0.01); text->SetTextAngle(0); }; - if ( TOF ){ + if ( var.TOF ){ text->SetTextSize(0.020); text->DrawLatex(var.xxvc-0.24*var.sfx,var.yxvc-0.130*var.sfy,"S3"); text->DrawLatex(var.xxvc-0.24*var.sfx,var.yxvc+0.350*var.sfy,"S2"); @@ -6578,19 +7650,19 @@ text->DrawLatex(var.xyvc+0.21*var.sfx,var.yyvc+0.653*var.sfy,"S1"); text->SetTextSize(0.01); }; - if ( S4 ){ + if ( var.S4 ){ text->SetTextSize(0.020); - text->DrawLatex(var.xxvc-0.24*var.sfx,var.yxvc-0.350*var.sfy,"S4"); - text->DrawLatex(var.xyvc+0.21*var.sfx,var.yyvc-0.350*var.sfy,"S4"); + text->DrawLatex(var.xxvc-0.28*var.sfx,var.yxvc-0.350*var.sfy,"S4"); + text->DrawLatex(var.xyvc+0.25*var.sfx,var.yyvc-0.350*var.sfy,"S4"); text->SetTextSize(0.01); }; - if ( !INFOS ){ + if ( !var.INFOS ){ text->SetTextSize(0.01); text->DrawLatex(var.xxvc-0.025*var.sfx,var.yxvc-0.520*var.sfy,"CPU SIDE"); text->SetTextAngle(90); text->DrawLatex(var.xyvc+0.17*var.sfx,var.yyvc+0.075*var.sfy,"CPU SIDE"); text->DrawLatex(var.xyvc-0.17*var.sfx,var.yyvc+0.075*var.sfy,"VME SIDE"); - if ( AC || TRK ){ + if ( var.AC ){ text->SetTextAngle(90); text->DrawLatex(var.xcat-0.235*var.sfx,var.ycat-0.025*var.sfy,"VME SIDE"); text->DrawLatex(var.xcat+0.235*var.sfx,var.ycat-0.025*var.sfy,"CPU SIDE"); @@ -6625,32 +7697,32 @@ // text->SetTextSize(0.015); text->SetTextFont(2); - DrawX(var.xxvc-0.23*var.sfx,var.yxvc-0.508*var.sfy,0.005,var); + DrawX(var.xxvc-0.25*var.sfx,var.yxvc-0.328*var.sfy,0.005,var); //508 text->SetTextFont(32); - text->DrawLatex(var.xxvc-0.246*var.sfx,var.yxvc-0.508*var.sfy,"y"); + text->DrawLatex(var.xxvc-0.266*var.sfx,var.yxvc-0.328*var.sfy,"y"); TArrow *arr; - arr = new TArrow(var.xxvc-0.23*var.sfx,var.yxvc-0.508*var.sfy,var.xxvc-0.19*var.sfx,var.yxvc-0.508*var.sfy); + arr = new TArrow(var.xxvc-0.25*var.sfx,var.yxvc-0.328*var.sfy,var.xxvc-0.21*var.sfx,var.yxvc-0.328*var.sfy); arr->SetArrowSize(0.005); arr->Draw(); - text->DrawLatex(var.xxvc-0.19*var.sfx,var.yxvc-0.515*var.sfy,"x"); - arr = new TArrow(var.xxvc-0.23*var.sfx,var.yxvc-0.508*var.sfy,var.xxvc-0.23*var.sfx,var.yxvc-0.468*var.sfy); + text->DrawLatex(var.xxvc-0.21*var.sfx,var.yxvc-0.335*var.sfy,"x"); + arr = new TArrow(var.xxvc-0.25*var.sfx,var.yxvc-0.328*var.sfy,var.xxvc-0.25*var.sfx,var.yxvc-0.288*var.sfy); arr->SetArrowSize(0.005); arr->Draw(); - text->DrawLatex(var.xxvc-0.246*var.sfx,var.yxvc-0.468*var.sfy,"z"); + text->DrawLatex(var.xxvc-0.266*var.sfx,var.yxvc-0.288*var.sfy,"z"); // text->SetTextSize(0.015); text->SetTextFont(2); - DrawX(var.xyvc+0.22*var.sfx,var.yyvc-0.508*var.sfy,0.005,var); + DrawX(var.xyvc+0.24*var.sfx,var.yyvc-0.328*var.sfy,0.005,var); text->SetTextFont(32); - text->DrawLatex(var.xyvc+0.23*var.sfx,var.yyvc-0.508*var.sfy,"x"); - arr = new TArrow(var.xyvc+0.22*var.sfx,var.yyvc-0.508*var.sfy,var.xyvc+0.18*var.sfx,var.yyvc-0.508*var.sfy); + text->DrawLatex(var.xyvc+0.25*var.sfx,var.yyvc-0.328*var.sfy,"x"); + arr = new TArrow(var.xyvc+0.24*var.sfx,var.yyvc-0.328*var.sfy,var.xyvc+0.2*var.sfx,var.yyvc-0.328*var.sfy); arr->SetArrowSize(0.005); arr->Draw(); - text->DrawLatex(var.xyvc+0.17*var.sfx,var.yyvc-0.511*var.sfy,"y"); - arr = new TArrow(var.xyvc+0.22*var.sfx,var.yyvc-0.508*var.sfy,var.xyvc+0.22*var.sfx,var.yyvc-0.468*var.sfy); + text->DrawLatex(var.xyvc+0.19*var.sfx,var.yyvc-0.335*var.sfy,"y"); + arr = new TArrow(var.xyvc+0.24*var.sfx,var.yyvc-0.328*var.sfy,var.xyvc+0.24*var.sfx,var.yyvc-0.288*var.sfy); arr->SetArrowSize(0.005); arr->Draw(); - text->DrawLatex(var.xyvc+0.23*var.sfx,var.yyvc-0.468*var.sfy,"z"); + text->DrawLatex(var.xyvc+0.25*var.sfx,var.yyvc-0.288*var.sfy,"z"); text->SetTextSize(0.01); }; }; @@ -6660,6 +7732,7 @@ figure->Modified(); figure->Update(); figure->cd(); + figure->SetEditable(kFALSE); // // print infos on terminal // @@ -6689,30 +7762,86 @@ // Interact with user: do you want to continue, go backward, exit or print the figure? // printf("\n\n\n\n\n\n\n\n\n\n"); - if ( i != maxevent ) { - si = i; - doflag = 1; - jumpto = 0; - TString figty = "ev"; - var.i = i; - var.doflag = doflag; - var.jumpto = jumpto; - var.nevents = nevents; - var.lastevno = lastevno; - var.firstevno = firstevno; - Int_t ifout = WhatToDoEV(var,file,outDir,figty,*figure); - i = var.i; - doflag = var.doflag; - jumpto = var.jumpto; - if ( i != si ) OOBT = 1000000000; - if ( maxevent < i+1 ) { - maxevent = nevents; - printf("WARNING: you have chosen an event number out of the starting range.\n Range extended to %i\n\n",maxevent); - }; - if ( ifout ) goto theend; + si = i; + doflag = 1; + jumpto = 0; + var.i = i; + var.doflag = doflag; + var.jumpto = jumpto; + var.nevents = nevents; + var.lastevno = lastevno; + var.firstevno = firstevno; + // + char *bw; + if ( var.bw ){ + bw = "_bw"; } else { - printf("\n\n"); + bw = ""; + }; + TString filenm = file; + const string fil = (const char*)filenm; + Int_t posiz = fil.find("dw_"); + if ( posiz == -1 ) posiz = fil.find("DW_"); + Int_t posiz2 = posiz+13; + TString file2; + stringcopy(file2,filenm,posiz,posiz2); + const char *figrec = file2; + const char *outdir = outDir; + stringstream figsave; + figsave.str(""); + figsave << outdir << "/"; + figsave << figrec; + figsave << "_ev_"; + figsave << (var.i+1); + figsave << bw; + var.svas=figsave.str().c_str(); + pamgui->upgrnamfi(); + // + var.jumpen = false; + // njumpen = 0; + Int_t ifout = 0; + while( !var.goon && !var.refresh && !var.restart ) { + if ( !gROOT->GetListOfCanvases()->FindObject(figure) ) { + pamgui->Close(); + gSystem->ProcessEvents(); + gApplication->Terminate(0); + }; + gSystem->ProcessEvents(); + gSystem->Sleep(10); + }; + var.goon = false; + if ( var.refresh || var.restart ){ + headerFile->Close(); + triggerFile->Close(); + if ( trackerFile ) trackerFile->Close(); + if ( trackerFile2 ) trackerFile2->Close(); + if ( caloFile )caloFile->Close(); + if ( neutronFile ) neutronFile->Close(); + if ( acFile ) acFile->Close(); + if ( tofFile ) tofFile->Close(); + if ( tofFileL1 ) tofFileL1->Close(); + if ( s4File ) s4File->Close(); + if ( trackhead ) trackhead->Close(); + if ( trackcalibFile1 ) trackcalibFile1->Close(); + if ( trackcalibFile2 ) trackcalibFile2->Close(); + if ( trackerFile2b ) trackerFile2b->Close(); + if ( var.refresh ) goto refresh; + if ( var.restart ){ + filename = var.thefilename.Data(); + pamgui->Close(); + goto restart; + }; + }; + // + i = var.i; + doflag = var.doflag; + jumpto = var.jumpto; + if ( i != si ) OOBT = 1000000000; + if ( maxevent < i ) { + maxevent = nevents; + printf("WARNING: you have chosen an event number out of the starting range.\n Range extended to %i\n\n",maxevent); }; + if ( ifout ) goto theend; }; if ( doflag == 2 && i == 0 ) { printf("\n WARNING: Cannot go backward! Going forward. \n"); @@ -6720,6 +7849,7 @@ }; if ( doflag == 2 && i>0 ) i--; if ( doflag == 1 ) i++; + if ( var.doflag == 3 ) selection = 0; // // if in selection mode, print out a event progress bar: //