Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ZDC Unpacker to L1RawtoDigi #42733

Merged
merged 18 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ namespace l1t {
event_.put(std::move(muonShowers_[0]), "MuonShower");
event_.put(std::move(egammas_[0]), "EGamma");
event_.put(std::move(etsums_[0]), "EtSum");
event_.put(std::move(zdcsums_[0]), "EtSumZDC");
event_.put(std::move(jets_[0]), "Jet");
event_.put(std::move(taus_[0]), "Tau");
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));
event_.put(std::move(egammas_[i]), "EGamma" + std::to_string(i + 1));
event_.put(std::move(etsums_[i]), "EtSum" + std::to_string(i + 1));
event_.put(std::move(zdcsums_[i]), "EtSumZDC" + std::to_string(i + 1));
event_.put(std::move(jets_[i]), "Jet" + std::to_string(i + 1));
event_.put(std::move(taus_[i]), "Tau" + std::to_string(i + 1));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace l1t {
muonShowers_.begin(), muonShowers_.end(), [] { return std::make_unique<MuonShowerBxCollection>(); });
std::generate(egammas_.begin(), egammas_.end(), [] { return std::make_unique<EGammaBxCollection>(); });
std::generate(etsums_.begin(), etsums_.end(), [] { return std::make_unique<EtSumBxCollection>(); });
std::generate(zdcsums_.begin(), zdcsums_.end(), [] { return std::make_unique<EtSumBxCollection>(); });
std::generate(jets_.begin(), jets_.end(), [] { return std::make_unique<JetBxCollection>(); });
std::generate(taus_.begin(), taus_.end(), [] { return std::make_unique<TauBxCollection>(); });
};
Expand All @@ -36,6 +37,7 @@ namespace l1t {
};
inline EGammaBxCollection* getEGammas(const unsigned int copy) override { return egammas_[copy].get(); };
inline EtSumBxCollection* getEtSums(const unsigned int copy) override { return etsums_[copy].get(); };
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(); };

