/[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.10 - (hide annotations) (download)
Mon Jun 15 14:17:21 2009 UTC (15 years, 5 months ago) by mocchiut
Branch: MAIN
Changes since 1.9: +69 -8 lines
Cosmetic changes to popup windows

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 mocchiut 1.4 #include <PamLevel2.h>
50     //
51 mocchiut 1.1 #include <FEVpamevcontrol.h>
52     //
53     ClassImp(PAMevcontrol);
54     ClassImp(CalorimeterCalibration);
55     //
56    
57     using namespace std;
58    
59     void stringcopy(TString& s1, const TString& s2, Int_t from=0, Int_t to=0){
60     if ( to == 0 ){
61     Int_t t2length = s2.Length();
62     s1 = "";
63     to = t2length;
64     };
65     for (Int_t i = from; i<to; i++){
66     s1.Append(s2[i],1);
67     };
68     }
69    
70     void stringappend(TString& s1, const TString& s2){
71     Int_t t2length = s2.Length();
72     for (Int_t i = 0; i<t2length; i++){
73     s1.Append(s2[i],1);
74     };
75     }
76    
77     CalorimeterCalibration::CalorimeterCalibration() {
78     fname = "dw_000000_000.dat";
79     status = 0;
80     for (Int_t i=0; i<2;i++){
81     for (Int_t j=0; j<22;j++){
82     for (Int_t m=0; m<96;m++){
83     mip[i][j][m] = 0.;
84     ermip[i][j][m] = 0.;
85     chi2[i][j][m] = 0.;
86     ndf[i][j][m] = 0.;
87     mask[i][j][m] = 0.;
88     for (Int_t a = 0; a < 4 ; a++){
89     fp[a][i][j][m] = 0.;
90     fpe[a][i][j][m] = 0.;
91     };
92     };
93     };
94     };
95     };
96    
97     PAMevcontrol::PAMevcontrol(const TGWindow *p,UInt_t w,UInt_t h,Variables & var, Levels &level, TCanvas &figure) : TGMainFrame(p, w, h){
98     //
99     SetCleanup(kDeepCleanup);
100     DontCallClose();
101     Connect("CloseWindow()","PAMevcontrol",this,"Terminate()");
102     //
103     clev = &level;
104     cvar = &var;
105     thefigure = &figure;
106     //
107 mocchiut 1.3 cframe1 = new TGCompositeFrame(this, 280, 40, kVerticalFrame);
108 mocchiut 1.1 TGCompositeFrame *cframe2 = new TGCompositeFrame(this, 280, 60, kVerticalFrame);
109     TGCompositeFrame *cframe3 = new TGCompositeFrame(this, 280, 60, kVerticalFrame);
110     TGCompositeFrame *cframe4 = new TGCompositeFrame(this, 280, 60, kVerticalFrame);
111 mocchiut 1.3 TGCompositeFrame *cframe5 = new TGCompositeFrame(this, 280, 60, kVerticalFrame);
112     gf = new TGGroupFrame(cframe1, "Detectors");
113     TGGroupFrame *gf2 = new TGGroupFrame(cframe5, "Appearance");
114 mocchiut 1.1 TGGroupFrame *inputf = new TGGroupFrame(cframe2, "Input");
115     TGGroupFrame *jumpf = new TGGroupFrame(cframe3, "Jump to");
116     TGGroupFrame *savef = new TGGroupFrame(cframe4, "Save figure as");
117     //
118     TGHorizontalFrame *htexts = new TGHorizontalFrame(savef,400,800);
119     TGHorizontalFrame *htextsl = new TGHorizontalFrame(cframe4,400,800);
120     TGHorizontalFrame *htext = new TGHorizontalFrame(inputf,400,800);
121     TGHorizontalFrame *htext2 = new TGHorizontalFrame(inputf,400,800);
122     TGHorizontalFrame *htext3 = new TGHorizontalFrame(jumpf,400,800);
123     TGHorizontalFrame *htext4 = new TGHorizontalFrame(jumpf,400,80);
124     TGHorizontalFrame *hframe = new TGHorizontalFrame(this,400,800);
125 mocchiut 1.3 for (Int_t fr=0; fr<12; fr++) hframedec[fr] = new TGHorizontalFrame(gf, 7, 7);
126     TGHorizontalFrame *hframe3 = new TGHorizontalFrame(gf2, 280, 40);
127     TGHorizontalFrame *hframe4 = new TGHorizontalFrame(gf2,280,10);
128 mocchiut 1.1 TGVerticalFrame *hframe5 = new TGVerticalFrame(hframe4, 280, 40);
129     TGHorizontalFrame *hfrprog = new TGHorizontalFrame(this,400,800);
130     //
131     TGTextEntry *fText = new TGTextEntry(htext, new TGTextBuffer(20),-1);
132     fText->SetText(cvar->thefilename.Data());
133     TGTextButton *Load = new TGTextButton(htext,"Load");
134     Load->Connect("Pressed()","TGTextEntry",fText,"ReturnPressed()");
135     fText->Connect("ReturnPressed()", "PAMevcontrol", this,"SetFilename()");
136     fText->Connect("TabPressed()", "PAMevcontrol", this,"CompleteText()");
137     htext->AddFrame(fText, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY, 0, 5, 5, 5));
138 mocchiut 1.3 htext->AddFrame(Load, new TGLayoutHints(kLHintsCenterX,0,5,5,5));
139 mocchiut 1.1 inputf->AddFrame(new TGLabel(inputf, new TGHotString("Filename:")));
140     inputf->AddFrame(htext, new TGLayoutHints(kLHintsExpandX));
141     //
142     fText2 = new TGTextEntry(htext2, new TGTextBuffer(20),-1);
143     fText2->SetText(cvar->thefilter.Data());
144     TGTextButton *Load2 = new TGTextButton(htext2,"Load");
145     Load2->Connect("Clicked()","TGTextEntry",fText2,"ReturnPressed()");
146 mocchiut 1.2 Load2->SetToolTipText("Clear box and click to unload file");
147 mocchiut 1.1 fText2->Connect("ReturnPressed()", "PAMevcontrol", this,"SetFilter()");
148     fText2->Connect("TabPressed()", "PAMevcontrol", this,"CompleteText()");
149     htext2->AddFrame(fText2, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY, 0, 5, 5, 5));
150 mocchiut 1.3 htext2->AddFrame(Load2, new TGLayoutHints(kLHintsCenterX,0,5,5,5));
151 mocchiut 1.1 inputf->AddFrame(new TGLabel(inputf, new TGHotString("Selection file:")));
152     inputf->AddFrame(htext2, new TGLayoutHints(kLHintsExpandX));
153     //
154     cframe2->AddFrame(inputf,new TGLayoutHints(kLHintsExpandX,5,5,5,5));
155     //
156 mocchiut 1.3 //
157     //
158     fComboDec = new TGComboBox(gf, 98);
159     fComboDec->AddEntry(" - Select Detector -", 11);
160     fComboDec->AddEntry("PSCU - ORB", 0);
161     fComboDec->AddEntry("Run", 1);
162     fComboDec->AddEntry("Trigger", 2);
163     fComboDec->AddEntry("ToF", 3);
164     fComboDec->AddEntry("Tracker", 4);
165     fComboDec->AddEntry("Anticounter", 5);
166     fComboDec->AddEntry("Calorimeter", 6);
167     fComboDec->AddEntry("S4", 7);
168     fComboDec->AddEntry("ND", 8);
169     fComboDec->AddEntry("Software info", 9);
170     fComboDec->AddEntry("ALL", 10);
171     fComboDec->Select(11);
172     fComboDec->Resize(150,23);
173     gf->AddFrame(fComboDec, new TGLayoutHints(kLHintsCenterY | kLHintsExpandX| kLHintsLeft, 5, 7, 7, 7));
174     fComboDec->Connect("Selected(Int_t)","PAMevcontrol",this,"refreshdec(Int_t)");
175     //
176     // PSCU/Orbital
177     //
178     fshoworb = new TGTextButton(hframedec[0], "Show Data");
179     fshoworb->Connect("Clicked()","PAMevcontrol", this,"showorbdata()");
180     if ( !cvar->ORB ) fshoworb->SetState(kButtonDisabled);
181     hframedec[0]->AddFrame(fshoworb, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,5,5,5));
182     //
183     // RUN
184     //
185     fshowrun = new TGTextButton(hframedec[1], "Show Data");
186     fshowrun->Connect("Clicked()","PAMevcontrol", this,"showrundata()");
187     if ( !cvar->RUN ) fshoworb->SetState(kButtonDisabled);
188     hframedec[1]->AddFrame(fshowrun, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,5,5,5));
189     //
190     // Trigger
191     //
192     fshowtrg = new TGTextButton(hframedec[2], "Show Data");
193     fshowtrg->Connect("Clicked()","PAMevcontrol", this,"showtrgdata()");
194     if ( !cvar->TRG ) fshowtrg->SetState(kButtonDisabled);
195     hframedec[2]->AddFrame(fshowtrg, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,5,5,5));
196     //
197     // TOF
198     //
199     fchktof = new TGCheckButton(hframedec[3], "Show");
200 mocchiut 1.1 fchktof->Connect("Clicked()","PAMevcontrol", this,"chktof()");
201     if ( cvar->TOF ) fchktof->SetState(kButtonDown);
202 mocchiut 1.3 hframedec[3]->AddFrame(fchktof, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,2,5,5));
203     fshowtof = new TGTextButton(hframedec[3], "Show Data");
204     fshowtof->Connect("Clicked()","PAMevcontrol", this,"showtofdata()");
205     if ( !cvar->TOF ) fshowtof->SetState(kButtonDisabled);
206     hframedec[3]->AddFrame(fshowtof, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,2,5,5,5));
207     //
208     // Tracker
209     //
210     fchktrk = new TGCheckButton(hframedec[4], "Show");
211     fchktrk->Connect("Clicked()","PAMevcontrol",this,"chktrk()");
212     if ( cvar->TRK ) fchktrk->SetState(kButtonDown);
213     hframedec[4]->AddFrame(fchktrk, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,2,5,5));
214     fshowtrk = new TGTextButton(hframedec[4], "Show Data");
215     fshowtrk->Connect("Clicked()","PAMevcontrol", this,"showtrkdata()");
216     if ( !cvar->TRK ) fshowtrk->SetState(kButtonDisabled);
217     hframedec[4]->AddFrame(fshowtrk, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,2,5,5,5));
218     //
219     // AC
220 mocchiut 1.1 //
221 mocchiut 1.3 fchkac = new TGCheckButton(hframedec[5], "Show");
222 mocchiut 1.1 fchkac->Connect("Clicked()","PAMevcontrol", this,"chkac()");
223     if ( cvar->AC ) fchkac->SetState(kButtonDown);
224 mocchiut 1.3 hframedec[5]->AddFrame(fchkac, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,2,5,5));
225     fshowac = new TGTextButton(hframedec[5], "Show Data");
226     fshowac->Connect("Clicked()","PAMevcontrol", this,"showacdata()");
227     if ( !cvar->AC ) fshowac->SetState(kButtonDisabled);
228     hframedec[5]->AddFrame(fshowac, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,2,5,5,5));
229 mocchiut 1.1 //
230 mocchiut 1.3 // Calorimeter
231     //
232     fchkcalo = new TGCheckButton(hframedec[6], "Show");
233     fchkcalo->Connect("Clicked()","PAMevcontrol",this,"chkcalo()");
234     if ( cvar->CALO ) fchkcalo->SetState(kButtonDown);
235     hframedec[6]->AddFrame(fchkcalo, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,2,5,5));
236     fchkcalost = new TGCheckButton(hframedec[6], "Track");
237     fchkcalost->Connect("Clicked()","PAMevcontrol",this,"chkcalost()");
238     if ( cvar->CALO ) fchkcalost->SetState(kButtonUp);
239     hframedec[6]->AddFrame(fchkcalost, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,2,2,5,5));
240     fshowcal = new TGTextButton(hframedec[6], "Show Data");
241     fshowcal->Connect("Clicked()","PAMevcontrol", this,"showcaldata()");
242     if ( !cvar->CALO ) fshowcal->SetState(kButtonDisabled);
243     hframedec[6]->AddFrame(fshowcal, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,2,5,5,5));
244 mocchiut 1.1 //
245 mocchiut 1.3 // S4
246 mocchiut 1.1 //
247 mocchiut 1.3 fchks4 = new TGCheckButton(hframedec[7], "Show");
248 mocchiut 1.1 fchks4->Connect("Clicked()","PAMevcontrol",this,"chks4()");
249     if ( cvar->S4 ) fchks4->SetState(kButtonDown);
250 mocchiut 1.3 hframedec[7]->AddFrame(fchks4, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,2,5,5));
251     fshows4 = new TGTextButton(hframedec[7], "Show Data");
252     fshows4->Connect("Clicked()","PAMevcontrol", this,"shows4data()");
253     if ( !cvar->S4 ) fshows4->SetState(kButtonDisabled);
254     hframedec[7]->AddFrame(fshows4, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,2,5,5,5));
255     //
256     // ND
257 mocchiut 1.1 //
258 mocchiut 1.3 fchknd = new TGCheckButton(hframedec[8], "Show");
259 mocchiut 1.1 fchknd->Connect("Clicked()","PAMevcontrol",this,"chknd()");
260     if ( cvar->ND ) fchknd->SetState(kButtonDown);
261 mocchiut 1.3 hframedec[8]->AddFrame(fchknd, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,2,5,5));
262     fshownd = new TGTextButton(hframedec[8], "Show Data");
263     fshownd->Connect("Clicked()","PAMevcontrol", this,"shownddata()");
264     if ( !cvar->ND ) fshownd->SetState(kButtonDisabled);
265     hframedec[8]->AddFrame(fshownd, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,2,5,5,5));
266     //
267     // Software infos
268     //
269     fshowsi = new TGTextButton(hframedec[9], "Show Data");
270 mocchiut 1.5 fshowsi->Connect("Clicked()","PAMevcontrol", this,"showsidata()");
271 mocchiut 1.3 if ( !cvar->RUN ) fshoworb->SetState(kButtonDisabled);
272     hframedec[9]->AddFrame(fshoworb, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,2,5,5));
273 mocchiut 1.1 //
274 mocchiut 1.3 // All data
275     //
276     fshowall = new TGTextButton(hframedec[10], "Show Data");
277 mocchiut 1.5 fshowall->Connect("Clicked()","PAMevcontrol", this,"showalldata()");
278 mocchiut 1.3 hframedec[10]->AddFrame(fshowall, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,5,5,5));
279     //
280     // for (Int_t fr=0; fr<11; fr++) gf->AddFrame(hframedec[fr], new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,1,1,1,1));
281     //
282     gf->AddFrame(hframedec[11], new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,5,17,17));
283 mocchiut 1.1 //
284 mocchiut 1.3 // for (Int_t fr=0; fr<11; fr++) gf->AddFrame(hframedec[fr],new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,0,5,5,5));
285     // gf->GetLayoutManager()->SetPadBottom(5);
286     // gf->MapSubwindows();
287 mocchiut 1.1 //
288 mocchiut 1.2 fchkinfo = new TGCheckButton(hframe3, "Infos");
289 mocchiut 1.1 fchkinfo->Connect("Clicked()","PAMevcontrol",this,"chkinfo()");
290     if ( cvar->INFOS ) fchkinfo->SetState(kButtonDown);
291 mocchiut 1.3 hframe3->AddFrame(fchkinfo, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,0,5,5,5));
292 mocchiut 1.1 //
293 mocchiut 1.2 fchknames = new TGCheckButton(hframe3, "Names");
294 mocchiut 1.1 fchknames->Connect("Clicked()","PAMevcontrol",this,"chknames()");
295     if ( cvar->VINFOS ) fchknames->SetState(kButtonDown);
296 mocchiut 1.3 hframe3->AddFrame(fchknames, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,5,5,5));
297 mocchiut 1.2 fchkpalette = new TGCheckButton(hframe3, "Palette");
298 mocchiut 1.1 fchkpalette->Connect("Clicked()","PAMevcontrol",this,"chkpalette()");
299     if ( cvar->PALETTE) fchkpalette->SetState(kButtonDown);
300 mocchiut 1.3 hframe3->AddFrame(fchkpalette, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,10,5,5,5));
301     gf2->AddFrame(hframe3, new TGLayoutHints(kLHintsExpandX));
302 mocchiut 1.1 //
303     TGVButtonGroup *group = new TGVButtonGroup(hframe4);
304     bwc0 = new TGRadioButton(group, "Colour");
305     bwc1 = new TGRadioButton(group, "B/W");
306     if ( cvar->bw ){
307     bwc1->SetState(kButtonDown);
308     } else {
309     bwc0->SetState(kButtonDown);
310     };
311     bwc0->Connect("Pressed()", "PAMevcontrol",this,"radiocolor()");
312     bwc1->Connect("Pressed()", "PAMevcontrol",this,"radiobw()");
313 mocchiut 1.4 hframe4->AddFrame(group,new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,2,5,5));
314 mocchiut 1.1 //
315     //
316 mocchiut 1.4 // ftrks4 = new TGCheckButton(hframe5, "Track in S4/ND");
317     // ftrks4->Connect("Clicked()","PAMevcontrol",this,"radiotrack()");
318     // if ( cvar->tracknds4) ftrks4->SetState(kButtonDown);
319     // hframe5->AddFrame(ftrks4, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,2,5,5));
320    
321     fgetl0 = new TGTextButton(hframe5, "Get L0 file");
322     fgetl0->Connect("Clicked()","PAMevcontrol", this,"getl0file()");
323     hframe5->AddFrame(fgetl0, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,5,5,5));
324    
325     ffl0 = new TGCheckButton(hframe5, "Force RAW");
326 mocchiut 1.1 ffl0->Connect("Clicked()","PAMevcontrol",this,"forcel0()");
327     if ( cvar->fl0 ) ffl0->SetState(kButtonDown);
328     if ( !cvar->fl0 ) ffl0->SetState(kButtonUp);
329 mocchiut 1.4 hframe5->AddFrame(ffl0, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,2,5,5,5));
330 mocchiut 1.3 //
331     hframe4->AddFrame(hframe5, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,10,5,5,5));
332     gf2->AddFrame(hframe4, new TGLayoutHints(kLHintsExpandX));
333 mocchiut 1.1 //
334 mocchiut 1.3 cframe1->AddFrame(gf, new TGLayoutHints(kLHintsExpandX,5,5,5,5));
335     // cframe1->Resize(280,10);
336     // cframe1->GetLayoutManager()->SetDefaultHeight(5);
337     // MapWindow();
338 mocchiut 1.1 //
339 mocchiut 1.3 cframe5->AddFrame(gf2, new TGLayoutHints(kLHintsExpandX,5,5,5,5));
340 mocchiut 1.1 //
341     TGHButtonGroup *jgroup = new TGHButtonGroup(htext4);
342     jbwc0 = new TGRadioButton(jgroup, "packet ");
343     jbwc1 = new TGRadioButton(jgroup, "progressive");
344     jbwc1->SetState(kButtonDown);
345     jbwc0->Connect("Pressed()", "PAMevcontrol",this,"radioevent()");
346     jbwc1->Connect("Pressed()", "PAMevcontrol",this,"radioprog()");
347     htext4->AddFrame(jgroup,new TGLayoutHints(kLHintsExpandX,1,1,0,0));
348     //
349     TGTextEntry *fText3 = new TGTextEntry(htext3, new TGTextBuffer(6),-1);
350     TGTextButton *Jump = new TGTextButton(htext3,"go");
351     Jump->Connect("Clicked()","TGTextEntry",fText3,"ReturnPressed()");
352     fText3->Connect("ReturnPressed()", "PAMevcontrol", this,"jumpto()");
353     htext3->AddFrame(new TGLabel(htext3, new TGHotString("number")), new TGLayoutHints(kLHintsExpandX,0,0,1,1));
354     htext3->AddFrame(fText3, new TGLayoutHints(kLHintsExpandX, 0, 8, 0, 0));
355     htext3->AddFrame(Jump, new TGLayoutHints(kLHintsExpandX,0,0,0,0));
356     jumpf->AddFrame(htext4, new TGLayoutHints(kLHintsExpandX,0,0,1,1)); //
357     jumpf->AddFrame(htext3, new TGLayoutHints(kLHintsExpandX,0,0,0,1)); //
358     //
359     cframe3->AddFrame(jumpf,new TGLayoutHints(kLHintsExpandX,5,5,5,5));
360     //
361     fText4 = new TGTextEntry(htexts, new TGTextBuffer(18),-1);
362     TGTextButton *save = new TGTextButton(htextsl,"save");
363     save->Connect("Clicked()","TGTextEntry",fText4,"ReturnPressed()");
364     fText4->Connect("ReturnPressed()", "PAMevcontrol", this,"saveas()");
365     fText4->Connect("TabPressed()", "PAMevcontrol", this,"CompleteText()");
366     htexts->AddFrame(fText4, new TGLayoutHints(kLHintsExpandX, 0, 8, 1, 1));
367     //
368     fCombo = new TGComboBox(htexts, 98);
369     fCombo->AddEntry(".ps", 0);
370     fCombo->AddEntry(".eps", 1);
371     fCombo->AddEntry(".gif", 2);
372     fCombo->AddEntry(".jpg", 3);
373     fCombo->AddEntry(".tiff", 4);
374     fCombo->AddEntry(".xpm", 5);
375     fCombo->AddEntry(".pdf", 6);
376     fCombo->AddEntry(".xml", 7);
377     fCombo->AddEntry(".png", 8);
378     fCombo->AddEntry(".svg", 9);
379     fCombo->AddEntry(".root", 10);
380     fCombo->AddEntry(".C", 11);
381     fCombo->Select(0);
382     fCombo->Resize(50,23);
383     // htexts->AddFrame(fCombo, new TGLayoutHints(kLHintsCenterX | kLHintsTop | kLHintsLeft | kLHintsCenterY | kLHintsExpandX, 0, 8, 1, 1));
384 mocchiut 1.3 htexts->AddFrame(fCombo, new TGLayoutHints(kLHintsExpandY | kLHintsExpandY| kLHintsRight, 2, 2, 2, 1));
385 mocchiut 1.1 //
386     htextsl->AddFrame(save, new TGLayoutHints(kLHintsExpandX,0,0,2,1));
387     savef->AddFrame(htexts, new TGLayoutHints(kLHintsExpandX,0,0,2,5));
388     // savef->AddFrame(htextsl, new TGLayoutHints(kLHintsExpandX,5,2,5,2));
389     savef->AddFrame(htextsl, new TGLayoutHints(kLHintsExpandX,8,0,5,2));
390     //
391     cframe4->AddFrame(savef,new TGLayoutHints(kLHintsExpandX,5,5,5,5));
392     //
393     fHProg1 = new TGHProgressBar(hfrprog, TGProgressBar::kFancy, 260);
394     fHProg1->SetBarColor("green");
395     fHProg1->ShowPosition();
396     hfrprog->AddFrame(fHProg1, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY | kLHintsExpandX,5,5,5,5));
397     //
398     //
399     TGTextButton *prev = new TGTextButton(hframe,"< &Back");
400     prev->Connect("Clicked()","PAMevcontrol",this,"prev()");
401     hframe->AddFrame(prev, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4));
402     //
403     TGTextButton *exit = new TGTextButton(hframe,"E&xit");//,"gApplication->Terminate(0)");
404     exit->Connect("Clicked()","PAMevcontrol",this,"Terminate()");
405     exit->SetToolTipText("Quit the event viewer");
406     hframe->AddFrame(exit, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4));
407     //
408     bstop = new TGTextButton(hframe,"&Stop");
409     bstop->Connect("Clicked()","PAMevcontrol",this,"stop()");
410     hframe->AddFrame(bstop, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4));
411     bstop->SetState(kButtonDisabled);
412     //
413     TGTextButton *next = new TGTextButton(hframe,"&Next >");
414     next->Connect("Clicked()","PAMevcontrol",this,"next()");
415     hframe->AddFrame(next, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4));
416     //
417     //
418     // AddFrame(htext, new TGLayoutHints(kLHintsExpandX,2,2,15,1));
419     AddFrame(cframe2, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
420     AddFrame(cframe1, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
421 mocchiut 1.3 AddFrame(cframe5, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
422 mocchiut 1.1 AddFrame(cframe3, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
423     AddFrame(cframe4, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
424     AddFrame(hfrprog, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
425 mocchiut 1.3 AddFrame(hframe, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
426 mocchiut 1.1 // Set a name to the main frame
427     SetWindowName("PAMELA Event Viewer control panel");
428     // Map all subwindows of main frame
429     MapSubwindows();
430     // Initialize the layout algorithm
431     Resize(GetDefaultSize());
432     // Map main frame
433     MapWindow();
434 mocchiut 1.3 //
435     gf->HideFrame(hframedec[11]);
436     for (Int_t fr=0; fr<11; fr++){
437     gf->AddFrame(hframedec[fr],new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,0,5,5,5));
438     gf->HideFrame(hframedec[fr]);
439     };
440     gf->MapSubwindows();
441     //
442 mocchiut 1.1 }
443    
444     void PAMevcontrol::DIALOG(Int_t ty, TString warn){
445     //
446 mocchiut 1.9 // ty = 0 -> INFO, ty = 1 -> WARNING, ty = 2 -> ERROR
447 mocchiut 1.1 //
448     Int_t retval;
449     TString title;
450     EMsgBoxIcon mb_icon = kMBIconStop;
451 mocchiut 1.10 if ( ty == 2 ){
452     title="ERROR!!";
453     mb_icon = kMBIconStop;
454     new TGMsgBox(gClient->GetRoot(), this, title.Data(), warn.Data(), mb_icon, kMBOk, &retval);
455     } else {
456     if ( ty == 0 ){
457 mocchiut 1.1 title="INFO";
458     mb_icon = kMBIconAsterisk;
459 mocchiut 1.10 };
460     if ( ty == 1 ){
461 mocchiut 1.1 title="WARNING!";
462     mb_icon = kMBIconExclamation;
463 mocchiut 1.10 };
464     const TGPicture *icon_pic;
465     switch (mb_icon) {
466     case kMBIconStop:
467     icon_pic = gClient->GetPicture("mb_stop_s.xpm");
468     if (!icon_pic) Error("TGMsgBox", "mb_stop_s.xpm not found");
469     break;
470    
471     case kMBIconQuestion:
472     icon_pic = gClient->GetPicture("mb_question_s.xpm");
473     if (!icon_pic) Error("TGMsgBox", "mb_question_s.xpm not found");
474     break;
475    
476     case kMBIconExclamation:
477     icon_pic = gClient->GetPicture("mb_exclamation_s.xpm");
478     if (!icon_pic) Error("TGMsgBox", "mb_exclamation_s.xpm not found");
479     break;
480    
481     case kMBIconAsterisk:
482     icon_pic = gClient->GetPicture("mb_asterisk_s.xpm");
483     if (!icon_pic) Error("TGMsgBox", "mb_asterisk_s.xpm not found");
484     break;
485    
486     default:
487     icon_pic = 0;
488     break;
489     }
490     //
491     TGTransientFrame *compofra = new TGTransientFrame(gClient->GetRoot(), 0, 200, 80, kHorizontalFrame);
492     TGHorizontalFrame *fIconFrame = new TGHorizontalFrame(compofra, 98, 78);
493     TGIcon *fIcon = new TGIcon(fIconFrame, icon_pic, icon_pic->GetWidth(), icon_pic->GetHeight());
494     fIconFrame->AddFrame(fIcon, new TGLayoutHints(kLHintsCenterX|kLHintsCenterY, 1, 1, 1, 1));
495     compofra->AddFrame(fIconFrame, new TGLayoutHints(kLHintsCenterX|kLHintsCenterY, 1, 1, 1, 1));
496     //
497     TGHorizontalFrame *fLabelFrame = new TGHorizontalFrame(compofra, 98, 78);
498     TGLabel *la=new TGLabel(fLabelFrame,warn.Data());
499     la->SetTextJustify(kLHintsCenterX);
500     fLabelFrame->AddFrame(la, new TGLayoutHints(kLHintsCenterX|kLHintsCenterY, 1, 1, 1, 1));
501     compofra->AddFrame(fLabelFrame, new TGLayoutHints(kLHintsCenterX|kLHintsCenterY, 1, 1, 1, 1));
502     //
503     compofra->SetWindowName(title.Data());
504     compofra->MapSubwindows();
505     compofra->Resize(compofra->GetDefaultWidth(),80);
506     compofra->CenterOnParent();
507     compofra->MapWindow();
508     //
509     Int_t kkk = 0;
510     while ( kkk < 200 ){
511     gSystem->ProcessEvents();
512     gSystem->Sleep(10);
513     kkk++;
514     };
515     if ( compofra ){
516     la->Delete();
517     fLabelFrame->Delete();
518     fIcon->Delete();
519     fIconFrame->Delete();
520     compofra->DestroyWindow();
521     compofra->Delete();
522     };
523 mocchiut 1.1 };
524 mocchiut 1.10 //
525 mocchiut 1.1 }
526    
527 mocchiut 1.3 void PAMevcontrol::refreshdec(Int_t n){
528     //
529     for (Int_t i=0; i<11; i++){
530     gf->HideFrame(hframedec[i]);
531     };
532     //
533     if ( n < 11 ){
534     gf->ShowFrame(hframedec[n]);
535     };
536     };
537    
538    
539     void PAMevcontrol::showorbdata(){
540 mocchiut 1.5 cvar->showorb = !cvar->showorb;
541     if ( !cvar->showorb ) fshoworb->SetText("Show Data");
542     if ( cvar->showorb ) fshoworb->SetText("Hide Data");
543     // printf("orb \n");
544 mocchiut 1.3 };
545    
546     void PAMevcontrol::showtrgdata(){
547 mocchiut 1.5 cvar->showtrg = !cvar->showtrg;
548     if ( !cvar->showtrg ) fshowtrg->SetText("Show Data");
549     if ( cvar->showtrg ) fshowtrg->SetText("Hide Data");
550     // printf("trg \n");
551 mocchiut 1.3 };
552    
553     void PAMevcontrol::showrundata(){
554 mocchiut 1.5 cvar->showrun = !cvar->showrun;
555     if ( !cvar->showrun ) fshowrun->SetText("Show Data");
556     if ( cvar->showrun ) fshowrun->SetText("Hide Data");
557     // printf("run \n");
558 mocchiut 1.3 };
559    
560     void PAMevcontrol::showcaldata(){
561 mocchiut 1.5 cvar->showcal = !cvar->showcal;
562     if ( !cvar->showcal ) fshowcal->SetText("Show Data");
563     if ( cvar->showcal ) fshowcal->SetText("Hide Data");
564     // printf("cal \n");
565 mocchiut 1.3 };
566    
567     void PAMevcontrol::chkcalost(){
568 mocchiut 1.4 if ( cvar->CALOT ) {
569     cvar->CALOT = 0;
570 mocchiut 1.3 } else {
571 mocchiut 1.4 cvar->CALOT = 1;
572 mocchiut 1.3 };
573     cvar->i--;
574     cvar->nevents = 0;
575     cvar->firstevno = 0;
576     cvar->lastevno = 0;
577     cvar->refresh = true;
578     };
579    
580     void PAMevcontrol::showtrkdata(){
581 mocchiut 1.5 cvar->showtrk = !cvar->showtrk;
582     if ( !cvar->showtrk ) fshowtrk->SetText("Show Data");
583     if ( cvar->showtrk ) fshowtrk->SetText("Hide Data");
584     // printf("trk \n");
585 mocchiut 1.3 };
586    
587     void PAMevcontrol::showtofdata(){
588 mocchiut 1.5 cvar->showtof = !cvar->showtof;
589     if ( !cvar->showtof ) fshowtof->SetText("Show Data");
590     if ( cvar->showtof ) fshowtof->SetText("Hide Data");
591     // printf("tof \n");
592 mocchiut 1.3 };
593    
594     void PAMevcontrol::showacdata(){
595 mocchiut 1.5 cvar->showac = !cvar->showac;
596     if ( !cvar->showac ) fshowac->SetText("Show Data");
597     if ( cvar->showac ) fshowac->SetText("Hide Data");
598     // printf("ac \n");
599 mocchiut 1.3 };
600    
601     void PAMevcontrol::shownddata(){
602 mocchiut 1.5 cvar->shownd = !cvar->shownd;
603     if ( !cvar->shownd ) fshownd->SetText("Show Data");
604     if ( cvar->shownd ) fshownd->SetText("Hide Data");
605     // printf("nd \n");
606 mocchiut 1.3 };
607    
608     void PAMevcontrol::shows4data(){
609 mocchiut 1.5 cvar->shows4 = !cvar->shows4;
610     if ( !cvar->shows4 ) fshows4->SetText("Show Data");
611     if ( cvar->shows4 ) fshows4->SetText("Hide Data");
612     // printf("s4 \n");
613 mocchiut 1.3 };
614    
615     void PAMevcontrol::showsidata(){
616 mocchiut 1.5 cvar->showsi = !cvar->showsi;
617     if ( !cvar->showsi ) fshowsi->SetText("Show Data");
618     if ( cvar->showsi ) fshowsi->SetText("Hide Data");
619     // printf("si \n");
620 mocchiut 1.3 };
621    
622     void PAMevcontrol::showalldata(){
623 mocchiut 1.5 cvar->showall = !cvar->showall;
624     if ( !cvar->showall ) fshowall->SetText("Show Data");
625     if ( cvar->showall ) fshowall->SetText("Hide Data");
626     // printf("all \n");
627 mocchiut 1.3 };
628 mocchiut 1.1
629     void PAMevcontrol::SetFilename() {
630     TGTextEntry *entry = (TGTextEntry*)gTQSender;
631     TString text = entry->GetText();
632     cvar->thefilename=text.Data();
633 mocchiut 1.7 cvar->i = 0;
634 mocchiut 1.1 cvar->nevents = 0;
635     cvar->firstevno = 0;
636     cvar->lastevno = 0;
637     if ( cvar->fl0 ) {
638     cvar->fl0 = false;
639     ffl0->SetState(kButtonUp);
640     };
641     cvar->restart = true;
642     cvar->waitforever = false;
643     }
644    
645 mocchiut 1.4 void PAMevcontrol::getl0file() {
646     //
647     TString host = "mysql://localhost/pamelaprod";
648     TString user = "anonymous";
649     TString psw = "";
650     const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
651     const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
652     const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
653     if ( !pamdbhost ) pamdbhost = "";
654     if ( !pamdbuser ) pamdbuser = "";
655     if ( !pamdbpsw ) pamdbpsw = "";
656     if ( strcmp(pamdbhost,"") ) host = pamdbhost;
657     if ( strcmp(pamdbuser,"") ) user = pamdbuser;
658     if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
659     cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
660     cout<<"Connecting to DB"<<endl;
661     cout<<"HOST "<<host<<endl;
662     cout<<"USER "<<user<<endl;
663     cout<<"PSW "<<psw<<endl;
664     cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
665     TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
666 mocchiut 1.6 //
667     TSQLResult *pResult;
668     TSQLRow *Row;
669     //
670 mocchiut 1.4 if( dbc && dbc->IsConnected() ){
671     //
672 mocchiut 1.6 // Retrieve the file
673 mocchiut 1.4 //
674     if ( clev->file == 2 ){
675 mocchiut 1.6 //
676     // Starting from level2
677     //
678 mocchiut 1.4 GL_ROOT glroot = GL_ROOT();
679     if( !glroot.Query_GL_ROOT(cvar->idroot,dbc) ){
680     //
681     cvar->thefilename= glroot.PATH + glroot.NAME;
682     cvar->nevents = 0;
683     cvar->firstevno = 0;
684     cvar->lastevno = 0;
685     if ( cvar->fl0 ) {
686     cvar->fl0 = false;
687     ffl0->SetState(kButtonUp);
688     };
689     cvar->restart = true;
690     cvar->waitforever = false;
691     //
692     if ( cvar->thefilter != "" ){
693     cvar->thefilter="";
694     cvar->selex = true;
695     };
696 mocchiut 1.6 cvar->i = cvar->EVF + cvar->i ;
697 mocchiut 1.4 //cvar->refresh = true;
698     // cvar->file = 0;
699     //
700 mocchiut 1.6 } else {
701 mocchiut 1.4 stringstream warning;
702     warning.str("");
703     warning << " Problems getting Level0 file ";
704     DIALOG(2,warning.str().c_str());
705     };
706 mocchiut 1.6 } else {
707 mocchiut 1.4 //
708     // starting from L0
709     //
710 mocchiut 1.6 stringstream query;
711     query.str("");
712     query << " SELECT ID FROM GL_ROOT WHERE NAME='"<< gSystem->BaseName(cvar->thefilename.Data()) <<"' order by INSERT_TIME desc limit 1;";
713     // printf(" query is %s \n",query.str().c_str());
714     pResult = dbc->Query(query.str().c_str());
715     Row = pResult->Next();
716     UInt_t idrl0 = 0;
717     if ( Row ){
718     idrl0 = (UInt_t)atoll(Row->GetField(0));
719     };
720     //
721     query.str("");
722     query << " SELECT ID,ID_ROOT_L2,EV_FROM FROM GL_RUN WHERE EV_FROM<="<<cvar->i<<" AND EV_TO>="<< cvar->i<<" AND ID_ROOT_L0="<< idrl0 <<";";
723     // printf(" query is %s \n",query.str().c_str());
724     pResult = dbc->Query(query.str().c_str());
725     Row = pResult->Next();
726     UInt_t idrl2 = 0;
727     UInt_t idrlun = 0;
728     UInt_t evfrom = 0;
729     if ( Row ){
730     idrlun = (UInt_t)atoll(Row->GetField(0));
731     idrl2 = (UInt_t)atoll(Row->GetField(1));
732     evfrom = (UInt_t)atoll(Row->GetField(2));
733     };
734     //
735     query.str("");
736     query << " SELECT ID,NEVENTS FROM GL_RUN WHERE ID_ROOT_L2="<< idrl2 <<" order by RUNHEADER_TIME asc;";
737     // printf(" query is %s \n",query.str().c_str());
738     pResult = dbc->Query(query.str().c_str());
739     Row = pResult->Next();
740     UInt_t coren = 0;
741     while ( Row ){
742     if ( (UInt_t)atoll(Row->GetField(0)) == idrlun ) break;
743     coren += (UInt_t)atoll(Row->GetField(1));
744     Row = pResult->Next();
745     };
746     coren += cvar->i - evfrom;
747     //
748     GL_ROOT glroot = GL_ROOT();
749     if( !glroot.Query_GL_ROOT(idrl2,dbc) ){
750     //
751     cvar->i = coren;
752     //
753     cvar->thefilename= glroot.PATH + glroot.NAME;
754     cvar->nevents = 0;
755     cvar->firstevno = 0;
756     cvar->lastevno = 0;
757     if ( cvar->fl0 ) {
758     cvar->fl0 = false;
759     ffl0->SetState(kButtonUp);
760     };
761     cvar->restart = true;
762     cvar->waitforever = false;
763     //
764     if ( cvar->thefilter != "" ){
765     cvar->thefilter="";
766     cvar->selex = true;
767     };
768     //
769     } else {
770     stringstream warning;
771     warning.str("");
772     warning << " Problems getting Level2 file ";
773     DIALOG(2,warning.str().c_str());
774     };
775     // stringstream warning;
776     // warning.str("");
777     // warning << " Not yet implemented ";
778     // DIALOG(2,warning.str().c_str());
779 mocchiut 1.4 };
780     //
781     } else {
782     stringstream warning;
783     warning.str("");
784     warning << " Problems connectiong to DB! ";
785     DIALOG(2,warning.str().c_str());
786     };
787     dbc->Close();
788     };
789    
790 mocchiut 1.1 void PAMevcontrol::CheckLevel() {
791     if ( clev->file == 2 ){
792     ffl0->SetState(kButtonDisabled);
793 mocchiut 1.4 // if ( !cvar->tracknds4 ) {
794     // ftrks4->SetState(kButtonUp);
795     // } else {
796     // ftrks4->SetState(kButtonDown);
797     // };
798 mocchiut 1.1 } else {
799 mocchiut 1.4 //ftrks4->SetState(kButtonDisabled);
800 mocchiut 1.1 if ( !cvar->fl0 ) {
801     ffl0->SetState(kButtonUp);
802     } else {
803     ffl0->SetState(kButtonDown);
804     };
805     };
806 mocchiut 1.5 if ( clev->file == 2 ){
807     fgetl0->SetText("Get L0 file");
808     } else {
809     fgetl0->SetText("Get L2 file");
810     };
811 mocchiut 1.1 }
812    
813     void PAMevcontrol::SetSearching() {
814     bstop->SetState(kButtonUp);
815     };
816    
817     void PAMevcontrol::StopSearching() {
818     bstop->SetState(kButtonDisabled);
819     };
820    
821 mocchiut 1.2 void PAMevcontrol::RefreshButtons() {
822     if ( cvar->jumprog ){
823     jbwc1->SetState(kButtonDown);
824 mocchiut 1.8 jbwc0->SetState(kButtonUp);
825 mocchiut 1.2 } else {
826 mocchiut 1.8 jbwc1->SetState(kButtonUp);
827 mocchiut 1.2 jbwc0->SetState(kButtonDown);
828     };
829     if ( cvar->fl0 ){
830     ffl0->SetState(kButtonDown);
831     } else {
832     ffl0->SetState(kButtonUp);
833     };
834 mocchiut 1.4 // if ( cvar->tracknds4) ftrks4->SetState(kButtonDown);
835 mocchiut 1.2 if ( cvar->bw ){
836     bwc1->SetState(kButtonDown);
837 mocchiut 1.8 bwc0->SetState(kButtonUp);
838 mocchiut 1.2 } else {
839     bwc0->SetState(kButtonDown);
840 mocchiut 1.8 bwc1->SetState(kButtonUp);
841 mocchiut 1.2 };
842     if ( cvar->PALETTE) fchkpalette->SetState(kButtonDown); else fchkpalette->SetState(kButtonUp);
843     if ( cvar->VINFOS ) fchknames->SetState(kButtonDown); else fchknames->SetState(kButtonUp);
844     if ( cvar->INFOS ) fchkinfo->SetState(kButtonDown); else fchkinfo->SetState(kButtonUp);
845 mocchiut 1.4 //
846 mocchiut 1.3 if ( cvar->CALOT ) fchkcalost->SetState(kButtonDown); else fchkcalost->SetState(kButtonUp);
847 mocchiut 1.4 if ( cvar->CALO ){
848     fchkcalo->SetState(kButtonDown);
849     fshowcal->SetState(kButtonUp);
850     } else {
851     fchkcalo->SetState(kButtonUp);
852     fchkcalost->SetState(kButtonDisabled);
853     fshowcal->SetState(kButtonDisabled);
854     };
855     //
856     if ( cvar->ND ){
857     fchknd->SetState(kButtonDown);
858     fshownd->SetState(kButtonUp);
859     } else {
860     fchknd->SetState(kButtonUp);
861     fshownd->SetState(kButtonDisabled);
862     };
863     //
864     if ( cvar->S4 ){
865     fchks4->SetState(kButtonDown);
866     fshows4->SetState(kButtonUp);
867     } else {
868     fchks4->SetState(kButtonUp);
869     fshows4->SetState(kButtonDisabled);
870     };
871     //
872     if ( cvar->TRK ){
873     fchktrk->SetState(kButtonDown);
874     fshowtrk->SetState(kButtonUp);
875     } else {
876     fchktrk->SetState(kButtonUp);
877     fshowtrk->SetState(kButtonDisabled);
878     }
879     //
880     if ( cvar->AC ){
881     fchkac->SetState(kButtonDown);
882     fshowac->SetState(kButtonUp);
883     } else {
884     fchkac->SetState(kButtonUp);
885     fshowac->SetState(kButtonDisabled);
886     };
887     //
888     if ( cvar->TOF ){
889     fchktof->SetState(kButtonDown);
890     fshowtof->SetState(kButtonUp);
891     } else {
892     fchktof->SetState(kButtonUp);
893     fshowtof->SetState(kButtonDisabled);
894     };
895     //
896     CheckLevel();
897     //
898 mocchiut 1.2 };
899    
900 mocchiut 1.1 void PAMevcontrol::SetFilter() {
901     TGTextEntry *entry = (TGTextEntry*)gTQSender;
902     TString text = entry->GetText();
903     cvar->thefilter=text.Data();
904     cvar->i--;
905     cvar->selex = true;
906     cvar->nevents = 0;
907     cvar->firstevno = 0;
908     cvar->lastevno = 0;
909     cvar->refresh = true;
910     }
911    
912     void PAMevcontrol::CompleteText() {
913     TGTextEntry *entry = (TGTextEntry*)gTQSender;
914     TString text = entry->GetText();
915     Int_t curspos = entry->GetCursorPosition();
916     Int_t ncurspos = 0;
917     TString textrem;
918     stringcopy(textrem,text,curspos,text.Length());
919     text.Resize(curspos);
920     if ( !strcmp(text.Data(),"") ) {
921     stringstream ntext;
922     ntext.str("");
923     ntext << gSystem->ExpandPathName("$HOME");
924     text = ntext.str().c_str();
925     curspos=ntext.str().length();
926     };
927     char *test = gSystem->ExpandPathName(text.Data());
928     const char *dir = gSystem->DirName(test);
929     const char *base = gSystem->BaseName(test);
930     TString lbase = base;
931     Int_t lenbase = lbase.Length();
932     TSystemDirectory *tsd = new TSystemDirectory("",dir);
933     TSystemFile *file;
934     TList *lsmatch = new TList;
935     Int_t numf = 0;
936     Int_t numgo = 0;
937     Int_t charmac = 0;
938     TString tbase;
939     Int_t k = 0;
940     stringstream newtext;
941     TSystemFile *mfile;
942     TSystemFile nfile;
943     TList *lsf = new TList;
944     const char *ctbase;
945     if ( !tsd->GetListOfFiles() ){
946     gVirtualX->Bell(0);
947     goto end;
948     };
949     lsf = tsd->GetListOfFiles();
950     file = (TSystemFile*)lsf->First();
951     //
952     while( (TSystemFile*)lsf->After(file) ){
953     numf++;
954     file = (TSystemFile*)lsf->After(file);
955     if ( !strncmp(file->GetName(),base,lenbase) ){
956     numgo++;
957     lsmatch->AddLast(file);
958     const char *ctbase = file->GetName();
959     tbase = ctbase;
960     charmac = tbase.Length();
961     };
962     };
963     newtext.str("");
964     if ( numgo > 0 ){
965     mfile = (TSystemFile*)lsmatch->First();
966     ctbase = mfile->GetName();
967     while ( (!strcmp(ctbase,"..") || !strcmp(ctbase,".")) && (TSystemFile*)lsmatch->After(mfile) ) {
968     mfile = (TSystemFile*)lsmatch->After(mfile);
969     ctbase = mfile->GetName();
970     };
971     tbase = ctbase;
972     base = ctbase;
973     charmac = tbase.Length();;
974     while( (TSystemFile*)lsmatch->After(mfile) ){
975     mfile = (TSystemFile*)lsmatch->After(mfile);
976     ctbase = mfile->GetName();
977     while ( (!strcmp(ctbase,"..") || !strcmp(ctbase,".")) && (TSystemFile*)lsmatch->After(mfile) ) {
978     mfile = (TSystemFile*)lsmatch->After(mfile);
979     ctbase = mfile->GetName();
980     };
981     tbase = ctbase;
982     k = 0;
983     for ( Int_t i=lenbase; i<=tbase.Length(); i++){
984     if ( !strncmp(tbase.Data(),base,i) && strcmp(tbase.Data(),base) ){
985     k = i;
986     };
987     };
988     if ( k <= charmac){
989     charmac = k;
990     };
991     };
992     gVirtualX->Bell(0);
993     };
994     if ( !charmac ) {
995     gVirtualX->Bell(0);
996     goto end;
997     };
998     tbase.Resize(charmac);
999     if ( !strcmp(dir,"") || !strcmp(dir,"/") ){
1000     newtext << "/" << tbase.Data();
1001     } else {
1002     newtext << dir << "/" << tbase.Data();
1003     };
1004     nfile = TSystemFile(tbase.Data(),dir);
1005     if ( nfile.IsDirectory() && numgo == 1 ) newtext << "/";
1006     ncurspos = newtext.str().length();
1007     if ( textrem.Length() ) newtext << textrem.Data();
1008     entry->SetText(newtext.str().c_str());
1009     entry->SetCursorPosition(ncurspos);
1010     end:
1011     lsf->Clear();
1012     lsmatch->Clear();
1013     }
1014    
1015     void PAMevcontrol::saveas() {
1016     TString text = fText4->GetText();
1017     Int_t sel=fCombo->GetSelected();
1018     TString ty;
1019     switch (sel){
1020     case (0):
1021     ty = ".ps";
1022     break;
1023     case (1):
1024     ty = ".eps";
1025     break;
1026     case (2):
1027     ty = ".gif";
1028     break;
1029     case (3):
1030     ty = ".jpg";
1031     break;
1032     case (4):
1033     ty = ".tiff";
1034     break;
1035     case (5):
1036     ty = ".xpm";
1037     break;
1038     case (6):
1039     ty = ".pdf";
1040     break;
1041     case (7):
1042     ty = ".xml";
1043     break;
1044     case (8):
1045     ty = ".png";
1046     break;
1047     case (9):
1048     ty = ".svg";
1049     break;
1050     case (10):
1051     ty = ".root";
1052     break;
1053     case (11):
1054     ty = ".C";
1055     break;
1056     };
1057     if ( sel == 0 ) ty = ".ps";
1058     stringstream name;
1059     if ( strcmp(text.Data(),"") ){
1060     name.str("");
1061     name << text.Data();
1062     name << ty.Data();
1063     thefigure->SaveAs(name.str().c_str());
1064     name.str("");
1065     name << " Saved as ";
1066     name << text.Data();
1067     name << ty.Data();
1068     DIALOG(0,name.str().c_str());
1069     printf(" Saved as %s%s \n",text.Data(),ty.Data());
1070     };
1071     }
1072    
1073     void PAMevcontrol::increment(float val) {
1074     fHProg1->Reset();
1075     fHProg1->SetPosition(val);
1076     gSystem->ProcessEvents();
1077     }
1078    
1079     void PAMevcontrol::forcel0() {
1080 mocchiut 1.5 cvar->fl0 = !cvar->fl0;
1081     cvar->alrforc = false;
1082     cvar->i--;
1083     cvar->nevents = 0;
1084     cvar->firstevno = 0;
1085     cvar->lastevno = 0;
1086     cvar->refresh = true;
1087 mocchiut 1.1 }
1088    
1089     void PAMevcontrol::clearselfi(){
1090     fText2->SetText("");
1091     }
1092    
1093     void PAMevcontrol::upgrnamfi(){
1094     fText4->SetText(cvar->svas.Data());
1095     fText4->SetCursorPosition(fText4->GetMaxLength());
1096     }
1097    
1098     void PAMevcontrol::jumpto() {
1099     TGTextEntry *entry = (TGTextEntry*)gTQSender;
1100     TString text = entry->GetText();
1101     Int_t j;
1102     j = atoi(text.Data());
1103     if ( cvar->jumprog ){
1104     if ( j < 1 || j > cvar->nevents ) {
1105     printf("\n You can choose between 1 and %i \n",(int)cvar->nevents);
1106     stringstream warning;
1107     warning.str("");
1108     warning << "You can choose between 1 and ";
1109     warning << (int)cvar->nevents;
1110     DIALOG(1,warning.str().c_str());
1111     } else {
1112     stringstream warning;
1113     // warning.str("");
1114     // warning << "Jumping to progressive number ";
1115     // warning << j;
1116     // DIALOG(0,warning.str().c_str());
1117     printf("\n Jumping to progressive number %i\n\n",j);
1118     cvar->i = j-2;
1119     cvar->goon = true;
1120     SetSearching();
1121     };
1122     } else {
1123     if ( j < cvar->firstevno || j > cvar->lastevno ) {
1124     printf("\n You can choose between %i and %i \n",cvar->firstevno,cvar->lastevno);
1125     stringstream warning;
1126     warning.str("");
1127     warning << "You can choose between ";
1128     warning << cvar->firstevno;
1129     warning << " and ";
1130     warning << cvar->lastevno;
1131     DIALOG(1,warning.str().c_str());
1132     } else {
1133     // stringstream warning;
1134     // warning.str("");
1135     // warning << "Jumping to event number ";
1136     // warning << j;
1137     // DIALOG(0,warning.str().c_str());
1138     printf("\n Jumping to packet number %i\n\n",j);
1139     cvar->jumpto = j;
1140     cvar->jumpen = true;
1141     cvar->goon = true;
1142     SetSearching();
1143     };
1144     };
1145     entry->SetText("");
1146     }
1147    
1148     void PAMevcontrol::radioevent() {
1149     cvar->jumprog = false;
1150     }
1151    
1152     void PAMevcontrol::radioprog() {
1153     cvar->jumprog = true;
1154     }
1155    
1156     void PAMevcontrol::radiocolor() {
1157     if ( !cvar->goon ){
1158     if ( cvar->bw ) {
1159     cvar->bw = 0;
1160     cvar->i--;
1161     cvar->goon = true;
1162     };
1163     };
1164     }
1165    
1166     void PAMevcontrol::radiobw() {
1167     if ( !cvar->goon ){
1168     if ( !cvar->bw ) {
1169     cvar->bw = 1;
1170     cvar->i--;
1171     cvar->goon = true;
1172     };
1173     };
1174     }
1175    
1176     void PAMevcontrol::radiotrack() {
1177     if ( cvar->tracknds4 ) {
1178     cvar->tracknds4 = 0;
1179     } else {
1180     cvar->tracknds4 = 1;
1181     };
1182     cvar->i--;
1183     cvar->goon = true;
1184     }
1185    
1186     void PAMevcontrol::chktof() {
1187     if ( cvar->TOF ) {
1188     cvar->TOF = 0;
1189     } else {
1190     cvar->TOF = 1;
1191     };
1192     cvar->i--;
1193     cvar->nevents = 0;
1194     cvar->firstevno = 0;
1195     cvar->lastevno = 0;
1196     cvar->refresh = true;
1197     }
1198    
1199     void PAMevcontrol::chkac() {
1200     if ( cvar->AC ) {
1201     cvar->AC = 0;
1202     } else {
1203     cvar->AC = 1;
1204     };
1205     cvar->i--;
1206     cvar->nevents = 0;
1207     cvar->firstevno = 0;
1208     cvar->lastevno = 0;
1209     cvar->refresh = true;
1210     }
1211    
1212     void PAMevcontrol::chktrk() {
1213     if ( cvar->TRK ) {
1214     cvar->TRK = 0;
1215     } else {
1216     cvar->TRK = 1;
1217     };
1218     cvar->i--;
1219     cvar->nevents = 0;
1220     cvar->firstevno = 0;
1221     cvar->lastevno = 0;
1222     cvar->refresh = true;
1223     }
1224    
1225     void PAMevcontrol::chkcalo() {
1226     if ( cvar->CALO ) {
1227     cvar->CALO = 0;
1228     } else {
1229     cvar->CALO = 1;
1230     };
1231     cvar->i--;
1232     cvar->nevents = 0;
1233     cvar->firstevno = 0;
1234     cvar->lastevno = 0;
1235     cvar->refresh = true;
1236     }
1237    
1238     void PAMevcontrol::chks4() {
1239     if ( cvar->S4 ) {
1240     cvar->S4 = 0;
1241     } else {
1242     cvar->S4 = 1;
1243     };
1244     cvar->i--;
1245     cvar->nevents = 0;
1246     cvar->firstevno = 0;
1247     cvar->lastevno = 0;
1248     cvar->refresh = true;
1249     }
1250    
1251     void PAMevcontrol::chknd() {
1252     if ( cvar->ND ) {
1253     cvar->ND = 0;
1254     } else {
1255     cvar->ND = 1;
1256     };
1257     cvar->i--;
1258     cvar->nevents = 0;
1259     cvar->firstevno = 0;
1260     cvar->lastevno = 0;
1261     cvar->refresh = true;
1262     }
1263    
1264     void PAMevcontrol::chkinfo() {
1265     if ( cvar->INFOS ) {
1266     cvar->INFOS = 0;
1267     } else {
1268     cvar->INFOS = 1;
1269     };
1270     cvar->i--;
1271     cvar->goon = true;
1272     }
1273    
1274     void PAMevcontrol::chknames() {
1275     if ( cvar->VINFOS ) {
1276     cvar->VINFOS = 0;
1277     } else {
1278     cvar->VINFOS = 1;
1279     };
1280     cvar->i--;
1281     cvar->goon = true;
1282     }
1283    
1284     void PAMevcontrol::chkpalette() {
1285     if ( cvar->PALETTE ) {
1286     cvar->PALETTE = 0;
1287     } else {
1288     cvar->PALETTE = 1;
1289     };
1290     cvar->i--;
1291     cvar->goon = true;
1292     }
1293    
1294     void PAMevcontrol::next() {
1295     SetSearching();
1296     if ( cvar->i == cvar->nevents-1 ) {
1297     printf("This is the last event, you can't go forward! \n");
1298     DIALOG(1,"This is the last event!");
1299     } else {
1300     cvar->goon = true;
1301     cvar->doflag = 1;
1302     };
1303     }
1304    
1305     void PAMevcontrol::stop() {
1306     DIALOG(1,"Stop searching");
1307     cvar->doflag = 3;
1308     }
1309    
1310     void PAMevcontrol::prev() {
1311     SetSearching();
1312     if ( cvar->i > 0 ) {
1313     printf("WARNING: going backward!\n\n");
1314     cvar->doflag = 2;
1315     cvar->goon = true;
1316     } else {
1317     printf("This is the first event, you can't go backward! \n");
1318     DIALOG(1,"This is the first event!");
1319     };
1320     }
1321    
1322     void PAMevcontrol::Terminate() {
1323     gSystem->ProcessEvents();
1324     gApplication->Terminate(0);
1325     }
1326    
1327     PAMevcontrol::~PAMevcontrol() {
1328     // Clean up used widgets: frames, buttons, layouthints
1329     Cleanup();
1330     delete this;
1331     }

  ViewVC Help
Powered by ViewVC 1.1.23