Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Detectors/Upgrades/ALICE3/IOTOF/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
add_subdirectory(base)
add_subdirectory(simulation)
add_subdirectory(DataFormatsIOTOF)
add_subdirectory(workflow)
add_subdirectory(macros)
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,57 @@
#ifndef ALICEO2_IOTOF_DIGIT_H
#define ALICEO2_IOTOF_DIGIT_H

#include "SimulationDataFormat/MCCompLabel.h"
#include "DataFormatsITSMFT/Digit.h"

namespace o2::iotof
{
class Digit : public o2::itsmft::Digit
{
public:
Digit() = default;
~Digit() = default;
Digit(UShort_t chipindex = 0, UShort_t row = 0, UShort_t col = 0, Int_t charge = 0, double time = 0.)
: o2::itsmft::Digit(chipindex, row, col, charge), mTime(time) {};
: o2::itsmft::Digit(chipindex, row, col, charge), mTime(time){};

// Setters
void setTime(double time) { mTime = time; }

// Getters
double getTime() const { return mTime; }

static UInt_t getOrderingKey(UShort_t chipindex, UShort_t row, UShort_t col)
{
return (static_cast<UInt_t>(chipindex) << 16) | (static_cast<UInt_t>(row) << 8) | static_cast<UInt_t>(col);
}

private:
double mTime = 0.; ///< Measured time (ns)
ClassDefNV(Digit, 1);
};

// McLabelRef is used to store the MC label of the hit contributing to a digit, and eventually link to extra contributions to the same pixel
struct McLabelRef {
o2::MCCompLabel mLabel; ///< hit label
int mNext = -1; ///< eventual next contribution to the same pixel
McLabelRef(o2::MCCompLabel label = 0, int next = -1) : mLabel(label), mNext(next) {}

ClassDefNV(McLabelRef, 1);
};

class LabeledDigit : public Digit
{
public:
LabeledDigit(UShort_t chipindex = 0, UShort_t row = 0, UShort_t col = 0, Int_t charge = 0, double time = 0.,
o2::MCCompLabel label = 0)
: Digit(chipindex, row, col, charge, time), mLabel(label) {}

void setLabel(McLabelRef label) { mLabel = label; }
McLabelRef getLabel() const { return mLabel; }

private:
McLabelRef mLabel; ///< label of the hit contributing to the digit, and eventually reference to extra contributions to the same pixel
ClassDefNV(LabeledDigit, 1);
};

} // namespace o2::iotof
#endif // ALICEO2_IOTOF_DIGIT_H
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,12 @@
#pragma link off all functions;

#pragma link C++ class o2::iotof::Digit + ;
// #pragma link C++ class std::vector < o2::iotof::Digit> + ;
#pragma link C++ class std::vector < o2::iotof::Digit> + ;

#pragma link C++ class o2::iotof::McLabelRef + ;
#pragma link C++ class std::vector < o2::iotof::McLabelRef> + ;

