Skip to content

Commit

Permalink
Don't use Totem T2 RecHits due to relVal geometry problems, DB vs xml
Browse files Browse the repository at this point in the history
  • Loading branch information
oljemark committed Jun 9, 2023
1 parent 9eb5976 commit f932e9c
Show file tree
Hide file tree
Showing 16 changed files with 120 additions and 156 deletions.
38 changes: 35 additions & 3 deletions CalibPPS/ESProducers/plugins/TotemDAQMappingESSourceXML.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Framework/interface/ESProducer.h"
#include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
#include "FWCore/Framework/interface/ESProducts.h"
Expand Down Expand Up @@ -85,6 +87,8 @@ class TotemDAQMappingESSourceXML : public edm::ESProducer, public edm::EventSetu
TotemDAQMappingESSourceXML(const edm::ParameterSet &);
~TotemDAQMappingESSourceXML() override;

static void fillDescriptions(edm::ConfigurationDescriptions &);

edm::ESProducts<std::unique_ptr<TotemDAQMapping>, std::unique_ptr<TotemAnalysisMask>> produce(const TotemReadoutRcd &);

private:
Expand Down Expand Up @@ -276,9 +280,7 @@ TotemDAQMappingESSourceXML::TotemDAQMappingESSourceXML(const edm::ParameterSet &
: verbosity(conf.getUntrackedParameter<unsigned int>("verbosity", 0)),
subSystemName(conf.getUntrackedParameter<string>("subSystem")),
sampicSubDetId(conf.getParameter<unsigned int>("sampicSubDetId")),
packedPayload(conf.existsAs<bool>("multipleChannelsPerPayload", true)
? conf.getParameter<bool>("multipleChannelsPerPayload")
: false),
packedPayload(conf.getParameter<bool>("multipleChannelsPerPayload")),
currentBlock(0),
currentBlockValid(false) {
for (const auto &it : conf.getParameter<vector<ParameterSet>>("configuration")) {
Expand Down Expand Up @@ -1062,4 +1064,34 @@ void TotemDAQMappingESSourceXML::GetChannels(xercesc::DOMNode *n, set<unsigned c

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

void TotemDAQMappingESSourceXML::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
// totemDAQMappingESSourceXML
edm::ParameterSetDescription desc;
desc.addUntracked<unsigned int>("verbosity", 0);
desc.addUntracked<std::string>("subSystem", "")->setComment("set it to: TrackingStrip, ...");
desc.add<unsigned int>("sampicSubDetId");
desc.add<bool>("multipleChannelsPerPayload", false);
{
edm::ParameterSetDescription vpsd1;
vpsd1.add<edm::EventRange>("validityRange", edm::EventRange(1, 0, 1, 1, 0, 0));
vpsd1.add<std::vector<std::string>>("mappingFileNames", {});
vpsd1.add<std::vector<std::string>>("maskFileNames", {});
std::vector<edm::ParameterSet> temp1;
temp1.reserve(1);
{
edm::ParameterSet temp2;
temp2.addParameter<edm::EventRange>("validityRange", edm::EventRange(1, 0, 1, 1, 0, 0));
temp2.addParameter<std::vector<std::string>>("mappingFileNames", {});
temp2.addParameter<std::vector<std::string>>("maskFileNames", {});
temp1.push_back(temp2);
}
desc.addVPSet("configuration", vpsd1, temp1)->setComment("validityRange, mappingFileNames and maskFileNames");
}
descriptions.add("totemDAQMappingESSourceXML", desc);
// or use the following to generate the label from the module's C++ type
//descriptions.addWithDefaultLabel(desc);
}

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

DEFINE_FWK_EVENTSETUP_SOURCE(TotemDAQMappingESSourceXML);
18 changes: 0 additions & 18 deletions CalibPPS/ESProducers/python/totemDAQMappingESSourceXML_cfi.py

This file was deleted.

8 changes: 1 addition & 7 deletions CalibPPS/ESProducers/python/totemT2DAQMapping_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@
totemDAQMappingESSourceXML = _xml.clone(
subSystem = "TotemT2",
configuration = cms.VPSet(
#initial dummy diamond map copy, use only for Run 2 where T2 mapping is read with old schema
cms.PSet(
validityRange = cms.EventRange("1:min - 339999:max"),
mappingFileNames = cms.vstring("CondFormats/PPSObjects/xml/mapping_totem_nt2_2021.xml"),
maskFileNames = cms.vstring()
),
#old v2.1 T2 firmware test file
cms.PSet(
validityRange = cms.EventRange("340000:min - 368022:max"),
validityRange = cms.EventRange("1:min - 368022:max"),
mappingFileNames = cms.vstring("CondFormats/PPSObjects/xml/mapping_totem_nt2_2023.xml"),
maskFileNames = cms.vstring()
),
Expand Down
69 changes: 24 additions & 45 deletions DQM/CTPPS/plugins/TotemT2DQMSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "DataFormats/CTPPSDetId/interface/TotemT2DetId.h"
#include "DataFormats/TotemReco/interface/TotemT2Digi.h"
#include "DataFormats/TotemReco/interface/TotemT2RecHit.h"

#include "Geometry/Records/interface/TotemGeometryRcd.h"
#include "DQM/CTPPS/interface/TotemT2Segmentation.h"
Expand All @@ -46,14 +45,11 @@ class TotemT2DQMSource : public DQMEDAnalyzer {
void bookErrorFlagsHistogram(DQMStore::IBooker&);
void fillErrorFlagsHistogram(const TotemT2Digi&, const TotemT2DetId&);
void fillEdges(const TotemT2Digi&, const TotemT2DetId&);
void fillToT(const TotemT2RecHit&, const TotemT2DetId&);
void fillToT(const TotemT2Digi&, const TotemT2DetId&);
void fillFlags(const TotemT2Digi&, const TotemT2DetId&);

const edm::ESGetToken<TotemGeometry, TotemGeometryRcd> geometryToken_;
const edm::EDGetTokenT<edmNew::DetSetVector<TotemT2Digi>> digiToken_;
const edm::EDGetTokenT<edmNew::DetSetVector<TotemT2RecHit>> rechitToken_;

std::unique_ptr<TotemT2Segmentation> segm_;

static constexpr double T2_BIN_WIDTH_NS_ = 25. / 4;
MonitorElement* totemT2ErrorFlags_2D_ = nullptr;
Expand Down Expand Up @@ -129,7 +125,7 @@ TotemT2DQMSource::SectorPlots::SectorPlots(
"trailing edge", title + " trailing edge (DIGIs); trailing edge (ns)", 25 * windowsNum, 0, 25 * windowsNum);

timeOverTreshold = ibooker.book1D(
"time over threshold", title + " time over threshold (rechit);time over threshold (ns)", 500, -50, 200);
"time over threshold", title + " time over threshold (digi);time over threshold (ns)", 500, -50, 200);

eventFlags = ibooker.book1D(
"event flags", title + " event flags (digi);Event flags (TE/LE valid, TE/LE multiple)", 4, -0.5, 3.5);
Expand Down Expand Up @@ -183,7 +179,7 @@ TotemT2DQMSource::ChannelPlots::ChannelPlots(DQMStore::IBooker& ibooker, unsigne
"trailing edge", title + " trailing edge (DIGIs); trailing edge (ns)", 25 * windowsNum, 0, 25 * windowsNum);

timeOverTresholdCh = ibooker.book1D(
"time over threshold", title + " time over threshold (rechit);time over threshold (ns)", 500, -50, 200);
"time over threshold", title + " time over threshold (digi);time over threshold (ns)", 500, -50, 200);

eventFlagsCh = ibooker.book1D(
"event flags", title + " event flags (digi);Event flags (TE/LE valid, TE/LE multiple)", 4, -0.5, 3.5);
Expand All @@ -195,7 +191,6 @@ TotemT2DQMSource::ChannelPlots::ChannelPlots(DQMStore::IBooker& ibooker, unsigne
TotemT2DQMSource::TotemT2DQMSource(const edm::ParameterSet& iConfig)
: geometryToken_(esConsumes<TotemGeometry, TotemGeometryRcd, edm::Transition::BeginRun>()),
digiToken_(consumes<edmNew::DetSetVector<TotemT2Digi>>(iConfig.getParameter<edm::InputTag>("digisTag"))),
rechitToken_(consumes<edmNew::DetSetVector<TotemT2RecHit>>(iConfig.getParameter<edm::InputTag>("rechitsTag"))),
nbinsx_(iConfig.getParameter<unsigned int>("nbinsx")),
nbinsy_(iConfig.getParameter<unsigned int>("nbinsy")),
windowsNum_(iConfig.getParameter<unsigned int>("windowsNum")) {}
Expand Down Expand Up @@ -224,47 +219,23 @@ void TotemT2DQMSource::bookHistograms(DQMStore::IBooker& ibooker, const edm::Run
}

// build a segmentation helper for the size of histograms previously booked
segm_ = std::make_unique<TotemT2Segmentation>(iSetup.getData(geometryToken_), nbinsx_, nbinsy_);
}

void TotemT2DQMSource::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
// fill digis information
for (const auto& ds_digis : iEvent.get(digiToken_)) {
const TotemT2DetId detid(ds_digis.detId());
const TotemT2DetId planeId(detid.planeId());
for (const auto& digi : ds_digis) {
segm_->fill(planePlots_[planeId].digisMultiplicity->getTH2D(), detid);
fillTriggerBitset(detid);
fillErrorFlagsHistogram(digi, detid);
fillEdges(digi, detid);
fillFlags(digi, detid);
if (!ds_digis.empty()) {
const TotemT2DetId detid(ds_digis.detId());
for (const auto& digi : ds_digis) {
fillTriggerBitset(detid);
fillErrorFlagsHistogram(digi, detid);
fillEdges(digi, detid);
fillToT(digi, detid);
fillFlags(digi, detid);
}
}
}

// fill rechits information
std::unordered_map<unsigned int, std::set<unsigned int>> planes;
for (const auto& ds_rechits : iEvent.get(rechitToken_)) {
const TotemT2DetId detid(ds_rechits.detId());
const TotemT2DetId planeId(detid.planeId());
for (const auto& rechit : ds_rechits) {
segm_->fill(planePlots_[planeId].rechitMultiplicity->getTH2D(), detid);
fillToT(rechit, detid);
fillActivePlanes(planes, detid);
}
}

for (const auto& plt : sectorPlots_)
plt.second.activePlanesCount->Fill(planes[plt.first].size());

for (unsigned short arm = 0; arm <= CTPPSDetId::maxArm; ++arm)
for (unsigned short plane = 0; plane <= 1; ++plane)
for (unsigned short id = 0; id <= TotemT2DetId::maxChannel; ++id) {
const TotemT2DetId detid(arm, plane, id);
if (areChannelsTriggered(detid)) {
const TotemT2DetId secId(detid.armId());
segm_->fill(sectorPlots_[secId].triggerEmulator->getTH2D(), detid);
}
}

clearTriggerBitset();
}
Expand Down Expand Up @@ -321,7 +292,7 @@ void TotemT2DQMSource::bookErrorFlagsHistogram(DQMStore::IBooker& ibooker) {
void TotemT2DQMSource::fillErrorFlagsHistogram(const TotemT2Digi& digi, const TotemT2DetId& detid) {
// readout flags histogram filling
for (unsigned int i = 0; i < 4; i++) {
if (digi.getStatus() & (1 << i))
if (digi.status() & (1 << i))
totemT2ErrorFlags_2D_->Fill(i + 0.0, detid.arm() + 0.0);
}
}
Expand All @@ -334,10 +305,18 @@ void TotemT2DQMSource::fillEdges(const TotemT2Digi& digi, const TotemT2DetId& de
channelPlots_[detid].trailingEdgeCh->Fill(T2_BIN_WIDTH_NS_ * digi.trailingEdge());
}

void TotemT2DQMSource::fillToT(const TotemT2RecHit& rechit, const TotemT2DetId& detid) {
void TotemT2DQMSource::fillToT(const TotemT2Digi& digi, const TotemT2DetId& detid) {
const TotemT2DetId secId(detid.armId());
sectorPlots_[secId].timeOverTreshold->Fill(rechit.toT());
channelPlots_[detid].timeOverTresholdCh->Fill(rechit.toT());

const int t_lead = digi.leadingEdge(), t_trail = digi.trailingEdge();
// don't skip no-edge digis
double toT = 0.;
if (digi.hasLE() && digi.hasTE()) {
toT = (t_trail - t_lead) * T2_BIN_WIDTH_NS_; // in ns
}

sectorPlots_[secId].timeOverTreshold->Fill(toT);
channelPlots_[detid].timeOverTresholdCh->Fill(toT);
}

void TotemT2DQMSource::fillFlags(const TotemT2Digi& digi, const TotemT2DetId& detid) {
Expand Down
1 change: 0 additions & 1 deletion DQM/CTPPS/python/totemT2DQMSource_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer
totemT2DQMSource = DQMEDAnalyzer('TotemT2DQMSource',
digisTag = cms.InputTag('totemT2Digis', 'TotemT2'),
rechitsTag = cms.InputTag('totemT2RecHits'),
nbinsx = cms.uint32(25),
nbinsy = cms.uint32(25),
windowsNum = cms.uint32(8),
Expand Down
2 changes: 1 addition & 1 deletion DQM/CTPPS/test/totemt2_dqm_test_common_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#from Configuration.AlCa.GlobalTag import GlobalTag
#process.GlobalTag = GlobalTag(process.GlobalTag, '130X_dataRun3_HLT_v2', '')

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

# CTPPS DQM modules
Expand Down
4 changes: 0 additions & 4 deletions DQM/CTPPS/test/totemt2_dqm_test_nino_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
#Raw-to-digi
process.load('EventFilter.CTPPSRawToDigi.ctppsRawToDigi_cff')

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

# CTPPS DQM modules
process.load("DQM.CTPPS.ctppsDQM_cff")
process.totemDAQMappingESSourceXML_TotemT2.verbosity = 0
Expand All @@ -65,7 +62,6 @@
process.path = cms.Path(
process.ctppsRawToDigi *
process.totemT2Digis *
process.totemT2RecHits *
process.totemT2DQMSource
)

Expand Down
2 changes: 1 addition & 1 deletion DataFormats/TotemReco/interface/TotemT2Digi.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TotemT2Digi {
unsigned short leadingEdge() const { return lead_edge_; }
void setTrailingEdge(unsigned short te) { trail_edge_ = te; }
unsigned short trailingEdge() const { return trail_edge_; }
unsigned char getStatus() const { return status_ & 0xF; }
unsigned char status() const { return status_ & 0xF; }
bool hasLE() const { return marker_ & 0x1; }
bool hasTE() const { return marker_ & 0x2; }
bool hasManyLE() const { return marker_ & 0x4; }
Expand Down
49 changes: 49 additions & 0 deletions EventFilter/CTPPSRawToDigi/plugins/TotemVFATRawToDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
#include "DataFormats/CTPPSDigi/interface/TotemTimingDigi.h"
#include "DataFormats/TotemReco/interface/TotemT2Digi.h"

#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"

#include <string>

class TotemVFATRawToDigi : public edm::stream::EDProducer<> {
Expand All @@ -44,6 +47,7 @@ class TotemVFATRawToDigi : public edm::stream::EDProducer<> {

void produce(edm::Event &, const edm::EventSetup &) override;
void endStream() override;
static void fillDescriptions(edm::ConfigurationDescriptions &);

private:
std::string subSystemName;
Expand Down Expand Up @@ -196,4 +200,49 @@ void TotemVFATRawToDigi::run(edm::Event &event, const edm::EventSetup &es) {

void TotemVFATRawToDigi::endStream() { rawToDigiConverter.printSummaries(); }

void TotemVFATRawToDigi::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
// totemVFATRawToDigi
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("rawDataTag", edm::InputTag(""));
desc.add<std::string>("subSystem", "")->setComment("options: RP");
desc.add<std::vector<unsigned int>>("fedIds", {})
->setComment(
"IMPORTANT: leave empty to load the default configuration from "
"DataFormats/FEDRawData/interface/FEDNumbering.h");
{
edm::ParameterSetDescription psd0;
psd0.addUntracked<unsigned int>("verbosity", 0);
desc.add<edm::ParameterSetDescription>("RawUnpacking", psd0);
}
{
edm::ParameterSetDescription psd0;
psd0.addUntracked<unsigned int>("verbosity", 0)
->setComment(
"0-3: 1=one line/event with some corrupted VFAT frame, 2=list all corrupt VFAT frames/event, 3=all "
"problems with every corrupt frame");
psd0.add<unsigned int>("testFootprint", 2)->setComment("0=no test, 1=warn only, 2=warn and skip");
psd0.add<unsigned int>("testCRC", 2);
psd0.add<unsigned int>("testID", 2)->setComment("compare the ID from data and mapping");
psd0.add<unsigned int>("testECMostFrequent", 2)
->setComment("compare frame EC with the most frequent value in the event");
psd0.add<unsigned int>("testBCMostFrequent", 2);
psd0.addUntracked<unsigned int>("EC_min", 10)
->setComment("minimal number of frames to search for the most frequent counter value");
psd0.addUntracked<unsigned int>("BC_min", 10);
psd0.addUntracked<double>("EC_fraction", 0.6)
->setComment(
"the most frequent counter value is accepted provided its relative occupancy is higher than this fraction");
psd0.addUntracked<double>("BC_fraction", 0.6);
psd0.add<bool>("useOlderT2TestFile", false)
->setComment("treat hwID field as two separate 8-bit fields instead of one 16-bit");
psd0.addUntracked<bool>("printErrorSummary", false)->setComment("per-VFAT error summary at the end of the job");
psd0.addUntracked<bool>("printUnknownFrameSummary", false)
->setComment("summary of frames found in data, but not in the mapping");
desc.add<edm::ParameterSetDescription>("RawToDigi", psd0);
}
descriptions.add("totemVFATRawToDigi", desc);
// or use the following to generate the label from the module's C++ type
//descriptions.addWithDefaultLabel(desc);
}

DEFINE_FWK_MODULE(TotemVFATRawToDigi);
4 changes: 0 additions & 4 deletions EventFilter/CTPPSRawToDigi/python/ctppsRawToDigi_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,6 @@
(ctpps_2016 | ctpps_2017 | ctpps_2018).toModify(ctppsPixelDigis, isRun3 = False )
(ctpps_2016 | ctpps_2017 | ctpps_2018).toModify(totemDAQMappingESSourceXML_TotemTiming, sampicSubDetId = 6)

# The Totem T2 mapping was expanded with a 2-channel unpacker in PR #41472, changing the xml format causing this module to not accept
# the 2021 dummy mapping copied from diamonds if this parameter is turned on
(ctpps_2016 | ctpps_2017 | ctpps_2018).toModify(totemDAQMappingESSourceXML_TotemT2, multipleChannelsPerPayload = False)

# raw-to-digi task and sequence
ctppsRawToDigiTask = cms.Task(
totemRPRawToDigi,
Expand Down
Loading

0 comments on commit f932e9c

Please sign in to comment.