Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions DataFormats/L1CaloTrigger/interface/CICADA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef DataFormats_L1Trigger_CICADA_h
#define DataFormats_L1Trigger_CICADA_h

#include "DataFormats/L1Trigger/interface/BXVector.h"

namespace l1t {
typedef BXVector<float> CICADABxCollection;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming back to this question #44222 (comment), maybe from a different angle, I wonder if float is a good long-term choice, as opposed to a dedicated l1t:CICADA class (however simple it may currently be).

Some points.

  • Today, l1t::CICADA would just be something like (in short) class CICADA { float score; };. Is there a possibility that in future one could use the available bits to extract more than a score (e.g. a score with reduced precision plus some different info from other bits) ? If so, a dedicated data format would be more future-proof, and it would minimise changes downstream in the future.
  • On the topic of downstream changes (and minimising them in the future), I was asked by Efe if the 'CICADA object' should be propagated to the machinery that HLT uses for "trigger objects" (see for example the discussion in Updates to include HTMHF triggers in GT emulator #45295). I don't think this is strictly necessary, but if it will/should be done, having a dedicated class l1t:CICADA would be better, imho. @cms-sw/hlt-l2 can correct me.
  • In Saving score as part of AXOL1TL Emulator  #45227, there is a different-but-similar use case, and in that case a dedicated class is being introduced (AXOL1TLScore).

I do not know if this (float vs l1t:CICADA) needs to be addressed in this PR or not, but it's worth bringing up imho.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the relative difficulty from the engineering perspective of changing what CICADA is, and where it is located means that it is unlikely to ever change from it's current 16 bit fixed point (8 integer bits) interpretation for the L1T side. At least in the time we have left to run the current L1T system. I don't think we need to worry about, for example, float precision not being enough and needing to swap to double.

I can't really speak to future use cases, but admittedly I think the class idea is at least more future proof.

I would just give anything not have to do that in this PR though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this part of a dedicated data type is descoped?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be my preference.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, just had a chat with @eyigitba about the technical reasons for doing this. Strictly, I think it is agreed it is not needed for this PR, but may be more integral for "sophisticated" use at HLT (treating the CICADA score as an object in case we want to do that) than I was giving it credit for. I think there is also desire to centralize with AXO some of these ideas. I can take a look at this with a bit more priority in that case.

}

#endif
1 change: 1 addition & 0 deletions DataFormats/L1CaloTrigger/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
#include <vector>
#include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
#include "DataFormats/Common/interface/Wrapper.h"
#include "DataFormats/L1CaloTrigger/interface/CICADA.h"
3 changes: 3 additions & 0 deletions DataFormats/L1CaloTrigger/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@
<class name="std::vector<L1CaloRegion>"/>
<class name="edm::Wrapper<std::vector<L1CaloEmCand>>" splitLevel="0"/>
<class name="edm::Wrapper<std::vector<L1CaloRegion>>" splitLevel="0"/>

<class name="l1t::CICADABxCollection"/>
<class name="edm::Wrapper<l1t::CICADABxCollection>"/>
</lcgdict>
1 change: 1 addition & 0 deletions EventFilter/L1TRawToDigi/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<use name="DataFormats/RPCDigi"/>
<use name="DataFormats/L1DTTrackFinder"/>
<use name="DataFormats/L1TMuon"/>
<use name="DataFormats/L1CaloTrigger"/>
<use name="EventFilter/RPCRawToDigi"/>
<use name="boost_regex"/>
<export>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "EventFilter/L1TRawToDigi/plugins/UnpackerFactory.h"

#include "CICADAUnpacker.h"

#include <cmath>

using namespace edm;

namespace l1t {
namespace stage2 {
bool CICADAUnpacker::unpack(const Block& block, UnpackerCollections* coll) {
LogDebug("L1T") << "Block Size = " << block.header().getSize();
LogDebug("L1T") << "Board ID = " << block.amc().getBoardID();

auto res = static_cast<CaloLayer1Collections*>(coll)->getCICADABxCollection();
// default BX range to trigger standard -2 to 2
// Even though CICADA will never have BX information
// And everything gets put in BX 0
res->setBXRange(-2, 2);

int amc_slot = block.amc().getAMCNumber();
if (not(amc_slot == 7)) {
throw cms::Exception("CICADAUnpacker")
<< "Calo Summary (CICADA) unpacker is unpacking an unexpected AMC. Expected AMC number 7, got AMC number "
<< amc_slot << std::endl;
return false;
} else {
const uint32_t* base = block.payload().data();
//This differs slightly from uGT, in that we grab the first 4 bits
//of the last 4 words (still in first to last order) and arrange those
uint32_t word = (caloCrateCicadaBitsPattern & base[2]) >> 16 | (caloCrateCicadaBitsPattern & base[3]) >> 20 |
(caloCrateCicadaBitsPattern & base[4]) >> 24 | (caloCrateCicadaBitsPattern & base[5]) >> 28;
float score = static_cast<float>(word) / 256.f;
res->push_back(0, score);
return true;
}
}

} // namespace stage2
} // namespace l1t

DEFINE_L1T_UNPACKER(l1t::stage2::CICADAUnpacker);
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef EventFilter_L1TRawToDigi_CICADAUnpacker_h
#define EventFilter_L1TRawToDigi_CICADAUnpacker_h

#include "EventFilter/L1TRawToDigi/interface/Unpacker.h"
#include "CaloLayer1Collections.h"

namespace l1t {
namespace stage2 {
class CICADAUnpacker : public Unpacker {
public:
bool unpack(const Block& block, UnpackerCollections* coll) override;

private:
static constexpr unsigned int caloCrateCicadaBitsPattern = 0xF0000000; //first 4 bits of the words are CICADA
};
} // namespace stage2
} // namespace l1t

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace l1t {
for (int i = 0; i < 5; ++i) {
event_.put(std::move(ecalDigisBx_[i]), "EcalDigisBx" + std::to_string(i + 1));
}
event_.put(std::move(cicadaDigis_), "CICADAScore");
}
} // namespace stage2
} // namespace l1t
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
#include "EventFilter/L1TRawToDigi/interface/UnpackerCollections.h"
#include "L1TObjectCollections.h"
#include "DataFormats/L1CaloTrigger/interface/CICADA.h"