#pragma link C++ class o2::iotof::LabeledDigit + ;
#pragma link C++ class std::vector < o2::iotof::LabeledDigit> + ;

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
{
public:
using DetMatrixCache::getMatrixL2G;
using DetMatrixCache::getMatrixT2L;

GeometryTGeo(bool build = false, int loadTrans = 0);
void Build(int loadTrans);
Expand All @@ -33,25 +34,29 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
static const char* getIOTOFVolPattern() { return sIOTOFVolumeName.c_str(); }

// Inner TOF
const int getITOFNumberOfChips() { return mNumberOfChipsIOTOF[0]; }
static const char* getITOFLayerPattern() { return sITOFLayerName.c_str(); }
static const char* getITOFStavePattern() { return sITOFStaveName.c_str(); }
static const char* getITOFModulePattern() { return sITOFModuleName.c_str(); }
static const char* getITOFChipPattern() { return sITOFChipName.c_str(); }
static const char* getITOFSensorPattern() { return sITOFSensorName.c_str(); }

// Outer TOF
const int getOTOFNumberOfChips() { return mNumberOfChipsIOTOF[1]; }
static const char* getOTOFLayerPattern() { return sOTOFLayerName.c_str(); }
static const char* getOTOFStavePattern() { return sOTOFStaveName.c_str(); }
static const char* getOTOFModulePattern() { return sOTOFModuleName.c_str(); }
static const char* getOTOFChipPattern() { return sOTOFChipName.c_str(); }
static const char* getOTOFSensorPattern() { return sOTOFSensorName.c_str(); }

// Forward TOF
const int getFTOFNumberOfChips() { return mNumberOfChipsFTOF; }
static const char* getFTOFLayerPattern() { return sFTOFLayerName.c_str(); }
static const char* getFTOFChipPattern() { return sFTOFChipName.c_str(); }
static const char* getFTOFSensorPattern() { return sFTOFSensorName.c_str(); }

// Backward TOF
const int getBTOFNumberOfChips() { return mNumberOfChipsBTOF; }
static const char* getBTOFLayerPattern() { return sBTOFLayerName.c_str(); }
static const char* getBTOFChipPattern() { return sBTOFChipName.c_str(); }
static const char* getBTOFSensorPattern() { return sBTOFSensorName.c_str(); }
Expand Down Expand Up @@ -90,8 +95,31 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
/// for a given chip 'index' by querying the TGeoManager
TGeoHMatrix* extractMatrixSensor(int index) const;

// sensor ref X and alpha
void extractSensorXAlpha(int, float&, float&);

// create matrix for tracking to local frame for IOTOF
TGeoHMatrix& createT2LMatrix(int);

TString getMatrixPath(int index) const;

// cache for tracking frames
void defineSensors();
bool isTrackingFrameCached() const { return !mCacheRefX.empty(); }
void fillTrackingFramesCache();

float getSensorRefAlpha(int chipId) const
{
const int local = chipId;
return mCacheRefAlpha[local];
}

float getSensorX(int chipId) const
{
const int local = chipId;
return mCacheRefX[local];
}

protected:
// Determine the number of active parts in the geometry
int extractNumberOfStavesIOTOF(int lay) const;
Expand Down Expand Up @@ -141,6 +169,10 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
// Backward TOF
int mNumberOfChipsBTOF;

std::vector<int> sensors;
std::vector<float> mCacheRefX; /// cache for X of IOTOF
std::vector<float> mCacheRefAlpha; /// cache for sensor ref alpha IOTOF

private:
static std::unique_ptr<o2::iotof::GeometryTGeo> sInstance;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "CommonUtils/ConfigurableParam.h"
#include "CommonUtils/ConfigurableParamHelper.h"


namespace o2
{
namespace iotof
Expand All @@ -38,6 +39,39 @@ struct ChipSpecifics {
float SensorSizeRows() const { return ActiveMatrixSizeRows() + PassiveEdgeTop + PassiveEdgeReadOut; }
};

struct ITOFChipSpecifics : ChipSpecifics {
ITOFChipSpecifics()
{
NCols = 258;
NRows = 271;
PitchCol = 250.00e-4;
PitchRow = 100.00e-4;
SensorLayerThicknessEff = 50.e-4;
SensorLayerThickness = 50.e-4;
}
};

struct OTOFChipSpecifics : ChipSpecifics {
OTOFChipSpecifics()
{
NCols = 517;
NRows = 243;
PitchCol = 250.00e-4;
PitchRow = 100.00e-4;
PassiveEdgeSide = 106.48e-4;
SensorLayerThicknessEff = 50.e-4;
SensorLayerThickness = 50.e-4;
}
};

struct ITOFChipSpecificParam : public o2::conf::ConfigurableParamPromoter<ITOFChipSpecificParam, ITOFChipSpecifics> {
O2ParamDef(ITOFChipSpecificParam, "ITOFChipSpecific");
};

struct OTOFChipSpecificParam : public o2::conf::ConfigurableParamPromoter<OTOFChipSpecificParam, OTOFChipSpecifics> {
O2ParamDef(OTOFChipSpecificParam, "OTOFChipSpecific");
};

struct IOTOFBaseParam : public o2::conf::ConfigurableParamHelper<IOTOFBaseParam> {
bool enableInnerTOF = true; // Enable Inner TOF layer
bool enableOuterTOF = true; // Enable Outer TOF layer
Expand All @@ -49,9 +83,6 @@ struct IOTOFBaseParam : public o2::conf::ConfigurableParamHelper<IOTOFBaseParam>
float x2x0 = 0.02f; // thickness expressed in radiation length, for all layers for the moment
float sensorThickness = 0.0050f; // thickness of the sensor in cm, for all layers for the moment, the default is set to 50 microns

ChipSpecifics iTofChipSpecifics{258, 271, 250.00e-4, 100.00e-4, 0.00f, 0.00e-4, 0.00e-4, 50.e-4, 50.e-4};
ChipSpecifics oTofChipSpecifics{251, 487, 250.00e-4, 100.00e-4, 0.00f, 0.00e-4, 106.48e-4, 50.e-4, 50.e-4};

O2ParamDef(IOTOFBaseParam, "IOTOFBase");
};

Expand Down
73 changes: 72 additions & 1 deletion Detectors/Upgrades/ALICE3/IOTOF/base/src/GeometryTGeo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <IOTOFBase/GeometryTGeo.h>
#include <IOTOFBase/IOTOFBaseParam.h>
#include <TGeoManager.h>
#include <TMath.h>

namespace o2
{
Expand Down Expand Up @@ -261,8 +262,31 @@ void GeometryTGeo::Build(int loadTrans)
LOG(info) << "numberOfChipsITOF = " << mNumberOfChipsIOTOF[0] << ", numberOfChipsOTOF = " << mNumberOfChipsIOTOF[1] << ", numberOfChips = " << numberOfChips << ", mNumberOfChipesPerStaveITOF" << mNumberOfChipsPerStaveIOTOF[0];

setSize(numberOfChips);
defineSensors();
fillTrackingFramesCache();
fillMatrixCache(loadTrans);
// fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::L2G));
// fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::L2G));
}

void GeometryTGeo::defineSensors()
{
for (int i = 0; i < mSize; i++) {
sensors.push_back(i);
}
}

void GeometryTGeo::fillTrackingFramesCache()
{
// fill for every sensor of IOTOF its tracking frame parameters
if (!isTrackingFrameCached() && !sensors.empty()) {
size_t newSize = sensors.size();
mCacheRefX.resize(newSize);
mCacheRefAlpha.resize(newSize);
for (int i = 0; i < newSize; i++) {
int sensorId = sensors[i];
extractSensorXAlpha(sensorId, mCacheRefX[i], mCacheRefAlpha[i]);
}
}
}

void GeometryTGeo::fillMatrixCache(int mask)
Expand All @@ -273,6 +297,8 @@ void GeometryTGeo::fillMatrixCache(int mask)
return;
}

LOG(debug) << "Filling matrix cache for " << getName() << " with mask " << mask;

if ((mask & o2::math_utils::bit2Mask(o2::math_utils::TransformType::L2G)) && !getCacheL2G().isFilled()) {
// Matrices for Local (Sensor!!! rather than the full chip) to Global frame transformation
LOG(info) << "Loading " << getName() << " L2G matrices from TGeo; there are " << mSize << " matrices";
Expand All @@ -284,6 +310,51 @@ void GeometryTGeo::fillMatrixCache(int mask)
cacheL2G.setMatrix(o2::math_utils::Transform3D(*hm), i);
}
}

