Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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 #include "EventFilter/CTPPSRawToDigi/interface/SimpleVFATFrameCollection.h"
0010 
0011 using namespace std;
0012 
0013 SimpleVFATFrameCollection::SimpleVFATFrameCollection() {}
0014 
0015 SimpleVFATFrameCollection::~SimpleVFATFrameCollection() { data.clear(); }
0016 
0017 const VFATFrame* SimpleVFATFrameCollection::GetFrameByID(unsigned int ID) const {
0018   // first convert ID to 12bit form
0019   ID = ID & 0xFFF;
0020 
0021   for (MapType::const_iterator it = data.begin(); it != data.end(); ++it)
0022     if (it->second.getChipID() == ID)
0023       if (it->second.checkFootprint() && it->second.checkCRC())
0024         return &(it->second);
0025 
0026   return nullptr;
0027 }
0028 
0029 const VFATFrame* SimpleVFATFrameCollection::GetFrameByIndex(TotemFramePosition index) const {
0030   MapType::const_iterator it = data.find(index);
0031   if (it != data.end())
0032     return &(it->second);
0033   else
0034     return nullptr;
0035 }
0036 
0037 VFATFrameCollection::value_type SimpleVFATFrameCollection::BeginIterator() const {
0038   MapType::const_iterator it = data.begin();
0039   return (it == data.end()) ? value_type(TotemFramePosition(), nullptr) : value_type(it->first, &it->second);
0040 }
0041 
0042 VFATFrameCollection::value_type SimpleVFATFrameCollection::NextIterator(const value_type& value) const {
0043   if (!value.second)
0044     return value;
0045 
0046   MapType::const_iterator it = data.find(value.first);
0047   it++;
0048 
0049   return (it == data.end()) ? value_type(TotemFramePosition(), nullptr) : value_type(it->first, &it->second);
0050 }
0051 
0052 bool SimpleVFATFrameCollection::IsEndIterator(const value_type& value) const { return (value.second == nullptr); }