Skip to content

Commit 3f679a6

Browse files
andreasmolandershahor02
authored andcommitted
FIT: Geometry alignment macros
- Make misalignment macros usable for creating exact misalignments - Add macro for reading misalignments from CCDB - Add a couple of plots to hit reading marcos (needed to verify misalignments) - Minor change to FV0 geometry to provoding symbolic names of alignable volumes
1 parent 90f3763 commit 3f679a6

File tree

8 files changed

+196
-46
lines changed

8 files changed

+196
-46
lines changed

Detectors/FIT/FT0/macros/FT0Misaligner.C

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
1+
// Copyright 2021-2025 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+
/// \file FT0Misaligner.C
13+
/// \brief ROOT macro for creating an FT0 geometry alignment object. Based on ITSMisaligner.C
14+
///
15+
/// \author Andreas Molander andreas.molander@cern.ch, Alla Maevskaya
16+
117
#if !defined(__CLING__) || defined(__ROOTCLING__)
2-
//#define ENABLE_UPGRADES
18+
19+
#include "CCDB/CcdbApi.h"
320
#include "DetectorsCommonDataFormats/DetID.h"
421
#include "DetectorsCommonDataFormats/DetectorNameConf.h"
522
#include "DetectorsCommonDataFormats/AlignParam.h"
6-
#include "DetectorsBase/GeometryManager.h"
7-
#include "CCDB/CcdbApi.h"
8-
#include "FT0Base/Geometry.h"
9-
#include <TRandom.h>
23+
1024
#include <TFile.h>
1125
#include <vector>
1226
#include <fmt/format.h>
27+
1328
#endif
1429

1530
using AlgPar = std::array<double, 6>;
@@ -23,19 +38,15 @@ void FT0Misaligner(const std::string& ccdbHost = "http://ccdb-test.cern.ch:8080"
2338
const std::string& fileName = "FT0Alignment.root")
2439
{
2540
std::vector<o2::detectors::AlignParam> params;
26-
o2::base::GeometryManager::loadGeometry("", false);
27-
// auto geom = o2::ft0::Geometry::Instance();
2841
AlgPar pars;
2942
bool glo = true;
3043

3144
o2::detectors::DetID detFT0("FT0");
3245

33-
// FT0 detector
34-
//set A side
3546
std::string symNameA = "FT0A";
3647
pars = generateMisalignment(xA, yA, zA, psiA, thetaA, phiA);
3748
params.emplace_back(symNameA.c_str(), -1, pars[0], pars[1], pars[2], pars[3], pars[4], pars[5], glo);
38-
//set C side
49+
3950
std::string symNameC = "FT0C";
4051
pars = generateMisalignment(xC, yC, zC, psiC, thetaC, phiC);
4152
params.emplace_back(symNameC.c_str(), -1, pars[0], pars[1], pars[2], pars[3], pars[4], pars[5], glo);
@@ -57,14 +68,15 @@ void FT0Misaligner(const std::string& ccdbHost = "http://ccdb-test.cern.ch:8080"
5768
algFile.Close();
5869
}
5970
}
71+
6072
AlgPar generateMisalignment(double x, double y, double z, double psi, double theta, double phi)
6173
{
6274
AlgPar pars;
63-
pars[0] = gRandom->Gaus(0, x);
64-
pars[1] = gRandom->Gaus(0, y);
65-
pars[2] = gRandom->Gaus(0, z);
66-
pars[3] = gRandom->Gaus(0, psi);
67-
pars[4] = gRandom->Gaus(0, theta);
68-
pars[5] = gRandom->Gaus(0, phi);
75+
pars[0] = x;
76+
pars[1] = y;
77+
pars[2] = z;
78+
pars[3] = psi;
79+
pars[4] = theta;
80+
pars[5] = phi;
6981
return std::move(pars);
7082
}

Detectors/FIT/FV0/base/include/FV0Base/Geometry.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ class Geometry
133133
return o2::base::GeometryManager::getPNEntry(getDetID(), index);
134134
}
135135

