Skip to content

Commit

Permalink
Merge pull request #25240 from Dr15Jones/globalCastorDigiToRaw
Browse files Browse the repository at this point in the history
Make CastorDigiToRaw a global module
  • Loading branch information
cmsbuild committed Nov 20, 2018
2 parents 9e56120 + 16f8300 commit 96e3987
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 49 deletions.
14 changes: 7 additions & 7 deletions EventFilter/CastorRawToDigi/interface/CastorCtdcPacker.h
Expand Up @@ -13,14 +13,14 @@
class CastorCtdcPacker {
public:

void pack(int fedid, int dccnumber,
int nl1a, int orbitn, int bcn,
const CastorCollections& inputs,
const CastorElectronicsMap& emap,
FEDRawData& output);
static void pack(int fedid, int dccnumber,
int nl1a, int orbitn, int bcn,
const CastorCollections& inputs,
const CastorElectronicsMap& emap,
FEDRawData& output);
private:
int findSamples(const DetId& did, const CastorCollections& inputs,
unsigned short* buffer, int &presamples);
static int findSamples(const DetId& did, const CastorCollections& inputs,
unsigned short* buffer, int &presamples);
};

#endif
14 changes: 7 additions & 7 deletions EventFilter/CastorRawToDigi/interface/CastorPacker.h
Expand Up @@ -13,14 +13,14 @@
class CastorPacker {
public:

void pack(int fedid, int dccnumber,
int nl1a, int orbitn, int bcn,
const CastorCollections& inputs,
const CastorElectronicsMap& emap,
FEDRawData& output);
static void pack(int fedid, int dccnumber,
int nl1a, int orbitn, int bcn,
const CastorCollections& inputs,
const CastorElectronicsMap& emap,
FEDRawData& output);
private:
int findSamples(const DetId& did, const CastorCollections& inputs,
unsigned short* buffer, int &presamples);
static int findSamples(const DetId& did, const CastorCollections& inputs,
unsigned short* buffer, int &presamples);
};

#endif
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
8 changes: 5 additions & 3 deletions EventFilter/CastorRawToDigi/src/CastorCtdcPacker.cc
Expand Up @@ -11,6 +11,7 @@

using namespace std;

namespace {
template <class Coll, class DetIdClass>
int process(const Coll* pt, const DetId& did, unsigned short* buffer, int& presamples) {
if (pt==nullptr) return 0;
Expand All @@ -24,6 +25,7 @@ int process(const Coll* pt, const DetId& did, unsigned short* buffer, int& presa
}
return size;
}
}

int CastorCtdcPacker::findSamples(const DetId& did, const CastorCollections& inputs,
unsigned short* buffer, int &presamples) {
Expand All @@ -46,7 +48,7 @@ void CastorCtdcPacker::pack(int fedid, int dccnumber,
std::vector<unsigned short> trigdata(CastorCORData::CHANNELS_PER_SPIGOT*CastorCORData::MAXIMUM_SAMPLES_PER_CHANNEL);
std::vector<unsigned char> preclen(CastorCORData::CHANNELS_PER_SPIGOT);
std::vector<unsigned char> triglen(CastorCORData::CHANNELS_PER_SPIGOT);
static const int CORFormatVersion=1;
constexpr int CORFormatVersion=1;

// CastorCORData spigots[CastorCTDCHeader::SPIGOT_COUNT];
CastorCORData spigots[2];
Expand Down Expand Up @@ -95,8 +97,8 @@ void CastorCtdcPacker::pack(int fedid, int dccnumber,
spigots[spigot].pack(&(preclen[0]),&(precdata[0]),
&(triglen[0]),&(trigdata[0]),
true);
static const int pipeline=0x22;
static const int firmwareRev=0;
constexpr int pipeline=0x22;
constexpr int firmwareRev=0;
int submodule=exampleEId.htrTopBottom()&0x1;
submodule|=(exampleEId.htrSlot()&0x1F)<<1;
submodule|=(exampleEId.readoutVMECrateId()&0x1f)<<6;
Expand Down
8 changes: 5 additions & 3 deletions EventFilter/CastorRawToDigi/src/CastorPacker.cc
Expand Up @@ -7,6 +7,7 @@
#include "DataFormats/FEDRawData/interface/FEDTrailer.h"
#include "FWCore/Utilities/interface/CRC16.h"

namespace {
template <class Coll, class DetIdClass>
int process(const Coll* pt, const DetId& did, unsigned short* buffer, int& presamples) {
if (pt==nullptr) return 0;
Expand All @@ -20,6 +21,7 @@ int process(const Coll* pt, const DetId& did, unsigned short* buffer, int& presa
}
return size;
}
}

int CastorPacker::findSamples(const DetId& did, const CastorCollections& inputs,
unsigned short* buffer, int &presamples) {
Expand All @@ -42,7 +44,7 @@ void CastorPacker::pack(int fedid, int dccnumber,
std::vector<unsigned short> trigdata(HcalHTRData::CHANNELS_PER_SPIGOT*HcalHTRData::MAXIMUM_SAMPLES_PER_CHANNEL);
std::vector<unsigned char> preclen(HcalHTRData::CHANNELS_PER_SPIGOT);
std::vector<unsigned char> triglen(HcalHTRData::CHANNELS_PER_SPIGOT);
static const int HTRFormatVersion=3;
constexpr int HTRFormatVersion=3;

HcalHTRData spigots[15];
// loop over all valid channels in the given dcc, spigot by spigot.
Expand Down Expand Up @@ -93,8 +95,8 @@ void CastorPacker::pack(int fedid, int dccnumber,
spigots[spigot].pack(&(preclen[0]),&(precdata[0]),
&(triglen[0]),&(trigdata[0]),
false);
static const int pipeline=0x22;
static const int firmwareRev=0;
constexpr int pipeline=0x22;
constexpr int firmwareRev=0;
int submodule=exampleEId.htrTopBottom()&0x1;
submodule|=(exampleEId.htrSlot()&0x1F)<<1;
submodule|=(exampleEId.readoutVMECrateId()&0x1f)<<6;
Expand Down

0 comments on commit 96e3987

Please sign in to comment.