Skip to content

Commit

Permalink
Merge branch 'l1t-devel-CMSSW_7_1_0_pre8' of github.com:cms-l1t-offli…
Browse files Browse the repository at this point in the history
…ne/cmssw into from-CMSSW_7_1_0_pre8
  • Loading branch information
Sam-Harper committed Jun 10, 2014
2 parents d80cf00 + f058452 commit 6739b04
Show file tree
Hide file tree
Showing 41 changed files with 595 additions and 506 deletions.
1 change: 0 additions & 1 deletion EventFilter/L1TRawToDigi/interface/BasePacker.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace l1t {
class BasePacker {
public:
virtual Blocks pack(const edm::Event&) = 0;
virtual void fetchToken(L1TDigiToRaw*) = 0;
};
}

Expand Down
4 changes: 0 additions & 4 deletions EventFilter/L1TRawToDigi/interface/BaseUnpacker.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
#ifndef BaseUnpacker_h
#define BaseUnpacker_h

#include "EventFilter/L1TRawToDigi/interface/UnpackerCollections.h"

namespace l1t {
class BaseUnpacker {
public:
// Returns successful read
virtual bool unpack(const unsigned char *data, const unsigned blockid, const unsigned size) = 0;
// Obtain the collection(s) to unpack into
virtual void setCollections(UnpackerCollections& coll) = 0;
};
}

Expand Down
16 changes: 8 additions & 8 deletions EventFilter/L1TRawToDigi/interface/L1TDigiToRaw.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/one/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

Expand All @@ -35,24 +35,24 @@
#include "EventFilter/L1TRawToDigi/interface/PackerFactory.h"

