Skip to content

Commit 80278f6

Browse files
authored
Merge a39c7fa into sapling-pr-archive-ehellbar
2 parents 909eff9 + a39c7fa commit 80278f6

File tree

51 files changed

+1218
-356
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1218
-356
lines changed

DataFormats/common/include/CommonDataFormat/BunchFilling.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ class BunchFilling
107107

108108
ClassDefNV(BunchFilling, 2);
109109
};
110-
} // namespace o2
111110

112111
namespace framework
113112
{
@@ -118,5 +117,6 @@ struct is_messageable<o2::BunchFilling> : std::true_type {
118117
};
119118

120119
} // namespace framework
120+
} // namespace o2
121121

122122
#endif

DataFormats/simulation/src/DigitizationContext.cxx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ void DigitizationContext::applyMaxCollisionFilter(std::vector<std::tuple<int, in
577577
if (indices_old_to_new.find(lastindex) != indices_old_to_new.end()) {
578578
std::get<1>(tf_indices) = indices_old_to_new[lastindex]; // end;
579579
} else {
580-
std::get<1>(tf_indices) = newrecords.size(); // end;
580+
std::get<1>(tf_indices) = newrecords.size() - 1; // end; -1 since index inclusif
581581
}
582582
if (indices_old_to_new.find(previndex) != indices_old_to_new.end()) {
583583
std::get<2>(tf_indices) = indices_old_to_new[previndex]; // previous or "early" index
@@ -591,11 +591,6 @@ void DigitizationContext::applyMaxCollisionFilter(std::vector<std::tuple<int, in
591591
std::vector<std::tuple<int, int, int>> DigitizationContext::calcTimeframeIndices(long startOrbit, long orbitsPerTF, double orbitsEarly) const
592592
{
593593
auto timeframeindices = getTimeFrameBoundaries(mEventRecords, startOrbit, orbitsPerTF, orbitsEarly);
594-
LOG(info) << "Fixed " << timeframeindices.size() << " timeframes ";
595-
for (auto p : timeframeindices) {
596-
LOG(info) << std::get<0>(p) << " " << std::get<1>(p) << " " << std::get<2>(p);
597-
}
598-
599594
return timeframeindices;
600595
}
601596

@@ -708,7 +703,7 @@ DigitizationContext DigitizationContext::extractSingleTimeframe(int timeframeid,
708703
auto tf_ranges = timeframeindices.at(timeframeid);
709704

710705
auto startindex = std::get<0>(tf_ranges);
711-
auto endindex = std::get<1>(tf_ranges);
706+
auto endindex = std::get<1>(tf_ranges) + 1;
712707
auto earlyindex = std::get<2>(tf_ranges);
713708

714709
if (earlyindex >= 0) {

Detectors/AOD/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ target_link_libraries(
1919
O2::FDDWorkflow
2020
O2::FV0Workflow
2121
O2::Framework
22+
O2::FrameworkAnalysisSupport
2223
O2::GlobalTracking
2324
O2::GlobalTrackingWorkflow
2425
O2::ITSMFTWorkflow
@@ -75,6 +76,7 @@ o2_add_executable(
7576
O2::DataFormatsFT0
7677
O2::Steer
7778
O2::ZDCBase
79+
O2::FrameworkAnalysisSupport
7880
nlohmann_json::nlohmann_json
7981
)
8082

Detectors/Upgrades/ALICE3/TRK/base/include/TRKBase/GeometryTGeo.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
9393
int getModule(int index) const;
9494
int getChip(int index) const;
9595

96+
void defineMLOTSensors();
97+
int getBarrelLayer(int) const;
98+
99+
// sensor ref X and alpha for ML & OT
100+
void extractSensorXAlphaMLOT(int, float&, float&);
101+
102+
// cache for tracking frames (ML & OT)
103+
bool isTrackingFrameCachedMLOT() const { return !mCacheRefXMLOT.empty(); }
104+
void fillTrackingFramesCacheMLOT();
105+
106+
float getSensorRefAlphaMLOT(int index) const { return mCacheRefAlphaMLOT[index]; }
107+
float getSensorXMLOT(int index) const { return mCacheRefXMLOT[index]; }
108+
109+
// create matrix for tracking to local frame for MLOT
110+
TGeoHMatrix& createT2LMatrixMLOT(int);
111+
112+
/// This routine computes the chip index number from the subDetID, petal, disk, layer, stave /// TODO: retrieve also from chip when chips will be available
96113
/// This routine computes the chip index number from the subDetID, petal, disk, layer, stave, half stave, module, chip
97114
/// \param int subDetID The subdetector ID, 0 for VD, 1 for MLOT
98115
/// \param int petalcase The petal case number for VD, from 0 to 3
@@ -200,10 +217,14 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
200217

201218
bool mOwner = true; //! is it owned by the singleton?
202219

220+
std::vector<int> sensorsMLOT;
221+
std::vector<float> mCacheRefXMLOT; /// cache for X of ML and OT
222+
std::vector<float> mCacheRefAlphaMLOT; /// cache for sensor ref alpha ML and OT
223+
203224
private:
204225
static std::unique_ptr<o2::trk::GeometryTGeo> sInstance;
205226
};
206227

207228
} // namespace trk
208229
} // namespace o2
209-
#endif
230+
#endif

Detectors/Upgrades/ALICE3/TRK/base/src/GeometryTGeo.cxx

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <TRKBase/GeometryTGeo.h>
1313
#include <TGeoManager.h>
1414
#include "TRKBase/SegmentationChip.h"
15+
#include <TMath.h>
1516

1617
#include <limits>
1718

@@ -123,6 +124,8 @@ void GeometryTGeo::Build(int loadTrans)
123124

124125
setSize(numberOfChipsTotal);
125126
fillMatrixCache(loadTrans);
127+
defineMLOTSensors();
128+
fillTrackingFramesCacheMLOT();
126129
}
127130

128131
//__________________________________________________________________________
@@ -466,6 +469,32 @@ TGeoHMatrix* GeometryTGeo::extractMatrixSensor(int index) const
466469
return &matTmp;
467470
}
468471

472+
//__________________________________________________________________________
473+
void GeometryTGeo::defineMLOTSensors()
474+
{
475+
for (int i = 0; i < mSize; i++) {
476+
if (getSubDetID(i) == 0) {
477+
continue;
478+
}
479+
sensorsMLOT.push_back(i);
480+
}
481+
}
482+
483+
//__________________________________________________________________________
484+
void GeometryTGeo::fillTrackingFramesCacheMLOT()
485+
{
486+
// fill for every sensor of ML & OT its tracking frame parameters
487+
if (!isTrackingFrameCachedMLOT() && !sensorsMLOT.empty()) {
488+
size_t newSize = sensorsMLOT.size();
489+
mCacheRefXMLOT.resize(newSize);
490+
mCacheRefAlphaMLOT.resize(newSize);
491+
for (int i = 0; i < newSize; i++) {
492+
int sensorId = sensorsMLOT[i];
493+
extractSensorXAlphaMLOT(sensorId, mCacheRefXMLOT[i], mCacheRefAlphaMLOT[i]);
494+
}
495+
}
496+
}
497+
469498
//__________________________________________________________________________
470499
void GeometryTGeo::fillMatrixCache(int mask)
471500
{
@@ -488,6 +517,21 @@ void GeometryTGeo::fillMatrixCache(int mask)
488517
}
489518
}
490519

520+
// build T2L matrices for ML & OT !! VD is yet to be implemented once its geometry will be more refined
521+
if ((mask & o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L)) && !getCacheT2L().isFilled()) {
522+
LOGP(info, "Loading {} T2L matrices from TGeo for ML & OT", getName());
523+
if (sensorsMLOT.size()) {
524+
int m_Size = sensorsMLOT.size();
525+
auto& cacheT2L = getCacheT2L();
526+
cacheT2L.setSize(m_Size);
527+
for (int i = 0; i < m_Size; i++) {
528+
int sensorID = sensorsMLOT[i];
529+
TGeoHMatrix& hm = createT2LMatrixMLOT(sensorID);
530+
cacheT2L.setMatrix(Mat3D(hm), i); // here, sensorIDs from 0 to 374, sensorIDs shifted to 36 !
531+
}
532+
}
533+
}
534+
491535
// TODO: build matrices for the cases T2L, T2G and T2GRot when needed
492536
}
493537

@@ -1109,5 +1153,87 @@ void GeometryTGeo::Print(Option_t*) const
11091153
std::cout << "]" << std::endl;
11101154
}
11111155

1156+
//__________________________________________________________________________
1157+
int GeometryTGeo::getBarrelLayer(int chipID) const
1158+
{
1159+
// for barrel layers only,
1160+
// so it would be consistent with number of layers i.e. from 0 to 10,
1161+
// starting from VD0 to OT10;
1162+
// skip the disks;
1163+
1164+
int subDetID = getSubDetID(chipID);
1165+
int subLayerID = getLayer(chipID);
1166+
1167+
if (subDetID < 0 || subDetID > 1) {
1168+
LOG(error) << "getBarrelLayer(): Invalid subDetID for barrel: " << subDetID
1169+
<< ". Expected values are 0 or 1.";
1170+
return -1;
1171+
}
1172+
1173+
if (subLayerID < 0 || subLayerID > 7) {
1174+
LOG(error) << "getBarrelLayer(): Invalid subLayerID for barrel: " << subDetID
1175+
<< ". Expected values are between 0 and 7.";
1176+
return -1;
1177+
}
1178+
1179+
const int baseOffsets[] = {0, 3};
1180+
1181+
return baseOffsets[subDetID] + subLayerID;
1182+
}
1183+
1184+
//__________________________________________________________________________
1185+
void GeometryTGeo::extractSensorXAlphaMLOT(int chipID, float& x, float& alp)
1186+
{
1187+
// works for ML and OT only, a.k.a flat sensors !!!
1188+
double locA[3] = {-100., 0., 0.}, locB[3] = {100., 0., 0.}, gloA[3], gloB[3];
1189+
double xp{0}, yp{0};
1190+
1191+
if (getSubDetID(chipID) == 0) {
1192+
1193+
LOG(error) << "extractSensorXAlphaMLOT(): VD layers are not supported yet! chipID = " << chipID;
1194+
return;
1195+
1196+
} else { // flat sensors, ML and OT
1197+
const TGeoHMatrix* matL2G = extractMatrixSensor(chipID);
1198+
matL2G->LocalToMaster(locA, gloA);
1199+
matL2G->LocalToMaster(locB, gloB);
1200+
double dx = gloB[0] - gloA[0], dy = gloB[1] - gloA[1];
1201+
double t = (gloB[0] * dx + gloB[1] * dy) / (dx * dx + dy * dy);
1202+
xp = gloB[0] - dx * t;
1203+
yp = gloB[1] - dy * t;
1204+
}
1205+
1206+
alp = std::atan2(yp, xp);
1207+
x = std::hypot(xp, yp);
1208+
o2::math_utils::bringTo02Pi(alp);
1209+
1210+
/// TODO:
1211+
// once the VD segmentation is done, VD should be added
1212+
}
1213+
1214+
//__________________________________________________________________________
1215+
TGeoHMatrix& GeometryTGeo::createT2LMatrixMLOT(int chipID)
1216+
{
1217+
// works only for ML & OT
1218+
// for VD is yet to be implemented once we have more refined geometry
1219+
if (getSubDetID(chipID) == 0) {
1220+
1221+
LOG(error) << "createT2LMatrixMLOT(): VD layers are not supported yet! chipID = " << chipID
1222+
<< "returning dummy values! ";
1223+
static TGeoHMatrix dummy;
1224+
return dummy;
1225+
1226+
} else {
1227+
static TGeoHMatrix t2l;
1228+
t2l.Clear();
1229+
float alpha = getSensorRefAlphaMLOT(chipID);
1230+
t2l.RotateZ(alpha * TMath::RadToDeg());
1231+
const TGeoHMatrix* matL2G = extractMatrixSensor(chipID);
1232+
const TGeoHMatrix& matL2Gi = matL2G->Inverse();
1233+
t2l.MultiplyLeft(&matL2Gi);
1234+
return t2l;
1235+
}
1236+
}
1237+
11121238
} // namespace trk
11131239
} // namespace o2

