Skip to content

Commit

Permalink
Merge pull request #9216 from cms-l1t-offline/l1t-updates-75x
Browse files Browse the repository at this point in the history
L1t updates 75x
  • Loading branch information
davidlange6 committed May 23, 2015
2 parents e9d56d3 + 4dd3c8f commit 2a9b48d
Show file tree
Hide file tree
Showing 96 changed files with 8,084 additions and 2,521 deletions.
1 change: 1 addition & 0 deletions EventFilter/L1TRawToDigi/BuildFile.xml
Expand Up @@ -3,6 +3,7 @@
<use name="DataFormats/L1Trigger"/>
<use name="DataFormats/L1TCalorimeter"/>
<use name="L1Trigger/L1TCalorimeter"/>
<use name="L1Trigger/L1TGlobal"/>
<export>
<lib name="1"/>
</export>
Expand Down
88 changes: 69 additions & 19 deletions EventFilter/L1TRawToDigi/plugins/MP7BufferDumpToRaw.cc
Expand Up @@ -134,8 +134,8 @@ class MP7BufferDumpToRaw : public edm::EDProducer {
MP7BufferDumpToRaw::MP7BufferDumpToRaw(const edm::ParameterSet& iConfig) :
rxFileReader_(iConfig.getUntrackedParameter<std::string>("rxFile", "rx_summary.txt")),
txFileReader_(iConfig.getUntrackedParameter<std::string>("txFile", "tx_summary.txt")),
rxPacketReader_(iConfig.getUntrackedParameter<std::string>("rxFile", "rx_summary.txt")),
txPacketReader_(iConfig.getUntrackedParameter<std::string>("txFile", "tx_summary.txt")),
rxPacketReader_(iConfig.getUntrackedParameter<std::string>("rxFile", "rx_summary.txt"), 1, 0),
txPacketReader_(iConfig.getUntrackedParameter<std::string>("txFile", "tx_summary.txt"), 1, 0),
packetisedData_(iConfig.getUntrackedParameter<bool>("packetisedData", true)),
nFramesPerEvent_(iConfig.getUntrackedParameter<int>("nFramesPerEvent", 6)),
iBoard_(iConfig.getUntrackedParameter<int>("boardOffset", 0)),
Expand Down Expand Up @@ -184,11 +184,40 @@ class MP7BufferDumpToRaw : public edm::EDProducer {
edm::LogError("L1T") << "Wrong number of block specs " << vpset.size();
}

rxBlockLength_.resize(nBoard_);
txBlockLength_.resize(nBoard_);

for (unsigned i=0; i<nBoard_; ++i) {
rxBlockLength_.push_back(vpset.at(i).getUntrackedParameter< std::vector<int> >("rxBlockLength") );
txBlockLength_.push_back(vpset.at(i).getUntrackedParameter< std::vector<int> >("rxBlockLength") );

std::vector<int> rx = vpset.at(i).getUntrackedParameter< std::vector<int> >("rxBlockLength");

rxBlockLength_.at(i).resize(rx.size());

for (unsigned j=0; j<rx.size(); ++j) {
rxBlockLength_.at(i).at(j) = rx.at(j);

if (rx.at(j) != 0) {
// LogDebug("L1T") << "Block readout : board " << i << " Rx link " << j << " size " << rx.at(j);
}
}

std::vector<int> tx = vpset.at(i).getUntrackedParameter< std::vector<int> >("txBlockLength");
txBlockLength_.at(i).resize(tx.size());

for (unsigned j=0; j<tx.size(); ++j) {
txBlockLength_.at(i).at(j) = tx.at(j);

if (tx.at(j) != 0) {
// LogDebug("L1T") << "Block readout : board " << i << " Tx link " << j << " size " << tx.at(j);
}
}

}

LogDebug("L1T") << "Board ID size " << boardId_.size();

LogDebug("L1T") << "Frames per event " << nFramesPerEvent_;

}


Expand Down Expand Up @@ -217,9 +246,7 @@ MP7BufferDumpToRaw::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
// create AMC formatted data
if (mux_) {
std::vector<Block> blocks = getBlocks(iBoard_);
formatAMC(amc13, blocks, boardId_.at(iBoard_));
iBoard_++; //advance to next AMC for next event...
iBoard_ = iBoard_ % nBoard_;
formatAMC(amc13, blocks, iBoard_);
}
else {
for (unsigned iBoard=0; iBoard<nBoard_; ++iBoard) {
Expand All @@ -240,6 +267,12 @@ MP7BufferDumpToRaw::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)

// put the collection in the event
iEvent.put(raw_coll);

//advance to next AMC for next event, if required...
if (mux_) {
iBoard_++;
iBoard_ = iBoard_ % nBoard_;
}

}