// build T2L matrices for IOTOF
if ((mask & o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L)) && !getCacheT2L().isFilled()) {
LOGP(info, "Loading {} T2L matrices from TGeo for IOTOF", getName());
if (sensors.size()) {
int m_Size = sensors.size();
auto& cacheT2L = getCacheT2L();
cacheT2L.setSize(m_Size);
for (int i = 0; i < m_Size; i++) {
int sensorID = sensors[i];
TGeoHMatrix& hm = createT2LMatrix(sensorID);
cacheT2L.setMatrix(Mat3D(hm), i);
}
}
}
}

void GeometryTGeo::extractSensorXAlpha(int chipID, float& x, float& alp)
{
double locA[3] = {-100., 0., 0.}, locB[3] = {100., 0., 0.}, gloA[3], gloB[3];
double xp{0}, yp{0};

const TGeoHMatrix* matL2G = extractMatrixSensor(chipID);
matL2G->LocalToMaster(locA, gloA);
matL2G->LocalToMaster(locB, gloB);
double dx = gloB[0] - gloA[0], dy = gloB[1] - gloA[1];
double t = (gloB[0] * dx + gloB[1] * dy) / (dx * dx + dy * dy);
xp = gloB[0] - dx * t;
yp = gloB[1] - dy * t;

alp = std::atan2(yp, xp);
x = std::hypot(xp, yp);
o2::math_utils::bringTo02Pi(alp);
}

