FACT++  1.0
void FactGui::DisplayEventData ( )
inlineprivatevirtual

Implements MainWindow.

Definition at line 969 of file FactGui.h.

References i, kBlue, kGreen, kMagenta, kRed, start(), and str.

970  {
971  if (!fEventData)
972  return;
973 
974 #ifdef HAVE_ROOT
975  TCanvas *c = fAdcDataCanv->GetCanvas();
976 
977  TH1 *hf = dynamic_cast<TH1*>(c->FindObject("Frame"));
978  TH1 *h = dynamic_cast<TH1*>(c->FindObject("EventData"));
979  TH1 *d0 = dynamic_cast<TH1*>(c->FindObject("DrsCalib0"));
980  TH1 *d1 = dynamic_cast<TH1*>(c->FindObject("DrsCalib1"));
981  TH1 *d2 = dynamic_cast<TH1*>(c->FindObject("DrsCalib2"));
982 
983  const int roi = fAdcPhysical->isChecked() ? 1024 : (fEventData->Roi>0 ? fEventData->Roi : 1);
984 
985  if ((hf && hf->GetNbinsX()!=roi) ||
986  (dynamic_cast<TH2*>(h) && !fAdcPersistent->isChecked()) ||
987  (!dynamic_cast<TH2*>(h) && fAdcPersistent->isChecked()))
988  {
989  delete hf;
990  delete h;
991  delete d0;
992  delete d1;
993  delete d2;
994  d0 = 0;
995  d1 = 0;
996  d2 = 0;
997  hf = 0;
998  }
999 
1000  if (!hf)
1001  {
1002  hf = new TH1F("Frame", "", roi, -0.5, roi-0.5);
1003  hf->SetDirectory(0);
1004  hf->SetBit(kCanDelete);
1005  hf->SetStats(kFALSE);
1006  hf->SetYTitle("Voltage [mV]");
1007  hf->GetXaxis()->CenterTitle();
1008  hf->GetYaxis()->CenterTitle();
1009  hf->SetMinimum(-1250);
1010  hf->SetMaximum(2150);
1011 
1012  if (!fAdcPersistent->isChecked())
1013  h = new TH1F("EventData", "", roi, -0.5, roi-0.5);
1014  else
1015  {
1016  h = new TH2F("EventData", "", roi, -0.5, roi-0.5, 6751, -2350.5*2000/4096, 4400.5*2000/4096);
1017  h->SetContour(50);
1018  gStyle->SetPalette(1, 0);
1019  }
1020 
1021  h->SetDirectory(0);
1022  h->SetBit(kCanDelete);
1023  h->SetMarkerStyle(kFullDotMedium);
1024  h->SetMarkerColor(kBlue);
1025 
1026  c->GetListOfPrimitives()->Add(hf, "");
1027 
1028  if (dynamic_cast<TH2*>(h))
1029  c->GetListOfPrimitives()->Add(h, "col same");
1030  }
1031 
1032  if (d0 && !(fDrsCalibBaselineOn->isChecked() && fDrsCalibBaseline->value()>0))
1033  {
1034  delete d0;
1035  d0 = 0;
1036  }
1037  if (d1 && !(fDrsCalibGainOn->isChecked() && fDrsCalibGain->value()>0))
1038  {
1039  delete d1;
1040  d1 = 0;
1041  }
1042  if (d2 && !(fDrsCalibTrgOffsetOn->isChecked() && fDrsCalibTrgOffset->value()>0))
1043  {
1044  delete d2;
1045  d2 = 0;
1046  }
1047 
1048  if (!d0 && fDrsCalibBaselineOn->isChecked() && fDrsCalibBaseline->value()>0)
1049  {
1050  d0 = new TH1F("DrsCalib0", "", roi, -0.5, roi-0.5);
1051  d0->SetDirectory(0);
1052  d0->SetBit(kCanDelete);
1053  d0->SetMarkerStyle(kFullDotSmall);
1054  d0->SetMarkerColor(kRed);
1055  d0->SetLineColor(kRed);
1056  c->GetListOfPrimitives()->Add(d0, "PEX0same");
1057  }
1058 
1059  if (!d1 && fDrsCalibGainOn->isChecked() && fDrsCalibGain->value()>0)
1060  {
1061  d1 = new TH1F("DrsCalib1", "", roi, -0.5, roi-0.5);
1062  d1->SetDirectory(0);
1063  d1->SetBit(kCanDelete);
1064  d1->SetMarkerStyle(kFullDotSmall);
1065  d1->SetMarkerColor(kMagenta);
1066  d1->SetLineColor(kMagenta);
1067  c->GetListOfPrimitives()->Add(d1, "PEX0same");
1068  }
1069 
1070  if (!d2 && fDrsCalibTrgOffsetOn->isChecked() && fDrsCalibTrgOffset->value()>0)
1071  {
1072  d2 = new TH1F("DrsCalib2", "", roi, -0.5, roi-0.5);
1073  d2->SetDirectory(0);
1074  d2->SetBit(kCanDelete);
1075  d2->SetMarkerStyle(kFullDotSmall);
1076  d2->SetMarkerColor(kGreen);
1077  d2->SetLineColor(kGreen);
1078  c->GetListOfPrimitives()->Add(d2, "PEX0same");
1079  }
1080 
1081  if (!dynamic_cast<TH2*>(h) && !c->GetListOfPrimitives()->FindObject(h))
1082  c->GetListOfPrimitives()->Add(h, "PLsame");
1083 
1084  // -----------------------------------------------------------
1085 
1086  const uint32_t p =
1087  fAdcChannel->value() +
1088  fAdcChip->value() * 9+
1089  fAdcBoard->value() * 36+
1090  fAdcCrate->value() *360;
1091 
1092  ostringstream str;
1093  str << "CBPX = " << fAdcCrate->value() << '|' << fAdcBoard->value() << '|' << fAdcChip->value() << '|' << fAdcChannel->value() << " (" << p << ")";
1094  str << " EventNum = " << fEventData->EventNum;
1095  str << " TriggerNum = " << fEventData->TriggerNum;
1096  str << " TriggerType = " << fEventData->TriggerType;
1097  str << " BoardTime = " << fEventData->BoardTime[fAdcBoard->value()+fAdcCrate->value()*10];
1098  str << " (" << Time(fEventData->PCTime, fEventData->PCUsec) << ")";
1099  hf->SetTitle(str.str().c_str());
1100  str.str("");
1101  str << "ADC Pipeline (start cell: " << fEventData->StartPix[p] << ")";
1102  hf->SetXTitle(str.str().c_str());
1103 
1104  // -----------------------------------------------------------
1105 
1106  const int16_t start = fEventData->StartPix[p];
1107 
1108  fDrsCalibBaseline->setEnabled(fDrsCalibBaseline->value()>0);
1109  fDrsCalibGain->setEnabled(fDrsCalibGain->value()>0);
1110  fDrsCalibTrgOffset->setEnabled(fDrsCalibTrgOffset->value()>0);
1111  fDrsCalibROI->setEnabled(fDrsCalibROI->value()>0);
1112 
1113  fDrsCalibBaseline2->setEnabled(fDrsCalibBaseline->value()>0);
1114  fDrsCalibGain2->setEnabled(fDrsCalibGain->value()>0);
1115  fDrsCalibTrgOffset2->setEnabled(fDrsCalibTrgOffset->value()>0);
1116  fDrsCalibROI2->setEnabled(fDrsCalibROI->value()>0);
1117 
1118  SetLedColor(fFadLedDrsBaseline, fDrsCalibBaseline->value()>0 ?kLedGreen:kLedGray, Time());
1119  SetLedColor(fFadLedDrsGain, fDrsCalibGain->value()>0 ?kLedGreen:kLedGray, Time());
1120  SetLedColor(fFadLedDrsTrgOff, fDrsCalibTrgOffset->value()>0?kLedGreen:kLedGray, Time());
1121 
1122  if (d0)//fDrsCalibBaseline->value()==0 || start<0)
1123  d0->Reset();
1124  if (d1)//fDrsCalibGain->value()==0 || start<0)
1125  d1->Reset();
1126  if (d2)//fDrsCalibTrgOffset->value()==0 || start<0)
1127  d2->Reset();
1128 
1129  if (!dynamic_cast<TH2*>(h))
1130  h->Reset();
1131  if (d0)
1132  d0->SetEntries(0);
1133  if (d1)
1134  d1->SetEntries(0);
1135  if (d2)
1136  d2->SetEntries(0);
1137 
1138  for (int i=0; i<fEventData->Roi; i++)
1139  {
1140  // FIXME: physcial: i -> (i+start)%1024
1141  // FIXME: logical: i -> i
1142 
1143  const int ii = fAdcPhysical->isChecked() ? (i+start)%1024 : i;
1144 
1145  //if (dynamic_cast<TH2*>(h))
1146  h->Fill(ii, reinterpret_cast<float*>(fEventData->Adc_Data)[p*fEventData->Roi+i]);
1147  //else
1148  // h->SetBinContent(i+1, reinterpret_cast<float*>(fEventData->Adc_Data)[p*fEventData->Roi+i]);
1149  if (start<0)
1150  continue;
1151 
1152  if (d0)
1153  {
1154  d0->SetBinContent(ii+1, fDrsCalibration[1440*1024*0 + p*1024+(start+i)%1024]);
1155  d0->SetBinError(ii+1, fDrsCalibration[1440*1024*1 + p*1024+(start+i)%1024]);
1156 
1157  }
1158  if (d1)
1159  {
1160  d1->SetBinContent(ii+1, fDrsCalibration[1440*1024*2 + p*1024+(start+i)%1024]);
1161  d1->SetBinError(ii+1, fDrsCalibration[1440*1024*3 + p*1024+(start+i)%1024]);
1162  }
1163  if (d2)
1164  {
1165  d2->SetBinContent(ii+1, fDrsCalibration[1440*1024*4 + p*1024 + i]);
1166  d2->SetBinError(ii+1, fDrsCalibration[1440*1024*5 + p*1024 + i]);
1167  }
1168  }
1169 
1170  // -----------------------------------------------------------
1171  if (fAdcDynamicScale->isEnabled() && fAdcDynamicScale->isChecked())
1172  {
1173  h->SetMinimum();
1174  h->SetMaximum();
1175 
1176  hf->SetMinimum(h->GetMinimum());
1177  hf->SetMaximum(h->GetMaximum());
1178  }
1179  if (fAdcManualScale->isEnabled() && fAdcManualScale->isChecked())
1180  {
1181  if (h->GetMinimumStored()==-1111)
1182  {
1183  h->SetMinimum(-1150);//-1026);
1184  hf->SetMinimum(-1150);//-1026);
1185  }
1186  if (h->GetMaximumStored()==-1111)
1187  {
1188  h->SetMaximum(2150);//1025);
1189  hf->SetMaximum(2150);//1025);
1190  }
1191  }
1192 
1193  if (fAdcAutoScale->isEnabled() && fAdcAutoScale->isChecked())
1194  {
1195  h->SetMinimum();
1196  h->SetMaximum();
1197 
1198  if (h->GetMinimum()<hf->GetMinimum())
1199  hf->SetMinimum(h->GetMinimum());
1200  if (h->GetMaximum()>hf->GetMaximum())
1201  hf->SetMaximum(h->GetMaximum());
1202  }
1203 
1204  if (dynamic_cast<TH2*>(h))
1205  {
1206  h->SetMinimum();
1207  h->SetMaximum();
1208  }
1209 
1210  // -----------------------------------------------------------
1211 
1212  const int imin = ceil(hf->GetMinimum());
1213  const int imax = floor(hf->GetMaximum());
1214 
1215  TH1S hd("", "", imax-imin+1, imin-0.5, imax+0.5);
1216  hd.SetDirectory(0);
1217  TH1S h0("", "", imax-imin+1, imin-0.5, imax+0.5);
1218  h0.SetDirectory(0);
1219  TH1S h1("", "", imax-imin+1, imin-0.5, imax+0.5);
1220  h1.SetDirectory(0);
1221  TH1S h2("", "", imax-imin+1, imin-0.5, imax+0.5);
1222  h2.SetDirectory(0);
1223  hd.SetLineColor(h->GetLineColor());
1224  if (d0)
1225  h0.SetLineColor(d0->GetLineColor());
1226  if (d1)
1227  h1.SetLineColor(d1->GetLineColor());
1228  if (d2)
1229  h2.SetLineColor(d2->GetLineColor());
1230 
1231  for (int i=0; i<fEventData->Roi; i++)
1232  {
1233  if (!dynamic_cast<TH2*>(h))
1234  hd.Fill(h->GetBinContent(i+1));
1235  if (d0)
1236  h0.Fill(d0->GetBinContent(i+1));
1237  if (d1)
1238  h1.Fill(d1->GetBinContent(i+1));
1239  if (d2)
1240  h2.Fill(d2->GetBinContent(i+1));
1241  }
1242 
1243  double mm = hd.GetMaximum(hd.GetEntries());
1244  if (h0.GetMaximum(h0.GetEntries())>mm)
1245  mm = h0.GetMaximum();
1246  if (h1.GetMaximum(h1.GetEntries())>mm)
1247  mm = h1.GetMaximum();
1248  if (h2.GetMaximum(h2.GetEntries())>mm)
1249  mm = h2.GetMaximum();
1250 
1251  TIter Next(hf->GetListOfFunctions());
1252  TObject *obj = 0;
1253  while ((obj=Next()))
1254  if (dynamic_cast<TBox*>(obj))
1255  delete hf->GetListOfFunctions()->Remove(obj);
1256 
1257  const double l = h->GetBinLowEdge(h->GetXaxis()->GetLast()+1);
1258  const double m = c->GetX2();
1259 
1260  const double scale = 0.9*(m-l)/mm;
1261 
1262  DrawHorizontal(hf, l, h2, scale);
1263  DrawHorizontal(hf, l, h1, scale);
1264  DrawHorizontal(hf, l, h0, scale);
1265  DrawHorizontal(hf, l, hd, scale);
1266 
1267  // -----------------------------------------------------------
1268 
1269  c->Modified();
1270  c->Update();
1271 #endif
1272  }
int start(int initState)
Definition: feeserver.c:1740
int i
Definition: db_dim_client.c:21
Set color Green.
Definition: WindowLog.h:18
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
char str[80]
Definition: test_client.c:7
Set color Red.
Definition: WindowLog.h:17
void SetLedColor(QPushButton *button, LedColor_t col, const Time &t)
Definition: FactGui.h:156
void DrawHorizontal(TH1 *hf, double xmax, TH1 &h, double scale)
Definition: FactGui.h:948
Set color Magenta.
Definition: WindowLog.h:21
Set color Blue.
Definition: WindowLog.h:20
EVENT * fEventData
Definition: FactGui.h:946
vector< float > fDrsCalibration
Definition: FactGui.h:1337

+ Here is the call graph for this function: