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 Attributes | Static Private Attributes
edm::FUShmOutputModule Class Reference

#include <FUShmOutputModule.h>

Inheritance diagram for edm::FUShmOutputModule:
evf::OutputModule

Public Member Functions

void clearDatasetCounts ()
 
void countEventForDatasets (EventMsgView const &eventMessage)
 
void doOutputEvent (EventMsgBuilder const &eventMessage)
 
void doOutputHeader (InitMsgBuilder const &initMessage)
 
 FUShmOutputModule (edm::ParameterSet const &ps)
 
unsigned int getCounts ()
 
std::vector< unsigned int > & getDatasetCounts ()
 
std::vector< std::string > getDatasetNames ()
 
std::string getStreamId ()
 
void insertStreamAndDatasetInfo (edm::ParameterSet &streams, edm::ParameterSet datasets)
 
void parseDatasets (InitMsgView const &initMessage)
 
void sendPostponedInitMsg ()
 
void sendPostponedStart ()
 
void setNExpectedEPs (unsigned int EPs)
 
void setPostponeInitMsg ()
 
void start ()
 
void stop ()
 
void unregisterFromShm ()
 
 ~FUShmOutputModule ()
 

Static Public Member Functions

static void fillDescription (ParameterSetDescription &)
 

Private Attributes

unsigned int count_
 
std::vector< unsigned int > datasetCounts_
 
std::vector< StringsdatasetPaths_
 
std::vector< std::pair
< std::string,
edm::EventSelector * > > 
dpEventSelectors_
 
std::string name_
 
unsigned int nExpectedEPs_
 
unsigned int numDatasets_
 
std::vector< std::string > selectedDatasetNames_
 
evf::FUShmBuffershmBuffer_
 
std::string streamId_
 
unsigned int totalPaths_
 

Static Private Attributes

static uint32 fuGuidValue_ = 0
 
static bool fuIdsInitialized_ = false
 

Detailed Description

Definition at line 59 of file FUShmOutputModule.h.

Constructor & Destructor Documentation

edm::FUShmOutputModule::FUShmOutputModule ( edm::ParameterSet const &  ps)

Definition at line 44 of file FUShmOutputModule.cc.

References FDEBUG, fuGuidValue_, fuIdsInitialized_, dttmaxenums::L, name_, AlCaHLTBitMon_QueryRunRegistry::string, and edm::Guid::toString().

44  :
45  shmBuffer_(0)
46  , name_(ps.getParameter<std::string>( "@module_label" ))
47  , count_(0)
48  , nExpectedEPs_(0)
49  , numDatasets_(0)
50  , streamId_()
51  {
52  FDEBUG(9) << "FUShmOutputModule: constructor" << endl;
54  edm::Service<evf::ShmOutputModuleRegistry>()->registerModule(name_, this);
55  if (! fuIdsInitialized_) {
56  fuIdsInitialized_ = true;
57 
58  edm::Guid guidObj(true);
59  std::string guidString = guidObj.toString();
60 
61  uLong crc = crc32(0L, Z_NULL, 0);
62  Bytef* buf = (Bytef*)guidString.data();
63  crc = crc32(crc, buf, guidString.length());
64  fuGuidValue_ = crc;
65  }
66  }
#define FDEBUG(lev)
Definition: DebugMacros.h:18
Definition: Guid.h:23
evf::FUShmBuffer * shmBuffer_
edm::FUShmOutputModule::~FUShmOutputModule ( )

Definition at line 68 of file FUShmOutputModule.cc.

References SM_SharedMemoryHandle::detachShmBuffer(), FDEBUG, and sm_sharedmemory.

69  {
70  FDEBUG(9) << "FUShmOutputModule: FUShmOutputModule destructor" << endl;
72  //shmdt(shmBuffer_);
73  }
#define FDEBUG(lev)
Definition: DebugMacros.h:18
static SM_SharedMemoryHandle sm_sharedmemory

Member Function Documentation

void edm::FUShmOutputModule::clearDatasetCounts ( )
inline

Definition at line 80 of file FUShmOutputModule.h.

References datasetCounts_, and i.

80  {
81  for (unsigned int i=0;i<datasetCounts_.size();i++) datasetCounts_[i]=0;
82  }
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned int > datasetCounts_
void edm::FUShmOutputModule::countEventForDatasets ( EventMsgView const &  eventMessage)

Definition at line 202 of file FUShmOutputModule.cc.

References datasetCounts_, dpEventSelectors_, EventMsgView::hltTriggerBits(), i, numDatasets_, edm::second(), and totalPaths_.

Referenced by doOutputEvent().

