Subversion Repositories f9daq

Rev

Rev 167 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
146 f9daq 1
#include "../include/sipmscan.h"
2
#include "../include/workstation.h"
3
 
4
#include <stdio.h>
5
#include <stdlib.h>
6
 
7
// Layout hints
8
TGLayoutHints *f0centerX = new TGLayoutHints(kLHintsCenterX,2,2,2,2);
9
TGLayoutHints *f0leftX = new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2);
10
TGLayoutHints *f0leftXnoleft = new TGLayoutHints(kLHintsLeft | kLHintsTop,0,2,2,2);
11
TGLayoutHints *f0leftXnopad = new TGLayoutHints(kLHintsLeft | kLHintsTop,0,0,0,0);
12
TGLayoutHints *f0leftXpad = new TGLayoutHints(kLHintsLeft | kLHintsTop,12,12,2,2);
13
TGLayoutHints *f0rightX = new TGLayoutHints(kLHintsRight | kLHintsTop,2,2,2,2);
14
TGLayoutHints *f0rightXpad = new TGLayoutHints(kLHintsRight | kLHintsTop,12,12,2,2);
15
TGLayoutHints *f0centerY = new TGLayoutHints(kLHintsCenterY,2,2,2,2);
16
TGLayoutHints *f0center2d = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY,2,2,2,2);
17
TGLayoutHints *f1expandX = new TGLayoutHints(kLHintsExpandX,2,2,2,2);
18
TGLayoutHints *f1expand2d = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,2,2,2,2);
19
TGLayoutHints *f1expandXpad = new TGLayoutHints(kLHintsExpandX,12,12,2,2);
20
 
21
// Edit file window ---------------------------------------------------
22
 
