CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Attributes
RPCTwinMuxDigiToRaw Class Reference

#include <RPCTwinMuxDigiToRaw.h>

Inheritance diagram for RPCTwinMuxDigiToRaw:
edm::stream::EDProducer<>

Public Member Functions

void beginRun (edm::Run const &run, edm::EventSetup const &setup) override
 
void produce (edm::Event &event, edm::EventSetup const &setup) override
 
 RPCTwinMuxDigiToRaw (edm::ParameterSet const &config)
 
 ~RPCTwinMuxDigiToRaw () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descs)
 

Protected Attributes

int bx_max_
 
int bx_min_
 
edm::EDGetTokenT< RPCDigiCollectiondigi_token_
 
edm::ESGetToken< RPCInverseLBLinkMap, RPCInverseLBLinkMapRcdes_lb_link_map_token_
 
edm::ESGetToken< RPCAMCLinkMap, RPCTwinMuxLinkMapRcdes_tm_link_map_br_token_
 
edm::ESGetToken< RPCInverseAMCLinkMap, RPCInverseTwinMuxLinkMapRcdes_tm_link_map_token_
 
edm::ESWatcher< RPCTwinMuxLinkMapRcdes_tm_link_map_watcher_
 
int event_type_
 
std::map< int, std::vector< RPCAMCLink > > fed_amcs_
 
bool ignore_eod_
 
unsigned int ufov_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 29 of file RPCTwinMuxDigiToRaw.h.

Constructor & Destructor Documentation

◆ RPCTwinMuxDigiToRaw()

RPCTwinMuxDigiToRaw::RPCTwinMuxDigiToRaw ( edm::ParameterSet const &  config)

Definition at line 26 of file RPCTwinMuxDigiToRaw.cc.

References digi_token_.

27  : es_tm_link_map_br_token_(esConsumes<RPCAMCLinkMap, RPCTwinMuxLinkMapRcd, edm::Transition::BeginRun>()),
28  es_tm_link_map_token_(esConsumes<RPCInverseAMCLinkMap, RPCInverseTwinMuxLinkMapRcd>()),
29  es_lb_link_map_token_(esConsumes<RPCInverseLBLinkMap, RPCInverseLBLinkMapRcd>()),
30  bx_min_(config.getParameter<int>("bxMin")),
31  bx_max_(config.getParameter<int>("bxMax")),
32  ignore_eod_(config.getParameter<bool>("ignoreEOD")),
33  event_type_(config.getParameter<int>("eventType")),
34  ufov_(config.getParameter<unsigned int>("uFOV")) {
35  produces<FEDRawDataCollection>();
36  digi_token_ = consumes<RPCDigiCollection>(config.getParameter<edm::InputTag>("inputTag"));
37 }
Definition: config.py:1
edm::ESGetToken< RPCAMCLinkMap, RPCTwinMuxLinkMapRcd > es_tm_link_map_br_token_
edm::ESGetToken< RPCInverseAMCLinkMap, RPCInverseTwinMuxLinkMapRcd > es_tm_link_map_token_
edm::ESGetToken< RPCInverseLBLinkMap, RPCInverseLBLinkMapRcd > es_lb_link_map_token_
edm::EDGetTokenT< RPCDigiCollection > digi_token_

◆ ~RPCTwinMuxDigiToRaw()

RPCTwinMuxDigiToRaw::~RPCTwinMuxDigiToRaw ( )
override

Definition at line 39 of file RPCTwinMuxDigiToRaw.cc.

39 {}

Member Function Documentation

◆ beginRun()

void RPCTwinMuxDigiToRaw::beginRun ( edm::Run const &  run,
edm::EventSetup const &  setup 
)
override

Definition at line 52 of file RPCTwinMuxDigiToRaw.cc.

References amc, edm::ESWatcher< T >::check(), es_tm_link_map_br_token_, es_tm_link_map_watcher_, fed_amcs_, RPCAMCLinkMap::getMap(), singleTopDQM_cfi::setup, jetUpdater_cfi::sort, and tier0::unique().

