/[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.13 - (hide annotations) (download)
Fri Apr 13 08:07:31 2012 UTC (12 years, 7 months ago) by mocchiut
Branch: MAIN
CVS Tags: v10REDr01, v10RED, HEAD
Changes since 1.12: +8 -8 lines
Level0 bug fixed, SVL cutoff added to legend

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.12 cframe1 = new TGCompositeFrame(this, 280, 60, 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 mocchiut 1.13 TGHorizontalFrame *htexts = new TGHorizontalFrame(savef,300,800);
119     TGHorizontalFrame *htextsl = new TGHorizontalFrame(cframe4,300,800);
120     TGHorizontalFrame *htext = new TGHorizontalFrame(inputf,300,800);
121     TGHorizontalFrame *htext2 = new TGHorizontalFrame(inputf,300,800);
122     TGHorizontalFrame *htext3 = new TGHorizontalFrame(jumpf,300,800);
123     TGHorizontalFrame *htext4 = new TGHorizontalFrame(jumpf,300,80);
124     TGHorizontalFrame *hframe = new TGHorizontalFrame(this,300,800);
125 mocchiut 1.3 for (Int_t fr=0; fr<12; fr++) hframedec[fr] = new TGHorizontalFrame(gf, 7, 7);
126 mocchiut 1.12 TGHorizontalFrame *hframe3 = new TGHorizontalFrame(gf2, 280, 60);
127 mocchiut 1.3 TGHorizontalFrame *hframe4 = new TGHorizontalFrame(gf2,280,10);
128 mocchiut 1.12 TGVerticalFrame *hframe5 = new TGVerticalFrame(hframe4, 280, 60);
129 mocchiut 1.13 TGHorizontalFrame *hfrprog = new TGHorizontalFrame(this,300,800);
130 mocchiut 1.1 //
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.12 hframe3->AddFrame(fchkinfo, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,0,1,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.12 hframe3->AddFrame(fchknames, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,0,1,5,5));
297    
298 mocchiut 1.2 fchkpalette = new TGCheckButton(hframe3, "Palette");
299 mocchiut 1.1 fchkpalette->Connect("Clicked()","PAMevcontrol",this,"chkpalette()");
300     if ( cvar->PALETTE) fchkpalette->SetState(kButtonDown);
301 mocchiut 1.12 hframe3->AddFrame(fchkpalette, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,0,2,5,5));
302    
303     fchktrigger = new TGCheckButton(hframe3, "Trigger");
304     fchktrigger->Connect("Clicked()","PAMevcontrol",this,"chktrigger()");
305     if ( cvar->PATTRIG) fchktrigger->SetState(kButtonDown);
306     hframe3->AddFrame(fchktrigger, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,1,2,5,5));
307    
308 mocchiut 1.3 gf2->AddFrame(hframe3, new TGLayoutHints(kLHintsExpandX));
309 mocchiut 1.1 //
310     TGVButtonGroup *group = new TGVButtonGroup(hframe4);
311     bwc0 = new TGRadioButton(group, "Colour");
312     bwc1 = new TGRadioButton(group, "B/W");
313     if ( cvar->bw ){
314     bwc1->SetState(kButtonDown);
315     } else {
316     bwc0->SetState(kButtonDown);
317     };
318     bwc0->Connect("Pressed()", "PAMevcontrol",this,"radiocolor()");
319     bwc1->Connect("Pressed()", "PAMevcontrol",this,"radiobw()");
320 mocchiut 1.4 hframe4->AddFrame(group,new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,2,5,5));
321 mocchiut 1.1 //
322     //
323 mocchiut 1.4 // ftrks4 = new TGCheckButton(hframe5, "Track in S4/ND");
324     // ftrks4->Connect("Clicked()","PAMevcontrol",this,"radiotrack()");
325     // if ( cvar->tracknds4) ftrks4->SetState(kButtonDown);
326     // hframe5->AddFrame(ftrks4, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,2,5,5));
327    
328     fgetl0 = new TGTextButton(hframe5, "Get L0 file");
329     fgetl0->Connect("Clicked()","PAMevcontrol", this,"getl0file()");
330     hframe5->AddFrame(fgetl0, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,5,5,5));
331    
332     ffl0 = new TGCheckButton(hframe5, "Force RAW");
333 mocchiut 1.1 ffl0->Connect("Clicked()","PAMevcontrol",this,"forcel0()");
334     if ( cvar->fl0 ) ffl0->SetState(kButtonDown);
335     if ( !cvar->fl0 ) ffl0->SetState(kButtonUp);
336 mocchiut 1.4 hframe5->AddFrame(ffl0, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,2,5,5,5));
337 mocchiut 1.3 //
338     hframe4->AddFrame(hframe5, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,10,5,5,5));
339     gf2->AddFrame(hframe4, new TGLayoutHints(kLHintsExpandX));
340 mocchiut 1.1 //
341 mocchiut 1.3 cframe1->AddFrame(gf, new TGLayoutHints(kLHintsExpandX,5,5,5,5));
342     // cframe1->Resize(280,10);
343     // cframe1->GetLayoutManager()->SetDefaultHeight(5);
344     // MapWindow();
345 mocchiut 1.1 //
346 mocchiut 1.3 cframe5->AddFrame(gf2, new TGLayoutHints(kLHintsExpandX,5,5,5,5));
347 mocchiut 1.1 //
348     TGHButtonGroup *jgroup = new TGHButtonGroup(htext4);
349     jbwc0 = new TGRadioButton(jgroup, "packet ");
350     jbwc1 = new TGRadioButton(jgroup, "progressive");
351     jbwc1->SetState(kButtonDown);
352     jbwc0->Connect("Pressed()", "PAMevcontrol",this,"radioevent()");
353     jbwc1->Connect("Pressed()", "PAMevcontrol",this,"radioprog()");
354     htext4->AddFrame(jgroup,new TGLayoutHints(kLHintsExpandX,1,1,0,0));
355     //
356     TGTextEntry *fText3 = new TGTextEntry(htext3, new TGTextBuffer(6),-1);
357     TGTextButton *Jump = new TGTextButton(htext3,"go");
358     Jump->Connect("Clicked()","TGTextEntry",fText3,"ReturnPressed()");
359     fText3->Connect("ReturnPressed()", "PAMevcontrol", this,"jumpto()");
360     htext3->AddFrame(new TGLabel(htext3, new TGHotString("number")), new TGLayoutHints(kLHintsExpandX,0,0,1,1));
361     htext3->AddFrame(fText3, new TGLayoutHints(kLHintsExpandX, 0, 8, 0, 0));
362     htext3->AddFrame(Jump, new TGLayoutHints(kLHintsExpandX,0,0,0,0));
363     jumpf->AddFrame(htext4, new TGLayoutHints(kLHintsExpandX,0,0,1,1)); //
364     jumpf->AddFrame(htext3, new TGLayoutHints(kLHintsExpandX,0,0,0,1)); //
365     //
366     cframe3->AddFrame(jumpf,new TGLayoutHints(kLHintsExpandX,5,5,5,5));
367     //
368     fText4 = new TGTextEntry(htexts, new TGTextBuffer(18),-1);
369     TGTextButton *save = new TGTextButton(htextsl,"save");
370     save->Connect("Clicked()","TGTextEntry",fText4,"ReturnPressed()");
371     fText4->Connect("ReturnPressed()", "PAMevcontrol", this,"saveas()");
372     fText4->Connect("TabPressed()", "PAMevcontrol", this,"CompleteText()");
373     htexts->AddFrame(fText4, new TGLayoutHints(kLHintsExpandX, 0, 8, 1, 1));
374     //
375     fCombo = new TGComboBox(htexts, 98);
376     fCombo->AddEntry(".ps", 0);
377     fCombo->AddEntry(".eps", 1);
378     fCombo->AddEntry(".gif", 2);
379     fCombo->AddEntry(".jpg", 3);
380     fCombo->AddEntry(".tiff", 4);
381     fCombo->AddEntry(".xpm", 5);
382     fCombo->AddEntry(".pdf", 6);
383     fCombo->AddEntry(".xml", 7);
384     fCombo->AddEntry(".png", 8);
385     fCombo->AddEntry(".svg", 9);
386     fCombo->AddEntry(".root", 10);
387     fCombo->AddEntry(".C", 11);
388     fCombo->Select(0);
389     fCombo->Resize(50,23);
390     // htexts->AddFrame(fCombo, new TGLayoutHints(kLHintsCenterX | kLHintsTop | kLHintsLeft | kLHintsCenterY | kLHintsExpandX, 0, 8, 1, 1));
391 mocchiut 1.3 htexts->AddFrame(fCombo, new TGLayoutHints(kLHintsExpandY | kLHintsExpandY| kLHintsRight, 2, 2, 2, 1));
392 mocchiut 1.1 //
393     htextsl->AddFrame(save, new TGLayoutHints(kLHintsExpandX,0,0,2,1));
394     savef->AddFrame(htexts, new TGLayoutHints(kLHintsExpandX,0,0,2,5));
395     // savef->AddFrame(htextsl, new TGLayoutHints(kLHintsExpandX,5,2,5,2));
396     savef->AddFrame(htextsl, new TGLayoutHints(kLHintsExpandX,8,0,5,2));
397     //
398     cframe4->AddFrame(savef,new TGLayoutHints(kLHintsExpandX,5,5,5,5));
399     //
400     fHProg1 = new TGHProgressBar(hfrprog, TGProgressBar::kFancy, 260);
401     fHProg1->SetBarColor("green");
402     fHProg1->ShowPosition();
403     hfrprog->AddFrame(fHProg1, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY | kLHintsExpandX,5,5,5,5));
404     //
405     //
406     TGTextButton *prev = new TGTextButton(hframe,"< &Back");
407     prev->Connect("Clicked()","PAMevcontrol",this,"prev()");
408     hframe->AddFrame(prev, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4));
409     //
410     TGTextButton *exit = new TGTextButton(hframe,"E&xit");//,"gApplication->Terminate(0)");
411     exit->Connect("Clicked()","PAMevcontrol",this,"Terminate()");
412     exit->SetToolTipText("Quit the event viewer");
413     hframe->AddFrame(exit, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4));
414     //
415     bstop = new TGTextButton(hframe,"&Stop");
416     bstop->Connect("Clicked()","PAMevcontrol",this,"stop()");
417     hframe->AddFrame(bstop, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4));
418     bstop->SetState(kButtonDisabled);
419     //
420     TGTextButton *next = new TGTextButton(hframe,"&Next >");
421     next->Connect("Clicked()","PAMevcontrol",this,"next()");
422     hframe->AddFrame(next, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4));
423     //
424     //
425     // AddFrame(htext, new TGLayoutHints(kLHintsExpandX,2,2,15,1));
426     AddFrame(cframe2, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
427     AddFrame(cframe1, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
428 mocchiut 1.3 AddFrame(cframe5, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
429 mocchiut 1.1 AddFrame(cframe3, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
430     AddFrame(cframe4, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
431     AddFrame(hfrprog, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
432 mocchiut 1.3 AddFrame(hframe, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
433 mocchiut 1.1 // Set a name to the main frame
434     SetWindowName("PAMELA Event Viewer control panel");
435     // Map all subwindows of main frame
436     MapSubwindows();
437     // Initialize the layout algorithm
438     Resize(GetDefaultSize());
439     // Map main frame
440     MapWindow();
441 mocchiut 1.3 //
442     gf->HideFrame(hframedec[11]);
443     for (Int_t fr=0; fr<11; fr++){
444     gf->AddFrame(hframedec[fr],new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,0,5,5,5));
445     gf->HideFrame(hframedec[fr]);
446     };
447     gf->MapSubwindows();
448     //
449 mocchiut 1.1 }
450    
451 mocchiut 1.11 void PAMevcontrol::Refresh(){
452     // bah
453     return;
454     this->Clear();
455     MapSubwindows();
456     // Initialize the layout algorithm
457     Resize(GetDefaultSize());
458     // Map main frame
459     MapWindow();
460     }
461    
462 mocchiut 1.1 void PAMevcontrol::DIALOG(Int_t ty, TString warn){
463     //
464 mocchiut 1.9 // ty = 0 -> INFO, ty = 1 -> WARNING, ty = 2 -> ERROR
465 mocchiut 1.1 //
466     Int_t retval;
467     TString title;
468     EMsgBoxIcon mb_icon = kMBIconStop;
469 mocchiut 1.11 if ( ty == 2 || ty == 3 ){
470     if ( ty == 2 ){
471 mocchiut 1.10 title="ERROR!!";
472     mb_icon = kMBIconStop;
473     new TGMsgBox(gClient->GetRoot(), this, title.Data(), warn.Data(), mb_icon, kMBOk, &retval);
474 mocchiut 1.11 } else {
475     title="HELP";
476     mb_icon = kMBIconQuestion;
477     new TGMsgBox(gClient->GetRoot(), this, title.Data(), warn.Data(), mb_icon, kMBOk, &retval);
478     };
479 mocchiut 1.10 } else {
480     if ( ty == 0 ){
481 mocchiut 1.1 title="INFO";
482     mb_icon = kMBIconAsterisk;
483 mocchiut 1.10 };
484     if ( ty == 1 ){
485 mocchiut 1.1 title="WARNING!";
486     mb_icon = kMBIconExclamation;
487 mocchiut 1.10 };
488 mocchiut 1.11 if ( ty == 4 ){
489     title="DATA";
490     mb_icon = kMBIconExclamation;
491     };
492 mocchiut 1.10 const TGPicture *icon_pic;
493     switch (mb_icon) {
494     case kMBIconStop:
495     icon_pic = gClient->GetPicture("mb_stop_s.xpm");
496     if (!icon_pic) Error("TGMsgBox", "mb_stop_s.xpm not found");
497     break;
498    
499     case kMBIconQuestion:
500     icon_pic = gClient->GetPicture("mb_question_s.xpm");
501     if (!icon_pic) Error("TGMsgBox", "mb_question_s.xpm not found");
502     break;
503    
504     case kMBIconExclamation:
505     icon_pic = gClient->GetPicture("mb_exclamation_s.xpm");
506     if (!icon_pic) Error("TGMsgBox", "mb_exclamation_s.xpm not found");
507     break;
508    
509     case kMBIconAsterisk:
510     icon_pic = gClient->GetPicture("mb_asterisk_s.xpm");
511     if (!icon_pic) Error("TGMsgBox", "mb_asterisk_s.xpm not found");
512     break;
513    
514     default:
515     icon_pic = 0;
516     break;
517     }
518     //
519 mocchiut 1.11 if ( ty == 4 ){// non funziona il recupero dei puntatori a questi oggetti come e` possibile?
520     // gObjectTable->Print();
521     TGLabel *la=dynamic_cast<TGLabel*>(gDirectory->FindObject("la"));
522     TGHorizontalFrame *fLabelFrame=dynamic_cast<TGHorizontalFrame*>(gDirectory->FindObject("fLabelFrame"));
523     TGTransientFrame *compofra=dynamic_cast<TGTransientFrame*>(gDirectory->FindObject("compofra"));
524     if ( la ) la->Delete();
525     if ( fLabelFrame ) fLabelFrame->Delete();
526     if ( compofra ){
527     compofra->DestroyWindow();
528     compofra->Delete();
529     };
530     };
531 mocchiut 1.10 TGTransientFrame *compofra = new TGTransientFrame(gClient->GetRoot(), 0, 200, 80, kHorizontalFrame);
532 mocchiut 1.11 TGHorizontalFrame *fIconFrame = NULL;
533     TGIcon *fIcon = NULL;
534     if ( ty != 4 ){
535     compofra->DontCallClose();
536     fIconFrame = new TGHorizontalFrame(compofra, 98, 78);
537     fIcon = new TGIcon(fIconFrame, icon_pic, icon_pic->GetWidth(), icon_pic->GetHeight());
538     fIconFrame->AddFrame(fIcon, new TGLayoutHints(kLHintsCenterX|kLHintsCenterY, 1, 1, 1, 1));
539     compofra->AddFrame(fIconFrame, new TGLayoutHints(kLHintsCenterX|kLHintsCenterY, 1, 1, 1, 1));
540     };
541 mocchiut 1.10 //
542     TGHorizontalFrame *fLabelFrame = new TGHorizontalFrame(compofra, 98, 78);
543     TGLabel *la=new TGLabel(fLabelFrame,warn.Data());
544     la->SetTextJustify(kLHintsCenterX);
545     fLabelFrame->AddFrame(la, new TGLayoutHints(kLHintsCenterX|kLHintsCenterY, 1, 1, 1, 1));
546     compofra->AddFrame(fLabelFrame, new TGLayoutHints(kLHintsCenterX|kLHintsCenterY, 1, 1, 1, 1));
547     //
548     compofra->SetWindowName(title.Data());
549     compofra->MapSubwindows();
550 mocchiut 1.11 if ( ty != 4 ){
551     compofra->Resize(compofra->GetDefaultWidth(),80);
552     } else {
553     compofra->Resize(compofra->GetDefaultSize());
554     };
555 mocchiut 1.10 compofra->CenterOnParent();
556     compofra->MapWindow();
557     //
558 mocchiut 1.11 if ( ty != 4 ){
559     Int_t kkk = 0;
560     while ( kkk < 200 ){
561     gSystem->ProcessEvents();
562     gSystem->Sleep(10);
563     kkk++;
564     };
565 mocchiut 1.10 };
566 mocchiut 1.11 if ( compofra && ty != 4 ){
567 mocchiut 1.10 la->Delete();
568     fLabelFrame->Delete();
569 mocchiut 1.11 if ( fIcon ) fIcon->Delete();
570     if ( fIconFrame ) fIconFrame->Delete();
571 mocchiut 1.10 compofra->DestroyWindow();
572     compofra->Delete();
573     };
574 mocchiut 1.1 };
575 mocchiut 1.10 //
576 mocchiut 1.1 }
577    
578 mocchiut 1.3 void PAMevcontrol::refreshdec(Int_t n){
579     //
580     for (Int_t i=0; i<11; i++){
581     gf->HideFrame(hframedec[i]);
582     };
583     //
584     if ( n < 11 ){
585     gf->ShowFrame(hframedec[n]);
586     };
587     };
588    
589    
590     void PAMevcontrol::showorbdata(){
591 mocchiut 1.5 cvar->showorb = !cvar->showorb;
592     if ( !cvar->showorb ) fshoworb->SetText("Show Data");
593     if ( cvar->showorb ) fshoworb->SetText("Hide Data");
594     // printf("orb \n");
595 mocchiut 1.3 };
596    
597     void PAMevcontrol::showtrgdata(){
598 mocchiut 1.5 cvar->showtrg = !cvar->showtrg;
599     if ( !cvar->showtrg ) fshowtrg->SetText("Show Data");
600     if ( cvar->showtrg ) fshowtrg->SetText("Hide Data");
601     // printf("trg \n");
602 mocchiut 1.3 };
603    
604     void PAMevcontrol::showrundata(){
605 mocchiut 1.5 cvar->showrun = !cvar->showrun;
606     if ( !cvar->showrun ) fshowrun->SetText("Show Data");
607     if ( cvar->showrun ) fshowrun->SetText("Hide Data");
608     // printf("run \n");
609 mocchiut 1.3 };
610    
611     void PAMevcontrol::showcaldata(){
612 mocchiut 1.5 cvar->showcal = !cvar->showcal;
613     if ( !cvar->showcal ) fshowcal->SetText("Show Data");
614     if ( cvar->showcal ) fshowcal->SetText("Hide Data");
615     // printf("cal \n");
616 mocchiut 1.3 };
617    
618     void PAMevcontrol::chkcalost(){
619 mocchiut 1.4 if ( cvar->CALOT ) {
620     cvar->CALOT = 0;
621 mocchiut 1.3 } else {
622 mocchiut 1.4 cvar->CALOT = 1;
623 mocchiut 1.3 };
624     cvar->i--;
625     cvar->nevents = 0;
626     cvar->firstevno = 0;
627     cvar->lastevno = 0;
628     cvar->refresh = true;
629     };
630    
631     void PAMevcontrol::showtrkdata(){
632 mocchiut 1.5 cvar->showtrk = !cvar->showtrk;
633     if ( !cvar->showtrk ) fshowtrk->SetText("Show Data");
634     if ( cvar->showtrk ) fshowtrk->SetText("Hide Data");
635     // printf("trk \n");
636 mocchiut 1.3 };
637    
638     void PAMevcontrol::showtofdata(){
639 mocchiut 1.5 cvar->showtof = !cvar->showtof;
640     if ( !cvar->showtof ) fshowtof->SetText("Show Data");
641     if ( cvar->showtof ) fshowtof->SetText("Hide Data");
642     // printf("tof \n");
643 mocchiut 1.3 };
644    
645     void PAMevcontrol::showacdata(){
646 mocchiut 1.5 cvar->showac = !cvar->showac;
647     if ( !cvar->showac ) fshowac->SetText("Show Data");
648     if ( cvar->showac ) fshowac->SetText("Hide Data");
649     // printf("ac \n");
650 mocchiut 1.3 };
651    
652     void PAMevcontrol::shownddata(){
653 mocchiut 1.5 cvar->shownd = !cvar->shownd;
654     if ( !cvar->shownd ) fshownd->SetText("Show Data");
655     if ( cvar->shownd ) fshownd->SetText("Hide Data");
656     // printf("nd \n");
657 mocchiut 1.3 };
658    
659     void PAMevcontrol::shows4data(){
660 mocchiut 1.5 cvar->shows4 = !cvar->shows4;
661     if ( !cvar->shows4 ) fshows4->SetText("Show Data");
662     if ( cvar->shows4 ) fshows4->SetText("Hide Data");
663     // printf("s4 \n");
664 mocchiut 1.3 };
665    
666     void PAMevcontrol::showsidata(){
667 mocchiut 1.5 cvar->showsi = !cvar->showsi;
668     if ( !cvar->showsi ) fshowsi->SetText("Show Data");
669     if ( cvar->showsi ) fshowsi->SetText("Hide Data");
670     // printf("si \n");
671 mocchiut 1.3 };
672    
673     void PAMevcontrol::showalldata(){
674 mocchiut 1.5 cvar->showall = !cvar->showall;
675     if ( !cvar->showall ) fshowall->SetText("Show Data");
676     if ( cvar->showall ) fshowall->SetText("Hide Data");
677     // printf("all \n");
678 mocchiut 1.3 };
679 mocchiut 1.1
680     void PAMevcontrol::SetFilename() {
681     TGTextEntry *entry = (TGTextEntry*)gTQSender;
682     TString text = entry->GetText();
683     cvar->thefilename=text.Data();
684 mocchiut 1.7 cvar->i = 0;
685 mocchiut 1.1 cvar->nevents = 0;
686     cvar->firstevno = 0;
687     cvar->lastevno = 0;
688     if ( cvar->fl0 ) {
689     cvar->fl0 = false;
690     ffl0->SetState(kButtonUp);
691     };
692     cvar->restart = true;
693     cvar->waitforever = false;
694     }
695    
696 mocchiut 1.4 void PAMevcontrol::getl0file() {
697     //
698     TString host = "mysql://localhost/pamelaprod";
699     TString user = "anonymous";
700     TString psw = "";
701     const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
702     const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
703     const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
704     if ( !pamdbhost ) pamdbhost = "";
705     if ( !pamdbuser ) pamdbuser = "";
706     if ( !pamdbpsw ) pamdbpsw = "";
707     if ( strcmp(pamdbhost,"") ) host = pamdbhost;
708     if ( strcmp(pamdbuser,"") ) user = pamdbuser;
709     if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
710     cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
711     cout<<"Connecting to DB"<<endl;
712     cout<<"HOST "<<host<<endl;
713     cout<<"USER "<<user<<endl;
714     cout<<"PSW "<<psw<<endl;
715     cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
716     TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
717 mocchiut 1.6 //
718     TSQLResult *pResult;
719     TSQLRow *Row;
720     //
721 mocchiut 1.4 if( dbc && dbc->IsConnected() ){
722     //
723 mocchiut 1.6 // Retrieve the file
724 mocchiut 1.4 //
725     if ( clev->file == 2 ){
726 mocchiut 1.6 //
727     // Starting from level2
728     //
729 mocchiut 1.4 GL_ROOT glroot = GL_ROOT();
730     if( !glroot.Query_GL_ROOT(cvar->idroot,dbc) ){
731     //
732     cvar->thefilename= glroot.PATH + glroot.NAME;
733     cvar->nevents = 0;
734     cvar->firstevno = 0;
735     cvar->lastevno = 0;
736     if ( cvar->fl0 ) {
737     cvar->fl0 = false;
738     ffl0->SetState(kButtonUp);
739     };
740     cvar->restart = true;
741     cvar->waitforever = false;
742     //
743     if ( cvar->thefilter != "" ){
744     cvar->thefilter="";
745     cvar->selex = true;
746     };
747 mocchiut 1.6 cvar->i = cvar->EVF + cvar->i ;
748 mocchiut 1.4 //cvar->refresh = true;
749     // cvar->file = 0;
750     //
751 mocchiut 1.6 } else {
752 mocchiut 1.4 stringstream warning;
753     warning.str("");
754     warning << " Problems getting Level0 file ";
755     DIALOG(2,warning.str().c_str());
756     };
757 mocchiut 1.6 } else {
758 mocchiut 1.4 //
759     // starting from L0
760     //
761 mocchiut 1.6 stringstream query;
762     query.str("");
763     query << " SELECT ID FROM GL_ROOT WHERE NAME='"<< gSystem->BaseName(cvar->thefilename.Data()) <<"' order by INSERT_TIME desc limit 1;";
764     // printf(" query is %s \n",query.str().c_str());
765     pResult = dbc->Query(query.str().c_str());
766     Row = pResult->Next();
767     UInt_t idrl0 = 0;
768     if ( Row ){
769     idrl0 = (UInt_t)atoll(Row->GetField(0));
770     };
771     //
772     query.str("");
773     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 <<";";
774     // printf(" query is %s \n",query.str().c_str());
775     pResult = dbc->Query(query.str().c_str());
776     Row = pResult->Next();
777     UInt_t idrl2 = 0;
778     UInt_t idrlun = 0;
779     UInt_t evfrom = 0;
780     if ( Row ){
781     idrlun = (UInt_t)atoll(Row->GetField(0));
782     idrl2 = (UInt_t)atoll(Row->GetField(1));
783     evfrom = (UInt_t)atoll(Row->GetField(2));
784     };
785     //
786     query.str("");
787     query << " SELECT ID,NEVENTS FROM GL_RUN WHERE ID_ROOT_L2="<< idrl2 <<" order by RUNHEADER_TIME asc;";
788     // printf(" query is %s \n",query.str().c_str());
789     pResult = dbc->Query(query.str().c_str());
790     Row = pResult->Next();
791     UInt_t coren = 0;
792     while ( Row ){
793     if ( (UInt_t)atoll(Row->GetField(0)) == idrlun ) break;
794     coren += (UInt_t)atoll(Row->GetField(1));
795     Row = pResult->Next();
796     };
797     coren += cvar->i - evfrom;
798     //
799     GL_ROOT glroot = GL_ROOT();
800     if( !glroot.Query_GL_ROOT(idrl2,dbc) ){
801     //
802     cvar->i = coren;
803     //
804     cvar->thefilename= glroot.PATH + glroot.NAME;
805     cvar->nevents = 0;
806     cvar->firstevno = 0;
807     cvar->lastevno = 0;
808     if ( cvar->fl0 ) {
809     cvar->fl0 = false;
810     ffl0->SetState(kButtonUp);
811     };
812     cvar->restart = true;
813     cvar->waitforever = false;
814     //
815     if ( cvar->thefilter != "" ){
816     cvar->thefilter="";
817     cvar->selex = true;
818     };
819     //
820     } else {
821     stringstream warning;
822     warning.str("");
823     warning << " Problems getting Level2 file ";
824     DIALOG(2,warning.str().c_str());
825     };
826     // stringstream warning;
827     // warning.str("");
828     // warning << " Not yet implemented ";
829     // DIALOG(2,warning.str().c_str());
830 mocchiut 1.4 };
831     //
832     } else {
833     stringstream warning;
834     warning.str("");
835     warning << " Problems connectiong to DB! ";
836     DIALOG(2,warning.str().c_str());
837     };
838     dbc->Close();
839     };
840    
841 mocchiut 1.1 void PAMevcontrol::CheckLevel() {
842     if ( clev->file == 2 ){
843     ffl0->SetState(kButtonDisabled);
844 mocchiut 1.4 // if ( !cvar->tracknds4 ) {
845     // ftrks4->SetState(kButtonUp);
846     // } else {
847     // ftrks4->SetState(kButtonDown);
848     // };
849 mocchiut 1.1 } else {
850 mocchiut 1.4 //ftrks4->SetState(kButtonDisabled);
851 mocchiut 1.1 if ( !cvar->fl0 ) {
852     ffl0->SetState(kButtonUp);
853     } else {
854     ffl0->SetState(kButtonDown);
855     };
856     };
857 mocchiut 1.5 if ( clev->file == 2 ){
858     fgetl0->SetText("Get L0 file");
859     } else {
860     fgetl0->SetText("Get L2 file");
861     };
862 mocchiut 1.1 }
863    
864     void PAMevcontrol::SetSearching() {
865     bstop->SetState(kButtonUp);
866     };
867    
868     void PAMevcontrol::StopSearching() {
869     bstop->SetState(kButtonDisabled);
870     };
871    
872 mocchiut 1.2 void PAMevcontrol::RefreshButtons() {
873     if ( cvar->jumprog ){
874     jbwc1->SetState(kButtonDown);
875 mocchiut 1.8 jbwc0->SetState(kButtonUp);
876 mocchiut 1.2 } else {
877 mocchiut 1.8 jbwc1->SetState(kButtonUp);
878 mocchiut 1.2 jbwc0->SetState(kButtonDown);
879     };
880     if ( cvar->fl0 ){
881     ffl0->SetState(kButtonDown);
882     } else {
883     ffl0->SetState(kButtonUp);
884     };
885 mocchiut 1.4 // if ( cvar->tracknds4) ftrks4->SetState(kButtonDown);
886 mocchiut 1.2 if ( cvar->bw ){
887     bwc1->SetState(kButtonDown);
888 mocchiut 1.8 bwc0->SetState(kButtonUp);
889 mocchiut 1.2 } else {
890     bwc0->SetState(kButtonDown);
891 mocchiut 1.8 bwc1->SetState(kButtonUp);
892 mocchiut 1.2 };
893 mocchiut 1.12 if ( cvar->PATTRIG) fchktrigger->SetState(kButtonDown); else fchktrigger->SetState(kButtonUp);
894 mocchiut 1.2 if ( cvar->PALETTE) fchkpalette->SetState(kButtonDown); else fchkpalette->SetState(kButtonUp);
895     if ( cvar->VINFOS ) fchknames->SetState(kButtonDown); else fchknames->SetState(kButtonUp);
896     if ( cvar->INFOS ) fchkinfo->SetState(kButtonDown); else fchkinfo->SetState(kButtonUp);
897 mocchiut 1.4 //
898 mocchiut 1.3 if ( cvar->CALOT ) fchkcalost->SetState(kButtonDown); else fchkcalost->SetState(kButtonUp);
899 mocchiut 1.4 if ( cvar->CALO ){
900     fchkcalo->SetState(kButtonDown);
901     fshowcal->SetState(kButtonUp);
902     } else {
903     fchkcalo->SetState(kButtonUp);
904     fchkcalost->SetState(kButtonDisabled);
905     fshowcal->SetState(kButtonDisabled);
906     };
907     //
908     if ( cvar->ND ){
909     fchknd->SetState(kButtonDown);
910     fshownd->SetState(kButtonUp);
911     } else {
912     fchknd->SetState(kButtonUp);
913     fshownd->SetState(kButtonDisabled);
914     };
915     //
916     if ( cvar->S4 ){
917     fchks4->SetState(kButtonDown);
918     fshows4->SetState(kButtonUp);
919     } else {
920     fchks4->SetState(kButtonUp);
921     fshows4->SetState(kButtonDisabled);
922     };
923     //
924     if ( cvar->TRK ){
925     fchktrk->SetState(kButtonDown);
926     fshowtrk->SetState(kButtonUp);
927     } else {
928     fchktrk->SetState(kButtonUp);
929     fshowtrk->SetState(kButtonDisabled);
930     }
931     //
932     if ( cvar->AC ){
933     fchkac->SetState(kButtonDown);
934     fshowac->SetState(kButtonUp);
935     } else {
936     fchkac->SetState(kButtonUp);
937     fshowac->SetState(kButtonDisabled);
938     };
939     //
940     if ( cvar->TOF ){
941     fchktof->SetState(kButtonDown);
942     fshowtof->SetState(kButtonUp);
943     } else {
944     fchktof->SetState(kButtonUp);
945     fshowtof->SetState(kButtonDisabled);
946     };
947     //
948     CheckLevel();
949     //
950 mocchiut 1.2 };
951    
952 mocchiut 1.1 void PAMevcontrol::SetFilter() {
953     TGTextEntry *entry = (TGTextEntry*)gTQSender;
954     TString text = entry->GetText();
955     cvar->thefilter=text.Data();
956     cvar->i--;
957     cvar->selex = true;
958     cvar->nevents = 0;
959     cvar->firstevno = 0;
960     cvar->lastevno = 0;
961     cvar->refresh = true;
962     }
963    
964     void PAMevcontrol::CompleteText() {
965     TGTextEntry *entry = (TGTextEntry*)gTQSender;
966     TString text = entry->GetText();
967     Int_t curspos = entry->GetCursorPosition();
968     Int_t ncurspos = 0;
969     TString textrem;
970     stringcopy(textrem,text,curspos,text.Length());
971     text.Resize(curspos);
972     if ( !strcmp(text.Data(),"") ) {
973     stringstream ntext;
974     ntext.str("");
975     ntext << gSystem->ExpandPathName("$HOME");
976     text = ntext.str().c_str();
977     curspos=ntext.str().length();
978     };
979     char *test = gSystem->ExpandPathName(text.Data());
980     const char *dir = gSystem->DirName(test);
981     const char *base = gSystem->BaseName(test);
982     TString lbase = base;
983     Int_t lenbase = lbase.Length();
984     TSystemDirectory *tsd = new TSystemDirectory("",dir);
985     TSystemFile *file;
986     TList *lsmatch = new TList;
987     Int_t numf = 0;
988     Int_t numgo = 0;
989     Int_t charmac = 0;
990     TString tbase;
991     Int_t k = 0;
992     stringstream newtext;
993     TSystemFile *mfile;
994     TSystemFile nfile;
995     TList *lsf = new TList;
996     const char *ctbase;
997     if ( !tsd->GetListOfFiles() ){
998     gVirtualX->Bell(0);
999     goto end;
1000     };
1001     lsf = tsd->GetListOfFiles();
1002     file = (TSystemFile*)lsf->First();
1003     //
1004     while( (TSystemFile*)lsf->After(file) ){
1005     numf++;
1006     file = (TSystemFile*)lsf->After(file);
1007     if ( !strncmp(file->GetName(),base,lenbase) ){
1008     numgo++;
1009     lsmatch->AddLast(file);
1010     const char *ctbase = file->GetName();
1011     tbase = ctbase;
1012     charmac = tbase.Length();
1013     };
1014     };
1015     newtext.str("");
1016     if ( numgo > 0 ){
1017     mfile = (TSystemFile*)lsmatch->First();
1018     ctbase = mfile->GetName();
1019     while ( (!strcmp(ctbase,"..") || !strcmp(ctbase,".")) && (TSystemFile*)lsmatch->After(mfile) ) {
1020     mfile = (TSystemFile*)lsmatch->After(mfile);
1021     ctbase = mfile->GetName();
1022     };
1023     tbase = ctbase;
1024     base = ctbase;
1025     charmac = tbase.Length();;
1026     while( (TSystemFile*)lsmatch->After(mfile) ){
1027     mfile = (TSystemFile*)lsmatch->After(mfile);
1028     ctbase = mfile->GetName();
1029     while ( (!strcmp(ctbase,"..") || !strcmp(ctbase,".")) && (TSystemFile*)lsmatch->After(mfile) ) {
1030     mfile = (TSystemFile*)lsmatch->After(mfile);
1031     ctbase = mfile->GetName();
1032     };
1033     tbase = ctbase;
1034     k = 0;
1035     for ( Int_t i=lenbase; i<=tbase.Length(); i++){
1036     if ( !strncmp(tbase.Data(),base,i) && strcmp(tbase.Data(),base) ){
1037     k = i;
1038     };
1039     };
1040     if ( k <= charmac){
1041     charmac = k;
1042     };
1043     };
1044     gVirtualX->Bell(0);
1045     };
1046     if ( !charmac ) {
1047     gVirtualX->Bell(0);
1048     goto end;
1049     };
1050     tbase.Resize(charmac);
1051     if ( !strcmp(dir,"") || !strcmp(dir,"/") ){
1052     newtext << "/" << tbase.Data();
1053     } else {
1054     newtext << dir << "/" << tbase.Data();
1055     };
1056     nfile = TSystemFile(tbase.Data(),dir);
1057     if ( nfile.IsDirectory() && numgo == 1 ) newtext << "/";
1058     ncurspos = newtext.str().length();
1059     if ( textrem.Length() ) newtext << textrem.Data();
1060     entry->SetText(newtext.str().c_str());
1061     entry->SetCursorPosition(ncurspos);
1062     end:
1063     lsf->Clear();
1064     lsmatch->Clear();
1065     }
1066    
1067     void PAMevcontrol::saveas() {
1068     TString text = fText4->GetText();
1069     Int_t sel=fCombo->GetSelected();
1070     TString ty;
1071     switch (sel){
1072     case (0):
1073     ty = ".ps";
1074     break;
1075     case (1):
1076     ty = ".eps";
1077     break;
1078     case (2):
1079     ty = ".gif";
1080     break;
1081     case (3):
1082     ty = ".jpg";
1083     break;
1084     case (4):
1085     ty = ".tiff";
1086     break;
1087     case (5):
1088     ty = ".xpm";
1089     break;
1090     case (6):
1091     ty = ".pdf";
1092     break;
1093     case (7):
1094     ty = ".xml";
1095     break;
1096     case (8):
1097     ty = ".png";
1098     break;
1099     case (9):
1100     ty = ".svg";
1101     break;
1102     case (10):
1103     ty = ".root";
1104     break;
1105     case (11):
1106     ty = ".C";
1107     break;
1108     };
1109     if ( sel == 0 ) ty = ".ps";
1110     stringstream name;
1111     if ( strcmp(text.Data(),"") ){
1112     name.str("");
1113     name << text.Data();
1114     name << ty.Data();
1115     thefigure->SaveAs(name.str().c_str());
1116     name.str("");
1117     name << " Saved as ";
1118     name << text.Data();
1119     name << ty.Data();
1120     DIALOG(0,name.str().c_str());
1121     printf(" Saved as %s%s \n",text.Data(),ty.Data());
1122     };
1123     }
1124    
1125     void PAMevcontrol::increment(float val) {
1126     fHProg1->Reset();
1127     fHProg1->SetPosition(val);
1128     gSystem->ProcessEvents();
1129     }
1130    
1131     void PAMevcontrol::forcel0() {
1132 mocchiut 1.5 cvar->fl0 = !cvar->fl0;
1133     cvar->alrforc = false;
1134     cvar->i--;
1135     cvar->nevents = 0;
1136     cvar->firstevno = 0;
1137     cvar->lastevno = 0;
1138     cvar->refresh = true;
1139 mocchiut 1.1 }
1140    
1141     void PAMevcontrol::clearselfi(){
1142     fText2->SetText("");
1143     }
1144    
1145     void PAMevcontrol::upgrnamfi(){
1146     fText4->SetText(cvar->svas.Data());
1147     fText4->SetCursorPosition(fText4->GetMaxLength());
1148     }
1149    
1150     void PAMevcontrol::jumpto() {
1151     TGTextEntry *entry = (TGTextEntry*)gTQSender;
1152     TString text = entry->GetText();
1153     Int_t j;
1154     j = atoi(text.Data());
1155     if ( cvar->jumprog ){
1156     if ( j < 1 || j > cvar->nevents ) {
1157     printf("\n You can choose between 1 and %i \n",(int)cvar->nevents);
1158     stringstream warning;
1159     warning.str("");
1160     warning << "You can choose between 1 and ";
1161     warning << (int)cvar->nevents;
1162     DIALOG(1,warning.str().c_str());
1163     } else {
1164     stringstream warning;
1165     // warning.str("");
1166     // warning << "Jumping to progressive number ";
1167     // warning << j;
1168     // DIALOG(0,warning.str().c_str());
1169     printf("\n Jumping to progressive number %i\n\n",j);
1170     cvar->i = j-2;
1171     cvar->goon = true;
1172     SetSearching();
1173     };
1174     } else {
1175     if ( j < cvar->firstevno || j > cvar->lastevno ) {
1176     printf("\n You can choose between %i and %i \n",cvar->firstevno,cvar->lastevno);
1177     stringstream warning;
1178     warning.str("");
1179     warning << "You can choose between ";
1180     warning << cvar->firstevno;
1181     warning << " and ";
1182     warning << cvar->lastevno;
1183     DIALOG(1,warning.str().c_str());
1184     } else {
1185     // stringstream warning;
1186     // warning.str("");
1187     // warning << "Jumping to event number ";
1188     // warning << j;
1189     // DIALOG(0,warning.str().c_str());
1190     printf("\n Jumping to packet number %i\n\n",j);
1191     cvar->jumpto = j;
1192     cvar->jumpen = true;
1193     cvar->goon = true;
1194     SetSearching();
1195     };
1196     };
1197     entry->SetText("");
1198     }
1199    
1200     void PAMevcontrol::radioevent() {
1201     cvar->jumprog = false;
1202     }
1203    
1204     void PAMevcontrol::radioprog() {
1205     cvar->jumprog = true;
1206     }
1207    
1208     void PAMevcontrol::radiocolor() {
1209     if ( !cvar->goon ){
1210     if ( cvar->bw ) {
1211     cvar->bw = 0;
1212     cvar->i--;
1213     cvar->goon = true;
1214     };
1215     };
1216     }
1217    
1218     void PAMevcontrol::radiobw() {
1219     if ( !cvar->goon ){
1220     if ( !cvar->bw ) {
1221     cvar->bw = 1;
1222     cvar->i--;
1223     cvar->goon = true;
1224     };
1225     };
1226     }
1227    
1228     void PAMevcontrol::radiotrack() {
1229     if ( cvar->tracknds4 ) {
1230     cvar->tracknds4 = 0;
1231     } else {
1232     cvar->tracknds4 = 1;
1233     };
1234     cvar->i--;
1235     cvar->goon = true;
1236     }
1237    
1238     void PAMevcontrol::chktof() {
1239     if ( cvar->TOF ) {
1240     cvar->TOF = 0;
1241     } else {
1242     cvar->TOF = 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::chkac() {
1252     if ( cvar->AC ) {
1253     cvar->AC = 0;
1254     } else {
1255     cvar->AC = 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::chktrk() {
1265     if ( cvar->TRK ) {
1266     cvar->TRK = 0;
1267     } else {
1268     cvar->TRK = 1;
1269     };
1270     cvar->i--;
1271     cvar->nevents = 0;
1272     cvar->firstevno = 0;
1273     cvar->lastevno = 0;
1274     cvar->refresh = true;
1275     }
1276    
1277     void PAMevcontrol::chkcalo() {
1278     if ( cvar->CALO ) {
1279     cvar->CALO = 0;
1280     } else {
1281     cvar->CALO = 1;
1282     };
1283     cvar->i--;
1284     cvar->nevents = 0;
1285     cvar->firstevno = 0;
1286     cvar->lastevno = 0;
1287     cvar->refresh = true;
1288     }
1289    
1290     void PAMevcontrol::chks4() {
1291     if ( cvar->S4 ) {
1292     cvar->S4 = 0;
1293     } else {
1294     cvar->S4 = 1;
1295     };
1296     cvar->i--;
1297     cvar->nevents = 0;
1298     cvar->firstevno = 0;
1299     cvar->lastevno = 0;
1300     cvar->refresh = true;
1301     }
1302    
1303     void PAMevcontrol::chknd() {
1304     if ( cvar->ND ) {
1305     cvar->ND = 0;
1306     } else {
1307     cvar->ND = 1;
1308     };
1309     cvar->i--;
1310     cvar->nevents = 0;
1311     cvar->firstevno = 0;
1312     cvar->lastevno = 0;
1313     cvar->refresh = true;
1314     }
1315    
1316     void PAMevcontrol::chkinfo() {
1317     if ( cvar->INFOS ) {
1318     cvar->INFOS = 0;
1319     } else {
1320     cvar->INFOS = 1;
1321     };
1322     cvar->i--;
1323     cvar->goon = true;
1324     }
1325    
1326     void PAMevcontrol::chknames() {
1327     if ( cvar->VINFOS ) {
1328     cvar->VINFOS = 0;
1329     } else {
1330     cvar->VINFOS = 1;
1331     };
1332     cvar->i--;
1333     cvar->goon = true;
1334     }
1335    
1336     void PAMevcontrol::chkpalette() {
1337     if ( cvar->PALETTE ) {
1338     cvar->PALETTE = 0;
1339     } else {
1340     cvar->PALETTE = 1;
1341     };
1342     cvar->i--;
1343     cvar->goon = true;
1344     }
1345    
1346 mocchiut 1.12 void PAMevcontrol::chktrigger() {
1347     if ( cvar->PATTRIG ) {
1348     cvar->PATTRIG = 0;
1349     } else {
1350     cvar->PATTRIG = 1;
1351     };
1352     cvar->i--;
1353     cvar->goon = true;
1354     }
1355    
1356 mocchiut 1.1 void PAMevcontrol::next() {
1357     SetSearching();
1358     if ( cvar->i == cvar->nevents-1 ) {
1359     printf("This is the last event, you can't go forward! \n");
1360     DIALOG(1,"This is the last event!");
1361     } else {
1362     cvar->goon = true;
1363     cvar->doflag = 1;
1364     };
1365     }
1366    
1367     void PAMevcontrol::stop() {
1368     DIALOG(1,"Stop searching");
1369     cvar->doflag = 3;
1370     }
1371    
1372     void PAMevcontrol::prev() {
1373     SetSearching();
1374     if ( cvar->i > 0 ) {
1375     printf("WARNING: going backward!\n\n");
1376     cvar->doflag = 2;
1377     cvar->goon = true;
1378     } else {
1379     printf("This is the first event, you can't go backward! \n");
1380     DIALOG(1,"This is the first event!");
1381     };
1382     }
1383    
1384     void PAMevcontrol::Terminate() {
1385     gSystem->ProcessEvents();
1386     gApplication->Terminate(0);
1387     }
1388    
1389     PAMevcontrol::~PAMevcontrol() {
1390     // Clean up used widgets: frames, buttons, layouthints
1391     Cleanup();
1392     delete this;
1393     }

  ViewVC Help
Powered by ViewVC 1.1.23