Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PPS: re-alignment module #30452

Merged
merged 5 commits into from
Jul 4, 2020
Merged
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
103 changes: 103 additions & 0 deletions RecoPPS/Local/plugins/PPSLocalTrackLiteReAligner.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/****************************************************************************
*
* This is a part of TOTEM offline software.
* Authors:
* Jan Kašpar (jan.kaspar@gmail.com)
*
****************************************************************************/

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h"
#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h"

#include "CondFormats/AlignmentRecord/interface/RPRealAlignmentRecord.h"
#include "CondFormats/PPSObjects/interface/CTPPSRPAlignmentCorrectionsData.h"

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

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

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

static void fillDescriptions(edm::ConfigurationDescriptions &);

private:
const edm::EDGetTokenT<CTPPSLocalTrackLiteCollection> inputTrackToken_;

const edm::ESGetToken<CTPPSRPAlignmentCorrectionsData, RPRealAlignmentRecord> alignmentToken_;

const std::string outputTrackTag_;
};

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

PPSLocalTrackLiteReAligner::PPSLocalTrackLiteReAligner(const edm::ParameterSet &iConfig)
: inputTrackToken_(consumes<CTPPSLocalTrackLiteCollection>(iConfig.getParameter<edm::InputTag>("inputTrackTag"))),
alignmentToken_(esConsumes<CTPPSRPAlignmentCorrectionsData, RPRealAlignmentRecord>(
iConfig.getParameter<edm::ESInputTag>("alignmentTag"))),
outputTrackTag_(iConfig.getParameter<std::string>("outputTrackTag")) {
produces<CTPPSLocalTrackLiteCollection>(outputTrackTag_);
}

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

void PPSLocalTrackLiteReAligner::fillDescriptions(edm::ConfigurationDescriptions &descr) {
edm::ParameterSetDescription desc;

desc.add<edm::InputTag>("inputTrackTag", edm::InputTag("ctppsLocalTrackLiteProducer"))
->setComment("tag of the input CTPPSLocalTrackLiteCollection");

desc.add<edm::ESInputTag>("alignmentTag", edm::ESInputTag(""))->setComment("tag of the alignment data");

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

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

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

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

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

// 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("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(),
tr.xUnc(),
tr.y() + it->second.getShY(),
tr.yUnc(),
tr.tx(),
tr.txUnc(),
tr.ty(),
tr.tyUnc(),
tr.chiSquaredOverNDF(),
tr.pixelTrackRecoInfo(),
tr.numberOfPointsUsedForFit(),
tr.time(),
tr.timeUnc());
}
}

// save output to event
iEvent.put(std::move(output), outputTrackTag_);
}

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

DEFINE_FWK_MODULE(PPSLocalTrackLiteReAligner);
48 changes: 48 additions & 0 deletions RecoPPS/Local/test/re_alignment/align_base.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<xml DocumentType="AlignmentDescription">
<iov first="286693:0" last="309054:0">
<!-- RP 023 -->
<!-- plane 0 --> <det id="2023227392" sh_x="-35.9635" sh_y="87.2363" rot_z="2.68553"/>
<!-- plane 1 --> <det id="2023292928" sh_x="84.2971" sh_y="-133.722" rot_z="-3.13393"/>
<!-- plane 2 --> <det id="2023358464" sh_x="-66.6512" sh_y="79.825" rot_z="1.30372"/>
<!-- plane 3 --> <det id="2023424000" sh_x="-10.4912" sh_y="-20.1502" rot_z="0.311843"/>
<!-- plane 4 --> <det id="2023489536" sh_x="-24.1605" sh_y="-26.5815" rot_z="-0.936705"/>
<!-- plane 5 --> <det id="2023555072" sh_x="52.9695" sh_y="13.3938" rot_z="-0.313406"/>
<!-- RP 123 -->
<!-- plane 0 --> <det id="2040004608" sh_x="-11.5768" sh_y="34.0201" rot_z="-0.768535"/>
<!-- plane 1 --> <det id="2040070144" sh_x="15.7797" sh_y="-54.2286" rot_z="1.88971"/>
<!-- plane 2 --> <det id="2040135680" sh_x="-40.0864" sh_y="-15.8274" rot_z="-0.612843"/>
<!-- plane 3 --> <det id="2040201216" sh_x="35.6525" sh_y="92.4925" rot_z="1.63349"/>
<!-- plane 4 --> <det id="2040266752" sh_x="-1.36095" sh_y="-137.044" rot_z="1.09791"/>
<!-- plane 5 --> <det id="2040332288" sh_x="1.59186" sh_y="80.5886" rot_z="-0.664545"/>
</iov>
<iov first="309055:0" last="999999:0">
<!-- RP 003 -->
<!-- plane 0 --> <det id="2014838784" sh_x="-15.7701" sh_y="-94.4936" rot_z="-1.4252"/>
<!-- plane 1 --> <det id="2014904320" sh_x="93.9394" sh_y="-26.9887" rot_z="1.91457"/>
<!-- plane 2 --> <det id="2014969856" sh_x="-63.0278" sh_y="152.031" rot_z="-1.65325"/>
<!-- plane 3 --> <det id="2015035392" sh_x="10.37" sh_y="97.6936" rot_z="3.3245"/>
<!-- plane 4 --> <det id="2015100928" sh_x="-92.1971" sh_y="-32.6216" rot_z="0.115109"/>
<!-- plane 5 --> <det id="2015166464" sh_x="66.686" sh_y="-95.6206" rot_z="-1.63449"/>
<!-- RP 023 -->
<!-- plane 0 --> <det id="2023227392" sh_x="4.54579" sh_y="-40.6927" rot_z="0.848513"/>
<!-- plane 1 --> <det id="2023292928" sh_x="31.1031" sh_y="73.2235" rot_z="-1.95257"/>
<!-- plane 2 --> <det id="2023358464" sh_x="-47.7215" sh_y="7.24208" rot_z="2.24815"/>
<!-- plane 3 --> <det id="2023424000" sh_x="35.172" sh_y="-92.319" rot_z="-0.689027"/>
<!-- plane 4 --> <det id="2023489536" sh_x="-3.6213" sh_y="136.939" rot_z="-0.358975"/>
<!-- plane 5 --> <det id="2023555072" sh_x="-19.4781" sh_y="-84.3935" rot_z="-0.0043562"/>
<!-- RP 103 -->
<!-- plane 0 --> <det id="2031616000" sh_x="-24.7711" sh_y="-57.4046" rot_z="1.71518"/>
<!-- plane 1 --> <det id="2031681536" sh_x="-13.5192" sh_y="-0.22209" rot_z="3.08372"/>
<!-- plane 2 --> <det id="2031747072" sh_x="12.1851" sh_y="33.8158" rot_z="-5.21848"/>
<!-- plane 3 --> <det id="2031812608" sh_x="63.0733" sh_y="75.9386" rot_z="0.374934"/>
<!-- plane 4 --> <det id="2031878144" sh_x="-80.7587" sh_y="-46.9854" rot_z="0.342114"/>
<!-- plane 5 --> <det id="2031943680" sh_x="43.7905" sh_y="-5.14235" rot_z="-0.495176"/>
<!-- RP 123 -->
<!-- plane 0 --> <det id="2040004608" sh_x="-36.6176" sh_y="-82.9431" rot_z="-0.743671"/>
<!-- plane 1 --> <det id="2040070144" sh_x="79.3757" sh_y="125.733" rot_z="4.87596"/>
<!-- plane 2 --> <det id="2040135680" sh_x="-48.6157" sh_y="-75.2134" rot_z="-1.09407"/>
<!-- plane 3 --> <det id="2040201216" sh_x="1.47217" sh_y="3.87701" rot_z="-0.264878"/>
<!-- plane 4 --> <det id="2040266752" sh_x="-37.9384" sh_y="17.2434" rot_z="0.0792749"/>
<!-- plane 5 --> <det id="2040332288" sh_x="42.3237" sh_y="11.3038" rot_z="-1.4928"/>
</iov>
</xml>
20 changes: 20 additions & 0 deletions RecoPPS/Local/test/re_alignment/align_corr.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- Shifts in um, rotations in mrad. -->
<xml DocumentType="AlignmentDescription">
<iov first="320688:1" last="320688:4294967295">
<!-- RP 3 -->
<rp id="2014838784" sh_x="-3693.00" sh_y="-3944.00" sh_z=" +0.00" rot_x="+0.00000" rot_y="+0.00000" rot_z="-0.00000"/>