52  {
55  fed_amcs_.clear();
56  for (auto const& tm_link : es_tm_link_map->getMap()) {
57  RPCAMCLink amc(tm_link.first);
58  amc.setAMCInput();
59  fed_amcs_[amc.getFED()].push_back(amc);
60  }
61  for (auto& fed_amcs : fed_amcs_) {
62  std::sort(fed_amcs.second.begin(), fed_amcs.second.end());
63  fed_amcs.second.erase(std::unique(fed_amcs.second.begin(), fed_amcs.second.end()), fed_amcs.second.end());
64  }
65  }
66 }
edm::ESGetToken< RPCAMCLinkMap, RPCTwinMuxLinkMapRcd > es_tm_link_map_br_token_
double amc
Definition: hdecay.h:20
std::map< int, std::vector< RPCAMCLink > > fed_amcs_
def unique(seq, keepstr=True)
Definition: tier0.py:24
map_type & getMap()
Definition: RPCAMCLinkMap.h:27
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::ESWatcher< RPCTwinMuxLinkMapRcd > es_tm_link_map_watcher_
Definition: AMCSpec.h:8

◆ fillDescriptions()

void RPCTwinMuxDigiToRaw::fillDescriptions ( edm::ConfigurationDescriptions descs)
static

Definition at line 41 of file RPCTwinMuxDigiToRaw.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and HLT_2022v12_cff::InputTag.

