File indexing completed on 2025-08-14 02:08:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "FWCore/PluginManager/interface/ModuleDef.h"
0012 #include "FWCore/Framework/interface/MakerMacros.h"
0013
0014 #include <iostream>
0015 #include <vector>
0016
0017 #include "DPGAnalysis/MuonTools/interface/MuBaseFlatTableProducer.h"
0018 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0019 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0020 #include "FWCore/Framework/interface/ConsumesCollector.h"
0021 #include "DataFormats/TCDS/interface/TCDSRecord.h"
0022
0023 class MuGEML1FETableProducer : public MuBaseFlatTableProducer {
0024 public:
0025
0026 MuGEML1FETableProducer(const edm::ParameterSet&);
0027
0028
0029 static void fillDescriptions(edm::ConfigurationDescriptions&);
0030
0031 protected:
0032
0033 void fillTable(edm::Event&) final;
0034
0035
0036 void getFromES(const edm::Run&, const edm::EventSetup&) final;
0037
0038 private:
0039 nano_mu::EDTokenHandle<TCDSRecord> m_token;
0040 static constexpr int BX_IN_ORBIT = 3564;
0041 };
0042
0043 MuGEML1FETableProducer::MuGEML1FETableProducer(const edm::ParameterSet& config)
0044 : MuBaseFlatTableProducer{config}, m_token{config, consumesCollector(), "src"} {
0045 produces<nanoaod::FlatTable>();
0046 }
0047
0048 void MuGEML1FETableProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0049 edm::ParameterSetDescription desc;
0050
0051 desc.add<std::string>("name", "l1aHistory");
0052 desc.add<edm::InputTag>("src", edm::InputTag{"tcdsDigis:tcdsRecord"});
0053
0054 descriptions.addWithDefaultLabel(desc);
0055 }
0056
0057 void MuGEML1FETableProducer::getFromES(const edm::Run& run, const edm::EventSetup& environment) {}
0058
0059 void MuGEML1FETableProducer::fillTable(edm::Event& ev) {
0060 std::vector<int> bxDiffs;
0061
0062 auto record = m_token.conditionalGet(ev);
0063
0064
0065
0066 for (const auto l1aEntry : record->getFullL1aHistory()) {
0067 int bxDiff = BX_IN_ORBIT * (record->getOrbitNr() - l1aEntry.getOrbitNr()) + record->getBXID() - l1aEntry.getBXID();
0068 bxDiffs.push_back(bxDiff);
0069 }
0070
0071 auto table = std::make_unique<nanoaod::FlatTable>(bxDiffs.size(), m_name, false, false);
0072 addColumn(table, "bxDiffs", bxDiffs, "BX differences between event and L1As");
0073
0074 ev.put(std::move(table));
0075 }
0076
0077 DEFINE_FWK_MODULE(MuGEML1FETableProducer);