23
// Open a new tab for editing datafile headers
24
void TGAppMainFrame::HeaderEditTab(TGTab *mainTab, bool create, int *tabid)
25
{
26
   unsigned int nrfiles;
27
   ULong_t rcolor, bcolor;
28
   gClient->GetColorByName("red", rcolor);
29
   gClient->GetColorByName("black", bcolor);
30
 
31
   if(create)
32
   {
33
      TGCompositeFrame *fH1, *fV1;
34
      TGHorizontalFrame *fTitle;
35
      TGGroupFrame *fG1;
36
      TGLabel *lab;
37
 
38
      int startTab = mainTab->GetCurrent();
39
      int newTab = mainTab->GetNumberOfTabs();
40
      if(DBGSIG > 1) printf("HeaderEditTab(): Current tab = %d, Nr. of tabs = %d\n", startTab, newTab );
41
 
42
      double numform[6];
43
 
44
      int subgroup[2];
45
      subgroup[0] = mainTab->GetWidth()-10;
46
      subgroup[1] = mainTab->GetHeight()-10;
47
 
48
      TGCompositeFrame *fT1;
49
      fT1 = fTab->AddTab("File header editor");
50
 
51
      // Title label
52
      fTitle = new TGHorizontalFrame(fT1, 100, 25, kFixedHeight | kSunkenFrame);
53
      TGTitleLabel(fT1, fTitle, "File header editor", (Pixel_t)FORECOLOR, (Pixel_t)BACKCOLOR, FONT);
54
      fT1->AddFrame(fTitle, new TGLayoutHints(kLHintsExpandX | kLHintsTop));
55
 
56
      // List view of files that we will edit
57
      if(DBGSIG > 1) printf("HeaderEditTab(): Creating TGListBox *editList -> List box for editing files\n");
58
      editList = new TGListBox(fT1,1);
59
      editList->GetVScrollbar();
60
      editList->Resize(300, (3*subgroup[1]/7)-10 );
61
      fT1->AddFrame(editList, f1expandXpad);
62
 
63
      editList->SetMultipleSelections((multiSelect->widgetChBox[0]->IsOn()));
64
 
65
      // Copy the file list from the analysis tab for clearer view
66
      nrfiles = fileList->GetNumberOfEntries();
67
      printf("Nr. files = %d\n", nrfiles);
68
      for(int i = 0; i < nrfiles; i++)
69
         editList->AddEntry(fileList->GetEntry(i)->GetTitle(), i);
70
 
71
      fH1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kHorizontalFrame);
72
      fV1 = new TGCompositeFrame(fH1, subgroup[0]/2, subgroup[1], kVerticalFrame);
73
      // Time stamp display
74
      if(DBGSIG > 1) printf("HeaderEditTab(): Creating TSubStructure *timeEditDisplay -> Display text Entry (time stamp)\n");
75
      timeEditDisplay = new TSubStructure();
76
      if(timeEditDisplay->TGLabelTEntry(fV1, subgroup[0]/2-4, 30, "Time of measurement:", "", "oneline"))
77
         fV1->AddFrame(timeEditDisplay->outsidebox, f0leftXpad);
78
      timeEditDisplay->widgetTE->SetState(kFALSE);
79
 
80
      // Bias voltage edit
81
      if(DBGSIG > 1) printf("HeaderEditTab(): Creating TSubStructure *biasEdit -> Number entry for bias voltage edit\n");
82
      biasEdit = new TSubStructure();
83
      for(int i = 0; i < 6; i++) numform[i] = 0;
84
      numform[0] = 7; numform[1] = 2;
85
      if(biasEdit->TGCheckNEntry(fV1, subgroup[0]/2, 30, "Bias voltage edit:", 0, 0.00, numform, "left"))
86
         fV1->AddFrame(biasEdit->outsidebox, f0leftXpad);
87
 
88
      // Position edits
89
      if(DBGSIG > 1) printf("HeaderEditTab(): Creating TSubStructure *xPosEdit, *yPosEdit, *zPosEdit -> Number entries for position edit\n");
90
      xPosEdit = new TSubStructure();
91
      for(int i = 0; i < 6; i++) numform[i] = 0;
92
      numform[0] = 9; numform[3] = 2; numform[4] = -100; numform[5] = 215000;
93
      if(xPosEdit->TGCheckNEntry(fV1, subgroup[0]/2, 30, "X position edit:", 0, 0, numform, "left"))
94
         fV1->AddFrame(xPosEdit->outsidebox, f0leftXpad);
95
 
96
      yPosEdit = new TSubStructure();
97
      if(yPosEdit->TGCheckNEntry(fV1, subgroup[0]/2, 30, "Y position edit:", 0, 0, numform, "left"))
98
         fV1->AddFrame(yPosEdit->outsidebox, f0leftXpad);
99
 
100
      zPosEdit = new TSubStructure();
101
      numform[5] = 375000;
102
      if(zPosEdit->TGCheckNEntry(fV1, subgroup[0]/2, 30, "Z position edit:", 0, 0, numform, "left"))
103
         fV1->AddFrame(zPosEdit->outsidebox, f0leftXpad);
104
 
105
      // Temperature edit
106
      if(DBGSIG > 1) printf("HeaderEditTab(): Creating TSubStructure *tempEdit -> Number entry for temperature edit\n");
107
      tempEdit = new TSubStructure();
108
      for(int i = 0; i < 6; i++) numform[i] = 0;
109
      numform[0] = 6; numform[1] = 1;
110
      if(tempEdit->TGCheckNEntry(fV1, subgroup[0]/2, 30, "Temperature edit:", 0, 0.0, numform, "left"))
111
         fV1->AddFrame(tempEdit->outsidebox, f0leftXpad);
112
 
113
      // Angle edit
114
      if(DBGSIG > 1) printf("HeaderEditTab(): Creating TSubStructure *angleEdit -> Number entry for angle edit\n");
115
      angleEdit = new TSubStructure();
116
      for(int i = 0; i < 6; i++) numform[i] = 0;
117
      numform[0] = 7; numform[1] = 2;
118
      if(angleEdit->TGCheckNEntry(fV1, subgroup[0]/2, 30, "Incidence angle edit:", 0, 0.00, numform, "left"))
119
         fV1->AddFrame(angleEdit->outsidebox, f0leftXpad);
120
 
121
      // Laser settings edit
122
      if(DBGSIG > 1) printf("HeaderEditTab(): Creating TSubStructure *laserEdit -> Display text Entry for laser edit\n");
123
      laserEdit = new TSubStructure();
124
      if(laserEdit->TGCheckTEntry(fV1, subgroup[0]/2, 30, "Laser settings edit:", 0, "", "oneline"))
125
         fV1->AddFrame(laserEdit->outsidebox, f0leftXpad);
126
 
127
      // Edit and close buttons
128
      if(DBGSIG > 1) printf("HeaderEditTab(): Creating TSubStructure *editHead -> 2 buttons for either editing the head or closing the tab\n");
129
      editHead = new TSubStructure();
130
      const char *selnames[512] = {"Edit header","Close"};
131
      if(editHead->TGMultiButton(fV1, subgroup[0]/2, 30, 2, selnames, "center"))
132
         fV1->AddFrame(editHead->outsidebox, f0leftXpad);
133
      fH1->AddFrame(fV1, f0leftXnopad);
134
 
135
      fV1 = new TGCompositeFrame(fH1, subgroup[0]/2, subgroup[1], kVerticalFrame);
136
      // Multiple file select
137
      if(DBGSIG > 1) printf("HeaderEditTab(): Creating TSubStructure *editMulti -> 1 Check button to set multi select or not\n");
138
      editMulti = new TSubStructure();
139
      int *checksel;
140
      checksel = new int;
141
      *checksel = multiSelect->widgetChBox[0]->IsDown();
142
      selnames[0] = "Select multiple files";
143
      if(editMulti->TGCheckList(fV1, subgroup[0]/2, 30, 1, selnames, checksel, "vertical", "center"))
144
         fV1->AddFrame(editMulti->outsidebox, f0centerX);
145
 
146
      // Warning information
147
      fG1 = new TGGroupFrame(fV1, "Warnings");
148
      lab = new TGLabel(fG1, "Note: Tick checkbox in front of each header information you wish to change\n(to avoid any unwanted changes, they are unticked by default).");
149
      fG1->AddFrame(lab, f0leftXpad);
150
      lab = new TGLabel(fG1, "Note: When selecting files in the list, the entry fields will update accordingly\nwith information from the selected file (only for those where check\nboxes are not turned on).");
151
      fG1->AddFrame(lab, f0leftXpad);
152
      lab = new TGLabel(fG1, "Warning: Using button \"Edit header\" will edit headers in all files currently\nselected in the above selection list.");
153
      lab->SetTextColor(rcolor);
154
      fG1->AddFrame(lab, f0leftXpad);
155
      if((editMulti->widgetChBox[0]->IsOn()))
156
      {
157
         selectWarn = new TGLabel(fG1, "Warning: Multiple files selected!");
158
         selectWarn->SetTextColor(rcolor);
159
         fG1->AddFrame(selectWarn, f0leftXpad);
160
      }
161
      else
162
      {
163
         selectWarn = new TGLabel(fG1, "Note: Single file selected.      ");
164
         selectWarn->SetTextColor(bcolor);
165
         fG1->AddFrame(selectWarn, f0leftXpad);
166
      }
167
      fV1->AddFrame(fG1, f0centerX);
168
      fH1->AddFrame(fV1, f0centerX);
169
 
170
      // Actions for header editor
171
      editList->Connect("Selected(Int_t)", "TGAppMainFrame", this, "ShowHeaderEdit(Int_t)");
172
      biasEdit->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=1)");
173
      xPosEdit->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=2)");
174
      yPosEdit->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=3)");
175
      zPosEdit->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=4)");
176
      tempEdit->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=5)");
177
      angleEdit->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=6)");
178
      laserEdit->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=7)");
179
      editMulti->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "SetWarnings()");
180
      editHead->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "StartHeaderEdit()");
181
      char cTemp[512];
182
      sprintf(cTemp, "CloseEditTab(=%d)", newTab*100+startTab);
183
      editHead->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, cTemp);
184
 
185
      fT1->AddFrame(fH1, f1expand2d);
186
      fMain->MapSubwindows();
187
      fMain->MapWindow();
188
      fMain->Layout();
189
 
190
      // Initialize the values
191
      for(int i = 0; i < 8; i++)
192
         EditTickToggle(i);
193
 
194
      // Switch to new tab
195
      fTab->SetTab(newTab);
196
 
197
      if(DBGSIG > 1)
198
      {
199
         printf("HeaderEditTab(): New tab objects (Edit Header)\n");
200
         gObjectTable->Print();
201
      }
202
   }
