CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
RPCPackingModule Class Reference

#include <RPCPackingModule.h>

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

Public Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 get data, convert to raw event, attach again to Event More...
 
 RPCPackingModule (const edm::ParameterSet &)
 ctor More...
 
 ~RPCPackingModule () override
 dtor More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static std::vector< rpcrawtodigi::EventRecordseventRecords (int fedId, int trigger_BX, const RPCDigiCollection *, const RPCRecordFormatter &)
 

Private Member Functions

FEDRawDatarawData (int fedId, unsigned int lvl1_ID, const RPCDigiCollection *, const RPCRecordFormatter &) const
 

Private Attributes

edm::EDGetTokenT< RPCDigiCollectiondataLabel_
 
edm::ESWatcher< RPCEMapRcdrecordWatcher_
 
const RPCReadOutMappingtheCabling
 

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

Driver class for digi to raw data conversions

Definition at line 32 of file RPCPackingModule.h.

Constructor & Destructor Documentation

◆ RPCPackingModule()

RPCPackingModule::RPCPackingModule ( const edm::ParameterSet pset)
explicit

ctor

Definition at line 32 of file RPCPackingModule.cc.

32  {
33  dataLabel_ = consumes<RPCDigiCollection>(pset.getParameter<edm::InputTag>("InputLabel"));
34  theCabling = new RPCReadOutMapping("");
35  produces<FEDRawDataCollection>();
36 }

References muonDTDigis_cfi::pset.

◆ ~RPCPackingModule()

RPCPackingModule::~RPCPackingModule ( )
override

dtor

Definition at line 38 of file RPCPackingModule.cc.

38 { delete theCabling; }

Member Function Documentation

◆ eventRecords()

vector< EventRecords > RPCPackingModule::eventRecords ( int  fedId,
int  trigger_BX,
const RPCDigiCollection digis,
const RPCRecordFormatter formatter 
)
static

Definition at line 129 of file RPCPackingModule.cc.

132  {
133  typedef DigiContainerIterator<RPCDetId, RPCDigi> DigiRangeIterator;
134  vector<EventRecords> dataRecords;
135 
136  LogDebug("RPCRawDataPacker") << "Packing Fed id=" << fedId;
137  for (DigiRangeIterator it = digis->begin(); it != digis->end(); it++) {
138  RPCDetId rpcDetId = (*it).first;
139  uint32_t rawDetId = rpcDetId.rawId();
140  RPCDigiCollection::Range range = digis->get(rpcDetId);
141  for (vector<RPCDigi>::const_iterator id = range.first; id != range.second; id++) {
142  const RPCDigi& digi = (*id);
143  vector<EventRecords> rawFromDigi = formatter.recordPack(rawDetId, digi, trigger_BX);
144  dataRecords.insert(dataRecords.end(), rawFromDigi.begin(), rawFromDigi.end());
145  }
146  }
147 
148  //
149  // merge data words
150  //
151  LogTrace("RPCRawDataPacker") << " size of data: " << dataRecords.size();
152  vector<EventRecords> merged = EventRecords::mergeRecords(dataRecords);
153  LogTrace("") << " size of megred: " << merged.size();
154 
155  return merged;
156 }

References l1tstage2_dqm_sourceclient-live_cfg::fedId, LogDebug, LogTrace, FastTimerService_cff::range, DetId::rawId(), and RPCRecordFormatter::recordPack().

Referenced by omtf::RpcPacker::pack(), and rawData().

◆ produce()

void RPCPackingModule::produce ( edm::Event ev,
const edm::EventSetup es 
)
override

get data, convert to raw event, attach again to Event

Definition at line 40 of file RPCPackingModule.cc.

40  {
42  ev.getByToken(dataLabel_, digiCollection);
43  LogDebug("") << DebugDigisPrintout()(digiCollection.product());
44 
45  if (recordWatcher_.check(es)) {
46  delete theCabling;
47  LogTrace("") << "record has CHANGED!!, initialise readout map!";
48  ESHandle<RPCEMap> readoutMapping;
49  es.get<RPCEMapRcd>().get(readoutMapping);
50  theCabling = readoutMapping->convert();
51  LogTrace("") << " READOUT MAP VERSION: " << theCabling->version() << endl;
52  }
53 
54  auto buffers = std::make_unique<FEDRawDataCollection>();
55 
56  // pair<int,int> rpcFEDS=FEDNumbering::getRPCFEDIds();
57  pair<int, int> rpcFEDS(790, 792);
58  for (int id = rpcFEDS.first; id <= rpcFEDS.second; ++id) {
59  RPCRecordFormatter formatter(id, theCabling);
60  unsigned int lvl1_ID = ev.id().event();
61  FEDRawData* rawData = RPCPackingModule::rawData(id, lvl1_ID, digiCollection.product(), formatter);
62  FEDRawData& fedRawData = buffers->FEDData(id);
63 
65  delete rawData;
66  }
67  ev.put(std::move(buffers));
68 }

References RPCEMap::convert(), apvshotsanalyzer_cfi::digiCollection, ev, l1t_dqm_sourceclient-live_cfg::fedRawData, edm::EventSetup::get(), get, LogDebug, LogTrace, eostools::move(), rawData(), and l1tstage2_dqm_sourceclient-live_cfg::rawData.

◆ rawData()

FEDRawData * RPCPackingModule::rawData ( int  fedId,
unsigned int  lvl1_ID,
const RPCDigiCollection digis,
const RPCRecordFormatter formatter 
) const
private

Definition at line 70 of file RPCPackingModule.cc.