namespace l1t {
class L1TDigiToRaw : public edm::EDProducer {
class L1TDigiToRaw : public edm::one::EDProducer<edm::one::SharedResources, edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
public:
explicit L1TDigiToRaw(const edm::ParameterSet&);
~L1TDigiToRaw();

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

using edm::EDProducer::consumes;
using edm::one::EDProducer<edm::one::SharedResources, edm::one::WatchRuns, edm::one::WatchLuminosityBlocks>::consumes;

private:
virtual void beginJob() override;
virtual void produce(edm::Event&, const edm::EventSetup&) override;
virtual void endJob() override;
//virtual void beginRun(edm::Run const&, edm::EventSetup const&) override;
//virtual void endRun(edm::Run const&, edm::EventSetup const&) override;
//virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
//virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;

virtual void beginRun(edm::Run const&, edm::EventSetup const&) override {};
virtual void endRun(edm::Run const&, edm::EventSetup const&) override {};
virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override {};
virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override {};

// ----------member data ---------------------------
// FIXME is actually fixed by the firmware version
Expand Down
17 changes: 9 additions & 8 deletions EventFilter/L1TRawToDigi/interface/L1TRawToDigi.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/one/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

Expand All @@ -33,29 +33,30 @@
#include "FWCore/Utilities/interface/InputTag.h"

namespace l1t {
class L1TRawToDigi : public edm::EDProducer {
class BaseUnpackerFactory;

class L1TRawToDigi : public edm::one::EDProducer<edm::one::SharedResources, edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
public:
explicit L1TRawToDigi(const edm::ParameterSet&);
~L1TRawToDigi();

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
virtual void beginJob() override;
virtual void produce(edm::Event&, const edm::EventSetup&) override;
virtual void endJob() override;

//virtual void beginRun(edm::Run const&, edm::EventSetup const&) override;
//virtual void endRun(edm::Run const&, edm::EventSetup const&) override;
//virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
//virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
virtual void beginRun(edm::Run const&, edm::EventSetup const&) override {};
virtual void endRun(edm::Run const&, edm::EventSetup const&) override {};
virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override {};
virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override {};

// ----------member data ---------------------------
// FIXME is actually fixed by the firmware version
static const unsigned MAX_BLOCKS = 256;

edm::InputTag inputLabel_;
int fedId_;
std::vector<std::auto_ptr<BaseUnpackerFactory>> factories_;
};
}

Expand Down
32 changes: 27 additions & 5 deletions EventFilter/L1TRawToDigi/interface/PackerFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,43 @@
#include <memory>
#include <vector>

#include "FWCore/PluginManager/interface/PluginFactory.h"
#include "EventFilter/L1TRawToDigi/interface/BasePacker.h"

namespace edm {
class ConsumesCollector;
class ParameterSet;
namespace one {
class EDProducerBase;
}
}

namespace l1t {
typedef std::vector<std::shared_ptr<l1t::BasePacker>> PackerList;

class BasePackerFactory {
public:
virtual PackerList create(const unsigned&, const int fedid) = 0;
};

typedef BasePackerFactory*(fun)(const edm::ParameterSet&, edm::ConsumesCollector&);
typedef edmplugin::PluginFactory<fun> PackerFactoryFacility;

class PackerFactory {
public:
static PackerList createPackers(const edm::ParameterSet&, const unsigned, const int fedid);
~PackerFactory();

private:
virtual PackerList create(const edm::ParameterSet&, const unsigned&, const int fedid) = 0;
static const PackerFactory* get();

std::auto_ptr<BasePackerFactory> makePackerFactory(const edm::ParameterSet&, edm::ConsumesCollector&) const;

static std::vector<PackerFactory*> createFactories();
static std::vector<PackerFactory*> factories_;
private:
PackerFactory();
static const PackerFactory instance_;
};
}

#define DEFINE_L1TPACKER(type) \
DEFINE_EDM_PLUGIN(l1t::PackerFactoryFacility,type,#type)

#endif
43 changes: 0 additions & 43 deletions EventFilter/L1TRawToDigi/interface/UnpackerCollections.h

This file was deleted.

32 changes: 27 additions & 5 deletions EventFilter/L1TRawToDigi/interface/UnpackerFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@
#include <unordered_map>
#include <vector>

#include "FWCore/PluginManager/interface/PluginFactory.h"
#include "EventFilter/L1TRawToDigi/interface/BaseUnpacker.h"
#include "EventFilter/L1TRawToDigi/interface/Block.h"

namespace edm {
class Event;
class ParameterSet;
namespace one {
class EDProducerBase;
}
}

namespace l1t {
typedef std::pair<BlockId, std::shared_ptr<l1t::BaseUnpacker>> UnpackerItem;
typedef std::unordered_map<BlockId, std::shared_ptr<l1t::BaseUnpacker>> UnpackerMap;
Expand All @@ -18,16 +27,29 @@ namespace l1t {
return res;
};

class BaseUnpackerFactory {
public:
virtual std::vector<UnpackerItem> create(edm::Event&, const unsigned&, const int fedid) = 0;
};

typedef BaseUnpackerFactory*(fct)(const edm::ParameterSet&, edm::one::EDProducerBase&);
typedef edmplugin::PluginFactory<fct> UnpackerFactoryFacility;

class UnpackerFactory {
public:
static UnpackerMap createUnpackers(unsigned fw, const int fedid);
~UnpackerFactory();

private:
virtual std::vector<UnpackerItem> create(unsigned fw, const int fedid) = 0;
static const UnpackerFactory* get();

std::auto_ptr<BaseUnpackerFactory> makeUnpackerFactory(const std::string&, const edm::ParameterSet&, edm::one::EDProducerBase&) const;

static std::vector<UnpackerFactory*> createFactories();
static std::vector<UnpackerFactory*> factories_;
private:
UnpackerFactory();
static const UnpackerFactory instance_;
};
}

#define DEFINE_L1TUNPACKER(type) \
DEFINE_EDM_PLUGIN(l1t::UnpackerFactoryFacility,type,#type)

#endif
15 changes: 12 additions & 3 deletions EventFilter/L1TRawToDigi/plugins/L1TDigiToRaw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "EventFilter/L1TRawToDigi/interface/L1TDigiToRaw.h"

#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Utilities/interface/CRC16.h"

#include <iomanip>
Expand All @@ -18,10 +19,18 @@ namespace l1t {
produces<FEDRawDataCollection>();

fwId_ = config.getParameter<unsigned int>("FWId");
packers_ = PackerFactory::createPackers(config, fwId_, fedId_);

for (auto& packer: packers_)
packer->fetchToken(this);
auto cc = edm::ConsumesCollector(consumesCollector());

auto packer_cfg = config.getParameterSet("packers");
auto packer_names = packer_cfg.getParameterNames();

for (const auto& name: packer_names) {
const auto& pset = packer_cfg.getParameterSet(name);
auto factory = std::auto_ptr<BasePackerFactory>(PackerFactory::get()->makePackerFactory(pset, cc));
auto packer_list = factory->create(fwId_, fedId_);
packers_.insert(packers_.end(), packer_list.begin(), packer_list.end());
}
}


Expand Down
68 changes: 16 additions & 52 deletions EventFilter/L1TRawToDigi/plugins/L1TRawToDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"

#include "EventFilter/L1TRawToDigi/interface/L1TRawToDigi.h"
#include "EventFilter/L1TRawToDigi/interface/UnpackerCollections.h"
#include "EventFilter/L1TRawToDigi/interface/UnpackerFactory.h"

namespace l1t {
L1TRawToDigi::L1TRawToDigi(const edm::ParameterSet& config) :
inputLabel_(config.getParameter<edm::InputTag>("InputLabel")),
fedId_(config.getParameter<int>("FedId"))
{
// Register products
UnpackerCollections::registerCollections(this);
auto factory_names = config.getParameter<std::vector<std::string>>("Unpackers");
for (const auto& name: factory_names)
factories_.push_back(UnpackerFactory::get()->makeUnpackerFactory(name, config, *this));
}


Expand Down Expand Up @@ -75,17 +75,18 @@ namespace l1t {

unsigned fw = fw_id;

UnpackerCollections coll(event);
auto unpackers = UnpackerFactory::createUnpackers(fw, fedId_);
for (auto& up: unpackers)
up.second->setCollections(coll);
UnpackerMap unpackers;
for (auto& f: factories_) {
for (const auto& up: f->create(event, fedId_, fw)) {
unpackers.insert(up);
}
}

auto payload_end = idx + payload_size * 4;
for (unsigned int b = 0; idx < payload_end; ++b) {
// FIXME Number of blocks actually fixed by firmware
if (b >= MAX_BLOCKS) {
LogDebug("L1T") << "Reached block limit - bailing out from this event!";
// TODO Handle error
LogError("L1T") << "Reached block limit - bailing out from this event!";
break;
}

Expand All @@ -96,8 +97,14 @@ namespace l1t {

auto unpacker = unpackers.find(block_id);
if (unpacker == unpackers.end()) {
LogWarning("L1T") << "Cannot find an unpacker for block ID "
<< block_id << ", FED ID " << fedId_ << ", and FW ID "
<< fw << "!";
// TODO Handle error
} else if (!unpacker->second->unpack(data + idx, block_id, block_size)) {
LogWarning("L1T") << "Error unpacking data for block ID "
<< block_id << ", FED ID " << fedId_ << ", and FW ID "
<< fw << "!";
// TODO Handle error
}

Expand All @@ -106,49 +113,6 @@ namespace l1t {
}
}

// ------------ method called once each job just before starting event loop ------------
void
L1TRawToDigi::beginJob()
{
}

// ------------ method called once each job just after ending the event loop ------------
void
L1TRawToDigi::endJob() {
}

// ------------ method called when starting to processes a run ------------
/*
void
L1TRawToDigi::beginRun(edm::Run const&, edm::EventSetup const&)
{
}
*/

// ------------ method called when ending the processing of a run ------------
/*
void
L1TRawToDigi::endRun(edm::Run const&, edm::EventSetup const&)
{
}
*/

// ------------ method called when starting to processes a luminosity block ------------
/*
void
L1TRawToDigi::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
{
}
*/

// ------------ method called when ending the processing of a luminosity block ------------
/*
void
L1TRawToDigi::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
{
}
*/

// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
void
L1TRawToDigi::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
Expand Down
Loading

0 comments on commit 6739b04

Please sign in to comment.