Skip to content

Commit

Permalink
Merge pull request #39699 from Dr15Jones/deprecatedSimPPSRPDigiProducer
Browse files Browse the repository at this point in the history
Fixed CMS deprecation warnings in SimPPS/RPDigiProducer
  • Loading branch information
cmsbuild authored Oct 17, 2022
2 parents 28de7f9 + ee4b5d8 commit 407ef28
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 31 deletions.
7 changes: 5 additions & 2 deletions SimPPS/RPDigiProducer/plugins/RPDetDigitizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
RPDetDigitizer::RPDetDigitizer(const edm::ParameterSet &params,
CLHEP::HepRandomEngine &eng,
RPDetId det_id,
const edm::EventSetup &iSetup)
const CTPPSRPAlignmentCorrectionsData *alignments,
const CTPPSGeometry &geom)

: det_id_(det_id) {
verbosity_ = params.getParameter<int>("RPVerbosity");
numStrips_ = RPTopology().DetStripNo();
Expand All @@ -24,7 +26,8 @@ RPDetDigitizer::RPDetDigitizer(const edm::ParameterSet &params,
theRPPileUpSignals = std::make_unique<RPPileUpSignals>(params, det_id_);
theRPVFATSimulator = std::make_unique<RPVFATSimulator>(params, det_id_);
theRPHitChargeConverter = std::make_unique<RPHitChargeConverter>(params, eng, det_id_);
theRPDisplacementGenerator = std::make_unique<RPDisplacementGenerator>(params, det_id_, iSetup);
theRPDisplacementGenerator = std::make_unique<RPDisplacementGenerator>(
params.getParameter<bool>("RPDisplacementOn"), det_id_, alignments, geom);
}

void RPDetDigitizer::run(const std::vector<PSimHit> &input,
Expand Down
5 changes: 4 additions & 1 deletion SimPPS/RPDigiProducer/plugins/RPDetDigitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
namespace CLHEP {
class HepRandomEngine;
}
class CTPPSRPAlignmentCorrectionsData;
class CTPPSGeometry;

class RPDetDigitizer {
public:
RPDetDigitizer(const edm::ParameterSet &params,
CLHEP::HepRandomEngine &eng,
RPDetId det_id,
const edm::EventSetup &iSetup);
const CTPPSRPAlignmentCorrectionsData *alignments,
const CTPPSGeometry &geom);
void run(const std::vector<PSimHit> &input,
const std::vector<int> &input_links,
std::vector<TotemRPDigi> &output_digi,
Expand Down
19 changes: 16 additions & 3 deletions SimPPS/RPDigiProducer/plugins/RPDigiProducer.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// user include files
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
Expand Down Expand Up @@ -31,6 +31,9 @@
#include "SimPPS/RPDigiProducer/plugins/RPDetDigitizer.h"
#include "SimPPS/RPDigiProducer/plugins/DeadChannelsManager.h"

#include "Geometry/Records/interface/VeryForwardMisalignedGeometryRecord.h"
#include "Geometry/Records/interface/VeryForwardRealGeometryRecord.h"

// system include files
#include <memory>
#include <vector>
Expand All @@ -49,7 +52,7 @@ namespace CLHEP {
class HepRandomEngine;
}

class RPDigiProducer : public edm::EDProducer {
class RPDigiProducer : public edm::stream::EDProducer<> {
public:
explicit RPDigiProducer(const edm::ParameterSet&);
~RPDigiProducer() override = default;
Expand Down Expand Up @@ -85,6 +88,8 @@ class RPDigiProducer : public edm::EDProducer {

edm::EDGetTokenT<CrossingFrame<PSimHit>> tokenCrossingFrameTotemRP;
edm::ESGetToken<TotemAnalysisMask, TotemReadoutRcd> tokenAnalysisMask;
edm::ESGetToken<CTPPSRPAlignmentCorrectionsData, VeryForwardMisalignedGeometryRecord> alignmentToken;
edm::ESGetToken<CTPPSGeometry, VeryForwardRealGeometryRecord> geomToken;
};

RPDigiProducer::RPDigiProducer(const edm::ParameterSet& conf) : conf_(conf) {
Expand All @@ -105,6 +110,8 @@ RPDigiProducer::RPDigiProducer(const edm::ParameterSet& conf) : conf_(conf) {
if (simulateDeadChannels) {
tokenAnalysisMask = esConsumes();
}
alignmentToken = esConsumes();
geomToken = esConsumes();
}

//
Expand Down Expand Up @@ -168,11 +175,17 @@ void RPDigiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
DigiVector.reserve(400);
DigiVector.clear();

CTPPSRPAlignmentCorrectionsData const* alignments = nullptr;
if (auto rec = iSetup.tryToGet<VeryForwardMisalignedGeometryRecord>()) {
alignments = &iSetup.getData(alignmentToken);
}
auto const& geom = iSetup.getData(geomToken);

for (simhit_map_iterator it = simHitMap_.begin(); it != simHitMap_.end(); ++it) {
edm::DetSet<TotemRPDigi> digi_collector(it->first);

if (theAlgoMap.find(it->first) == theAlgoMap.end()) {
theAlgoMap[it->first] = std::make_unique<RPDetDigitizer>(conf_, *rndEngine_, it->first, iSetup);
theAlgoMap[it->first] = std::make_unique<RPDetDigitizer>(conf_, *rndEngine_, it->first, alignments, geom);
}

std::vector<int> input_links;
Expand Down
23 changes: 6 additions & 17 deletions SimPPS/RPDigiProducer/plugins/RPDisplacementGenerator.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "Geometry/Records/interface/VeryForwardMisalignedGeometryRecord.h"
#include "Geometry/Records/interface/VeryForwardRealGeometryRecord.h"
#include "Geometry/VeryForwardGeometryBuilder/interface/CTPPSGeometry.h"
#include "CondFormats/PPSObjects/interface/CTPPSRPAlignmentCorrectionsData.h"
#include "DataFormats/CTPPSDetId/interface/TotemRPDetId.h"
Expand All @@ -16,34 +12,27 @@
using namespace std;
using namespace edm;

RPDisplacementGenerator::RPDisplacementGenerator(const edm::ParameterSet &ps,
RPDisplacementGenerator::RPDisplacementGenerator(bool iIsOn,
RPDetId _detId,
const edm::EventSetup &iSetup)
const CTPPSRPAlignmentCorrectionsData *alignments,
const CTPPSGeometry &geom)
: detId_(_detId) {
isOn_ = ps.getParameter<bool>("RPDisplacementOn");

// read the alignment correction
ESHandle<CTPPSRPAlignmentCorrectionsData> alignments;
if (auto rec = iSetup.tryToGet<VeryForwardMisalignedGeometryRecord>()) {
iSetup.get<VeryForwardMisalignedGeometryRecord>().get(alignments);
}
isOn_ = iIsOn;

unsigned int decId = rawToDecId(detId_);

math::XYZVectorD S_m;
RotationMatrix R_m;

if (alignments.isValid()) {
if (alignments) {
const CTPPSRPAlignmentCorrectionData &ac = alignments->getFullSensorCorrection(decId);
S_m = ac.getTranslation();
R_m = ac.getRotationMatrix();
} else
isOn_ = false;

// transform shift and rotation to the local coordinate frame
ESHandle<CTPPSGeometry> geom;
iSetup.get<VeryForwardRealGeometryRecord>().get(geom);
const DetGeomDesc *g = geom->sensor(detId_);
const DetGeomDesc *g = geom.sensor(detId_);
const RotationMatrix &R_l = g->rotation();
rotation_ = R_l.Inverse() * R_m.Inverse() * R_l;
shift_ = R_l.Inverse() * R_m.Inverse() * S_m;
Expand Down
16 changes: 8 additions & 8 deletions SimPPS/RPDigiProducer/plugins/RPDisplacementGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
#include <Math/Rotation3D.h>
#include <map>

namespace edm {
class ParameterSet;
class EventSetup;
} // namespace edm

class PSimHit;

/**
Expand All @@ -22,16 +17,21 @@ class PSimHit;
*
* PSimHit points are given in the "local Det frame" (PSimHit.h)
*/
class CTPPSRPAlignmentCorrectionsData;
class CTPPSGeometry;

class RPDisplacementGenerator {
public:
using RotationMatrix = ROOT::Math::Rotation3D;
using Translation = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>>;

RPDisplacementGenerator(const edm::ParameterSet &, RPDetId, const edm::EventSetup &);
RPDisplacementGenerator(bool iIsOn,
RPDetId,
const CTPPSRPAlignmentCorrectionsData* alignments,
const CTPPSGeometry& geom);

/// returns displaced PSimHit
PSimHit displace(const PSimHit &);
PSimHit displace(const PSimHit&);

static uint32_t rawToDecId(uint32_t raw);

Expand All @@ -47,7 +47,7 @@ class RPDisplacementGenerator {
bool isOn_;

/// displaces a point
Local3DPoint displacePoint(const Local3DPoint &);
Local3DPoint displacePoint(const Local3DPoint&);
};

#endif

0 comments on commit 407ef28

Please sign in to comment.