CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
 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 std::vector
< rpcrawtodigi::EventRecords
eventRecords (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
< RPCDigiCollection
dataLabel_
 
edm::ESGetToken< RPCEMap,
RPCEMapRcd
readoutMappingToken_
 
edm::ESWatcher< RPCEMapRcdrecordWatcher_
 
const RPCReadOutMappingtheCabling
 

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

Driver class for digi to raw data conversions

Definition at line 34 of file RPCPackingModule.h.

Constructor & Destructor Documentation

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

ctor

Definition at line 31 of file RPCPackingModule.cc.

References edm::ParameterSet::getParameter().

31  {
32  dataLabel_ = consumes<RPCDigiCollection>(pset.getParameter<edm::InputTag>("InputLabel"));
33  readoutMappingToken_ = esConsumes<RPCEMap, RPCEMapRcd>();
34  theCabling = new RPCReadOutMapping("");
35  produces<FEDRawDataCollection>();
36 }
const RPCReadOutMapping * theCabling
edm::ESGetToken< RPCEMap, RPCEMapRcd > readoutMappingToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< RPCDigiCollection > dataLabel_
RPCPackingModule::~RPCPackingModule ( )
override

dtor

Definition at line 38 of file RPCPackingModule.cc.

38 { delete theCabling; }
const RPCReadOutMapping * theCabling

Member Function Documentation

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

Definition at line 128 of file RPCPackingModule.cc.

References l1tstage2_dqm_sourceclient-live_cfg::fedId, LogDebug, LogTrace, isotrackNtupler::merged, sistrip::SpyUtilities::range(), DetId::rawId(), and RPCRecordFormatter::recordPack().

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

131  {
132  typedef DigiContainerIterator<RPCDetId, RPCDigi> DigiRangeIterator;
133  vector<EventRecords> dataRecords;
134 
135  LogDebug("RPCRawDataPacker") << "Packing Fed id=" << fedId;
136  for (DigiRangeIterator it = digis->begin(); it != digis->end(); it++) {
137  RPCDetId rpcDetId = (*it).first;
138  uint32_t rawDetId = rpcDetId.rawId();
139  RPCDigiCollection::Range range = digis->get(rpcDetId);
140  for (vector<RPCDigi>::const_iterator id = range.first; id != range.second; id++) {
141  const RPCDigi& digi = (*id);
142  vector<EventRecords> rawFromDigi = formatter.recordPack(rawDetId, digi, trigger_BX);
143  dataRecords.insert(dataRecords.end(), rawFromDigi.begin(), rawFromDigi.end());
144  }
145  }
146 
147  //
148  // merge data words
149  //
150  LogTrace("RPCRawDataPacker") << " size of data: " << dataRecords.size();
151  vector<EventRecords> merged = EventRecords::mergeRecords(dataRecords);
152  LogTrace("") << " size of megred: " << merged.size();
153 
154  return merged;
155 }
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
#define LogTrace(id)
const uint16_t range(const Frame &aFrame)
std::vector< rpcrawtodigi::EventRecords > recordPack(uint32_t rawDetId, const RPCDigi &digi, int trigger_BX) const
std::pair< const_iterator, const_iterator > Range
#define LogDebug(id)
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.

References reco_application_2006_simpleTBanalysis_cfg::digiCollection, edm::EventID::event(), edm::Event::getByToken(), edm::EventSetup::getHandle(), edm::EventBase::id(), LogDebug, LogTrace, eostools::move(), edm::Handle< T >::product(), edm::Event::put(), and rawData().

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!";
49  theCabling = readoutMapping->convert();
50  LogTrace("") << " READOUT MAP VERSION: " << theCabling->version() << endl;
51  }
52 
53  auto buffers = std::make_unique<FEDRawDataCollection>();
54 
55  // pair<int,int> rpcFEDS=FEDNumbering::getRPCFEDIds();
56  pair<int, int> rpcFEDS(790, 792);
57  for (int id = rpcFEDS.first; id <= rpcFEDS.second; ++id) {
58  RPCRecordFormatter formatter(id, theCabling);
59  unsigned int lvl1_ID = ev.id().event();
60  FEDRawData* rawData = RPCPackingModule::rawData(id, lvl1_ID, digiCollection.product(), formatter);
61  FEDRawData& fedRawData = buffers->FEDData(id);
62 
63  fedRawData = *rawData;
64  delete rawData;
65  }
66  ev.put(std::move(buffers));
67 }
EventNumber_t event() const
Definition: EventID.h:40
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define LogTrace(id)
FEDRawData * rawData(int fedId, unsigned int lvl1_ID, const RPCDigiCollection *, const RPCRecordFormatter &) const
const std::string & version() const
version as string
def move
Definition: eostools.py:511
const RPCReadOutMapping * theCabling
edm::ESGetToken< RPCEMap, RPCEMapRcd > readoutMappingToken_
T const * product() const
Definition: Handle.h:70
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::EventID id() const
Definition: EventBase.h:59
edm::EDGetTokenT< RPCDigiCollection > dataLabel_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
edm::ESWatcher< RPCEMapRcd > recordWatcher_
#define LogDebug(id)
FEDRawData * RPCPackingModule::rawData ( int  fedId,
unsigned int  lvl1_ID,
const RPCDigiCollection digis,
const RPCRecordFormatter formatter 
) const
private

