Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:29

0001 /****************************************************************************
0002 *
0003 * This is a part of the TOTEM offline software.
0004 * Authors: 
0005 *   Mate Csanad (mate.csanad@cern.ch)
0006 *   Jan Kašpar (jan.kaspar@gmail.com) 
0007 *    
0008 ****************************************************************************/
0009 
0010 #ifndef EventFilter_CTPPSRawToDigi_SimpleVFATFrameCollection
0011 #define EventFilter_CTPPSRawToDigi_SimpleVFATFrameCollection
0012 
0013 #include "EventFilter/CTPPSRawToDigi/interface/VFATFrameCollection.h"
0014 #include "CondFormats/PPSObjects/interface/TotemT2FramePosition.h"
0015 
0016 #include <map>
0017 
0018 /**
0019  * A basic implementation of VFAT frame collection, as map: TotemFramePosition --> VFATFrame.
0020 **/
0021 class SimpleVFATFrameCollection : public VFATFrameCollection {
0022 protected:
0023   typedef std::map<TotemFramePosition, VFATFrame> MapType;
0024 
0025   MapType data;
0026 
0027   value_type BeginIterator() const override;
0028   value_type NextIterator(const value_type&) const override;
0029   bool IsEndIterator(const value_type&) const override;
0030 
0031 public:
0032   SimpleVFATFrameCollection();
0033   ~SimpleVFATFrameCollection() override;
0034 
0035   const VFATFrame* GetFrameByID(unsigned int ID) const override;
0036   const VFATFrame* GetFrameByIndex(TotemFramePosition index) const override;
0037 
0038   unsigned int Size() const override { return data.size(); }
0039 
0040   bool Empty() const override { return (data.empty()); }
0041 
0042   void Insert(const TotemFramePosition& index, const VFATFrame& frame) { data.insert({index, frame}); }
0043   void Insert(const TotemT2FramePosition& index, const VFATFrame& frame) {
0044     data.insert({TotemFramePosition(index.getRawPosition()), frame});
0045   }
0046   /// inserts an empty (default) frame to the given position and returns pointer to the frame
0047   VFATFrame* InsertEmptyFrame(TotemFramePosition index) { return &data.insert({index, VFATFrame()}).first->second; }
0048 
0049   /// cleans completely the collection
0050   void Clear() { data.clear(); }
0051 };
0052 
0053 #endif