Skip to content
Merged
Changes from 1 commit
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
10 changes: 4 additions & 6 deletions Geometry/VeryForwardGeometryBuilder/src/DetGeomDesc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "DataFormats/CTPPSDetId/interface/TotemTimingDetId.h"
#include "DataFormats/CTPPSDetId/interface/CTPPSPixelDetId.h"
#include "DataFormats/CTPPSDetId/interface/CTPPSDiamondDetId.h"
#include "DataFormats/Math/interface/GeantUnits.h"
#include <DD4hep/DD4hepUnits.h>
#include "FWCore/MessageLogger/interface/MessageLogger.h"

/*
Expand All @@ -47,14 +47,14 @@ DetGeomDesc::DetGeomDesc(const cms::DDFilteredView& fv, const bool isRun2)
: m_name(computeNameWithNoNamespace(fv.name())),
m_copy(fv.copyNum()),
m_isDD4hep(true),
m_trans(geant_units::operators::convertCmToMm(fv.translation())), // converted from cm (DD4hep) to mm
m_trans(fv.translation() / dd4hep::mm), // converted from cm (DD4hep) to mm
m_rot(fv.rotation()),
m_params(computeParameters(fv)), // default unit from DD4hep (cm)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would convert m_params to mm right here (actually in computeParameters). Then all members of DetGeomDesc would be in Geant4 units. computeDiamondDimensions could then be simplified because the input units would be always mm.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When old DD is removed, that case will disappear anyway.
In the meantime, I would not make old DD case depend on the DD4hep units, while the DD4hep case needs the /dd4hep::mm to have the certainty of getting mm regardless of the DD4hep internals.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghugo83 I am saying the opposite. Make the interface consistent. For DetGeomDesc members and methods, all units should be mm. Right now, the params method (which is never used, as far as I can tell) and m_params store DD4hep units, while all the other members and methods use mm.
If m_params in the DD4hep version were converted to mm at initialization, then computeDiamondDimensions would expect mm only, and it could be simplified by the removal of the if.

Copy link
Contributor Author

@ghugo83 ghugo83 Jan 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cvuosalo Ha yes, I looked at it more properly, sorry I see what you mean now.
params() is used (from legacy) in CondTools/Geometry/plugins/PGeometricDetBuilder.cc to store PGeometricDet info to DB.
It is true that it would be easier to just convert all shape parameters to mm in a computeParameters function. The computeDiamondDimensions would just be a particular case of this, in the event that the shape is a box.

It is actually the version which I had at first.
But the thing is that it was implying a specific treatment for each possible shape, because we want to convert only the parameters which are lengths, and not all the parameters of the shape.
This was making the computeParameters() function quite heavy.
And in practice, as you noticed, only the box shape parameters are used anyway in the PPS legacy code.

Hence, after discussion with the PPS team, it was decided that the shape parameters are only treated in the case of a box, with the computeDiamondDimensions and getDiamondDimensions functions.
The params() function instead, which provides info to DB, is kept untouched, and just provides the shape parameters in their native format (units, but also orders of parameters).

Shall we want to simplify this, we could just remove params() function - but that would imply removing (useless) info stored in DB in legacy, hence changing the CondFormats objects, hence PPS team preferred keeping that params() function as-is, and just having a special treatment for boxes.

Does this make more sense? :)

m_isABox(dd4hep::isA<dd4hep::Box>(fv.solid())),
m_diamondBoxParams(computeDiamondDimensions(m_isABox, m_isDD4hep, m_params)), // converted from cm (DD4hep) to mm
m_sensorType(computeSensorType(fv.name())),
m_geographicalID(computeDetIDFromDD4hep(m_name, fv.copyNos(), fv.copyNum(), isRun2)),
m_z(geant_units::operators::convertCmToMm(fv.translation().z())) // converted from cm (DD4hep) to mm
m_z(fv.translation().z() / dd4hep::mm) // converted from cm (DD4hep) to mm
{}

DetGeomDesc::DetGeomDesc(const DetGeomDesc& ref, CopyMode cm) {
Expand Down Expand Up @@ -152,9 +152,7 @@ DiamondDimensions DetGeomDesc::computeDiamondDimensions(const bool isABox,
boxShapeParameters = {params.at(0), params.at(1), params.at(2)};
} else {
// convert cm (DD4hep) to mm (legacy expected by PPS reco software)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments on lines 50, 57, and 154 need to be updated. DD4hep units are not necessarily cm anymore.

 // Convert DD4hep units to mm (legacy expected by PPS reco software)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cvuosalo Same, sorry will quickly address the comment tonight when I am back to a computer

boxShapeParameters = {geant_units::operators::convertCmToMm(params.at(0)),
geant_units::operators::convertCmToMm(params.at(1)),
geant_units::operators::convertCmToMm(params.at(2))};
boxShapeParameters = {params.at(0) / dd4hep::mm, params.at(1) / dd4hep::mm, params.at(2) / dd4hep::mm};
}
}
return boxShapeParameters;
Expand Down