203  {
204  if (!numDatasets_) return;
205  uint8 hlt_out[totalPaths_];
206  eventMessage.hltTriggerBits( hlt_out );
207  for (size_t i=0;i<numDatasets_;i++) {
208  if ( dpEventSelectors_[i].second->acceptEvent( hlt_out, totalPaths_)) {
209  datasetCounts_[i]++;
210  }
211  }
212  }
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned int > datasetCounts_
U second(std::pair< T, U > const &p)
std::vector< std::pair< std::string, edm::EventSelector * > > dpEventSelectors_
unsigned char uint8
Definition: MsgTools.h:11
void edm::FUShmOutputModule::doOutputEvent ( EventMsgBuilder const &  eventMessage)

Definition at line 133 of file FUShmOutputModule.cc.

References count_, countEventForDatasets(), FDEBUG, fuGuidValue_, SM_SharedMemoryHandle::getShmBuffer(), run_regression::ret, shmBuffer_, EventMsgBuilder::size(), findQualityFiles::size, sm_sharedmemory, EventMsgBuilder::startAddress(), and evf::FUShmBuffer::writeRecoEventData().

134  {
135  if(!shmBuffer_) edm::LogError("FUShmOutputModule")
136  << " Invalid shared memory buffer at first event"
137  << " Make sure you configure the ResourceBroker before the FUEventProcessor! "
138  << " No event is sent - this is fatal! Should throw here";
139  else
140  {
141  count_++;
142  unsigned char* buffer = (unsigned char*) eventMessage.startAddress();
143  unsigned int size = eventMessage.size();
144  EventMsgView eventView(eventMessage.startAddress());
145  countEventForDatasets(eventView);
146  unsigned int runid = eventView.run();
147  unsigned int eventid = eventView.event();
148  unsigned int outModId = eventView.outModId();
149  FDEBUG(10) << "FUShmOutputModule: event size = " << size << std::endl;
150  //bool ret = shmBuffer_->writeRecoEventData(runid, eventid, outModId, buffer, size);
151  bool ret = sm_sharedmemory.getShmBuffer()->writeRecoEventData(runid, eventid, outModId, getpid(), fuGuidValue_, buffer, size);
152  if(!ret) edm::LogError("FUShmOutputModule") << " Error with writing data to ShmBuffer";
153  }
154  }
bool writeRecoEventData(unsigned int runNumber, unsigned int evtNumber, unsigned int outModId, unsigned int fuProcessId, unsigned int fuGuid, unsigned char *data, unsigned int dataSize)
Definition: FUShmBuffer.cc:714
#define FDEBUG(lev)
Definition: DebugMacros.h:18
evf::FUShmBuffer * getShmBuffer()
static SM_SharedMemoryHandle sm_sharedmemory
void countEventForDatasets(EventMsgView const &eventMessage)
tuple size
Write out results.
evf::FUShmBuffer * shmBuffer_
void edm::FUShmOutputModule::doOutputHeader ( InitMsgBuilder const &  initMessage)

Definition at line 109 of file FUShmOutputModule.cc.

References count_, FDEBUG, fuGuidValue_, SM_SharedMemoryHandle::getShmBuffer(), nExpectedEPs_, InitMsgView::outputModuleId(), parseDatasets(), run_regression::ret, shmBuffer_, InitMsgBuilder::size(), findQualityFiles::size, sm_sharedmemory, InitMsgBuilder::startAddress(), and evf::FUShmBuffer::writeRecoInitMsg().

110  {
111  unsigned char* buffer = (unsigned char*) initMessage.startAddress();
112  unsigned int size = initMessage.size();
113  InitMsgView dummymsg(buffer);
114  parseDatasets(dummymsg);
115  count_ = 0;
117  if(!shmBuffer_) edm::LogError("FUShmOutputModule")
118  << " Error getting shared memory buffer for INIT. "
119  << " Make sure you configure the ResourceBroker before the FUEventProcessor! "
120  << " No INIT is sent - this is probably fatal!";
121  if(shmBuffer_)
122  {
123  FDEBUG(10) << "writing out INIT message with size = " << size << std::endl;
124  // no method in InitMsgBuilder to get the output module id, recast
125  uint32 dmoduleId = dummymsg.outputModuleId();
126 
127  //bool ret = shmBuffer_->writeRecoInitMsg(dmoduleId, buffer, size);
128  bool ret = sm_sharedmemory.getShmBuffer()->writeRecoInitMsg(dmoduleId, getpid(), fuGuidValue_, buffer, size,nExpectedEPs_);
129  if(!ret) edm::LogError("FUShmOutputModule") << " Error writing preamble to ShmBuffer";
130  }
131  }
#define FDEBUG(lev)
Definition: DebugMacros.h:18
bool writeRecoInitMsg(unsigned int outModId, unsigned int fuProcessId, unsigned int fuGuid, unsigned char *data, unsigned int dataSize, unsigned int nExpectedEPs)
Definition: FUShmBuffer.cc:693
evf::FUShmBuffer * getShmBuffer()
unsigned int uint32
Definition: MsgTools.h:13
static SM_SharedMemoryHandle sm_sharedmemory
tuple size
Write out results.
void parseDatasets(InitMsgView const &initMessage)
evf::FUShmBuffer * shmBuffer_
void edm::FUShmOutputModule::fillDescription ( ParameterSetDescription description)
static

