Skip to content

Commit

Permalink
Made CastorDigiToRaw a global module
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr15Jones committed Nov 14, 2018
1 parent c177e99 commit 16f8300
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 29 deletions.
35 changes: 16 additions & 19 deletions EventFilter/CastorRawToDigi/plugins/CastorDigiToRaw.cc
Expand Up @@ -14,18 +14,14 @@ using namespace std;

CastorDigiToRaw::CastorDigiToRaw(edm::ParameterSet const& conf) :
castorTag_(conf.getParameter<edm::InputTag>("CASTOR")),
usingctdc_(conf.getParameter<bool>("CastorCtdc"))

usingctdc_(conf.getParameter<bool>("CastorCtdc")),
tok_input_(consumes<CastorDigiCollection>(castorTag_)),
tok_put_(produces<FEDRawDataCollection>())
{
tok_input_ = consumes<CastorDigiCollection>(castorTag_);
produces<FEDRawDataCollection>();
}

// Virtual destructor needed.
CastorDigiToRaw::~CastorDigiToRaw() { }

// Functions that gets called by framework every event
void CastorDigiToRaw::produce(edm::Event& e, const edm::EventSetup& es)
void CastorDigiToRaw::produce(edm::StreamID, edm::Event& e, const edm::EventSetup& es) const
{
CastorCollections colls;

Expand All @@ -40,32 +36,33 @@ void CastorDigiToRaw::produce(edm::Event& e, const edm::EventSetup& es)
es.get<CastorDbRecord>().get( pSetup );
const CastorElectronicsMap* readoutMap=pSetup->getCastorMapping();
// Step B: Create empty output
auto raw = std::make_unique<FEDRawDataCollection>();
FEDRawDataCollection raw;

const int ifed_first=FEDNumbering::MINCASTORFEDID; //690
const int ifed_last=FEDNumbering::MAXCASTORFEDID; //693
constexpr int ifed_first=FEDNumbering::MINCASTORFEDID; //690
constexpr int ifed_last=FEDNumbering::MAXCASTORFEDID; //693

int orbitN=e.id().event();
int bcnN=2000;

// Step C: pack all requested FEDs
for (int ifed=ifed_first; ifed<=ifed_last; ++ifed) {
FEDRawData& fed = raw->FEDData(ifed);
FEDRawData& fed = raw.FEDData(ifed);
try {
if ( usingctdc_ ) {
ctdcpacker_.pack(ifed,ifed-ifed_first, e.id().event(),
orbitN, bcnN, colls, *readoutMap, fed);
} else {
packer_.pack(ifed,ifed-ifed_first, e.id().event(),
orbitN, bcnN, colls, *readoutMap, fed); }
if ( usingctdc_ ) {
CastorCtdcPacker::pack(ifed,ifed-ifed_first, e.id().event(),
orbitN, bcnN, colls, *readoutMap, fed);
} else {
CastorPacker::pack(ifed,ifed-ifed_first, e.id().event(),
orbitN, bcnN, colls, *readoutMap, fed);
}
} catch (cms::Exception& e) {
edm::LogWarning("Unpacking error") << e.what();
} catch (...) {
edm::LogWarning("Unpacking exception");
}
}

e.put(std::move(raw));
e.emplace(tok_put_,std::move(raw));
}


17 changes: 7 additions & 10 deletions EventFilter/CastorRawToDigi/plugins/CastorDigiToRaw.h
Expand Up @@ -12,7 +12,7 @@
*
************************************************************/

#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "DataFormats/Common/interface/Handle.h"

Expand All @@ -23,20 +23,17 @@
#include "EventFilter/CastorRawToDigi/interface/CastorCtdcPacker.h"
#include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"

class CastorDigiToRaw : public edm::EDProducer
class CastorDigiToRaw : public edm::global::EDProducer<>
{
public:
explicit CastorDigiToRaw(const edm::ParameterSet& ps);
~CastorDigiToRaw() override;
void produce(edm::Event& e, const edm::EventSetup& c) override;
void produce(edm::StreamID, edm::Event& e, const edm::EventSetup& c) const override;

private:
CastorPacker packer_;
CastorCtdcPacker ctdcpacker_;
edm::InputTag castorTag_;
bool usingctdc_;
edm::EDGetTokenT<CastorDigiCollection> tok_input_;

const edm::InputTag castorTag_;
const bool usingctdc_;
const edm::EDGetTokenT<CastorDigiCollection> tok_input_;
const edm::EDPutTokenT<FEDRawDataCollection> tok_put_;
};

#endif

0 comments on commit 16f8300

Please sign in to comment.