Skip to content

Commit 9e8e30b

Browse files
authored
Implement a few fixes (#14)
* Fix typo in initialisation of SegmentationSuperAlpide * Fix final y in digitisation * Fix macro to test clusters * Fix trailing whitespace
1 parent 87868f7 commit 9e8e30b

5 files changed

Lines changed: 95 additions & 89 deletions

File tree

Detectors/Upgrades/IT3/macros/test/CMakeLists.txt

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,9 @@
99
# granted to it by virtue of its status as an Intergovernmental Organization
1010
# or submit itself to any jurisdiction.
1111

12-
# o2_add_test_root_macro(CheckDigitsITS3.C
13-
# PUBLIC_LINK_LIBRARIES O2::ITSBase
14-
# O2::ITS3Base
15-
# O2::ITSMFTBase
16-
# O2::ITSMFTSimulation
17-
# O2::ITS3Simulation
18-
# O2::MathUtils
19-
# O2::SimulationDataFormat
20-
# O2::DetectorsBase
21-
# LABELS its3)
22-
23-
# o2_add_test_root_macro(CheckClustersITS3.C
24-
# PUBLIC_LINK_LIBRARIES O2::ITSBase
25-
# O2::ITS3Base
26-
# O2::ITSMFTBase
27-
# O2::ITSMFTSimulation
28-
# O2::ITS3Simulation
29-
# O2::ITS3Reconstruction
30-
# O2::MathUtils
31-
# O2::SimulationDataFormat
32-
# O2::DetectorsBase
33-
# LABELS its3)
34-
o2_add_test_root_macro(CheckSquasherITS3.C
12+
o2_add_test_root_macro(CheckDigitsITS3.C
13+
LABELS its3)
14+
o2_add_test_root_macro(CheckClustersITS3.C
15+
LABELS its3)
16+
o2_add_test_root_macro(CheckSquasherITS3.C
3517
LABELS its3)

Detectors/Upgrades/IT3/macros/test/CheckClustersITS3.notest renamed to Detectors/Upgrades/IT3/macros/test/CheckClustersITS3.C

Lines changed: 65 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <TNtuple.h>
1010
#include <TString.h>
1111
#include <TTree.h>
12+
#include <TROOT.h>
13+
#include <TStyle.h>
1214

1315
#include "DetectorsCommonDataFormats/DetID.h"
1416
#include "ITSMFTBase/SegmentationAlpide.h"
@@ -26,9 +28,14 @@
2628
#include "DetectorsCommonDataFormats/DetectorNameConf.h"
2729
#endif
2830

29-
void CheckClustersITS3(std::string clusfile = "o2clus_it3.root", std::string hitfile = "o2sim_HitsIT3.root",
30-
std::string inputGeom = "", std::string dictfile = "")
31+
void CheckClustersITS3(int nITS3layers = 3, std::string clusfile = "o2clus_it3.root", std::string hitfile = "o2sim_HitsIT3.root",
32+
std::string inputGeom = "", std::string dictfile = "", bool batch = true)
3133
{
34+
gROOT->SetBatch(batch);
35+
36+
// we assume that we have 2 chips per layer
37+
const int nChipsPerLayer = 2;
38+
3239
const int QEDSourceID = 99; // Clusters from this MC source correspond to QED electrons
3340

3441
using namespace o2::base;
@@ -158,21 +165,24 @@ void CheckClustersITS3(std::string clusfile = "o2clus_it3.root", std::string hit
158165
auto pattID = cluster.getPatternID();
159166
o2::math_utils::Point3D<float> locC;
160167
auto chipID = cluster.getSensorID();
161-
if (pattID == o2::itsmft::CompCluster::InvalidPatternID || dict.isGroup(pattID)) {
168+
if (pattID == o2::its3::CompCluster::InvalidPatternID || dict.isGroup(pattID)) {
162169
o2::itsmft::ClusterPattern patt(pattIt);
163170
locC = dict.getClusterCoordinates(chipID, cluster, patt, false);
164171
} else {
165172
locC = dict.getClusterCoordinates(chipID, cluster);
166173
errX = dict.getErrX(pattID);
167174
errZ = dict.getErrZ(pattID);
168175
npix = dict.getNpixels(pattID);
176+
LOGP(info, "I am invalid and I am on chip {}", chipID);
169177
}
170178
// Transformation to the local --> global
171-
auto gloC = gman->getMatrixL2G(chipID) * locC;
172-
if (chipID < o2::its3::SegmentationSuperAlpide::NLayers) {
173-
double radius = SegmentationSuperAlpide::Radii[chipID];
174-
double phi = locC.X() / radius;
175-
gloC.SetXYZ(radius * std::cos(phi), radius * std::sin(phi), locC.Z());
179+
auto gloC = gman->getMatrixL2G(chipID)(locC);
180+
if (chipID / nChipsPerLayer < nITS3layers) {
181+
double radius = SegmentationSuperAlpide::Radii[chipID / nChipsPerLayer];
182+
183+
bool isTop = !(chipID % nChipsPerLayer);
184+
double phi = locC.X() / radius + (isTop ? -0.5 : +0.5) * (float)TMath::Pi();
185+
gloC.SetXYZ(-radius * std::cos(phi), -(isTop ? radius * std::sin(phi) - 0.1 / 2 : radius * std::sin(phi) + 0.1 / 2), locC.Z());
176186
}
177187

178188
const auto& lab = (clusLabArr->getLabels(clEntry))[0];
@@ -195,24 +205,34 @@ void CheckClustersITS3(std::string clusfile = "o2clus_it3.root", std::string hit
195205
float dx = 0, dz = 0;
196206
int ievH = lab.getEventID();
197207
o2::math_utils::Point3D<float> locH, locHsta;
208+
o2::math_utils::Point3D<float> gloH, gloHsta;
198209

199210
// mean local position of the hit
200211
locH = gman->getMatrixL2G(chipID) ^ (hit.GetPos()); // inverse conversion from global to local
201212
locHsta = gman->getMatrixL2G(chipID) ^ (hit.GetPosStart());
202213

203-
if (chipID < 4) {
204-
float startPhi{std::atan2(-hit.GetPosStart().Y(), -hit.GetPosStart().X())};
205-
float endPhi{std::atan2(-hit.GetPos().Y(), -hit.GetPos().X())};
206-
locH.SetXYZ(SegmentationSuperAlpide::Radii[chipID] * endPhi, 0.f, hit.GetPos().Z());
207-
locHsta.SetXYZ(SegmentationSuperAlpide::Radii[chipID] * startPhi, 0.f, hit.GetPosStart().Z());
214+
if (chipID / nChipsPerLayer < nITS3layers) {
215+
bool isTop = !(chipID % nChipsPerLayer);
216+
float reShiftedY = isTop ? hit.GetPosStart().Y() - 0.1 / 2 : hit.GetPosStart().Y() + 0.1 / 2;
217+
float startPhi{std::atan2(-reShiftedY, -hit.GetPosStart().X()) + (isTop ? (float)TMath::Pi() / 2 : -(float)TMath::Pi() / 2)};
218+
float reShiftedEndY = isTop ? hit.GetPos().Y() - 0.1 / 2 : hit.GetPos().Y() + 0.1 / 2;
219+
float endPhi{std::atan2(-reShiftedEndY, -hit.GetPos().X()) + (isTop ? (float)TMath::Pi() / 2 : -(float)TMath::Pi() / 2)};
220+
float deltaY = reShiftedEndY - reShiftedY;
221+
locH.SetXYZ(SegmentationSuperAlpide::Radii[chipID / nChipsPerLayer] * endPhi, 0.f, hit.GetPos().Z());
222+
locHsta.SetXYZ(SegmentationSuperAlpide::Radii[chipID / nChipsPerLayer] * startPhi, deltaY, hit.GetPosStart().Z());
208223
}
209-
210224
auto x0 = locHsta.X(), dltx = locH.X() - x0;
211225
auto y0 = locHsta.Y(), dlty = locH.Y() - y0;
212226
auto z0 = locHsta.Z(), dltz = locH.Z() - z0;
213-
auto r = (0.5 * (Segmentation::SensorLayerThickness - Segmentation::SensorLayerThicknessEff) - y0) / dlty;
214-
locH.SetXYZ(x0 + r * dltx, y0 + r * dlty, z0 + r * dltz);
215-
//locH.SetXYZ(0.5 * (locH.X() + locHsta.X()), 0.5 * (locH.Y() + locHsta.Y()), 0.5 * (locH.Z() + locHsta.Z()));
227+
228+
if (chipID / nChipsPerLayer >= nITS3layers) {
229+
auto r = (0.5 * (Segmentation::SensorLayerThickness - Segmentation::SensorLayerThicknessEff) - y0) / dlty;
230+
locH.SetXYZ(x0 + r * dltx, y0 + r * dlty, z0 + r * dltz);
231+
} else {
232+
// not really precise, but okish
233+
locH.SetXYZ(0.5 * (locH.X() + locHsta.X()), 0.5 * (locH.Y() + locHsta.Y()), 0.5 * (locH.Z() + locHsta.Z()));
234+
}
235+
216236
std::array<float, 18> data = {(float)lab.getEventID(), (float)trID,
217237
locH.X(), locH.Z(), dltx / dlty, dltz / dlty,
218238
gloC.X(), gloC.Y(), gloC.Z(),
@@ -223,30 +243,34 @@ void CheckClustersITS3(std::string clusfile = "o2clus_it3.root", std::string hit
223243
}
224244
}
225245

226-
new TCanvas;
227-
nt.Draw("cgy:cgx");
228-
new TCanvas;
229-
nt.Draw("dz:dx", "abs(dz)<0.01 && abs(dx)<0.01");
230-
new TCanvas;
231-
nt.Draw("dz:tz", "abs(dz)<0.005 && abs(tz)<2");
232-
233-
auto c1 = new TCanvas("p1", "pullX");
234-
c1->cd();
235-
c1->SetLogy();
236-
nt.Draw("dx/ex", "abs(dx/ex)<10&&patid<10");
237-
auto c2 = new TCanvas("p2", "pullZ");
238-
c2->cd();
239-
c2->SetLogy();
240-
nt.Draw("dz/ez", "abs(dz/ez)<10&&patid<10");
241-
242-
auto d1 = new TCanvas("d1", "deltaX");
243-
d1->cd();
244-
d1->SetLogy();
245-
nt.Draw("dx", "abs(dx)<5");
246-
auto d2 = new TCanvas("d2", "deltaZ");
247-
d2->cd();
248-
d2->SetLogy();
249-
nt.Draw("dz", "abs(dz)<5");
246+
auto canvCgXCgY = new TCanvas("canvCgXCgY", "", 1600, 1600);
247+
canvCgXCgY->Divide(2, 2);
248+
canvCgXCgY->cd(1);
249+
nt.Draw("cgy:cgx>>h_cgy_vs_cgx_IB(1000, -10, 10, 1000, -10, 10)", "id < 6", "colz");
250+
canvCgXCgY->cd(2);
251+
nt.Draw("cgy:cgz>>h_cgy_vs_cgz_IB(1000, -15, 15, 1000, -10, 10)", "id < 6", "colz");
252+
canvCgXCgY->cd(3);
253+
nt.Draw("cgy:cgx>>h_cgy_vs_cgx_OB(1000, -50, 50, 1000, -50, 50)", "id >= 6", "colz");
254+
canvCgXCgY->cd(4);
255+
nt.Draw("cgy:cgz>>h_cgy_vs_cgz_OB(1000, -100, 100, 1000, -50, 50)", "id >= 6", "colz");
256+
canvCgXCgY->SaveAs("it3clusters_y_vs_x_vs_z.pdf");
257+
258+
auto canvdXdZ = new TCanvas("canvdXdZ", "", 1600, 800);
259+
canvdXdZ->Divide(2, 1);
260+
canvdXdZ->cd(1);
261+
nt.Draw("dx:dz>>h_dx_vs_dz_IB(1000, -0.025, 0.025, 1000, -0.025, 0.025)", "id < 6", "colz");
262+
canvdXdZ->cd(2);
263+
nt.Draw("dx:dz>>h_dx_vs_dz_OB(1000, -0.025, 0.025, 1000, -0.025, 0.025)", "id >= 6", "colz");
264+
canvdXdZ->SaveAs("it3clusters_dx_vs_dz.pdf");
265+
266+
// auto c1 = new TCanvas("p1", "pullX");
267+
// c1->cd();
268+
// c1->SetLogy();
269+
// nt.Draw("dx/ex", "abs(dx/ex)<10&&patid<10");
270+
// auto c2 = new TCanvas("p2", "pullZ");
271+
// c2->cd();
272+
// c2->SetLogy();
273+
// nt.Draw("dz/ez", "abs(dz/ez)<10&&patid<10");
250274

251275
fout.cd();
252276
nt.Write();

Detectors/Upgrades/IT3/macros/test/CheckDigitsITS3.C

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929

3030
void CheckDigitsITS3(int nITS3layers = 3, std::string digifile = "it3digits.root", std::string hitfile = "o2sim_HitsIT3.root", std::string inputGeom = "", std::string paramfile = "o2sim_par.root", bool batch = true)
3131
{
32-
if (batch) {
33-
gROOT->SetBatch();
34-
}
32+
gROOT->SetBatch(batch);
3533

3634
using namespace o2::base;
3735

@@ -217,8 +215,9 @@ void CheckDigitsITS3(int nITS3layers = 3, std::string digifile = "it3digits.root
217215
float startPhi{std::atan2(-reShiftedY, -hit.GetPosStart().X()) + (isTop ? (float)TMath::Pi() / 2 : -(float)TMath::Pi() / 2)};
218216
float reShiftedEndY = isTop ? hit.GetPos().Y() - 0.1 / 2 : hit.GetPos().Y() + 0.1 / 2;
219217
float endPhi{std::atan2(-reShiftedEndY, -hit.GetPos().X()) + (isTop ? (float)TMath::Pi() / 2 : -(float)TMath::Pi() / 2)};
218+
float deltaY = reShiftedEndY - reShiftedY;
220219
locH.SetXYZ(SegmentationSuperAlpide::Radii[chipID / nChipsPerLayer] * endPhi, 0.f, hit.GetPos().Z());
221-
locHsta.SetXYZ(SegmentationSuperAlpide::Radii[chipID / nChipsPerLayer] * startPhi, 0.f, hit.GetPosStart().Z());
220+
locHsta.SetXYZ(SegmentationSuperAlpide::Radii[chipID / nChipsPerLayer] * startPhi, deltaY, hit.GetPosStart().Z());
222221
}
223222

224223
locH.SetXYZ(0.5 * (locH.X() + locHsta.X()), 0.5 * (locH.Y() + locHsta.Y()), 0.5 * (locH.Z() + locHsta.Z()));
@@ -253,15 +252,15 @@ void CheckDigitsITS3(int nITS3layers = 3, std::string digifile = "it3digits.root
253252
nt->Draw("y:x>>h_y_vs_x_OB(1000, -50, 50, 1000, -50, 50)", "id >= 6", "colz");
254253
canvXY->cd(4);
255254
nt->Draw("y:z>>h_y_vs_z_OB(1000, -100, 100, 1000, -50, 50)", "id >= 6", "colz");
256-
canvXY->SaveAs("y_vs_x_vs_z.pdf");
255+
canvXY->SaveAs("it3digits_y_vs_x_vs_z.pdf");
257256

258257
auto canvdXdZ = new TCanvas("canvdXdZ", "", 1600, 800);
259258
canvdXdZ->Divide(2, 1);
260259
canvdXdZ->cd(1);
261260
nt->Draw("dx:dz>>h_dx_vs_dz_IB(1000, -0.025, 0.025, 1000, -0.025, 0.025)", "id < 6", "colz");
262261
canvdXdZ->cd(2);
263262
nt->Draw("dx:dz>>h_dx_vs_dz_OB(1000, -0.025, 0.025, 1000, -0.025, 0.025)", "id >= 6", "colz");
264-
canvdXdZ->SaveAs("dx_vs_dz.pdf");
263+
canvdXdZ->SaveAs("it3digits_dx_vs_dz.pdf");
265264

266265
f->Write();
267266
f->Close();

Detectors/Upgrades/IT3/reconstruction/src/TopologyDictionary.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ math_utils::Point3D<float> TopologyDictionary::getClusterCoordinates(int detID,
2222
{
2323

2424
static SegmentationSuperAlpide segmentations[6]{SegmentationSuperAlpide(0),
25+
SegmentationSuperAlpide(0),
26+
SegmentationSuperAlpide(1),
2527
SegmentationSuperAlpide(1),
2628
SegmentationSuperAlpide(2),
27-
SegmentationSuperAlpide(3),
28-
SegmentationSuperAlpide(4),
29-
SegmentationSuperAlpide(5)}; // TODO: fix NLayers
29+
SegmentationSuperAlpide(2)}; // TODO: fix NLayers
3030
math_utils::Point3D<float> locCl;
3131
if (detID >= 6) { // TODO: fix NLayers
3232
o2::itsmft::SegmentationAlpide::detectorToLocalUnchecked(cl.getRow(), cl.getCol(), locCl);
@@ -41,11 +41,11 @@ math_utils::Point3D<float> TopologyDictionary::getClusterCoordinates(int detID,
4141
math_utils::Point3D<float> TopologyDictionary::getClusterCoordinates(int detID, const its3::CompCluster& cl, const itsmft::ClusterPattern& patt, bool isGroup)
4242
{
4343
static SegmentationSuperAlpide segmentations[6]{SegmentationSuperAlpide(0),
44+
SegmentationSuperAlpide(0),
45+
SegmentationSuperAlpide(1),
4446
SegmentationSuperAlpide(1),
4547
SegmentationSuperAlpide(2),
46-
SegmentationSuperAlpide(3),
47-
SegmentationSuperAlpide(4),
48-
SegmentationSuperAlpide(5)}; // TODO: fix NLayers
48+
SegmentationSuperAlpide(2)}; // TODO: fix NLayers
4949

5050
auto refRow = cl.getRow();
5151
auto refCol = cl.getCol();

Detectors/Upgrades/IT3/simulation/src/Digitizer.cxx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -236,22 +236,23 @@ void Digitizer::processHit(const o2::itsmft::Hit& hit, uint32_t& maxFr, int evID
236236
float gap = 0.1; // FIXME: get this properly!
237237
auto startPos = hit.GetPosStart();
238238
// LOGP(info, "StartPos: {} {} {}", startPos.X(), startPos.Y(), startPos.Z());
239-
bool isTop = startPos.Y() > 0;
240-
float reShiftedStartY = isTop ? startPos.Y() - gap / 2 : startPos.Y() + gap / 2; // This is due to the gap between the ITS3 emispheres
241-
float startPhi{std::atan2(-reShiftedStartY, -startPos.X()) + (isTop ? constants::math::PI / 2 : -constants::math::PI / 2)};
242-
if (innerBarrel) {
243-
// LOGP(info, "X: {}, Y: {}, startPhi: {}", startPos.X(), reShiftedStartY, startPhi);
244-
}
245-
auto endPos = hit.GetPos();
246-
float reShiftedEndY = isTop ? endPos.Y() - gap / 2 : endPos.Y() + gap / 2; // This is due to the gap between the ITS3 emispheres
247-
float endPhi{std::atan2(-reShiftedEndY, -endPos.X()) + (isTop ? constants::math::PI / 2 : -constants::math::PI / 2)};
248-
if (innerBarrel) {
249-
// LOGP(info, "X: {}, Y: {}, endPhi: {}", endPos.X(), reShiftedEndY, endPhi);
250-
}
251239
math_utils::Vector3D<float> xyzLocS, xyzLocE;
252240
if (innerBarrel) {
241+
bool isTop = startPos.Y() > 0;
242+
float reShiftedStartY = isTop ? startPos.Y() - gap / 2 : startPos.Y() + gap / 2; // This is due to the gap between the ITS3 emispheres
243+
float startPhi{std::atan2(-reShiftedStartY, -startPos.X()) + (isTop ? constants::math::PI / 2 : -constants::math::PI / 2)};
244+
if (innerBarrel) {
245+
// LOGP(info, "X: {}, Y: {}, startPhi: {}", startPos.X(), reShiftedStartY, startPhi);
246+
}
247+
auto endPos = hit.GetPos();
248+
float reShiftedEndY = isTop ? endPos.Y() - gap / 2 : endPos.Y() + gap / 2; // This is due to the gap between the ITS3 emispheres
249+
float endPhi{std::atan2(-reShiftedEndY, -endPos.X()) + (isTop ? constants::math::PI / 2 : -constants::math::PI / 2)};
250+
if (innerBarrel) {
251+
// LOGP(info, "X: {}, Y: {}, endPhi: {}", endPos.X(), reShiftedEndY, endPhi);
252+
}
253+
float deltaY = reShiftedEndY - reShiftedEndY;
253254
xyzLocS = {SegmentationSuperAlpide::Radii[mLayerID[detID]] * (startPhi), 0.f, startPos.Z()};
254-
xyzLocE = {SegmentationSuperAlpide::Radii[mLayerID[detID]] * (endPhi), 0.f, endPos.Z()};
255+
xyzLocE = {SegmentationSuperAlpide::Radii[mLayerID[detID]] * (endPhi), deltaY, endPos.Z()};
255256
} else {
256257
xyzLocS = matrix ^ (hit.GetPosStart());
257258
xyzLocE = matrix ^ (hit.GetPos());

0 commit comments

Comments
 (0)