Project
Loading...
Searching...
No Matches
RawDisplay.cxx
Go to the documentation of this file.
1// Copyright 2019-2023 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#include "TRDQC/RawDisplay.h"
16
17#include <TVirtualPad.h>
18#include <TPad.h>
19#include <TCanvas.h>
20#include <TH2.h>
21#include <TLine.h>
22#include <TMarker.h>
23
24using namespace o2::trd;
25
26namespace o2::trd
27{
28
31{
32 // obtain pad number relative to MCM center
33 float padLocal = tracklet.getPositionBinSigned() * constants::GRANULARITYTRKLPOS;
34 // MCM number in column direction (0..7)
35 int mcmCol = (tracklet.getMCM() % constants::NMCMROBINCOL) + constants::NMCMROBINCOL * (tracklet.getROB() % 2);
36
37 // original calculation
38 // FIXME: understand why the offset seems to be 6 pads and not nChannels / 2 = 10.5
39 // return CAMath::Round(6.f + mcmCol * ((float)constants::NCOLMCM) + padLocal);
40
41 // my calculation
42 return float((mcmCol + 1) * constants::NCOLMCM) + padLocal - 10.0;
43}
44
45}; // namespace o2::trd
46
47RawDisplay::RawDisplay(RawDataSpan& dataspan, TVirtualPad* pad)
48 : mDataSpan(dataspan), mPad(pad)
49{
50}
51
52MCMDisplay::MCMDisplay(RawDataSpan& mcmdata, TVirtualPad* pad)
53 : RawDisplay(mcmdata, pad) // initializes mDataSpan, mPad
54{
55 int det = -1, rob = -1, mcm = -1;
56
57 if (std::distance(mDataSpan.digits.begin(), mDataSpan.digits.end())) {
58 auto x = *mDataSpan.digits.begin();
59 det = x.getDetector();
60 rob = x.getROB();
61 mcm = x.getMCM();
62 } else if (std::distance(mDataSpan.tracklets.begin(), mDataSpan.tracklets.end())) {
63 auto x = *mDataSpan.tracklets.begin();
64 det = x.getDetector();
65 rob = x.getROB();
66 mcm = x.getMCM();
67 } else {
68 O2ERROR("found neither digits nor tracklets in MCM");
69 assert(false);
70 }
71
72 mName = Form("det%03d_rob%d_mcm%02d", det, rob, mcm);
73 mDesc = Form("Detector %02d_%d_%d (%03d) - MCM %d:%02d", det / 30, (det % 30) / 6, det % 6, det, rob, mcm);
74 ;
75
76 // MCM column number on ROC [0..7]
78
79 mFirstPad = mcmcol * constants::NCOLMCM - 1;
80 mLastPad = (mcmcol + 1) * constants::NCOLMCM + 2;
81
82 if (pad == nullptr) {
83 mPad = new TCanvas(mName.c_str(), mDesc.c_str(), 800, 600);
84 } else {
85 mPad = pad;
86 mPad->SetName(mName.c_str());
87 mPad->SetTitle(mDesc.c_str());
88 }
89
90 mDigitsHisto = new TH2F(mName.c_str(), (mDesc + ";pad;time bin").c_str(), (mLastPad - mFirstPad), mFirstPad, mLastPad, 30, 0., 30.);
91
92 for (auto digit : mDataSpan.digits) {
93 auto adc = digit.getADC();
94 for (int tb = 0; tb < 30; ++tb) {
95 mDigitsHisto->Fill(digit.getPadCol(), tb, adc[tb]);
96 }
97 }
98 mDigitsHisto->SetStats(0);
99}
100
101void RawDisplay::drawDigits(std::string opt)
102{
103 mPad->cd();
104 mDigitsHisto->Draw(opt.c_str());
105}
106
108{
109 mPad->cd();
110
111 TLine trkl;
112 trkl.SetLineColor(kRed);
113 trkl.SetLineWidth(3);
114
115 for (auto tracklet : mDataSpan.tracklets) {
116 auto pos = PadColF(tracklet);
117 auto slope = -tracklet.getSlopeBinSigned() * constants::GRANULARITYTRKLSLOPE / constants::ADDBITSHIFTSLOPE;
118 trkl.DrawLine(pos, 0, pos + 30 * slope, 30);
119 }
120}
121
123{
124 mPad->cd();
125
126 drawDigits();
127
128 TMarker clustermarker;
129 clustermarker.SetMarkerColor(kRed);
130 clustermarker.SetMarkerStyle(2);
131 clustermarker.SetMarkerSize(1.5);
132
133 TMarker cogmarker;
134 cogmarker.SetMarkerColor(kGreen);
135 cogmarker.SetMarkerStyle(3);
136 cogmarker.SetMarkerSize(1.5);
137 for (int t = 1; t <= mDigitsHisto->GetNbinsY(); ++t) {
138 for (int p = 2; p <= mDigitsHisto->GetNbinsX() - 1; ++p) {
139 // cout << p << "/" << t << " -> " << mDigitsHisto->GetBinContent(i,j) << endl;
140 double baseline = 9.5;
141 double left = mDigitsHisto->GetBinContent(p - 1, t) - baseline;
142 double centre = mDigitsHisto->GetBinContent(p, t) - baseline;
143 double right = mDigitsHisto->GetBinContent(p + 1, t) - baseline;
144 if (centre > left && centre > right && (centre + left + right) > mClusterThreshold) {
145 double pos = 0.5 * log(right / left) / log(centre * centre / left / right);
146 double clpos = mDigitsHisto->GetXaxis()->GetBinCenter(p) + pos;
147 double cog = (right - left) / (right + centre + left) + mDigitsHisto->GetXaxis()->GetBinCenter(p);
148 // cout << "t=" << t << " p=" << p
149 // << ": ADCs = " << left << " / " << centre << " / " << right
150 // << " pos = " << pos << " ~ " << clpos
151 // << endl;
152 clustermarker.DrawMarker(clpos, t - 0.5);
153 // cogmarker.DrawMarker(cog, t - 0.5);
154 }
155 }
156 }
157}
158
160{
161 TMarker hitmarker;
162 hitmarker.SetMarkerColor(kBlue);
163 hitmarker.SetMarkerStyle(38);
164 for (auto hit : mDataSpan.hits) {
165 if (hit.getCharge() > 0.0) {
166 hitmarker.SetMarkerSize(log10(hit.getCharge()));
167 hitmarker.DrawMarker(hit.getPadCol(), hit.getTimeBin());
168 }
169 }
170}
171
173{
174 TLine line;
175 line.SetLineColor(kBlue);
176 line.SetLineWidth(2.0);
177
178 for (auto& trkl : mDataSpan.makeMCTrackSegments()) {
179 line.DrawLine(trkl.getStartPoint().getPadCol(), trkl.getStartPoint().getTimeBin(), trkl.getEndPoint().getPadCol(), trkl.getEndPoint().getTimeBin());
180 }
181}
uint16_t mcm
uint16_t rob
Global TRD definitions and constants.
#define O2ERROR(...)
Definition Logger.h:18
uint16_t pos
Definition RawData.h:3
uint16_t slope
Definition RawData.h:1
MCMDisplay(RawDataSpan &mcmdata, TVirtualPad *pad=nullptr)
TVirtualPad * mPad
Definition RawDisplay.h:49
std::string mName
Definition RawDisplay.h:51
RawDisplay(RawDataSpan &dataspan, TVirtualPad *pad=nullptr)
void drawDigits(std::string opt="colz")
std::string mDesc
Definition RawDisplay.h:52
RawDataSpan & mDataSpan
Definition RawDisplay.h:48
GLint GLenum GLint x
Definition glcorearb.h:403
GLdouble GLdouble right
Definition glcorearb.h:4077
GLint left
Definition glcorearb.h:1979
constexpr int NMCMROBINCOL
the number of MCMs per ROB in column direction
Definition Constants.h:49
constexpr float GRANULARITYTRKLSLOPE
granularity of slope in tracklet64 word in pads/timebin
Definition Constants.h:70
constexpr int NCOLMCM
the number of pads per MCM
Definition Constants.h:53
constexpr int ADDBITSHIFTSLOPE
in the TRAP the slope is shifted by 3 additional bits compared to the position
Definition Constants.h:66
constexpr float GRANULARITYTRKLPOS
granularity of position in tracklet64 word in pad-widths
Definition Constants.h:69
float PadColF(o2::trd::Tracklet64 &tracklet)
Modified version of o2::trd::Tracklet64::getPadCol returning a float.
static int getROBSide(int irob)
boost::iterator_range< std::vector< o2::trd::Tracklet64 >::iterator > tracklets
std::vector< TrackSegment > makeMCTrackSegments()
boost::iterator_range< std::vector< o2::trd::Digit >::iterator > digits
boost::iterator_range< std::vector< HitPoint >::iterator > hits
ArrayADC adc