CMS 3D CMS Logo

MuDTTPGPhiFlatTableProducer.cc
Go to the documentation of this file.
1 
11 
12 #include <iostream>
13 #include <vector>
14 
16 
19 
21 
23 public:
24  enum class TriggerTag { TM_IN = 0, TM_OUT, BMTF_IN };
25 
28 
31 
32 protected:
34  void fillTable(edm::Event&) final;
35 
37  void getFromES(const edm::Run&, const edm::EventSetup&) final;
38 
39 private:
43 
46 
49 
52 };
53 
56  m_tag{getTag(config)},
57  m_token{config, consumesCollector(), "src"},
58  m_trigGeomUtils{consumesCollector()} {
59  produces<nanoaod::FlatTable>();
60 }
61 
64 
65  desc.add<std::string>("name", "ltBmtfIn");
66  desc.ifValue(edm::ParameterDescription<std::string>("tag", "BMTF_IN", true),
67  edm::allowedValues<std::string>("BMTF_IN", "TM_IN", "TM_OUT"));
68  desc.add<edm::InputTag>("src", edm::InputTag{"bmtfDigis"});
69 
70  descriptions.addWithDefaultLabel(desc);
71 }
72 
75 }
76 
78  unsigned int nTrigs{0};
79 
80  std::vector<int16_t> wheel;
81  std::vector<int16_t> sector;
82  std::vector<int16_t> station;
83 
84  std::vector<int16_t> quality;
85  std::vector<int16_t> rpcBit;
86 
87  std::vector<int> phi;
88  std::vector<int> phiB;
89 
90  std::vector<float> posLoc_x;
91  std::vector<float> dirLoc_phi;
92 
93  std::vector<int16_t> bx;
94  std::vector<int16_t> is2nd;
95 
96  auto trigColl = m_token.conditionalGet(ev);
97 
98  if (trigColl.isValid()) {
99  const auto trigs = trigColl->getContainer();
100  for (const auto& trig : (*trigs)) {
101  if (trig.code() != 7) {
102  wheel.push_back(trig.whNum());
103  sector.push_back(trig.scNum() + (m_tag != TriggerTag::BMTF_IN ? 1 : 0));
104  station.push_back(trig.stNum());
105 
106  quality.push_back(trig.code());
107 
108  if (m_tag == TriggerTag::TM_OUT)
109  rpcBit.push_back(trig.RpcBit());
110 
111  phi.push_back(trig.phi());
112  phiB.push_back(trig.phiB());
113 
114  auto [x, dir] = m_trigGeomUtils.trigToReco(&trig);
115 
116  posLoc_x.push_back(x);
117  dirLoc_phi.push_back(dir);
118 
119  bx.push_back(trig.bxNum() - (m_tag == TriggerTag::TM_IN && trig.Ts2Tag() ? 1 : 0));
120  is2nd.push_back(trig.Ts2Tag());
121 
122  ++nTrigs;
123  }
124  }
125  }
126 
127  auto table = std::make_unique<nanoaod::FlatTable>(nTrigs, m_name, false, false);
128 
129  table->setDoc("Barrel trigger primitive information (phi view)");
130 
131  addColumn(table, "wheel", wheel, "wheel - [-2:2] range");
133  "sector",
134  sector,
135  "sector"
136  "<br /> - [1:12] range for TwinMux"
137  "<br /> - [0:11] range for BMTF input"
138  "<br /> - double MB4 stations are part of S4 and S10 in TwinMux"
139  "<br /> - double MB4 stations are part of S3 and S9 in BMTF input");
140  addColumn(table, "station", station, "station - [1:4] range");
142  "quality",
143  quality,
144  "quality - [0:6] range"
145  "<br /> - [0:1] : uncorrelated L triggers"
146  "<br /> - [2:3] : uncorrelated H triggers"
147  "<br /> - 4 : correlated LL triggers"
148  "<br /> - 5 : correlated HL triggers"
149  "<br /> - 6 : correlated HH triggers");
150  if (m_tag == TriggerTag::TM_OUT) {
152  "rpcBit",
153  rpcBit,
154  "use of RPC - [0:2] range"
155  "<br /> - 0 : RPC not used"
156  "<br /> - 1 : RPC+DT combined trigger"
157  "<br /> - 2 : RPC-only trigger");
158  }
159 
161  "phi",
162  phi,
163  "phi - scale and range:"
164  "<br /> - 4096 correstpond to 1 rad"
165  "<br /> - 0 is @ (DT sector - 1) * 30 deg in global CMS phi");
167  "phiB",
168  phiB,
169  "phiB - scale and range:"
170  "<br /> - 512 correstpond to 1 rad"
171  "<br /> - 0 is a muon with infinite pT (straight line)");
172  addColumn(table, "posLoc_x", posLoc_x, "position x in chamber local coordinates - cm");
173  addColumn(table, "dirLoc_phi", dirLoc_phi, "direction phi angle in chamber local coordinates - deg");
175  "bx",
176  bx,
177  "bx:"
178  "<br /> - BX = 0 is the one where the event is collected"
179  "<br /> - TwinMux range [X:Y]"
180  "<br /> - BMT input range [X:Y]");
181  addColumn(table, "is2nd", is2nd, "1st/2nd track flag - [0:1]");
182 
183  ev.put(std::move(table));
184 }
185 
187  auto tag{TriggerTag::TM_IN};
188 
189  auto tagName = config.getParameter<std::string>("tag");
190 
191  if (tagName != "TM_IN" && tagName != "TM_OUT" && tagName != "BMTF_IN")
192  edm::LogError("") << "[MuDTTPGPhiFlatTableProducer]::getTag: " << tagName
193  << " is not a valid tag, defaulting to TM_IN";
194 
195  if (tagName == "TM_OUT") {
197  } else if (tagName == "BMTF_IN") {
199  }
200 
201  return tag;
202 }
203 
206 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
nano_mu::DTTrigGeomUtils m_trigGeomUtils
The class to perform DT local trigger coordinate conversions.
static void fillDescriptions(edm::ConfigurationDescriptions &)
Fill descriptors.
Definition: config.py:1
MuDTTPGPhiFlatTableProducer(const edm::ParameterSet &)
Constructor.
auto conditionalGet(const edm::Event &ev) const
Definition: MuNtupleUtils.h:49
Log< level::Error, false > LogError
void addColumn(std::unique_ptr< nanoaod::FlatTable > &table, const std::string name, const std::vector< T > &vec, const std::string descr)
string quality
void getFromES(const edm::Run &run, const edm::EventSetup &environment)
Update EventSetup information.
void getFromES(const edm::Run &, const edm::EventSetup &) final
Get info from the ES by run.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void fillTable(edm::Event &) final
Fill tree branches for a given event.
std::string m_name
The label name of the FlatTableProducer.
nano_mu::EDTokenHandle< L1MuDTChambPhContainer > m_token
The trigger-primitive token.
dictionary config
Read in AllInOne config in JSON format.
Definition: DiMuonV_cfg.py:30
TriggerTag getTag(const edm::ParameterSet &)
Helper function translating config parameter into TriggerTag.
def move(src, dest)
Definition: eostools.py:511
chambCoord trigToReco(const L1MuDTChambPhDigi *trig)
Return local position and direction in chamber RF - legacy.
Definition: Run.h:45