diff --git a/CalibPPS/ESProducers/plugins/TotemDAQMappingESSourceXML.cc b/CalibPPS/ESProducers/plugins/TotemDAQMappingESSourceXML.cc index 56f5a4ded3776..c9e412ef265ad 100644 --- a/CalibPPS/ESProducers/plugins/TotemDAQMappingESSourceXML.cc +++ b/CalibPPS/ESProducers/plugins/TotemDAQMappingESSourceXML.cc @@ -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" @@ -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> produce(const TotemReadoutRcd &); private: @@ -276,7 +280,7 @@ TotemDAQMappingESSourceXML::TotemDAQMappingESSourceXML(const edm::ParameterSet & : verbosity(conf.getUntrackedParameter("verbosity", 0)), subSystemName(conf.getUntrackedParameter("subSystem")), sampicSubDetId(conf.getParameter("sampicSubDetId")), - packedPayload(conf.getUntrackedParameter("multipleChannelsPerPayload", false)), + packedPayload(conf.getParameter("multipleChannelsPerPayload")), currentBlock(0), currentBlockValid(false) { for (const auto &it : conf.getParameter>("configuration")) { @@ -1060,4 +1064,34 @@ void TotemDAQMappingESSourceXML::GetChannels(xercesc::DOMNode *n, set("verbosity", 0); + desc.addUntracked("subSystem", "")->setComment("set it to: TrackingStrip, ..."); + desc.add("sampicSubDetId"); + desc.add("multipleChannelsPerPayload", false); + { + edm::ParameterSetDescription vpsd1; + vpsd1.add("validityRange", edm::EventRange(1, 0, 1, 1, 0, 0)); + vpsd1.add>("mappingFileNames", {}); + vpsd1.add>("maskFileNames", {}); + std::vector temp1; + temp1.reserve(1); + { + edm::ParameterSet temp2; + temp2.addParameter("validityRange", edm::EventRange(1, 0, 1, 1, 0, 0)); + temp2.addParameter>("mappingFileNames", {}); + temp2.addParameter>("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); diff --git a/CalibPPS/ESProducers/python/totemDAQMappingESSourceXML_cfi.py b/CalibPPS/ESProducers/python/totemDAQMappingESSourceXML_cfi.py deleted file mode 100644 index db425a1a7e347..0000000000000 --- a/CalibPPS/ESProducers/python/totemDAQMappingESSourceXML_cfi.py +++ /dev/null @@ -1,17 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -totemDAQMappingESSourceXML = cms.ESSource("TotemDAQMappingESSourceXML", - verbosity = cms.untracked.uint32(0), - - # set it to: TrackingStrip, ... - subSystem = cms.untracked.string(""), - - configuration = cms.VPSet( - # example configuration block: - #cms.PSet( - # validityRange = cms.EventRange("1:min - 999999999:max"), - # mappingFileNames = cms.vstring("CondFormats/PPSObjects/xml/ctpps_mapping_to_fill_5288.xml"), - # maskFileNames = cms.vstring() - #) - ) -) diff --git a/CalibPPS/ESProducers/python/totemT2DAQMapping_cff.py b/CalibPPS/ESProducers/python/totemT2DAQMapping_cff.py index c7ff2e5fd1a33..2dbe3115eb3c0 100644 --- a/CalibPPS/ESProducers/python/totemT2DAQMapping_cff.py +++ b/CalibPPS/ESProducers/python/totemT2DAQMapping_cff.py @@ -4,20 +4,20 @@ totemDAQMappingESSourceXML = _xml.clone( subSystem = "TotemT2", - multipleChannelsPerPayload = cms.untracked.bool(False), configuration = cms.VPSet( - #initial dummy diamond map copy + #old v2.1 T2 firmware test file cms.PSet( - validityRange = cms.EventRange("1:min - 364982:max"), - mappingFileNames = cms.vstring("CondFormats/PPSObjects/xml/mapping_totem_nt2_2021.xml"), + validityRange = cms.EventRange("1:min - 368022:max"), + mappingFileNames = cms.vstring("CondFormats/PPSObjects/xml/mapping_totem_nt2_2023.xml"), maskFileNames = cms.vstring() ), - #T2 firmware test files + #final T2 mapping test files cms.PSet( - validityRange = cms.EventRange("364983:min - 999999999:max"), - mappingFileNames = cms.vstring("CondFormats/PPSObjects/xml/mapping_totem_nt2_2023.xml"), + validityRange = cms.EventRange("368023:min - 999999999:max"), + mappingFileNames = cms.vstring("CondFormats/PPSObjects/xml/mapping_totem_nt2_2023_final.xml"), maskFileNames = cms.vstring() ) ), sampicSubDetId = cms.uint32(6), + multipleChannelsPerPayload = True, ) diff --git a/CondFormats/PPSObjects/xml/mapping_totem_nt2_2023_final.xml b/CondFormats/PPSObjects/xml/mapping_totem_nt2_2023_final.xml new file mode 100644 index 0000000000000..64a6a4367f85f --- /dev/null +++ b/CondFormats/PPSObjects/xml/mapping_totem_nt2_2023_final.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DQM/CTPPS/plugins/TotemT2DQMSource.cc b/DQM/CTPPS/plugins/TotemT2DQMSource.cc index a76e4d2728e71..c9ab152314376 100644 --- a/DQM/CTPPS/plugins/TotemT2DQMSource.cc +++ b/DQM/CTPPS/plugins/TotemT2DQMSource.cc @@ -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" @@ -44,18 +43,18 @@ class TotemT2DQMSource : public DQMEDAnalyzer { void clearTriggerBitset(); bool areChannelsTriggered(const TotemT2DetId&); void bookErrorFlagsHistogram(DQMStore::IBooker&); - void fillErrorFlagsHistogram(const TotemT2Digi&); + 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 geometryToken_; const edm::EDGetTokenT> digiToken_; - const edm::EDGetTokenT> rechitToken_; - - std::unique_ptr segm_; static constexpr double T2_BIN_WIDTH_NS_ = 25. / 4; - MonitorElement* HPTDCErrorFlags_2D_ = nullptr; + MonitorElement* totemT2ErrorFlags_2D_ = nullptr; + + enum evFlag { t2TE = 0, t2LE, t2MT, t2ML }; const unsigned int nbinsx_, nbinsy_; const unsigned int windowsNum_; @@ -68,7 +67,7 @@ class TotemT2DQMSource : public DQMEDAnalyzer { std::bitset<(TotemT2DetId::maxPlane + 1) * (TotemT2DetId::maxChannel + 1)> hitTilesArray; static const unsigned int MINIMAL_TRIGGER = 3; - MonitorElement *leadingEdge = nullptr, *trailingEdge = nullptr, *timeOverTreshold = nullptr; + MonitorElement *leadingEdge = nullptr, *trailingEdge = nullptr, *timeOverTreshold = nullptr, *eventFlags = nullptr; SectorPlots() = default; SectorPlots( @@ -78,6 +77,7 @@ class TotemT2DQMSource : public DQMEDAnalyzer { struct PlanePlots { MonitorElement* digisMultiplicity = nullptr; MonitorElement* rechitMultiplicity = nullptr; + MonitorElement* eventFlagsPl = nullptr; PlanePlots() = default; PlanePlots(DQMStore::IBooker& ibooker, unsigned int id, unsigned int nbinsx, unsigned int nbinsy); @@ -86,6 +86,7 @@ class TotemT2DQMSource : public DQMEDAnalyzer { MonitorElement* leadingEdgeCh = nullptr; MonitorElement* trailingEdgeCh = nullptr; MonitorElement* timeOverTresholdCh = nullptr; + MonitorElement* eventFlagsCh = nullptr; ChannelPlots() = default; ChannelPlots(DQMStore::IBooker& ibooker, unsigned int id, unsigned int windowsNum); @@ -124,7 +125,13 @@ 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)", 250, -25, 100); + "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); + + for (unsigned short flag_index = 1; flag_index <= 4; ++flag_index) + eventFlags->setBinLabel(flag_index, "Flag " + std::to_string(flag_index)); } TotemT2DQMSource::PlanePlots::PlanePlots(DQMStore::IBooker& ibooker, @@ -152,6 +159,12 @@ TotemT2DQMSource::PlanePlots::PlanePlots(DQMStore::IBooker& ibooker, nbinsy, -0.5, double(nbinsy) - 0.5); + + eventFlagsPl = ibooker.book1D( + "event flags", title + " event flags (digi);Event flags (TE/LE valid, TE/LE multiple)", 4, -0.5, 3.5); + + for (unsigned short flag_index = 1; flag_index <= 4; ++flag_index) + eventFlagsPl->setBinLabel(flag_index, "Flag " + std::to_string(flag_index)); } TotemT2DQMSource::ChannelPlots::ChannelPlots(DQMStore::IBooker& ibooker, unsigned int id, unsigned int windowsNum) { @@ -166,13 +179,18 @@ 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)", 250, -25, 100); + "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); + + for (unsigned short flag_index = 1; flag_index <= 4; ++flag_index) + eventFlagsCh->setBinLabel(flag_index, "Flag " + std::to_string(flag_index)); } TotemT2DQMSource::TotemT2DQMSource(const edm::ParameterSet& iConfig) : geometryToken_(esConsumes()), digiToken_(consumes>(iConfig.getParameter("digisTag"))), - rechitToken_(consumes>(iConfig.getParameter("rechitsTag"))), nbinsx_(iConfig.getParameter("nbinsx")), nbinsy_(iConfig.getParameter("nbinsy")), windowsNum_(iConfig.getParameter("windowsNum")) {} @@ -201,46 +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(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); - fillEdges(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> 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(); } @@ -285,18 +280,21 @@ bool TotemT2DQMSource::areChannelsTriggered(const TotemT2DetId& detid) { } void TotemT2DQMSource::bookErrorFlagsHistogram(DQMStore::IBooker& ibooker) { - HPTDCErrorFlags_2D_ = ibooker.book2D("HPTDC Errors", " HPTDC Errors?", 8, -0.5, 7.5, 2, -0.5, 1.5); - for (unsigned short error_index = 1; error_index <= 8; ++error_index) - HPTDCErrorFlags_2D_->setBinLabel(error_index, "Flag " + std::to_string(error_index)); + totemT2ErrorFlags_2D_ = ibooker.book2D("nt2 readout flags", " nt2 readout flags", 4, -0.5, 3.5, 2, -0.5, 1.5); + for (unsigned short error_index = 1; error_index <= 4; ++error_index) + totemT2ErrorFlags_2D_->setBinLabel(error_index, "Flag " + std::to_string(error_index)); int tmpIndex = 0; - HPTDCErrorFlags_2D_->setBinLabel(++tmpIndex, "some id 0", /* axis */ 2); - HPTDCErrorFlags_2D_->setBinLabel(++tmpIndex, "some id 1", /* axis */ 2); + totemT2ErrorFlags_2D_->setBinLabel(++tmpIndex, "arm 4-5", /* axis */ 2); + totemT2ErrorFlags_2D_->setBinLabel(++tmpIndex, "arm 5-6", /* axis */ 2); } -void TotemT2DQMSource::fillErrorFlagsHistogram(const TotemT2Digi& digi) { - // placeholder for error hitogram filling - (void)digi; +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)) + totemT2ErrorFlags_2D_->Fill(i + 0.0, detid.arm() + 0.0); + } } void TotemT2DQMSource::fillEdges(const TotemT2Digi& digi, const TotemT2DetId& detid) { @@ -307,10 +305,46 @@ 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()); + + 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) { const TotemT2DetId secId(detid.armId()); - sectorPlots_[secId].timeOverTreshold->Fill(rechit.toT()); - channelPlots_[detid].timeOverTresholdCh->Fill(rechit.toT()); + const TotemT2DetId planeId(detid.planeId()); + if (digi.hasTE()) { + sectorPlots_[secId].eventFlags->Fill(t2TE + 0.0); + planePlots_[planeId].eventFlagsPl->Fill(t2TE + 0.0); + channelPlots_[detid].eventFlagsCh->Fill(t2TE + 0.0); + } + + if (digi.hasLE()) { + sectorPlots_[secId].eventFlags->Fill(t2LE + 0.0); + planePlots_[planeId].eventFlagsPl->Fill(t2LE + 0.0); + channelPlots_[detid].eventFlagsCh->Fill(t2LE + 0.0); + } + + if (digi.hasManyTE()) { + sectorPlots_[secId].eventFlags->Fill(t2MT + 0.0); + planePlots_[planeId].eventFlagsPl->Fill(t2MT + 0.0); + channelPlots_[detid].eventFlagsCh->Fill(t2MT + 0.0); + } + + if (digi.hasManyLE()) { + sectorPlots_[secId].eventFlags->Fill(t2ML + 0.0); + planePlots_[planeId].eventFlagsPl->Fill(t2ML + 0.0); + channelPlots_[detid].eventFlagsCh->Fill(t2ML + 0.0); + } } DEFINE_FWK_MODULE(TotemT2DQMSource); diff --git a/DQM/CTPPS/python/ctppsDQM_cff.py b/DQM/CTPPS/python/ctppsDQM_cff.py index 58c83de4ba182..a3c1898a1f32c 100644 --- a/DQM/CTPPS/python/ctppsDQM_cff.py +++ b/DQM/CTPPS/python/ctppsDQM_cff.py @@ -11,6 +11,8 @@ from DQM.CTPPS.totemTimingDQMSource_cfi import * +from DQM.CTPPS.totemT2DQMSource_cfi import * + from DQM.CTPPS.ctppsPixelDQMSource_cfi import * from DQM.CTPPS.elasticPlotDQMSource_cfi import * @@ -42,6 +44,7 @@ + diamondSampicDQMSourceOnline + ctppsCommonDQMSourceOnline + elasticPlotDQMSource + + totemT2DQMSource ) _ctppsDQMCalibrationHarvest = cms.Sequence( diff --git a/DQM/CTPPS/python/totemT2DQMSource_cfi.py b/DQM/CTPPS/python/totemT2DQMSource_cfi.py index 001b9c7d509bb..41e1a0c5d8278 100644 --- a/DQM/CTPPS/python/totemT2DQMSource_cfi.py +++ b/DQM/CTPPS/python/totemT2DQMSource_cfi.py @@ -3,10 +3,9 @@ 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(4), + windowsNum = cms.uint32(8), perLSsaving = cms.untracked.bool(False), #driven by DQMServices/Core/python/DQMStore_cfi.py ) diff --git a/DQM/CTPPS/test/totemt2_dqm_test_cfg.py b/DQM/CTPPS/test/totemt2_dqm_test_cfg.py index ac80aea04182a..dc08bf5c6d030 100644 --- a/DQM/CTPPS/test/totemt2_dqm_test_cfg.py +++ b/DQM/CTPPS/test/totemt2_dqm_test_cfg.py @@ -50,9 +50,9 @@ process.totemDAQMappingESSourceXML_TotemT2.verbosity = 0 process.totemT2Digis.RawUnpacking.verbosity = 0 process.totemT2Digis.RawToDigi.verbosity = 0 -process.totemT2Digis.RawToDigi.useOlderT2TestFile = cms.untracked.uint32(1) -process.totemT2Digis.RawToDigi.printUnknownFrameSummary = 0 -process.totemT2Digis.RawToDigi.printErrorSummary = 0 +process.totemT2Digis.RawToDigi.useOlderT2TestFile = True +process.totemT2Digis.RawToDigi.printUnknownFrameSummary = False +process.totemT2Digis.RawToDigi.printErrorSummary = False process.totemDAQMappingESSourceXML_TotemT2.multipleChannelsPerPayload = True process.path = cms.Path( diff --git a/DQM/CTPPS/test/totemt2_dqm_test_common_cfg.py b/DQM/CTPPS/test/totemt2_dqm_test_common_cfg.py new file mode 100644 index 0000000000000..20b6a4624250c --- /dev/null +++ b/DQM/CTPPS/test/totemt2_dqm_test_common_cfg.py @@ -0,0 +1,74 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Run3_cff import Run3 + +# needed to have ctppsDQMCalibrationSource properly working +from Configuration.Eras.Modifier_ctpps_cff import ctpps + +process = cms.Process('RECODQM', Run3) + +# minimum of logs +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cerr'), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +# load DQM framework +process.load("DQM.Integration.config.environment_cfi") +process.dqmEnv.subSystemFolder = "CTPPS" +process.dqmEnv.eventInfoFolder = "EventInfo" +process.dqmSaver.path = "" +process.dqmSaver.tag = "CTPPS" + +# raw data source, T2 + TrackingStrips either in run 368593 (correct) or 368594 (no) +process.source = cms.Source("NewEventStreamFileReader", + fileNames = cms.untracked.vstring( + '/store/t0streamer/Minidaq/A/000/368/593/run368593_ls0001_streamA_StorageManager.dat', +# '/store/t0streamer/Minidaq/A/000/368/594/run368594_ls0001_streamA_StorageManager.dat', + ) +) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(8000) +) + +# raw-to-digi conversion +process.load("EventFilter.CTPPSRawToDigi.ctppsRawToDigi_cff") + +# global tag - conditions for P5 cluster +#process.load("DQM.Integration.config.FrontierCondition_GT_cfi") + +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '130X_dataRun3_Prompt_Candidate_2023_06_06_21_34_08', '') + +# local RP reconstruction chain with standard settings +process.load("RecoPPS.Configuration.recoCTPPS_cff") + +# CTPPS DQM modules +process.load("DQM.CTPPS.ctppsDQM_cff") + +process.path = cms.Path( + process.ctppsRawToDigi * + process.recoCTPPS * + process.ctppsDQMCalibrationSource * + process.ctppsDQMCalibrationHarvest +) + +process.end_path = cms.EndPath( + process.dqmEnv + + process.dqmSaver +) + +process.schedule = cms.Schedule( + process.path, + process.end_path +) diff --git a/DQM/CTPPS/test/totemt2_dqm_test_nino_cfg.py b/DQM/CTPPS/test/totemt2_dqm_test_nino_cfg.py new file mode 100644 index 0000000000000..6a15df51bd877 --- /dev/null +++ b/DQM/CTPPS/test/totemt2_dqm_test_nino_cfg.py @@ -0,0 +1,76 @@ +import FWCore.ParameterSet.Config as cms +import string + +from Configuration.Eras.Era_Run3_cff import Run3 + +process = cms.Process('RECODQM', Run3) + +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(6000) ) +process.verbosity = cms.untracked.PSet( input = cms.untracked.int32(-1) ) + +# minimum of logs +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cerr'), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +# load DQM framework +process.load("DQM.Integration.config.environment_cfi") +process.dqmEnv.subSystemFolder = "CTPPS" +process.dqmEnv.eventInfoFolder = "EventInfo" +process.dqmSaver.path = "" +process.dqmSaver.tag = "CTPPS" +# raw data source +process.source = cms.Source("NewEventStreamFileReader", + fileNames = cms.untracked.vstring( +# '/store/t0streamer/Minidaq/A/000/368/023/run368023_ls0001_streamA_StorageManager.dat', + 'file:/eos/cms/store/t0streamer/Minidaq/A/000/368/080/run368080_ls0001_streamA_StorageManager.dat', + 'file:/eos/cms/store/t0streamer/Minidaq/A/000/368/080/run368080_ls0002_streamA_StorageManager.dat', +# '/store/t0streamer/Minidaq/A/000/368/081/run368081_ls0001_streamA_StorageManager.dat', +# '/store/t0streamer/Minidaq/A/000/368/081/run368081_ls0002_streamA_StorageManager.dat', +# '/store/t0streamer/Minidaq/A/000/368/082/run368082_ls0001_streamA_StorageManager.dat', +# '/store/t0streamer/Minidaq/A/000/368/082/run368082_ls0002_streamA_StorageManager.dat', +# '/store/group/dpg_ctpps/comm_ctpps/TotemT2/RecoTest/run364983_ls0001_streamA_StorageManager.dat', + ) +) + +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '130X_dataRun3_HLT_v2', '') + +#Raw-to-digi +process.load('EventFilter.CTPPSRawToDigi.ctppsRawToDigi_cff') + +# CTPPS DQM modules +process.load("DQM.CTPPS.ctppsDQM_cff") +process.totemDAQMappingESSourceXML_TotemT2.verbosity = 0 +process.totemT2Digis.RawUnpacking.verbosity = 0 +process.totemT2Digis.RawToDigi.verbosity = 0 +process.totemT2Digis.RawToDigi.testCRC = 1 +process.totemT2Digis.RawToDigi.useOlderT2TestFile = False +process.totemT2Digis.RawToDigi.printUnknownFrameSummary = True +process.totemT2Digis.RawToDigi.printErrorSummary = True + +process.path = cms.Path( + process.ctppsRawToDigi * + process.totemT2Digis * + process.totemT2DQMSource +) + +process.end_path = cms.EndPath( + process.dqmEnv + + process.dqmSaver +) + +process.schedule = cms.Schedule( + process.path, + process.end_path +) diff --git a/DataFormats/TotemReco/interface/TotemT2Digi.h b/DataFormats/TotemReco/interface/TotemT2Digi.h index 2a5450c08446a..23eeb788eee87 100644 --- a/DataFormats/TotemReco/interface/TotemT2Digi.h +++ b/DataFormats/TotemReco/interface/TotemT2Digi.h @@ -12,12 +12,13 @@ class TotemT2Digi { public: TotemT2Digi() = default; - TotemT2Digi(unsigned short id, unsigned char marker, unsigned short le, unsigned short te); + TotemT2Digi(unsigned short id, unsigned char marker, unsigned short le, unsigned short te, unsigned char status); void setLeadingEdge(unsigned short le) { lead_edge_ = le; } 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; } bool hasLE() const { return marker_ & 0x1; } bool hasTE() const { return marker_ & 0x2; } bool hasManyLE() const { return marker_ & 0x4; } @@ -32,6 +33,8 @@ class TotemT2Digi { unsigned short lead_edge_{0}; /// Trailing edge time unsigned short trail_edge_{0}; + /// Header status flags + unsigned char status_{0}; }; bool operator<(const TotemT2Digi& lhs, const TotemT2Digi& rhs); diff --git a/DataFormats/TotemReco/src/TotemT2Digi.cc b/DataFormats/TotemReco/src/TotemT2Digi.cc index 6d8e5cffd2efd..47ffd2076e42c 100644 --- a/DataFormats/TotemReco/src/TotemT2Digi.cc +++ b/DataFormats/TotemReco/src/TotemT2Digi.cc @@ -1,7 +1,8 @@ #include "DataFormats/TotemReco/interface/TotemT2Digi.h" -TotemT2Digi::TotemT2Digi(unsigned short id, unsigned char marker, unsigned short le, unsigned short te) - : id_(id), marker_(marker), lead_edge_(le), trail_edge_(te) {} +TotemT2Digi::TotemT2Digi( + unsigned short id, unsigned char marker, unsigned short le, unsigned short te, unsigned char status) + : id_(id), marker_(marker), lead_edge_(le), trail_edge_(te), status_(status) {} bool operator<(const TotemT2Digi& lhs, const TotemT2Digi& rhs) { if (lhs.leadingEdge() < rhs.leadingEdge()) diff --git a/DataFormats/TotemReco/src/classes_def.xml b/DataFormats/TotemReco/src/classes_def.xml index 7df18e6c92ba4..2f35479c49d5f 100644 --- a/DataFormats/TotemReco/src/classes_def.xml +++ b/DataFormats/TotemReco/src/classes_def.xml @@ -1,5 +1,6 @@ - + + diff --git a/EventFilter/CTPPSRawToDigi/interface/RawToDigiConverter.h b/EventFilter/CTPPSRawToDigi/interface/RawToDigiConverter.h index c1c8f3c1d5b0b..6738ac3f98d35 100644 --- a/EventFilter/CTPPSRawToDigi/interface/RawToDigiConverter.h +++ b/EventFilter/CTPPSRawToDigi/interface/RawToDigiConverter.h @@ -69,29 +69,28 @@ class RawToDigiConverter { TotemVFATStatus status; }; - unsigned char verbosity; + const unsigned char verbosity; - unsigned int olderTotemT2FileTest; //Test file with T2 frame ver 2.1 - - unsigned int printErrorSummary; - unsigned int printUnknownFrameSummary; + const bool printErrorSummary; + const bool printUnknownFrameSummary; enum TestFlag { tfNoTest, tfWarn, tfErr }; /// flags for which tests to run - unsigned int testFootprint; - unsigned int testCRC; - unsigned int testID; - unsigned int testECRaw; - unsigned int testECDAQ; - unsigned int testECMostFrequent; - unsigned int testBCMostFrequent; + const unsigned int testFootprint; + const unsigned int testCRC; + const unsigned int testID; + const unsigned int testECMostFrequent; + const unsigned int testBCMostFrequent; /// the minimal required number of frames to determine the most frequent counter value - unsigned int EC_min, BC_min; + const unsigned int EC_min, BC_min; /// the minimal required (relative) occupancy of the most frequent counter value to be accepted - double EC_fraction, BC_fraction; + const double EC_fraction, BC_fraction; + + //Test file with two 8-bit hwID fields + const bool olderTotemT2FileTest; /// error summaries std::map > errorSummary; diff --git a/EventFilter/CTPPSRawToDigi/interface/TotemT2VFATFrame.h b/EventFilter/CTPPSRawToDigi/interface/TotemT2VFATFrame.h index 84fa5ca984be8..77ef26aebaf18 100644 --- a/EventFilter/CTPPSRawToDigi/interface/TotemT2VFATFrame.h +++ b/EventFilter/CTPPSRawToDigi/interface/TotemT2VFATFrame.h @@ -36,6 +36,9 @@ namespace totem::nt2::vfat { return frame.getData()[header_offset + 1 + num_words_per_channel * ch_id] & 0x1f; } + /// retrieve the header status flags + inline uint8_t statusMarker(const VFATFrame& frame) { return (frame.getData()[header_offset - 1] >> 8) & 0xf; } + /// retrieve the HW identifier for this channel, in firmware >2.1 inline uint16_t newChannelId(const VFATFrame& frame, size_t ch_id) { return frame.getData()[header_offset + 0 + num_words_per_channel * ch_id] & 0xffff; diff --git a/EventFilter/CTPPSRawToDigi/interface/VFATFrame.h b/EventFilter/CTPPSRawToDigi/interface/VFATFrame.h index 96decce9d1bf6..b17b256efd275 100644 --- a/EventFilter/CTPPSRawToDigi/interface/VFATFrame.h +++ b/EventFilter/CTPPSRawToDigi/interface/VFATFrame.h @@ -54,6 +54,9 @@ class VFATFrame { /// Returns the CRC. VFATFrame::word getCRC() const { return data[0]; } + /// Returns the CRC, for non-reversed TOTEM T2. + VFATFrame::word getCRCT2() const { return data[11]; } + /// Sets presence flags. void setPresenceFlags(uint8_t v) { presenceFlags = v; } @@ -85,11 +88,19 @@ class VFATFrame { /// Returns false if any of the groups (in BC, EC and ID words) is present but wrong. bool checkFootprint() const; + /// Checks the fixed bits in the frame, for the TOTEM T2 non-inverse word ordering. + /// Returns false if any of the groups (in BC, EC and ID words) is present but wrong. + bool checkFootprintT2() const; + /// Checks the validity of frame (CRC and daqErrorFlags). /// Returns false if daqErrorFlags is non-zero. /// Returns false if the CRC is present and invalid. virtual bool checkCRC() const; + /// Checks the validity of Totem T2 non-reversed CRC. + /// Returns false if the CRC is present and invalid. + virtual bool checkCRCT2() const; + /// Checks if channel number 'channel' was active. /// Returns positive number if it was active, 0 otherwise. virtual bool channelActive(unsigned char channel) const { diff --git a/EventFilter/CTPPSRawToDigi/plugins/TotemVFATRawToDigi.cc b/EventFilter/CTPPSRawToDigi/plugins/TotemVFATRawToDigi.cc index 951395833e8a1..8ceb238e8a5e5 100644 --- a/EventFilter/CTPPSRawToDigi/plugins/TotemVFATRawToDigi.cc +++ b/EventFilter/CTPPSRawToDigi/plugins/TotemVFATRawToDigi.cc @@ -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 class TotemVFATRawToDigi : public edm::stream::EDProducer<> { @@ -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; @@ -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("rawDataTag", edm::InputTag("")); + desc.add("subSystem", "")->setComment("options: RP"); + desc.add>("fedIds", {}) + ->setComment( + "IMPORTANT: leave empty to load the default configuration from " + "DataFormats/FEDRawData/interface/FEDNumbering.h"); + { + edm::ParameterSetDescription psd0; + psd0.addUntracked("verbosity", 0); + desc.add("RawUnpacking", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.addUntracked("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("testFootprint", 2)->setComment("0=no test, 1=warn only, 2=warn and skip"); + psd0.add("testCRC", 2); + psd0.add("testID", 2)->setComment("compare the ID from data and mapping"); + psd0.add("testECMostFrequent", 2) + ->setComment("compare frame EC with the most frequent value in the event"); + psd0.add("testBCMostFrequent", 2); + psd0.addUntracked("EC_min", 10) + ->setComment("minimal number of frames to search for the most frequent counter value"); + psd0.addUntracked("BC_min", 10); + psd0.addUntracked("EC_fraction", 0.6) + ->setComment( + "the most frequent counter value is accepted provided its relative occupancy is higher than this fraction"); + psd0.addUntracked("BC_fraction", 0.6); + psd0.add("useOlderT2TestFile", false) + ->setComment("treat hwID field as two separate 8-bit fields instead of one 16-bit"); + psd0.addUntracked("printErrorSummary", false)->setComment("per-VFAT error summary at the end of the job"); + psd0.addUntracked("printUnknownFrameSummary", false) + ->setComment("summary of frames found in data, but not in the mapping"); + desc.add("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); diff --git a/EventFilter/CTPPSRawToDigi/python/ctppsRawToDigi_cff.py b/EventFilter/CTPPSRawToDigi/python/ctppsRawToDigi_cff.py index 1e5b35027f1ed..2cf2c8c9d36b2 100644 --- a/EventFilter/CTPPSRawToDigi/python/ctppsRawToDigi_cff.py +++ b/EventFilter/CTPPSRawToDigi/python/ctppsRawToDigi_cff.py @@ -52,8 +52,8 @@ # various error/warning/info output may be enabled with these flags # totemRPRawToDigi.RawUnpacking.verbosity = 1 # totemRPRawToDigi.RawToDigi.verbosity = 1 # or higher number for more output -# totemRPRawToDigi.RawToDigi.printErrorSummary = 1 -# totemRPRawToDigi.RawToDigi.printUnknownFrameSummary = 1 +# totemRPRawToDigi.RawToDigi.printErrorSummary = True +# totemRPRawToDigi.RawToDigi.printUnknownFrameSummary = True # ---------- diamonds ---------- totemDAQMappingESSourceXML_TimingDiamond = cms.ESSource("TotemDAQMappingESSourceXML", @@ -102,7 +102,7 @@ ) from EventFilter.CTPPSRawToDigi.ctppsDiamondRawToDigi_cfi import ctppsDiamondRawToDigi -ctppsDiamondRawToDigi.rawDataTag = cms.InputTag("rawDataCollector") +ctppsDiamondRawToDigi.rawDataTag = "rawDataCollector" # ---------- Totem Timing ---------- totemDAQMappingESSourceXML_TotemTiming = cms.ESSource("TotemDAQMappingESSourceXML", @@ -132,16 +132,16 @@ ) from EventFilter.CTPPSRawToDigi.totemTimingRawToDigi_cfi import totemTimingRawToDigi -totemTimingRawToDigi.rawDataTag = cms.InputTag("rawDataCollector") +totemTimingRawToDigi.rawDataTag = "rawDataCollector" # ---------- Totem nT2 ---------- from CalibPPS.ESProducers.totemT2DAQMapping_cff import totemDAQMappingESSourceXML as totemDAQMappingESSourceXML_TotemT2 from EventFilter.CTPPSRawToDigi.totemT2Digis_cfi import totemT2Digis -totemT2Digis.rawDataTag = cms.InputTag("rawDataCollector") +totemT2Digis.rawDataTag = "rawDataCollector" # ---------- pixels ---------- from EventFilter.CTPPSRawToDigi.ctppsPixelDigis_cfi import ctppsPixelDigis -ctppsPixelDigis.inputLabel = cms.InputTag("rawDataCollector") +ctppsPixelDigis.inputLabel = "rawDataCollector" from Configuration.Eras.Modifier_ctpps_2016_cff import ctpps_2016 from Configuration.Eras.Modifier_ctpps_2017_cff import ctpps_2017 diff --git a/EventFilter/CTPPSRawToDigi/python/totemT2Digis_cfi.py b/EventFilter/CTPPSRawToDigi/python/totemT2Digis_cfi.py index 58a085d5964b0..2ca895ad79791 100644 --- a/EventFilter/CTPPSRawToDigi/python/totemT2Digis_cfi.py +++ b/EventFilter/CTPPSRawToDigi/python/totemT2Digis_cfi.py @@ -3,10 +3,12 @@ from EventFilter.CTPPSRawToDigi.totemVFATRawToDigi_cfi import totemVFATRawToDigi totemT2Digis = totemVFATRawToDigi.clone( - subSystem = cms.string('TotemT2'), + subSystem = 'TotemT2', RawToDigi = totemVFATRawToDigi.RawToDigi.clone( - testID = cms.uint32(0), #Some ID mismatch in test sample - testCRC = cms.uint32(0), # no need to test CRC for diamond frames - testECMostFrequent = cms.uint32(0) # show error in the DQM and then DAQ is sending resync, no need to test in the unpacker + testID = 0, #Some ID mismatch in test sample + testCRC = 0, # no need to test CRC for diamond frames + testECMostFrequent = 0, # show error in the DQM and then DAQ is sending resync, no need to test in the unpacker + testBCMostFrequent = 0, # no need to test in the unpacker, footprint test is enough + useOlderT2TestFile = False # March '23 version with two 8-bit ID fields ) ) diff --git a/EventFilter/CTPPSRawToDigi/python/totemTimingRawToDigi_cfi.py b/EventFilter/CTPPSRawToDigi/python/totemTimingRawToDigi_cfi.py index 86a1457ad6fc0..6a08f1a3f7293 100644 --- a/EventFilter/CTPPSRawToDigi/python/totemTimingRawToDigi_cfi.py +++ b/EventFilter/CTPPSRawToDigi/python/totemTimingRawToDigi_cfi.py @@ -9,24 +9,27 @@ totemTimingRawToDigi = totemVFATRawToDigi.clone( subSystem = 'TotemTiming', - fedIds = cms.vuint32(586, 587), #as declared in DataFormats/FEDRawData/interface/FEDNumbering.h + fedIds = [586, 587], #as declared in DataFormats/FEDRawData/interface/FEDNumbering.h - RawToDigi = cms.PSet( - verbosity = cms.untracked.uint32(0), + RawToDigi = dict( + verbosity = 0, - # disable all the checks - testFootprint = cms.uint32(0), - testCRC = cms.uint32(0), - testID = cms.uint32(0), # compare the ID from data and mapping - testECMostFrequent = cms.uint32(0), # compare frame's EC with the most frequent value in the event - testBCMostFrequent = cms.uint32(0), # compare frame's BC with the most frequent value in the event - - # if non-zero, prints a per-VFAT error summary at the end of the job - printErrorSummary = cms.untracked.uint32(0), + # disable all the checks + testFootprint = 0, + testCRC = 0, + testID = 0, # compare the ID from data and mapping + testECMostFrequent = 0, # compare frame's EC with the most frequent value in the event + testBCMostFrequent = 0, # compare frame's BC with the most frequent value in the event + + # tracked parameter for Totem T2 + useOlderT2TestFile = False, + + # if true, prints a per-VFAT error summary at the end of the job + printErrorSummary = False, - # if non-zero, prints a summary of frames found in data, but not in the mapping - printUnknownFrameSummary = cms.untracked.uint32(0) - ) + # if true, prints a summary of frames found in data, but not in the mapping + printUnknownFrameSummary = False + ) ) # for Run 2 backward compatibility diff --git a/EventFilter/CTPPSRawToDigi/python/totemVFATRawToDigi_cfi.py b/EventFilter/CTPPSRawToDigi/python/totemVFATRawToDigi_cfi.py deleted file mode 100644 index c9f7ab11433f8..0000000000000 --- a/EventFilter/CTPPSRawToDigi/python/totemVFATRawToDigi_cfi.py +++ /dev/null @@ -1,48 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -totemVFATRawToDigi = cms.EDProducer("TotemVFATRawToDigi", - rawDataTag = cms.InputTag(""), - - # options: "RP" - subSystem = cms.string(""), - - # IMPORTANT: leave empty to load the default configuration from - # DataFormats/FEDRawData/interface/FEDNumbering.h - fedIds = cms.vuint32(), - - RawUnpacking = cms.PSet( - verbosity = cms.untracked.uint32(0), - ), - - RawToDigi = cms.PSet( - # 0: no error output - # 1: one-line message for every event with at least one corrupted VFAT frame - # 2: lists all corrupted VFATs in all events - # 3: lists all corruptions for all corrupted VFATs in all events - verbosity = cms.untracked.uint32(0), - - # flags for available consistency tests - # 0: do not perform the test at all - # 1: print an error message, but keep the frame - # 2: print an error message and do not process the frame - testFootprint = cms.uint32(2), - testCRC = cms.uint32(2), - testID = cms.uint32(2), # compare the ID from data and mapping - testECMostFrequent = cms.uint32(2), # compare frame's EC with the most frequent value in the event - testBCMostFrequent = cms.uint32(2), # compare frame's BC with the most frequent value in the event - - # the minimal number of frames to search for the most frequent counter value - EC_min = cms.untracked.uint32(10), - BC_min = cms.untracked.uint32(10), - - # the most frequent counter value is accepted provided its relative occupancy is higher than this fraction - EC_fraction = cms.untracked.double(0.6), - BC_fraction = cms.untracked.double(0.6), - - # if non-zero, prints a per-VFAT error summary at the end of the job - printErrorSummary = cms.untracked.uint32(0), - - # if non-zero, prints a summary of frames found in data, but not in the mapping - printUnknownFrameSummary = cms.untracked.uint32(0), - ) -) diff --git a/EventFilter/CTPPSRawToDigi/src/RawDataUnpacker.cc b/EventFilter/CTPPSRawToDigi/src/RawDataUnpacker.cc index 12b2c794b6fc4..f8ba166409d0b 100644 --- a/EventFilter/CTPPSRawToDigi/src/RawDataUnpacker.cc +++ b/EventFilter/CTPPSRawToDigi/src/RawDataUnpacker.cc @@ -459,6 +459,7 @@ int RawDataUnpacker::processOptoRxFrameSampic(const word *buf, // save frame to output frame.setPresenceFlags(1); if ((optoRxId >= FEDNumbering::MINTotemT2FEDID && optoRxId <= FEDNumbering::MAXTotemT2FEDID)) { + frame.setPresenceFlags(15); // check three VFAT signature digits, CRC present if (verbosity > 0) edm::LogWarning("Totem") << "T2 Frame Positions created: " << fp2a << "/" << fp2b << std::endl; diff --git a/EventFilter/CTPPSRawToDigi/src/RawToDigiConverter.cc b/EventFilter/CTPPSRawToDigi/src/RawToDigiConverter.cc index 4ed3dba9bb1e6..b5baf2c0230ce 100644 --- a/EventFilter/CTPPSRawToDigi/src/RawToDigiConverter.cc +++ b/EventFilter/CTPPSRawToDigi/src/RawToDigiConverter.cc @@ -25,9 +25,8 @@ using namespace edm; RawToDigiConverter::RawToDigiConverter(const edm::ParameterSet &conf) : verbosity(conf.getUntrackedParameter("verbosity", 0)), - olderTotemT2FileTest(conf.getUntrackedParameter("useOlderT2TestFile", 0)), - printErrorSummary(conf.getUntrackedParameter("printErrorSummary", 1)), - printUnknownFrameSummary(conf.getUntrackedParameter("printUnknownFrameSummary", 1)), + printErrorSummary(conf.getUntrackedParameter("printErrorSummary")), + printUnknownFrameSummary(conf.getUntrackedParameter("printUnknownFrameSummary")), testFootprint(conf.getParameter("testFootprint")), testCRC(conf.getParameter("testCRC")), @@ -39,7 +38,9 @@ RawToDigiConverter::RawToDigiConverter(const edm::ParameterSet &conf) BC_min(conf.getUntrackedParameter("BC_min", 10)), EC_fraction(conf.getUntrackedParameter("EC_fraction", 0.6)), - BC_fraction(conf.getUntrackedParameter("BC_fraction", 0.6)) {} + BC_fraction(conf.getUntrackedParameter("BC_fraction", 0.6)), + + olderTotemT2FileTest(conf.getParameter("useOlderT2TestFile")) {} void RawToDigiConverter::runCommon(const VFATFrameCollection &input, const TotemDAQMapping &mapping, @@ -80,8 +81,13 @@ void RawToDigiConverter::runCommon(const VFATFrameCollection &input, record.status.setNumberOfClustersSpecified(record.frame->isNumberOfClustersPresent()); record.status.setNumberOfClusters(record.frame->getNumberOfClusters()); + // check for T2 payload bits + int rawT2 = fr.Position().getRawPosition(); + bool isT2Frame = (rawT2 >> 18); + // check footprint - if (testFootprint != tfNoTest && !record.frame->checkFootprint()) { + if (((!isT2Frame) && testFootprint != tfNoTest && !record.frame->checkFootprint()) || + (isT2Frame && testFootprint != tfNoTest && !record.frame->checkFootprintT2())) { problemsPresent = true; if (verbosity > 0) @@ -94,7 +100,8 @@ void RawToDigiConverter::runCommon(const VFATFrameCollection &input, } // check CRC - if (testCRC != tfNoTest && !record.frame->checkCRC()) { + if (((!isT2Frame) && (testCRC != tfNoTest && !record.frame->checkCRC())) || + (isT2Frame && testCRC != tfNoTest && !record.frame->checkCRCT2())) { problemsPresent = true; if (verbosity > 0) @@ -123,6 +130,8 @@ void RawToDigiConverter::runCommon(const VFATFrameCollection &input, if (verbosity > 0 && problemsPresent) { string message = (stopProcessing) ? "(and will be dropped)" : "(but will be used though)"; if (verbosity > 2) { + if (isT2Frame && verbosity > 3) + record.frame->PrintT2(); ees << " Frame at " << fr.Position() << " seems corrupted " << message << ":" << endl; ees << fes.rdbuf(); } else @@ -395,8 +404,7 @@ void RawToDigiConverter::run(const VFATFrameCollection &coll, int allT2 = 0; int goodT2 = 0; int foundT2 = 0; - const int T2shiftOld = - (olderTotemT2FileTest > 0 ? 8 : 0); //Run on TOTEM T2 test file (ver 2.1) or final T2 data ver 2.2 + const int T2shiftOld = (olderTotemT2FileTest ? 8 : 0); //Run on TOTEM T2 test file (ver 2.1) or final T2 data ver 2.3 // second loop over data for (auto &p : records) { @@ -431,7 +439,8 @@ void RawToDigiConverter::run(const VFATFrameCollection &coll, .emplace_back(hw_id, totem::nt2::vfat::channelMarker(*record.frame, frame_id), totem::nt2::vfat::leadingEdgeTime(*record.frame, frame_id), - totem::nt2::vfat::trailingEdgeTime(*record.frame, frame_id)); + totem::nt2::vfat::trailingEdgeTime(*record.frame, frame_id), + totem::nt2::vfat::statusMarker(*record.frame)); foundT2++; } else { if (verbosity > 2) diff --git a/EventFilter/CTPPSRawToDigi/src/VFATFrame.cc b/EventFilter/CTPPSRawToDigi/src/VFATFrame.cc index 36fbf224cbf01..fbff151ddc2cb 100644 --- a/EventFilter/CTPPSRawToDigi/src/VFATFrame.cc +++ b/EventFilter/CTPPSRawToDigi/src/VFATFrame.cc @@ -59,6 +59,19 @@ bool VFATFrame::checkFootprint() const { return true; } +bool VFATFrame::checkFootprintT2() const { + if (isIDPresent() && (data[2] & 0xF000) != 0xE000) + return false; + + if (isECPresent() && (data[1] & 0xF000) != 0xC000) + return false; + + if (isBCPresent() && (data[0] & 0xF000) != 0xA000) + return false; + + return true; +} + bool VFATFrame::checkCRC() const { // check DAQ error flags if (daqErrorFlags != 0) @@ -77,6 +90,20 @@ bool VFATFrame::checkCRC() const { return (crc_fin == data[0]); } +bool VFATFrame::checkCRCT2() const { + // return true if CRC not present + if (!isCRCPresent()) + return true; + + // compare CRC + word crc_fin = 0xffff; + + for (int i = 0; i < 11; i++) + crc_fin = calculateCRC(crc_fin, data[i]); + + return (crc_fin == data[11]); +} + VFATFrame::word VFATFrame::calculateCRC(VFATFrame::word crc_in, VFATFrame::word dato) { word v = 0x0001; word mask = 0x0001; @@ -164,6 +191,24 @@ void VFATFrame::PrintT2(bool binary) const { printf("\n"); } } else { + // print right CRC + word crc_fin = 0xffff; + + for (int i = 0; i < 11; i++) + crc_fin = calculateCRC(crc_fin, data[i]); + + printf("CRC = %04x ", getCRCT2()); + + if (checkCRCT2()) + printf("( OK), footprint "); + else + printf("(FAIL, right = %04x), footprint ", crc_fin); + + if (checkFootprintT2()) + printf(" OK"); + else + printf("FAIL"); + printf("Frame = %04x|%04x|%04x|", data[0], data[1], data[2]); for (int i = 3; i < 11; i++) printf("%04x", data[i]); diff --git a/RecoPPS/Configuration/python/RecoCTPPS_EventContent_cff.py b/RecoPPS/Configuration/python/RecoCTPPS_EventContent_cff.py index 309437919c3ae..5f2566403d039 100644 --- a/RecoPPS/Configuration/python/RecoCTPPS_EventContent_cff.py +++ b/RecoPPS/Configuration/python/RecoCTPPS_EventContent_cff.py @@ -14,6 +14,12 @@ 'keep TotemRPUVPatternedmDetSetVector_totemRPUVPatternFinder_*_*', 'keep TotemRPLocalTrackedmDetSetVector_totemRPLocalTrackFitter_*_*', + # totem T2 + 'keep TotemFEDInfos_totemT2Digis_*_*', + 'keep TotemT2DigiedmNewDetSetVector_totemT2Digis_*_*', + 'keep TotemVFATStatusedmDetSetVector_totemT2Digis_*_*', + 'keep TotemT2RecHitedmNewDetSetVector_totemT2RecHits_*_*', + # timing diamonds 'keep TotemFEDInfos_ctppsDiamondRawToDigi_*_*', 'keep CTPPSDiamondDigiedmDetSetVector_ctppsDiamondRawToDigi_*_*', diff --git a/RecoPPS/Configuration/python/recoCTPPS_cff.py b/RecoPPS/Configuration/python/recoCTPPS_cff.py index 1f036f35c1e38..c0afd90c53bc1 100644 --- a/RecoPPS/Configuration/python/recoCTPPS_cff.py +++ b/RecoPPS/Configuration/python/recoCTPPS_cff.py @@ -3,6 +3,7 @@ from RecoPPS.Local.totemRPLocalReconstruction_cff import * from RecoPPS.Local.ctppsDiamondLocalReconstruction_cff import * from RecoPPS.Local.totemTimingLocalReconstruction_cff import * +from RecoPPS.Local.totemT2LocalReconstruction_cff import * from RecoPPS.Local.ctppsPixelLocalReconstruction_cff import * from RecoPPS.Local.ctppsLocalTrackLiteProducer_cff import ctppsLocalTrackLiteProducer @@ -16,6 +17,7 @@ totemRPLocalReconstructionTask , ctppsDiamondLocalReconstructionTask , diamondSampicLocalReconstructionTask , + totemT2LocalReconstructionTask , ctppsPixelLocalReconstructionTask , ctppsLocalTrackLiteProducer , ctppsProtons diff --git a/RecoPPS/Local/python/totemT2LocalReconstruction_cff.py b/RecoPPS/Local/python/totemT2LocalReconstruction_cff.py new file mode 100644 index 0000000000000..ceebb2d5d2f09 --- /dev/null +++ b/RecoPPS/Local/python/totemT2LocalReconstruction_cff.py @@ -0,0 +1,13 @@ +import FWCore.ParameterSet.Config as cms + +# reco hit production +from RecoPPS.Local.totemT2RecHits_cfi import * + +# T2 geometry seems not to be uploaded to CondDB, here we load XML version, which produces `TotemGeometryRcd`, consumed only by T2 code. +from Geometry.ForwardCommonData.totemT22021V2XML_cfi import * +from Geometry.ForwardGeometry.totemGeometryESModule_cfi import * + +totemT2LocalReconstructionTask = cms.Task( + totemT2RecHits +) +totemT2LocalReconstruction = cms.Sequence(totemT2LocalReconstructionTask) diff --git a/RecoPPS/Local/test/totemT2NewDigi_reco_cfg.py b/RecoPPS/Local/test/totemT2NewDigi_reco_cfg.py index 84de085f5cb5f..853f2f78c1455 100644 --- a/RecoPPS/Local/test/totemT2NewDigi_reco_cfg.py +++ b/RecoPPS/Local/test/totemT2NewDigi_reco_cfg.py @@ -32,21 +32,21 @@ process.load('CalibPPS.ESProducers.totemT2DAQMapping_cff') process.load('EventFilter.CTPPSRawToDigi.totemT2Digis_cfi') process.totemT2Digis.rawDataTag = cms.InputTag("rawDataCollector") -process.totemDAQMappingESSourceXML.verbosity = cms.untracked.uint32(1) -process.totemT2Digis.RawUnpacking.verbosity = cms.untracked.uint32(1) -process.totemT2Digis.RawToDigi.verbosity = cms.untracked.uint32(3) -process.totemT2Digis.RawToDigi.useOlderT2TestFile = cms.untracked.uint32(1) -process.totemT2Digis.RawToDigi.printUnknownFrameSummary = cms.untracked.uint32(3) -process.totemT2Digis.RawToDigi.printErrorSummary = cms.untracked.uint32(3) -process.totemDAQMappingESSourceXML.multipleChannelsPerPayload = cms.untracked.bool(True) +process.totemDAQMappingESSourceXML.verbosity = 1 +process.totemT2Digis.RawUnpacking.verbosity = 1 +process.totemT2Digis.RawToDigi.verbosity = 3 +process.totemT2Digis.RawToDigi.useOlderT2TestFile = True +process.totemT2Digis.RawToDigi.printUnknownFrameSummary = True +process.totemT2Digis.RawToDigi.printErrorSummary = True +process.totemDAQMappingESSourceXML.multipleChannelsPerPayload = True # rechits production -process.load('Geometry.ForwardCommonData.totemT22021V2XML_cfi') -process.load('Geometry.ForwardGeometry.totemGeometryESModule_cfi') -process.load('RecoPPS.Local.totemT2RecHits_cfi') +#process.load('Geometry.ForwardCommonData.totemT22021V2XML_cfi') +#process.load('Geometry.ForwardGeometry.totemGeometryESModule_cfi') +#process.load('RecoPPS.Local.totemT2RecHits_cfi') process.output = cms.OutputModule("PoolOutputModule", - fileName = cms.untracked.string("file:output-miniDaq2303-T2testFile-ver2.1--1ev.root"), + fileName = cms.untracked.string("file:output-miniDaq2303-T2testFile-ver2.1-noRecHits--1ev.root"), outputCommands = cms.untracked.vstring( 'drop *', 'keep *_totemT2*_*_*', @@ -56,7 +56,7 @@ # execution configuration process.p = cms.Path( process.totemT2Digis - * process.totemT2RecHits +# * process.totemT2RecHits ) process.outpath = cms.EndPath(process.output) diff --git a/RecoPPS/Local/test/totemT2_geom_rechits_cfg.py b/RecoPPS/Local/test/totemT2_geom_rechits_cfg.py new file mode 100644 index 0000000000000..d424b06c7365d --- /dev/null +++ b/RecoPPS/Local/test/totemT2_geom_rechits_cfg.py @@ -0,0 +1,79 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Run3_cff import Run3 + +# needed to have ctppsDQMCalibrationSource properly working +#from Configuration.Eras.Modifier_ctpps_cff import ctpps + +process = cms.Process('RECO', Run3) + +# minimum of logs +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cerr'), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +# load DQM framework +#process.load("DQM.Integration.config.environment_cfi") +#process.dqmEnv.subSystemFolder = "CTPPS" +#process.dqmEnv.eventInfoFolder = "EventInfo" +#process.dqmSaver.path = "" +#process.dqmSaver.tag = "CTPPS" + +# raw data source, T2 + TrackingStrips either in run 368593 (correct) or 368594 (no) +process.source = cms.Source("NewEventStreamFileReader", + fileNames = cms.untracked.vstring( + '/store/t0streamer/Minidaq/A/000/368/593/run368593_ls0001_streamA_StorageManager.dat', +# '/store/t0streamer/Minidaq/A/000/368/594/run368594_ls0001_streamA_StorageManager.dat', + ) +) +# raw data source +#alignment run without T2, TimingDiamond and TrackingStrip not affected by PR changes + + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1000) +) + +# raw-to-digi conversion +process.load("EventFilter.CTPPSRawToDigi.ctppsRawToDigi_cff") + +# global tag - conditions for P5 cluster +#process.load("DQM.Integration.config.FrontierCondition_GT_cfi") + +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '130X_dataRun3_Prompt_Candidate_2023_06_06_21_34_08', '') + +# local RP reconstruction chain with standard settings +process.load("RecoPPS.Configuration.recoCTPPS_cff") + +# CTPPS DQM modules +#process.load("DQM.CTPPS.ctppsDQM_cff") + +process.path = cms.Path( + process.ctppsRawToDigi * + process.recoCTPPS +) + +process.output = cms.OutputModule("PoolOutputModule", + fileName = cms.untracked.string("file:output-commonReco-368593-newPCGT-1000ev.root"), + outputCommands = cms.untracked.vstring( + 'keep *', + ), +) + +process.outpath = cms.EndPath(process.output) + +process.schedule = cms.Schedule( + process.path, + process.outpath +)