Detectors/Upgrades/ALICE3/TRK/simulation/src/TRKLayer.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ TGeoVolume* TRKLayer::createMetalStack(std::string type)
9494
if (type == "cylinder") {
9595
metalStack = new TGeoTube(mInnerRadius + mSensorThickness, mInnerRadius + mChipThickness, mChipLength / 2); // TO BE CHECKED !!!
9696
} else if (type == "flat") {
97-
metalStack = new TGeoBBox(mChipWidth / 2, mChipThickness - mSensorThickness / 2, mChipLength / 2); // TO BE CHECKED !!!
97+
metalStack = new TGeoBBox(mChipWidth / 2, (mChipThickness - mSensorThickness) / 2, mChipLength / 2); // TO BE CHECKED !!!
9898
} else {
9999
LOGP(fatal, "Metal stack of type '{}' is not implemented", type);
100100
}
@@ -198,6 +198,9 @@ TGeoVolume* TRKLayer::createModule(std::string type)
198198

199199
TGeoCombiTrans* transLeft = new TGeoCombiTrans();
200200
transLeft->SetTranslation(xLeft, 0, zLeft); // TO BE CHECKED !!!
201+
TGeoRotation* rot = new TGeoRotation();
202+
rot->RotateY(180);
203+
transLeft->SetRotation(rot);
201204
LOGP(info, "Inserting {} in {} ", chipVolLeft->GetName(), moduleVol->GetName());
202205
moduleVol->AddNode(chipVolLeft, iChip * 2, transLeft);
203206

