/[PAMELA software]/eventviewer/flight/src/FEVpamevcontrol.cpp
ViewVC logotype

Annotation of /eventviewer/flight/src/FEVpamevcontrol.cpp

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.23