File indexing completed on 2024-04-06 12:06:32
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "FWCore/ParameterSet/interface/allowedValues.h"
0011
0012 #include <iostream>
0013 #include <vector>
0014
0015 #include "DPGAnalysis/MuonTools/interface/MuBaseFlatTableProducer.h"
0016
0017 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0019
0020 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h"
0021
0022 class MuDTTPGPhiFlatTableProducer : public MuBaseFlatTableProducer {
0023 public:
0024 enum class TriggerTag { TM_IN = 0, TM_OUT, BMTF_IN };
0025
0026
0027 MuDTTPGPhiFlatTableProducer(const edm::ParameterSet&);
0028
0029
0030 static void fillDescriptions(edm::ConfigurationDescriptions&);
0031
0032 protected:
0033
0034 void fillTable(edm::Event&) final;
0035
0036
0037 void getFromES(const edm::Run&, const edm::EventSetup&) final;
0038
0039 private:
0040
0041
0042 TriggerTag m_tag;
0043
0044
0045 nano_mu::EDTokenHandle<L1MuDTChambPhContainer> m_token;
0046
0047
0048 nano_mu::DTTrigGeomUtils m_trigGeomUtils;
0049
0050
0051 TriggerTag getTag(const edm::ParameterSet&);
0052 };
0053
0054 MuDTTPGPhiFlatTableProducer::MuDTTPGPhiFlatTableProducer(const edm::ParameterSet& config)
0055 : MuBaseFlatTableProducer{config},
0056 m_tag{getTag(config)},
0057 m_token{config, consumesCollector(), "src"},
0058 m_trigGeomUtils{consumesCollector()} {
0059 produces<nanoaod::FlatTable>();
0060 }
0061
0062 void MuDTTPGPhiFlatTableProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0063 edm::ParameterSetDescription desc;
0064
0065 desc.add<std::string>("name", "ltBmtfIn");
0066 desc.ifValue(edm::ParameterDescription<std::string>("tag", "BMTF_IN", true),
0067 edm::allowedValues<std::string>("BMTF_IN", "TM_IN", "TM_OUT"));
0068 desc.add<edm::InputTag>("src", edm::InputTag{"bmtfDigis"});
0069
0070 descriptions.addWithDefaultLabel(desc);
0071 }
0072
0073 void MuDTTPGPhiFlatTableProducer::getFromES(const edm::Run& run, const edm::EventSetup& environment) {
0074 m_trigGeomUtils.getFromES(run, environment);
0075 }
0076
0077 void MuDTTPGPhiFlatTableProducer::fillTable(edm::Event& ev) {
0078 unsigned int nTrigs{0};
0079
0080 std::vector<int16_t> wheel;
0081 std::vector<int16_t> sector;
0082 std::vector<int16_t> station;
0083
0084 std::vector<int16_t> quality;
0085 std::vector<int16_t> rpcBit;
0086
0087 std::vector<int> phi;
0088 std::vector<int> phiB;
0089
0090 std::vector<float> posLoc_x;
0091 std::vector<float> dirLoc_phi;
0092
0093 std::vector<int16_t> bx;
0094 std::vector<int16_t> is2nd;
0095
0096 auto trigColl = m_token.conditionalGet(ev);
0097
0098 if (trigColl.isValid()) {
0099 const auto trigs = trigColl->getContainer();
0100 for (const auto& trig : (*trigs)) {
0101 if (trig.code() != 7) {
0102 wheel.push_back(trig.whNum());
0103 sector.push_back(trig.scNum() + (m_tag != TriggerTag::BMTF_IN ? 1 : 0));
0104 station.push_back(trig.stNum());
0105
0106 quality.push_back(trig.code());
0107
0108 if (m_tag == TriggerTag::TM_OUT)
0109 rpcBit.push_back(trig.RpcBit());
0110
0111 phi.push_back(trig.phi());
0112 phiB.push_back(trig.phiB());
0113
0114 auto [x, dir] = m_trigGeomUtils.trigToReco(&trig);
0115
0116 posLoc_x.push_back(x);
0117 dirLoc_phi.push_back(dir);
0118
0119 bx.push_back(trig.bxNum() - (m_tag == TriggerTag::TM_IN && trig.Ts2Tag() ? 1 : 0));
0120 is2nd.push_back(trig.Ts2Tag());
0121
0122 ++nTrigs;
0123 }
0124 }
0125 }
0126
0127 auto table = std::make_unique<nanoaod::FlatTable>(nTrigs, m_name, false, false);
0128
0129 table->setDoc("Barrel trigger primitive information (phi view)");
0130
0131 addColumn(table, "wheel", wheel, "wheel - [-2:2] range");
0132 addColumn(table,
0133 "sector",
0134 sector,
0135 "sector"
0136 "<br /> - [1:12] range for TwinMux"
0137 "<br /> - [0:11] range for BMTF input"
0138 "<br /> - double MB4 stations are part of S4 and S10 in TwinMux"
0139 "<br /> - double MB4 stations are part of S3 and S9 in BMTF input");
0140 addColumn(table, "station", station, "station - [1:4] range");
0141 addColumn(table,
0142 "quality",
0143 quality,
0144 "quality - [0:6] range"
0145 "<br /> - [0:1] : uncorrelated L triggers"
0146 "<br /> - [2:3] : uncorrelated H triggers"
0147 "<br /> - 4 : correlated LL triggers"
0148 "<br /> - 5 : correlated HL triggers"
0149 "<br /> - 6 : correlated HH triggers");
0150 if (m_tag == TriggerTag::TM_OUT) {
0151 addColumn(table,
0152 "rpcBit",
0153 rpcBit,
0154 "use of RPC - [0:2] range"
0155 "<br /> - 0 : RPC not used"
0156 "<br /> - 1 : RPC+DT combined trigger"
0157 "<br /> - 2 : RPC-only trigger");
0158 }
0159
0160 addColumn(table,
0161 "phi",
0162 phi,
0163 "phi - scale and range:"
0164 "<br /> - 4096 correstpond to 1 rad"
0165 "<br /> - 0 is @ (DT sector - 1) * 30 deg in global CMS phi");
0166 addColumn(table,
0167 "phiB",
0168 phiB,
0169 "phiB - scale and range:"
0170 "<br /> - 512 correstpond to 1 rad"
0171 "<br /> - 0 is a muon with infinite pT (straight line)");
0172 addColumn(table, "posLoc_x", posLoc_x, "position x in chamber local coordinates - cm");
0173 addColumn(table, "dirLoc_phi", dirLoc_phi, "direction phi angle in chamber local coordinates - deg");
0174 addColumn(table,
0175 "bx",
0176 bx,
0177 "bx:"
0178 "<br /> - BX = 0 is the one where the event is collected"
0179 "<br /> - TwinMux range [X:Y]"
0180 "<br /> - BMT input range [X:Y]");
0181 addColumn(table, "is2nd", is2nd, "1st/2nd track flag - [0:1]");
0182
0183 ev.put(std::move(table));
0184 }
0185
0186 MuDTTPGPhiFlatTableProducer::TriggerTag MuDTTPGPhiFlatTableProducer::getTag(const edm::ParameterSet& config) {
0187 auto tag{TriggerTag::TM_IN};
0188
0189 auto tagName = config.getParameter<std::string>("tag");
0190
0191 if (tagName != "TM_IN" && tagName != "TM_OUT" && tagName != "BMTF_IN")
0192 edm::LogError("") << "[MuDTTPGPhiFlatTableProducer]::getTag: " << tagName
0193 << " is not a valid tag, defaulting to TM_IN";
0194
0195 if (tagName == "TM_OUT") {
0196 tag = TriggerTag::TM_OUT;
0197 } else if (tagName == "BMTF_IN") {
0198 tag = TriggerTag::BMTF_IN;
0199 }
0200
0201 return tag;
0202 }
0203
0204 #include "FWCore/PluginManager/interface/ModuleDef.h"
0205 #include "FWCore/Framework/interface/MakerMacros.h"
0206
0207 DEFINE_FWK_MODULE(MuDTTPGPhiFlatTableProducer);