Skip to content

Commit 4fec71b

Browse files
committed
Add CaloSummary/CICADA Unpacker
Fix format Remove debug statement
1 parent d9d5e0e commit 4fec71b

File tree

6 files changed

+83
-1
lines changed

6 files changed

+83
-1
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#include "FWCore/MessageLogger/interface/MessageLogger.h"
2+
#include "EventFilter/L1TRawToDigi/plugins/UnpackerFactory.h"
3+
4+
#include "L1Trigger/L1TCalorimeter/interface/CaloTools.h"
5+
6+
#include "L1TObjectCollections.h"
7+
8+
#include "CaloSummaryUnpacker.h"
9+
#include "GTSetup.h"
10+
11+
#include <cmath>
12+
13+
float l1t::stage2::CaloSummaryUnpacker::processBitsToScore(const unsigned int bitsArray[]) {
14+
float constructedScore = 0.0;
15+
//All bits have been shifted to just left of the decimal point
16+
//We need to convert them to float, shift them back to their proper position
17+
//And then add them into the total
18+
//The proper power is 4(-(bitIndex+1) + numCICADAWords/2)
19+
// i.e. shift bitIndex to max out at half the number of CICADA words (indexed at 0) then count down
20+
//And we shift by 4 bits a time, hence the factor of 4
21+
for (unsigned short bitIndex = 0; bitIndex < numCICADAWords; ++bitIndex) {
22+
constructedScore += ((float)bitsArray[bitIndex]) * pow(2.0, 4 * (numCICADAWords / 2 - (bitIndex + 1)));
23+
}
24+
return constructedScore;
25+
}
26+
27+
bool l1t::stage2::CaloSummaryUnpacker::unpack(const Block& block, UnpackerCollections* coll) {
28+
LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
29+
//convert to float and then multiply by a factor based on the index?
30+
unsigned int cicadaBits[numCICADAWords] = {0, 0, 0, 0};
31+
32+
auto res_ = static_cast<L1TObjectCollections*>(coll)->getCICADAScore();
33+
34+
for (unsigned int wordNum = 0; wordNum < nFrames; ++wordNum) {
35+
uint32_t raw_data = block.payload().at(wordNum);
36+
if (wordNum < numCICADAWords) { // check the first 4 frames for CICADA bits
37+
cicadaBits[wordNum] =
38+
(cicadaBitsPattern & raw_data) >>
39+
28; //The 28 shifts the extracted bits over to the start of the 32 bit result data for easier working with
40+
}
41+
}
42+
*res_ = processBitsToScore(cicadaBits);
43+
44+
return true;
45+
}
46+
47+
DEFINE_L1T_UNPACKER(l1t::stage2::CaloSummaryUnpacker);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifndef L1T_PACKER_STAGE2_CaloSummaryUnpacker_H
2+
#define L1T_PACKER_STAGE2_CaloSummaryUnpacker_H
3+
4+
#include "EventFilter/L1TRawToDigi/interface/Unpacker.h"
5+
6+
namespace l1t {
7+
namespace stage2 {
8+
class CaloSummaryUnpacker : public Unpacker {
9+
public:
10+
CaloSummaryUnpacker() = default;
11+
~CaloSummaryUnpacker() override = default;
12+
13+
bool unpack(const Block& block, UnpackerCollections* coll) override;
14+
float processBitsToScore(const unsigned int[]);
15+
16+
static constexpr unsigned short numCICADAWords = 4; // We have 4 words/frames that contain CICADA bits
17+
static constexpr unsigned int nFrames = 6; //My understanding is that we give 6 32 bit words to uGT
18+
static constexpr unsigned int cicadaBitsPattern =
19+
0xF0000000; //first 4 bits of the first 4 words/frames are CICADA
20+
};
21+
} // namespace stage2
22+
} // namespace l1t
23+
#endif

EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace l1t {
1212
event_.put(std::move(zdcsums_[0]), "EtSumZDC");
1313
event_.put(std::move(jets_[0]), "Jet");
1414
event_.put(std::move(taus_[0]), "Tau");
15+
event_.put(std::move(cicadaScore_), "CICADAScore");
1516
for (int i = 1; i < 6; ++i) {
1617
event_.put(std::move(muons_[i]), "Muon" + std::to_string(i + 1));
1718
event_.put(std::move(muonShowers_[i]), "MuonShower" + std::to_string(i + 1));

EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTCollections.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ namespace l1t {
1818
class GTCollections : public L1TObjectCollections {
1919
public:
2020
GTCollections(edm::Event& e)
21-
: L1TObjectCollections(e), algBlk_(new GlobalAlgBlkBxCollection()), extBlk_(new GlobalExtBlkBxCollection()) {
21+
: L1TObjectCollections(e),
22+
cicadaScore_(std::make_unique<float>(0.0)),
23+
algBlk_(new GlobalAlgBlkBxCollection()),
24+
extBlk_(new GlobalExtBlkBxCollection()) {
2225
std::generate(muons_.begin(), muons_.end(), [] { return std::make_unique<MuonBxCollection>(); });
2326
std::generate(
2427
muonShowers_.begin(), muonShowers_.end(), [] { return std::make_unique<MuonShowerBxCollection>(); });
@@ -40,6 +43,7 @@ namespace l1t {
4043
inline EtSumBxCollection* getZDCSums(const unsigned int copy) override { return zdcsums_[copy].get(); };
4144
inline JetBxCollection* getJets(const unsigned int copy) override { return jets_[copy].get(); };
4245
inline TauBxCollection* getTaus(const unsigned int copy) override { return taus_[copy].get(); };
46+
inline float* getCICADAScore() override { return cicadaScore_.get(); };
4347

4448
inline GlobalAlgBlkBxCollection* getAlgs() { return algBlk_.get(); };
4549
inline GlobalExtBlkBxCollection* getExts() { return extBlk_.get(); };
@@ -52,6 +56,7 @@ namespace l1t {
5256
std::array<std::unique_ptr<EtSumBxCollection>, 6> zdcsums_;
5357
std::array<std::unique_ptr<JetBxCollection>, 6> jets_;
5458
std::array<std::unique_ptr<TauBxCollection>, 6> taus_;
59+
std::unique_ptr<float> cicadaScore_;
5560

5661
std::unique_ptr<GlobalAlgBlkBxCollection> algBlk_;
5762
std::unique_ptr<GlobalExtBlkBxCollection> extBlk_;

EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/ZDCUnpacker.h"
1010
#include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/JetUnpacker.h"
1111
#include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/TauUnpacker.h"
12+
#include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h"
1213

1314
#include "GTSetup.h"
1415

@@ -64,6 +65,7 @@ namespace l1t {
6465
prod.produces<EtSumBxCollection>("EtSumZDC");
6566
prod.produces<JetBxCollection>("Jet");
6667
prod.produces<TauBxCollection>("Tau");
68+
prod.produces<float>("CICADAScore");
6769
prod.produces<GlobalAlgBlkBxCollection>();
6870
prod.produces<GlobalExtBlkBxCollection>();
6971
for (int i = 2; i < 7; ++i) { // Collections from boards 2-6
@@ -91,6 +93,8 @@ namespace l1t {
9193
auto zdc_unp = static_pointer_cast<l1t::stage2::ZDCUnpacker>(UnpackerFactory::get()->make("stage2::ZDCUnpacker"));
9294
auto jet_unp = static_pointer_cast<l1t::stage2::JetUnpacker>(UnpackerFactory::get()->make("stage2::JetUnpacker"));
9395
auto tau_unp = static_pointer_cast<l1t::stage2::TauUnpacker>(UnpackerFactory::get()->make("stage2::TauUnpacker"));
96+
auto caloSummary_unp = static_pointer_cast<l1t::stage2::CaloSummaryUnpacker>(
97+
UnpackerFactory::get()->make("stage2::CaloSummaryUnpacker"));
9498

9599
if (fw >= 0x10f2) {
96100
etsum_unp = static_pointer_cast<l1t::stage2::EtSumUnpacker>(
@@ -126,6 +130,7 @@ namespace l1t {
126130
res[16] = tau_unp;
127131
res[18] = tau_unp;
128132
res[20] = etsum_unp;
133+
res[22] = caloSummary_unp;
129134

130135
if (amc == 1) { // only unpack first uGT board for the external signal inputs (single copy)
131136
res[24] = ext_unp;

EventFilter/L1TRawToDigi/plugins/implementations_stage2/L1TObjectCollections.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace l1t {
2626
virtual EtSumBxCollection* getZDCSums(const unsigned int copy) { return nullptr; }
2727
virtual JetBxCollection* getJets(const unsigned int copy) { return nullptr; }
2828
virtual TauBxCollection* getTaus(const unsigned int copy) { return nullptr; }
29+
virtual float* getCICADAScore() { return nullptr; }
2930

3031
virtual EcalTrigPrimDigiCollection* getEcalDigisBx(const unsigned int copy) { return nullptr; };
3132
};

0 commit comments

Comments
 (0)