73  {
74  //
75  // get merged records
76  //
77  int trigger_BX = 200; // FIXME - set event by event but correct bx assigment in digi
78  vector<EventRecords> merged = RPCPackingModule::eventRecords(fedId, trigger_BX, digis, formatter);
79 
80  //
81  // create data words
82  //
83  vector<Word64> dataWords;
85  typedef vector<EventRecords>::const_iterator IR;
86  for (IR ir = merged.begin(), irEnd = merged.end(); ir != irEnd; ++ir) {
87  Word64 w = (((Word64(ir->recordBX().data()) << 16) | ir->recordSLD().data()) << 16 | ir->recordCD().data()) << 16 |
88  empty.data();
89  dataWords.push_back(w);
90  }
91 
92  //
93  // create raw data
94  //
95  int nHeaders = 1;
96  int nTrailers = 1;
97  int dataSize = (nHeaders + nTrailers + dataWords.size()) * sizeof(Word64);
98  FEDRawData* raw = new FEDRawData(dataSize);
99 
100  //
101  // add header
102  //
103  unsigned char* pHeader = raw->data();
104  int evt_ty = 3;
105  int source_ID = fedId;
106  FEDHeader::set(pHeader, evt_ty, lvl1_ID, trigger_BX, source_ID);
107 
108  //
109  // add datawords
110  //
111  for (unsigned int idata = 0; idata < dataWords.size(); idata++) {
112  Word64* word = reinterpret_cast<Word64*>(pHeader + (idata + 1) * sizeof(Word64));
113  *word = dataWords[idata];
114  }
115 
116  //
117  // add trailer
118  //
119  unsigned char* pTrailer = pHeader + raw->size() - sizeof(Word64);
120  int crc = 0;
121  int evt_stat = 15;
122  int tts = 0;
123  int datasize = raw->size() / sizeof(Word64);
124  FEDTrailer::set(pTrailer, datasize, crc, evt_stat, tts);
125 
126  return raw;
127 }

References FEDRawData::data(), std::empty(), eventRecords(), l1tstage2_dqm_sourceclient-live_cfg::fedId, FEDHeader::set(), FEDTrailer::set(), FEDRawData::size(), and w.

Referenced by produce().

Member Data Documentation

◆ dataLabel_

edm::EDGetTokenT<RPCDigiCollection> RPCPackingModule::dataLabel_
private

Definition at line 52 of file RPCPackingModule.h.

◆ recordWatcher_

edm::ESWatcher<RPCEMapRcd> RPCPackingModule::recordWatcher_
private

Definition at line 53 of file RPCPackingModule.h.

◆ theCabling

const RPCReadOutMapping* RPCPackingModule::theCabling
private

Definition at line 54 of file RPCPackingModule.h.

edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
RPCRecordFormatter
Definition: RPCRecordFormatter.h:15
RPCPackingModule::rawData
FEDRawData * rawData(int fedId, unsigned int lvl1_ID, const RPCDigiCollection *, const RPCRecordFormatter &) const
Definition: RPCPackingModule.cc:70
RPCEMap::convert
RPCReadOutMapping const * convert() const
Definition: RPCEMap.h:64
Word64
uint64_t Word64
Definition: RPCPackingModule.cc:30
RPCDetId
Definition: RPCDetId.h:16
rpcrawtodigi::EmptyWord
Definition: EmptyWord.h:8
RPCPackingModule::dataLabel_
edm::EDGetTokenT< RPCDigiCollection > dataLabel_
Definition: RPCPackingModule.h:52
edm::Handle< RPCDigiCollection >
RPCReadOutMapping::version
const std::string & version() const
version as string
Definition: RPCReadOutMapping.h:43
RPCRecordFormatter::recordPack
std::vector< rpcrawtodigi::EventRecords > recordPack(uint32_t rawDetId, const RPCDigi &digi, int trigger_BX) const
Definition: RPCRecordFormatter.cc:32
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
FEDRawData
Definition: FEDRawData.h:19
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
RPCPackingModule::recordWatcher_
edm::ESWatcher< RPCEMapRcd > recordWatcher_
Definition: RPCPackingModule.h:53
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
l1t_dqm_sourceclient-live_cfg.fedRawData
fedRawData
Definition: l1t_dqm_sourceclient-live_cfg.py:188
w
const double w
Definition: UKUtility.cc:23
edm::ESHandle
Definition: DTSurvey.h:22
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
Word64
uint64_t Word64
Definition: RPCUnpackingModule.cc:38
RPCReadOutMapping
Definition: RPCReadOutMapping.h:22
apvshotsanalyzer_cfi.digiCollection
digiCollection
Definition: apvshotsanalyzer_cfi.py:4
l1tstage2_dqm_sourceclient-live_cfg.fedId
fedId
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:88
FEDTrailer::set
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
get
#define get
RPCEMapRcd
Definition: RPCEMapRcd.h:5
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
eostools.move
def move(src, dest)
Definition: eostools.py:511
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
RPCDigi
Definition: RPCDigi.h:19
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
FEDHeader::set
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
MuonDigiCollection< RPCDetId, RPCDigi >::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
rpcrawtodigi::DebugDigisPrintout
Definition: DebugDigisPrintout.h:11
RPCPackingModule::eventRecords
static std::vector< rpcrawtodigi::EventRecords > eventRecords(int fedId, int trigger_BX, const RPCDigiCollection *, const RPCRecordFormatter &)
Definition: RPCPackingModule.cc:129
RPCPackingModule::theCabling
const RPCReadOutMapping * theCabling
Definition: RPCPackingModule.h:54
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
DigiContainerIterator
Definition: MuonDigiCollection.h:30
edm::InputTag
Definition: InputTag.h:15
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27