CMS 3D CMS Logo

MuDTTPGThetaFlatTableProducer.cc
Go to the documentation of this file.
1 
12 
13 #include <iostream>
14 #include <vector>
15 
18 
20 
22 public:
23  enum class TriggerTag { TM_IN = 0, BMTF_IN };
24 
27 
30 
31 protected:
33  void fillTable(edm::Event&) final;
34 
35 private:
39 
42 
45 };
46 
48  : MuBaseFlatTableProducer{config}, m_tag{getTag(config)}, m_token{config, consumesCollector(), "src"} {
49  produces<nanoaod::FlatTable>();
50 }
51 
54 
55  desc.add<std::string>("name", "ltBmtfInTh");
56  desc.ifValue(edm::ParameterDescription<std::string>("tag", "BMTF_IN", true),
57  edm::allowedValues<std::string>("BMTF_IN", "TM_IN"));
58  desc.add<edm::InputTag>("src", edm::InputTag{"bmtfDigis"});
59 
60  descriptions.addWithDefaultLabel(desc);
61 }
62 
64  unsigned int nTrigs{0};
65 
66  std::vector<int8_t> wheel;
67  std::vector<int8_t> sector;
68  std::vector<int8_t> station;
69 
70  std::vector<int8_t> bx;
71  std::vector<uint32_t> hitMap;
72 
73  auto trigColl = m_token.conditionalGet(ev);
74 
75  if (trigColl.isValid()) {
76  const auto trigs = trigColl->getContainer();
77  for (const auto& trig : (*trigs)) {
78  bool hasData = false;
79  for (int pos = 0; pos < 7; ++pos) {
80  if (trig.code(pos)) {
81  hasData = true;
82  break;
83  }
84  }
85 
86  if (!hasData)
87  continue;
88 
89  wheel.push_back(trig.whNum());
90  sector.push_back(trig.scNum() + (m_tag != TriggerTag::BMTF_IN ? 1 : 0));
91  station.push_back(trig.stNum());
92 
93  bx.push_back(trig.bxNum());
94 
95  uint32_t hitMapCh = 0;
96  for (int pos = 0; pos < 7; ++pos)
97  if (trig.code(pos))
98  hitMapCh = hitMapCh | (0x1 << pos);
99 
100  hitMap.push_back(hitMapCh);
101 
102  ++nTrigs;
103  }
104  }
105 
106  auto table = std::make_unique<nanoaod::FlatTable>(nTrigs, m_name, false, false);
107 
108  table->setDoc("Barrel trigger primitive information (theta view)");
109 
110  addColumn(table, "wheel", wheel, "wheel - [-2:2] range");
112  "sector",
113  sector,
114  "sector"
115  "<br /> - [1:12] range for TwinMux"
116  "<br /> - [0:11] range for BMTF input"
117  "<br /> - double MB4 stations are part of S4 and S10 in TwinMux"
118  "<br /> - double MB4 stations are part of S3 and S9 in BMTF input");
119  addColumn(table, "station", station, "station - [1:3] range");
121  "bx",
122  bx,
123  "bx:"
124  "<br /> - BX = 0 is the one where the event is collected"
125  "<br /> - TwinMux range [X:Y]"
126  "<br /> - BMTF input range [X:Y]");
128  "hitMap",
129  hitMap,
130  "Map groups of BTIs that fired (unsigned int):"
131  "<br /> there are 7 groups of BTI per chamber, the first one"
132  "<br /> being the less significant bit of the map [CHECK]");
133 
134  ev.put(std::move(table));
135 }
136 
138  auto tag{TriggerTag::TM_IN};
139 
140  auto tagName = config.getParameter<std::string>("tag");
141 
142  if (tagName != "TM_IN" && tagName != "BMTF_IN")
143  edm::LogError("") << "[MuDTTPGThetaFlatTableProducer]::getTag: " << tagName
144  << " is not a valid tag, defaulting to TM_IN";
145 
146  if (tagName == "BMTF_IN")
148 
149  return tag;
150 }
151 
154 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
nano_mu::EDTokenHandle< L1MuDTChambThContainer > m_token
The trigger-primitive token.
dictionary config
Read in AllInOne config in JSON format.
Definition: DMR_cfg.py:21
Definition: config.py:1
static void fillDescriptions(edm::ConfigurationDescriptions &)
Fill descriptors.
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)
TriggerTag getTag(const edm::ParameterSet &)
Helper function translating config parameter into TriggerTag.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void fillTable(edm::Event &) final
Fill tree branches for a given events.
std::string m_name
The label name of the FlatTableProducer.
MuDTTPGThetaFlatTableProducer(const edm::ParameterSet &)
Constructor.
def move(src, dest)
Definition: eostools.py:511