diff --git a/EventFilter/L1ScoutingRawToDigi/BuildFile.xml b/EventFilter/L1ScoutingRawToDigi/BuildFile.xml
new file mode 100644
index 0000000000000..920689c518329
--- /dev/null
+++ b/EventFilter/L1ScoutingRawToDigi/BuildFile.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/EventFilter/L1ScoutingRawToDigi/interface/blocks.h b/EventFilter/L1ScoutingRawToDigi/interface/blocks.h
new file mode 100644
index 0000000000000..2515f4ac42d21
--- /dev/null
+++ b/EventFilter/L1ScoutingRawToDigi/interface/blocks.h
@@ -0,0 +1,123 @@
+#ifndef DataFormats_Scouting_BLOCKS_H
+#define DataFormats_Scouting_BLOCKS_H
+
+#include
+#include
+#include
+#include "scales.h"
+
+namespace scoutingRun3 {
+
+namespace ugmt {
+ struct hw_data_block{
+ std::vector vorbit;
+ std::vector vbx;
+ std::vector vinterm;
+ std::vector vipt;
+ std::vector viptunconstrained;
+ std::vector vcharge;
+ std::vector viso;
+ std::vector vindex;
+ std::vector vqual;
+ std::vector viphi;
+ std::vector viphiext;
+ std::vector vieta;
+ std::vector vietaext;
+ std::vector vidxy;
+
+ unsigned int size() {return vipt.size();}
+ bool empty() {return vipt.empty();}
+ static const unsigned int ncols = 14;
+
+ std::vector iAt(int i) {
+ return {
+ vorbit[i],
+ vbx[i],
+ vinterm[i],
+ vipt[i],
+ viptunconstrained[i],
+ vcharge[i],
+ viso[i],
+ vindex[i],
+ vqual[i],
+ viphi[i],
+ viphiext[i],
+ vieta[i],
+ vietaext[i],
+ vidxy[i],
+ };
+ }
+ };
+
+ struct muon {
+ uint32_t f;
+ uint32_t s;
+ uint32_t extra;
+ };
+
+ struct block {
+ uint32_t bx;
+ uint32_t orbit;
+ muon mu[16];
+ };
+}
+
+
+
+namespace demux {
+ struct hw_data_block {
+ std::vector vorbit;
+ std::vector vbx;
+ std::vector vET;
+ std::vector vType;
+ std::vector vEta;
+ std::vector vPhi;
+ std::vector vIso;
+
+ unsigned int size() {return vET.size();}
+ bool empty() {return vET.empty();}
+ static const unsigned int ncols = 13;
+
+ };
+
+ struct block_old {
+ uint32_t header;
+ uint32_t bx;
+ uint32_t orbit;
+ uint32_t frame[56]; // +8 for extra word containing link number
+ };
+
+ // unrolled frame block
+ struct block {
+ uint32_t header;
+ uint32_t bx;
+ uint32_t orbit;
+ uint32_t link0;
+ uint32_t jet1[6];
+ uint32_t link1;
+ uint32_t jet2[6];
+ uint32_t link2;
+ uint32_t egamma1[6];
+ uint32_t link3;
+ uint32_t egamma2[6];
+ uint32_t link4;
+ uint32_t empty[6];
+ uint32_t link5;
+ uint32_t sum[6];
+ uint32_t link6;
+ uint32_t tau1[6];
+ uint32_t link7;
+ uint32_t tau2[6];
+ };
+}
+
+
+
+namespace bmtf {
+ struct block {
+ uint64_t stub[8];
+ };
+}
+
+}
+#endif
diff --git a/EventFilter/L1ScoutingRawToDigi/interface/masks.h b/EventFilter/L1ScoutingRawToDigi/interface/masks.h
new file mode 100644
index 0000000000000..d2b699563797f
--- /dev/null
+++ b/EventFilter/L1ScoutingRawToDigi/interface/masks.h
@@ -0,0 +1,125 @@
+#ifndef DF_S_MASKS_H
+#define DF_S_MASKS_H
+
+#include
+#include "shifts.h"
+
+namespace scoutingRun3 {
+
+namespace ugmt {
+ // struct masks{
+ struct masksMuon {
+ // bx word: 16 bits used for actual bx, MS 4 bits are muon type
+ // 0xf intermediate,
+ // 0x0 final
+ // following 4 bits for link id
+ static constexpr uint32_t bx = 0x1fff;
+ static constexpr uint32_t interm = 0x0001;
+ //masks for muon 64 bits
+ static constexpr uint32_t phiext = 0x03ff;
+ static constexpr uint32_t pt = 0x01ff;
+ static constexpr uint32_t ptuncon = 0x00ff; // 8 bits
+ static constexpr uint32_t qual = 0x000f;
+ static constexpr uint32_t etaext = 0x01ff;
+ static constexpr uint32_t etaextv = 0x00ff;
+ static constexpr uint32_t etaexts = 0x0100;
+ static constexpr uint32_t iso = 0x0003;
+ static constexpr uint32_t chrg = 0x0001;
+ static constexpr uint32_t chrgv = 0x0001;
+ static constexpr uint32_t index = 0x007f;
+ static constexpr uint32_t phi = 0x03ff;
+ static constexpr uint32_t eta = 0x01ff;
+ static constexpr uint32_t etav = 0x00ff;
+ static constexpr uint32_t etas = 0x0100;
+ static constexpr uint32_t dxy = 0x0003;
+ };
+}
+
+
+
+namespace demux {
+ // struct masksCaloJet{
+ struct masksJet {
+ static constexpr uint32_t ET = 0x07ff;
+ static constexpr uint32_t eta = 0x00ff;
+ static constexpr uint32_t phi = 0x00ff;
+ };
+
+ // struct masksCaloEGamma{
+ struct masksEGamma {
+ static constexpr uint32_t ET = 0x01ff;
+ static constexpr uint32_t eta = 0x00ff;
+ static constexpr uint32_t phi = 0x00ff;
+ static constexpr uint32_t iso = 0x0003;
+ };
+
+ // struct masksCaloTau{
+ struct masksTau {
+ static constexpr uint32_t ET = 0x01ff;
+ static constexpr uint32_t eta = 0x00ff;
+ static constexpr uint32_t phi = 0x00ff;
+ static constexpr uint32_t iso = 0x0003;
+ };
+
+ // struct masksCaloESums{
+ struct masksESums {
+ static constexpr uint32_t ETEt = 0x0fff; // Et of ET object
+ static constexpr uint32_t ETEttem = 0x0fff;
+ static constexpr uint32_t ETMinBiasHF = 0x000f;
+
+ static constexpr uint32_t HTEt = 0x0fff; // Et of HT object
+ static constexpr uint32_t HTtowerCount = 0x1fff;
+ static constexpr uint32_t HTMinBiasHF = 0x0003;
+
+ static constexpr uint32_t ETmissEt = 0x0fff;
+ static constexpr uint32_t ETmissPhi = 0x00ff;
+ static constexpr uint32_t ETmissASYMET = 0x00ff;
+ static constexpr uint32_t ETmissMinBiasHF = 0x0003;
+
+ static constexpr uint32_t HTmissEt = 0x0fff;
+ static constexpr uint32_t HTmissPhi = 0x00ff;
+ static constexpr uint32_t HTmissASYMHT = 0x00ff;
+ static constexpr uint32_t HTmissMinBiasHF = 0x0003;
+
+ static constexpr uint32_t ETHFmissEt = 0x0fff;
+ static constexpr uint32_t ETHFmissPhi = 0x00ff;
+ static constexpr uint32_t ETHFmissASYMETHF = 0x00ff;
+ static constexpr uint32_t ETHFmissCENT = 0x0003;
+
+ static constexpr uint32_t HTHFmissEt = 0x0fff;
+ static constexpr uint32_t HTHFmissPhi = 0x00ff;
+ static constexpr uint32_t HTHFmissASYMHTHF = 0x00ff;
+ static constexpr uint32_t HTHFmissCENT = 0x0003;
+ };
+}
+
+
+
+namespace bmtf {
+ struct masksStubs {
+ static constexpr uint64_t valid = 0x0001;
+ static constexpr uint64_t phi = 0x0fff;
+ static constexpr uint64_t phiB = 0x03ff;
+ static constexpr uint64_t qual = 0x0007;
+ static constexpr uint64_t eta = 0x007f;
+ static constexpr uint64_t qeta = 0x007f;
+ static constexpr uint64_t station = 0x0003;
+ static constexpr uint64_t wheel = 0x0007;
+ static constexpr uint64_t reserved = 0x0007;
+ static constexpr uint64_t bx = 0xffff;
+ };
+}
+
+
+
+struct header_masks {
+ static constexpr uint32_t bxmatch = 0x00ff << header_shifts::bxmatch;
+ static constexpr uint32_t mAcount = 0x000f << header_shifts::mAcount;
+ static constexpr uint32_t orbitmatch = 0x00ff << header_shifts::orbitmatch;
+ static constexpr uint32_t warningTestEnabled = 0x0001 << header_shifts::warningTestEnabled;
+ static constexpr uint32_t mBcount = 0x000f << header_shifts::mBcount;
+ static constexpr uint32_t sBmtfCount = 0x000f << header_shifts::sBmtfCount;
+};
+
+}
+#endif
diff --git a/EventFilter/L1ScoutingRawToDigi/interface/scales.h b/EventFilter/L1ScoutingRawToDigi/interface/scales.h
new file mode 100644
index 0000000000000..de9f4a1024257
--- /dev/null
+++ b/EventFilter/L1ScoutingRawToDigi/interface/scales.h
@@ -0,0 +1,32 @@
+#ifndef DF_S_SCALES_H
+#define DF_S_SCALES_H
+
+#include
+#include
+
+namespace scoutingRun3 {
+
+namespace ugmt {
+ // struct gmt_scales{
+ struct scales {
+ static constexpr float pt_scale = 0.5;
+ static constexpr float ptunconstrained_scale = 1.0;
+ static constexpr float phi_scale = 2.*M_PI/576.;
+ static constexpr float eta_scale = 0.0870/8; // 9th MS bit is sign
+ static constexpr float phi_range = M_PI;
+ };
+}
+
+
+
+namespace demux {
+ // struct gmt_scales{
+ struct scales {
+ static constexpr float phi_scale = 2.*M_PI/144.;
+ static constexpr float eta_scale = 0.0435;
+ static constexpr float et_scale = 0.5;
+ };
+}
+
+}
+#endif
diff --git a/EventFilter/L1ScoutingRawToDigi/interface/shifts.h b/EventFilter/L1ScoutingRawToDigi/interface/shifts.h
new file mode 100644
index 0000000000000..78ca418507744
--- /dev/null
+++ b/EventFilter/L1ScoutingRawToDigi/interface/shifts.h
@@ -0,0 +1,121 @@
+#ifndef DF_S_SHIFTS_H
+#define DF_S_SHIFTS_H
+
+#include
+
+namespace scoutingRun3 {
+
+namespace ugmt {
+ // struct shifts{
+ struct shiftsMuon {
+ // bx word: 16 bits used for actual bx, MS 4 bits are muon type
+ // 0xf intermediate,
+ // 0x0 final
+ // following 4 bits for link id
+ static constexpr uint32_t bx = 0;
+ static constexpr uint32_t interm = 31; // updated for new run3 format (tj)
+ // shifts for muon 64 bits
+ static constexpr uint32_t phiext = 0;
+ static constexpr uint32_t pt = 10;
+ static constexpr uint32_t qual = 19;
+ static constexpr uint32_t etaext = 23;
+ static constexpr uint32_t iso = 0;
+ static constexpr uint32_t chrg = 2;
+ static constexpr uint32_t chrgv = 3;
+ static constexpr uint32_t index = 4;
+ static constexpr uint32_t phi = 11;
+ static constexpr uint32_t eta1 = 13;
+ static constexpr uint32_t eta2 = 22;
+ static constexpr uint32_t ptuncon = 21;
+ static constexpr uint32_t dxy = 30;
+ };
+}
+
+
+
+namespace demux {
+ // struct shiftsCaloJet{
+ struct shiftsJet {
+ static constexpr uint32_t ET = 0;
+ static constexpr uint32_t eta = 11;
+ static constexpr uint32_t phi = 19;
+ };
+
+ // struct shiftsCaloEGamma{
+ struct shiftsEGamma {
+ static constexpr uint32_t ET = 0;
+ static constexpr uint32_t eta = 9;
+ static constexpr uint32_t phi = 17;
+ static constexpr uint32_t iso = 25;
+ };
+
+ // struct shiftsCaloTau{
+ struct shiftsTau {
+ static constexpr uint32_t ET = 0;
+ static constexpr uint32_t eta = 9;
+ static constexpr uint32_t phi = 17;
+ static constexpr uint32_t iso = 25;
+ };
+
+ // struct shiftsCaloESums{
+ struct shiftsESums {
+ static constexpr uint32_t ETEt = 0; // Et of ET object
+ static constexpr uint32_t ETEttem = 12;
+ static constexpr uint32_t ETMinBiasHF = 28;
+
+ static constexpr uint32_t HTEt = 0; // Et of HT object
+ static constexpr uint32_t HTtowerCount = 12;
+ static constexpr uint32_t HTMinBiasHF = 28;
+
+ static constexpr uint32_t ETmissEt = 0;
+ static constexpr uint32_t ETmissPhi = 12;
+ static constexpr uint32_t ETmissASYMET = 20;
+ static constexpr uint32_t ETmissMinBiasHF = 28;
+
+ static constexpr uint32_t HTmissEt = 0;
+ static constexpr uint32_t HTmissPhi = 12;
+ static constexpr uint32_t HTmissASYMHT = 20;
+ static constexpr uint32_t HTmissMinBiasHF = 28;
+
+ static constexpr uint32_t ETHFmissEt = 0;
+ static constexpr uint32_t ETHFmissPhi = 12;
+ static constexpr uint32_t ETHFmissASYMETHF = 20;
+ static constexpr uint32_t ETHFmissCENT = 28;
+
+ static constexpr uint32_t HTHFmissEt = 0;
+ static constexpr uint32_t HTHFmissPhi = 12;
+ static constexpr uint32_t HTHFmissASYMHTHF = 20;
+ static constexpr uint32_t HTHFmissCENT = 28;
+ };
+}
+
+
+
+namespace bmtf {
+ struct shiftsStubs {
+ static constexpr uint32_t valid = 0;
+ static constexpr uint32_t phi = 1;
+ static constexpr uint32_t phiB = 13;
+ static constexpr uint32_t qual = 23;
+ static constexpr uint32_t eta = 26;
+ static constexpr uint32_t qeta = 33;
+ static constexpr uint32_t station = 40;
+ static constexpr uint32_t wheel = 42;
+ static constexpr uint32_t reserved = 45;
+ static constexpr uint32_t bx = 48;
+ };
+}
+
+
+
+struct header_shifts {
+ static constexpr uint32_t bxmatch = 24;
+ static constexpr uint32_t mAcount = 16;
+ static constexpr uint32_t orbitmatch = 8;
+ static constexpr uint32_t warningTestEnabled = 8;
+ static constexpr uint32_t mBcount = 0;
+ static constexpr uint32_t sBmtfCount = 0;
+};
+
+}
+#endif
diff --git a/EventFilter/L1ScoutingRawToDigi/plugins/BuildFile.xml b/EventFilter/L1ScoutingRawToDigi/plugins/BuildFile.xml
new file mode 100644
index 0000000000000..32f0b6b906b36
--- /dev/null
+++ b/EventFilter/L1ScoutingRawToDigi/plugins/BuildFile.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/EventFilter/L1ScoutingRawToDigi/plugins/ScCALORawToDigi.cc b/EventFilter/L1ScoutingRawToDigi/plugins/ScCALORawToDigi.cc
new file mode 100644
index 0000000000000..eb6d1c84cf1d5
--- /dev/null
+++ b/EventFilter/L1ScoutingRawToDigi/plugins/ScCALORawToDigi.cc
@@ -0,0 +1,345 @@
+#include "EventFilter/L1ScoutingRawToDigi/plugins/ScCALORawToDigi.h"
+
+ScCaloRawToDigi::ScCaloRawToDigi(const edm::ParameterSet& iConfig) {
+ using namespace edm;
+ using namespace scoutingRun3;
+ srcInputTag = iConfig.getParameter( "srcInputTag" );
+ debug = iConfig.getUntrackedParameter("debug", false);
+
+ // produces().setBranchAlias( "JetOrbitCollection" );
+ // produces().setBranchAlias( "TauOrbitCollection" );
+ // produces().setBranchAlias( "EGammaOrbitCollection" );
+ // produces().setBranchAlias( "EtSumOrbitCollection" );
+
+ produces().setBranchAlias( "ScJetOrbitCollection" );
+ produces().setBranchAlias( "ScTauOrbitCollection" );
+ produces().setBranchAlias( "ScEGammaOrbitCollection" );
+ produces().setBranchAlias( "ScEtSumOrbitCollection" );
+
+ rawToken = consumes(srcInputTag);
+ }
+
+ScCaloRawToDigi::~ScCaloRawToDigi() {};
+
+void ScCaloRawToDigi::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
+ using namespace edm;
+ using namespace scoutingRun3;
+
+ Handle ScoutingRawDataCollection;
+ iEvent.getByToken( rawToken, ScoutingRawDataCollection );
+
+ const FEDRawData& sourceRawData = ScoutingRawDataCollection->FEDData(SDSNumbering::CaloSDSID);
+ size_t orbitSize = sourceRawData.size();
+
+ // std::unique_ptr unpackedJets(new JetOrbitCollection);
+ // std::unique_ptr unpackedTaus(new TauOrbitCollection);
+ // std::unique_ptr unpackedEGammas(new EGammaOrbitCollection);
+ // std::unique_ptr unpackedEtSums(new EtSumOrbitCollection);
+
+ std::unique_ptr unpackedJets(new ScJetOrbitCollection);
+ std::unique_ptr unpackedTaus(new ScTauOrbitCollection);
+ std::unique_ptr unpackedEGammas(new ScEGammaOrbitCollection);
+ std::unique_ptr unpackedEtSums(new ScEtSumOrbitCollection);
+
+ if((sourceRawData.size()==0) && debug ){
+ std::cout << "No raw data for CALO FED\n";
+ }
+
+ unpackOrbit(
+ unpackedJets.get(), unpackedTaus.get(),
+ unpackedEGammas.get(), unpackedEtSums.get(),
+ sourceRawData.data(), orbitSize
+ );
+
+ // store collections in the event
+ iEvent.put( std::move(unpackedJets) );
+ iEvent.put( std::move(unpackedTaus) );
+ iEvent.put( std::move(unpackedEGammas) );
+ iEvent.put( std::move(unpackedEtSums) );
+}
+
+void ScCaloRawToDigi::unpackOrbit(
+ scoutingRun3::ScJetOrbitCollection* jets, scoutingRun3::ScTauOrbitCollection* taus,
+ scoutingRun3::ScEGammaOrbitCollection* eGammas, scoutingRun3::ScEtSumOrbitCollection* etSums,
+ const unsigned char* buf, size_t len
+ ){
+
+ using namespace scoutingRun3;
+
+ size_t pos = 0;
+
+ while (pos < len) {
+
+ assert(pos+ (4+4+4+56*4) <= len); //sizeof(demux::block)
+
+ demux::block *bl = (demux::block *)(buf + pos);
+ pos += 4+4+4+56*4;
+
+ assert(pos <= len);
+ uint32_t orbit = bl->orbit & 0x7FFFFFFF;
+ uint32_t bx = bl->bx;
+
+ if(debug) {
+ std::cout << " CALO Orbit " << orbit << ", BX -> "<< bx << std::endl;
+ }
+
+ math::PtEtaPhiMLorentzVector vec;
+
+ int32_t ET(0), Eta(0), Phi(0), Iso(0);
+ //float fET(0), fEta(0), fPhi(0);
+
+ // unpack jets from first link
+ for (uint32_t i=0; i<6; i++) {
+ ET = ((bl->jet1[i] >> demux::shiftsJet::ET) & demux::masksJet::ET);
+
+ if (ET != 0) {
+ Eta = ((bl->jet1[i] >> demux::shiftsJet::eta) & demux::masksJet::eta);
+ Phi = ((bl->jet1[i] >> demux::shiftsJet::phi) & demux::masksJet::phi);
+ Iso = 0;
+
+ if (Eta > 127) Eta = Eta - 256;
+ // fPhi = Phi * demux::scales::phi_scale; fPhi = fPhi>=2.*M_PI ? fPhi-2.*M_PI : fPhi;
+ // fEta = Eta * demux::scales::eta_scale;
+ // fET = ET * demux::scales::et_scale;
+
+ //l1t::Jet jet(math::PtEtaPhiMLorentzVector(fET, fEta, fPhi, 0.), ET, Eta, Phi, Iso);
+ ScJet jet1(ET, Eta, Phi, 0);
+ jets->addBxObject(bx, jet1);
+
+
+ if (debug){
+ std::cout << "--- Jet link 1 ---\n";
+ std::cout <<"\tEt [GeV/Hw]: "<< jet1.getEt() << "/" << jet1.getHwEt() << "\n";
+ std::cout <<"\tEta [rad/Hw]: " << jet1.getEta() << "/" << jet1.getHwEta() << "\n";
+ std::cout <<"\tPhi [rad/Hw]: " << jet1.getPhi() << "/" << jet1.getHwPhi() << "\n";
+ }
+ }
+ } // end link1 jet unpacking loop
+
+ // unpack jets from second link
+ for (uint32_t i=0; i<6; i++) {
+ ET = ((bl->jet2[i] >> demux::shiftsJet::ET) & demux::masksJet::ET);
+
+ if (ET != 0) {
+ Eta = ((bl->jet2[i] >> demux::shiftsJet::eta) & demux::masksJet::eta);
+ Phi = ((bl->jet2[i] >> demux::shiftsJet::phi) & demux::masksJet::phi);
+ Iso = 0;
+
+ if (Eta > 127) Eta = Eta - 256;
+ // fPhi = Phi * demux::scales::phi_scale; fPhi = fPhi>=2.*M_PI ? fPhi-2.*M_PI : fPhi;
+ // fEta = Eta * demux::scales::eta_scale;
+ // fET = ET * demux::scales::et_scale;
+
+ //l1t::Jet jet(math::PtEtaPhiMLorentzVector(fET, fEta, fPhi, 0.), ET, Eta, Phi, Iso);
+ ScJet jet2(ET, Eta, Phi, 0);
+ jets->addBxObject(bx, jet2);
+
+ if (debug){
+ std::cout << "--- Jet link 2 ---\n";
+ std::cout <<"\tEt [GeV/Hw]: " << jet2.getEt() << "/" << jet2.getHwEt() << "\n";
+ std::cout <<"\tEta [rad/Hw]: " << jet2.getEta() << "/" << jet2.getHwEta() << "\n";
+ std::cout <<"\tPhi [rad/Hw]: " << jet2.getPhi() << "/" << jet2.getHwPhi() << "\n";
+ }
+ }
+ } // end link1 jet unpacking loop
+
+ // unpack eg from first link
+ for (uint32_t i=0; i<6; i++) {
+ ET = ((bl->egamma1[i] >> demux::shiftsEGamma::ET) & demux::masksEGamma::ET);
+ if (ET != 0) {
+ Eta = ((bl->egamma1[i] >> demux::shiftsEGamma::eta) & demux::masksEGamma::eta);
+ Phi = ((bl->egamma1[i] >> demux::shiftsEGamma::phi) & demux::masksEGamma::phi);
+ Iso = ((bl->egamma1[i] >> demux::shiftsEGamma::iso) & demux::masksEGamma::iso);
+
+ if (Eta > 127) Eta = Eta - 256;
+ // fPhi = Phi * demux::scales::phi_scale; fPhi = fPhi>=2.*M_PI ? fPhi-2.*M_PI : fPhi;
+ // fEta = Eta * demux::scales::eta_scale;
+ // fET = ET * demux::scales::et_scale;
+
+ //l1t::EGamma eGamma(math::PtEtaPhiMLorentzVector(fET, fEta, fPhi, 0.), ET, Eta, Phi, 0, Iso);
+ ScEGamma eGamma1(ET, Eta, Phi, Iso);
+ eGammas->addBxObject(bx, eGamma1);
+
+ if (debug){
+ std::cout << "--- E/g link 1 ---\n";
+ std::cout <<"\tEt [GeV/Hw]: " << eGamma1.getEt() << "/" << eGamma1.getHwEt() << "\n";
+ std::cout <<"\tEta [rad/Hw]: " << eGamma1.getEta() << "/" << eGamma1.getHwEta() << "\n";
+ std::cout <<"\tPhi [rad/Hw]: " << eGamma1.getPhi() << "/" << eGamma1.getHwPhi() << "\n";
+ std::cout <<"\tIso [Hw]: " << eGamma1.getIso() << "\n";
+ }
+ }
+ } // end eg link 1
+
+ // unpack eg from second link link
+ for (uint32_t i=0; i<6; i++) {
+ ET = ((bl->egamma2[i] >> demux::shiftsEGamma::ET) & demux::masksEGamma::ET);
+ if (ET != 0) {
+ Eta = ((bl->egamma2[i] >> demux::shiftsEGamma::eta) & demux::masksEGamma::eta);
+ Phi = ((bl->egamma2[i] >> demux::shiftsEGamma::phi) & demux::masksEGamma::phi);
+ Iso = ((bl->egamma2[i] >> demux::shiftsEGamma::iso) & demux::masksEGamma::iso);
+
+ if (Eta > 127) Eta = Eta - 256;
+ // fPhi = Phi * demux::scales::phi_scale; fPhi = fPhi>=2.*M_PI ? fPhi-2.*M_PI : fPhi;
+ // fEta = Eta * demux::scales::eta_scale;
+ // fET = ET * demux::scales::et_scale;
+
+ //l1t::EGamma eGamma(math::PtEtaPhiMLorentzVector(fET, fEta, fPhi, 0.), ET, Eta, Phi, 0, Iso);
+ ScEGamma eGamma2(ET, Eta, Phi, Iso);
+ eGammas->addBxObject(bx, eGamma2);
+
+ if (debug){
+ std::cout << "--- E/g link 2 ---\n";
+ std::cout <<"\tEt [GeV/Hw]: " << eGamma2.getEt() << "/" << eGamma2.getHwEt() << "\n";
+ std::cout <<"\tEta [rad/Hw]: " << eGamma2.getEta() << "/" << eGamma2.getHwEta() << "\n";
+ std::cout <<"\tPhi [rad/Hw]: " << eGamma2.getPhi() << "/" << eGamma2.getHwPhi() << "\n";
+ std::cout <<"\tIso [Hw]: " << eGamma2.getIso() << "\n";
+ }
+ }
+
+ } // end of eg unpacker
+
+ // unpack taus from first link
+ for (uint32_t i=0; i<6; i++) {
+ ET = ((bl->tau1[i] >> demux::shiftsTau::ET) & demux::masksTau::ET);
+ if (ET != 0) {
+ Eta = ((bl->tau1[i] >> demux::shiftsTau::eta) & demux::masksTau::eta);
+ Phi = ((bl->tau1[i] >> demux::shiftsTau::phi) & demux::masksTau::phi);
+ Iso = ((bl->tau1[i] >> demux::shiftsTau::iso) & demux::masksTau::iso);
+
+ if (Eta > 127) Eta = Eta - 256;
+ // fPhi = Phi * demux::scales::phi_scale; fPhi = fPhi>=2.*M_PI ? fPhi-2.*M_PI : fPhi;
+ // fEta = Eta * demux::scales::eta_scale;
+ // fET = ET * demux::scales::et_scale;
+
+ //l1t::Tau tau(math::PtEtaPhiMLorentzVector(fET, fEta, fPhi, 0.), ET, Eta, Phi, 0, Iso);
+ ScTau tau1(ET, Eta, Phi, Iso);
+ taus->addBxObject(bx, tau1);
+
+ if (debug){
+ std::cout << "--- Tau link 1 ---\n";
+ std::cout <<"\tEt [GeV/Hw]: " << tau1.getEt() << "/" << tau1.getHwEt() << "\n";
+ std::cout <<"\tEta [rad/Hw]: " << tau1.getEta() << "/" << tau1.getHwEta() << "\n";
+ std::cout <<"\tPhi [rad/Hw]: " << tau1.getPhi() << "/" << tau1.getHwPhi() << "\n";
+ std::cout <<"\tIso [Hw]: " << tau1.getIso() << "\n";
+ }
+ }
+ } // end tau link 1
+
+ // unpack taus from second link
+ for (uint32_t i=0; i<6; i++) {
+ ET = ((bl->tau2[i] >> demux::shiftsTau::ET) & demux::masksTau::ET);
+ if (ET != 0) {
+ Eta = ((bl->tau2[i] >> demux::shiftsTau::eta) & demux::masksTau::eta);
+ Phi = ((bl->tau2[i] >> demux::shiftsTau::phi) & demux::masksTau::phi);
+ Iso = ((bl->tau2[i] >> demux::shiftsTau::iso) & demux::masksTau::iso);
+
+ if (Eta > 127) Eta = Eta - 256;
+ // fPhi = Phi * demux::scales::phi_scale; fPhi = fPhi>=2.*M_PI ? fPhi-2.*M_PI : fPhi;
+ // fEta = Eta * demux::scales::eta_scale;
+ // fET = ET * demux::scales::et_scale;
+
+ //l1t::Tau tau(math::PtEtaPhiMLorentzVector(fET, fEta, fPhi, 0.), ET, Eta, Phi, 0, Iso);
+ ScTau tau2(ET, Eta, Phi, Iso);
+ taus->addBxObject(bx, tau2);
+
+ if (debug){
+ std::cout << "--- Tau link 2 ---\n";
+ std::cout <<"\tEt [GeV/Hw]: " << tau2.getEt() << "/" << tau2.getHwEt() << "\n";
+ std::cout <<"\tEta [rad/Hw]: " << tau2.getEta() << "/" << tau2.getHwEta() << "\n";
+ std::cout <<"\tPhi [rad/Hw]: " << tau2.getPhi() << "/" << tau2.getHwPhi() << "\n";
+ std::cout <<"\tIso [Hw]: " << tau2.getIso() << "\n";
+ }
+ }
+ } // end tau unpacker
+
+ // unpack et sums
+
+ int32_t ETEt(0), HTEt(0), ETmissEt(0), ETmissPhi(0), HTmissEt(0), HTmissPhi(0);
+ // float fETEt(0), fHTEt(0), fETmissEt(0), fHTmissEt(0), fETmissPhi(0), fHTmissPhi(0);
+
+ // ET
+ ETEt = ((bl->sum[0] >> demux::shiftsESums::ETEt) & demux::masksESums::ETEt);
+ // fETEt = ETEt * demux::scales::et_scale;
+
+ //l1t::EtSum sum = l1t::EtSum(math::PtEtaPhiMLorentzVector(fETEt, 0, 0, 0.), l1t::EtSum::EtSumType::kTotalEt, ETEt);
+ ScEtSum sumTotEt(ETEt, 0, l1t::EtSum::EtSumType::kTotalEt);
+ etSums->addBxObject(bx, sumTotEt);
+
+ // HT
+ HTEt = ((bl->sum[1] >> demux::shiftsESums::HTEt) & demux::masksESums::HTEt);
+ // fHTEt = HTEt * demux::scales::et_scale;
+
+ //sum = l1t::EtSum(math::PtEtaPhiMLorentzVector(fHTEt, 0, 0, 0.), l1t::EtSum::EtSumType::kTotalHt, HTEt);
+ ScEtSum sumTotHt(HTEt, 0, l1t::EtSum::EtSumType::kTotalHt);
+ etSums->addBxObject(bx, sumTotHt);
+
+ // ETMiss
+ ETmissEt = ((bl->sum[2] >> demux::shiftsESums::ETmissEt) & demux::masksESums::ETmissEt);
+ ETmissPhi = ((bl->sum[2] >> demux::shiftsESums::ETmissPhi) & demux::masksESums::ETmissPhi);
+ // fETmissEt = ETmissEt * demux::scales::et_scale;
+ // fETmissPhi = ETmissPhi * demux::scales::phi_scale;
+ // fETmissPhi = fETmissPhi>2.*M_PI? fETmissPhi - 2.*M_PI : fETmissPhi;
+
+ //sum = l1t::EtSum(math::PtEtaPhiMLorentzVector(fETmissEt, 0, fETmissPhi, 0.), l1t::EtSum::EtSumType::kMissingEt, ETmissEt, 0, ETmissPhi);
+
+ ScEtSum sumMissEt(ETmissEt, ETmissPhi, l1t::EtSum::EtSumType::kMissingEt);
+ etSums->addBxObject(bx, sumMissEt);
+
+ // HTMiss
+ HTmissEt = ((bl->sum[3] >> demux::shiftsESums::HTmissEt) & demux::masksESums::HTmissEt);
+ HTmissPhi = ((bl->sum[3] >> demux::shiftsESums::HTmissPhi) & demux::masksESums::HTmissPhi);
+ // fHTmissEt = HTmissEt * demux::scales::et_scale;
+ // fHTmissPhi = HTmissPhi * demux::scales::phi_scale;
+ // fHTmissPhi = fHTmissPhi>2.*M_PI? fHTmissPhi - 2.*M_PI : fHTmissPhi;
+
+ ScEtSum sumMissHt(HTmissEt, HTmissPhi, l1t::EtSum::EtSumType::kMissingHt);
+ etSums->addBxObject(bx, sumMissHt);
+
+
+ // // ETHFMiss
+ // ETHFmissEt = ((bl->sum[4] >> demux::shiftsESums::ETHFmissEt) & demux::masksESums::ETHFmissEt);
+ // ETHFmissPhi = ((bl->sum[4] >> demux::shiftsESums::ETHFmissPhi) & demux::masksESums::ETHFmissPhi);
+ // ETHFmissASYMETHF = ((bl->sum[4] >> demux::shiftsESums::ETHFmissASYMETHF) & demux::masksESums::ETHFmissASYMETHF);
+ // //ETHFmissCENT = ((bl.sum[4] >> demux::shiftsESums::ETHFmissCENT) & demux::masksESums::ETHFmissCENT);
+
+ // sum = l1t::EtSum(*dummyLVec_, l1t::EtSum::EtSumType::kMissingEtHF, ETHFmissEt, 0, ETHFmissPhi);
+ // etSums->push_back(bx, sum);
+ // sum = l1t::EtSum(*dummyLVec_, l1t::EtSum::EtSumType::kAsymEtHF, ETHFmissASYMETHF);
+ // etSums->push_back(bx, sum);
+
+
+ // // HTHFMiss
+ // HTHFmissEt = ((bl->sum[5] >> demux::shiftsESums::HTHFmissEt) & demux::masksESums::HTHFmissEt);
+ // HTHFmissPhi = ((bl->sum[5] >> demux::shiftsESums::HTHFmissPhi) & demux::masksESums::HTHFmissPhi);
+ // HTHFmissASYMHTHF = ((bl->sum[5] >> demux::shiftsESums::HTHFmissASYMHTHF) & demux::masksESums::HTHFmissASYMHTHF);
+ // //HTHFmissCENT = ((bl->sum[5] >> demux::shiftsESums::HTHFmissCENT) & demux::masksESums::HTHFmissCENT);
+
+ // sum = l1t::EtSum(*dummyLVec_, l1t::EtSum::EtSumType::kMissingHtHF, HTHFmissEt, 0, HTHFmissPhi);
+ // etSums->push_back(bx, sum);
+ // sum = l1t::EtSum(*dummyLVec_, l1t::EtSum::EtSumType::kAsymHtHF, HTHFmissASYMHTHF);
+ // etSums->push_back(bx, sum);
+
+ // add sums to event
+ // etSums->push_back(bx, bx_etSums);
+
+ } // end of orbit loop
+
+ jets->flatten();
+ eGammas->flatten();
+ taus->flatten();
+ etSums->flatten();
+
+}
+
+void ScCaloRawToDigi::unpackRawJet(std::vector& jets, uint32_t *rawData){
+
+ return;
+}
+
+void ScCaloRawToDigi::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
+ edm::ParameterSetDescription desc;
+ desc.setUnknown();
+ descriptions.addDefault(desc);
+}
+
+DEFINE_FWK_MODULE(ScCaloRawToDigi);
diff --git a/EventFilter/L1ScoutingRawToDigi/plugins/ScCALORawToDigi.h b/EventFilter/L1ScoutingRawToDigi/plugins/ScCALORawToDigi.h
new file mode 100644
index 0000000000000..ce82c6e19c886
--- /dev/null
+++ b/EventFilter/L1ScoutingRawToDigi/plugins/ScCALORawToDigi.h
@@ -0,0 +1,57 @@
+#include
+#include "FWCore/Framework/interface/Frameworkfwd.h"
+#include "FWCore/Framework/interface/stream/EDProducer.h"
+#include "FWCore/Framework/interface/Event.h"
+#include "FWCore/Framework/interface/MakerMacros.h"
+#include "FWCore/ParameterSet/interface/ParameterSet.h"
+#include "FWCore/Utilities/interface/StreamID.h"
+
+#include "DataFormats/FEDRawData/interface/FEDRawData.h"
+#include "DataFormats/L1ScoutingRawData/interface/SDSNumbering.h"
+#include "DataFormats/L1ScoutingRawData/interface/SDSRawDataCollection.h"
+#include "DataFormats/L1Scouting/interface/OrbitCollection.h"
+
+#include "DataFormats/L1Trigger/interface/EGamma.h"
+#include "DataFormats/L1Trigger/interface/Jet.h"
+#include "DataFormats/L1Trigger/interface/Tau.h"
+#include "DataFormats/L1Trigger/interface/EtSum.h"
+
+#include "DataFormats/L1Scouting/interface/L1ScoutingCalo.h"
+
+#include "EventFilter/L1ScoutingRawToDigi/interface/shifts.h"
+#include "EventFilter/L1ScoutingRawToDigi/interface/scales.h"
+#include "EventFilter/L1ScoutingRawToDigi/interface/masks.h"
+#include "EventFilter/L1ScoutingRawToDigi/interface/blocks.h"
+
+class ScCaloRawToDigi : public edm::stream::EDProducer<> {
+public:
+ explicit ScCaloRawToDigi(const edm::ParameterSet&);
+ ~ScCaloRawToDigi() override;
+
+ static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
+
+private:
+ void produce(edm::Event&, const edm::EventSetup&) override;
+
+ void unpackOrbit(
+ //l1t::JetBxCollection* jets, l1t::TauBxCollection* taus,
+ //l1t::EGammaBxCollection* eGammas, l1t::EtSumBxCollection* etSums,
+ scoutingRun3::ScJetOrbitCollection* jets, scoutingRun3::ScTauOrbitCollection* taus,
+ scoutingRun3::ScEGammaOrbitCollection* eGammas, scoutingRun3::ScEtSumOrbitCollection* etSums,
+ const unsigned char* buf, size_t len
+ );
+
+ void unpackRawJet(std::vector& jets, uint32_t *rawData);
+
+ // std::vector bx_jets;
+ // std::vector bx_taus;
+ // std::vector bx_eGammas;
+ // std::vector bx_etSums;
+
+ std::unique_ptr>> dummyLVec_;
+
+ bool debug = false;
+
+ edm::InputTag srcInputTag;
+ edm::EDGetToken rawToken;
+};
diff --git a/EventFilter/L1ScoutingRawToDigi/plugins/ScGMTRawToDigi.cc b/EventFilter/L1ScoutingRawToDigi/plugins/ScGMTRawToDigi.cc
new file mode 100644
index 0000000000000..f31de17ce250d
--- /dev/null
+++ b/EventFilter/L1ScoutingRawToDigi/plugins/ScGMTRawToDigi.cc
@@ -0,0 +1,235 @@
+#include "EventFilter/L1ScoutingRawToDigi/plugins/ScGMTRawToDigi.h"
+
+ScGMTRawToDigi::ScGMTRawToDigi(const edm::ParameterSet& iConfig) {
+ using namespace edm;
+ srcInputTag = iConfig.getParameter( "srcInputTag" );
+ debug_ = iConfig.getUntrackedParameter("debug", false);
+
+ //produces().setBranchAlias( "MuonOrbitCollection" );
+ produces().setBranchAlias( "ScMuonOrbitCollection" );
+ rawToken = consumes(srcInputTag);
+
+ bx_muons.reserve(8);
+ //dummyLVec_.reset( new ROOT::Math::LorentzVector>() );
+}
+
+ScGMTRawToDigi::~ScGMTRawToDigi() {};
+
+void ScGMTRawToDigi::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
+ using namespace edm;
+
+ Handle ScoutingRawDataCollection;
+ iEvent.getByToken( rawToken, ScoutingRawDataCollection );
+
+ const FEDRawData& sourceRawData = ScoutingRawDataCollection->FEDData(SDSNumbering::GmtSDSID);
+ size_t orbitSize = sourceRawData.size();
+
+ //std::unique_ptr unpackedMuons(new scoutingRun3::MuonOrbitCollection);
+ std::unique_ptr unpackedMuons(new scoutingRun3::ScMuonOrbitCollection);
+
+ if((sourceRawData.size()==0) && debug_){
+ std::cout << "No raw data for GMT FED\n";
+ }
+
+ unpackOrbit(unpackedMuons.get(), sourceRawData.data(), orbitSize);
+
+ // store collection in the event
+ iEvent.put( std::move(unpackedMuons) );
+}
+
+void ScGMTRawToDigi::unpackOrbit(
+ //l1t::MuonBxCollection* muons,
+ scoutingRun3::ScMuonOrbitCollection* muons,
+ const unsigned char* buf, size_t len
+ ){
+
+ using namespace scoutingRun3;
+ size_t pos = 0;
+
+ //muons->setBXRange(0,3565);
+
+ while (pos < len) {
+ assert(pos+4 <= len);
+
+ // get BX header
+ uint32_t header = *((uint32_t*)(buf + pos));
+ pos += 4;
+ // count mA and mB
+ uint32_t mAcount = (header & header_masks::mAcount) >> header_shifts::mAcount;
+ uint32_t mBcount = (header & header_masks::mBcount) >> header_shifts::mBcount;
+
+ // declare block to read
+ ugmt::block *bl = (ugmt::block *)(buf + pos);
+ pos += 4 + 4 + (mAcount+mBcount)*12;
+ assert(pos <= len);
+
+ uint32_t orbit = bl->orbit & 0x7FFFFFFF;
+ uint32_t bx = bl->bx;
+
+ if (debug_){
+ std::cout << " GMT Orbit " << orbit << ", BX -> "<< bx << ", nMuons -> " << mAcount+mBcount << std::endl;
+ }
+
+ // Unpack muons for this BX
+
+ bx_muons.clear();
+
+ // cuts should be applied
+ bool excludeIntermediate=true;
+ int ptcut=0;
+ unsigned int qualcut=0;
+
+ for (unsigned int i=0; imu[i].extra >> ugmt::shiftsMuon::interm) & ugmt::masksMuon::interm;
+ if (excludeIntermediate && (interm == 1)){
+ if (debug_){
+ std::cout << "Excluding intermediate muon\n";
+ }
+ continue;
+ }
+
+ uint32_t index = (bl->mu[i].s >> ugmt::shiftsMuon::index) & ugmt::masksMuon::index;
+ uint32_t ietaextu = (bl->mu[i].f >> ugmt::shiftsMuon::etaext) & ugmt::masksMuon::etaextv;
+ int32_t ietaext;
+ if (((bl->mu[i].f >> ugmt::shiftsMuon::etaext) & ugmt::masksMuon::etaexts)!=0) {
+ ietaext = ietaextu -= 256;
+ } else {
+ ietaext = ietaextu;
+ }
+
+ // extract pt and quality and apply cut if required
+ int32_t iptuncon = (bl->mu[i].s >> ugmt::shiftsMuon::ptuncon) & ugmt::masksMuon::ptuncon;
+ int32_t ipt = (bl->mu[i].f >> ugmt::shiftsMuon::pt) & ugmt::masksMuon::pt;
+ if ((ipt-1) < ptcut) {
+ continue;
+ }
+ uint32_t qual = (bl->mu[i].f >> ugmt::shiftsMuon::qual) & ugmt::masksMuon::qual;
+ if (qual < qualcut) {
+ continue;
+ }
+
+ // extract integer value for extrapolated phi
+ int32_t iphiext = ((bl->mu[i].f >> ugmt::shiftsMuon::phiext) & ugmt::masksMuon::phiext);
+
+ // extract integer value for extrapolated phi
+ int32_t idxy = ((bl->mu[i].s >> ugmt::shiftsMuon::dxy) & ugmt::masksMuon::dxy);
+
+ // extract iso bits and charge
+ uint32_t iso = (bl->mu[i].s >> ugmt::shiftsMuon::iso) & ugmt::masksMuon::iso;
+ int32_t chrg = 0;
+ if (((bl->mu[i].s >> ugmt::shiftsMuon::chrgv) & ugmt::masksMuon::chrgv)==1)
+ chrg=((bl->mu[i].s >> ugmt::shiftsMuon::chrg) & ugmt::masksMuon::chrg)==1 ? -1 : 1 ;
+
+ // extract eta and phi at muon station
+ int32_t iphi = (bl->mu[i].s >> ugmt::shiftsMuon::phi) & ugmt::masksMuon::phi;
+ uint32_t ieta1 = (bl->mu[i].extra >> ugmt::shiftsMuon::eta1) & ugmt::masksMuon::eta;
+ uint32_t ieta2 = (bl->mu[i].extra >> ugmt::shiftsMuon::eta2) & ugmt::masksMuon::eta;
+
+
+ uint32_t ieta_u;
+ int32_t ieta;
+ // checking if raw eta should be taken from muon 1 or muon 2
+ if ( (bl->mu[i].extra & 0x1) == 0 ) {
+ ieta_u = ieta1;
+ } else {
+ ieta_u = ieta2;
+ }
+
+ // two's complement
+ if ( ieta_u > 256 ) {
+ ieta = ieta_u - 512;
+ } else {
+ ieta = ieta_u;
+ }
+
+ // convert to physical units using scales
+ float fpt = (ipt -1) * ugmt::scales::pt_scale; // -1 since bin 0 is for invalid muons
+ float fptuncon = (iptuncon-1) * ugmt::scales::ptunconstrained_scale; // -1 since bin 0 is for invalid muons
+ float fphi = iphi * ugmt::scales::phi_scale;
+ float fphiext = iphiext * ugmt::scales::phi_scale;
+ float feta = ieta * ugmt::scales::eta_scale;
+ float fetaext = ietaext * ugmt::scales::eta_scale;
+
+ if (fphiext>M_PI) fphiext = fphiext - 2.*M_PI;
+ if (fphi >M_PI) fphi = fphi - 2.*M_PI;
+
+ // l1t::Muon muon;
+ // math::PtEtaPhiMLorentzVector vec{fpt, feta, fphi, 0.};
+
+ // muon.setP4(vec);
+ // muon.setHwPt(ipt);
+ // muon.setHwEta(ieta);
+ // muon.setHwPhi(iphi);
+ // muon.setHwQual(qual);
+ // muon.setHwCharge(chrg);
+ // muon.setHwChargeValid(chrg != 0);
+ // muon.setHwIso(iso);
+ // muon.setTfMuonIndex(index);
+ // muon.setHwEtaAtVtx(ietaext);
+ // muon.setHwPhiAtVtx(iphiext);
+ // muon.setEtaAtVtx(fetaext);
+ // muon.setPhiAtVtx(fphiext);
+ // muon.setHwPtUnconstrained(iptuncon);
+ // muon.setPtUnconstrained(fptuncon);
+ // muon.setHwDXY(idxy);
+
+ // ScMuon muon;
+
+ // muon.pt = ipt;
+ // muon.eta = ieta;
+ // muon.phi = iphi;
+ // muon.qual = qual;
+ // muon.chrg = chrg;
+ // muon.chrgv = chrg!=0;
+ // muon.iso = iso;
+ // muon.index = index;
+ // muon.etae = ietaext;
+ // muon.phie = iphiext;
+ // muon.ptUncon = iptuncon;
+
+ scoutingRun3::ScMuon muon(
+ ipt,
+ ieta,
+ iphi,
+ qual,
+ chrg,
+ chrg!=0,
+ iso,
+ index,
+ ietaext,
+ iphiext,
+ iptuncon,
+ idxy
+ );
+
+ muons->addBxObject(bx, muon);
+
+ // if (debug_){
+ // std::cout<<"--- Muon ---\n";
+ // std::cout<<"\tPt [GeV/Hw]: " << muon.pt() << "/" << muon.hwPt() << "\n";
+ // std::cout<<"\tEta [rad/Hw]: " << muon.eta() << "/" << muon.hwEta() << "\n";
+ // std::cout<<"\tPhi [rad/Hw]: " << muon.phi() << "/" << muon.hwPhi() << "\n";
+ // std::cout<<"\tCharge/valid: " << muon.hwCharge() << "/" << muon.hwChargeValid() << "\n";
+ // std::cout<<"\tPhiVtx [rad/Hw]: " << muon.phiAtVtx() << "/" << muon.hwPhiAtVtx() << "\n";
+ // std::cout<<"\tEtaVtx [rad/Hw]: " << muon.etaAtVtx() << "/" << muon.hwEtaAtVtx() << "\n";
+ // std::cout<<"\tPt uncon[GeV/Hw]: " << muon.ptUnconstrained() << "/" << muon.hwPtUnconstrained() << "\n";
+ // std::cout<<"\tDxy: " << muon.hwDXY() << "\n";
+ // std::cout<<"\tTF index: " << muon.tfMuonIndex() << "\n";
+ // }
+
+ } // end of bx
+
+ } // end orbit while loop
+
+ muons->flatten();
+
+}
+
+void ScGMTRawToDigi::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
+ edm::ParameterSetDescription desc;
+ desc.setUnknown();
+ descriptions.addDefault(desc);
+}
+
+DEFINE_FWK_MODULE(ScGMTRawToDigi);
diff --git a/EventFilter/L1ScoutingRawToDigi/plugins/ScGMTRawToDigi.h b/EventFilter/L1ScoutingRawToDigi/plugins/ScGMTRawToDigi.h
new file mode 100644
index 0000000000000..988ecff56edd7
--- /dev/null
+++ b/EventFilter/L1ScoutingRawToDigi/plugins/ScGMTRawToDigi.h
@@ -0,0 +1,47 @@
+#include
+#include "FWCore/Framework/interface/Frameworkfwd.h"
+#include "FWCore/Framework/interface/stream/EDProducer.h"
+#include "FWCore/Framework/interface/Event.h"
+#include "FWCore/Framework/interface/MakerMacros.h"
+#include "FWCore/ParameterSet/interface/ParameterSet.h"
+#include "FWCore/Utilities/interface/StreamID.h"
+
+#include "DataFormats/FEDRawData/interface/FEDRawData.h"
+#include "DataFormats/L1ScoutingRawData/interface/SDSNumbering.h"
+#include "DataFormats/L1ScoutingRawData/interface/SDSRawDataCollection.h"
+#include "DataFormats/L1Scouting/interface/OrbitCollection.h"
+
+#include "DataFormats/L1Trigger/interface/Muon.h"
+#include "DataFormats/L1Scouting/interface/L1ScoutingMuon.h"
+
+#include "EventFilter/L1ScoutingRawToDigi/interface/shifts.h"
+#include "EventFilter/L1ScoutingRawToDigi/interface/scales.h"
+#include "EventFilter/L1ScoutingRawToDigi/interface/masks.h"
+#include "EventFilter/L1ScoutingRawToDigi/interface/blocks.h"
+
+class ScGMTRawToDigi : public edm::stream::EDProducer<> {
+public:
+ explicit ScGMTRawToDigi(const edm::ParameterSet&);
+ ~ScGMTRawToDigi() override;
+
+ static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
+
+private:
+ //void beginStream(edm::StreamID) override;
+ void produce(edm::Event&, const edm::EventSetup&) override;
+ //void endStream() override;
+
+ void unpackOrbit(
+ scoutingRun3::ScMuonOrbitCollection* muons,
+ //l1t::MuonBxCollection* muons,
+ const unsigned char* buf, size_t len
+ );
+
+ std::vector bx_muons;
+ std::unique_ptr>> dummyLVec_;
+
+ bool debug_ = false;
+
+ edm::InputTag srcInputTag;
+ edm::EDGetToken rawToken;
+};