41  {
43  desc.add<edm::InputTag>("inputTag", edm::InputTag("simMuonRPCDigis", ""));
44  desc.add<int>("bxMin", -2);
45  desc.add<int>("bxMax", 2);
46  desc.add<bool>("ignoreEOD", true);
47  desc.add<int>("eventType", 1);
48  desc.add<unsigned int>("uFOV", 1);
49  descs.add("RPCTwinMuxDigiToRaw", desc);
50 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void RPCTwinMuxDigiToRaw::produce ( edm::Event event,
edm::EventSetup const &  setup 
)
override

Definition at line 68 of file RPCTwinMuxDigiToRaw.cc.

References bx_max_, bx_min_, evf::compute_crc(), data, digi_token_, es_lb_link_map_token_, es_tm_link_map_token_, event_type_, fed_amcs_, EcalFEDMonitor_cfi::FEDRawDataCollection, RPCTwinMuxPacker::getRPCTwinMuxRecords(), ignore_eod_, eostools::move(), FEDHeader::set(), FEDTrailer::set(), rpctwinmux::TwinMuxHeader::setRPCBXWindow(), singleTopDQM_cfi::setup, findQualityFiles::size, ufov_, and trackerHitRTTI::vector.

68  {
69  // Get EventSetup Electronics Maps
72 
73  // Get Digi Collection
74  edm::Handle<RPCDigiCollection> digi_collection;
75  event.getByToken(digi_token_, digi_collection);
76 
77  // Create output
78  std::unique_ptr<FEDRawDataCollection> data_collection(new FEDRawDataCollection());
79 
80  std::map<RPCAMCLink, std::vector<std::pair<int, rpctwinmux::RPCRecord> > > amc_bx_tmrecord;
82  *es_tm_link_map_,
83  bx_min_,
84  bx_max_,
85  event.bunchCrossing(),
86  *digi_collection,
87  amc_bx_tmrecord,
88  ignore_eod_);
89 
90  std::map<int, FEDRawData> fed_data;
91  // Loop over the FEDs
92  for (std::pair<const int, std::vector<RPCAMCLink> > const& fed_amcs : fed_amcs_) {
93  FEDRawData& data = data_collection->FEDData(fed_amcs.first);
94  unsigned int size(0);
95 
96  // FED Header + BLOCK Header (1 word + 1 word)
97  data.resize((size + 2) * 8);
98  // FED Header
99  FEDHeader::set(data.data() + size * 8, event_type_, event.id().event(), event.bunchCrossing(), fed_amcs.first);
100  ++size;
101  // BLOCK Header
102  rpctwinmux::BlockHeader block_header(ufov_, fed_amcs.second.size(), event.eventAuxiliary().orbitNumber());
103  std::memcpy(data.data() + size * 8, &block_header.getRecord(), 8);
104  ++size;
105 
106  // BLOCK AMC Content - 1 word each
107  data.resize((size + fed_amcs.second.size()) * 8);
108  unsigned int block_content_size(0);
109  for (RPCAMCLink const& amc : fed_amcs.second) {
110  std::map<RPCAMCLink, std::vector<std::pair<int, rpctwinmux::RPCRecord> > >::const_iterator bx_tmrecord(
111  amc_bx_tmrecord.find(amc));
112  unsigned int block_amc_size(3 + 2 * (bx_tmrecord == amc_bx_tmrecord.end() ? 0 : bx_tmrecord->second.size()));
113  block_content_size += block_amc_size;
114  rpctwinmux::BlockAMCContent amc_content(
115  true, true, true, true, true, true, true, block_amc_size, 0, amc.getAMCNumber(), 0);
116  std::memcpy(data.data() + size * 8, &amc_content.getRecord(), 8);
117  ++size;
118  }
119 
120  // AMC Payload - 2 words header, 1 word trailer, 2 words per RPCRecord
121  data.resize((size + block_content_size) * 8);
122  for (RPCAMCLink const& amc : fed_amcs.second) {
123  // TwinMux Header
124  std::map<RPCAMCLink, std::vector<std::pair<int, rpctwinmux::RPCRecord> > >::const_iterator bx_tmrecord(
125  amc_bx_tmrecord.find(amc));
126  unsigned int block_amc_size(3 + 2 * (bx_tmrecord == amc_bx_tmrecord.end() ? 0 : bx_tmrecord->second.size()));
127 
128  rpctwinmux::TwinMuxHeader tm_header(amc.getAMCNumber(),
129  event.id().event(),
130  event.bunchCrossing(),
131  block_amc_size,
132  event.eventAuxiliary().orbitNumber(),
133  0);
134  tm_header.setRPCBXWindow(bx_min_, bx_min_);
135  std::memcpy(data.data() + size * 8, tm_header.getRecord(), 16);
136  size += 2;
137 
138  if (bx_tmrecord != amc_bx_tmrecord.end()) {
139  for (std::vector<std::pair<int, rpctwinmux::RPCRecord> >::const_iterator tmrecord = bx_tmrecord->second.begin();
140  tmrecord != bx_tmrecord->second.end();
141  ++tmrecord) {
142  std::memcpy(data.data() + size * 8, tmrecord->second.getRecord(), 16);
143  size += 2;
144  }
145  }
146 
147  rpctwinmux::TwinMuxTrailer tm_trailer(0x0, event.id().event(), 3 + 2 * block_amc_size);
148  std::memcpy(data.data() + size * 8, &tm_trailer.getRecord(), 8);
149  ++size;
150  // CRC32 not calculated (for now)
151  }
152 
153  // BLOCK Trailer + FED Trailer (1 word + 1 word)
154  data.resize((size + 2) * 8);
155  // BLOCK Trailer
156  rpctwinmux::BlockTrailer block_trailer(0x0, 0, event.id().event(), event.bunchCrossing());
157  std::memcpy(data.data() + size * 8, &block_trailer.getRecord(), 8);
158  ++size;
159  // CRC32 not calculated (for now)
160 
161  // FED Trailer
162  ++size;
163  FEDTrailer::set(data.data() + (size - 1) * 8, size, 0x0, 0, 0);
164  std::uint16_t crc(evf::compute_crc(data.data(), size * 8));
165  FEDTrailer::set(data.data() + (size - 1) * 8, size, crc, 0, 0);
166  }
167 
168  event.put(std::move(data_collection));
169 }
size
Write out results.
static void set(unsigned char *trailer, uint32_t lenght, uint16_t crc, uint8_t evt_stat, uint8_t tts, bool moreTrailers=false)
Set all fields in the trailer.
Definition: FEDTrailer.cc:31
edm::ESGetToken< RPCInverseAMCLinkMap, RPCInverseTwinMuxLinkMapRcd > es_tm_link_map_token_
std::map< int, std::vector< RPCAMCLink > > fed_amcs_
void setRPCBXWindow(int bx_min=10, int bx_max=5)
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
Definition: CRC16.h:46
edm::ESGetToken< RPCInverseLBLinkMap, RPCInverseLBLinkMapRcd > es_lb_link_map_token_
static void getRPCTwinMuxRecords(RPCInverseLBLinkMap const &lb_map, RPCInverseAMCLinkMap const &amc_map, int min_bx, int max_bx, unsigned int bcn, RPCDigiCollection const &digis, std::map< RPCAMCLink, std::vector< std::pair< int, rpctwinmux::RPCRecord > > > &amc_bx_tmrecord, bool ignore_eod=false)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
edm::EDGetTokenT< RPCDigiCollection > digi_token_
static void set(unsigned char *header, uint8_t triggerType, uint32_t lvl1ID, uint16_t bxID, uint16_t sourceID, uint8_t version=0, bool moreHeaders=false)
Set all fields in the header.
Definition: FEDHeader.cc:25
Definition: AMCSpec.h:8
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1

