CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
GctDigiToRaw Class Reference

#include <EventFilter/GctRawToDigi/src/GctDigiToRaw.cc>

Inheritance diagram for GctDigiToRaw:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 GctDigiToRaw (const edm::ParameterSet &)
 
 ~GctDigiToRaw ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
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 ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
void print (FEDRawData &data)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

int counter_
 
int fedId_
 
GctFormatTranslateMCLegacy formatTranslator_
 
edm::InputTag gctInputLabel_
 
bool packRctCalo_
 
bool packRctEm_
 
edm::InputTag rctInputLabel_
 
bool verbose_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- 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

Description: Produce fake GCT raw data from digis

Implementation: <Notes on="" implementation>="">

Definition at line 42 of file GctDigiToRaw.h.

Constructor & Destructor Documentation

GctDigiToRaw::GctDigiToRaw ( const edm::ParameterSet iConfig)
explicit

Definition at line 40 of file GctDigiToRaw.cc.

References fedId_, and LogDebug.

40  :
41  rctInputLabel_(iConfig.getParameter<edm::InputTag>("rctInputLabel")),
42  gctInputLabel_(iConfig.getParameter<edm::InputTag>("gctInputLabel")),
43  packRctEm_(iConfig.getUntrackedParameter<bool>("packRctEm", true)),
44  packRctCalo_(iConfig.getUntrackedParameter<bool>("packRctCalo", true)),
45  fedId_(iConfig.getParameter<int>("gctFedId")),
46  verbose_(iConfig.getUntrackedParameter<bool>("verbose",false)),
47  counter_(0),
49 {
50  LogDebug("GCT") << "GctDigiToRaw will pack FED Id " << fedId_;
51 
52  //register the products
53  produces<FEDRawDataCollection>();
54 }
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool packRctCalo_
Definition: GctDigiToRaw.h:62
edm::InputTag rctInputLabel_
Definition: GctDigiToRaw.h:57
edm::InputTag gctInputLabel_
Definition: GctDigiToRaw.h:58
GctFormatTranslateMCLegacy formatTranslator_
Definition: GctDigiToRaw.h:74
GctDigiToRaw::~GctDigiToRaw ( )

Definition at line 57 of file GctDigiToRaw.cc.

58 {
59  // do anything here that needs to be done at destruction time
60  // (e.g. close files, deallocate resources etc.)
61 }

Member Function Documentation

void GctDigiToRaw::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 217 of file GctDigiToRaw.cc.

218 {
219 }
void GctDigiToRaw::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 223 of file GctDigiToRaw.cc.

223  {
224 }
void GctDigiToRaw::print ( FEDRawData data)
private

Definition at line 203 of file GctDigiToRaw.cc.

References gather_cfg::cout, FEDRawData::data(), i, FEDRawData::size(), and w().

Referenced by produce().

203  {
204 
205  const unsigned char * d = data.data();
206 
207  for (unsigned int i=0; i<data.size(); i=i+4) {
208  uint32_t w = (uint32_t)d[i] + (uint32_t)(d[i+1]<<8) + (uint32_t)(d[i+2]<<16) + (uint32_t)(d[i+3]<<24);
209  cout << std::hex << std::setw(4) << i/4 << " " << std::setw(8) << w << endl;
210  }
211 
212 }
int i
Definition: DBlmapReader.cc:9
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
tuple cout
Definition: gather_cfg.py:121
T w() const
void GctDigiToRaw::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 70 of file GctDigiToRaw.cc.

References evf::compute_crc(), counter_, edm::EventID::event(), fedId_, formatTranslator_, gctInputLabel_, edm::Event::getByLabel(), edm::EventBase::id(), edm::InputTag::label(), LogDebug, packRctCalo_, packRctEm_, print(), edm::Event::put(), rctInputLabel_, FEDRawData::resize(), FEDTrailer::set(), FEDHeader::set(), GctFormatTranslateBase::setPackingBxId(), GctFormatTranslateBase::setPackingEventId(), AlCaHLTBitMon_QueryRunRegistry::string, verbose_, GctFormatTranslateMCLegacy::writeAllRctCaloRegionBlock(), GctFormatTranslateMCLegacy::writeGctOutEmAndEnergyBlock(), GctFormatTranslateMCLegacy::writeGctOutJetBlock(), and GctFormatTranslateMCLegacy::writeRctEmCandBlocks().

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