<!-- RP 23 -->
<rp id="2023227392" sh_x="-41771.00" sh_y="-3708.00" sh_z=" +0.00" rot_x="+0.00000" rot_y="+0.00000" rot_z="-0.00000"/>

<!-- RP 103 -->
<rp id="2031616000" sh_x="-2745.00" sh_y="-3384.00" sh_z=" +0.00" rot_x="+0.00000" rot_y="+0.00000" rot_z="-0.00000"/>

<!-- RP 123 -->
<rp id="2040004608" sh_x="-41804.00" sh_y="-3190.00" sh_z=" +0.00" rot_x="+0.00000" rot_y="+0.00000" rot_z="-0.00000"/>

<!-- timing RPs -->
<rp id="2054160384" sh_x="0" sh_y="0"/>
<rp id="2070937600" sh_x="0" sh_y="0"/>
</iov>
</xml>
41 changes: 41 additions & 0 deletions RecoPPS/Local/test/re_alignment/reco_align_corr_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import FWCore.ParameterSet.Config as cms

from Configuration.StandardSequences.Eras import eras
process = cms.Process('ReAlignment', eras.Run2_2018)

# minimum of logs
process.MessageLogger = cms.Service("MessageLogger",
statistics = cms.untracked.vstring(),
destinations = cms.untracked.vstring("cout"),
cout = cms.untracked.PSet(
threshold = cms.untracked.string("WARNING")
)
)

# raw data source
process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring("file://output_base.root"),
)

# load alignment correction
process.load("CalibPPS.ESProducers.ctppsRPAlignmentCorrectionsDataESSourceXML_cfi")
process.ctppsRPAlignmentCorrectionsDataESSourceXML.RealFiles = cms.vstring(
"RecoPPS/Local/test/re_alignment/align_corr.xml"
)

process.esPreferLocalAlignment = cms.ESPrefer("CTPPSRPAlignmentCorrectionsDataESSourceXML", "ctppsRPAlignmentCorrectionsDataESSourceXML")

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

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

# processing sequences
process.path = cms.Path(
process.ppsLocalTrackLiteReAligner
* process.ctppsTrackDistributionPlotter
)
71 changes: 71 additions & 0 deletions RecoPPS/Local/test/re_alignment/reco_base_align_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import FWCore.ParameterSet.Config as cms

from Configuration.StandardSequences.Eras import eras
process = cms.Process('TEST', eras.Run2_2018)

# minimum of logs
process.MessageLogger = cms.Service("MessageLogger",
statistics = cms.untracked.vstring(),
destinations = cms.untracked.vstring("cout"),
cout = cms.untracked.PSet(
threshold = cms.untracked.string("WARNING")
)
)

# raw data source
process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring("/store/data/Run2018D/ZeroBias/RAW/v1/000/320/688/00000/601A721D-AD95-E811-B21A-FA163E28A50A.root"),
#fileNames = cms.untracked.vstring("root://eoscms.cern.ch//eos/cms/store/group/phys_pps/sw_test_input/601A721D-AD95-E811-B21A-FA163E28A50A.root"),

inputCommands = cms.untracked.vstring(
'drop *',
'keep FEDRawDataCollection_*_*_*'
)
)

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(1000)
)

# raw-to-digi conversion
process.load("EventFilter.CTPPSRawToDigi.ctppsRawToDigi_cff")

# local RP reconstruction chain with standard settings
process.load("RecoPPS.Configuration.recoCTPPS_cff")