203
   else
204
   {
205
      if(multiSelect->widgetChBox[0]->IsDown())
206
         editMulti->widgetChBox[0]->SetState(kButtonDown);
207
      else
208
         editMulti->widgetChBox[0]->SetState(kButtonUp);
209
 
210
      editList->SetMultipleSelections((editMulti->widgetChBox[0]->IsDown()));
211
 
212
      // Recopy the file list from the analysis tab
213
      nrfiles = fileList->GetNumberOfEntries();
214
      printf("Nr. files = %d\n", nrfiles);
215
      for(int i = 0; i < nrfiles; i++)
216
         editList->AddEntry(fileList->GetEntry(i)->GetTitle(), i);
217
 
218
      SetWarnings();
219
 
220
      // Switch to new tab
221
      fTab->SetTab(*tabid);
222
   }
223
}
224
 
225
// Change the warning when selecting multiple files
226
void TGAppMainFrame::SetWarnings()
227
{
228
   ULong_t rcolor, bcolor;
229
   gClient->GetColorByName("red", rcolor);
230
   gClient->GetColorByName("black", bcolor);
231
 
232
   editList->SetMultipleSelections((editMulti->widgetChBox[0]->IsDown()));
233
 
234
   // Set the warnings
235
   if(editMulti->widgetChBox[0]->IsDown())
236
   {
237
      selectWarn->SetText("Warning: Multiple files selected!");
238
      selectWarn->SetTextColor(rcolor);
239
      selectWarn->SetWrapLength(-1);
240
   }
241
   else
242
   {
243
      selectWarn->SetText("Note: Single file selected.      ");
244
      selectWarn->SetTextColor(bcolor);
245
      selectWarn->SetWrapLength(-1);
246
   }
247
}
248
 
249
// Actions for editing the header
250
void TGAppMainFrame::EditTickToggle(int type)
251
{
252
   // Toggle the edit possibility for header entries
253
 
254
   // Bias voltage
255
   if(type == 1)
256
   {
257
      if(biasEdit->widgetChBox[0]->IsDown()) biasEdit->widgetNE[0]->SetState(kTRUE);
258
      else biasEdit->widgetNE[0]->SetState(kFALSE);
259
   }
260
   // X position
261
   else if(type == 2)
262
   {
263
      if(xPosEdit->widgetChBox[0]->IsDown()) xPosEdit->widgetNE[0]->SetState(kTRUE);
264
      else xPosEdit->widgetNE[0]->SetState(kFALSE);
265
   }
266
   // Y position
267
   else if(type == 3)
268
   {
269
      if(yPosEdit->widgetChBox[0]->IsDown()) yPosEdit->widgetNE[0]->SetState(kTRUE);
270
      else yPosEdit->widgetNE[0]->SetState(kFALSE);
271
   }
272
   // Z position
273
   else if(type == 4)
274
   {
275
      if(zPosEdit->widgetChBox[0]->IsDown()) zPosEdit->widgetNE[0]->SetState(kTRUE);
276
      else zPosEdit->widgetNE[0]->SetState(kFALSE);
277
   }
278
   // Temperature
279
   else if(type == 5)
280
   {
281
      if(tempEdit->widgetChBox[0]->IsDown()) tempEdit->widgetNE[0]->SetState(kTRUE);
282
      else tempEdit->widgetNE[0]->SetState(kFALSE);
283
   }
284
   // Angle
285
   else if(type == 6)
286
   {
287
      if(angleEdit->widgetChBox[0]->IsDown()) angleEdit->widgetNE[0]->SetState(kTRUE);
288
      else angleEdit->widgetNE[0]->SetState(kFALSE);
289
   }
290
   // Laser info
291
   else if(type == 7)
292
   {
293
      if(laserEdit->widgetChBox[0]->IsDown()) laserEdit->widgetTE->SetState(kTRUE);
294
      else laserEdit->widgetTE->SetState(kFALSE);
295
   }
296
}
297
 
298
void TGAppMainFrame::StartHeaderEdit()
299
{
300
   unsigned int nrfiles = editList->GetNumberOfEntries();
301
   TList *files;
302
   // Changelist: Bias, X, Y, Z Positions, Temperature, Angle, Laser info
303
   bool changelist[] = { biasEdit->widgetChBox[0]->IsDown(), xPosEdit->widgetChBox[0]->IsDown(), yPosEdit->widgetChBox[0]->IsDown(), zPosEdit->widgetChBox[0]->IsDown(), tempEdit->widgetChBox[0]->IsDown(), angleEdit->widgetChBox[0]->IsDown(), laserEdit->widgetChBox[0]->IsDown() };
304
 
305
   if( nrfiles > 0 )
306
   {
307
      // check the selected file/files and return its name/their names
308
      files = new TList();
309
      editList->GetSelectedEntries(files);
310
      if(files)
311
      {
312
         for(int i = 0; i < (int)nrfiles; i++)
313
         {
314
            if(files->At(i))
315
            {
316
               if(DBGSIG)
317
                  printf("StartHeaderEdit(): Filename: %s\n", files->At(i)->GetTitle());
318
 
319
               HeaderChange( (char*)(files->At(i)->GetTitle()), changelist );
320
            }
321
         }
322
      }
323
   }
324
}
325
 
