Changeset 11759 for trunk/FACT++/gui/FactGui.h
- Timestamp:
- 08/03/11 18:18:49 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/gui/FactGui.h
r11749 r11759 27 27 #include "TGraph.h" 28 28 #include "TH1.h" 29 #include "TBox.h" 29 30 #include "TStyle.h" 30 31 #include "TMarker.h" … … 346 347 fData = data; 347 348 } 349 350 void SetData(const float *data) 351 { 352 for (int i=0; i<1440; i++) 353 fData[i] = data[i]; 354 } 348 355 }; 349 356 … … 392 399 DimStampedInfo fDimFadRuns; 393 400 DimStampedInfo fDimFadEvents; 401 DimStampedInfo fDimFadRawData; 394 402 DimStampedInfo fDimFadEventData; 395 403 DimStampedInfo fDimFadConnections; … … 1138 1146 EVENT *fEventData; 1139 1147 1148 void DrawHorizontal(TH1 *hf, double xmax, TH1 &h, double scale) 1149 { 1150 for (Int_t i=1;i<=h.GetNbinsX();i++) 1151 { 1152 if (h.GetBinContent(i)<0.5 || h.GetBinContent(i)>h.GetEntries()-0.5) 1153 continue; 1154 1155 TBox * box=new TBox(xmax, h.GetBinLowEdge(i), 1156 xmax+h.GetBinContent(i)*scale, 1157 h.GetBinLowEdge(i+1)); 1158 1159 box->SetFillStyle(0); 1160 box->SetLineColor(h.GetMarkerColor()); 1161 box->SetLineStyle(kSolid); 1162 box->SetBit(kCannotPick|kNoContextMenu); 1163 //box->Draw(); 1164 1165 hf->GetListOfFunctions()->Add(box); 1166 } 1167 } 1168 1169 /* 1170 void DrawHori(TH1 *h) 1171 { 1172 //Draw histogram h horizontaly with bars 1173 Double_t ymin = h->GetMinimum(); 1174 Double_t ymax = 1.05*h->GetMaximum(); 1175 1176 TAxis *axis = ; 1177 1178 Double_t xmin = h->GetXaxis()->GetXmin(); 1179 Double_t xmax = h->GetXaxis()->GetXmax(); 1180 1181 Int_t nbins = h->GetXaxis()->GetNbins(); 1182 1183 //TH2F *h2 = new TH2F("h2",h->GetTitle(),10,ymin,ymax,nbins,xmin,xmax); 1184 //h2->SetBit(kCanDelete); 1185 //h2->SetDirectory(0); 1186 //h2->SetStats(0); 1187 //h2->Draw(); 1188 TBox box; 1189 //Int_t color = h->GetFillColor(); 1190 //if (color == 0) color = 1; 1191 box.SetFillColor(color); 1192 Double_t dy; 1193 Double_t x1,y1,x2,y2; 1194 for (Int_t i=1;i<=nbins;i++) 1195 { 1196 dy = axis->GetBinWidth(i); 1197 1198 x1 = 0; 1199 x2 = h->GetBinContent(i); 1200 1201 y1 = h->GetBinCenter(i)-0.3*dy; 1202 y2 = h->GetBinCenter(i)+0.3*dy; 1203 1204 box.DrawBox(x1,y1,x2,y2); 1205 } 1206 }*/ 1207 1140 1208 void DisplayEventData() 1141 1209 { … … 1205 1273 d2->SetLineColor(kGreen); 1206 1274 1207 hf->Draw(" PL");1275 hf->Draw(""); 1208 1276 d0->Draw("PEX0same"); 1209 1277 d1->Draw("PEX0same"); … … 1214 1282 } 1215 1283 1284 // ----------------------------------------------------------- 1216 1285 1217 1286 const uint32_t p = … … 1232 1301 hf->SetXTitle(str.str().c_str()); 1233 1302 1303 // ----------------------------------------------------------- 1304 1234 1305 const int16_t start = fEventData->StartPix[p]; 1235 if (start<0) 1236 { 1306 if (fDrsRuns[0]==0 || start<0) 1237 1307 d0->Reset(); 1308 if (fDrsRuns[1]==0 || start<0) 1238 1309 d1->Reset(); 1310 if (fDrsRuns[2]==0 || start<0) 1239 1311 d2->Reset(); 1240 } 1312 1313 h->SetEntries(0); 1314 d0->SetEntries(0); 1315 d1->SetEntries(0); 1316 d2->SetEntries(0); 1317 1241 1318 for (int i=0; i<fEventData->Roi; i++) 1242 1319 { … … 1263 1340 } 1264 1341 1342 // ----------------------------------------------------------- 1343 1265 1344 if (fAdcDynamicScale->isChecked()) 1266 1345 { … … 1275 1354 if (h->GetMinimumStored()==-1111) 1276 1355 { 1277 h->SetMinimum(-1 026);1278 hf->SetMinimum(-1 026);1356 h->SetMinimum(-1150);//-1026); 1357 hf->SetMinimum(-1150);//-1026); 1279 1358 } 1280 1359 if (h->GetMaximumStored()==-1111) 1281 1360 { 1282 h->SetMaximum( 1025);1283 hf->SetMaximum( 1025);1361 h->SetMaximum(2550);//1025); 1362 hf->SetMaximum(2550);//1025); 1284 1363 } 1285 1364 } … … 1296 1375 } 1297 1376 1377 // ----------------------------------------------------------- 1378 1379 const int imin = ceil(hf->GetMinimum()); 1380 const int imax = floor(hf->GetMaximum()); 1381 1382 TH1S hd("", "", imax-imin+1, imin-0.5, imax+0.5); 1383 TH1S h0("", "", imax-imin+1, imin-0.5, imax+0.5); 1384 TH1S h1("", "", imax-imin+1, imin-0.5, imax+0.5); 1385 TH1S h2("", "", imax-imin+1, imin-0.5, imax+0.5); 1386 hd.SetDirectory(0); 1387 h0.SetDirectory(0); 1388 h1.SetDirectory(0); 1389 h2.SetDirectory(0); 1390 1391 for (int i=0; i<fEventData->Roi; i++) 1392 { 1393 hd.Fill(h->GetBinContent(i+1)); 1394 h0.Fill(d0->GetBinContent(i+1)); 1395 h1.Fill(d1->GetBinContent(i+1)); 1396 h2.Fill(d2->GetBinContent(i+1)); 1397 } 1398 1399 double mm = hd.GetMaximum(hd.GetEntries()); 1400 if (h0.GetMaximum(h0.GetEntries())>mm) 1401 mm = h0.GetMaximum(); 1402 if (h1.GetMaximum(h1.GetEntries())>mm) 1403 mm = h1.GetMaximum(); 1404 if (h2.GetMaximum(h2.GetEntries())>mm) 1405 mm = h2.GetMaximum(); 1406 1407 TIter Next(hf->GetListOfFunctions()); 1408 TObject *obj = 0; 1409 while ((obj=Next())) 1410 if (dynamic_cast<TBox*>(obj)) 1411 delete hf->GetListOfFunctions()->Remove(obj); 1412 1413 const double l = h->GetBinLowEdge(h->GetXaxis()->GetLast()+1); 1414 const double m = c->GetX2(); // X2()-X1() 1415 1416 const double scale = 0.9*(m-l)/mm; 1417 1418 c->cd(); 1419 1420 DrawHorizontal(hf, l, h2, scale); 1421 DrawHorizontal(hf, l, h1, scale); 1422 DrawHorizontal(hf, l, h0, scale); 1423 DrawHorizontal(hf, l, hd, scale); 1424 // DrawHorizontal(hf, l, &h1); 1425 // DrawHorizontal(hf, l, &h2); 1426 1427 // ----------------------------------------------------------- 1428 1298 1429 c->Modified(); 1299 1430 c->Update(); … … 1301 1432 } 1302 1433 1303 void handleFad EventData(const DimData &d)1434 void handleFadRawData(const DimData &d) 1304 1435 { 1305 1436 if (d.size()==0) … … 1328 1459 1329 1460 DisplayEventData(); 1461 } 1462 1463 void handleFadEventData(const DimData &d) 1464 { 1465 if (!CheckSize(d, 4*1440*sizeof(float))) 1466 return; 1467 1468 static int i=0; 1469 if (i++%10>0) 1470 return; 1471 1472 const float *ptr = d.ptr<float>(); 1473 1474 TCanvas *c = fEventCanv->GetCanvas(); 1475 Camera *cam1 = (Camera*)c->GetPad(1)->FindObject("Camera"); 1476 Camera *cam2 = (Camera*)c->GetPad(2)->FindObject("Camera"); 1477 Camera *cam3 = (Camera*)c->GetPad(3)->FindObject("Camera"); 1478 Camera *cam4 = (Camera*)c->GetPad(4)->FindObject("Camera"); 1479 1480 valarray<double> arr1(1440); 1481 valarray<double> arr2(1440); 1482 valarray<double> arr3(1440); 1483 valarray<double> arr4(1440); 1484 1485 for (int i=0; i<1440; i++) 1486 { 1487 arr1[i] = ptr[0*1440+fPixelMapHW[i]]; 1488 arr2[i] = ptr[1*1440+fPixelMapHW[i]]; 1489 arr3[i] = ptr[2*1440+fPixelMapHW[i]]; 1490 arr4[i] = ptr[3*1440+fPixelMapHW[i]]; 1491 } 1492 1493 cam1->SetData(arr1); 1494 cam2->SetData(arr2); 1495 cam3->SetData(arr3); 1496 cam4->SetData(arr4); 1497 1498 c->GetPad(1)->Modified(); 1499 c->GetPad(2)->Modified(); 1500 // c->GetPad(3)->Modified(); 1501 // c->GetPad(4)->Modified(); 1502 1503 c->Update(); 1330 1504 } 1331 1505 … … 1353 1527 fDrsRuns[1] = run[1]; 1354 1528 fDrsRuns[2] = run[2]; 1529 1530 cout << "Received: " << run[0] << " " << run[1] << " " << run[2] << endl; 1355 1531 1356 1532 const float *dat = d.ptr<float>(sizeof(uint32_t)*3); … … 2510 2686 return PostInfoHandler(&FactGui::handleFadRuns); 2511 2687 2512 if (getInfo()==&fDimFadEventData) 2688 if (getInfo()==&fDimFadRawData) 2689 return PostInfoHandler(&FactGui::handleFadRawData); 2690 2691 if (getInfo()==&fDimFadEventData) 2513 2692 return PostInfoHandler(&FactGui::handleFadEventData); 2514 2693 … … 2670 2849 } 2671 2850 2672 // Find the object which will get picked by the GetObjectInfo 2673 // due to buffer overflows in many root-versions 2674 // in TH1 and TProfile we have to work around and implement 2675 // our own GetObjectInfo which make everything a bit more 2676 // complicated. 2677 canv->cd(); 2851 if (obj) 2852 { 2853 // Find the object which will get picked by the GetObjectInfo 2854 // due to buffer overflows in many root-versions 2855 // in TH1 and TProfile we have to work around and implement 2856 // our own GetObjectInfo which make everything a bit more 2857 // complicated. 2858 canv->cd(); 2678 2859 #if ROOT_VERSION_CODE > ROOT_VERSION(5,22,00) 2679 const char *objectInfo =2680 obj->GetObjectInfo(tipped->GetEventX(),tipped->GetEventY());2860 const char *objectInfo = 2861 obj->GetObjectInfo(tipped->GetEventX(),tipped->GetEventY()); 2681 2862 #else 2682 const char *objectInfo = dynamic_cast<TH1*>(obj) ?2683 "" : obj->GetObjectInfo(tipped->GetEventX(),tipped->GetEventY());2863 const char *objectInfo = dynamic_cast<TH1*>(obj) ? 2864 "" : obj->GetObjectInfo(tipped->GetEventX(),tipped->GetEventY()); 2684 2865 #endif 2685 2866 2686 QString tipText; 2687 tipText += obj->GetName(); 2688 tipText += " ["; 2689 tipText += obj->ClassName(); 2690 tipText += "]: "; 2691 tipText += objectInfo; 2692 2693 if (dynamic_cast<Camera*>(obj)) 2694 { 2695 const float xx = canv->AbsPixeltoX(tipped->GetEventX()); 2696 const float yy = canv->AbsPixeltoY(tipped->GetEventY()); 2697 2698 Camera *cam = static_cast<Camera*>(obj); 2699 2700 const int isw = cam->GetIdx(xx, yy); 2701 const int ihw = fPixelMapHW[isw]; 2702 2703 const int idx = fPatchHW[isw]; 2704 2705 int ii = 0; 2706 for (; ii<160; ii++) 2707 if (idx==fPatchMapHW[ii]) 2708 break; 2709 2710 2711 const int patch = ihw%4; 2712 const int board = (ihw/4)%10; 2713 const int crate = (ihw/4)/10; 2714 2715 ostringstream str; 2716 str << " (hw=" << ihw << ") Patch=" << ii << " (hw=" << fPatchMapHW[idx] << "; Crate=" << crate << " Board=" << board << " Patch=" << patch << ")"; 2717 2718 tipText += str.str().c_str(); 2719 } 2720 2721 2722 fStatusBar->showMessage(tipText, 3000); 2867 QString tipText; 2868 tipText += obj->GetName(); 2869 tipText += " ["; 2870 tipText += obj->ClassName(); 2871 tipText += "]: "; 2872 tipText += objectInfo; 2873 2874 if (dynamic_cast<Camera*>(obj)) 2875 { 2876 const float xx = canv->AbsPixeltoX(tipped->GetEventX()); 2877 const float yy = canv->AbsPixeltoY(tipped->GetEventY()); 2878 2879 Camera *cam = static_cast<Camera*>(obj); 2880 2881 const int isw = cam->GetIdx(xx, yy); 2882 const int ihw = fPixelMapHW[isw]; 2883 2884 const int idx = fPatchHW[isw]; 2885 2886 int ii = 0; 2887 for (; ii<160; ii++) 2888 if (idx==fPatchMapHW[ii]) 2889 break; 2890 2891 2892 const int patch = ihw%4; 2893 const int board = (ihw/4)%10; 2894 const int crate = (ihw/4)/10; 2895 2896 ostringstream str; 2897 str << " (hw=" << ihw << ") Patch=" << ii << " (hw=" << fPatchMapHW[idx] << "; Crate=" << crate << " Board=" << board << " Patch=" << patch << ")"; 2898 2899 tipText += str.str().c_str(); 2900 } 2901 fStatusBar->showMessage(tipText, 3000); 2902 } 2723 2903 2724 2904 gSystem->DispatchOneEvent(kFALSE); … … 2959 3139 fDimFadRuns ("FAD_CONTROL/RUNS", (void*)NULL, 0, this), 2960 3140 fDimFadEvents ("FAD_CONTROL/EVENTS", (void*)NULL, 0, this), 3141 fDimFadRawData ("FAD_CONTROL/RAW_DATA", (void*)NULL, 0, this), 2961 3142 fDimFadEventData ("FAD_CONTROL/EVENT_DATA", (void*)NULL, 0, this), 2962 3143 fDimFadConnections ("FAD_CONTROL/CONNECTIONS", (void*)NULL, 0, this), … … 3207 3388 c->SetFrameBorderMode(0); 3208 3389 c->SetFillColor(kWhite); 3390 c->SetRightMargin(0.10); 3209 3391 c->SetGrid(); 3210 3392 c->cd(); 3393 3394 // -------------------------------------------------------------------------- 3395 3396 c = fEventCanv->GetCanvas(); 3397 c->SetBit(TCanvas::kNoContextMenu); 3398 c->SetBorderMode(0); 3399 c->SetFrameBorderMode(0); 3400 c->SetFillColor(kWhite); 3401 c->Divide(2,2); 3402 c->cd(1); 3403 gPad->SetBorderMode(0); 3404 gPad->SetFrameBorderMode(0); 3405 gPad->SetFillColor(kWhite); 3406 Camera *cam1 = new Camera; 3407 cam1->SetBit(kCanDelete); 3408 cam1->Draw(); 3409 c->cd(2); 3410 gPad->SetBorderMode(0); 3411 gPad->SetFrameBorderMode(0); 3412 gPad->SetFillColor(kWhite); 3413 Camera *cam2 = new Camera; 3414 cam2->SetBit(kCanDelete); 3415 cam2->Draw(); 3416 c->cd(3); 3417 gPad->SetBorderMode(0); 3418 gPad->SetFrameBorderMode(0); 3419 gPad->SetFillColor(kWhite); 3420 Camera *cam3 = new Camera; 3421 cam3->SetBit(kCanDelete); 3422 cam3->Draw(); 3423 c->cd(4); 3424 gPad->SetBorderMode(0); 3425 gPad->SetFrameBorderMode(0); 3426 gPad->SetFillColor(kWhite); 3427 Camera *cam4 = new Camera; 3428 cam4->SetBit(kCanDelete); 3429 cam4->Draw(); 3430 3431 3211 3432 3212 3433 // Create histogram?
Note:
See TracChangeset
for help on using the changeset viewer.