namespace l1t {
namespace stage2 {
Expand All @@ -15,7 +16,8 @@ namespace l1t {
: L1TObjectCollections(e),
ecalDigis_(new EcalTrigPrimDigiCollection()),
hcalDigis_(new HcalTrigPrimDigiCollection()),
caloRegions_(new L1CaloRegionCollection()) {
caloRegions_(new L1CaloRegionCollection()),
cicadaDigis_(std::make_unique<CICADABxCollection>()) {
// Pre-allocate:
// 72 iPhi values
// 28 iEta values in Ecal, 28 + 12 iEta values in Hcal + HF
Expand All @@ -37,13 +39,15 @@ namespace l1t {
inline EcalTrigPrimDigiCollection* getEcalDigisBx(const unsigned int copy) override {
return ecalDigisBx_[copy].get();
};
inline CICADABxCollection* getCICADABxCollection() { return cicadaDigis_.get(); };

private:
std::unique_ptr<EcalTrigPrimDigiCollection> ecalDigis_;
std::unique_ptr<HcalTrigPrimDigiCollection> hcalDigis_;
std::unique_ptr<L1CaloRegionCollection> caloRegions_;

std::array<std::unique_ptr<EcalTrigPrimDigiCollection>, 5> ecalDigisBx_;
std::unique_ptr<CICADABxCollection> cicadaDigis_;
};
} // namespace stage2
} // namespace l1t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "CaloLayer1Setup.h"

#include "DataFormats/L1CaloTrigger/interface/CICADA.h"

namespace l1t {
namespace stage2 {
std::unique_ptr<PackerTokens> CaloLayer1Setup::registerConsumes(const edm::ParameterSet& cfg,
Expand Down Expand Up @@ -58,6 +60,7 @@ namespace l1t {
for (int i = 0; i < 5; ++i) {
prod.produces<EcalTrigPrimDigiCollection>("EcalDigisBx" + std::to_string(i + 1));
}
prod.produces<CICADABxCollection>("CICADAScore");
}

std::unique_ptr<UnpackerCollections> CaloLayer1Setup::getCollections(edm::Event& e) {
Expand All @@ -72,6 +75,9 @@ namespace l1t {
if (board < 18) {
res[0] = UnpackerFactory::get()->make("stage2::CaloLayer1Unpacker");
}
if (fed == 1356 && amc == 7) { //calo summary board
res[0] = UnpackerFactory::get()->make("stage2::CICADAUnpacker");
}
}

return res;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "FWCore/Framework/interface/Event.h"

#include "CaloSummaryCollections.h"

namespace l1t {
namespace stage2 {
CaloSummaryCollections::~CaloSummaryCollections() { event_.put(std::move(cicadaDigis_)); }
} // namespace stage2
} // namespace l1t
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef EventFilter_L1TRawToDigi_CaloSummaryCollections_h
#define EventFilter_L1TRawToDigi_CaloSummaryCollections_h

#include "DataFormats/L1CaloTrigger/interface/CICADA.h"

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

namespace l1t {
namespace stage2 {
class CaloSummaryCollections : public UnpackerCollections {
public:
CaloSummaryCollections(edm::Event& e)
: UnpackerCollections(e), cicadaDigis_(std::make_unique<CICADABxCollection>()){};
~CaloSummaryCollections() override;
inline CICADABxCollection* getCICADABxCollection() { return cicadaDigis_.get(); };

private:
std::unique_ptr<CICADABxCollection> cicadaDigis_;
};
} // namespace stage2
} // namespace l1t

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "EventFilter/L1TRawToDigi/plugins/UnpackerFactory.h"

#include "L1Trigger/L1TCalorimeter/interface/CaloTools.h"

#include "L1TObjectCollections.h"

#include "DataFormats/L1CaloTrigger/interface/CICADA.h"

#include "CaloSummaryUnpacker.h"
#include "GTSetup.h"

#include <cmath>

bool l1t::stage2::CaloSummaryUnpacker::unpack(const Block& block, UnpackerCollections* coll) {
LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();

//Just a few things to help us handle the number of BXs
//Strictly, we should generally get five BXs, starting at -2, and going to 2
//With the central BX at 0. The frames count up from -2
int nBX = int(ceil(block.header().getSize() / nFramesPerEvent));
int firstBX = (nBX / 2) - nBX + 1;
int lastBX = nBX / 2;
int processedBXs = 0; //This will just help us keep track of what words we are grabbing

auto res_ = static_cast<L1TObjectCollections*>(coll)->getCICADAScore();
res_->setBXRange(firstBX, lastBX);

for (int bx = firstBX; bx <= lastBX; ++bx) {
unsigned short baseLocation = processedBXs * nFramesPerEvent;
const uint32_t* base = block.payload().data() + baseLocation;
//The take the first 4 bits of the first 4 words, and arrange them in order
uint32_t word = (cicadaBitsPattern & base[0]) >> 16 | (cicadaBitsPattern & base[1]) >> 20 |
(cicadaBitsPattern & base[2]) >> 24 | (cicadaBitsPattern & base[3]) >> 28;
//The score needs to be shifted 8 bits over the decimal point
float score = static_cast<float>(word) / 256.f;
res_->push_back(bx, score);
++processedBXs; //index BXs
}

return true;
}

DEFINE_L1T_UNPACKER(l1t::stage2::CaloSummaryUnpacker);
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef L1T_PACKER_STAGE2_CaloSummaryUnpacker_H
#define L1T_PACKER_STAGE2_CaloSummaryUnpacker_H

#include "EventFilter/L1TRawToDigi/interface/Unpacker.h"

namespace l1t {
namespace stage2 {
class CaloSummaryUnpacker : public Unpacker {
public:
CaloSummaryUnpacker() = default;
~CaloSummaryUnpacker() override = default;

bool unpack(const Block& block, UnpackerCollections* coll) override;
static constexpr unsigned int nFramesPerEvent =
6; //Calo Summary outputs 6 32 bit words (or frames in uGT parlance) per event.
static constexpr unsigned int cicadaBitsPattern =
0xF0000000; //first 4 bits of the first 4 words/frames are CICADA
};
} // namespace stage2
} // namespace l1t
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace l1t {
event_.put(std::move(zdcsums_[0]), "EtSumZDC");
event_.put(std::move(jets_[0]), "Jet");
event_.put(std::move(taus_[0]), "Tau");
event_.put(std::move(cicadaScore_), "CICADAScore");
for (int i = 1; i < 6; ++i) {
event_.put(std::move(muons_[i]), "Muon" + std::to_string(i + 1));
event_.put(std::move(muonShowers_[i]), "MuonShower" + std::to_string(i + 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "DataFormats/L1Trigger/interface/Jet.h"
#include "DataFormats/L1Trigger/interface/Tau.h"
#include "DataFormats/L1Trigger/interface/Muon.h"
#include "DataFormats/L1CaloTrigger/interface/CICADA.h"

#include "DataFormats/L1TGlobal/interface/GlobalAlgBlk.h"
#include "DataFormats/L1TGlobal/interface/GlobalExtBlk.h"
Expand All @@ -18,7 +19,10 @@ namespace l1t {
class GTCollections : public L1TObjectCollections {
public:
GTCollections(edm::Event& e)
: L1TObjectCollections(e), algBlk_(new GlobalAlgBlkBxCollection()), extBlk_(new GlobalExtBlkBxCollection()) {
: L1TObjectCollections(e),
cicadaScore_(std::make_unique<CICADABxCollection>()),
algBlk_(new GlobalAlgBlkBxCollection()),
extBlk_(new GlobalExtBlkBxCollection()) {
std::generate(muons_.begin(), muons_.end(), [] { return std::make_unique<MuonBxCollection>(); });
std::generate(
muonShowers_.begin(), muonShowers_.end(), [] { return std::make_unique<MuonShowerBxCollection>(); });
Expand All @@ -40,6 +44,7 @@ namespace l1t {
inline EtSumBxCollection* getZDCSums(const unsigned int copy) override { return zdcsums_[copy].get(); };
inline JetBxCollection* getJets(const unsigned int copy) override { return jets_[copy].get(); };
inline TauBxCollection* getTaus(const unsigned int copy) override { return taus_[copy].get(); };
inline CICADABxCollection* getCICADAScore() override { return cicadaScore_.get(); };

inline GlobalAlgBlkBxCollection* getAlgs() { return algBlk_.get(); };
inline GlobalExtBlkBxCollection* getExts() { return extBlk_.get(); };
Expand All @@ -52,6 +57,7 @@ namespace l1t {
std::array<std::unique_ptr<EtSumBxCollection>, 6> zdcsums_;
std::array<std::unique_ptr<JetBxCollection>, 6> jets_;
std::array<std::unique_ptr<TauBxCollection>, 6> taus_;
std::unique_ptr<CICADABxCollection> cicadaScore_;

std::unique_ptr<GlobalAlgBlkBxCollection> algBlk_;
std::unique_ptr<GlobalExtBlkBxCollection> extBlk_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/ZDCUnpacker.h"
#include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/JetUnpacker.h"
#include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/TauUnpacker.h"
#include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryUnpacker.h"

#include "GTSetup.h"

Expand Down Expand Up @@ -64,6 +65,7 @@ namespace l1t {
prod.produces<EtSumBxCollection>("EtSumZDC");
prod.produces<JetBxCollection>("Jet");
prod.produces<TauBxCollection>("Tau");
prod.produces<CICADABxCollection>("CICADAScore");
prod.produces<GlobalAlgBlkBxCollection>();
prod.produces<GlobalExtBlkBxCollection>();
for (int i = 2; i < 7; ++i) { // Collections from boards 2-6
Expand Down Expand Up @@ -91,6 +93,8 @@ namespace l1t {
auto zdc_unp = static_pointer_cast<l1t::stage2::ZDCUnpacker>(UnpackerFactory::get()->make("stage2::ZDCUnpacker"));
auto jet_unp = static_pointer_cast<l1t::stage2::JetUnpacker>(UnpackerFactory::get()->make("stage2::JetUnpacker"));
auto tau_unp = static_pointer_cast<l1t::stage2::TauUnpacker>(UnpackerFactory::get()->make("stage2::TauUnpacker"));
auto caloSummary_unp = static_pointer_cast<l1t::stage2::CaloSummaryUnpacker>(
UnpackerFactory::get()->make("stage2::CaloSummaryUnpacker"));

if (fw >= 0x10f2) {
etsum_unp = static_pointer_cast<l1t::stage2::EtSumUnpacker>(
Expand Down Expand Up @@ -126,6 +130,7 @@ namespace l1t {
res[16] = tau_unp;
res[18] = tau_unp;
res[20] = etsum_unp;
res[22] = caloSummary_unp;

if (amc == 1) { // only unpack first uGT board for the external signal inputs (single copy)
res[24] = ext_unp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "DataFormats/L1Trigger/interface/Tau.h"
#include "DataFormats/L1Trigger/interface/Muon.h"
#include "DataFormats/L1Trigger/interface/MuonShower.h"
#include "DataFormats/L1CaloTrigger/interface/CICADA.h"

#include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"

Expand All @@ -26,6 +27,7 @@ namespace l1t {
virtual EtSumBxCollection* getZDCSums(const unsigned int copy) { return nullptr; }
virtual JetBxCollection* getJets(const unsigned int copy) { return nullptr; }
virtual TauBxCollection* getTaus(const unsigned int copy) { return nullptr; }
virtual CICADABxCollection* getCICADAScore() { return nullptr; }

virtual EcalTrigPrimDigiCollection* getEcalDigisBx(const unsigned int copy) { return nullptr; };
};
Expand Down
10 changes: 6 additions & 4 deletions L1Trigger/L1TCaloLayer1/plugins/L1TCaloSummary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

#include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
#include "DataFormats/L1CaloTrigger/interface/L1CaloRegion.h"
#include "DataFormats/L1CaloTrigger/interface/CICADA.h"

#include "DataFormats/Math/interface/LorentzVector.h"

Expand Down Expand Up @@ -166,7 +167,7 @@ L1TCaloSummary<INPUT, OUTPUT>::L1TCaloSummary(const edm::ParameterSet& iConfig)

//anomaly trigger loading
model = loader.load_model();
produces<float>("CICADAScore");
produces<l1t::CICADABxCollection>("CICADAScore");
}

//
Expand All @@ -180,7 +181,8 @@ void L1TCaloSummary<INPUT, OUTPUT>::produce(edm::Event& iEvent, const edm::Event

std::unique_ptr<L1JetParticleCollection> bJetCands(new L1JetParticleCollection);

std::unique_ptr<float> CICADAScore = std::make_unique<float>();
std::unique_ptr<l1t::CICADABxCollection> CICADAScore = std::make_unique<l1t::CICADABxCollection>();
CICADAScore->setBXRange(-2, 2);

UCTGeometry g;

Expand Down Expand Up @@ -254,10 +256,10 @@ void L1TCaloSummary<INPUT, OUTPUT>::produce(edm::Event& iEvent, const edm::Event
model->predict();
model->read_result(modelResult);

*CICADAScore = modelResult[0].to_float();
CICADAScore->push_back(0, modelResult[0].to_float());

if (overwriteWithTestPatterns)
edm::LogInfo("L1TCaloSummary") << "Test Pattern Output: " << *CICADAScore;
edm::LogInfo("L1TCaloSummary") << "Test Pattern Output: " << CICADAScore->at(0, 0);

summaryCard.setRegionData(inputRegions);

Expand Down
Loading