326
void TGAppMainFrame::ShowHeaderEdit(int id)
327
{
328
   char cTemp[512];
329
 
330
   // Preparing input file
331
   inroot = TFile::Open(editList->GetEntry(id)->GetTitle(), "READ");
332
 
333
   // Header tree
334
   TTree *header_data;
335
   inroot->GetObject("header_data", header_data);
336
 
337
   // Display branches from header in the entry fields
338
   header_data->SetBranchAddress("timestamp", &evtheader.timestamp);
339
   header_data->GetEntry(0);
340
   header_data->SetBranchAddress("biasvolt", &evtheader.biasvolt);
341
   header_data->GetEntry(0);
342
   header_data->SetBranchAddress("xpos", &evtheader.xpos);
343
   header_data->GetEntry(0);
344
   header_data->SetBranchAddress("ypos", &evtheader.ypos);
345
   header_data->GetEntry(0);
346
   header_data->SetBranchAddress("zpos", &evtheader.zpos);
347
   header_data->GetEntry(0);
348
   header_data->SetBranchAddress("temperature", &evtheader.temperature);
349
   header_data->GetEntry(0);
350
   if( header_data->FindBranch("angle") )
351
   {
352
      header_data->SetBranchAddress("angle", &evtheader.angle);
353
      header_data->GetEntry(0);
354
   }
355
   header_data->SetBranchAddress("laserinfo", &evtheader.laserinfo);
356
   header_data->GetEntry(0);
357
 
358
   GetTime(evtheader.timestamp, cTemp);
359
 
360
   timeEditDisplay->widgetTE->SetText(cTemp);
361
   if(!biasEdit->widgetChBox[0]->IsDown())
362
      biasEdit->widgetNE[0]->SetNumber(evtheader.biasvolt);
363
   if(!xPosEdit->widgetChBox[0]->IsDown())
364
      xPosEdit->widgetNE[0]->SetNumber(evtheader.xpos);
365
   if(!yPosEdit->widgetChBox[0]->IsDown())
366
      yPosEdit->widgetNE[0]->SetNumber(evtheader.ypos);
367
   if(!zPosEdit->widgetChBox[0]->IsDown())
368
      zPosEdit->widgetNE[0]->SetNumber(evtheader.zpos);
369
   if(!tempEdit->widgetChBox[0]->IsDown())
370
      tempEdit->widgetNE[0]->SetNumber(evtheader.temperature);
371
   if(!angleEdit->widgetChBox[0]->IsDown())
372
   {
373
      if( header_data->FindBranch("angle") )
374
         tempEdit->widgetNE[0]->SetNumber(evtheader.angle);
375
      else
376
         tempEdit->widgetNE[0]->SetNumber(0.);
377
   }
378
   if(!laserEdit->widgetChBox[0]->IsDown())
379
      laserEdit->widgetTE->SetText(evtheader.laserinfo);
380
 
381
   delete header_data;
382
   delete inroot;
383
}
384
 
385
void TGAppMainFrame::HeaderChange(char *histfile, bool *changetype)
386
{
387
   int scopeTemp;
388
 
389
   if(DBGSIG)
390
      printf("HeaderChange(): Selected file: %s\n", histfile);
391
 
392
   // Preparing input file and the temporary output file
393
   inroot = TFile::Open(histfile, "READ");
394
 
395
   scopeTemp = inroot->GetListOfKeys()->Contains("scope_data");
396
 
397
   char outname[256];
398
   sprintf(outname, "%s/results/temp.root", rootdir);
399
   outroot = TFile::Open(outname, "RECREATE");
400
 
401
   // Tree structure of input file and output file
402
   TTree *header_data, *meas_data, *scope_data;
403
 
404
   printf("%d\n", inroot->GetListOfKeys()->Contains("header_data"));
405
   printf("%d\n", inroot->GetListOfKeys()->Contains("meas_data"));
406
   printf("%d\n", scopeTemp);
407
 
408
   TTree *new_meas_data, *new_scope_data;
409
   inroot->GetObject("header_data", header_data);
410
   inroot->GetObject("meas_data", meas_data);
411
   new_meas_data = meas_data->CloneTree();
412
   //TTree *new_scope_data;
413
   if(scopeTemp)
414
   {
415
      inroot->GetObject("scope_data", scope_data);
416
      new_scope_data = scope_data->CloneTree();
417
   }
418
   else
419
      printf("No scope_data header found.\n");
420
 
421
   // Save branches from the old header to temporary variables
422
   header_data->SetBranchAddress("nrch", &evtheader.nrch);
423
   header_data->GetEntry(0);
424
   header_data->SetBranchAddress("timestamp", &evtheader.timestamp);
425
   header_data->GetEntry(0);
426
   header_data->SetBranchAddress("biasvolt", &evtheader.biasvolt);
427
   header_data->GetEntry(0);
428
   header_data->SetBranchAddress("xpos", &evtheader.xpos);
429
   header_data->GetEntry(0);
430
   header_data->SetBranchAddress("ypos", &evtheader.ypos);
431
   header_data->GetEntry(0);
432
   header_data->SetBranchAddress("zpos", &evtheader.zpos);
433
   header_data->GetEntry(0);
434
   header_data->SetBranchAddress("temperature", &evtheader.temperature);
435
   header_data->GetEntry(0);
436
   if( header_data->FindBranch("angle") )
437
   {
438
      header_data->SetBranchAddress("angle", &evtheader.angle);
439
      header_data->GetEntry(0);
440
   }
441
   header_data->SetBranchAddress("laserinfo", &evtheader.laserinfo);
442
   header_data->GetEntry(0);
443
 
444
   int itemp[5] = {0,0,0,0,0};
445
   double dtemp[3] = {0.,0.,0.};
446
   char ctemp[256];
447
 
448
   itemp[0] = evtheader.nrch;
449
   itemp[1] = evtheader.timestamp;
450
   itemp[2] = evtheader.xpos;
451
   itemp[3] = evtheader.ypos;
452
   itemp[4] = evtheader.zpos;
453
   dtemp[0] = evtheader.biasvolt;
454
   dtemp[1] = evtheader.temperature;
455
   if( header_data->FindBranch("angle") )
456
      dtemp[2] = evtheader.angle;
457
   else
458
      dtemp[2] = 0.;
459
   sprintf(ctemp, "%s", evtheader.laserinfo);
460
 
461
   delete header_data;
462
   delete meas_data;
463
   if(scopeTemp)
464
      delete scope_data;
465
   delete inroot;
466
 
167 f9daq 467
//printf("HeaderChange(): 6\n");
146 f9daq 468
   // Prepare branches for the new header
469
   TTree *new_header_data = new TTree("header_data", "Header information for the measurement.");
470
   new_header_data->Branch("nrch", &evtheader.nrch, "nrch/I");
471
   new_header_data->Branch("timestamp", &evtheader.timestamp, "timestamp/I");
472
   new_header_data->Branch("biasvolt", &evtheader.biasvolt, "biasvolt/D");
473
   new_header_data->Branch("xpos", &evtheader.xpos, "xpos/I");
474
   new_header_data->Branch("ypos", &evtheader.ypos, "ypos/I");
475
   new_header_data->Branch("zpos", &evtheader.zpos, "zpos/I");
476
   new_header_data->Branch("temperature", &evtheader.temperature, "temperature/D");
477
   new_header_data->Branch("angle", &evtheader.angle, "temperature/D");
478
   new_header_data->Branch("laserinfo", &evtheader.laserinfo, "laserinfo/C");
479
 
167 f9daq 480
//printf("HeaderChange(): 7\n");
146 f9daq 481
   // Save new values (and old ones where we don't want to edit anything)
482
   evtheader.nrch = itemp[0];
483
   evtheader.timestamp = itemp[1];
484
   // Bias voltage
485
   if(changetype[0])
486
      evtheader.biasvolt = (double)biasEdit->widgetNE[0]->GetNumber();
487
   else
488
      evtheader.biasvolt = dtemp[0];
489
   // X pos
490
   if(changetype[1])
491
      evtheader.xpos = (int)xPosEdit->widgetNE[0]->GetNumber();
492
   else
493
      evtheader.xpos = itemp[2];
494
   // Y pos
495
   if(changetype[2])
496
      evtheader.ypos = (int)yPosEdit->widgetNE[0]->GetNumber();
497
   else
498
      evtheader.ypos = itemp[3];
499
   // Z pos
500
   if(changetype[3])
501
      evtheader.zpos = (int)zPosEdit->widgetNE[0]->GetNumber();
502
   else
503
      evtheader.zpos = itemp[4];
504
   // Temperature
505
   if(changetype[4])
506
      evtheader.temperature = (double)tempEdit->widgetNE[0]->GetNumber();
507
   else
508
      evtheader.temperature = dtemp[1];
509
   // Angle
510
   if(changetype[5])
511
      evtheader.angle = (double)angleEdit->widgetNE[0]->GetNumber();
512
   else
513
      evtheader.angle = dtemp[2];
514
   // Laser info
515
   if(changetype[6])
516
      sprintf(evtheader.laserinfo, "%s", laserEdit->widgetTE->GetText());
517
   else
518
      sprintf(evtheader.laserinfo, "%s", ctemp);
519
 
167 f9daq 520
//printf("HeaderChange(): 8\n");
146 f9daq 521
   new_header_data->Fill();
522
 
523
   // Write down the temporary output file
524
   new_header_data->Write();
525
   new_meas_data->Write();
526
   if(scopeTemp)
527
      new_scope_data->Write();
528
 
167 f9daq 529
//printf("HeaderChange(): 9\n");
146 f9daq 530
   delete new_header_data;
531
   delete new_meas_data;
532
   if(scopeTemp)
533
      delete new_scope_data;
534
   delete outroot;
535
 
536
   // Replace the original file with temporary output file (and delete temporary file)
537
   sprintf(outname, "cp -f %s/results/temp.root %s", rootdir, histfile);
538
   system(outname);
539
   sprintf(outname, "rm -f %s/results/temp.root", rootdir);
540
   system(outname);
541
 
542
   printf("Edited header in file: %s\n", histfile);
543
}
544
 
