|
| 1 | +/** \class MuGEML1FETableProducer MuGEML1FETableProducer.cc DPGAnalysis/MuonTools/src/MuGEML1FETableProducer.cc |
| 2 | + * |
| 3 | + * Helper class : FlatTableProducer for GEM Flower Event (reading FED RAW Data) |
| 4 | + * |
| 5 | + * \author Jeewon Heo |
| 6 | + * based on code written by C.Battilana (INFN BO) |
| 7 | + * |
| 8 | + */ |
| 9 | + |
| 10 | +//#include "FWCore/ParameterSet/interface/allowedValues.h" |
| 11 | +#include "FWCore/PluginManager/interface/ModuleDef.h" |
| 12 | +#include "FWCore/Framework/interface/MakerMacros.h" |
| 13 | + |
| 14 | +#include <iostream> |
| 15 | +#include <vector> |
| 16 | + |
| 17 | +#include "DPGAnalysis/MuonTools/interface/MuBaseFlatTableProducer.h" |
| 18 | +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" |
| 19 | +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" |
| 20 | +#include "FWCore/Framework/interface/ConsumesCollector.h" |
| 21 | +#include "DataFormats/TCDS/interface/TCDSRecord.h" |
| 22 | + |
| 23 | +class MuGEML1FETableProducer : public MuBaseFlatTableProducer { |
| 24 | +public: |
| 25 | + /// Constructor |
| 26 | + MuGEML1FETableProducer(const edm::ParameterSet&); |
| 27 | + |
| 28 | + /// Fill descriptors |
| 29 | + static void fillDescriptions(edm::ConfigurationDescriptions&); |
| 30 | + |
| 31 | +protected: |
| 32 | + /// Fill tree branches for a given event |
| 33 | + void fillTable(edm::Event&) final; |
| 34 | + |
| 35 | + /// Get info from the ES by run |
| 36 | + void getFromES(const edm::Run&, const edm::EventSetup&) final; |
| 37 | + |
| 38 | +private: |
| 39 | + nano_mu::EDTokenHandle<TCDSRecord> m_token; |
| 40 | + static constexpr int BX_IN_ORBIT = 3564; |
| 41 | +}; |
| 42 | + |
| 43 | +MuGEML1FETableProducer::MuGEML1FETableProducer(const edm::ParameterSet& config) |
| 44 | + : MuBaseFlatTableProducer{config}, m_token{config, consumesCollector(), "src"} { |
| 45 | + produces<nanoaod::FlatTable>(); |
| 46 | +} |
| 47 | + |
| 48 | +void MuGEML1FETableProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { |
| 49 | + edm::ParameterSetDescription desc; |
| 50 | + |
| 51 | + desc.add<std::string>("name", "l1aHistory"); |
| 52 | + desc.add<edm::InputTag>("src", edm::InputTag{"tcdsDigis:tcdsRecord"}); |
| 53 | + |
| 54 | + descriptions.addWithDefaultLabel(desc); |
| 55 | +} |
| 56 | + |
| 57 | +void MuGEML1FETableProducer::getFromES(const edm::Run& run, const edm::EventSetup& environment) {} |
| 58 | + |
| 59 | +void MuGEML1FETableProducer::fillTable(edm::Event& ev) { |
| 60 | + std::vector<int> bxDiffs; |
| 61 | + |
| 62 | + auto record = m_token.conditionalGet(ev); |
| 63 | + |
| 64 | + // in Heavy Ion Physics the getL1aHistoryEntry is not saved ... |
| 65 | + // comment out and use this as proxy to inquire BX,Orbit and Lumi |
| 66 | + for (const auto l1aEntry : record->getFullL1aHistory()) { |
| 67 | + int bxDiff = BX_IN_ORBIT * (record->getOrbitNr() - l1aEntry.getOrbitNr()) + record->getBXID() - l1aEntry.getBXID(); |
| 68 | + bxDiffs.push_back(bxDiff); |
| 69 | + } |
| 70 | + |
| 71 | + auto table = std::make_unique<nanoaod::FlatTable>(bxDiffs.size(), m_name, false, false); |
| 72 | + addColumn(table, "bxDiffs", bxDiffs, "BX differences between event and L1As"); |
| 73 | + |
| 74 | + ev.put(std::move(table)); |
| 75 | +} |
| 76 | + |
| 77 | +DEFINE_FWK_MODULE(MuGEML1FETableProducer); |
0 commit comments