CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)
 get data, convert to raw event, attach again to Event More...
 
 RPCPackingModule (const edm::ParameterSet &)
 ctor More...
 
virtual ~RPCPackingModule ()
 dtor More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static std::vector
< rpcrawtodigi::EventRecords
eventRecords (int fedId, int trigger_BX, const RPCDigiCollection *, const RPCRecordFormatter &)
 
- Static Public Member Functions inherited from edm::EDProducer
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 &)
 

Private Attributes

edm::EDGetTokenT
< RPCDigiCollection
dataLabel_
 
unsigned long eventCounter_
 
const RPCReadOutMappingtheCabling
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 23 of file RPCPackingModule.h.

Constructor & Destructor Documentation

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

ctor

Definition at line 35 of file RPCPackingModule.cc.

References dataLabel_, edm::ParameterSet::getParameter(), and theCabling.

36  : eventCounter_(0)
37 {
38 
39  dataLabel_ = consumes<RPCDigiCollection>(pset.getParameter<edm::InputTag>("InputLabel"));
40  theCabling = new RPCReadOutMapping("");
41  produces<FEDRawDataCollection>();
42 
43 }
T getParameter(std::string const &) const
unsigned long eventCounter_
const RPCReadOutMapping * theCabling
edm::EDGetTokenT< RPCDigiCollection > dataLabel_
RPCPackingModule::~RPCPackingModule ( )
virtual

dtor

Definition at line 45 of file RPCPackingModule.cc.

References theCabling.

46 {
47  delete theCabling;
48 }
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 147 of file RPCPackingModule.cc.

References LogDebug, LogTrace, DetId::rawId(), and RPCRecordFormatter::recordPack().

Referenced by rawData().

152 {
153  typedef DigiContainerIterator<RPCDetId, RPCDigi> DigiRangeIterator;
154  vector<EventRecords> dataRecords;
155 
156 
157  LogDebug("RPCRawDataPacker")<<"Packing Fed id="<<fedId;
158  for (DigiRangeIterator it=digis->begin(); it != digis->end(); it++) {
159  RPCDetId rpcDetId = (*it).first;
160  uint32_t rawDetId = rpcDetId.rawId();
161  RPCDigiCollection::Range range = digis->get(rpcDetId);
162  for (vector<RPCDigi>::const_iterator id = range.first; id != range.second; id++) {
163  const RPCDigi & digi = (*id);
164  vector<EventRecords> rawFromDigi = formatter.recordPack(rawDetId, digi, trigger_BX);
165  dataRecords.insert(dataRecords.end(), rawFromDigi.begin(), rawFromDigi.end());
166  }
167  }
168 
169  //
170  // merge data words
171  //
172  LogTrace("RPCRawDataPacker") <<" size of data: " << dataRecords.size();
173  vector<EventRecords> merged = EventRecords::mergeRecords(dataRecords);
174  LogTrace("") <<" size of megred: " << merged.size();
175 
176  return merged;
177 }
#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 
)
virtual

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

Implements edm::EDProducer.

Definition at line 51 of file RPCPackingModule.cc.

References edm::ESWatcher< T >::check(), dataLabel_, reco_application_2006_simpleTBanalysis_cfg::digiCollection, edm::EventID::event(), eventCounter_, edm::EventSetup::get(), edm::Event::getByToken(), edm::EventBase::id(), LogDebug, LogTrace, edm::Handle< T >::product(), edm::Event::put(), rawData(), theCabling, and RPCReadOutMapping::version().

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

