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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

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
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static std::vector< rpcrawtodigi::EventRecordseventRecords (int fedId, int trigger_BX, const RPCDigiCollection *, const RPCRecordFormatter &)
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
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:127
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
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
const T & get() const
Definition: EventSetup.h:55
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::EventID id() const
Definition: EventBase.h:60
edm::EDGetTokenT< RPCDigiCollection > dataLabel_
RPCReadOutMapping const * convert() const
Definition: RPCEMap.h:67
edm::ESWatcher< RPCEMapRcd > recordWatcher_
def move(src, dest)
Definition: eostools.py:510
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, FEDTrailer::set(), FEDHeader::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 &)
static void set(unsigned char *trailer, int evt_lgth, int crc, int evt_stat, int tts, bool T=false)
Set all fields in the trailer.
Definition: FEDTrailer.cc:42
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
const Data & data() const
Definition: DataRecord.h:32
static void set(unsigned char *header, int evt_ty, int lvl1_ID, int bx_ID, int source_ID, int version=0, bool H=false)
Set all fields in the header.
Definition: FEDHeader.cc:40
uint64_t Word64
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28

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.