545
void TGAppMainFrame::CloseEditTab(int tabval)
546
{
547
   int curtab = (int)TMath::Floor(tabval/100.);
548
   int oldtab = tabval - curtab*100;
549
 
550
   if(DBGSIG > 1) printf("CloseEditTab(): New tab = %d, old tab = %d\n", curtab, oldtab);
551
 
552
   fTab->RemoveTab(curtab);
553
 
554
   delete editList;
555
   delete timeEditDisplay;
556
   delete biasEdit;
557
   delete xPosEdit;
558
   delete yPosEdit;
559
   delete zPosEdit;
560
   delete tempEdit;
561
   delete angleEdit;
562
   delete laserEdit;
563
   delete editHead;
564
   delete selectWarn;
565
 
566
   for(int i = 0; i < fTab->GetNumberOfTabs(); i++)
567
      if(DBGSIG > 1) printf("CloseEditTab(): Name of tab (%d) = %s\n", i, fTab->GetTabTab(i)->GetString() );
568
 
569
   fTab->SetTab(oldtab);
570
}
571
 
572
// Edit file window ---------------------------------------------------
573
 
574
// Temporary analysis window ------------------------------------------
575
 
576
// Open a new tab for editing datafile headers
577
void TGAppMainFrame::TempAnalysisTab(TGTab *mainTab, bool create, int *tabid, int analtype)
578
{
579
   if(create)
580
   {
581
      TGCompositeFrame *fH1, *fV1;
582
      TGHorizontalFrame *fTitle;
583
      TGGroupFrame *fG1;
584
      TGLabel *lab;
585
 
586
      int startTab = mainTab->GetCurrent();
587
      int newTab = mainTab->GetNumberOfTabs();
588
      if(DBGSIG > 1) printf("TempAnalysisTab(): Current tab = %d, Nr. of tabs = %d\n", startTab, newTab );
589
 
590
      double numform[6];
172 f9daq 591
      double numform2[6];
146 f9daq 592
 
593
      int subgroup[2];
594
      subgroup[0] = mainTab->GetWidth()-10;
595
      subgroup[1] = mainTab->GetHeight()-10;
596
 
597
      TGCompositeFrame *fT1;
598
      fT1 = fTab->AddTab("Analysis edit");
599
 
600
      // Title label
601
      fTitle = new TGHorizontalFrame(fT1, 100, 25, kFixedHeight | kSunkenFrame);
602
      TGTitleLabel(fT1, fTitle, "Analysis edit", (Pixel_t)FORECOLOR, (Pixel_t)BACKCOLOR, FONT);
603
      fT1->AddFrame(fTitle, new TGLayoutHints(kLHintsExpandX | kLHintsTop));
604
 
605
      fV1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kVerticalFrame);
606
      // Temporary analysis canvas
607
      if( (analTab->GetCurrent() == 3) || ((analTab->GetCurrent() == 0) && (intSpect->widgetChBox[0]->IsDown() || intSpect->widgetChBox[1]->IsDown())) )
608
      {
609
         tempAnalysisCanvas = new TRootEmbeddedCanvas("tempAnalysisCanvas",fV1,subgroup[1],5*subgroup[1]/6);
610
         fV1->AddFrame(tempAnalysisCanvas, f0centerX);
611
      }
612
      else
613
      {
614
         tempAnalysisCanvas = new TRootEmbeddedCanvas("tempAnalysisCanvas",fV1,3*subgroup[0]/4,3*subgroup[1]/4);
615
         fV1->AddFrame(tempAnalysisCanvas, f1expandXpad);
616
      }
617
      tempAnalysisCanvas->GetCanvas()->SetGrid();
618
 
172 f9daq 619
      // Specific options for plotting (analtype: 0 = Normal integration, 1 = Edge scans, 2 = Relative PDE, 3 = Breakdown voltage, 4 = Surface scan, 5 = Timing,...)
146 f9daq 620
      // Normal integration
621
      if(analtype == 0)
622
      {
623
      }
624
      // Edge scans
625
      else if(analtype == 1)
626
      {
627
      }
628
      // Relative PDE
629
      else if(analtype == 2)
630
      {
631
         // Running average offset
632
         if(DBGSIG > 1) printf("TempAnalysisTab(): Creating TSubStructure *runningOff -> Set running average offset.\n");
633
         runningOff = new TSubStructure();
634
         for(int i = 0; i < 6; i++) numform[i] = 0;
635
         numform[0] = 5; numform[2] = 2;
636
         if(runningOff->TGLabelNEntry(fV1, subgroup[0]/2-24, 30, "Running average offset:", 0, numform, "center"))
637
            fV1->AddFrame(runningOff->outsidebox, f1expandXpad);
638
 
639
         // Running average setting for plot
640
         if(DBGSIG > 1) printf("TempAnalysisTab(): Creating TSubStructure *runningAver -> Produce running average of a graph.\n");
641
         runningAver = new TSubStructure();
642
         for(int i = 0; i < 6; i++) numform[i] = 0;
643
         numform[0] = 5; numform[2] = 2;
644
         if(runningAver->TGLabelNEntry(fV1, subgroup[0]/2-24, 30, "Running average type (0 to disable):", 0, numform, "center"))
645
            fV1->AddFrame(runningAver->outsidebox, f1expandXpad);
646
 
647
         // Putting a second y-axis to the plot for mean number of photons histogram
648
         if(DBGSIG > 1) printf("TempAnalysisTab(): Creating TSubStructure *secondAxis -> Create second y-axis for mean number of photons.\n");
649
         secondAxis = new TSubStructure();
650
         for(int i = 0; i < 6; i++) numform[i] = 0;
651
         numform[0] = 5; numform[1] = 1; numform[2] = 2;
652
         if(secondAxis->TGLabelNEntry(fV1, subgroup[0]/2-24, 30, "Scale second axis:", 0, numform, "center"))
653
            fV1->AddFrame(secondAxis->outsidebox, f1expandXpad);
654
 
655
         runningAver->widgetNE[0]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "ApplyRunningAver()");
656
         runningOff->widgetNE[0]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "ApplyRunningAver()");