TGeoHMatrix& GeometryTGeo::createT2LMatrix(int chipID)
{
static TGeoHMatrix t2l;
t2l.Clear();
float alpha = getSensorRefAlpha(chipID);
t2l.RotateZ(alpha * TMath::RadToDeg());
const TGeoHMatrix* matL2G = extractMatrixSensor(chipID);
const TGeoHMatrix& matL2Gi = matL2G->Inverse();
t2l.MultiplyLeft(&matL2Gi);
return t2l;
}

GeometryTGeo* GeometryTGeo::Instance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@

#include "IOTOFBase/IOTOFBaseParam.h"

O2ParamImpl(o2::iotof::IOTOFBaseParam);
O2ParamImpl(o2::iotof::IOTOFBaseParam);
O2ParamImpl(o2::iotof::ITOFChipSpecificParam);
O2ParamImpl(o2::iotof::OTOFChipSpecificParam);
33 changes: 18 additions & 15 deletions Detectors/Upgrades/ALICE3/IOTOF/simulation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
# Copyright 2019-2020 CERN and copyright holders of ALICE O2.
# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
# All rights not expressly granted are reserved.
#Copyright 2019 - 2020 CERN and copyright holders of ALICE O2.
#See https: // alice-o2.web.cern.ch/copyright for details of the copyright holders.
#All rights not expressly granted are reserved.
#
# This software is distributed under the terms of the GNU General Public
# License v3 (GPL Version 3), copied verbatim in the file "COPYING".
#This software is distributed under the terms of the GNU General Public
#License v3(GPL Version 3), copied verbatim in the file "COPYING".
#
# In applying this license CERN does not waive the privileges and immunities
# granted to it by virtue of its status as an Intergovernmental Organization
#In applying this license CERN does not waive the privileges and immunities
#granted to it by virtue of its status as an Intergovernmental Organization
# or submit itself to any jurisdiction.

Check failure on line 10 in Detectors/Upgrades/ALICE3/IOTOF/simulation/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / PR formatting / copyright headers

Missing or malformed copyright notice

This source file is missing the correct copyright notice.

o2_add_library(IOTOFSimulation
SOURCES src/Layer.cxx
src/Chip.cxx
src/Detector.cxx
src/Digitizer.cxx
# src/IOTOFServices.cxx
src/Segmentation.cxx
src/DPLDigitizerParam.cxx
#src/IOTOFServices.cxx
src/Segmentation.cxx
PUBLIC_LINK_LIBRARIES O2::IOTOFBase
O2::DataFormatsIOTOF
O2::ITSMFTSimulation)

o2_target_root_dictionary(IOTOFSimulation
HEADERS include/IOTOFSimulation/Detector.h
include/IOTOFSimulation/Layer.h
include/IOTOFSimulation/Digitizer.h
# include/IOTOFSimulation/IOTOFServices.h
include/IOTOFSimulation/Segmentation.h
)
HEADERS include/IOTOFSimulation/Detector.h

Check failure on line 25 in Detectors/Upgrades/ALICE3/IOTOF/simulation/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / PR formatting / whitespace

Trailing spaces

Remove the trailing spaces at the end of the line.
include/IOTOFSimulation/Chip.h

Check failure on line 26 in Detectors/Upgrades/ALICE3/IOTOF/simulation/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / PR formatting / whitespace

Trailing spaces

Remove the trailing spaces at the end of the line.
include/IOTOFSimulation/Layer.h

Check failure on line 27 in Detectors/Upgrades/ALICE3/IOTOF/simulation/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / PR formatting / whitespace

Trailing spaces

Remove the trailing spaces at the end of the line.
include/IOTOFSimulation/Digitizer.h

Check failure on line 28 in Detectors/Upgrades/ALICE3/IOTOF/simulation/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / PR formatting / whitespace

Trailing spaces

Remove the trailing spaces at the end of the line.
include/IOTOFSimulation/DPLDigitizerParam.h
#include/IOTOFSimulation/IOTOFServices.h
include/IOTOFSimulation/Segmentation.h)
Loading
Loading