File indexing completed on 2023-06-05 22:16:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "DPGAnalysis/MuonTools/interface/MuBaseFlatTableProducer.h"
0011 #include "FWCore/ParameterSet/interface/allowedValues.h"
0012
0013 #include <iostream>
0014 #include <vector>
0015
0016 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0018
0019 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h"
0020
0021 class MuDTTPGThetaFlatTableProducer : public MuBaseFlatTableProducer {
0022 public:
0023 enum class TriggerTag { TM_IN = 0, BMTF_IN };
0024
0025
0026 MuDTTPGThetaFlatTableProducer(const edm::ParameterSet&);
0027
0028
0029 static void fillDescriptions(edm::ConfigurationDescriptions&);
0030
0031 protected:
0032
0033 void fillTable(edm::Event&) final;
0034
0035 private:
0036
0037
0038 TriggerTag m_tag;
0039
0040
0041 nano_mu::EDTokenHandle<L1MuDTChambThContainer> m_token;
0042
0043
0044 TriggerTag getTag(const edm::ParameterSet&);
0045 };
0046
0047 MuDTTPGThetaFlatTableProducer::MuDTTPGThetaFlatTableProducer(const edm::ParameterSet& config)
0048 : MuBaseFlatTableProducer{config}, m_tag{getTag(config)}, m_token{config, consumesCollector(), "src"} {
0049 produces<nanoaod::FlatTable>();
0050 }
0051
0052 void MuDTTPGThetaFlatTableProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0053 edm::ParameterSetDescription desc;
0054
0055 desc.add<std::string>("name", "ltBmtfInTh");
0056 desc.ifValue(edm::ParameterDescription<std::string>("tag", "BMTF_IN", true),
0057 edm::allowedValues<std::string>("BMTF_IN", "TM_IN"));
0058 desc.add<edm::InputTag>("src", edm::InputTag{"bmtfDigis"});
0059
0060 descriptions.addWithDefaultLabel(desc);
0061 }
0062
0063 void MuDTTPGThetaFlatTableProducer::fillTable(edm::Event& ev) {
0064 unsigned int nTrigs{0};
0065
0066 std::vector<int8_t> wheel;
0067 std::vector<int8_t> sector;
0068 std::vector<int8_t> station;
0069
0070 std::vector<int8_t> bx;
0071 std::vector<uint32_t> hitMap;
0072
0073 auto trigColl = m_token.conditionalGet(ev);
0074
0075 if (trigColl.isValid()) {
0076 const auto trigs = trigColl->getContainer();
0077 for (const auto& trig : (*trigs)) {
0078 bool hasData = false;
0079 for (int pos = 0; pos < 7; ++pos) {
0080 if (trig.code(pos)) {
0081 hasData = true;
0082 break;
0083 }
0084 }
0085
0086 if (!hasData)
0087 continue;
0088
0089 wheel.push_back(trig.whNum());
0090 sector.push_back(trig.scNum() + (m_tag != TriggerTag::BMTF_IN ? 1 : 0));
0091 station.push_back(trig.stNum());
0092
0093 bx.push_back(trig.bxNum());
0094
0095 uint32_t hitMapCh = 0;
0096 for (int pos = 0; pos < 7; ++pos)
0097 if (trig.code(pos))
0098 hitMapCh = hitMapCh | (0x1 << pos);
0099
0100 hitMap.push_back(hitMapCh);
0101
0102 ++nTrigs;
0103 }
0104 }
0105
0106 auto table = std::make_unique<nanoaod::FlatTable>(nTrigs, m_name, false, false);
0107
0108 table->setDoc("Barrel trigger primitive information (theta view)");
0109
0110 addColumn(table, "wheel", wheel, "wheel - [-2:2] range");
0111 addColumn(table,
0112 "sector",
0113 sector,
0114 "sector"
0115 "<br /> - [1:12] range for TwinMux"
0116 "<br /> - [0:11] range for BMTF input"
0117 "<br /> - double MB4 stations are part of S4 and S10 in TwinMux"
0118 "<br /> - double MB4 stations are part of S3 and S9 in BMTF input");
0119 addColumn(table, "station", station, "station - [1:3] range");
0120 addColumn(table,
0121 "bx",
0122 bx,
0123 "bx:"
0124 "<br /> - BX = 0 is the one where the event is collected"
0125 "<br /> - TwinMux range [X:Y]"
0126 "<br /> - BMTF input range [X:Y]");
0127 addColumn(table,
0128 "hitMap",
0129 hitMap,
0130 "Map groups of BTIs that fired (unsigned int):"
0131 "<br /> there are 7 groups of BTI per chamber, the first one"
0132 "<br /> being the less significant bit of the map [CHECK]");
0133
0134 ev.put(std::move(table));
0135 }
0136
0137 MuDTTPGThetaFlatTableProducer::TriggerTag MuDTTPGThetaFlatTableProducer::getTag(const edm::ParameterSet& config) {
0138 auto tag{TriggerTag::TM_IN};
0139
0140 auto tagName = config.getParameter<std::string>("tag");
0141
0142 if (tagName != "TM_IN" && tagName != "BMTF_IN")
0143 edm::LogError("") << "[MuDTTPGThetaFlatTableProducer]::getTag: " << tagName
0144 << " is not a valid tag, defaulting to TM_IN";
0145
0146 if (tagName == "BMTF_IN")
0147 tag = TriggerTag::BMTF_IN;
0148
0149 return tag;
0150 }
0151
0152 #include "FWCore/PluginManager/interface/ModuleDef.h"
0153 #include "FWCore/Framework/interface/MakerMacros.h"
0154
0155 DEFINE_FWK_MODULE(MuDTTPGThetaFlatTableProducer);