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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 26 of file RPCPackingModule.h.

Constructor & Destructor Documentation

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

ctor

Definition at line 33 of file RPCPackingModule.cc.

References edm::ParameterSet::getParameter().

34 {
35 
36  dataLabel_ = consumes<RPCDigiCollection>(pset.getParameter<edm::InputTag>("InputLabel"));
37  theCabling = new RPCReadOutMapping("");
38  produces<FEDRawDataCollection>();
39 
40 }
T getParameter(std::string const &) const
const RPCReadOutMapping * theCabling
edm::EDGetTokenT< RPCDigiCollection > dataLabel_
RPCPackingModule::~RPCPackingModule ( )
override

dtor

Definition at line 42 of file RPCPackingModule.cc.

43 {
44  delete theCabling;
45 }
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 139 of file RPCPackingModule.cc.

References l1t::stage2::layer2::fedId, LogDebug, LogTrace, DetId::rawId(), and RPCRecordFormatter::recordPack().

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

144 {
145  typedef DigiContainerIterator<RPCDetId, RPCDigi> DigiRangeIterator;
146  vector<EventRecords> dataRecords;
147 
148 
149  LogDebug("RPCRawDataPacker")<<"Packing Fed id="<<fedId;
150  for (DigiRangeIterator it=digis->begin(); it != digis->end(); it++) {
151  RPCDetId rpcDetId = (*it).first;
152  uint32_t rawDetId = rpcDetId.rawId();
153  RPCDigiCollection::Range range = digis->get(rpcDetId);
154  for (vector<RPCDigi>::const_iterator id = range.first; id != range.second; id++) {
155  const RPCDigi & digi = (*id);
156  vector<EventRecords> rawFromDigi = formatter.recordPack(rawDetId, digi, trigger_BX);
157  dataRecords.insert(dataRecords.end(), rawFromDigi.begin(), rawFromDigi.end());
158  }
159  }
160 
161  //
162  // merge data words
163  //
164  LogTrace("RPCRawDataPacker") <<" size of data: " << dataRecords.size();
165  vector<EventRecords> merged = EventRecords::mergeRecords(dataRecords);
166  LogTrace("") <<" size of megred: " << merged.size();
167 
168  return merged;
169 }
#define LogDebug(id)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
std::vector< rpcrawtodigi::EventRecords > recordPack(uint32_t rawDetId, const RPCDigi &digi, int trigger_BX) const
#define LogTrace(id)
std::pair< const_iterator, const_iterator > Range
void RPCPackingModule::produce ( edm::Event ev,
const edm::EventSetup es 
)
override

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

Definition at line 48 of file RPCPackingModule.cc.

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

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

50 {
52  ev.getByToken(dataLabel_,digiCollection);
53  LogDebug("") << DebugDigisPrintout()(digiCollection.product());
54 
55  if(recordWatcher_.check(es)) {
56  delete theCabling;
57  LogTrace("") << "record has CHANGED!!, initialise readout map!";
58  ESHandle<RPCEMap> readoutMapping;
59  es.get<RPCEMapRcd>().get(readoutMapping);
60  theCabling = readoutMapping->convert();
61  LogTrace("") <<" READOUT MAP VERSION: " << theCabling->version() << endl;
62  }
63 
64  auto buffers = std::make_unique<FEDRawDataCollection>();
65 
66 // pair<int,int> rpcFEDS=FEDNumbering::getRPCFEDIds();
67  pair<int,int> rpcFEDS(790,792);
68  for (int id= rpcFEDS.first; id<=rpcFEDS.second; ++id){
69 
70  RPCRecordFormatter formatter(id, theCabling) ;
71  unsigned int lvl1_ID = ev.id().event();
72  FEDRawData* rawData = RPCPackingModule::rawData(id, lvl1_ID, digiCollection.product(), formatter);
73  FEDRawData& fedRawData = buffers->FEDData(id);
74 
75  fedRawData = *rawData;
76  delete rawData;
77  }
78  ev.put(std::move(buffers));
79 }
#define LogDebug(id)
EventNumber_t event() const
Definition: EventID.h:41
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
FEDRawData * rawData(int fedId, unsigned int lvl1_ID, const RPCDigiCollection *, const RPCRecordFormatter &) const
const std::string & version() const
version as string
const RPCReadOutMapping * theCabling
#define LogTrace(id)
T const * product() const
Definition: Handle.h:81
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::EventID id() const
Definition: EventBase.h:60
T get() const
Definition: EventSetup.h:62
edm::EDGetTokenT< RPCDigiCollection > dataLabel_
RPCReadOutMapping const * convert() const
Definition: RPCEMap.h:67
edm::ESWatcher< RPCEMapRcd > recordWatcher_
def move(src, dest)
Definition: eostools.py:511
FEDRawData * RPCPackingModule::rawData ( int  fedId,
unsigned int  lvl1_ID,
const RPCDigiCollection digis,
const RPCRecordFormatter formatter 
) const
private

Definition at line 82 of file RPCPackingModule.cc.

References rpcrawtodigi::DataRecord::data(), FEDRawData::data(), relativeConstraints::empty, eventRecords(), l1t::stage2::layer2::fedId, FEDHeader::set(), FEDTrailer::set(), FEDRawData::size(), and w.

Referenced by produce().

83 {
84  //
85  // get merged records
86  //
87  int trigger_BX = 200; // FIXME - set event by event but correct bx assigment in digi
88  vector<EventRecords> merged = RPCPackingModule::eventRecords(fedId,trigger_BX,digis,formatter);
89 
90  //
91  // create data words
92  //
93  vector<Word64> dataWords;
95  typedef vector<EventRecords>::const_iterator IR;
96  for (IR ir = merged.begin(), irEnd = merged.end() ; ir != irEnd; ++ir) {
97  Word64 w = ( ( (Word64(ir->recordBX().data()) << 16) | ir->recordSLD().data() ) << 16
98  | ir->recordCD().data() ) << 16 | empty.data();
99  dataWords.push_back(w);
100  }
101 
102  //
103  // create raw data
104  //
105  int nHeaders = 1;
106  int nTrailers = 1;
107  int dataSize = (nHeaders+nTrailers+dataWords.size()) * sizeof(Word64);
108  FEDRawData * raw = new FEDRawData(dataSize);
109 
110  //
111  // add header
112  //
113  unsigned char *pHeader = raw->data();
114  int evt_ty = 3;
115  int source_ID = fedId;
116  FEDHeader::set(pHeader, evt_ty, lvl1_ID, trigger_BX, source_ID);
117 
118  //
119  // add datawords
120  //
121  for (unsigned int idata = 0; idata < dataWords.size(); idata ++) {
122  Word64 * word = reinterpret_cast<Word64* >(pHeader+(idata+1)*sizeof(Word64));
123  *word = dataWords[idata];
124  }
125 
126  //
127  // add trailer
128  //
129  unsigned char *pTrailer = pHeader + raw->size()-sizeof(Word64);
130  int crc = 0;
131  int evt_stat = 15;
132  int tts = 0;
133  int datasize = raw->size()/sizeof(Word64);
134  FEDTrailer::set(pTrailer, datasize, crc, evt_stat, tts);
135 
136  return raw;
137 }
uint64_t Word64
const double w
Definition: UKUtility.cc:23
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:47
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
const Data & data() const
Definition: DataRecord.h:32
uint64_t Word64
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
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

Member Data Documentation

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

Definition at line 45 of file RPCPackingModule.h.

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

Definition at line 46 of file RPCPackingModule.h.

const RPCReadOutMapping* RPCPackingModule::theCabling
private

Definition at line 47 of file RPCPackingModule.h.