53 {
54  eventCounter_++;
55  LogInfo("RPCPackingModule") << "[RPCPackingModule::produce] "
56  << "event counter: " << eventCounter_;
57 
59  ev.getByToken(dataLabel_,digiCollection);
60  LogDebug("") << DebugDigisPrintout()(digiCollection.product());
61 
62  static edm::ESWatcher<RPCEMapRcd> recordWatcher;
63  if(recordWatcher.check(es)) {
64  delete theCabling;
65  LogTrace("") << "record has CHANGED!!, initialise readout map!";
66  ESHandle<RPCEMap> readoutMapping;
67  es.get<RPCEMapRcd>().get(readoutMapping);
68  theCabling = readoutMapping->convert();
69  LogTrace("") <<" READOUT MAP VERSION: " << theCabling->version() << endl;
70  }
71 
72  auto_ptr<FEDRawDataCollection> buffers( new FEDRawDataCollection );
73 
74 // pair<int,int> rpcFEDS=FEDNumbering::getRPCFEDIds();
75  pair<int,int> rpcFEDS(790,792);
76  for (int id= rpcFEDS.first; id<=rpcFEDS.second; ++id){
77 
78  RPCRecordFormatter formatter(id, theCabling) ;
79  unsigned int lvl1_ID = ev.id().event();
80  FEDRawData* rawData = RPCPackingModule::rawData(id, lvl1_ID, digiCollection.product(), formatter);
81  FEDRawData& fedRawData = buffers->FEDData(id);
82 
83  fedRawData = *rawData;
84  delete rawData;
85  }
86  ev.put( buffers );
87 }
#define LogDebug(id)
EventNumber_t event() const
Definition: EventID.h:44
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
unsigned long eventCounter_
const std::string & version() const
version as string
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
FEDRawData * rawData(int fedId, unsigned int lvl1_ID, const RPCDigiCollection *, const RPCRecordFormatter &)
const RPCReadOutMapping * theCabling
#define LogTrace(id)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: Handle.h:81
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:58
edm::EventID id() const
Definition: EventBase.h:56
edm::EDGetTokenT< RPCDigiCollection > dataLabel_
FEDRawData * RPCPackingModule::rawData ( int  fedId,
unsigned int  lvl1_ID,
const RPCDigiCollection digis,
const RPCRecordFormatter formatter 
)
private

Definition at line 90 of file RPCPackingModule.cc.

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

Referenced by produce().

91 {
92  //
93  // get merged records
94  //
95  int trigger_BX = 200; // FIXME - set event by event but correct bx assigment in digi
96  vector<EventRecords> merged = RPCPackingModule::eventRecords(fedId,trigger_BX,digis,formatter);
97 
98  //
99  // create data words
100  //
101  vector<Word64> dataWords;
103  typedef vector<EventRecords>::const_iterator IR;
104  for (IR ir = merged.begin(), irEnd = merged.end() ; ir != irEnd; ++ir) {
105  Word64 w = ( ( (Word64(ir->recordBX().data()) << 16) | ir->recordSLD().data() ) << 16
106  | ir->recordCD().data() ) << 16 | empty.data();
107  dataWords.push_back(w);
108  }
109 
110  //
111  // create raw data
112  //
113  int nHeaders = 1;
114  int nTrailers = 1;
115  int dataSize = (nHeaders+nTrailers+dataWords.size()) * sizeof(Word64);
116  FEDRawData * raw = new FEDRawData(dataSize);
117 
118  //
119  // add header
120  //
121  unsigned char *pHeader = raw->data();
122  int evt_ty = 3;
123  int source_ID = fedId;
124  FEDHeader::set(pHeader, evt_ty, lvl1_ID, trigger_BX, source_ID);
125 
126  //
127  // add datawords
128  //
129  for (unsigned int idata = 0; idata < dataWords.size(); idata ++) {
130  Word64 * word = reinterpret_cast<Word64* >(pHeader+(idata+1)*sizeof(Word64));
131  *word = dataWords[idata];
132  }
133 
134  //
135  // add trailer
136  //
137  unsigned char *pTrailer = pHeader + raw->size()-sizeof(Word64);
138  int crc = 0;
139  int evt_stat = 15;
140  int tts = 0;
141  int datasize = raw->size()/sizeof(Word64);
142  FEDTrailer::set(pTrailer, datasize, crc, evt_stat, tts);
143 
144  return raw;
145 }
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
T w() const

Member Data Documentation

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

Definition at line 42 of file RPCPackingModule.h.

Referenced by produce(), and RPCPackingModule().

unsigned long RPCPackingModule::eventCounter_
private

Definition at line 43 of file RPCPackingModule.h.

Referenced by produce().

const RPCReadOutMapping* RPCPackingModule::theCabling
private

Definition at line 44 of file RPCPackingModule.h.

Referenced by produce(), RPCPackingModule(), and ~RPCPackingModule().