Expand All @@ -249,13 +282,13 @@ std::vector<Block>
MP7BufferDumpToRaw::getBlocks(int iBoard)
{

LogDebug("L1T") << "Getting blocks from board " << iBoard;
LogDebug("L1T") << "Getting blocks from board " << iBoard << ", " << rxBlockLength_.at(iBoard).size() << " Rx links, " << txBlockLength_.at(iBoard).size() << " Tx links";

std::vector<Block> blocks;

// Rx blocks first
for (unsigned link=0; link<rxBlockLength_.at(iBoard).size(); ++link) {

unsigned id = link*2;
unsigned size = rxBlockLength_.at(iBoard).at(link);

Expand All @@ -277,15 +310,16 @@ MP7BufferDumpToRaw::getBlocks(int iBoard)
}
}
else {

for (unsigned iFrame=rxIndex_.at(iBoard); iFrame<rxIndex_.at(iBoard)+size; ++iFrame) {
uint64_t d = rxFileReader_.get(iBoard).link(link).at(iFrame);
// LogDebug("L1T") << "Frame " << iFrame << " : " << std::hex << d;
LogDebug("L1T") << "Frame " << iFrame << " : " << std::hex << d;
if ((d & 0x100000000) > 0) data.push_back( d & 0xffffffff );
}
rxIndex_.at(iBoard) += nFramesPerEvent_;

}

LogDebug("L1T") << "AMC " << iBoard << " block " << id << ", size " << data.size();
LogDebug("L1T") << "Board " << iBoard << " block " << id << ", size " << data.size();

Block block(id, data);
blocks.push_back(block);
Expand All @@ -300,37 +334,52 @@ MP7BufferDumpToRaw::getBlocks(int iBoard)

if (size==0) continue;

LogDebug("L1T") << "Block " << id << " expecting size " << size;

std::vector<uint32_t> data;
if (packetisedData_) {

const PacketData& p = txPacketReader_.get(iBoard);
PacketData::const_iterator itr = p.begin();
for (unsigned i=0; i<txIndex_.at(iBoard); i++) itr++;
for (unsigned iFrame=itr->first_; iFrame<itr->last_; ++iFrame) {

LogDebug("L1T") << "Found packet [" << itr->first_ << ", " << itr->last_ << "]";
LogDebug("L1T") << "Link " << link << " has " << itr->links_.find(link)->second.size() << " frames";

for (unsigned iFrame=0; iFrame<itr->links_.find(link)->second.size(); ++iFrame) {
uint64_t d = itr->links_.find(link)->second.at(iFrame);
data.push_back(d);
}

}
else {

for (unsigned iFrame=txIndex_.at(iBoard); iFrame<txIndex_.at(iBoard)+size; ++iFrame) {
uint64_t d = txFileReader_.get(iBoard).link(link).at(iFrame);
// LogDebug("L1T") << "Frame " << iFrame << " : " << std::hex << d;
LogDebug("L1T") << "Frame " << iFrame << " : " << std::hex << d;
if ((d & 0x100000000) > 0) data.push_back( d & 0xffffffff );
}
txIndex_.at(iBoard) += nFramesPerEvent_;

}

LogDebug("L1T") << "AMC " << iBoard << " block " << id << ", size " << data.size();
LogDebug("L1T") << "Board " << iBoard << " block " << id << ", size " << data.size();

Block block(id, data);

blocks.push_back(block);

}



if (packetisedData_) {
rxIndex_.at(iBoard)++;
txIndex_.at(iBoard)++;
}
else {
rxIndex_.at(iBoard) += nFramesPerEvent_;
txIndex_.at(iBoard) += nFramesPerEvent_;
}

LogDebug("L1T") << "AMC " << iBoard << ", read " << blocks.size() << " blocks";
LogDebug("L1T") << "Board " << iBoard << ", read " << blocks.size() << " blocks";

return blocks;

Expand Down Expand Up @@ -373,6 +422,7 @@ MP7BufferDumpToRaw::formatAMC(amc13::Packet& amc13, const std::vector<Block>& bl
}