Definition at line 69 of file RPCPackingModule.cc.

References rpcrawtodigi::DataRecord::data(), FEDRawData::data(), relativeConstraints::empty, eventRecords(), l1tstage2_dqm_sourceclient-live_cfg::fedId, IR, isotrackNtupler::merged, FEDHeader::set(), FEDTrailer::set(), FEDRawData::size(), and w().

Referenced by produce().

72  {
73  //
74  // get merged records
75  //
76  int trigger_BX = 200; // FIXME - set event by event but correct bx assigment in digi
77  vector<EventRecords> merged = RPCPackingModule::eventRecords(fedId, trigger_BX, digis, formatter);
78 
79  //
80  // create data words
81  //
82  vector<Word64> dataWords;
84  typedef vector<EventRecords>::const_iterator IR;
85  for (IR ir = merged.begin(), irEnd = merged.end(); ir != irEnd; ++ir) {
86  Word64 w = (((Word64(ir->recordBX().data()) << 16) | ir->recordSLD().data()) << 16 | ir->recordCD().data()) << 16 |
87  empty.data();
88  dataWords.push_back(w);
89  }
90 
91  //
92  // create raw data
93  //
94  int nHeaders = 1;
95  int nTrailers = 1;
96  int dataSize = (nHeaders + nTrailers + dataWords.size()) * sizeof(Word64);
97  FEDRawData* raw = new FEDRawData(dataSize);
98 
99  //
100  // add header
101  //
102  unsigned char* pHeader = raw->data();
103  int evt_ty = 3;
104  int source_ID = fedId;
105  FEDHeader::set(pHeader, evt_ty, lvl1_ID, trigger_BX, source_ID);
106 
107  //
108  // add datawords
109  //
110  for (unsigned int idata = 0; idata < dataWords.size(); idata++) {
111  Word64* word = reinterpret_cast<Word64*>(pHeader + (idata + 1) * sizeof(Word64));
112  *word = dataWords[idata];
113  }
114 
115  //
116  // add trailer
117  //
118  unsigned char* pTrailer = pHeader + raw->size() - sizeof(Word64);
119  int crc = 0;
120  int evt_stat = 15;
121  int tts = 0;
122  int datasize = raw->size() / sizeof(Word64);
123  FEDTrailer::set(pTrailer, datasize, crc, evt_stat, tts);
124 
125  return raw;
126 }
#define IR(x)
Integer representation of a floating-point value.
Definition: IceFPU.h:18
static std::vector< rpcrawtodigi::EventRecords > eventRecords(int fedId, int trigger_BX, const RPCDigiCollection *, const RPCRecordFormatter &)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
uint64_t word
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
const Data & data() const
Definition: DataRecord.h:31
uint64_t Word64
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
T w() const
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
cms_uint64_t Word64

Member Data Documentation

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

Definition at line 54 of file RPCPackingModule.h.

edm::ESGetToken<RPCEMap, RPCEMapRcd> RPCPackingModule::readoutMappingToken_
private

Definition at line 57 of file RPCPackingModule.h.

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

Definition at line 55 of file RPCPackingModule.h.

const RPCReadOutMapping* RPCPackingModule::theCabling
private

Definition at line 56 of file RPCPackingModule.h.