Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "UnpackerFactory.h"
0002 
0003 #include "FWCore/Utilities/interface/EDMException.h"
0004 
0005 #include <cmath>
0006 
0007 EDM_REGISTER_PLUGINFACTORY(l1t::UnpackerFactoryT, "UnpackerFactory");
0008 
0009 namespace l1t {
0010   const UnpackerFactory UnpackerFactory::instance_;
0011 
0012   void getBXRange(int nbx, int& first, int& last) {
0013     last = std::floor(nbx / 2.);
0014     first = std::min(0, -last + (1 - nbx % 2));
0015   }
0016 
0017   std::shared_ptr<Unpacker> UnpackerFactory::make(const std::string& name) const {
0018     auto unpacker = std::shared_ptr<Unpacker>(UnpackerFactoryT::get()->create("l1t::" + name));
0019 
0020     if (unpacker.get() == nullptr) {
0021       throw edm::Exception(edm::errors::Configuration, "NoSourceModule") << "Cannot find an unpacker named " << name;
0022     }
0023 
0024     return unpacker;
0025   }
0026 }  // namespace l1t