172 f9daq 657
 
658
         ToolTipSetRelativePDE();
146 f9daq 659
      }
172 f9daq 660
      // Breakdown voltage
661
      else if(analtype == 3)
662
      {
663
      }
664
      // Surface scan
665
      else if(analtype == 4)
666
      {
667
         fH1 = new TGCompositeFrame(fV1, subgroup[0], subgroup[1], kHorizontalFrame);
146 f9daq 668
 
172 f9daq 669
         // Values to create a crop of the graph
670
         if(DBGSIG > 1) printf("TempAnalysisTab(): Creating TSubStructure *xCrop -> Set how many X parts of the surface scan to crop.\n");
671
         xCrop = new TSubStructure();
672
         for(int i = 0; i < 6; i++) { numform[i] = 0; numform2[i] = 0; }
673
         if(posUnitsPlot->widgetCB->GetSelected() == 0) { numform[0] = 8; numform[2] = 2; numform2[0] = 8; numform2[2] = 2; }
674
         else if(posUnitsPlot->widgetCB->GetSelected() == 1) { numform[0] = 8; numform[1] = 2; numform[2] = 2; numform2[0] = 8; numform2[1] = 2; numform2[2] = 2; }
675
         if(xCrop->TGLabelDoubleNEntry(fH1, subgroup[0]/4-50, 30, "X axis crop values:", 0, numform, 0, numform2, "center"))
676
            fH1->AddFrame(xCrop->outsidebox, f1expandXpad);
677
 
678
         if(DBGSIG > 1) printf("TempAnalysisTab(): Creating TSubStructure *yCrop -> Set how many Y parts of the surface scan to crop.\n");
679
         yCrop = new TSubStructure();
680
         for(int i = 0; i < 6; i++) { numform[i] = 0; numform2[i] = 0; }
681
         if(posUnitsPlot->widgetCB->GetSelected() == 0) { numform[0] = 8; numform[2] = 2; numform2[0] = 8; numform2[2] = 2; }
682
         else if(posUnitsPlot->widgetCB->GetSelected() == 1) { numform[0] = 8; numform[1] = 2; numform[2] = 2; numform2[0] = 8; numform2[1] = 2; numform2[2] = 2; }
683
         if(yCrop->TGLabelDoubleNEntry(fH1, subgroup[0]/4-50, 30, "Y axis crop values:", 0, numform, 0, numform2, "center"))
684
            fH1->AddFrame(yCrop->outsidebox, f1expandXpad);
685
 
686
         if(DBGSIG > 1) printf("TempAnalysisTab(): Creating TSubStructure *interpolSize -> Set the interpolation step size of the 2D graph.\n");
687
         interpolSize = new TSubStructure();
688
         for(int i = 0; i < 6; i++) { numform[i] = 0; numform2[i] = 0; }
689
         if(posUnitsPlot->widgetCB->GetSelected() == 0) { numform[0] = 8; numform[2] = 2; numform2[0] = 8; numform2[2] = 2; }
690
         else if(posUnitsPlot->widgetCB->GetSelected() == 1) { numform[0] = 8; numform[1] = 2; numform[2] = 2; numform2[0] = 8; numform2[1] = 2; numform2[2] = 2; }
691
         if(interpolSize->TGLabelDoubleNEntry(fH1, subgroup[0]/4+20, 30, "Interpol. step size:", 500, numform, 500, numform2, "center"))
692
            fH1->AddFrame(interpolSize->outsidebox, f1expandXpad);
693
 
694
         if(DBGSIG > 1) printf("TempAnalysisTab(): Creating TSubStructure *updateCrop -> 2 buttons for either updating the crop or making an integral\n");
695
         updateCrop = new TSubStructure();
696
         const char *selnames[512] = {"Update","Integrate surface scan"};
697
         if(updateCrop->TGMultiButton(fH1, subgroup[0]/4-50, 30, 2, selnames, "center"))
698
            fH1->AddFrame(updateCrop->outsidebox, f1expandXpad);
699
 
700
         fV1->AddFrame(fH1, f1expandXpad);
701
 
702
         updateCrop->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "UpdateIntegrateSurface(=0)");
