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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descs)
 

Protected Attributes

int bx_max_
 
int bx_min_
 
edm::EDGetTokenT< RPCDigiCollectiondigi_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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 23 of file RPCTwinMuxDigiToRaw.h.

Constructor & Destructor Documentation

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

Definition at line 31 of file RPCTwinMuxDigiToRaw.cc.

References digi_token_, and edm::ParameterSet::getParameter().

32  : bx_min_(config.getParameter<int>("bxMin"))
33  , bx_max_(config.getParameter<int>("bxMax"))
34  , ignore_eod_(config.getParameter<bool>("ignoreEOD"))
35  , event_type_(config.getParameter<int>("eventType"))
36  , ufov_(config.getParameter<unsigned int>("uFOV"))
37 {
38  produces<FEDRawDataCollection>();
39  digi_token_ = consumes<RPCDigiCollection>(config.getParameter<edm::InputTag>("inputTag"));
40 }
Definition: config.py:1
edm::EDGetTokenT< RPCDigiCollection > digi_token_
RPCTwinMuxDigiToRaw::~RPCTwinMuxDigiToRaw ( )
override

Definition at line 42 of file RPCTwinMuxDigiToRaw.cc.

43 {}

Member Function Documentation

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

Definition at line 57 of file RPCTwinMuxDigiToRaw.cc.

References amc, edm::ESWatcher< T >::check(), es_tm_link_map_watcher_, fed_amcs_, edm::EventSetup::get(), RPCAMCLink::getFED(), RPCAMCLinkMap::getMap(), RPCAMCLink::setAMCInput(), jetUpdater_cfi::sort, and tier0::unique().

58 {
60  edm::ESHandle<RPCAMCLinkMap> es_tm_link_map;
61  setup.get<RPCTwinMuxLinkMapRcd>().get(es_tm_link_map);
62  fed_amcs_.clear();
63  for (auto const & tm_link : es_tm_link_map->getMap()) {
64  RPCAMCLink amc(tm_link.first);
65  amc.setAMCInput();
66  fed_amcs_[amc.getFED()].push_back(amc);
67  }
68  for (auto & fed_amcs : fed_amcs_) {
69  std::sort(fed_amcs.second.begin(), fed_amcs.second.end());
70  fed_amcs.second.erase(std::unique(fed_amcs.second.begin(), fed_amcs.second.end()), fed_amcs.second.end());
71  }
72  }
73 }
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
double amc
Definition: hdecay.h:20
std::map< int, std::vector< RPCAMCLink > > fed_amcs_
def unique(seq, keepstr=True)
Definition: tier0.py:25
map_type & getMap()
Definition: RPCAMCLinkMap.h:28
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
edm::ESWatcher< RPCTwinMuxLinkMapRcd > es_tm_link_map_watcher_
Definition: AMCSpec.h:8
void RPCTwinMuxDigiToRaw::fillDescriptions ( edm::ConfigurationDescriptions descs)
static

Definition at line 45 of file RPCTwinMuxDigiToRaw.cc.

References edm::ConfigurationDescriptions::add(), and edm::ParameterSetDescription::add().

