CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/EventFilter/ResourceBroker/interface/FUResource.h

Go to the documentation of this file.
00001 #ifndef FURESOURCE_H
00002 #define FURESOURCE_H 1
00003 
00004 
00005 #include "EventFilter/ResourceBroker/interface/FUTypes.h"
00006 #include "EventFilter/ShmBuffer/interface/FUShmRawCell.h"
00007 #include "EventFilter/Utilities/interface/Exception.h"
00008 
00009 #include "log4cplus/logger.h"
00010 #include "toolbox/mem/Reference.h"
00011 
00012 #include <vector>
00013 
00014 namespace xdaq {
00015   class Application;
00016 }
00017 
00018 
00019 namespace evf {
00020 
00021   class EvffedFillerRB;
00022   
00023   class FUResource
00024   {
00025   public:
00026     //
00027     // construction/destruction
00028     //
00029     FUResource(UInt_t fuResourceId
00030                , log4cplus::Logger
00031                , EvffedFillerRB *
00032                , xdaq::Application *);
00033     virtual ~FUResource();
00034     
00035     
00036     //
00037     // member functions
00038     //
00039     void   allocate(FUShmRawCell* shmCell);
00040     void   release();   
00041 
00042     void   process(MemRef_t* bufRef);
00043     void   processDataBlock(MemRef_t* bufRef) throw (evf::Exception);
00044     void   checkDataBlockPayload(MemRef_t* bufRef) throw (evf::Exception);
00045     void   appendBlockToSuperFrag(MemRef_t* bufRef);
00046     void   removeLastAppendedBlockFromSuperFrag();
00047     
00048     void   superFragSize()        throw (evf::Exception);
00049     void   fillSuperFragPayload() throw (evf::Exception);
00050     void   findFEDs()             throw (evf::Exception);
00051     
00052     void   releaseSuperFrag();
00053 
00054     static
00055     void   doFedIdCheck(bool doFedIdCheck) { doFedIdCheck_=doFedIdCheck; }
00056     static
00057     void   useEvmBoard(bool useEvmBoard)   { useEvmBoard_ =useEvmBoard; }
00058     void   doCrcCheck(bool doCrcCheck)     { doCrcCheck_  =doCrcCheck; }
00059     
00060     bool   crcBeingChecked() { return doCrcCheck_; }
00061 
00062     bool   fatalError()   const { return fatalError_; }
00063     bool   isAllocated()  const { return 0!=shmCell_; }
00064     bool   isComplete()   const;
00065         
00066     UInt_t fuResourceId() const { return fuResourceId_; }
00067     UInt_t buResourceId() const { return buResourceId_; }
00068     UInt_t evtNumber()    const { return evtNumber_; }
00069     
00070     UInt_t nbSent()       const  { return nbSent_; }
00071     void   incNbSent()           { nbSent_++; }
00072     
00073     UInt_t nbErrors(bool reset=true);
00074     UInt_t nbCrcErrors(bool reset=true);
00075     UInt_t nbBytes(bool reset=true);
00076 
00077     evf::FUShmRawCell* shmCell() { return shmCell_; }
00078 
00079     void scheduleCRCError(){nextEventWillHaveCRCError_ = true;}
00080     
00081   private:
00082     //
00083     // member data
00084     //
00085     log4cplus::Logger log_;
00086     
00087     static
00088     bool      doFedIdCheck_;
00089     static
00090     bool      useEvmBoard_;    
00091     bool      doCrcCheck_;
00092     bool      fatalError_;
00093 
00094     UInt_t    fuResourceId_;
00095     UInt_t    buResourceId_;
00096     UInt_t    evtNumber_;
00097     
00098     MemRef_t* superFragHead_;
00099     MemRef_t* superFragTail_;
00100 
00101     UInt_t    eventPayloadSize_;
00102     UInt_t    nFedMax_;
00103     UInt_t    nSuperFragMax_;
00104     
00105     UInt_t    iBlock_;
00106     UInt_t    nBlock_;
00107     UInt_t    iSuperFrag_;
00108     UInt_t    nSuperFrag_;
00109     
00110     UInt_t    nbSent_;
00111     
00112     UInt_t    nbErrors_;
00113     UInt_t    nbCrcErrors_;
00114     UInt_t    nbBytes_;
00115 
00116     UInt_t    fedSize_[1024];
00117     UInt_t    superFragSize_;
00118     UInt_t    eventSize_;
00119     
00120     evf::FUShmRawCell* shmCell_;
00121     EvffedFillerRB *frb_;    
00122 
00123     xdaq::Application *app_;
00124 
00125     bool      nextEventWillHaveCRCError_;
00126 
00127     static unsigned int gtpDaqId_;
00128     static unsigned int gtpEvmId_;
00129     static unsigned int gtpeId_;
00130 
00131   };
00132   
00133   //
00134   // typedefs
00135   //
00136   typedef std::vector<FUResource*> FUResourceVec_t;
00137 
00138   
00139 } // namespace evf
00140 
00141 
00142 //
00143 // implementation of inline functions
00144 //
00145 inline
00146 bool evf::FUResource::isComplete() const
00147 {
00148   return (nBlock_&&nSuperFrag_&&(iSuperFrag_==nSuperFrag_)&&(iBlock_==nBlock_));
00149 }
00150 
00151 
00152 #endif