200 B2DEBUG(20,
"end run");
206 m_monObj->setVariable(
"comment",
"No ADC histograms of CDC in file");
207 B2INFO(
"Histogram named m_hADC is not found.");
211 TF1* fitFunc[300] = {};
212 for (
int i = 0; i < 300; ++i) {
213 fitFunc[i] =
new TF1(Form(
"f%d", i),
"[0]+[6]*x+[1]*(exp([2]*(x-[3]))/(1+exp(-([4]-x)/[5])))",
214 4921 - 100, 4921 + 100);
215 fitFunc[i]->SetParLimits(6, 0, 0.1);
216 fitFunc[i]->SetParLimits(4, 4850., 5000.0);
217 fitFunc[i]->SetParLimits(5, 0, 50.0);
220 int neve =
m_hTDC->GetEntries();
221 if (neve == 0)neve = 1;
223 B2DEBUG(20,
"adc related");
226 TH1F* hADCMean =
new TH1F(
"hADCMean",
"ADC mean;board;adc mean", 300, 0, 300);
227 TH1F* hADC1000 =
new TH1F(
"ADC1000",
"ADC1000", 300, 0, 300);
228 TH1F* hADC0 =
new TH1F(
"ADC0",
"ADC0", 300, 0, 300);
231 std::vector<float> means = {};
232 std::vector<float> medians = {};
234 for (
int i = 0; i < 300; ++i) {
235 m_hADCs[i] =
m_hADC->ProjectionY(Form(
"hADC%d", i), i + 1, i + 1,
"");
236 m_hADCs[i]->SetTitle(Form(
"hADC%d", i));
237 float n =
static_cast<float>(
m_hADCs[i]->GetEntries());
240 hADC0->SetBinContent(i + 1, -0.1);
242 float n0 =
static_cast<float>(
m_hADCs[i]->GetBinContent(1));
244 B2DEBUG(21,
"bad adc bid " << i <<
" " << n0 <<
" " << n);
247 float bin1 =
m_hADCs[i]->GetBinContent(1);
251 medians.push_back(md);
252 hADCMean->SetBinContent(i + 1, m);
253 hADCMean->SetBinError(i + 1, 0);
254 double overflow =
m_hADCs[i]->GetBinContent(
m_hADCs[i]->GetNbinsX() + 1);
255 hADC1000->SetBinContent(i + 1, overflow / (overflow + n));
256 hADC0->SetBinContent(i + 1, bin1 / (overflow + n));
261 B2DEBUG(20,
"tdc related");
263 TH1F* hTDCEdge =
new TH1F(
"hTDCEdge",
"TDC edge;board;tdc edge [nsec]", 300, 0, 300);
264 TH1F* hTDCSlope =
new TH1F(
"hTDCSlope",
"TDC slope;board;tdc slope [nsec]", 300, 0, 300);
265 std::vector<float> tdcEdges = {};
266 std::vector<float> tdcSlopes = {};
267 for (
int i = 0; i < 300; ++i) {
268 m_hTDCs[i] =
m_hTDC->ProjectionY(Form(
"hTDC%d", i), i + 1, i + 1);
269 m_hTDCs[i]->SetTitle(Form(
"hTDC%d", i));
272 tdcEdges.push_back(0);
273 tdcSlopes.push_back(0);
275 double init_p0 =
m_hTDCs[i]->GetBinContent(700 + 60);
276 fitFunc[i]->SetParameters(init_p0, 100, 0.01, 4700, 4900, 2, 0.01);
277 fitFunc[i]->SetParameter(6, 0.02);
278 fitFunc[i]->SetParLimits(0, init_p0 - 200, init_p0 + 200);
279 int TDCfitstatus = -1;
281 TDCfitstatus =
m_hTDCs[i]->Fit(fitFunc[i],
"qM0",
"", 4850, 5000);
283 TDCfitstatus =
m_hTDCs[i]->Fit(fitFunc[i],
"qM0",
"", 4800, 5000);
285 float p4 = fitFunc[i]->GetParameter(4);
286 float p5 = fitFunc[i]->GetParameter(5);
288 if (TDCfitstatus != -1 && 4850 < p4 && p4 < 5000) {
289 hTDCEdge->SetBinContent(i + 1, p4);
290 hTDCEdge->SetBinError(i + 1, 0);
291 hTDCSlope->SetBinContent(i + 1, p5);
292 hTDCSlope->SetBinError(i + 1, 0);
294 tdcEdges.push_back(p4);
295 tdcSlopes.push_back(p5);
301 B2DEBUG(20,
"hit related");
302 TH1F* hHitPerLayer =
new TH1F(
"hHitPerLayer",
"hit/Layer;layer", 56, 0, 56);
303 TH1F* hHitRatePerWire =
new TH1F(
"hHitRatePerWire",
"hit rate (kHz)/Wire;layer", 56, 0, 56);
305 for (
int i = 0; i < 56; ++i) {
307 double tdcclock = 0.98255764;
308 if (i < 8) tdcwindow = 416;
309 else tdcwindow = 768;
310 m_hHits[i] =
m_hHit->ProjectionY(Form(
"hHit%d", i), i + 1, i + 1);
311 m_hHits[i]->SetTitle(Form(
"hHit%d", i));
315 for (
int j = 0; j < nBins; ++j) {
316 nhitSumL +=
m_hHits[i]->GetBinContent(j + 1);
319 hHitPerLayer->SetBinContent(i + 1, 1.0 * nhitSumL / neve);
320 hHitRatePerWire->SetBinContent(i + 1, (1.0 * nhitSumL / neve) / (1.0 * nBins * tdcwindow * tdcclock * 1e-6));
322 hHitPerLayer->SetBinContent(i + 1, nhitSumL);
323 hHitRatePerWire->SetBinContent(i + 1, (1.0 * nhitSumL) / (1.0 * nBins * tdcwindow * tdcclock * 1e-6));
325 hHitPerLayer->SetBinError(i + 1, 0);
326 hHitRatePerWire->SetBinError(i + 1, 0);
332 B2DEBUG(20,
"bad wire related");
333 hBadChannel =
new TH2F(
"hbadch",
"bad channel map;wire;layer", 400, 0, 400, 56, 0, 56);
334 for (
int i = 0; i < 400; ++i) {
335 for (
int j = 0; j < 56; ++j) {
340 hBadChannelBC =
new TH2F(
"hbadchBC",
"bad channel map per board/channel;board;channel", 300, 0, 300, 48, 0, 48);
341 for (
int i = 0; i < 300; ++i) {
342 for (
int j = 0; j < 48; ++j) {
349 h2p->SetTitle(
"bad wires in xy view");
350 h2p->GetXaxis()->SetTitle(
"X [cm]");
351 h2p->GetYaxis()->SetTitle(
"Y [cm]");
354 const int l = lw.first;
355 const int w = lw.second;
356 B2DEBUG(21,
"l " << l <<
" w " << w);
361 float dPhi =
static_cast<float>(2.0 * M_PI /
m_nSenseWires[l]);
362 float phi = dPhi * (w +
m_offset[l]);
363 float x = r * cos(phi);
364 float y = r * sin(phi);
365 h2p->Fill(x, y, 1.1);
368 B2DEBUG(20,
"writing");
372 hADCMean->SetMinimum(0);
373 hADCMean->SetMaximum(300);
374 hADCMean->DrawCopy();
377 hTDCEdge->SetMinimum(4800);
378 hTDCEdge->SetMaximum(5000);
379 hTDCEdge->DrawCopy();
382 hTDCSlope->SetMinimum(0);
383 hTDCSlope->SetMaximum(50);
384 hTDCSlope->DrawCopy();
393 hADC1000->DrawCopy();
399 hHitPerLayer->DrawCopy();
402 hHitRatePerWire->DrawCopy();
405 for (
int i = 0; i < 56; i++) {
411 m_cADC->Divide(6, 50, 0.0002, 0.0002);
412 m_cTDC->Divide(6, 50, 0.0002, 0.0002);
414 for (
int i = 0; i < 300; i++) {
416 Double_t max =
m_hADCs[i]->GetMaximum();
417 m_hADCs[i]->GetYaxis()->SetRangeUser(0, 3 * max);
422 fitFunc[i]->SetLineColor(kRed);
423 fitFunc[i]->Draw(
"same");
424 max =
m_hTDCs[i]->GetMaximum();
425 TLine* l1 =
new TLine(tdcEdges[i], 0, tdcEdges[i], max * 1.05);
426 l1->SetLineColor(kRed);
427 TLine* l0 =
new TLine(4910, 0, 4910, max * 1.05);
433 h2p->DrawCopy(
"col");
434 float superLayerR[10] = {16.3, 24.3, 35.66, 46.63, 57.55, 68.47,
435 79.39, 90.31, 101.23, 112.05
439 for (
int i = 0; i < 10; ++i) {
440 circs[i] =
new TEllipse(0, 0, superLayerR[i], superLayerR[i]);
441 circs[i]->SetFillStyle(4000);
442 circs[i]->SetLineStyle(kDashed);
443 circs[i]->SetLineColor(0);
444 circs[i]->Draw(
"same");
447 m_monObj->setVariable(
"nEvents", neve);
448 m_monObj->setVariable(
"nHits", nHits / neve);
450 m_monObj->setVariable(
"adcMean", std::accumulate(means.begin(), means.end(), 0.0) / means.size());
451 m_monObj->setVariable(
"adcMeanMedianBoard", std::accumulate(medians.begin(), medians.end(), 0.0) / medians.size());
452 m_monObj->setVariable(
"nDeadADC", nDeadADC);
453 m_monObj->setVariable(
"nBadADC", nBadADC);
454 m_monObj->setVariable(
"tdcEdge", std::accumulate(tdcEdges.begin(), tdcEdges.end(), 0.0) / (tdcEdges.size() - 1 - nDeadTDC));
455 m_monObj->setVariable(
"nDeadTDC", nDeadTDC);
456 m_monObj->setVariable(
"tdcSlope", std::accumulate(tdcSlopes.begin(), tdcSlopes.end(), 0.0) / (tdcSlopes.size() - 1 - nDeadTDC));
464 delete hHitRatePerWire;