forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cms-sw#139 from eparadas/BMTFUnpacker
Bmtf unpacker
- Loading branch information
Showing
9 changed files
with
378 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
EventFilter/L1TRawToDigi/src/implementations_stage2/BMTFCollections.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "FWCore/Framework/interface/Event.h" | ||
|
||
#include "BMTFCollections.h" | ||
|
||
namespace l1t { | ||
namespace stage2 { | ||
BMTFCollections::~BMTFCollections() | ||
{ | ||
event_.put(outputMuons_,"BMTF"); | ||
event_.put(inputMuonsPh_); | ||
event_.put(inputMuonsTh_); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
EventFilter/L1TRawToDigi/src/implementations_stage2/BMTFCollections.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef BMTFCollections_h | ||
#define BMTFCollections_h | ||
|
||
|
||
#include "DataFormats/L1TMuon/interface/RegionalMuonCand.h" | ||
#include "EventFilter/L1TRawToDigi/interface/UnpackerCollections.h" | ||
#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h" | ||
#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h" | ||
//#include "L1TObjectCollections.h" | ||
|
||
namespace l1t { | ||
namespace stage2 { | ||
class BMTFCollections : public UnpackerCollections { | ||
public: | ||
BMTFCollections(edm::Event& e) : | ||
UnpackerCollections(e), | ||
outputMuons_ (new RegionalMuonCandBxCollection()), | ||
inputMuonsPh_ (new L1MuDTChambPhContainer), | ||
inputMuonsTh_ (new L1MuDTChambThContainer) | ||
{}; | ||
|
||
virtual ~BMTFCollections(); | ||
|
||
inline RegionalMuonCandBxCollection* getBMTFMuons() {return outputMuons_.get();}; | ||
inline L1MuDTChambPhContainer* getInMuonsPh() { return inputMuonsPh_.get(); }; | ||
inline L1MuDTChambThContainer* getInMuonsTh() { return inputMuonsTh_.get(); }; | ||
|
||
private: | ||
std::auto_ptr<RegionalMuonCandBxCollection> outputMuons_; | ||
std::auto_ptr<L1MuDTChambPhContainer> inputMuonsPh_; | ||
std::auto_ptr<L1MuDTChambThContainer> inputMuonsTh_; | ||
}; | ||
} | ||
} | ||
|
||
#endif |
73 changes: 73 additions & 0 deletions
73
EventFilter/L1TRawToDigi/src/implementations_stage2/BMTFSetup.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include "FWCore/Framework/interface/stream/EDProducerBase.h" | ||
|
||
#include "EventFilter/L1TRawToDigi/interface/Packer.h" | ||
#include "EventFilter/L1TRawToDigi/interface/Unpacker.h" | ||
|
||
#include "EventFilter/L1TRawToDigi/interface/PackingSetup.h" | ||
|
||
#include "BMTFCollections.h" | ||
#include "BMTFTokens.h" | ||
|
||
namespace l1t { | ||
namespace stage2 { | ||
class BMTFSetup : public PackingSetup { | ||
public: | ||
virtual std::unique_ptr<PackerTokens> registerConsumes(const edm::ParameterSet& cfg, edm::ConsumesCollector& cc) override { | ||
return std::unique_ptr<PackerTokens>(new BMTFTokens(cfg, cc)); | ||
}; | ||
|
||
virtual void fillDescription(edm::ParameterSetDescription& desc) override {}; | ||
|
||
virtual PackerMap getPackers(int fed, unsigned int fw) override | ||
{ | ||
PackerMap res; | ||
|
||
/* if (fed == 1360) { | ||
// Use board id 1 for packing | ||
res[{1, 1}] = { | ||
PackerFactory::get()->make("stage2::MuonPacker") | ||
}; | ||
} | ||
*/ | ||
return res; | ||
}; | ||
|
||
virtual void registerProducts(edm::stream::EDProducerBase& prod) override | ||
{ | ||
prod.produces<RegionalMuonCandBxCollection>("BMTF"); | ||
prod.produces<L1MuDTChambPhContainer>(); | ||
prod.produces<L1MuDTChambThContainer>(); | ||
}; | ||
|
||
virtual std::unique_ptr<UnpackerCollections> getCollections(edm::Event& e) override | ||
{ | ||
return std::unique_ptr<UnpackerCollections>(new BMTFCollections(e)); | ||
}; | ||
|
||
virtual UnpackerMap getUnpackers(int fed, int board, int amc, unsigned int fw) override | ||
{ | ||
auto outputMuon = UnpackerFactory::get()->make("stage2::BMTFUnpackerOutput"); | ||
auto inputMuons = UnpackerFactory::get()->make("stage2::BMTFUnpackerInputs"); | ||
|
||
UnpackerMap res; | ||
if (fed == 1376) | ||
{ | ||
|
||
for(int iL = 0; iL <= 26; iL += 2) | ||
{ | ||
if ( iL == 12 || iL == 14 ) | ||
continue; | ||
|
||
res[iL] = inputMuons; | ||
} | ||
|
||
res[123] = outputMuon; | ||
} | ||
|
||
return res; | ||
}; | ||
}; | ||
} | ||
} | ||
|
||
DEFINE_L1T_PACKING_SETUP(l1t::stage2::BMTFSetup); |
21 changes: 21 additions & 0 deletions
21
EventFilter/L1TRawToDigi/src/implementations_stage2/BMTFTokens.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "FWCore/Framework/interface/ConsumesCollector.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/Utilities/interface/InputTag.h" | ||
|
||
#include "BMTFTokens.h" | ||
|
||
namespace l1t { | ||
namespace stage2 { | ||
BMTFTokens::BMTFTokens(const edm::ParameterSet& cfg, edm::ConsumesCollector& cc) : PackerTokens(cfg, cc) | ||
{ | ||
auto ouputTag = cfg.getParameter<edm::InputTag>("InputLabel"); | ||
auto inputTagPh = cfg.getParameter<edm::InputTag>("InputLabel"); | ||
auto inputTagTh = cfg.getParameter<edm::InputTag>("InputLabel"); | ||
|
||
outputMuonToken_ = cc.consumes<RegionalMuonCandBxCollection>(ouputTag); | ||
inputMuonTokenPh_ = cc.consumes<L1MuDTChambPhContainer>(inputTagPh); | ||
inputMuonTokenTh_ = cc.consumes<L1MuDTChambThContainer>(inputTagTh); | ||
|
||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
EventFilter/L1TRawToDigi/src/implementations_stage2/BMTFTokens.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef BMTFTokens_h | ||
#define BMTFTokens_h | ||
|
||
#include "DataFormats/L1TMuon/interface/RegionalMuonCand.h" | ||
#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h" | ||
#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h" | ||
#include "EventFilter/L1TRawToDigi/interface/PackerTokens.h" | ||
|
||
namespace l1t { | ||
namespace stage2 { | ||
class BMTFTokens : public PackerTokens { | ||
public: | ||
BMTFTokens(const edm::ParameterSet&, edm::ConsumesCollector&); | ||
|
||
inline const edm::EDGetTokenT<RegionalMuonCandBxCollection>& getOutputMuonToken() const {return outputMuonToken_;}; | ||
inline const edm::EDGetTokenT<L1MuDTChambPhContainer>& getInputMuonTokenPh() const {return inputMuonTokenPh_;}; | ||
inline const edm::EDGetTokenT<L1MuDTChambThContainer>& getInputMuonTokenTh() const {return inputMuonTokenTh_;}; | ||
|
||
private: | ||
edm::EDGetTokenT<RegionalMuonCandBxCollection> outputMuonToken_; | ||
edm::EDGetTokenT<L1MuDTChambPhContainer> inputMuonTokenPh_; | ||
edm::EDGetTokenT<L1MuDTChambThContainer> inputMuonTokenTh_; | ||
|
||
}; | ||
} | ||
} | ||
|
||
#endif |
111 changes: 111 additions & 0 deletions
111
EventFilter/L1TRawToDigi/src/implementations_stage2/BMTFUnpackerInputs.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
#include "BMTFUnpackerInputs.h" | ||
|
||
#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h" | ||
#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h" | ||
|
||
namespace l1t | ||
{ | ||
namespace stage2 | ||
{ | ||
void numWheelSectorTrTag(int& wheelNo, int& sectorNo, int& tagSegID, int linkNo, int amcNo) | ||
{ | ||
if (linkNo >= 0 && linkNo < 6) | ||
wheelNo = -2; | ||
else if (linkNo >= 8 && linkNo < 14) | ||
wheelNo = -1; | ||
else if (linkNo >= 16 && linkNo < 22) | ||
wheelNo = 0; | ||
else if (linkNo >= 22 && linkNo < 28) | ||
wheelNo = 1; | ||
else if ( (linkNo >= 28 && linkNo < 29) || (linkNo >= 32 && linkNo < 36)) | ||
wheelNo = 2; | ||
|
||
sectorNo = amcNo; | ||
|
||
if ( linkNo%2 == 0 ) | ||
tagSegID = 0; | ||
else | ||
tagSegID = 1; | ||
} | ||
|
||
bool BMTFUnpackerInputs::unpack(const Block& block, UnpackerCollections *coll) | ||
{ | ||
unsigned int blockId = block.header().getID(); | ||
LogDebug("L1T") << "Block ID: " << blockId << " size: " << block.header().getSize(); | ||
auto payload = block.payload(); | ||
int nBX, firstBX, lastBX; | ||
|
||
nBX = int(ceil(block.header().getSize()/6)); | ||
getBXRange(nBX, firstBX, lastBX); | ||
|
||
LogDebug("L1T") << "BX override. Set firstBX = lastBX = 0"; | ||
|
||
L1MuDTChambPhContainer *resPhi; | ||
L1MuDTChambThContainer *resThe; | ||
resPhi = static_cast<BMTFCollections*>(coll)->getInMuonsPh(); | ||
resThe = static_cast<BMTFCollections*>(coll)->getInMuonsTh(); | ||
|
||
L1MuDTChambPhContainer::Phi_Container phi_data; | ||
L1MuDTChambThContainer::The_Container the_data; | ||
|
||
for(int ibx = firstBX; ibx <= lastBX; ibx++) | ||
{ | ||
uint32_t inputWords[block.header().getSize()/nBX]; | ||
|
||
for(unsigned int iw = 0; iw < block.header().getSize()/nBX; iw++) | ||
inputWords[iw] = payload[iw+(ibx+lastBX)*6]; | ||
|
||
int wheel, sector, trTag; | ||
numWheelSectorTrTag(wheel, sector, trTag, blockId/2, block.amc().getAMCNumber()); | ||
|
||
int mbPhi[4], mbPhiB[4], mbQual[4], mbBxC[4], mbRPC[4]; | ||
mbPhiB[2] = 0; | ||
|
||
for (int iw = 0; iw < 4; iw++) | ||
{ | ||
if ( ((inputWords[iw] & 0x3fffffff) == 0) || (inputWords[iw] == 0x505050bc) ) | ||
continue; | ||
else if ( (inputWords[iw] != 0x505050bc) && (inputWords[iw+2] == 0x505050bc) ) | ||
continue; | ||
|
||
|
||
if ( ((inputWords[iw] >> 11) & 0x1) == 1 ) | ||
mbPhi[iw] = ( inputWords[iw] & 0x7FF ) - 2048; | ||
else | ||
mbPhi[iw] = inputWords[iw] & 0xFFF; | ||
|
||
if ( iw != 2) | ||
{ | ||
if ( ((inputWords[iw] >> 21) & 0x1) == 1 ) | ||
mbPhiB[iw] = ( (inputWords[iw] >> 12) & 0x1FF ) - 512; | ||
else | ||
mbPhiB[iw] = (inputWords[iw] >> 12) & 0x3FF; | ||
} | ||
|
||
mbQual[iw] = (inputWords[iw] >> 22) & 0xF; | ||
mbBxC[iw] = (inputWords[iw] >> 30) & 0x3; | ||
|
||
if (mbQual[iw] == 0) | ||
continue; | ||
|
||
mbRPC[iw] = (inputWords[iw] >> 26) & 0x1; | ||
phi_data.push_back( L1MuDTChambPhDigi( ibx, wheel, sector, iw+1, mbPhi[iw], mbPhiB[iw], mbQual[iw], trTag, mbBxC[iw], mbRPC[iw] ) ); | ||
|
||
}//iw | ||
int mbEta[3];//, mbEtaBxC; | ||
for (int i = 0; i < 3; i++) | ||
mbEta[i] = (inputWords[4] >> (i*7 + 1)) & 0xFF; | ||
|
||
the_data.push_back(L1MuDTChambThDigi( ibx, wheel, sector, 3, mbEta) ); | ||
|
||
resPhi->setContainer(phi_data); | ||
resThe->setContainer(the_data); | ||
|
||
}//ibx | ||
|
||
|
||
return true; | ||
}//unpack | ||
}//ns2 | ||
}//ns l1t; | ||
|
16 changes: 16 additions & 0 deletions
16
EventFilter/L1TRawToDigi/src/implementations_stage2/BMTFUnpackerInputs.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
#include "EventFilter/L1TRawToDigi/interface/Unpacker.h" | ||
|
||
#include "BMTFCollections.h" | ||
|
||
namespace l1t{ | ||
namespace stage2{ | ||
class BMTFUnpackerInputs : public Unpacker | ||
{ | ||
public: | ||
virtual bool unpack(const Block& block, UnpackerCollections *coll) override; | ||
}; | ||
} | ||
} | ||
|
||
DEFINE_L1T_UNPACKER(l1t::stage2::BMTFUnpackerInputs); |
63 changes: 63 additions & 0 deletions
63
EventFilter/L1TRawToDigi/src/implementations_stage2/BMTFUnpackerOutput.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include "L1Trigger/L1TMuon/interface/RegionalMuonRawDigiTranslator.h" | ||
|
||
#include "BMTFUnpackerOutput.h" | ||
|
||
namespace l1t | ||
{ | ||
namespace stage2 | ||
{ | ||
bool BMTFUnpackerOutput::unpack(const Block& block, UnpackerCollections *coll) | ||
{ | ||
|
||
unsigned int blockId = block.header().getID(); | ||
LogDebug("L1T") << "Block ID: " << blockId << " size: " << block.header().getSize(); | ||
|
||
auto payload = block.payload(); | ||
|
||
//int nwords(2); //two words per muon | ||
int nBX, firstBX, lastBX; | ||
nBX = int(ceil(block.header().getSize()/6)); | ||
|
||
getBXRange(nBX, firstBX, lastBX); | ||
//if we want to use central BX, uncommect the two lines below | ||
//firstBX=0; | ||
//lastBX=0; | ||
//LogDebug("L1T") << "BX override. Set firstBX = lastBX = 0"; | ||
|
||
RegionalMuonCandBxCollection *res; | ||
res = static_cast<BMTFCollections*>(coll)->getBMTFMuons(); | ||
res->setBXRange(firstBX, lastBX); | ||
|
||
LogDebug("L1T") << "nBX = " << nBX << " firstBX = " << firstBX << " lastBX = " << lastBX; | ||
|
||
|
||
for(int ibx = firstBX; ibx <= lastBX; ibx++) | ||
{ | ||
int ip(0); | ||
for(unsigned int iw = 0; iw < block.header().getSize()/nBX; iw += 2) | ||
{ | ||
uint32_t raw_first = payload[ip+(ibx+lastBX)*6]; | ||
ip++; | ||
uint32_t raw_secnd = payload[ip+(ibx+lastBX)*6]; | ||
ip++; | ||
if ( raw_first == 0 ) | ||
{ | ||
LogDebug("L1T") << "Raw data is zero"; | ||
continue; | ||
} | ||
|
||
RegionalMuonCand muCand = RegionalMuonCand(); | ||
RegionalMuonRawDigiTranslator::fillRegionalMuonCand(muCand, raw_first, raw_secnd, block.amc().getAMCNumber() - 1, tftype::bmtf); | ||
muCand.setLink(blockId/2); | ||
|
||
LogDebug("L1T") << "Pt = " << muCand.hwPt() << " eta: " << muCand.hwEta() << " phi: " << muCand.hwPhi(); | ||
res->push_back(ibx, muCand); | ||
|
||
}//for iw | ||
}//for ibx | ||
|
||
return true; | ||
}//unpack | ||
}//ns stage2 | ||
}//ns lt1 | ||
|
16 changes: 16 additions & 0 deletions
16
EventFilter/L1TRawToDigi/src/implementations_stage2/BMTFUnpackerOutput.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
#include "EventFilter/L1TRawToDigi/interface/Unpacker.h" | ||
|
||
#include "BMTFCollections.h" | ||
|
||
namespace l1t{ | ||
namespace stage2{ | ||
class BMTFUnpackerOutput : public Unpacker | ||
{ | ||
public: | ||
virtual bool unpack(const Block& block, UnpackerCollections *coll) override; | ||
}; | ||
} | ||
} | ||
|
||
DEFINE_L1T_UNPACKER(l1t::stage2::BMTFUnpackerOutput); |