/[PAMELA software]/eventviewer/flight/macros/FEVpamevcontrol.cxx
ViewVC logotype

Annotation of /eventviewer/flight/macros/FEVpamevcontrol.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Fri Jul 14 14:21:42 2006 UTC (18 years, 5 months ago) by mocchiut
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
New _BETA_ and buggy version

1 mocchiut 1.1 #include <math.h>
2     #include <stdio.h>
3     #include <iostream>
4     #include <iomanip>
5     #include <fstream>
6     #include <sstream>
7     #if (__GNUC__ == 3) && (__GNUC_MINOR__ == 2)
8     char* operator+( std::streampos&, char* );
9     #endif
10     //
11     #include <TObjectTable.h>
12     #include <TGClient.h>
13     #include <TGButton.h>
14     #include <TGComboBox.h>
15     #include <TGLabel.h>
16     #include <TGTextEntry.h>
17     #include <TGFrame.h>
18     #include <TGButtonGroup.h>
19     #include <TGProgressBar.h>
20     #include <TGMsgBox.h>
21     #include <TGComboBox.h>
22     #include <TTree.h>
23     #include <TClassEdit.h>
24     #include <TObject.h>
25     #include <TList.h>
26     #include <TSystem.h>
27     #include <TSystemDirectory.h>
28     #include <TString.h>
29     #include <TFile.h>
30     #include <TClass.h>
31     #include <TCanvas.h>
32     #include <TH1.h>
33     #include <TH1F.h>
34     #include <TH2D.h>
35     #include <TLatex.h>
36     #include <TPad.h>
37     #include <TPaveLabel.h>
38     #include <TLine.h>
39     #include <TPolyLine.h>
40     #include <TChain.h>
41     #include <TApplication.h>
42     #include <TVirtualX.h>
43     #include <TGClient.h>
44     #include <TGWindow.h>
45     #include <TEllipse.h>
46     #include <TArrow.h>
47     #include <TStyle.h>
48     //
49     #include <FEVpamevcontrolfun.h>
50     //
51     ClassImp(PAMevcontrol);
52     ClassImp(CalorimeterCalibration);
53    
54     using namespace std;
55    
56     void stringcopy(TString& s1, const TString& s2, Int_t from=0, Int_t to=0){
57     if ( to == 0 ){
58     Int_t t2length = s2.Length();
59     s1 = "";
60     to = t2length;
61     };
62     for (Int_t i = from; i<to; i++){
63     s1.Append(s2[i],1);
64     };
65     }
66    
67     void stringappend(TString& s1, const TString& s2){
68     Int_t t2length = s2.Length();
69     for (Int_t i = 0; i<t2length; i++){
70     s1.Append(s2[i],1);
71     };
72     }
73    
74     CalorimeterCalibration::CalorimeterCalibration() {
75     fname = "dw_000000_000.dat";
76     status = 0;
77     for (Int_t i=0; i<2;i++){
78     for (Int_t j=0; j<22;j++){
79     for (Int_t m=0; m<96;m++){
80     mip[i][j][m] = 0.;
81     ermip[i][j][m] = 0.;
82     chi2[i][j][m] = 0.;
83     ndf[i][j][m] = 0.;
84     mask[i][j][m] = 0.;
85     for (Int_t a = 0; a < 4 ; a++){
86     fp[a][i][j][m] = 0.;
87     fpe[a][i][j][m] = 0.;
88     };
89     };
90     };
91     };
92     };
93    
94     PAMevcontrol::PAMevcontrol(const TGWindow *p,UInt_t w,UInt_t h,Variables & var, TCanvas &figure) : TGMainFrame(p, w, h){
95     //
96     SetCleanup(kDeepCleanup);
97     DontCallClose();
98     Connect("CloseWindow()","PAMevcontrol",this,"Terminate()");
99     //
100     cvar = &var;
101     thefigure = &figure;
102     //
103     TGCompositeFrame *cframe1 = new TGCompositeFrame(this, 280, 60, kVerticalFrame);
104     TGCompositeFrame *cframe2 = new TGCompositeFrame(this, 280, 60, kVerticalFrame);
105     TGCompositeFrame *cframe3 = new TGCompositeFrame(this, 280, 60, kVerticalFrame);
106     TGCompositeFrame *cframe4 = new TGCompositeFrame(this, 280, 60, kVerticalFrame);
107     TGGroupFrame *gf = new TGGroupFrame(cframe1, "Appearance");
108     TGGroupFrame *inputf = new TGGroupFrame(cframe2, "Input");
109     TGGroupFrame *jumpf = new TGGroupFrame(cframe3, "Jump to");
110     TGGroupFrame *savef = new TGGroupFrame(cframe4, "Save figure as");
111     //
112     TGHorizontalFrame *htexts = new TGHorizontalFrame(savef,400,800);
113     TGHorizontalFrame *htextsl = new TGHorizontalFrame(cframe4,400,800);
114     TGHorizontalFrame *htext = new TGHorizontalFrame(inputf,400,800);
115     TGHorizontalFrame *htext2 = new TGHorizontalFrame(inputf,400,800);
116     TGHorizontalFrame *htext3 = new TGHorizontalFrame(jumpf,400,800);
117     TGHorizontalFrame *htext4 = new TGHorizontalFrame(jumpf,400,80);
118     TGHorizontalFrame *hframe = new TGHorizontalFrame(this,400,800);
119     TGHorizontalFrame *hframe1 = new TGHorizontalFrame(gf, 280, 50);
120     TGHorizontalFrame *hframe2 = new TGHorizontalFrame(gf, 280, 40);
121     TGHorizontalFrame *hframe3 = new TGHorizontalFrame(gf, 280, 40);
122     TGHorizontalFrame *hframe4 = new TGHorizontalFrame(gf,280,10);
123     TGVerticalFrame *hframe5 = new TGVerticalFrame(hframe4, 280, 40);
124     TGHorizontalFrame *hfrprog = new TGHorizontalFrame(this,400,800);
125     //
126     TGTextEntry *fText = new TGTextEntry(htext, new TGTextBuffer(20),-1);
127     fText->SetText(cvar->thefilename.Data());
128     TGTextButton *Load = new TGTextButton(htext,"Load");
129     Load->Connect("Pressed()","TGTextEntry",fText,"ReturnPressed()");
130     fText->Connect("ReturnPressed()", "PAMevcontrol", this,"SetFilename()");
131     fText->Connect("TabPressed()", "PAMevcontrol", this,"CompleteText()");
132     htext->AddFrame(fText, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY, 0, 5, 5, 5));
133     htext->AddFrame(Load, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,0,5,5,5));
134     inputf->AddFrame(new TGLabel(inputf, new TGHotString("Filename:")));
135     inputf->AddFrame(htext, new TGLayoutHints(kLHintsExpandX));
136     //
137     fText2 = new TGTextEntry(htext2, new TGTextBuffer(20),-1);
138     fText2->SetText(cvar->thefilter.Data());
139     TGTextButton *Load2 = new TGTextButton(htext2,"Load");
140     Load2->Connect("Clicked()","TGTextEntry",fText2,"ReturnPressed()");
141     fText2->Connect("ReturnPressed()", "PAMevcontrol", this,"SetFilter()");
142     fText2->Connect("TabPressed()", "PAMevcontrol", this,"CompleteText()");
143     htext2->AddFrame(fText2, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY, 0, 5, 5, 5));
144     htext2->AddFrame(Load2, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,0,5,5,5));
145     inputf->AddFrame(new TGLabel(inputf, new TGHotString("Selection file:")));
146     inputf->AddFrame(htext2, new TGLayoutHints(kLHintsExpandX));
147     //
148     cframe2->AddFrame(inputf,new TGLayoutHints(kLHintsExpandX,5,5,5,5));
149     //
150     TGCheckButton *fchktof = new TGCheckButton(hframe1, "TOF");
151     fchktof->Connect("Clicked()","PAMevcontrol", this,"chktof()");
152     if ( cvar->TOF ) fchktof->SetState(kButtonDown);
153     hframe1->AddFrame(fchktof, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,0,5,5,5));
154     //
155     TGCheckButton *fchkac = new TGCheckButton(hframe1, "AC");
156     fchkac->Connect("Clicked()","PAMevcontrol", this,"chkac()");
157     if ( cvar->AC ) fchkac->SetState(kButtonDown);
158     hframe1->AddFrame(fchkac, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,5,25,5,5));
159     //
160     TGCheckButton *fchktrk = new TGCheckButton(hframe1, "Tracker");
161     fchktrk->Connect("Clicked()","PAMevcontrol",this,"chktrk()");
162     if ( cvar->TRK ) fchktrk->SetState(kButtonDown);
163     hframe1->AddFrame(fchktrk, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,10,5,5,5));
164     //
165     gf->AddFrame(hframe1, new TGLayoutHints(kLHintsExpandX));
166     //
167     TGCheckButton *fchks4 = new TGCheckButton(hframe2, "S4");
168     fchks4->Connect("Clicked()","PAMevcontrol",this,"chks4()");
169     if ( cvar->S4 ) fchks4->SetState(kButtonDown);
170     hframe2->AddFrame(fchks4, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,0,15,5,5));
171     //
172     TGCheckButton *fchknd = new TGCheckButton(hframe2, "ND");
173     fchknd->Connect("Clicked()","PAMevcontrol",this,"chknd()");
174     if ( cvar->ND ) fchknd->SetState(kButtonDown);
175     hframe2->AddFrame(fchknd, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,5,25,5,5));
176     //
177     TGCheckButton *fchkcalo = new TGCheckButton(hframe2, "Calorimeter");
178     fchkcalo->Connect("Clicked()","PAMevcontrol",this,"chkcalo()");
179     if ( cvar->CALO ) fchkcalo->SetState(kButtonDown);
180     hframe2->AddFrame(fchkcalo, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,10,2,5,5));
181     //
182     gf->AddFrame(hframe2, new TGLayoutHints(kLHintsExpandX));
183     //
184     TGCheckButton *fchkinfo = new TGCheckButton(hframe3, "Infos");
185     fchkinfo->Connect("Clicked()","PAMevcontrol",this,"chkinfo()");
186     if ( cvar->INFOS ) fchkinfo->SetState(kButtonDown);
187     hframe3->AddFrame(fchkinfo, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,0,5,5,5));
188     //
189     TGCheckButton *fchknames = new TGCheckButton(hframe3, "Names");
190     fchknames->Connect("Clicked()","PAMevcontrol",this,"chknames()");
191     if ( cvar->VINFOS ) fchknames->SetState(kButtonDown);
192     hframe3->AddFrame(fchknames, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,5,5,5,5));
193     TGCheckButton *fchkpalette = new TGCheckButton(hframe3, "Palette");
194     fchkpalette->Connect("Clicked()","PAMevcontrol",this,"chkpalette()");
195     if ( cvar->PALETTE) fchkpalette->SetState(kButtonDown);
196     hframe3->AddFrame(fchkpalette, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,10,5,5,5));
197     gf->AddFrame(hframe3, new TGLayoutHints(kLHintsExpandX));
198     //
199     TGVButtonGroup *group = new TGVButtonGroup(hframe4);
200     TGRadioButton *bwc0;
201     TGRadioButton *bwc1;
202     bwc0 = new TGRadioButton(group, "Colour");
203     bwc1 = new TGRadioButton(group, "B/W");
204     if ( cvar->bw ){
205     bwc1->SetState(kButtonDown);
206     } else {
207     bwc0->SetState(kButtonDown);
208     };
209     bwc0->Connect("Pressed()", "PAMevcontrol",this,"radiocolor()");
210     bwc1->Connect("Pressed()", "PAMevcontrol",this,"radiobw()");
211     hframe4->AddFrame(group,new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,1,5,5,5));
212     //
213     //
214     TGCheckButton *ftrks4 = new TGCheckButton(hframe5, "Track in S4/ND");
215     ftrks4->Connect("Clicked()","PAMevcontrol",this,"radiotrack()");
216     if ( cvar->tracknds4) ftrks4->SetState(kButtonDown);
217     hframe5->AddFrame(ftrks4, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,5,2,5,5));
218     TGCheckButton *ffl0 = new TGCheckButton(hframe5, "Force LEVEL0");
219     ffl0->Connect("Clicked()","PAMevcontrol",this,"forcel0()");
220     if ( cvar->fl0 ) ffl0->SetState(kButtonDown);
221     hframe5->AddFrame(ffl0, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,5,2,5,5));
222     //
223     hframe4->AddFrame(hframe5, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,10,5,5,5));
224     gf->AddFrame(hframe4, new TGLayoutHints(kLHintsExpandX));
225     //
226     cframe1->AddFrame(gf, new TGLayoutHints(kLHintsExpandX));
227     //
228     TGHButtonGroup *jgroup = new TGHButtonGroup(htext4);
229     TGRadioButton *jbwc0;
230     TGRadioButton *jbwc1;
231     jbwc0 = new TGRadioButton(jgroup, "event ");
232     jbwc1 = new TGRadioButton(jgroup, "progressive");
233     jbwc1->SetState(kButtonDown);
234     jbwc0->Connect("Pressed()", "PAMevcontrol",this,"radioevent()");
235     jbwc1->Connect("Pressed()", "PAMevcontrol",this,"radioprog()");
236     htext4->AddFrame(jgroup,new TGLayoutHints(kLHintsExpandX,1,1,0,0));
237     //
238     TGTextEntry *fText3 = new TGTextEntry(htext3, new TGTextBuffer(6),-1);
239     TGTextButton *Jump = new TGTextButton(htext3,"go");
240     Jump->Connect("Clicked()","TGTextEntry",fText3,"ReturnPressed()");
241     fText3->Connect("ReturnPressed()", "PAMevcontrol", this,"jumpto()");
242     htext3->AddFrame(new TGLabel(htext3, new TGHotString("number")), new TGLayoutHints(kLHintsExpandX,0,0,1,1));
243     htext3->AddFrame(fText3, new TGLayoutHints(kLHintsExpandX, 0, 8, 0, 0));
244     htext3->AddFrame(Jump, new TGLayoutHints(kLHintsExpandX,0,0,0,0));
245     jumpf->AddFrame(htext4, new TGLayoutHints(kLHintsExpandX,0,0,1,1)); //
246     jumpf->AddFrame(htext3, new TGLayoutHints(kLHintsExpandX,0,0,0,1)); //
247     //
248     cframe3->AddFrame(jumpf,new TGLayoutHints(kLHintsExpandX,5,5,5,5));
249     //
250     fText4 = new TGTextEntry(htexts, new TGTextBuffer(18),-1);
251     TGTextButton *save = new TGTextButton(htextsl,"save");
252     save->Connect("Clicked()","TGTextEntry",fText4,"ReturnPressed()");
253     fText4->Connect("ReturnPressed()", "PAMevcontrol", this,"saveas()");
254     fText4->Connect("TabPressed()", "PAMevcontrol", this,"CompleteText()");
255     htexts->AddFrame(fText4, new TGLayoutHints(kLHintsExpandX, 0, 8, 1, 1));
256     //
257     fCombo = new TGComboBox(htexts, 98);
258     fCombo->AddEntry(".ps", 0);
259     fCombo->AddEntry(".eps", 1);
260     fCombo->AddEntry(".gif", 2);
261     fCombo->AddEntry(".jpg", 3);
262     fCombo->AddEntry(".tiff", 4);
263     fCombo->AddEntry(".xpm", 5);
264     fCombo->AddEntry(".pdf", 6);
265     fCombo->AddEntry(".xml", 7);
266     fCombo->AddEntry(".png", 8);
267     fCombo->AddEntry(".svg", 9);
268     fCombo->AddEntry(".root", 10);
269     fCombo->AddEntry(".C", 11);
270     fCombo->Select(0);
271     fCombo->Resize(50,23);
272     // htexts->AddFrame(fCombo, new TGLayoutHints(kLHintsCenterX | kLHintsTop | kLHintsLeft | kLHintsCenterY | kLHintsExpandX, 0, 8, 1, 1));
273     htexts->AddFrame(fCombo, new TGLayoutHints(kLHintsExpandY | kLHintsRight, 2, 2, 2, 1));
274     //
275     htextsl->AddFrame(save, new TGLayoutHints(kLHintsExpandX,0,0,2,1));
276     savef->AddFrame(htexts, new TGLayoutHints(kLHintsExpandX,0,0,2,5));
277     // savef->AddFrame(htextsl, new TGLayoutHints(kLHintsExpandX,5,2,5,2));
278     savef->AddFrame(htextsl, new TGLayoutHints(kLHintsExpandX,8,0,5,2));
279     //
280     cframe4->AddFrame(savef,new TGLayoutHints(kLHintsExpandX,5,5,5,5));
281     //
282     fHProg1 = new TGHProgressBar(hfrprog, TGProgressBar::kFancy, 260);
283     fHProg1->SetBarColor("green");
284     fHProg1->ShowPosition();
285     hfrprog->AddFrame(fHProg1, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY | kLHintsExpandX,5,5,5,5));
286     //
287     //
288     TGTextButton *prev = new TGTextButton(hframe,"< &Back");
289     prev->Connect("Clicked()","PAMevcontrol",this,"prev()");
290     hframe->AddFrame(prev, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4));
291     //
292     TGTextButton *exit = new TGTextButton(hframe,"E&xit");//,"gApplication->Terminate(0)");
293     exit->Connect("Clicked()","PAMevcontrol",this,"Terminate()");
294     exit->SetToolTipText("Quit the event viewer");
295     hframe->AddFrame(exit, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4));
296     //
297     TGTextButton *stop = new TGTextButton(hframe,"&Stop");
298     stop->Connect("Clicked()","PAMevcontrol",this,"stop()");
299     hframe->AddFrame(stop, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4));
300     //
301     TGTextButton *next = new TGTextButton(hframe,"&Next >");
302     next->Connect("Clicked()","PAMevcontrol",this,"next()");
303     hframe->AddFrame(next, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4));
304     //
305     //
306     // AddFrame(htext, new TGLayoutHints(kLHintsExpandX,2,2,15,1));
307     AddFrame(cframe2, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
308     AddFrame(cframe1, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
309     AddFrame(cframe3, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
310     AddFrame(cframe4, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
311     AddFrame(hfrprog, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
312     AddFrame(hframe, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,1,1,1,1));
313     // Set a name to the main frame
314     SetWindowName("PAMELA Event Viewer control panel");
315     // Map all subwindows of main frame
316     MapSubwindows();
317     // Initialize the layout algorithm
318     Resize(GetDefaultSize());
319     // Map main frame
320     MapWindow();
321     }
322    
323     void PAMevcontrol::DIALOG(Int_t ty, TString warn){
324     //
325     // ty = 0 -> INFO, ty = 1 -> WARNING, ty = 3 -> ERROR
326     //
327     Int_t retval;
328     TString title;
329     EMsgBoxIcon mb_icon = kMBIconStop;
330     if ( ty == 0 ){
331     title="INFO";
332     mb_icon = kMBIconAsterisk;
333     };
334     if ( ty == 1 ){
335     title="WARNING!";
336     mb_icon = kMBIconExclamation;
337     };
338     if ( ty == 2 ){
339     title="ERROR!!";
340     mb_icon = kMBIconStop;
341     };
342     new TGMsgBox(gClient->GetRoot(), this, title.Data(), warn.Data(), mb_icon, kMBOk, &retval);
343     }
344    
345    
346     void PAMevcontrol::SetFilename() {
347     TGTextEntry *entry = (TGTextEntry*)gTQSender;
348     TString text = entry->GetText();
349     cvar->thefilename=text.Data();
350     cvar->nevents = 0;
351     cvar->firstevno = 0;
352     cvar->lastevno = 0;
353     cvar->restart = true;
354     cvar->waitforever = false;
355     }
356    
357     void PAMevcontrol::SetFilter() {
358     TGTextEntry *entry = (TGTextEntry*)gTQSender;
359     TString text = entry->GetText();
360     cvar->thefilter=text.Data();
361     cvar->i--;
362     cvar->selex = false;
363     cvar->nevents = 0;
364     cvar->firstevno = 0;
365     cvar->lastevno = 0;
366     cvar->refresh = true;
367     }
368    
369     void PAMevcontrol::CompleteText() {
370     TGTextEntry *entry = (TGTextEntry*)gTQSender;
371     TString text = entry->GetText();
372     Int_t curspos = entry->GetCursorPosition();
373     Int_t ncurspos = 0;
374     TString textrem;
375     stringcopy(textrem,text,curspos,text.Length());
376     text.Resize(curspos);
377     if ( !strcmp(text.Data(),"") ) {
378     stringstream ntext;
379     ntext.str("");
380     ntext << gSystem->ExpandPathName("$HOME");
381     text = ntext.str().c_str();
382     curspos=ntext.str().length();
383     };
384     char *test = gSystem->ExpandPathName(text.Data());
385     const char *dir = gSystem->DirName(test);
386     const char *base = gSystem->BaseName(test);
387     TString lbase = base;
388     Int_t lenbase = lbase.Length();
389     TSystemDirectory *tsd = new TSystemDirectory("",dir);
390     TSystemFile *file;
391     TList *lsmatch = new TList;
392     Int_t numf = 0;
393     Int_t numgo = 0;
394     Int_t charmac = 0;
395     TString tbase;
396     Int_t k = 0;
397     stringstream newtext;
398     TSystemFile *mfile;
399     TSystemFile nfile;
400     TList *lsf = new TList;
401     const char *ctbase;
402     if ( !tsd->GetListOfFiles() ){
403     gVirtualX->Bell(0);
404     goto end;
405     };
406     lsf = tsd->GetListOfFiles();
407     file = (TSystemFile*)lsf->First();
408     //
409     while( (TSystemFile*)lsf->After(file) ){
410     numf++;
411     file = (TSystemFile*)lsf->After(file);
412     if ( !strncmp(file->GetName(),base,lenbase) ){
413     numgo++;
414     lsmatch->AddLast(file);
415     const char *ctbase = file->GetName();
416     tbase = ctbase;
417     charmac = tbase.Length();
418     };
419     };
420     newtext.str("");
421     if ( numgo > 0 ){
422     mfile = (TSystemFile*)lsmatch->First();
423     ctbase = mfile->GetName();
424     while ( (!strcmp(ctbase,"..") || !strcmp(ctbase,".")) && (TSystemFile*)lsmatch->After(mfile) ) {
425     mfile = (TSystemFile*)lsmatch->After(mfile);
426     ctbase = mfile->GetName();
427     };
428     tbase = ctbase;
429     base = ctbase;
430     charmac = tbase.Length();;
431     while( (TSystemFile*)lsmatch->After(mfile) ){
432     mfile = (TSystemFile*)lsmatch->After(mfile);
433     ctbase = mfile->GetName();
434     while ( (!strcmp(ctbase,"..") || !strcmp(ctbase,".")) && (TSystemFile*)lsmatch->After(mfile) ) {
435     mfile = (TSystemFile*)lsmatch->After(mfile);
436     ctbase = mfile->GetName();
437     };
438     tbase = ctbase;
439     k = 0;
440     for ( Int_t i=lenbase; i<=tbase.Length(); i++){
441     if ( !strncmp(tbase.Data(),base,i) && strcmp(tbase.Data(),base) ){
442     k = i;
443     };
444     };
445     if ( k <= charmac){
446     charmac = k;
447     };
448     };
449     gVirtualX->Bell(0);
450     };
451     if ( !charmac ) {
452     gVirtualX->Bell(0);
453     goto end;
454     };
455     tbase.Resize(charmac);
456     if ( !strcmp(dir,"") || !strcmp(dir,"/") ){
457     newtext << "/" << tbase.Data();
458     } else {
459     newtext << dir << "/" << tbase.Data();
460     };
461     nfile = TSystemFile(tbase.Data(),dir);
462     if ( nfile.IsDirectory() && numgo == 1 ) newtext << "/";
463     ncurspos = newtext.str().length();
464     if ( textrem.Length() ) newtext << textrem.Data();
465     entry->SetText(newtext.str().c_str());
466     entry->SetCursorPosition(ncurspos);
467     end:
468     lsf->Clear();
469     lsmatch->Clear();
470     }
471    
472     void PAMevcontrol::saveas() {
473     TString text = fText4->GetText();
474     Int_t sel=fCombo->GetSelected();
475     TString ty;
476     switch (sel){
477     case (0):
478     ty = ".ps";
479     break;
480     case (1):
481     ty = ".eps";
482     break;
483     case (2):
484     ty = ".gif";
485     break;
486     case (3):
487     ty = ".jpg";
488     break;
489     case (4):
490     ty = ".tiff";
491     break;
492     case (5):
493     ty = ".xpm";
494     break;
495     case (6):
496     ty = ".pdf";
497     break;
498     case (7):
499     ty = ".xml";
500     break;
501     case (8):
502     ty = ".png";
503     break;
504     case (9):
505     ty = ".svg";
506     break;
507     case (10):
508     ty = ".root";
509     break;
510     case (11):
511     ty = ".C";
512     break;
513     };
514     if ( sel == 0 ) ty = ".ps";
515     stringstream name;
516     if ( strcmp(text.Data(),"") ){
517     name.str("");
518     name << text.Data();
519     name << ty.Data();
520     thefigure->SaveAs(name.str().c_str());
521     name.str("");
522     name << " Saved as ";
523     name << text.Data();
524     name << ty.Data();
525     DIALOG(0,name.str().c_str());
526     printf(" Saved as %s%s \n",text.Data(),ty.Data());
527     };
528     }
529    
530     void PAMevcontrol::increment(float val) {
531     fHProg1->Reset();
532     fHProg1->SetPosition(val);
533     gSystem->ProcessEvents();
534     }
535    
536     void PAMevcontrol::forcel0() {
537     if ( cvar->fl0 ) {
538     cvar->fl0 = false;
539     } else {
540     cvar->fl0 = true;
541     };
542     cvar->alrforc = false;
543     cvar->i--;
544     cvar->nevents = 0;
545     cvar->firstevno = 0;
546     cvar->lastevno = 0;
547     cvar->refresh = true;
548     }
549    
550     void PAMevcontrol::clearselfi(){
551     fText2->SetText("");
552     }
553    
554     void PAMevcontrol::upgrnamfi(){
555     fText4->SetText(cvar->svas.Data());
556     fText4->SetCursorPosition(fText4->GetMaxLength());
557     }
558    
559     void PAMevcontrol::jumpto() {
560     TGTextEntry *entry = (TGTextEntry*)gTQSender;
561     TString text = entry->GetText();
562     Int_t j;
563     j = atoi(text.Data());
564     if ( cvar->jumprog ){
565     if ( j < 1 || j > cvar->nevents ) {
566     printf("\n You can choose between 1 and %i \n",(int)cvar->nevents);
567     stringstream warning;
568     warning.str("");
569     warning << "You can choose between 1 and ";
570     warning << (int)cvar->nevents;
571     DIALOG(1,warning.str().c_str());
572     } else {
573     stringstream warning;
574     warning.str("");
575     warning << "Jumping to progressive number ";
576     warning << j;
577     DIALOG(0,warning.str().c_str());
578     printf("\n Jumping to progressive number %i\n\n",j);
579     cvar->i = j-2;
580     cvar->goon = true;
581     };
582     } else {
583     if ( j < cvar->firstevno || j > cvar->lastevno ) {
584     printf("\n You can choose between %i and %i \n",cvar->firstevno,cvar->lastevno);
585     stringstream warning;
586     warning.str("");
587     warning << "You can choose between ";
588     warning << cvar->firstevno;
589     warning << " and ";
590     warning << cvar->lastevno;
591     DIALOG(1,warning.str().c_str());
592     } else {
593     stringstream warning;
594     warning.str("");
595     warning << "Jumping to event number ";
596     warning << j;
597     DIALOG(0,warning.str().c_str());
598     printf("\n Jumping to event number %i\n\n",j);
599     cvar->jumpto = j;
600     cvar->jumpen = true;
601     cvar->goon = true;
602     };
603     };
604     entry->SetText("");
605     }
606    
607     void PAMevcontrol::radioevent() {
608     cvar->jumprog = false;
609     }
610    
611     void PAMevcontrol::radioprog() {
612     cvar->jumprog = true;
613     }
614    
615     void PAMevcontrol::radiocolor() {
616     if ( !cvar->goon ){
617     if ( cvar->bw ) {
618     cvar->bw = 0;
619     cvar->i--;
620     cvar->goon = true;
621     };
622     };
623     }
624    
625     void PAMevcontrol::radiobw() {
626     if ( !cvar->goon ){
627     if ( !cvar->bw ) {
628     cvar->bw = 1;
629     cvar->i--;
630     cvar->goon = true;
631     };
632     };
633     }
634    
635     void PAMevcontrol::radiotrack() {
636     if ( cvar->tracknds4 ) {
637     cvar->tracknds4 = 0;
638     } else {
639     cvar->tracknds4 = 1;
640     };
641     cvar->i--;
642     cvar->goon = true;
643     }
644    
645     void PAMevcontrol::chktof() {
646     if ( cvar->TOF ) {
647     cvar->TOF = 0;
648     } else {
649     cvar->TOF = 1;
650     };
651     cvar->i--;
652     cvar->nevents = 0;
653     cvar->firstevno = 0;
654     cvar->lastevno = 0;
655     cvar->refresh = true;
656     }
657    
658     void PAMevcontrol::chkac() {
659     if ( cvar->AC ) {
660     cvar->AC = 0;
661     } else {
662     cvar->AC = 1;
663     };
664     cvar->i--;
665     cvar->nevents = 0;
666     cvar->firstevno = 0;
667     cvar->lastevno = 0;
668     cvar->refresh = true;
669     }
670    
671     void PAMevcontrol::chktrk() {
672     if ( cvar->TRK ) {
673     cvar->TRK = 0;
674     } else {
675     cvar->TRK = 1;
676     };
677     cvar->i--;
678     cvar->nevents = 0;
679     cvar->firstevno = 0;
680     cvar->lastevno = 0;
681     cvar->refresh = true;
682     }
683    
684     void PAMevcontrol::chkcalo() {
685     if ( cvar->CALO ) {
686     cvar->CALO = 0;
687     } else {
688     cvar->CALO = 1;
689     };
690     cvar->i--;
691     cvar->nevents = 0;
692     cvar->firstevno = 0;
693     cvar->lastevno = 0;
694     cvar->refresh = true;
695     }
696    
697     void PAMevcontrol::chks4() {
698     if ( cvar->S4 ) {
699     cvar->S4 = 0;
700     } else {
701     cvar->S4 = 1;
702     };
703     cvar->i--;
704     cvar->nevents = 0;
705     cvar->firstevno = 0;
706     cvar->lastevno = 0;
707     cvar->refresh = true;
708     }
709    
710     void PAMevcontrol::chknd() {
711     if ( cvar->ND ) {
712     cvar->ND = 0;
713     } else {
714     cvar->ND = 1;
715     };
716     cvar->i--;
717     cvar->nevents = 0;
718     cvar->firstevno = 0;
719     cvar->lastevno = 0;
720     cvar->refresh = true;
721     }
722    
723     void PAMevcontrol::chkinfo() {
724     if ( cvar->INFOS ) {
725     cvar->INFOS = 0;
726     } else {
727     cvar->INFOS = 1;
728     };
729     cvar->i--;
730     cvar->goon = true;
731     }
732    
733     void PAMevcontrol::chknames() {
734     if ( cvar->VINFOS ) {
735     cvar->VINFOS = 0;
736     } else {
737     cvar->VINFOS = 1;
738     };
739     cvar->i--;
740     cvar->goon = true;
741     }
742    
743     void PAMevcontrol::chkpalette() {
744     if ( cvar->PALETTE ) {
745     cvar->PALETTE = 0;
746     } else {
747     cvar->PALETTE = 1;
748     };
749     cvar->i--;
750     cvar->goon = true;
751     }
752    
753     void PAMevcontrol::next() {
754     if ( cvar->i == cvar->nevents-1 ) {
755     printf("This is the last event, you can't go forward! \n");
756     DIALOG(1,"This is the last event!");
757     } else {
758     cvar->goon = true;
759     cvar->doflag = 1;
760     };
761     }
762    
763     void PAMevcontrol::stop() {
764     DIALOG(1,"Stop searching");
765     cvar->doflag = 3;
766     }
767    
768     void PAMevcontrol::prev() {
769     if ( cvar->i > 0 ) {
770     printf("WARNING: going backward!\n\n");
771     cvar->doflag = 2;
772     cvar->goon = true;
773     } else {
774     printf("This is the first event, you can't go backward! \n");
775     DIALOG(1,"This is the first event!");
776     };
777     }
778    
779     void PAMevcontrol::Terminate() {
780     gSystem->ProcessEvents();
781     gApplication->Terminate(0);
782     }
783    
784     PAMevcontrol::~PAMevcontrol() {
785     // Clean up used widgets: frames, buttons, layouthints
786     Cleanup();
787     delete this;
788     }

  ViewVC Help
Powered by ViewVC 1.1.23