CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/EventFilter/StorageManager/src/FaultyEventStreamHandler.cc

Go to the documentation of this file.
00001 // $Id: FaultyEventStreamHandler.cc,v 1.5 2012/04/20 10:48:02 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_->getElementForOutputModuleId( event.outputModuleId() );
00051       
00052       newFileHandler.reset(
00053         new EventFileHandler(initMsgView, fileRecord, dbFileHandler_, 0)
00054       );
00055     }
00056     catch (stor::exception::IncompleteEventMessage& e) //faulty data event
00057     {
00058       newFileHandler.reset(
00059         new FRDFileHandler(fileRecord, dbFileHandler_, 0)
00060       );
00061     }
00062     catch (stor::exception::WrongI2OMessageType& e) //faulty error event
00063     {
00064       newFileHandler.reset(
00065         new FRDFileHandler(fileRecord, dbFileHandler_, 0)
00066       );
00067     }
00068     
00069     fileHandlers_.push_back(newFileHandler);
00070     
00071     return newFileHandler;
00072   }
00073   
00074 } // namespace stor
00075