CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/EventFilter/StorageManager/src/FaultyEventStreamHandler.cc

Go to the documentation of this file.
00001 // $Id: FaultyEventStreamHandler.cc,v 1.3 2011/03/07 15:31:32 mommsen Exp $
00003 
00004 #include "FWCore/Utilities/interface/Exception.h"
00005 
00006 #include "EventFilter/StorageManager/interface/Configuration.h"
00007 #include "EventFilter/StorageManager/interface/EventFileHandler.h"
00008 #include "EventFilter/StorageManager/interface/EventStreamConfigurationInfo.h"
00009 #include "EventFilter/StorageManager/interface/FaultyEventStreamHandler.h"
00010 #include "EventFilter/StorageManager/interface/FRDFileHandler.h"
00011 
00012 
00013 namespace stor {
00014   
00015   FaultyEventStreamHandler::FaultyEventStreamHandler
00016   (
00017     const SharedResourcesPtr sharedResources,
00018     const DbFileHandlerPtr dbFileHandler,
00019     const std::string& streamName
00020   ):
00021   StreamHandler(sharedResources, dbFileHandler),
00022   initMsgCollection_(sharedResources->initMsgCollection_)
00023   {
00024     streamRecord_->streamName = streamName;
00025     streamRecord_->fractionToDisk = 1;
00026   }
00027   
00028   
00029   StreamHandler::FileHandlerPtr
00030   FaultyEventStreamHandler::getFileHandler(const I2OChain& event)
00031   {
00032     // In the faulty event stream a new file is opened for each event.
00033     closeAllFiles();
00034     return newFileHandler(event);
00035   }
00036   
00037   
00038   StreamHandler::FileHandlerPtr
00039   FaultyEventStreamHandler::newFileHandler(const I2OChain& event)
00040   {
00041     FileHandlerPtr newFileHandler;
00042     FilesMonitorCollection::FileRecordPtr fileRecord = getNewFileRecord(event);
00043     
00044     // As each event can have a different outputModuleId, we need to 
00045     // determine the init msg for each event.
00046     // If this is not possible, use the FRD data format.
00047     try
00048     {
00049       InitMsgSharedPtr initMsgView =
00050         initMsgCollection_->getElementForOutputModule(
00051           initMsgCollection_->getOutputModuleName( event.outputModuleId() )
00052         );
00053       
00054       newFileHandler.reset(
00055         new EventFileHandler(initMsgView, fileRecord, dbFileHandler_,
00056           diskWritingParams_, 0)
00057       );
00058     }
00059     catch (stor::exception::IncompleteEventMessage& e) //faulty data event
00060     {
00061       newFileHandler.reset(
00062         new FRDFileHandler(fileRecord, dbFileHandler_, diskWritingParams_, 0)
00063       );
00064     }
00065     catch (stor::exception::WrongI2OMessageType& e) //faulty error event
00066     {
00067       newFileHandler.reset(
00068         new FRDFileHandler(fileRecord, dbFileHandler_, diskWritingParams_, 0)
00069       );
00070     }
00071     
00072     fileHandlers_.push_back(newFileHandler);
00073     
00074     return newFileHandler;
00075   }
00076   
00077 } // namespace stor
00078