LogDebug("L1T") << "Creating AMC packet " << iBoard;
// LogDebug("L1T") << iBoard << ", " << boardId_.at(iBoard) << ", " << load64.size();

amc13.add(iBoard, boardId_.at(iBoard), load64);

Expand Down
15 changes: 15 additions & 0 deletions EventFilter/L1TRawToDigi/python/gtStage2Digis_cfi.py
@@ -0,0 +1,15 @@
import FWCore.ParameterSet.Config as cms

gtStage2Digis = cms.EDProducer(
"L1TRawToDigi",
Setup = cms.string("stage2::GTSetup"),
InputLabel = cms.InputTag("rawDataCollector"),
FedIds = cms.vint32( 1404 ),
FWId = cms.untracked.int32(2),
lenSlinkHeader = cms.untracked.int32(8),
lenSlinkTrailer = cms.untracked.int32(8),
lenAMCHeader = cms.untracked.int32(8),
lenAMCTrailer = cms.untracked.int32(0),
lenAMC13Header = cms.untracked.int32(8),
lenAMC13Trailer = cms.untracked.int32(8)
)
Expand Up @@ -66,7 +66,7 @@
0,0,0,0, # q13 52-55
0,0,0,0, # q14 56-59
0,0,0,0, # q15 60-63
0,0,6,0, # q16 64-67
0,0,0,0, # q16 64-67
0,0,0,0) # q17 68-71
)
)
Expand Down
74 changes: 74 additions & 0 deletions EventFilter/L1TRawToDigi/python/stage2GTMP7BufferRaw_cfi.py
@@ -0,0 +1,74 @@
import FWCore.ParameterSet.Config as cms

stage2GTRaw = cms.EDProducer(
"MP7BufferDumpToRaw",
rxFile = cms.untracked.string("gt_rx_summary.txt"),
txFile = cms.untracked.string("gt_tx_summary.txt"),

# input file type
packetisedData = cms.untracked.bool(False),

# parameters for non-packetised data
nFramesPerEvent = cms.untracked.int32(6),
nFramesOffset = cms.untracked.vuint32(0),
nFramesLatency = cms.untracked.vuint32(0),

# DAQ parameters
fedId = cms.untracked.int32(1404),
eventType = cms.untracked.int32(238),
fwVersion = cms.untracked.int32(255),
lenSlinkHeader = cms.untracked.int32(8), # length in 8 bit words !
lenSlinkTrailer = cms.untracked.int32(8),

# readout parameters
boardId = cms.untracked.vint32( 0 ),
mux = cms.untracked.bool(False),
muxOffset = cms.untracked.int32(0),

# these parameters specify the amount of data from each link to be
# recorded in the FEDRawData object
# if insufficient data is read from any channel to produce the
# record, module will pad with zeros
blocks = cms.untracked.VPSet(
cms.untracked.PSet(
rxBlockLength = cms.untracked.vint32(0,0,0,0, # q0 0-3
0,0,6,6, # q1 4-7
0,0,6,0, # q2 8-11
0,0,0,0, # q3 12-15
0,0,0,0, # q4 16-19
0,0,0,0, # q5 20-23
0,0,0,0, # q6 24-27
0,0,0,0, # q7 28-31
0,0,0,0, # q8 32-35
0,0,0,0, # q9 36-39
0,0,0,0, # q10 40-43
0,0,0,0, # q11 44-47
0,0,0,0, # q12 48-51
0,0,0,0, # q13 52-55
0,0,0,0, # q14 56-59
0,0,0,0, # q15 60-63
0,0,0,0, # q16 64-67
0,0,0,0), # q17 68-71

txBlockLength = cms.untracked.vint32(6,6,6,0, # q0 0-3
0,0,0,0, # q1 4-7
0,0,0,0, # q2 8-11
0,0,0,0, # q3 12-15
0,0,0,0, # q4 16-19
0,0,0,0, # q5 20-23
0,0,0,0, # q6 24-27
0,0,0,0, # q7 28-31
0,0,0,0, # q8 32-35
0,0,0,0, # q9 36-39
0,0,0,0, # q10 40-43
0,0,0,0, # q11 44-47
0,0,0,0, # q12 48-51
0,0,0,0, # q13 52-55
0,0,0,0, # q14 56-59
0,0,0,0, # q15 60-63
0,0,0,0, # q16 64-67
0,0,0,0) # q17 68-71
)
)

)
5 changes: 4 additions & 1 deletion EventFilter/L1TRawToDigi/python/stage2MP7BufferRaw_cff.py
Expand Up @@ -2,15 +2,18 @@