# define GT
process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, "106X_dataRun2_v26")

# override alignment settings
process.load("CalibPPS.ESProducers.ctppsRPAlignmentCorrectionsDataESSourceXML_cfi")
process.ctppsRPAlignmentCorrectionsDataESSourceXML.RealFiles = cms.vstring(
"RecoPPS/Local/test/re_alignment/align_base.xml"
)

process.esPreferLocalAlignment = cms.ESPrefer("CTPPSRPAlignmentCorrectionsDataESSourceXML", "ctppsRPAlignmentCorrectionsDataESSourceXML")

# track plotter
process.ctppsTrackDistributionPlotter = cms.EDAnalyzer("CTPPSTrackDistributionPlotter",
tagTracks = cms.InputTag("ctppsLocalTrackLiteProducer"),
outputFile = cms.string("output_tracks_base.root")
)

# processing sequences
process.path = cms.Path(
process.ctppsRawToDigi
* process.recoCTPPS
* process.ctppsTrackDistributionPlotter
)

# output configuration
process.output = cms.OutputModule("PoolOutputModule",
fileName = cms.untracked.string("output_base.root"),
outputCommands = cms.untracked.vstring(
"drop *",
'keep CTPPSLocalTrackLites_*_*_*'
)
)

process.outpath = cms.EndPath(process.output)
61 changes: 61 additions & 0 deletions RecoPPS/Local/test/re_alignment/reco_full_align_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import FWCore.ParameterSet.Config as cms

from Configuration.StandardSequences.Eras import eras
process = cms.Process('TEST', eras.Run2_2018)

# minimum of logs
process.MessageLogger = cms.Service("MessageLogger",
statistics = cms.untracked.vstring(),
destinations = cms.untracked.vstring("cout"),
cout = cms.untracked.PSet(
threshold = cms.untracked.string("WARNING")
)
)

# raw data source
process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring("/store/data/Run2018D/ZeroBias/RAW/v1/000/320/688/00000/601A721D-AD95-E811-B21A-FA163E28A50A.root"),
#fileNames = cms.untracked.vstring("root://eoscms.cern.ch//eos/cms/store/group/phys_pps/sw_test_input/601A721D-AD95-E811-B21A-FA163E28A50A.root"),

inputCommands = cms.untracked.vstring(
'drop *',
'keep FEDRawDataCollection_*_*_*'
)
)

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(1000)
)

# raw-to-digi conversion
process.load("EventFilter.CTPPSRawToDigi.ctppsRawToDigi_cff")

# local RP reconstruction chain with standard settings
process.load("RecoPPS.Configuration.recoCTPPS_cff")

# define GT
process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, "106X_dataRun2_v26")

# override alignment settings
process.load("CalibPPS.ESProducers.ctppsRPAlignmentCorrectionsDataESSourceXML_cfi")
process.ctppsRPAlignmentCorrectionsDataESSourceXML.RealFiles = cms.vstring(
"RecoPPS/Local/test/re_alignment/align_base.xml",
"RecoPPS/Local/test/re_alignment/align_corr.xml"
)

process.esPreferLocalAlignment = cms.ESPrefer("CTPPSRPAlignmentCorrectionsDataESSourceXML", "ctppsRPAlignmentCorrectionsDataESSourceXML")

# track plotter
process.ctppsTrackDistributionPlotter = cms.EDAnalyzer("CTPPSTrackDistributionPlotter",
tagTracks = cms.InputTag("ctppsLocalTrackLiteProducer"),
outputFile = cms.string("output_tracks_full.root")
)

# processing sequences
process.path = cms.Path(
process.ctppsRawToDigi
* process.recoCTPPS
* process.ctppsTrackDistributionPlotter
)
8 changes: 8 additions & 0 deletions RecoPPS/Local/test/re_alignment/run_all
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

cmsRun reco_full_align_cfg.py &> reco_full_align.log &
cmsRun reco_base_align_cfg.py &> reco_base_align.log &

wait

cmsRun reco_align_corr_cfg.py &> reco_align_corr.log