Definition at line 104 of file FUShmOutputModule.cc.

105  {
106  }
unsigned int edm::FUShmOutputModule::getCounts ( )
inlinevirtual

Implements evf::OutputModule.

Definition at line 69 of file FUShmOutputModule.h.

References count_.

69  {
70  return count_;
71  }
std::vector<unsigned int>& edm::FUShmOutputModule::getDatasetCounts ( )
inline

Definition at line 79 of file FUShmOutputModule.h.

References datasetCounts_.

79 {return datasetCounts_;}
std::vector< unsigned int > datasetCounts_
std::vector<std::string> edm::FUShmOutputModule::getDatasetNames ( )
inline

Definition at line 78 of file FUShmOutputModule.h.

References selectedDatasetNames_.

Referenced by evf::ShmOutputModuleRegistry::updateDatasetInfo().

78 {return selectedDatasetNames_;}
std::vector< std::string > selectedDatasetNames_
std::string edm::FUShmOutputModule::getStreamId ( )
inline

Definition at line 83 of file FUShmOutputModule.h.

References streamId_.

Referenced by evf::ShmOutputModuleRegistry::updateDatasetInfo().

83 {return streamId_;}
void edm::FUShmOutputModule::insertStreamAndDatasetInfo ( edm::ParameterSet streams,
edm::ParameterSet  datasets 
)

Definition at line 75 of file FUShmOutputModule.cc.

References datasetPaths_, edm::ParameterSet::getParameter(), i, name_, numDatasets_, selectedDatasetNames_, streamId_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by evf::ShmOutputModuleRegistry::insertStreamAndDatasetInfo().

76  {
77  if (numDatasets_) return;
78  try {
79  //compose dataset name string
80  if (name_.size() > std::string("hltOutput").size() && name_.find("hltOutput")!=std::string::npos)
81  streamId_=name_.substr(name_.find("hltOutput")+std::string("hltOutput").size());
82  else return;
83 
84  //make local copy of dataset definitions
85  if (streamId_.size()) {
86  Strings streamDatasetList = streams.getParameter<Strings>(streamId_);
87  for (size_t i=0;i<streamDatasetList.size();i++) {
88  selectedDatasetNames_.push_back(streamDatasetList[i]);
89  Strings thisDatasetPaths = datasets.getParameter<Strings>(streamDatasetList[i]);
90  datasetPaths_.push_back(thisDatasetPaths);
91  numDatasets_++;
92  }
93  }
94  }
95  catch (...) {
96  //not present:ignore
97  selectedDatasetNames_.clear();
98  datasetPaths_.clear();
99  numDatasets_=0;
101  }
102  }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > selectedDatasetNames_
std::vector< std::string > Strings
Definition: MsgTools.h:18
std::vector< Strings > datasetPaths_
void edm::FUShmOutputModule::parseDatasets ( InitMsgView const &  initMessage)

Definition at line 185 of file FUShmOutputModule.cc.

References datasetCounts_, datasetPaths_, dpEventSelectors_, InitMsgView::hltTriggerNames(), i, numDatasets_, selectedDatasetNames_, AlCaHLTBitMon_QueryRunRegistry::string, and totalPaths_.

Referenced by doOutputHeader().

