Skip to content
Open
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
6 changes: 3 additions & 3 deletions DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ bool channelAlignedWithTrack(const CTPPSGeometry* geom,
const float tolerance = 1) {
const DetGeomDesc* det = geom->sensor(detid);
const float x_pos = det->translation().x(),
x_width = 2.0 * det->getDiamondWidth().at(0); // parameters stand for half the size
x_width = 2.0 * det->getDiamondDimensions().xHalfWidth; // parameters stand for half the size
return ((x_pos + 0.5 * x_width > localTrack.x0() - localTrack.x0Sigma() - tolerance &&
x_pos + 0.5 * x_width < localTrack.x0() + localTrack.x0Sigma() + tolerance) ||
(x_pos - 0.5 * x_width > localTrack.x0() - localTrack.x0Sigma() - tolerance &&
Expand Down Expand Up @@ -515,13 +515,13 @@ void CTPPSDiamondDQMSource::dqmBeginRun(const edm::Run& iRun, const edm::EventSe
const CTPPSGeometry& geom = iSetup.getData(ctppsGeometryRunToken_);
const CTPPSDiamondDetId detid(0, CTPPS_DIAMOND_STATION_ID, CTPPS_DIAMOND_RP_ID, 0, 0);
const DetGeomDesc* det = geom.sensor(detid);
horizontalShiftOfDiamond_ = det->translation().x() - det->getDiamondWidth().at(0);
horizontalShiftOfDiamond_ = det->translation().x() - det->getDiamondDimensions().xHalfWidth;

// Rough alignement of pixel detector for diamond thomography
const CTPPSPixelDetId pixid(0, CTPPS_PIXEL_STATION_ID, CTPPS_FAR_RP_ID, 0);
if (iRun.run() > 300000) { //Pixel installed
det = geom.sensor(pixid);
horizontalShiftBwDiamondPixels_ = det->translation().x() - det->getDiamondWidth().at(0) - horizontalShiftOfDiamond_ - 1;
horizontalShiftBwDiamondPixels_ = det->translation().x() - det->getDiamondDimensions().xHalfWidth - horizontalShiftOfDiamond_ - 1;
}
}

Expand Down
4 changes: 2 additions & 2 deletions DQM/CTPPS/plugins/TotemTimingDQMSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,11 @@ void TotemTimingDQMSource::dqmBeginRun(const edm::Run &iRun, const edm::EventSet
{
const DetGeomDesc *det_top = geom->sensorNoThrow(detid_top);
if (det_top) {
verticalShiftTop_ = det_top->translation().y() + det_top->getDiamondWidth().at(1);
verticalShiftTop_ = det_top->translation().y() + det_top->getDiamondDimensions().yHalfWidth;
}
const DetGeomDesc *det_bot = geom->sensorNoThrow(detid_bot);
if (det_bot)
verticalShiftBot_ = det_bot->translation().y() + det_bot->getDiamondWidth().at(1);
verticalShiftBot_ = det_bot->translation().y() + det_bot->getDiamondDimensions().yHalfWidth;
}
}

Expand Down
45 changes: 16 additions & 29 deletions DetectorDescription/DDCMS/interface/DDFilteredView.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,47 +149,34 @@ namespace cms {
return dd4hep::isA<Shape>(solid());
}

template <typename... Ts>
bool isABox(Ts&&... ts) const {
return isA<dd4hep::Box>(std::forward<Ts>(ts)...);
bool isABox() const {
return isA<dd4hep::Box>();
}

template <typename... Ts>
bool isAConeSeg(Ts&&... ts) const {
return isA<dd4hep::ConeSegment>(std::forward<Ts>(ts)...);
bool isAConeSeg() const {
return isA<dd4hep::ConeSegment>();
}

template <typename... Ts>
bool isAPseudoTrap(Ts&&... ts) const {
return isA<dd4hep::PseudoTrap>(std::forward<Ts>(ts)...);
bool isAPseudoTrap() const {
return isA<dd4hep::PseudoTrap>();
}

template <typename... Ts>
bool isATrapezoid(Ts&&... ts) const {
return isA<dd4hep::Trap>(std::forward<Ts>(ts)...);
bool isATrapezoid() const {
return isA<dd4hep::Trap>();
}

template <typename... Ts>
bool isATruncTube(Ts&&... ts) const {
return isA<dd4hep::TruncatedTube>(std::forward<Ts>(ts)...);
bool isATruncTube() const {
return isA<dd4hep::TruncatedTube>();
}

template <typename... Ts>
bool isATubeSeg(Ts&&... ts) const {
return isA<dd4hep::Tube>(std::forward<Ts>(ts)...);
}

template <typename... Ts>
bool isASubtraction(Ts&&... ts) const {
return (isA<dd4hep::SubtractionSolid>(std::forward<Ts>(ts)...) and
not isA<dd4hep::TruncatedTube>(std::forward<Ts>(ts)...) and
not isA<dd4hep::PseudoTrap>(std::forward<Ts>(ts)...));
bool isATubeSeg() const {
return isA<dd4hep::Tube>();
}

bool isABoolean() const {
return (isA<dd4hep::IntersectionSolid>()
or isA<dd4hep::SubtractionSolid>()
or isA<dd4hep::UnionSolid>());
bool isASubtraction() const {
return (isA<dd4hep::SubtractionSolid>() and
not isA<dd4hep::TruncatedTube>() and
not isA<dd4hep::PseudoTrap>());
}

dd4hep::Solid solid() const;
Expand Down
68 changes: 39 additions & 29 deletions Geometry/VeryForwardGeometryBuilder/interface/DetGeomDesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,58 +41,64 @@ class CTPPSRPAlignmentCorrectionData;
*
**/

struct DiamondDimensions {
double xHalfWidth;
double yHalfWidth;
double zHalfWidth;
};

class DetGeomDesc {
public:
using Container = std::vector<DetGeomDesc*>;
using RotationMatrix = ROOT::Math::Rotation3D;
using Translation = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>>;

///Default constructors
// Default
DetGeomDesc() {};

///Constructors to be used when looping over DDD
// Constructor (old DD)
DetGeomDesc(DDFilteredView* fv);

///Constructor from DD4Hep DDFilteredView
// Constructor from DD4Hep DDFilteredView
DetGeomDesc(const cms::DDFilteredView& fv, const cms::DDSpecParRegistry& allSpecParSections);

/// copy constructor and assignment operator
DetGeomDesc(const DetGeomDesc&);
DetGeomDesc& operator=(const DetGeomDesc&);

/// destructor
virtual ~DetGeomDesc();

/// ID stuff
// general info
const std::string& name() const { return m_name; }
int copyno() const { return m_copy; }

// placement info
Translation translation() const { return m_trans; }
RotationMatrix rotation() const { return m_rot; }

// shape info
// params() is left for general access to solid shape parameters, but should be used
// only with great care, for two reasons: 1. order of parameters may possibly change from
// a version to another of DD4hep; 2. length parameters unit is cm while PPS uses mm.
std::vector<double> params() const { return m_params; }
bool isABox() const { return m_isABox; }
DiamondDimensions getDiamondDimensions() const;

// sensor type
const std::string& sensorType() const { return m_sensorType; }

// ID info
void setGeographicalID(DetId id) { m_geographicalID = id; }
DetId geographicalID() const { return m_geographicalID; }

/// access to the tree structure
// components (children) management
Container components() const;
float parentZPosition() const { return m_z; }

/// components (children) management
void addComponent(DetGeomDesc*);
bool isLeaf() const { return m_container.empty(); }

/// geometry information
RotationMatrix rotation() const { return m_rot; }
Translation translation() const { return m_trans; }
const std::string& name() const { return m_name; }
int copyno() const { return m_copy; }
const std::string& sensorType() const { return m_sensorType; }
std::vector<double> getDiamondWidth() const;

// Method params() is left for general access to solid shape parameters but should be used
// only with great care, for two reasons: 1. order of parameters may possibly change from
// a version to another of DD4hep; 2. length parameters unit is cm while PPS uses mm.
std::vector<double> params() const { return m_params; }

/// alignment
// alignment
void applyAlignment(const CTPPSRPAlignmentCorrectionData&);

private:
// DetGeomDesc() {}
void deleteComponents(); /// deletes just the first daughters
void deepDeleteComponents(); /// traverses the tree and deletes all nodes.
void clearComponents() { m_container.resize(0); }
Expand All @@ -101,15 +107,19 @@ class DetGeomDesc {
DetId computeDetID(const cms::DDFilteredView& fv) const;
std::string computeSensorType(const std::string& nodePath, const cms::DDSpecParRegistry& allSpecParSections);

Container m_container;
std::string m_name;
int m_copy;
Translation m_trans;
RotationMatrix m_rot;
std::string m_name;
std::vector<double> m_params;
bool m_isABox;
std::string m_sensorType;
DetId m_geographicalID;
int m_copy;

Container m_container;
float m_z;
std::string m_sensorType;

bool m_isOldDD;
};

#endif
85 changes: 48 additions & 37 deletions Geometry/VeryForwardGeometryBuilder/src/DetGeomDesc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,94 +40,105 @@ using namespace cms_units::operators;
**/

DetGeomDesc::DetGeomDesc(DDFilteredView* fv)
: m_trans(fv->translation()),
: m_name(((fv->logicalPart()).ddname()).name()),
m_copy(fv->copyno()),
m_trans(fv->translation()),
m_rot(fv->rotation()),
m_name(((fv->logicalPart()).ddname()).name()),
m_params(((fv->logicalPart()).solid()).parameters()),
m_copy(fv->copyno()),
m_isABox(fv->shape() == DDSolidShape::ddbox),
m_sensorType(""),
m_z(fv->geoHistory().back().absTranslation().z()),
m_sensorType("") {
m_isOldDD(true)
{
std::string sensor_name = fv->geoHistory().back().logicalPart().name().fullname();
std::size_t found = sensor_name.find(DDD_CTPPS_PIXELS_SENSOR_NAME);
if (found != std::string::npos && sensor_name.substr(found - 4, 3) == DDD_CTPPS_PIXELS_SENSOR_TYPE_2x2) {
m_sensorType = DDD_CTPPS_PIXELS_SENSOR_TYPE_2x2;
}
}


// Constructor from DD4Hep DDFilteredView, also using the SpecPars to access 2x2 wafers info.
DetGeomDesc::DetGeomDesc(const cms::DDFilteredView& fv, const cms::DDSpecParRegistry& allSpecParSections)
: m_trans(fv.translation() / 1._mm), // Convert cm (DD4hep) to mm (legacy)
: m_name(fv.name()),
m_copy(fv.copyNum()),
m_trans(fv.translation() / 1._mm), // Convert cm (DD4hep) to mm (legacy)
m_rot(fv.rotation()),
m_name(fv.name()),
m_params(copyParameters(fv)),
m_params(copyParameters(fv)),
m_isABox(fv.isABox()),
m_sensorType(computeSensorType(fv.path(), allSpecParSections)),
m_geographicalID(computeDetID(fv)),
m_copy(fv.copyNum()),
m_z(fv.translation().z() / 1._mm), // Convert cm (DD4hep) to mm (legacy)
m_sensorType(computeSensorType(fv.path(), allSpecParSections))
m_isOldDD(false)
{}

//----------------------------------------------------------------------------------------------------

DetGeomDesc::DetGeomDesc(const DetGeomDesc& ref) { (*this) = ref; }

//----------------------------------------------------------------------------------------------------

DetGeomDesc& DetGeomDesc::operator=(const DetGeomDesc& ref) {
m_params = ref.m_params;
m_trans = ref.m_trans;
m_rot = ref.m_rot;
m_name = ref.m_name;
m_copy = ref.m_copy;
m_trans = ref.m_trans;
m_rot = ref.m_rot;
m_params = ref.m_params;
m_isABox = ref.m_isABox;
m_sensorType = ref.m_sensorType;
m_geographicalID = ref.m_geographicalID;
m_z = ref.m_z;
m_sensorType = ref.m_sensorType;
return (*this);
}

//----------------------------------------------------------------------------------------------------

DetGeomDesc::~DetGeomDesc() { deepDeleteComponents(); }

//----------------------------------------------------------------------------------------------------

DetGeomDesc::Container DetGeomDesc::components() const { return m_container; }

//----------------------------------------------------------------------------------------------------

void DetGeomDesc::addComponent(DetGeomDesc* det) { m_container.emplace_back(det); }

//----------------------------------------------------------------------------------------------------

void DetGeomDesc::deleteComponents() { m_container.erase(m_container.begin(), m_container.end()); }

//----------------------------------------------------------------------------------------------------
DiamondDimensions DetGeomDesc::getDiamondDimensions() const {
// Convert parameters units from cm (DD4hep standard) to mm (expected by PPS reco software).
// This implementation is customized for the diamond sensors, which are represented by the
// Box shape parameterized by x, y and z half width.

void DetGeomDesc::deepDeleteComponents() {
for (auto& it : m_container) {
it->deepDeleteComponents();
delete it;
DiamondDimensions parameters;
if (isABox()) {
const double factor = (m_isOldDD ? 1. : 1./1._mm);
parameters = { m_params.at(0)*factor, m_params.at(1)*factor, m_params.at(2)*factor };
}
clearComponents();
else {
edm::LogError("DetGeomDesc::getDiamondDimensions is not called on a box, for solid ")
<< name() << ", Id = " << geographicalID();
}
return parameters;
}

//----------------------------------------------------------------------------------------------------

void DetGeomDesc::applyAlignment(const CTPPSRPAlignmentCorrectionData& t) {
m_rot = t.getRotationMatrix() * m_rot;
m_trans = t.getTranslation() + m_trans;
}

//----------------------------------------------------------------------------------------------------

std::vector<double> DetGeomDesc::getDiamondWidth() const {
// Convert parameters units from cm (DD4hep standard) to mm (expected by PPS reco software).
// This implementation is customized for the diamond sensors, which are represented by the
// Box shape parameterized by x, y and z half width.
std::vector<double> parameters;
parameters = { m_params[0] / 1._mm , m_params[1] / 1._mm , m_params[2] / 1._mm };
return parameters;
/*
* private
*/


void DetGeomDesc::deleteComponents() { m_container.erase(m_container.begin(), m_container.end()); }


void DetGeomDesc::deepDeleteComponents() {
for (auto& it : m_container) {
it->deepDeleteComponents();
delete it;
}
clearComponents();
}

//----------------------------------------------------------------------------------------------------

std::vector<double> DetGeomDesc::copyParameters(const cms::DDFilteredView& fv) const {
auto myShape = fv.solid();
Expand Down
6 changes: 3 additions & 3 deletions RecoPPS/Local/src/CTPPSDiamondRecHitProducerAlgorithm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ void CTPPSDiamondRecHitProducerAlgorithm::build(const CTPPSGeometry& geom,
z_pos = det->parentZPosition(); // retrieve the plane position;

// parameters stand for half the size
const float x_width = 2.0 * det->getDiamondWidth().at(0);
const float y_width = 2.0 * det->getDiamondWidth().at(1);
const float z_width = 2.0 * det->getDiamondWidth().at(2);
const float x_width = 2.0 * det->getDiamondDimensions().xHalfWidth;
const float y_width = 2.0 * det->getDiamondDimensions().yHalfWidth;
const float z_width = 2.0 * det->getDiamondDimensions().zHalfWidth;

// retrieve the timing calibration part for this channel
const int sector = detid.arm(), station = detid.station(), plane = detid.plane(), channel = detid.channel();
Expand Down
5 changes: 3 additions & 2 deletions RecoPPS/Local/src/TotemTimingRecHitProducerAlgorithm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ void TotemTimingRecHitProducerAlgorithm::build(const CTPPSGeometry& geom,
y_pos = det->translation().y();
z_pos = det->parentZPosition(); // retrieve the plane position;

x_width = 2.0 * det->getDiamondWidth()[0], // parameters stand for half the size
y_width = 2.0 * det->getDiamondWidth()[1], z_width = 2.0 * det->getDiamondWidth()[2];
x_width = 2.0 * det->getDiamondDimensions().xHalfWidth; // parameters stand for half the size
y_width = 2.0 * det->getDiamondDimensions().yHalfWidth;
z_width = 2.0 * det->getDiamondDimensions().zHalfWidth;
} else
throw cms::Exception("TotemTimingRecHitProducerAlgorithm") << "Failed to retrieve a sensor for " << detid;

Expand Down
4 changes: 0 additions & 4 deletions SimPPS/RPDigiProducer/plugins/RPDisplacementGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ RPDisplacementGenerator::RPDisplacementGenerator(const edm::ParameterSet &ps,
rotation_ = R_l.Inverse() * R_m.Inverse() * R_l;
shift_ = R_l.Inverse() * R_m.Inverse() * S_m;

std::cout << " shift = " << shift_ << std::endl;
std::cout << " rotation = " << rotation_ << std::endl;


LogDebug("RPDisplacementGenerator").log([&](auto &log) {
log << " det id = " << decId << ", isOn = " << isOn_ << "\n";
if (isOn_) {
Expand Down
Loading