from EventFilter.L1TRawToDigi.stage2MP7BufferRaw_cfi import *
from EventFilter.L1TRawToDigi.stage2DemuxMP7BufferRaw_cfi import *
from EventFilter.L1TRawToDigi.stage2GTMP7BufferRaw_cfi import *
from EventFilter.RawDataCollector.rawDataCollector_cfi import *

rawDataCollector.RawCollectionList = cms.VInputTag(
cms.InputTag('stage2MPRaw'),
cms.InputTag('stage2DemuxRaw')
cms.InputTag('stage2DemuxRaw'),
cms.InputTag('stage2GTRaw')
)

stage2MP7BufferRaw = cms.Sequence(
stage2MPRaw
+stage2DemuxRaw
+stage2GTRaw
+rawDataCollector
)
1 change: 1 addition & 0 deletions EventFilter/L1TRawToDigi/src/Block.cc
Expand Up @@ -49,6 +49,7 @@ namespace l1t {
MP7Payload::getHeader()
{
LogTrace("L1T") << "Getting header from " << std::hex << *data_;

return BlockHeader(data_++);
}

Expand Down
Expand Up @@ -7,14 +7,15 @@
#include "DataFormats/L1Trigger/interface/Jet.h"
#include "DataFormats/L1Trigger/interface/Tau.h"

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

namespace l1t {
namespace stage2 {
class CaloCollections : public UnpackerCollections {
class CaloCollections : public L1TObjectCollections {
public:
CaloCollections(edm::Event& e) :
UnpackerCollections(e),
L1TObjectCollections(e),
towers_(new CaloTowerBxCollection()),
egammas_(new EGammaBxCollection()),
etsums_(new EtSumBxCollection()),
Expand All @@ -26,10 +27,10 @@ namespace l1t {
virtual ~CaloCollections();

inline CaloTowerBxCollection* getTowers() { return towers_.get(); };
inline EGammaBxCollection* getEGammas() { return egammas_.get(); };
inline EtSumBxCollection* getEtSums() { return etsums_.get(); };
inline JetBxCollection* getJets() { return jets_.get(); };
inline TauBxCollection* getTaus() { return taus_.get(); };
inline EGammaBxCollection* getEGammas() override { return egammas_.get(); };
inline EtSumBxCollection* getEtSums() override { return etsums_.get(); };
inline JetBxCollection* getJets() override { return jets_.get(); };
inline TauBxCollection* getTaus() override { return taus_.get(); };

inline EtSumBxCollection* getMPEtSums() { return mp_etsums_.get(); };
inline JetBxCollection* getMPJets() { return mp_jets_.get(); };
Expand Down
Expand Up @@ -59,10 +59,9 @@ namespace l1t {

UnpackerMap res;
if (fed == 1366) {
res[1] = egamma_unp;
res[3] = etsum_unp;
res[5] = jet_unp;
res[7] = tau_unp;
res[13] = jet_unp;
res[15] = jet_unp;
res[21] = etsum_unp;
} else if (fed == 1360) {
res[1] = mp_unp;
res[3] = mp_unp;
Expand Down
Expand Up @@ -29,9 +29,9 @@ namespace stage2 {
int firstBX = -(std::ceil((double)nBX/2.)-1);
int lastBX;
if (nBX % 2 == 0) {
lastBX = std::ceil((double)nBX/2.)+1;
} else {
lastBX = std::ceil((double)nBX/2.);
} else {
lastBX = std::ceil((double)nBX/2.)-1;
}

auto res_ = static_cast<CaloCollections*>(coll)->getTowers();
Expand All @@ -49,7 +49,7 @@ namespace stage2 {
unsigned link_phi = (link % 2 == 0) ? link : (link -1);

// Loop over multiple BX and fill towers collection
for (int bx=firstBX; bx<lastBX; bx++){
for (int bx=firstBX; bx<=lastBX; bx++){

for (unsigned frame=1; frame<42 && frame<(block.header().getSize()+1); frame++){

Expand Down

0 comments on commit 2a9b48d

Please sign in to comment.