136+
static std::string getDetectorRightSymName()
137+
{
138+
return sDetectorRightName + "_0";
139+
}
140+
141+
static std::string getDetectorLeftSymName()
142+
{
143+
return sDetectorLeftName + "_1";
144+
}
145+
136146
/// Get the density of the PMTs.
137147
static constexpr float getPmtDensity()
138148
{
@@ -143,6 +153,8 @@ class Geometry
143153
explicit Geometry(EGeoType initType);
144154

145155
inline static const std::string sDetectorName = "FV0";
156+
inline static const std::string sDetectorRightName = sDetectorName + "RIGHT";
157+
inline static const std::string sDetectorLeftName = sDetectorName + "LEFT";
146158

147159
// General geometry constants
148160
static constexpr float sEpsilon = 0.01; ///< Used to make one spatial dimension infinitesimally larger than other

Detectors/FIT/FV0/macros/FV0Misaligner.C

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
1+
// Copyright 2021-2025 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+
/// \file FV0Misaligner.C
13+
/// \brief ROOT macro for creating an FV0 geometry alignment object. The alignment object will align both
14+
/// detector halves in the same way. Based on ITSMisaligner.C
15+
///
16+
/// \author Andreas Molander andreas.molander@cern.ch, Alla Maevskaya
17+
118
#if !defined(__CLING__) || defined(__ROOTCLING__)
19+
20+
#include "CCDB/CcdbApi.h"
221
#include "DetectorsCommonDataFormats/DetID.h"
322
#include "DetectorsCommonDataFormats/DetectorNameConf.h"
423
#include "DetectorsCommonDataFormats/AlignParam.h"
5-
#include "DetectorsBase/GeometryManager.h"
6-
#include "CCDB/CcdbApi.h"
7-
#include <TRandom.h>
24+
#include "FV0Base/Geometry.h"
25+
826
#include <TFile.h>
927
#include <vector>
1028
#include <fmt/format.h>
29+
1130
#endif
1231

1332
using AlgPar = std::array<double, 6>;
@@ -20,16 +39,14 @@ void FV0Misaligner(const std::string& ccdbHost = "http://ccdb-test.cern.ch:8080"
2039
const std::string& fileName = "FV0Alignment.root")
2140
{
2241
std::vector<o2::detectors::AlignParam> params;
23-
o2::base::GeometryManager::loadGeometry("", false);
2442
AlgPar pars;
2543
bool glo = true;
2644

2745
o2::detectors::DetID detFV0("FV0");
2846

29-
// FV0 detector
30-
for (int ihalf = 1; ihalf < 3; ihalf++) {
31-
std::string symName = Form("FV0half_%i", ihalf);
32-
pars = generateMisalignment(x, y, z, psi, theta, phi);
47+
pars = generateMisalignment(x, y, z, psi, theta, phi);
48+
49+
for (auto& symName : {o2::fv0::Geometry::getDetectorRightSymName(), o2::fv0::Geometry::getDetectorLeftSymName()}) {
3350
params.emplace_back(symName.c_str(), -1, pars[0], pars[1], pars[2], pars[3], pars[4], pars[5], glo);
3451
}
3552

@@ -50,14 +67,15 @@ void FV0Misaligner(const std::string& ccdbHost = "http://ccdb-test.cern.ch:8080"
5067
algFile.Close();
5168
}
5269
}
70+
5371
AlgPar generateMisalignment(double x, double y, double z, double psi, double theta, double phi)
5472
{
5573
AlgPar pars;
56-
pars[0] = gRandom->Gaus(0, x);
57-
pars[1] = gRandom->Gaus(0, y);
58-
pars[2] = gRandom->Gaus(0, z);
59-
pars[3] = gRandom->Gaus(0, psi);
60-
pars[4] = gRandom->Gaus(0, theta);
61-
pars[5] = gRandom->Gaus(0, phi);
74+
pars[0] = x;
75+
pars[1] = y;
76+
pars[2] = z;
77+
pars[3] = psi;
78+
pars[4] = theta;
79+
pars[5] = phi;
6280
return std::move(pars);
6381
}

Detectors/FIT/FV0/simulation/src/Detector.cxx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ void Detector::ConstructGeometry()
280280
// mGeometry->enableComponent(Geometry::eAluminiumContainer, false);
281281
mGeometry->buildGeometry();
282282
}
283+
283284
void Detector::addAlignableVolumes() const
284285
{
285286
//
@@ -292,19 +293,19 @@ void Detector::addAlignableVolumes() const
292293
LOG(info) << "FV0: Add alignable volumes";
293294

294295
if (!gGeoManager) {
295-
LOG(fatal) << "TGeoManager doesn't exist !";
296+
LOG(fatal) << "TGeoManager doesn't exist!";
296297
return;
297298
}
298299

299-
TString volPath, symName;
300-
for (auto& half : {"RIGHT_0", "LEFT_1"}) {
301-
volPath = Form("/cave_1/barrel_1/FV0_1/FV0%s", half);
302-
symName = Form("FV0%s", half);
303-
LOG(info) << "FV0: Add alignable volume: " << symName << ": " << volPath;
304-
if (!gGeoManager->SetAlignableEntry(symName.Data(), volPath.Data())) {
305-
LOG(fatal) << "FV0: Unable to set alignable entry! " << symName << ": " << volPath;
300+
auto addAlignabelVolume = [](const std::string& volPath, const std::string& symName) -> void {
301+
LOG(info) << "FV0: Add alignable volume: " << symName << " <-> " << volPath;
302+
if (!gGeoManager->SetAlignableEntry(symName.c_str(), volPath.c_str())) {
303+
LOG(fatal) << "FV0: Unable to set alignable entry! " << symName << " <-> " << volPath;
306304
}
307-
}
305+
};
306+
307+
addAlignabelVolume("/cave_1/barrel_1/FV0_1/FV0RIGHT_0", Geometry::getDetectorRightSymName());
308+
addAlignabelVolume("/cave_1/barrel_1/FV0_1/FV0LEFT_1", Geometry::getDetectorLeftSymName());
308309
}
309310

310311
o2::fv0::Hit* Detector::addHit(Int_t trackId, Int_t cellId,

Detectors/FIT/macros/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,9 @@ o2_add_test_root_macro(compareRecPoints.C
4545
O2::DataFormatsFIT
4646
LABELS fit)
4747

48+
o2_add_test_root_macro(readAlignParam.C
49+
PUBLIC_LINK_LIBRARIES O2::CCDB
50+
LABELS fit)
51+
4852
o2_data_file(COPY readFITDCSdata.C DESTINATION Detectors/FIT/macros/)
4953
o2_data_file(COPY readFITDeadChannelMap.C DESTINATION Detectors/FIT/macros/)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2019-2025 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+
/// \file readAlignParam.C
13+
/// \brief ROOT macro for reading geometry alignment parameters
14+
///
15+
/// \author Andreas Molander <andreas.molander@cern.ch>
16+
17+
#if !defined(__CLING__) || defined(__ROOTCLING__)
18+
19+
#include "CCDB/BasicCCDBManager.h"
20+
#include "DetectorsCommonDataFormats/AlignParam.h"
21+
#include "DetectorsCommonDataFormats/DetID.h"
22+
#include "DetectorsCommonDataFormats/DetectorNameConf.h"
23+
24+
#include <string>
25+
#include <vector>
26+
27+
#endif
28+
29+
int readAlignParam(const std::string& detectorName = "FT0",
30+
long timestamp = -1,
31+
const std::string& ccdbUrl = "https://alice-ccdb.cern.ch")
32+
{
33+
o2::ccdb::BasicCCDBManager& ccdbManager = o2::ccdb::BasicCCDBManager::instance();
34+
ccdbManager.setURL(ccdbUrl);
35+
ccdbManager.setTimestamp(timestamp);
36+
37+
const o2::detectors::DetID detID(detectorName.c_str());
38+
const std::string alignmentPath = o2::base::DetectorNameConf::getAlignmentPath(detID);
39+
const auto alignments = ccdbManager.get<std::vector<o2::detectors::AlignParam>>(alignmentPath);
40+
41+
if (!alignments) {
42+
std::cerr << "No alignment parameters found at " << alignmentPath << std::endl;
43+
return 1;
44+
}
45+
46+
for (auto alignment : *alignments) {
47+
alignment.print();
48+
}
49+
50+
return 0;
51+
}

Detectors/FIT/macros/readFT0hits.C

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
1+
// Copyright 2019-2025 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+
112
#if !defined(__CLING__) || defined(__ROOTCLING__)
13+
14+
#include "DataFormatsFIT/Triggers.h"
215
#include "DataFormatsFT0/Digit.h"
316
#include "DataFormatsFT0/HitType.h"
417
#include "SimulationDataFormat/MCEventHeader.h"
518
#include <TFile.h>
19+
#include <TH1F.h>
620
#include <TH2F.h>
721
#include <TTree.h>
822
#include "DetectorsCommonDataFormats/DetID.h"
923
#include "DetectorsCommonDataFormats/DetectorNameConf.h"
1024

25+
#endif
26+
1127
void readFT0hits()
1228
{
1329

@@ -24,6 +40,8 @@ void readFT0hits()
2440
TH2F* hPel = new TH2F("hPelDig", "N p.e. ", 220, 0, 220, 500, 0, 10000);
2541
TH2F* hXYA = new TH2F("hXYA", "X vs Y A side", 400, -20, 20, 400, -20, 20);
2642
TH2F* hXYC = new TH2F("hXYC", "X vs Y C side", 400, -20, 20, 400, -20, 20);
43+
TH1F* hZA = new TH1F("hZA", "Z A side", 200, 330, 340);
44+
TH1F* hZC = new TH1F("hZC", "Z C side", 200, -90, -80);
2745

2846
gDirectory = cwd;
2947

@@ -59,10 +77,13 @@ void readFT0hits()
5977
hTimeHitA->Fill(detID, hit_time[detID] - 11.04);
6078
hTimeHitC->Fill(detID, hit_time[detID] - 2.91);
6179
countE[detID]++;
62-
if (detID < 96)
80+
if (detID < 96) {
6381
hXYA->Fill(hit.GetX(), hit.GetY());
64-
if (detID > 95)
82+
hZA->Fill(hit.GetZ());
83+
} else {
6584
hXYC->Fill(hit.GetX(), hit.GetY());
85+
hZC->Fill(hit.GetZ());
86+
}
6687
}
6788
for (int ii = 0; ii < 220; ii++) {
6889
if (countE[ii] > 100) {
@@ -82,6 +103,6 @@ void readFT0hits()
82103
hMultHit->Write();
83104
hXYA->Write();
84105
hXYC->Write();
85-
106+
hZA->Write();
107+
hZC->Write();
86108
} // end of macro
87-
#endif

0 commit comments

Comments
 (0)