CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FRDEventOutputModule.h
Go to the documentation of this file.
1 #ifndef IOPool_Streamer_FRDEventOutputModule_h
2 #define IOPool_Streamer_FRDEventOutputModule_h
3 
8 
9 #include "boost/shared_array.hpp"
10 
11 class FRDEventMsgView;
12 template <class Consumer>
14 {
15  typedef unsigned int uint32;
23  public:
24  explicit FRDEventOutputModule(edm::ParameterSet const& ps);
26 
27  private:
28  virtual void write(edm::EventPrincipal const& e);
29  virtual void beginRun(edm::RunPrincipal const&);
30  virtual void endRun(edm::RunPrincipal const&);
31  virtual void writeRun(edm::RunPrincipal const&) {}
33 
34  std::auto_ptr<Consumer> templateConsumer_;
35  std::string label_;
36  std::string instance_;
37 };
38 
39 template <class Consumer>
41  edm::OutputModule(ps),
42  templateConsumer_(new Consumer(ps)),
43  label_(ps.getUntrackedParameter<std::string>("ProductLabel","source")),
44  instance_(ps.getUntrackedParameter<std::string>("ProductInstance",""))
45 {
46 }
47 
48 template <class Consumer>
50 
51 template <class Consumer>
53 
54  // serialize the FEDRawDataCollection into the format that we expect for
55  // FRDEventMsgView objects (may be better ways to do this)
56  edm::Event event(const_cast<edm::EventPrincipal&>(e), description());
58  event.getByLabel(label_, instance_, fedBuffers);
59 
60  // determine the expected size of the FRDEvent
61  int expectedSize = (4 + 1024) * sizeof(uint32);
62  for (int idx = 0; idx < 1024; ++idx) {
63  FEDRawData singleFED = fedBuffers->FEDData(idx);
64  expectedSize += singleFED.size();
65  //if (singleFED.size() > 0) {
66  // std::cout << "FED #" << idx << " size = " << singleFED.size() << std::endl;
67  //}
68  }
69 
70  // build the FRDEvent into a temporary buffer
71  boost::shared_array<unsigned char> workBuffer(new unsigned char[expectedSize + 256]);
72  uint32 *bufPtr = (uint32*) workBuffer.get();
73  *bufPtr++ = (uint32) 2; // version number
74  *bufPtr++ = (uint32) event.id().run();
75  *bufPtr++ = (uint32) event.luminosityBlock();
76  *bufPtr++ = (uint32) event.id().event();
77  for (int idx = 0; idx < 1024; ++idx) {
78  FEDRawData singleFED = fedBuffers->FEDData(idx);
79  *bufPtr++ = singleFED.size();
80  }
81  for (int idx = 0; idx < 1024; ++idx) {
82  FEDRawData singleFED = fedBuffers->FEDData(idx);
83  if (singleFED.size() > 0) {
84  memcpy(bufPtr, singleFED.data(), singleFED.size());
85  *bufPtr += singleFED.size();
86  }
87  }
88 
89  // create the FRDEventMsgView and use the template consumer to write it out
90  FRDEventMsgView msg(workBuffer.get());
91  templateConsumer_->doOutputEvent(msg);
92 }
93 
94 template <class Consumer>
96 {
97  templateConsumer_->start();
98 }
99 
100 template <class Consumer>
102 {
103  templateConsumer_->stop();
104 }
105 
106 #endif
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
FRDEventOutputModule(edm::ParameterSet const &ps)
virtual void writeRun(edm::RunPrincipal const &)
virtual void write(edm::EventPrincipal const &e)
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
std::auto_ptr< Consumer > templateConsumer_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
unsigned int uint32
Definition: MsgTools.h:13
tuple description
Definition: idDealer.py:66
edm::EventID id() const
Definition: EventBase.h:56
virtual void writeLuminosityBlock(edm::LuminosityBlockPrincipal const &)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
virtual void beginRun(edm::RunPrincipal const &)
virtual void endRun(edm::RunPrincipal const &)