Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:14:45

0001 /****************************************************************************
0002 *
0003 * This is a part of the TOTEM offline software.
0004 * Authors: 
0005 *   Jan Kašpar (jan.kaspar@gmail.com) 
0006 *    
0007 ****************************************************************************/
0008 
0009 #ifndef EventFilter_CTPPSRawToDigi_VFATFrameCollection
0010 #define EventFilter_CTPPSRawToDigi_VFATFrameCollection
0011 
0012 #include "CondFormats/PPSObjects/interface/TotemFramePosition.h"
0013 
0014 #include "EventFilter/CTPPSRawToDigi/interface/VFATFrame.h"
0015 
0016 #include <string>
0017 
0018 /**
0019  * Interface class for VFAT-frame collections.
0020 **/
0021 class VFATFrameCollection {
0022 public:
0023   VFATFrameCollection() {}
0024   virtual ~VFATFrameCollection() {}
0025 
0026   /// returns pointer to frame with ID, performs NO duplicity check (if there is precisely one frame with this 12bit ID)
0027   virtual const VFATFrame* GetFrameByID(unsigned int ID) const = 0;
0028 
0029   /// returns frame at given position in Slink frame
0030   virtual const VFATFrame* GetFrameByIndex(TotemFramePosition index) const = 0;
0031 
0032   /// returns frame at given position in Slink frame and checks 12bit ID
0033   virtual const VFATFrame* GetFrameByIndexID(TotemFramePosition index, unsigned int ID);
0034 
0035   /// return the number of VFAT frames in the collection
0036   virtual unsigned int Size() const = 0;
0037 
0038   /// returns whether the collection is empty
0039   virtual bool Empty() const = 0;
0040 
0041   /// pair: frame DAQ position, frame data
0042   typedef std::pair<TotemFramePosition, const VFATFrame*> value_type;
0043 
0044   /// the VFATFrameCollection interator
0045   class Iterator {
0046   protected:
0047     /// interator value
0048     value_type value;
0049 
0050     /// the pointer to the collection
0051     const VFATFrameCollection* collection;
0052 
0053   public:
0054     /// constructor, automatically sets the iterator to the beginning
0055     Iterator(const VFATFrameCollection* c = nullptr) : collection(c) {
0056       if (collection)
0057         value = collection->BeginIterator();
0058     }
0059 
0060     /// returns the DAQ position of the current element
0061     TotemFramePosition Position() { return value.first; }
0062 
0063     /// returns the frame data of the current element
0064     const VFATFrame* Data() { return value.second; }
0065 
0066     /// shifts the iterator
0067     void Next() { value = collection->NextIterator(value); }
0068 
0069     /// returns whether the iterator points over the end of the collection
0070     bool IsEnd() { return collection->IsEndIterator(value); }
0071   };
0072 
0073 protected:
0074   /// returns the beginning of the collection
0075   virtual value_type BeginIterator() const = 0;
0076 
0077   /// shifts the iterator
0078   virtual value_type NextIterator(const value_type&) const = 0;
0079 
0080   /// checks whether the iterator points over the end of the collection
0081   virtual bool IsEndIterator(const value_type&) const = 0;
0082 };
0083 
0084 #endif