Skip to content

Commit

Permalink
Review comments addressed.
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-kaspar committed Jul 1, 2020
1 parent be148f0 commit 3386bdf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
27 changes: 12 additions & 15 deletions RecoPPS/Local/plugins/PPSLocalTrackLiteReAligner.cc
Expand Up @@ -9,7 +9,7 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h"
Expand All @@ -20,11 +20,11 @@

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

class PPSLocalTrackLiteReAligner : public edm::stream::EDProducer<> {
class PPSLocalTrackLiteReAligner : public edm::global::EDProducer<> {
public:
explicit PPSLocalTrackLiteReAligner(const edm::ParameterSet &);

void produce(edm::Event &, const edm::EventSetup &) override;
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;

static void fillDescriptions(edm::ConfigurationDescriptions &);

Expand All @@ -40,7 +40,8 @@ class PPSLocalTrackLiteReAligner : public edm::stream::EDProducer<> {

PPSLocalTrackLiteReAligner::PPSLocalTrackLiteReAligner(const edm::ParameterSet &iConfig)
: inputTrackToken_(consumes<CTPPSLocalTrackLiteCollection>(iConfig.getParameter<edm::InputTag>("inputTrackTag"))),
alignmentToken_(esConsumes<CTPPSRPAlignmentCorrectionsData, RPRealAlignmentRecord>(iConfig.getParameter<edm::ESInputTag>("alignmentTag"))),
alignmentToken_(esConsumes<CTPPSRPAlignmentCorrectionsData, RPRealAlignmentRecord>(
iConfig.getParameter<edm::ESInputTag>("alignmentTag"))),
outputTrackTag_(iConfig.getParameter<std::string>("outputTrackTag")) {
produces<CTPPSLocalTrackLiteCollection>(outputTrackTag_);
}
Expand All @@ -57,28 +58,24 @@ void PPSLocalTrackLiteReAligner::fillDescriptions(edm::ConfigurationDescriptions

desc.add<std::string>("outputTrackTag", "")->setComment("tag of the output CTPPSLocalTrackLiteCollection");

descr.add("ctppsLocalTrackLiteReAligner", desc);
descr.add("ppsLocalTrackLiteReAligner", desc);
}

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

void PPSLocalTrackLiteReAligner::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) {
void PPSLocalTrackLiteReAligner::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const {
// get alignment corrections
auto const& alignment = iSetup.getData(alignmentToken_);

// get input
edm::Handle<CTPPSLocalTrackLiteCollection> hInputTracks;
iEvent.getByToken(inputTrackToken_, hInputTracks);
auto const &alignment = iSetup.getData(alignmentToken_);

// prepare output
auto output = std::make_unique<CTPPSLocalTrackLiteCollection>();

// apply alignment correction
for (const auto &tr : *hInputTracks) {
// apply alignment corrections
auto const &inputTracks = iEvent.get(inputTrackToken_);
for (const auto &tr : inputTracks) {
auto it = alignment.getRPMap().find(tr.rpId());
if (it == alignment.getRPMap().end()) {
edm::LogError("PPSLocalTrackLiteReAligner::produce")
<< "Cannot find alignment correction for RP " << tr.rpId() << ". The track will be skipped.";
edm::LogError("PPS") << "Cannot find alignment correction for RP " << tr.rpId() << ". The track will be skipped.";
} else {
output->emplace_back(tr.rpId(),
tr.x() + it->second.getShX(),
Expand Down
6 changes: 3 additions & 3 deletions RecoPPS/Local/test/re_alignment/reco_align_corr_cfg.py
Expand Up @@ -26,16 +26,16 @@
process.esPreferLocalAlignment = cms.ESPrefer("CTPPSRPAlignmentCorrectionsDataESSourceXML", "ctppsRPAlignmentCorrectionsDataESSourceXML")

# track re-alignment module
process.load("RecoPPS.Local.ctppsLocalTrackLiteReAligner_cfi")
process.load("RecoPPS.Local.ppsLocalTrackLiteReAligner_cfi")

# track plotter
process.ctppsTrackDistributionPlotter = cms.EDAnalyzer("CTPPSTrackDistributionPlotter",
tagTracks = cms.InputTag("ctppsLocalTrackLiteReAligner"),
tagTracks = cms.InputTag("ppsLocalTrackLiteReAligner"),
outputFile = cms.string("output_tracks_corr.root")
)

# processing sequences
process.path = cms.Path(
process.ctppsLocalTrackLiteReAligner
process.ppsLocalTrackLiteReAligner
* process.ctppsTrackDistributionPlotter
)

0 comments on commit 3386bdf

Please sign in to comment.