703
         updateCrop->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "UpdateIntegrateSurface(=1)");
704
 
705
         ToolTipSetSurfaceScan();
706
      }
707
 
146 f9daq 708
      // Export and close buttons
709
      if(DBGSIG > 1) printf("TempAnalysisTab(): Creating TSubStructure *exportExitAnalysis -> 2 buttons for either exporting the plot or closing the tab\n");
710
      exportExitAnalysis = new TSubStructure();
711
      const char *selnames[512] = {"Export","Close"};
712
      if(exportExitAnalysis->TGMultiButton(fV1, subgroup[0]/2, 30, 2, selnames, "center"))
713
         fV1->AddFrame(exportExitAnalysis->outsidebox, f1expandXpad);
714
 
715
      // Actions for header editor
716
      char cTemp[512];
167 f9daq 717
      exportExitAnalysis->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "ExportTempAnalysisPlot()");
146 f9daq 718
      sprintf(cTemp, "CloseTempAnalysisTab(=%d)", newTab*100+startTab);
719
      exportExitAnalysis->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, cTemp);
720
 
721
      fT1->AddFrame(fV1, f1expand2d);
722
 
723
      fMain->MapSubwindows();
724
      fMain->MapWindow();
725
      fMain->Layout();
726
 
172 f9daq 727
      ToolTipSetTempAnalysis();
728
 
146 f9daq 729
      // Set tab ID
730
      *tabid = newTab;
731
 
732
      if(DBGSIG > 1)
733
      {
734
         printf("TempAnalysisTab(): New tab objects (Temporary Analysis Header)\n");
735
         gObjectTable->Print();
736
      }
737
   }
738
   else
739
   {
740
      // Switch to new tab
741
      fTab->SetTab(*tabid);
742
   }
743
}
744
 
745
void TGAppMainFrame::CloseTempAnalysisTab(int tabval)
746
{
747
   int curtab = (int)TMath::Floor(tabval/100.);
748
   int oldtab = tabval - curtab*100;
749
 
750
   if(DBGSIG > 1) printf("CloseTempAnalysisTab(): New tab = %d, old tab = %d\n", curtab, oldtab);
751
 
752
   fTab->RemoveTab(curtab);
753
 
754
   delete tempAnalysisCanvas;
755
   delete exportExitAnalysis;
756
 
757
   for(int i = 0; i < fTab->GetNumberOfTabs(); i++)
758
      if(DBGSIG > 1) printf("CloseTempAnalysisTab(): Name of tab (%d) = %s\n", i, fTab->GetTabTab(i)->GetString() );
759
 
760
   fTab->SetTab(oldtab);
761
}
762
 
763
void TGAppMainFrame::ApplyRunningAver()
764
{
765
   TCanvas *gCanvas = tempAnalysisCanvas->GetCanvas();
766
   TList *funcList = (TList*)gCanvas->GetListOfPrimitives();
767
   unsigned int nrfunc = funcList->GetSize();
768
   TGraph *baseGr;
769
   char funcname[512];
770
   int runav = runningAver->widgetNE[0]->GetNumber();
771
   int offx = runningOff->widgetNE[0]->GetNumber();
772
 
773
   if(runav == 0)       // If running average is disabled, don't update the plot
774
      return;
775
 
776
   for(int i = 0; i < nrfunc; i++)
777
   {
778
      sprintf(funcname, "%s", funcList->At(i)->GetName());
779
      if(DBGSIG) printf("ApplyRunningAver(): Function is: %s\n", funcname);
780
 
781
      if(strcmp(funcname,"runaver") == 0)
782
      {
783
         gCanvas->GetPrimitive(funcname)->Delete();
784
         gCanvas->Modified();
785
         gCanvas->Update();
786
      }
787
      else if(strcmp(funcname,"pde") == 0)
788
      {
789
         baseGr = (TGraph*)gCanvas->GetPrimitive(funcname);
790
         int nrpoints = baseGr->GetN();
791
         TGraph *runaver = new TGraph((int)(nrpoints-2*offx)/runav);
792
         runaver->SetName("runaver");
793
         runaver->SetFillColor(1);
794
         runaver->SetLineColor(kBlack);
795
         runaver->SetLineWidth(2);
796
         runaver->SetMarkerColor(kBlack);
797
         int nr = 0, j = 0;
798
         double averx = 0, avery = 0;
799
         double *xval, *yval;
800
         xval = new double[runav];
801
         yval = new double[runav];
802
         while(1)
803
         {
804
            if((nr == (int)nrpoints/runav) || (runav*nr+j+offx > nrpoints-offx)) break;
805
            baseGr->GetPoint(runav*nr+j+offx,xval[j],yval[j]);
806
            if(DBGSIG) printf("ApplyRunningAver(): j = %d: X = %lf, Y = %lf\n", j, xval[j], yval[j]);
807
            averx += xval[j];
808
            avery += yval[j];
809
            j++;
810
            if((j == runav) && (runav*nr+j+offx <= nrpoints-offx))
811
            {
812
               runaver->SetPoint(nr,averx/runav,avery/runav);
813
               if(DBGSIG) printf("ApplyRunningAver(): \t%d: averX = %lf, averY = %lf\n", nr, averx/runav, avery/runav);
814
               nr++;
815
               averx = 0;
816
               avery = 0;
817
               j = 0;
818
            }
819
         }
820
         gCanvas->cd();
821
         runaver->Draw("l same");
822
         gCanvas->Modified();
823
         gCanvas->Update();
824
         delete[] xval;
825
         delete[] yval;
826
      }
827
   }
828
}
829
 