@@ -206,9 +209,6 @@ TGeoVolume* TRKLayer::createModule(std::string type)
206209

207210
TGeoCombiTrans* transRight = new TGeoCombiTrans();
208211
transRight->SetTranslation(xRight, 0, zRight); // TO BE CHECKED !!!
209-
TGeoRotation* rot = new TGeoRotation();
210-
rot->RotateY(180);
211-
transRight->SetRotation(rot);
212212
LOGP(info, "Inserting {} in {} ", chipVolRight->GetName(), moduleVol->GetName());
213213
moduleVol->AddNode(chipVolRight, iChip * 2 + 1, transRight);
214214
}

EventVisualisation/Base/src/DirectoryLoader.cxx

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,15 @@ using namespace o2::event_visualisation;
2929
deque<string> DirectoryLoader::load(const std::string& path, const std::string& marker, const std::vector<std::string>& ext)
3030
{
3131
deque<string> result;
32-
for (const auto& entry : std::filesystem::directory_iterator(path)) {
33-
if (std::find(ext.begin(), ext.end(), entry.path().extension()) != ext.end()) {
34-
result.push_back(entry.path().filename());
32+
try {
33+
for (const auto& entry : std::filesystem::directory_iterator(path)) {
34+
if (std::find(ext.begin(), ext.end(), entry.path().extension()) != ext.end()) {
35+
result.push_back(entry.path().filename());
36+
}
3537
}
38+
} catch (std::filesystem::filesystem_error const& ex) {
39+
LOGF(error, "filesystem problem during DirectoryLoader::load: %s", ex.what());
40+
return result;
3641
}
3742
// comparison with safety if marker not in the filename (-1+1 gives 0)
3843
std::sort(result.begin(), result.end(),
@@ -56,7 +61,8 @@ bool DirectoryLoader::canCreateNextFile(const std::vector<std::string>& paths, c
5661
}
5762
}
5863
} catch (std::filesystem::filesystem_error const& ex) {
59-
LOGF(info, "filesystem problem: %s", ex.what());
64+
LOGF(error, "filesystem problem during DirectoryLoader::canCreateNextFile: %s", ex.what());
65+
return false;
6066
}
6167
}
6268

@@ -87,12 +93,17 @@ bool DirectoryLoader::canCreateNextFile(const std::vector<std::string>& paths, c
8793
deque<string> DirectoryLoader::load(const std::vector<std::string>& paths, const std::string& marker, const std::vector<std::string>& ext)
8894
{
8995
deque<string> result;
90-
for (const auto& path : paths) {
91-
for (const auto& entry : std::filesystem::directory_iterator(path)) {
92-
if (std::find(ext.begin(), ext.end(), entry.path().extension()) != ext.end()) {
93-
result.push_back(entry.path().filename());
96+
try {
97+
for (const auto& path : paths) {
98+
for (const auto& entry : std::filesystem::directory_iterator(path)) {
99+
if (std::find(ext.begin(), ext.end(), entry.path().extension()) != ext.end()) {
100+
result.push_back(entry.path().filename());
101+
}
94102
}
95103
}
104+
} catch (std::filesystem::filesystem_error const& ex) {
105+
LOGF(error, "filesystem problem during DirectoryLoader::load: %s", ex.what());
106+
return result;
96107
}
97108
// comparison with safety if marker not in the filename (-1+1 gives 0)
98109
std::sort(result.begin(), result.end(),
@@ -135,10 +146,14 @@ std::time_t to_time_t(TP tp)
135146
int DirectoryLoader::getNumberOfFiles(const std::string& path, std::vector<std::string>& ext)
136147
{
137148
int res = 0;
138-
for (const auto& entry : std::filesystem::directory_iterator(path)) {
139-
if (std::find(ext.begin(), ext.end(), entry.path().extension()) != ext.end()) {
140-
res++;
149+
try {
150+
for (const auto& entry : std::filesystem::directory_iterator(path)) {
151+
if (std::find(ext.begin(), ext.end(), entry.path().extension()) != ext.end()) {
152+
res++;
153+
}
141154
}
155+
} catch (std::filesystem::filesystem_error const& ex) {
156+
LOGF(error, "filesystem problem during DirectoryLoader::getNumberOfFiles: %s", ex.what());
142157
}
143158
return res;
144159
}
@@ -160,8 +175,12 @@ std::string DirectoryLoader::getLatestFile(const std::string& path, std::vector<
160175

161176
void DirectoryLoader::removeOldestFiles(const std::string& path, std::vector<std::string>& ext, const int remaining)
162177
{
163-
while (getNumberOfFiles(path, ext) > remaining) {
164-
LOGF(info, "removing oldest file in folder: %s : %s", path, getLatestFile(path, ext));
165-
filesystem::remove(path + "/" + getLatestFile(path, ext));
178+
try {
179+
while (getNumberOfFiles(path, ext) > remaining) {
180+
LOGF(info, "removing oldest file in folder: %s : %s", path, getLatestFile(path, ext));
181+
filesystem::remove(path + "/" + getLatestFile(path, ext));
182+
}
183+
} catch (std::filesystem::filesystem_error const& ex) {
184+
LOGF(error, "filesystem problem during DirectoryLoader::removeOldestFiles: %s", ex.what());
166185
}
167186
}

EventVisualisation/DataConverter/src/VisualisationEventROOTSerializer.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ void VisualisationEventROOTSerializer::toFile(const VisualisationEvent& event, L
9797
{
9898
std::string fileName = location.fileName();
9999
TFile f(fileName.c_str(), "recreate");
100+
if (f.IsZombie()) {
101+
LOGF(error, "Could not create output file %s", fileName.c_str());
102+
return;
103+
}
100104

101105
saveInt("runNumber", event.mRunNumber);
102106
saveInt("runType", event.mRunType);

0 commit comments

Comments
 (0)