Expand All @@ -47,6 +49,7 @@ namespace l1t {
std::array<std::unique_ptr<MuonShowerBxCollection>, 6> muonShowers_;
std::array<std::unique_ptr<EGammaBxCollection>, 6> egammas_;
std::array<std::unique_ptr<EtSumBxCollection>, 6> etsums_;
std::array<std::unique_ptr<EtSumBxCollection>, 6> zdcsums_;
std::array<std::unique_ptr<JetBxCollection>, 6> jets_;
std::array<std::unique_ptr<TauBxCollection>, 6> taus_;

Expand Down
10 changes: 10 additions & 0 deletions EventFilter/L1TRawToDigi/plugins/implementations_stage2/GTSetup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
#include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/MuonUnpacker.h"
#include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/EGammaUnpacker.h"
#include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/EtSumUnpacker.h"
#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 "GTSetup.h"

const unsigned int l1t::stage2::zdc::nOutputFramePerBX = 6;

namespace l1t {
namespace stage2 {

std::unique_ptr<PackerTokens> GTSetup::registerConsumes(const edm::ParameterSet& cfg, edm::ConsumesCollector& cc) {
return std::unique_ptr<PackerTokens>(new GTTokens(cfg, cc));
}
Expand Down Expand Up @@ -55,6 +59,7 @@ namespace l1t {
prod.produces<MuonShowerBxCollection>("MuonShower");
prod.produces<EGammaBxCollection>("EGamma");
prod.produces<EtSumBxCollection>("EtSum");
prod.produces<EtSumBxCollection>("EtSumZDC");
prod.produces<JetBxCollection>("Jet");
prod.produces<TauBxCollection>("Tau");
prod.produces<GlobalAlgBlkBxCollection>();
Expand All @@ -64,6 +69,7 @@ namespace l1t {
prod.produces<MuonShowerBxCollection>("MuonShower" + std::to_string(i));
prod.produces<EGammaBxCollection>("EGamma" + std::to_string(i));
prod.produces<EtSumBxCollection>("EtSum" + std::to_string(i));
prod.produces<EtSumBxCollection>("EtSumZDC" + std::to_string(i));
prod.produces<JetBxCollection>("Jet" + std::to_string(i));
prod.produces<TauBxCollection>("Tau" + std::to_string(i));
}
Expand All @@ -80,6 +86,7 @@ namespace l1t {
static_pointer_cast<l1t::stage2::EGammaUnpacker>(UnpackerFactory::get()->make("stage2::EGammaUnpacker"));
auto etsum_unp =
static_pointer_cast<l1t::stage2::EtSumUnpacker>(UnpackerFactory::get()->make("stage2::EtSumUnpacker"));
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"));

Expand All @@ -97,6 +104,7 @@ namespace l1t {
muon_unp->setMuonCopy(amc - 1);
egamma_unp->setEGammaCopy(amc - 1);
etsum_unp->setEtSumCopy(amc - 1);
zdc_unp->setEtSumZDCCopy(amc - 1);
jet_unp->setJetCopy(amc - 1);
tau_unp->setTauCopy(amc - 1);

Expand Down Expand Up @@ -135,6 +143,8 @@ namespace l1t {
res[45] = alg_unp;
res[47] = alg_unp;
res[49] = alg_unp;

res[142] = zdc_unp;
}

return res;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

namespace l1t {
namespace stage2 {

namespace zdc {
extern const unsigned int nOutputFramePerBX;
} // namespace zdc

class GTSetup : public PackingSetup {
public:
~GTSetup() override{};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace l1t {
virtual MuonShowerBxCollection* getMuonShowers(const unsigned int copy) { return nullptr; }
virtual EGammaBxCollection* getEGammas(const unsigned int copy) { return nullptr; } //= 0;
virtual EtSumBxCollection* getEtSums(const unsigned int copy) { return nullptr; }
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; }

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

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

#include "L1TObjectCollections.h"

// #include "L1TStage2Layer2Constants.h"
#include "ZDCUnpacker.h"
#include "GTSetup.h"

namespace l1t {
namespace stage2 {
ZDCUnpacker::ZDCUnpacker() : EtSumZDCCopy_(0) {}

bool ZDCUnpacker::unpack(const Block& block, UnpackerCollections* coll) {
using namespace l1t::stage2;
uint32_t zdc_mask = 0x3FF;
LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();

int nBX = int(ceil(block.header().getSize() / zdc::nOutputFramePerBX));
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, remove int(ceil(, since it doesn't do anything on the result of an integer division.

If you need to round the result up, please change it to

Suggested change
int nBX = int(ceil(block.header().getSize() / zdc::nOutputFramePerBX));
int nBX = (block.header().getSize() + zdc::nOutputFramePerBX - 1) / zdc::nOutputFramePerBX;

// expect the first four frames to be the first 4 EtSum objects reported per event (see CMS IN-2013/005)

// Find the central, first and last BXs
int firstBX = (nBX / 2) - nBX + 1;
int lastBX = nBX / 2;

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

LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;

// Loop over multiple BX and fill EtSums collection
for (int bx = firstBX; bx <= lastBX; bx++) {
// ZDC -
int iFrame = (bx - firstBX) * zdc::nOutputFramePerBX;

uint32_t raw_data = block.payload().at(iFrame + 1); // ZDC - info is found on frame 1 of each bx

l1t::EtSum zdcm{l1t::EtSum::kZDCM};
zdcm.setHwPt(raw_data & zdc_mask);
zdcm.setP4(l1t::CaloTools::p4Demux(&zdcm));
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to check here: my understanding is that this function computes the four vector with the implicit understanding that the LSB is 0.5 GeV. Is that the case for the ZDC sums too? (Again this is based on me not finding documentation, so may be a moot point.)

Copy link
Contributor

Choose a reason for hiding this comment

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

it is correct your interpretation but in ZDC we should use the numerical expression and not the conversion in energy as it is going to be wrong, in my understanding. @cfmcginn can comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, I think the uGT emulator always uses the hw values anyway and gets the scales from the menu XML. The physical pT should, however be correct because that's what people usually look at in e.g. the ntuples.

Copy link
Contributor

Choose a reason for hiding this comment

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

what about the ZDC L1 candidate used in the object map ?

Copy link
Contributor

Choose a reason for hiding this comment

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

what about the ZDC L1 candidate used in the object map ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, absolutely. If someone accesses the physical pT value of that object they would get a value of hw_code*0.5 GeV. I'm not entirely sure from Ivan's answer whether this is correct.


LogDebug("L1T") << "ZDC -: pT " << zdcm.hwPt() << " bx " << bx;

res_->push_back(bx, zdcm);

// ZDC +
raw_data = block.payload().at(iFrame + 2); // ZDC + info is found on frame 2 of each bx
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the silly question; does the + 2 depend on the configuration of ZDC or of the uGT ?
For example, on how many time samples are used by ZDC, or how many bx are read by the uGT ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Right now this based on the word order given to us by Herbert.

GT_readout_ZDC

Last I checked, the iFrame calculation locates the front of the overall BX, and then the offset gets the right sum. I would rather that the right frame was calculated ahead of time in some way that indicates what it is, instead of leaving developers to wonder what the +1 and +2 offsets are though.


l1t::EtSum zdcp{l1t::EtSum::kZDCP};
zdcp.setHwPt(raw_data & zdc_mask);
zdcp.setP4(l1t::CaloTools::p4Demux(&zdcp));

LogDebug("L1T") << "ZDC +: pT " << zdcp.hwPt() << " bx " << bx;

res_->push_back(bx, zdcp);
}

return true;
}
} // namespace stage2
} // namespace l1t

DEFINE_L1T_UNPACKER(l1t::stage2::ZDCUnpacker);
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef L1T_PACKER_STAGE2_ZDCUnpacker_H
#define L1T_PACKER_STAGE2_ZDCUnpacker_H

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

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

bool unpack(const Block& block, UnpackerCollections* coll) override;

inline void setEtSumZDCCopy(const unsigned int copy) { EtSumZDCCopy_ = copy; };

private:
unsigned int EtSumZDCCopy_;
};
} // namespace stage2
} // namespace l1t

#endif