186  {
187  //reset counter
188  for (size_t i=0;i<datasetCounts_.size();i++) datasetCounts_[i]=0;
189  if (!numDatasets_) return;
190  if (dpEventSelectors_.size()) return;
191  Strings allPaths;
192  initMessage.hltTriggerNames(allPaths);
193  totalPaths_ = allPaths.size();
194  for (size_t i=0;i<numDatasets_;i++)
195  {
196  dpEventSelectors_.push_back(std::pair<std::string,
198  datasetCounts_.push_back(0);
199  }
200  }
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > selectedDatasetNames_
std::vector< std::string > Strings
Definition: MsgTools.h:18
std::vector< unsigned int > datasetCounts_
std::vector< Strings > datasetPaths_
std::vector< std::pair< std::string, edm::EventSelector * > > dpEventSelectors_
void edm::FUShmOutputModule::sendPostponedInitMsg ( )
void edm::FUShmOutputModule::sendPostponedStart ( )
void edm::FUShmOutputModule::setNExpectedEPs ( unsigned int  EPs)

Definition at line 174 of file FUShmOutputModule.cc.

References nExpectedEPs_.

174  {
175  nExpectedEPs_ = EPs;
176  }
void edm::FUShmOutputModule::setPostponeInitMsg ( )
void edm::FUShmOutputModule::start ( void  )

Definition at line 156 of file FUShmOutputModule.cc.

References SM_SharedMemoryHandle::getShmBuffer(), shmBuffer_, and sm_sharedmemory.

Referenced by progressbar.ProgressBar::__next__(), Types.LuminosityBlockRange::cppID(), and Types.EventRange::cppID().

157  {
158  //shmBuffer_ = evf::FUShmBuffer::getShmBuffer();
160  if(0==shmBuffer_)
161  edm::LogError("FUShmOutputModule")<<"Failed to attach to shared memory";
162  }
evf::FUShmBuffer * getShmBuffer()
static SM_SharedMemoryHandle sm_sharedmemory
evf::FUShmBuffer * shmBuffer_
void edm::FUShmOutputModule::stop ( )

Definition at line 164 of file FUShmOutputModule.cc.

References SM_SharedMemoryHandle::detachShmBuffer(), FDEBUG, shmBuffer_, and sm_sharedmemory.

165  {
166  FDEBUG(9) << "FUShmOutputModule: sending terminate run" << std::endl;
167  if(0!=shmBuffer_){
169  //shmdt(shmBuffer_);
170  shmBuffer_ = 0;
171  }
172  }
#define FDEBUG(lev)
Definition: DebugMacros.h:18
static SM_SharedMemoryHandle sm_sharedmemory
evf::FUShmBuffer * shmBuffer_
void edm::FUShmOutputModule::unregisterFromShm ( )

Definition at line 178 of file FUShmOutputModule.cc.

References SM_SharedMemoryHandle::getBufferRef(), evf::FUShmBuffer::removeClientPrcId(), shmBuffer_, and sm_sharedmemory.

178  {
180  if (0!=shmBuffer_) {
181  shmBuffer_->removeClientPrcId(getpid());
182  }
183  }
bool removeClientPrcId(pid_t prcId)
evf::FUShmBuffer * getBufferRef()
static SM_SharedMemoryHandle sm_sharedmemory
evf::FUShmBuffer * shmBuffer_

Member Data Documentation

unsigned int edm::FUShmOutputModule::count_
private

Definition at line 96 of file FUShmOutputModule.h.

Referenced by doOutputEvent(), doOutputHeader(), and getCounts().

std::vector<unsigned int> edm::FUShmOutputModule::datasetCounts_
private
std::vector<Strings> edm::FUShmOutputModule::datasetPaths_
private

Definition at line 107 of file FUShmOutputModule.h.

Referenced by insertStreamAndDatasetInfo(), and parseDatasets().

std::vector<std::pair<std::string,edm::EventSelector*> > edm::FUShmOutputModule::dpEventSelectors_
private

Definition at line 108 of file FUShmOutputModule.h.

Referenced by countEventForDatasets(), and parseDatasets().

uint32 edm::FUShmOutputModule::fuGuidValue_ = 0
staticprivate

Definition at line 99 of file FUShmOutputModule.h.

Referenced by doOutputEvent(), doOutputHeader(), and FUShmOutputModule().

bool edm::FUShmOutputModule::fuIdsInitialized_ = false
staticprivate

Initialize the static variables for the filter unit identifiers.

Definition at line 98 of file FUShmOutputModule.h.

Referenced by FUShmOutputModule().

std::string edm::FUShmOutputModule::name_
private

Definition at line 95 of file FUShmOutputModule.h.

Referenced by FUShmOutputModule(), and insertStreamAndDatasetInfo().

unsigned int edm::FUShmOutputModule::nExpectedEPs_
private

Definition at line 100 of file FUShmOutputModule.h.

Referenced by doOutputHeader(), and setNExpectedEPs().

unsigned int edm::FUShmOutputModule::numDatasets_
private
std::vector<std::string> edm::FUShmOutputModule::selectedDatasetNames_
private

Definition at line 106 of file FUShmOutputModule.h.

Referenced by getDatasetNames(), insertStreamAndDatasetInfo(), and parseDatasets().

evf::FUShmBuffer* edm::FUShmOutputModule::shmBuffer_
private

Definition at line 94 of file FUShmOutputModule.h.

Referenced by doOutputEvent(), doOutputHeader(), start(), stop(), and unregisterFromShm().

std::string edm::FUShmOutputModule::streamId_
private

Definition at line 111 of file FUShmOutputModule.h.

Referenced by getStreamId(), and insertStreamAndDatasetInfo().

unsigned int edm::FUShmOutputModule::totalPaths_
private

Definition at line 109 of file FUShmOutputModule.h.

Referenced by countEventForDatasets(), and parseDatasets().