1 |
andersj |
1.1 |
// example.C
|
2 |
|
|
#include <TGClient.h>
|
3 |
|
|
#include <TCanvas.h>
|
4 |
|
|
#include <TF1.h>
|
5 |
|
|
#include <TRandom.h>
|
6 |
|
|
#include <TGButton.h>
|
7 |
|
|
#include <TGButtonGroup.h>
|
8 |
|
|
#include <TGTextEntry.h>
|
9 |
|
|
#include <TGFrame.h>
|
10 |
|
|
#include <TGLabel.h>
|
11 |
|
|
#include <TGFileDialog.h>
|
12 |
|
|
#include <TRootEmbeddedCanvas.h>
|
13 |
|
|
#include <RQ_OBJECT.h>
|
14 |
|
|
#include "PlotAllDisplay.h"
|
15 |
|
|
#include "HistoManager.h"
|
16 |
|
|
|
17 |
|
|
#include <string.h>
|
18 |
|
|
#include <sys/types.h>
|
19 |
|
|
#include <sys/stat.h>
|
20 |
|
|
|
21 |
|
|
class PlotAllMenu {
|
22 |
|
|
RQ_OBJECT("PlotAllMenu")
|
23 |
|
|
private:
|
24 |
|
|
TGMainFrame *fMain;
|
25 |
|
|
TRootEmbeddedCanvas *fEcanvas;
|
26 |
|
|
TGRadioButton* fET[HistoManager::NUMEVTTYPES];
|
27 |
|
|
TGRadioButton* fFT[HistoManager::NUMHISTTYPES];
|
28 |
|
|
TGRadioButton* fVT[2];
|
29 |
|
|
TGRadioButton* fTBT[2];
|
30 |
|
|
TGRadioButton* fDoE[1];
|
31 |
|
|
TGCheckButton *checkbut,*elecbut,*topbut;
|
32 |
|
|
TGTextEntry* iphiEntry, *ietaEntry, *runnoEntry, * fiberEntry, *fiberChanEntry, *crateEntry, *SlotEntry;
|
33 |
|
|
PlotAllDisplay* theDisplay;
|
34 |
|
|
const char *username_;
|
35 |
|
|
public:
|
36 |
|
|
PlotAllMenu(const TGWindow *p,UInt_t w,UInt_t h, const char *username);
|
37 |
|
|
virtual ~PlotAllMenu();
|
38 |
|
|
void DoSelector();
|
39 |
|
|
void DoCrateSelector();
|
40 |
|
|
void DoDraw();
|
41 |
|
|
void DoBrowse();
|
42 |
|
|
void DoProcessRunNumber();
|
43 |
|
|
};
|
44 |
|
|
|
45 |
|
|
PlotAllMenu::PlotAllMenu(const TGWindow *p,UInt_t w,UInt_t h,
|
46 |
|
|
const char *username) {
|
47 |
|
|
theDisplay=0;
|
48 |
|
|
// Create a main frame
|
49 |
|
|
fMain = new TGMainFrame(p,w,h);
|
50 |
|
|
|
51 |
|
|
/***************************************************************
|
52 |
|
|
* Create a vertical frame widget for File Selection objects *
|
53 |
|
|
***************************************************************/
|
54 |
|
|
|
55 |
|
|
TGGroupFrame* fileselgf=new TGGroupFrame(fMain,"File Selection",kVerticalFrame);
|
56 |
|
|
fileselgf->SetLayoutManager(new TGMatrixLayout(fileselgf,0,2,5,5));
|
57 |
|
|
|
58 |
|
|
// first row
|
59 |
|
|
TGTextButton *processrn = new TGTextButton(fileselgf,"Process");
|
60 |
|
|
processrn->Connect("Clicked()","PlotAllMenu",this,"DoProcessRunNumber()");
|
61 |
|
|
fileselgf->AddFrame(processrn, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
|
62 |
|
|
|
63 |
|
|
TGHorizontalFrame *hframe1 = new TGHorizontalFrame(fileselgf,200,40);
|
64 |
|
|
hframe1->AddFrame(new TGLabel(hframe1," Run Number "));
|
65 |
|
|
runnoEntry=new TGTextEntry(hframe1,"12345 ");
|
66 |
|
|
hframe1->AddFrame(runnoEntry);
|
67 |
|
|
|
68 |
|
|
fileselgf->AddFrame(hframe1, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
|
69 |
|
|
|
70 |
|
|
// second row
|
71 |
|
|
fileselgf->AddFrame(new TGLabel(fileselgf," or "));
|
72 |
|
|
fileselgf->AddFrame(new TGLabel(fileselgf," "));
|
73 |
|
|
|
74 |
|
|
// third row
|
75 |
|
|
TGTextButton *browse = new TGTextButton(fileselgf,"Browse for file...");
|
76 |
|
|
browse->Connect("Clicked()","PlotAllMenu",this,"DoBrowse()");
|
77 |
|
|
fileselgf->AddFrame(browse, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
|
78 |
|
|
checkbut = new TGCheckButton(fileselgf,"Force re-processing");
|
79 |
|
|
fileselgf->AddFrame(checkbut, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
|
80 |
|
|
|
81 |
|
|
fMain->AddFrame(fileselgf, new TGLayoutHints(kLHintsCenterX,2,2,2,2));
|
82 |
|
|
|
83 |
|
|
/*************************************************************************
|
84 |
|
|
* Create a vertical frame widget for Plot parameter Selection objects *
|
85 |
|
|
*************************************************************************/
|
86 |
|
|
|
87 |
|
|
TGGroupFrame* plotselgf=new TGGroupFrame(fMain,"Plot Selection",kHorizontalFrame);
|
88 |
|
|
//plotselgf->SetLayoutManager(new TGMatrixLayout(plotselgf,0,2,5,5));
|
89 |
|
|
|
90 |
|
|
// first row:
|
91 |
|
|
// Create Selection widget
|
92 |
|
|
|
93 |
|
|
TGButtonGroup* ebg=new TGButtonGroup(plotselgf,"Event Type",kVerticalFrame);
|
94 |
|
|
|
95 |
|
|
fET[0]=new TGRadioButton(ebg,"Other");
|
96 |
|
|
fET[1]=new TGRadioButton(ebg,"Pedestal");
|
97 |
|
|
fET[2]=new TGRadioButton(ebg,"LED");
|
98 |
|
|
fET[3]=new TGRadioButton(ebg,"Laser");
|
99 |
|
|
fET[4]=new TGRadioButton(ebg,"Beam");
|
100 |
|
|
|
101 |
|
|
plotselgf->AddFrame(ebg, new TGLayoutHints(kLHintsCenterX)); // ,5,5,3,4));
|
102 |
|
|
|
103 |
|
|
TGButtonGroup* fbg=new TGButtonGroup(plotselgf,"Flavor Type",kVerticalFrame);
|
104 |
|
|
fFT[0]=new TGRadioButton(fbg,"Energy");
|
105 |
|
|
fFT[1]=new TGRadioButton(fbg,"Time");
|
106 |
|
|
fFT[2]=new TGRadioButton(fbg,"Pulse Shape");
|
107 |
|
|
fFT[3]=new TGRadioButton(fbg,"ADC");
|
108 |
|
|
|
109 |
|
|
plotselgf->AddFrame(fbg, new TGLayoutHints(kLHintsCenterX)); // ,5,5,3,4));
|
110 |
|
|
|
111 |
|
|
TGButtonGroup* vssbg=new TGButtonGroup(plotselgf,"VS Plot Stat",kHorizontalFrame);
|
112 |
|
|
fVT[0]=new TGRadioButton(vssbg,"Mean");
|
113 |
|
|
fVT[1]=new TGRadioButton(vssbg,"RMS");
|
114 |
|
|
|
115 |
|
|
plotselgf->AddFrame(vssbg, new TGLayoutHints(kLHintsCenterX)); // ,5,5,3,4));
|
116 |
|
|
|
117 |
|
|
fMain->AddFrame(plotselgf);
|
118 |
|
|
|
119 |
|
|
TGGroupFrame* gf=new TGGroupFrame(fMain,"Channel Selection",kVerticalFrame);
|
120 |
|
|
gf->SetLayoutManager(new TGMatrixLayout(gf,0,2,10,10));
|
121 |
|
|
gf->AddFrame(new TGLabel(gf," IPhi "));
|
122 |
|
|
iphiEntry=new TGTextEntry(gf,"0 ");
|
123 |
|
|
gf->AddFrame(iphiEntry);
|
124 |
|
|
gf->AddFrame(new TGLabel(gf," IEta "));
|
125 |
|
|
ietaEntry=new TGTextEntry(gf,"0 ");
|
126 |
|
|
gf->AddFrame(ietaEntry);
|
127 |
|
|
TGTextButton *selector = new TGTextButton(gf,"Visual Selector");
|
128 |
|
|
selector->Connect("Clicked()","PlotAllMenu",this,"DoSelector()");
|
129 |
|
|
gf->AddFrame(selector,new TGLayoutHints(kLHintsCenterX,5,5,3,4));
|
130 |
|
|
|
131 |
|
|
fMain->AddFrame(gf);
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
TGGroupFrame* ef=new TGGroupFrame(fMain,"Electronics Selection",kVerticalFrame);
|
135 |
|
|
ef->SetLayoutManager(new TGMatrixLayout(ef,0,4,10,10));
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
elecbut = new TGCheckButton(ef,"Use ElecId");
|
139 |
|
|
ef->AddFrame(elecbut, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
|
140 |
|
|
ef->AddFrame(new TGLabel(ef,""));
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
ef->AddFrame(new TGLabel(ef," Fiber "));
|
144 |
|
|
fiberEntry=new TGTextEntry(ef,"-1 ");
|
145 |
|
|
ef->AddFrame(fiberEntry);
|
146 |
|
|
ef->AddFrame(new TGLabel(ef," Fiber Chan"));
|
147 |
|
|
fiberChanEntry=new TGTextEntry(ef,"-1 ");
|
148 |
|
|
ef->AddFrame(fiberChanEntry);
|
149 |
|
|
ef->AddFrame(new TGLabel(ef," Crate "));
|
150 |
|
|
crateEntry=new TGTextEntry(ef," 2 ");
|
151 |
|
|
ef->AddFrame(crateEntry);
|
152 |
|
|
ef->AddFrame(new TGLabel(ef," HTR FPGA "));
|
153 |
|
|
SlotEntry=new TGTextEntry(ef,"16b ");
|
154 |
|
|
ef->AddFrame(SlotEntry);
|
155 |
|
|
|
156 |
|
|
#if 0
|
157 |
|
|
TGButtonGroup* topbot=new TGButtonGroup(ef,"Top or Bottom",kHorizontalFrame);
|
158 |
|
|
fTBT[0]=new TGRadioButton(topbot,"Bottom");
|
159 |
|
|
fTBT[1]=new TGRadioButton(topbot,"Top");
|
160 |
|
|
|
161 |
|
|
ef->AddFrame(topbot, new TGLayoutHints(kLHintsCenterX));
|
162 |
|
|
#endif
|
163 |
|
|
|
164 |
|
|
TGTextButton *CrateSelector = new TGTextButton(ef,"Visual Selector");
|
165 |
|
|
CrateSelector->Connect("Clicked()","PlotAllMenu",this,"DoCrateSelector()");
|
166 |
|
|
ef->AddFrame(CrateSelector,new TGLayoutHints(kLHintsCenterX,5,5,3,4));
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
fMain->AddFrame(ef);
|
170 |
|
|
|
171 |
|
|
// Create a horizontal frame widget with buttons
|
172 |
|
|
TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain,200,40);
|
173 |
|
|
|
174 |
|
|
TGTextButton *draw = new TGTextButton(hframe,"&Draw");
|
175 |
|
|
draw->Connect("Clicked()","PlotAllMenu",this,"DoDraw()");
|
176 |
|
|
hframe->AddFrame(draw, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
|
177 |
|
|
|
178 |
|
|
|
179 |
|
|
TGTextButton *exit = new TGTextButton(hframe,"&Exit",
|
180 |
|
|
"gApplication->Terminate(0)");
|
181 |
|
|
hframe->AddFrame(exit, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
|
182 |
|
|
fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2));
|
183 |
|
|
// Set a name to the main frame
|
184 |
|
|
fMain->SetWindowName("Plot Menu for HCAL");
|
185 |
|
|
// Map all subwindows of main frame
|
186 |
|
|
fMain->MapSubwindows();
|
187 |
|
|
// Initialize the layout algorithm
|
188 |
|
|
fMain->Resize(fMain->GetDefaultSize());
|
189 |
|
|
// Map main frame
|
190 |
|
|
fMain->MapWindow();
|
191 |
|
|
|
192 |
|
|
username_ = username;
|
193 |
|
|
}
|
194 |
|
|
|
195 |
|
|
void PlotAllMenu::DoSelector() {
|
196 |
|
|
|
197 |
|
|
int iev=0;
|
198 |
|
|
int ifl=0;
|
199 |
|
|
int ipstat=0;
|
200 |
|
|
for(int i=0; i<HistoManager::NUMEVTTYPES; i++) {
|
201 |
|
|
if (fET[i]->IsOn()) iev=i;
|
202 |
|
|
if (i<HistoManager::NUMHISTTYPES && fFT[i]->IsOn()) ifl=i;
|
203 |
|
|
if (i<2 && fVT[i]->IsOn()) ipstat=i;
|
204 |
|
|
}
|
205 |
|
|
theDisplay->displaySelector(iev,ifl,ipstat);
|
206 |
|
|
}
|
207 |
|
|
|
208 |
|
|
void PlotAllMenu::DoCrateSelector() {
|
209 |
|
|
|
210 |
|
|
int iev=0;
|
211 |
|
|
int ifl=0;
|
212 |
|
|
int ipstat=0;
|
213 |
|
|
for(int i=0; i<HistoManager::NUMEVTTYPES; i++) {
|
214 |
|
|
if (fET[i]->IsOn()) iev=i;
|
215 |
|
|
if (i<HistoManager::NUMHISTTYPES && fFT[i]->IsOn()) ifl=i;
|
216 |
|
|
if (i<2 && fVT[i]->IsOn()) ipstat=i;
|
217 |
|
|
}
|
218 |
|
|
|
219 |
|
|
int crate = atoi(crateEntry->GetText());
|
220 |
|
|
if (crate ==-1){std::cout<<"Please enter a crate number to use Electronics Visual Selector"<<std::endl;
|
221 |
|
|
}else{
|
222 |
|
|
theDisplay->CrateDisplaySelector(crate,iev,ifl,ipstat);}
|
223 |
|
|
}
|
224 |
|
|
|
225 |
|
|
|
226 |
|
|
void PlotAllMenu::DoDraw() {
|
227 |
|
|
int iev=0;
|
228 |
|
|
int ifl=0;
|
229 |
|
|
for (int i=0; i<HistoManager::NUMEVTTYPES; i++) {
|
230 |
|
|
if (fET[i]->IsOn()) iev=i;
|
231 |
|
|
if (i<HistoManager::NUMHISTTYPES && fFT[i]->IsOn()) ifl=i;
|
232 |
|
|
}
|
233 |
|
|
|
234 |
|
|
int ieta=atoi(ietaEntry->GetText());
|
235 |
|
|
int iphi=atoi(iphiEntry->GetText());
|
236 |
|
|
int fiber=atoi(fiberEntry->GetText());
|
237 |
|
|
int fiberChan=atoi(fiberChanEntry->GetText());
|
238 |
|
|
int crate=atoi(crateEntry->GetText());
|
239 |
|
|
|
240 |
|
|
int slot=0,tb=0;
|
241 |
|
|
char tbc='t';
|
242 |
|
|
sscanf(SlotEntry->GetText(),"%d%c",&slot,&tbc);
|
243 |
|
|
|
244 |
|
|
if (tbc=='t'){tb=1;}else{tb=0;}
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
if(!elecbut->IsOn()){
|
248 |
|
|
if (ieta==0 || iphi==0) {
|
249 |
|
|
theDisplay->displaySummary(ieta,iphi,iev,ifl);
|
250 |
|
|
} else {
|
251 |
|
|
theDisplay->displayOne(ieta,iphi,1,iev,ifl);
|
252 |
|
|
}
|
253 |
|
|
}else {
|
254 |
|
|
if (fiber==-1||fiberChan==-1){
|
255 |
|
|
|
256 |
|
|
theDisplay->displayElecSummary(crate,slot,tb,iev,ifl);
|
257 |
|
|
}else{
|
258 |
|
|
theDisplay->displayElecOne(fiber,fiberChan,crate,slot,tb,iev,ifl);
|
259 |
|
|
}
|
260 |
|
|
}
|
261 |
|
|
}
|
262 |
|
|
static const char *filetypes[] = { "POOL files", "*.root", 0, 0 };
|
263 |
|
|
|
264 |
|
|
void PlotAllMenu::DoBrowse() {
|
265 |
|
|
char line[1200];
|
266 |
|
|
char outfn[1200];
|
267 |
|
|
|
268 |
|
|
static TString dir(".");
|
269 |
|
|
TGFileInfo fi;
|
270 |
|
|
fi.fFileTypes = filetypes;
|
271 |
|
|
fi.fIniDir = StrDup(dir);
|
272 |
|
|
new TGFileDialog(gClient->GetRoot(), fMain, kFDOpen, &fi);
|
273 |
|
|
|
274 |
|
|
// Compose temporary root output filename
|
275 |
|
|
strcpy(line,fi.fFilename);
|
276 |
|
|
*(strstr(line,".root")) = 0; // null out ".root" suffix
|
277 |
|
|
|
278 |
|
|
// get rid of path prefix, put it in tmp
|
279 |
|
|
char *fn=strrchr(line,'/');
|
280 |
|
|
if (fn != NULL)
|
281 |
|
|
sprintf (outfn,"/tmp/%s.%s.plotall.root", fn+1, username_);
|
282 |
|
|
else
|
283 |
|
|
sprintf (outfn,"/tmp/%s.%s.plotall.root", fi.fFilename, username_);
|
284 |
|
|
|
285 |
|
|
struct stat buf;
|
286 |
|
|
if (!checkbut->IsOn() &&
|
287 |
|
|
!stat(outfn,&buf)) {
|
288 |
|
|
std::cout << "File already processed, loading results." << std::endl;
|
289 |
|
|
}
|
290 |
|
|
else {
|
291 |
|
|
std::cout << "Processing..." << std::endl;
|
292 |
|
|
sprintf(line,".! ./runCMSSWReco.sh %s %s",fi.fFilename, outfn);
|
293 |
|
|
gROOT->ProcessLine(line);
|
294 |
|
|
std::cout << "Done." << std::endl;
|
295 |
|
|
}
|
296 |
|
|
|
297 |
|
|
if (theDisplay!=0) delete theDisplay;
|
298 |
|
|
theDisplay=new PlotAllDisplay(outfn);
|
299 |
|
|
|
300 |
|
|
dir = fi.fIniDir;
|
301 |
|
|
}
|
302 |
|
|
|
303 |
|
|
void PlotAllMenu::DoProcessRunNumber() {
|
304 |
|
|
char line[1200];
|
305 |
|
|
char outfn[1200];
|
306 |
|
|
int runno=atoi(runnoEntry->GetText());
|
307 |
|
|
|
308 |
|
|
// Compose temporary root output filename
|
309 |
|
|
sprintf (outfn,"/tmp/%s.%d.plotall.root", username_,runno);
|
310 |
|
|
|
311 |
|
|
struct stat buf;
|
312 |
|
|
if (!checkbut->IsOn() &&
|
313 |
|
|
!stat(outfn,&buf)) {
|
314 |
|
|
std::cout << "File already processed, loading results." << std::endl;
|
315 |
|
|
}
|
316 |
|
|
else {
|
317 |
|
|
std::cout << "Processing..." << std::endl;
|
318 |
|
|
sprintf(line,".! ./runCMSSWReco.sh %d %s",runno, outfn);
|
319 |
|
|
gROOT->ProcessLine(line);
|
320 |
|
|
std::cout << "Done." << std::endl;
|
321 |
|
|
}
|
322 |
|
|
|
323 |
|
|
if (theDisplay!=0) delete theDisplay;
|
324 |
|
|
theDisplay=new PlotAllDisplay(outfn);
|
325 |
|
|
}
|
326 |
|
|
|
327 |
|
|
PlotAllMenu::~PlotAllMenu() {
|
328 |
|
|
// Clean up used widgets: frames, buttons, layouthints
|
329 |
|
|
fMain->Cleanup();
|
330 |
|
|
delete fMain;
|
331 |
|
|
}
|