71 {
72  using namespace edm;
73 
74  counter_++; // To "simulate" bunch crossings for now...
75  unsigned int bx = counter_ % 3564; // What's the proper way of doing this?
76  EventNumber_t eventNumber = iEvent.id().event();
77 
78  // Supply bx and EvID to the packer so it can make internal capture block headers.
81 
82  // The GCT and RCT input label strings
83  const std::string gctInputLabelStr = gctInputLabel_.label();
84  const std::string rctInputLabelStr = rctInputLabel_.label();
85 
86  // get GCT digis
88  iEvent.getByLabel(gctInputLabelStr, "isoEm", isoEm);
90  iEvent.getByLabel(gctInputLabelStr, "nonIsoEm", nonIsoEm);
92  iEvent.getByLabel(gctInputLabelStr, "cenJets", cenJets);
94  iEvent.getByLabel(gctInputLabelStr, "forJets", forJets);
96  iEvent.getByLabel(gctInputLabelStr, "tauJets", tauJets);
98  iEvent.getByLabel(gctInputLabelStr, "", etTotal);
100  iEvent.getByLabel(gctInputLabelStr, "", etHad);
102  iEvent.getByLabel(gctInputLabelStr, "", etMiss);
104  iEvent.getByLabel(gctInputLabelStr, "", hfRingSums);
106  iEvent.getByLabel(gctInputLabelStr, "", hfBitCounts);
108  iEvent.getByLabel(gctInputLabelStr, "", htMiss);
110  iEvent.getByLabel(gctInputLabelStr, "", jetCounts);
111 
112  // get RCT EM Cand digi
113  bool packRctEmThisEvent = packRctEm_;
115  if(packRctEmThisEvent)
116  {
117  iEvent.getByLabel(rctInputLabelStr, rctEm);
118  if(rctEm.failedToGet())
119  {
120  packRctEmThisEvent = false;
121  LogDebug("GCT") << "RCT EM Candidate packing requested, but failed to get them from event!";
122  }
123  }
124 
125  // get RCT Calo region digi
126  bool packRctCaloThisEvent = packRctCalo_;
128  if(packRctCaloThisEvent)
129  {
130  iEvent.getByLabel(rctInputLabelStr, rctCalo);
131  if(rctCalo.failedToGet())
132  {
133  packRctCaloThisEvent = false;
134  LogDebug("GCT") << "RCT Calo Region packing requested, but failed to get them from event!";
135  }
136  }
137 
138  // create the raw data collection
139  std::auto_ptr<FEDRawDataCollection> rawColl(new FEDRawDataCollection());
140 
141  // get the GCT buffer
142  FEDRawData& fedRawData=rawColl->FEDData(fedId_);
143 
144  // set the size & make pointers to the header, beginning of payload, and footer.
145  unsigned int rawSize = 88; // MUST BE MULTIPLE OF 8! (slink packets are 64 bit, but using 8-bit data struct).
146  if(packRctEmThisEvent) { rawSize += 232; } // Space for RCT EM Cands.
147  if(packRctCaloThisEvent) { rawSize += 800; } // Space for RCT Calo Regions (plus a 32-bit word of padding to make divisible by 8)
148  fedRawData.resize(rawSize);
149  unsigned char * pHeader = fedRawData.data();
150  unsigned char * pPayload = pHeader + 16; // 16 = 8 for slink header + 8 for Greg's versioning header.
151  unsigned char * pFooter = pHeader + rawSize - 8;
152 
153  // Write CDF header (exactly as told by Marco Zanetti)
154  FEDHeader fedHeader(pHeader);
155  fedHeader.set(pHeader, 1, eventNumber, bx, fedId_); // what should the bx_ID be?
156 
157  // Pack GCT jet output digis
159  cenJets.product(),
160  forJets.product(),
161  tauJets.product(),
162  hfRingSums.product(),
163  hfBitCounts.product(),
164  htMiss.product());
165 
166  pPayload += 36; //advance payload pointer
167 
168  // Pack GCT EM and energy sums digis.
170  isoEm.product(),
171  nonIsoEm.product(),
172  etTotal.product(),
173  etHad.product(),
174  etMiss.product());
175 
176  pPayload += 28; //advance payload pointer
177 
178  // Pack RCT EM Cands
179  if(packRctEmThisEvent)
180  {
181  formatTranslator_.writeRctEmCandBlocks(pPayload, rctEm.product());
182  pPayload+=232; //advance payload pointer
183  }
184 
185  // Pack RCT Calo Regions
186  if(packRctCaloThisEvent)
187  {
188  formatTranslator_.writeAllRctCaloRegionBlock(pPayload, rctCalo.product());
189  }
190 
191  // Write CDF footer (exactly as told by Marco Zanetti)
192  FEDTrailer fedTrailer(pFooter);
193  fedTrailer.set(pFooter, rawSize/8, evf::compute_crc(pHeader, rawSize), 0, 0);
194 
195  // Debug output.
196  if (verbose_) { print(fedRawData); }
197 
198  // Put the collection in the event.
199  iEvent.put(rawColl);
200 }
#define LogDebug(id)
void setPackingEventId(uint32_t eventId)
void writeGctOutEmAndEnergyBlock(unsigned char *d, const L1GctEmCandCollection *iso, const L1GctEmCandCollection *nonIso, const L1GctEtTotalCollection *etTotal, const L1GctEtHadCollection *etHad, const L1GctEtMissCollection *etMiss)
Writes GCT output EM and energy sums block into an unsigned char array, starting at the position poin...
EventNumber_t event() const
Definition: EventID.h:44
void writeAllRctCaloRegionBlock(unsigned char *d, const L1CaloRegionCollection *rctCalo)
Writes the giant hack that is the RCT Calo Regions block.
unsigned int EventNumber_t
Definition: EventID.h:30
bool packRctCalo_
Definition: GctDigiToRaw.h:62
void writeRctEmCandBlocks(unsigned char *d, const L1CaloEmCollection *rctEm)
Writes the 4 RCT EM Candidate blocks.
void writeGctOutJetBlock(unsigned char *d, const L1GctJetCandCollection *cenJets, const L1GctJetCandCollection *forJets, const L1GctJetCandCollection *tauJets, const L1GctHFRingEtSumsCollection *hfRingSums, const L1GctHFBitCountsCollection *hfBitCounts, const L1GctHtMissCollection *htMiss)
Writes GCT output jet cands and counts into an unsigned char array, starting at the position pointed ...
edm::InputTag rctInputLabel_
Definition: GctDigiToRaw.h:57
void print(FEDRawData &data)
void resize(size_t newsize)
Definition: FEDRawData.cc:33
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
Definition: CRC16.h:67
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
edm::InputTag gctInputLabel_
Definition: GctDigiToRaw.h:58
void setPackingBxId(uint32_t bxId)
std::string const & label() const
Definition: InputTag.h:42
edm::EventID id() const
Definition: EventBase.h:56
GctFormatTranslateMCLegacy formatTranslator_
Definition: GctDigiToRaw.h:74

Member Data Documentation

int GctDigiToRaw::counter_
private

Definition at line 71 of file GctDigiToRaw.h.

Referenced by produce().

int GctDigiToRaw::fedId_
private

Definition at line 65 of file GctDigiToRaw.h.

Referenced by GctDigiToRaw(), and produce().

GctFormatTranslateMCLegacy GctDigiToRaw::formatTranslator_
private

Definition at line 74 of file GctDigiToRaw.h.

Referenced by produce().

edm::InputTag GctDigiToRaw::gctInputLabel_
private

Definition at line 58 of file GctDigiToRaw.h.

Referenced by produce().

bool GctDigiToRaw::packRctCalo_
private

Definition at line 62 of file GctDigiToRaw.h.

Referenced by produce().

bool GctDigiToRaw::packRctEm_
private

Definition at line 61 of file GctDigiToRaw.h.

Referenced by produce().

edm::InputTag GctDigiToRaw::rctInputLabel_
private

Definition at line 57 of file GctDigiToRaw.h.

Referenced by produce().

bool GctDigiToRaw::verbose_
private

Definition at line 68 of file GctDigiToRaw.h.

Referenced by produce().