Member Data Documentation

◆ bx_max_

int RPCTwinMuxDigiToRaw::bx_max_
protected

Definition at line 44 of file RPCTwinMuxDigiToRaw.h.

Referenced by produce().

◆ bx_min_

int RPCTwinMuxDigiToRaw::bx_min_
protected

Definition at line 44 of file RPCTwinMuxDigiToRaw.h.

Referenced by produce().

◆ digi_token_

edm::EDGetTokenT<RPCDigiCollection> RPCTwinMuxDigiToRaw::digi_token_
protected

Definition at line 40 of file RPCTwinMuxDigiToRaw.h.

Referenced by produce(), and RPCTwinMuxDigiToRaw().

◆ es_lb_link_map_token_

edm::ESGetToken<RPCInverseLBLinkMap, RPCInverseLBLinkMapRcd> RPCTwinMuxDigiToRaw::es_lb_link_map_token_
protected

Definition at line 43 of file RPCTwinMuxDigiToRaw.h.

Referenced by produce().

◆ es_tm_link_map_br_token_

edm::ESGetToken<RPCAMCLinkMap, RPCTwinMuxLinkMapRcd> RPCTwinMuxDigiToRaw::es_tm_link_map_br_token_
protected

Definition at line 41 of file RPCTwinMuxDigiToRaw.h.

Referenced by beginRun().

◆ es_tm_link_map_token_

edm::ESGetToken<RPCInverseAMCLinkMap, RPCInverseTwinMuxLinkMapRcd> RPCTwinMuxDigiToRaw::es_tm_link_map_token_
protected

Definition at line 42 of file RPCTwinMuxDigiToRaw.h.

Referenced by produce().

◆ es_tm_link_map_watcher_

edm::ESWatcher<RPCTwinMuxLinkMapRcd> RPCTwinMuxDigiToRaw::es_tm_link_map_watcher_
protected

Definition at line 49 of file RPCTwinMuxDigiToRaw.h.

Referenced by beginRun().

◆ event_type_

int RPCTwinMuxDigiToRaw::event_type_
protected

Definition at line 46 of file RPCTwinMuxDigiToRaw.h.

Referenced by produce().

◆ fed_amcs_

std::map<int, std::vector<RPCAMCLink> > RPCTwinMuxDigiToRaw::fed_amcs_
protected

Definition at line 50 of file RPCTwinMuxDigiToRaw.h.

Referenced by beginRun(), and produce().

◆ ignore_eod_

bool RPCTwinMuxDigiToRaw::ignore_eod_
protected

Definition at line 45 of file RPCTwinMuxDigiToRaw.h.

Referenced by produce().

◆ ufov_

unsigned int RPCTwinMuxDigiToRaw::ufov_
protected

Definition at line 47 of file RPCTwinMuxDigiToRaw.h.

Referenced by produce().