46 {
48  desc.add<edm::InputTag>("inputTag", edm::InputTag("simMuonRPCDigis", ""));
49  desc.add<int>("bxMin", -2);
50  desc.add<int>("bxMax", 2);
51  desc.add<bool>("ignoreEOD", true);
52  desc.add<int>("eventType", 1);
53  desc.add<unsigned int>("uFOV", 1);
54  descs.add("RPCTwinMuxDigiToRaw", desc);
55 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void RPCTwinMuxDigiToRaw::produce ( edm::Event event,
edm::EventSetup const &  setup 
)
override

Definition at line 75 of file RPCTwinMuxDigiToRaw.cc.

References edm::EventBase::bunchCrossing(), bx_max_, bx_min_, evf::compute_crc(), FEDRawData::data(), data, DEFINE_FWK_MODULE, digi_token_, edm::EventID::event(), event_type_, fed_amcs_, edm::EventSetup::get(), RPCAMCLink::getAMCNumber(), RPCTwinMuxPacker::getRPCTwinMuxRecords(), edm::EventBase::id(), ignore_eod_, eostools::move(), FEDRawData::resize(), FEDHeader::set(), FEDTrailer::set(), rpctwinmux::TwinMuxHeader::setRPCBXWindow(), findQualityFiles::size, and ufov_.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

76 {
77  // Get EventSetup Electronics Maps
80 
81  setup.get<RPCInverseTwinMuxLinkMapRcd>().get(es_tm_link_map_);
82  setup.get<RPCInverseLBLinkMapRcd>().get(es_lb_link_map);
83 
84  // Get Digi Collection
85  edm::Handle<RPCDigiCollection> digi_collection;
86  event.getByToken(digi_token_, digi_collection);
87 
88  // Create output
89  std::unique_ptr<FEDRawDataCollection> data_collection(new FEDRawDataCollection());
90 
91  std::map<RPCAMCLink, std::vector<std::pair<int, rpctwinmux::RPCRecord> > > amc_bx_tmrecord;
92  RPCTwinMuxPacker::getRPCTwinMuxRecords(*es_lb_link_map, *es_tm_link_map_
93  , bx_min_, bx_max_, event.bunchCrossing()
94  , *digi_collection
95  , amc_bx_tmrecord
96  , ignore_eod_);
97 
98  std::map<int, FEDRawData> fed_data;
99  // Loop over the FEDs
100  for (std::pair<int, std::vector<RPCAMCLink> > const & fed_amcs : fed_amcs_) {
101  FEDRawData & data = data_collection->FEDData(fed_amcs.first);
102  unsigned int size(0);
103 
104  // FED Header + BLOCK Header (1 word + 1 word)
105  data.resize((size + 2) * 8);
106  // FED Header
107  FEDHeader::set(data.data() + size * 8, event_type_, event.id().event(), event.bunchCrossing(), fed_amcs.first);
108  ++size;
109  // BLOCK Header
110  rpctwinmux::BlockHeader block_header(ufov_, fed_amcs.second.size(), event.eventAuxiliary().orbitNumber());
111  std::memcpy(data.data() + size * 8, &block_header.getRecord(), 8);
112  ++size;
113 
114  // BLOCK AMC Content - 1 word each
115  data.resize((size + fed_amcs.second.size()) * 8);
116  unsigned int block_content_size(0);
117  for (RPCAMCLink const & amc : fed_amcs.second) {
118  std::map<RPCAMCLink, std::vector<std::pair<int, rpctwinmux::RPCRecord> > >::const_iterator bx_tmrecord(amc_bx_tmrecord.find(amc));
119  unsigned int block_amc_size(3 + 2 * (bx_tmrecord == amc_bx_tmrecord.end() ? 0 : bx_tmrecord->second.size()));
120  block_content_size += block_amc_size;
121  rpctwinmux::BlockAMCContent amc_content(true
122  , true, true
123  , true, true, true, true, block_amc_size
124  , 0, amc.getAMCNumber()
125  , 0);
126  std::memcpy(data.data() + size * 8, &amc_content.getRecord(), 8);
127  ++size;
128  }
129 
130  // AMC Payload - 2 words header, 1 word trailer, 2 words per RPCRecord
131  data.resize((size + block_content_size) * 8);
132  for (RPCAMCLink const & amc : fed_amcs.second) {
133  // TwinMux Header
134  std::map<RPCAMCLink, std::vector<std::pair<int, rpctwinmux::RPCRecord> > >::const_iterator bx_tmrecord(amc_bx_tmrecord.find(amc));
135  unsigned int block_amc_size(3 + 2 * (bx_tmrecord == amc_bx_tmrecord.end() ? 0 : bx_tmrecord->second.size()));
136 
137  rpctwinmux::TwinMuxHeader tm_header(amc.getAMCNumber(), event.id().event(), event.bunchCrossing()
138  , block_amc_size
139  , event.eventAuxiliary().orbitNumber()
140  , 0);
141  tm_header.setRPCBXWindow(bx_min_, bx_min_);
142  std::memcpy(data.data() + size * 8, tm_header.getRecord(), 16);
143  size += 2;
144 
145  if (bx_tmrecord != amc_bx_tmrecord.end()) {
146  for (std::vector<std::pair<int, rpctwinmux::RPCRecord> >::const_iterator tmrecord = bx_tmrecord->second.begin()
147  ; tmrecord != bx_tmrecord->second.end() ; ++tmrecord) {
148  std::memcpy(data.data() + size * 8, tmrecord->second.getRecord(), 16);
149  size += 2;
150  }
151  }
152 
153  rpctwinmux::TwinMuxTrailer tm_trailer(0x0, event.id().event(), 3 + 2 * block_amc_size);
154  std::memcpy(data.data() + size * 8, &tm_trailer.getRecord(), 8);
155  ++size;
156  // CRC32 not calculated (for now)
157  }
158 
159  // BLOCK Trailer + FED Trailer (1 word + 1 word)
160  data.resize((size + 2) * 8);
161  // BLOCK Trailer
162  rpctwinmux::BlockTrailer block_trailer(0x0, 0, event.id().event(), event.bunchCrossing());
163  std::memcpy(data.data() + size * 8, &block_trailer.getRecord(), 8);
164  ++size;
165  // CRC32 not calculated (for now)
166 
167  // FED Trailer
168  ++size;
169  FEDTrailer::set(data.data() + (size - 1) * 8, size, 0x0, 0, 0);
170  std::uint16_t crc(evf::compute_crc(data.data(), size * 8));
171  FEDTrailer::set(data.data() + (size - 1) * 8, size, crc, 0, 0);
172  }
173 
174  event.put(std::move(data_collection));
175 }
size
Write out results.
EventNumber_t event() const
Definition: EventID.h:41
int bunchCrossing() const
Definition: EventBase.h:64
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
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:60
void resize(size_t newsize)
Definition: FEDRawData.cc:32
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
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)
edm::EventID id() const
Definition: EventBase.h:59
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
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:47
Definition: AMCSpec.h:8
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

int RPCTwinMuxDigiToRaw::bx_max_
protected

Definition at line 38 of file RPCTwinMuxDigiToRaw.h.

Referenced by produce().

int RPCTwinMuxDigiToRaw::bx_min_
protected

Definition at line 38 of file RPCTwinMuxDigiToRaw.h.

Referenced by produce().

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

Definition at line 36 of file RPCTwinMuxDigiToRaw.h.

Referenced by produce(), and RPCTwinMuxDigiToRaw().

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

Definition at line 43 of file RPCTwinMuxDigiToRaw.h.

Referenced by beginRun().

int RPCTwinMuxDigiToRaw::event_type_
protected

Definition at line 40 of file RPCTwinMuxDigiToRaw.h.

Referenced by produce().

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

Definition at line 44 of file RPCTwinMuxDigiToRaw.h.

Referenced by beginRun(), and produce().

bool RPCTwinMuxDigiToRaw::ignore_eod_
protected

Definition at line 39 of file RPCTwinMuxDigiToRaw.h.

Referenced by produce().

unsigned int RPCTwinMuxDigiToRaw::ufov_
protected

Definition at line 41 of file RPCTwinMuxDigiToRaw.h.

Referenced by produce().