172 f9daq 830
void TGAppMainFrame::UpdateIntegrateSurface(int val)
831
{
832
   TCanvas *gCanvas = tempAnalysisCanvas->GetCanvas();
833
   TList *funcList = (TList*)gCanvas->GetListOfPrimitives();
834
   unsigned int nrfunc = funcList->GetSize();
835
   TGraph2D *baseGr;
836
   char funcname[512];
837
 
838
   double integralValue;
839
   int pointCount;
840
   double xStepsize, yStepsize;
841
   int xInterpol, yInterpol;
842
 
843
   for(int i = 0; i < nrfunc; i++)
844
   {
845
      sprintf(funcname, "%s", funcList->At(i)->GetName());
846
      if(DBGSIG) printf("UpdateIntegrateSurface(): Function is: %s\n", funcname);
847
 
848
      if(strcmp(funcname,"surfscan") == 0)
849
      {
850
         baseGr = (TGraph2D*)gCanvas->GetPrimitive(funcname);
851
 
852
         // Just set the initial things for the surface scan
853
         if(val == -1)
854
         {
855
            xCrop->widgetNE[0]->SetNumber(baseGr->GetXaxis()->GetXmin());
856
            xCrop->widgetNE[1]->SetNumber(baseGr->GetXaxis()->GetXmax());
857
            yCrop->widgetNE[0]->SetNumber(baseGr->GetYaxis()->GetXmin());
858
            yCrop->widgetNE[1]->SetNumber(baseGr->GetYaxis()->GetXmax());
859
 
860
            xCrop->widgetNE[0]->SetLimits(TGNumberFormat::kNELLimitMinMax, baseGr->GetXaxis()->GetXmin(), baseGr->GetXaxis()->GetXmax());
861
            xCrop->widgetNE[1]->SetLimits(TGNumberFormat::kNELLimitMinMax, baseGr->GetXaxis()->GetXmin(), baseGr->GetXaxis()->GetXmax());
862
            yCrop->widgetNE[0]->SetLimits(TGNumberFormat::kNELLimitMinMax, baseGr->GetYaxis()->GetXmin(), baseGr->GetYaxis()->GetXmax());
863
            yCrop->widgetNE[1]->SetLimits(TGNumberFormat::kNELLimitMinMax, baseGr->GetYaxis()->GetXmin(), baseGr->GetYaxis()->GetXmax());
864
         }
865
         // Update the cropping
866
         else if(val == 0)
867
         {
868
            baseGr->GetXaxis()->SetRange(xCrop->widgetNE[0]->GetNumber(), xCrop->widgetNE[1]->GetNumber());
869
            baseGr->GetXaxis()->SetRangeUser(xCrop->widgetNE[0]->GetNumber(), xCrop->widgetNE[1]->GetNumber());
870
            baseGr->GetYaxis()->SetRange(yCrop->widgetNE[0]->GetNumber(), yCrop->widgetNE[1]->GetNumber());
871
            baseGr->GetYaxis()->SetRangeUser(yCrop->widgetNE[0]->GetNumber(), yCrop->widgetNE[1]->GetNumber());
872
 
873
            gCanvas->Modified();
874
            gCanvas->Update();
875
         }
876
         // Make an integral over all histogram values in range
877
         else if(val == 1)
878
         {
879
            integralValue = 0;
880
            pointCount = 0;
881
 
882
            xStepsize = interpolSize->widgetNE[0]->GetNumber();
883
            yStepsize = interpolSize->widgetNE[1]->GetNumber();
884
            xInterpol = (int)((xCrop->widgetNE[1]->GetNumber() - xCrop->widgetNE[0]->GetNumber())/xStepsize);
885
            yInterpol = (int)((yCrop->widgetNE[1]->GetNumber() - yCrop->widgetNE[0]->GetNumber())/yStepsize);
886
 
887
            for(int j = 0; j < xInterpol; j++)
888
            {
889
               for(int k = 0; k < yInterpol; k++)
890
               {
891
                  if((xCrop->widgetNE[0]->GetNumber()+j*xStepsize+xStepsize/2. <= xCrop->widgetNE[1]->GetNumber()) && (yCrop->widgetNE[0]->GetNumber()+k*yStepsize+yStepsize/2. <= yCrop->widgetNE[1]->GetNumber()))
892
                  {
893
                     if(DBGSIG) cout << "Interpolation at (" << xCrop->widgetNE[0]->GetNumber()+j*xStepsize+xStepsize/2. << "," << yCrop->widgetNE[0]->GetNumber()+k*yStepsize+yStepsize/2. << ") is " << baseGr->Interpolate(xCrop->widgetNE[0]->GetNumber()+j*xStepsize+xStepsize/2., yCrop->widgetNE[0]->GetNumber()+k*yStepsize+yStepsize/2.) << endl;
894
                     integralValue += baseGr->Interpolate(xCrop->widgetNE[0]->GetNumber()+j*xStepsize+xStepsize/2., yCrop->widgetNE[0]->GetNumber()+k*yStepsize+yStepsize/2.);
895
                     pointCount++;
896
                  }
897
               }
898
            }
899
 
900
            cout << "Total integral value (" << pointCount << " points) = " << integralValue << endl << "Total normated integral value = " << (double)integralValue/pointCount << endl;
901
 
902
         }
903
      }
904
   }
905
}
906
 
167 f9daq 907
void TGAppMainFrame::ExportTempAnalysisPlot()
908
{
909
   TCanvas *gCanvas = tempAnalysisCanvas->GetCanvas();
910
 
911
   TGFileInfo file_info;
912
   const char *filetypes[] = {"PDF","*.pdf","Encapsulated PostScript (.eps)","*.eps", "JPG/JPEG", "*.jpg", "PNG", "*.png",0,0};
913
   char *cTemp;
914
   file_info.fFileTypes = filetypes;
915
   cTemp = new char[1024];
916
//   sprintf(cTemp, "%s/results", rootdir);
917
//   file_info.fIniDir = StrDup(cTemp);
172 f9daq 918
   file_info.fIniDir = StrDup(currentAnalDir);
167 f9daq 919
   new TGFileDialog(gClient->GetDefaultRoot(), fMain, kFDSave, &file_info);
920
   delete[] cTemp;
921
 
922
   if(file_info.fFilename != NULL)
923
      gCanvas->SaveAs(file_info.fFilename);
924
}
925
 
146 f9daq 926
// Temporary analysis window ------------------------------------------