95 m_muToken{
config, consumesCollector(),
"src"},
96 m_dtSegmentToken{
config, consumesCollector(),
"dtSegmentSrc"},
97 m_trigResultsToken{
config, consumesCollector(),
"trigResultsSrc"},
98 m_trigEventToken{
config, consumesCollector(),
"trigEventSrc"},
99 m_fillMatches{
config.getParameter<
bool>(
"fillMatches")},
102 m_dtGeometry{consumesCollector()} {
103 produces<nanoaod::FlatTable>();
105 produces<nanoaod::FlatTable>(
"matches");
106 produces<nanoaod::FlatTable>(
"staMatches");
119 desc.add<
bool>(
"fillMatches",
true);
133 const bool enableWildcard{
true};
136 TRegexp tNamePattern = TRegexp(
tName, enableWildcard);
140 if (
pathName.Contains(tNamePattern))
145 tNamePattern = TRegexp(
tName, enableWildcard);
149 if (
pathName.Contains(tNamePattern))
157 std::vector<bool> firesIsoTrig;
158 std::vector<bool> firesTrig;
160 std::vector<int> nMatches;
161 std::vector<int> staMu_nMatchSeg;
163 std::vector<uint32_t> matches_begin;
164 std::vector<uint32_t> matches_end;
166 std::vector<uint32_t> staMatches_begin;
167 std::vector<uint32_t> staMatches_end;
169 std::vector<int8_t> matches_wheel;
170 std::vector<int8_t> matches_sector;
171 std::vector<int8_t> matches_station;
173 std::vector<float> matches_x;
174 std::vector<float> matches_y;
176 std::vector<float> matches_phi;
177 std::vector<float> matches_eta;
178 std::vector<float> matches_edgeX;
179 std::vector<float> matches_edgeY;
181 std::vector<float> matches_dXdZ;
182 std::vector<float> matches_dYdZ;
184 std::vector<uint32_t> staMatches_MuSegIdx;
192 if (
muons.isValid() && segments.isValid()) {
200 firesIsoTrig.push_back(hasIsoTrig);
201 firesTrig.push_back(hasTrig);
204 firesIsoTrig.push_back(
false);
205 firesTrig.push_back(
false);
209 size_t iSegMatches = 0;
212 matches_begin.push_back(matches_wheel.size());
214 if (
muon.isMatchesValid()) {
215 for (
const auto&
match :
muon.matches()) {
220 matches_wheel.push_back(dtId.wheel());
221 matches_sector.push_back(dtId.sector());
222 matches_station.push_back(dtId.station());
224 matches_x.push_back(
match.x);
225 matches_y.push_back(
match.y);
230 matches_edgeX.push_back(
match.edgeX);
231 matches_edgeY.push_back(
match.edgeY);
233 matches_dXdZ.push_back(
match.dXdZ);
234 matches_dYdZ.push_back(
match.dYdZ);
241 matches_end.push_back(matches_wheel.size());
245 staMatches_begin.push_back(staMatches_MuSegIdx.size());
247 if (!
muon.outerTrack().isNull()) {
250 auto recHitIt = outerTrackRef->recHitsBegin();
251 auto recHitEnd = outerTrackRef->recHitsEnd();
253 for (; recHitIt != recHitEnd; ++recHitIt) {
257 const auto dtSegmentSta =
dynamic_cast<const DTRecSegment4D*
>((*recHitIt));
260 for (
const auto& segment : (*segments)) {
261 if (dtSegmentSta && dtSegmentSta->chamberId().station() == segment.chamberId().station() &&
262 dtSegmentSta->chamberId().wheel() == segment.chamberId().wheel() &&
263 dtSegmentSta->chamberId().sector() == segment.chamberId().sector() &&
264 std::abs(dtSegmentSta->localPosition().x() - segment.localPosition().x()) < 0.001 &&
265 std::abs(dtSegmentSta->localPosition().y() - segment.localPosition().y()) < 0.001 &&
266 std::abs(dtSegmentSta->localDirection().x() - segment.localDirection().x()) < 0.001 &&
267 std::abs(dtSegmentSta->localDirection().y() - segment.localDirection().y()) < 0.001) {
268 staMatches_MuSegIdx.push_back(iSeg);
279 staMatches_end.push_back(staMatches_MuSegIdx.size());
282 nMatches.push_back(iMatches);
283 staMu_nMatchSeg.push_back(iSegMatches);
294 "True if the muon is matched to an isolated trigger" 295 "<br />specified in the ntuple config file");
300 "True if the muon is matched to a (non isolated)trigger" 301 "<br />specified in the ntuple config file");
303 addColumn(
table,
"nMatches", nMatches,
"Number of muon chamber matches (DT only)");
304 addColumn(
table,
"staMu_nMatchSeg", staMu_nMatchSeg,
"Number of segments used in the standalone track (DT only)");
309 "begin() of range of quantities for a given muon in the *_matches_* vectors");
311 table,
"matches_end", matches_end,
"end() of range of quantities for a given muon in the *_matches_* vectors");
316 "begin() of range of quantities for a given muon in the matches_staMuSegIdx vector");
320 "end() of range of quantities for a given muon in the matches_staMuSegIdx vector");
325 auto sum = [](std::vector<int>
v) {
return std::accumulate(
v.begin(),
v.end(), 0); };
327 auto tabMatches = std::make_unique<nanoaod::FlatTable>(sum(nMatches),
m_name +
"_matches",
false,
false);
329 tabMatches->setDoc(
"RECO muon matches_* vectors");
331 addColumn(tabMatches,
"x", matches_x,
"x position of the extrapolated track on the matched DT chamber");
332 addColumn(tabMatches,
"y", matches_y,
"x position of the extrapolated track on the matched DT chamber");
334 addColumn(tabMatches,
"wheel", matches_wheel,
"matched DT chamber wheel");
335 addColumn(tabMatches,
"sector", matches_sector,
"matched DT chamber sector");
336 addColumn(tabMatches,
"station", matches_station,
"matched DT chamber station");
339 tabMatches,
"phi", matches_phi,
"phi of the (x,y) position on the matched DT chamber (global reference frame)");
343 " eta of the (x,y) position on the matched cDT hamber (global reference frame)");
345 addColumn(tabMatches,
"dXdZ", matches_dXdZ,
"dXdZ of the extrapolated track on the matched DT chamber");
346 addColumn(tabMatches,
"dYdZ", matches_dYdZ,
"dYdZ of the extrapolated track on the matched DT chamber");
351 std::make_unique<nanoaod::FlatTable>(sum(staMu_nMatchSeg),
m_name +
"_staMatches",
false,
false);
353 tabStaMatches->setDoc(
"RECO muon staMatches_* vector");
358 "Index of DT segments used in the standalone track it corresponds" 359 "<br />to the index of a given segment in the ntuple seg_* collection");
370 for (
int trigIdx : trigIndices) {
373 const unsigned trigModuleIndex =
374 std::find(trigModuleLabels.begin(), trigModuleLabels.end(),
"hltBoolEnd") - trigModuleLabels.begin() - 1;
375 const unsigned hltFilterIndex =
trigEvent->filterIndex(
edm::InputTag(trigModuleLabels[trigModuleIndex],
"",
"HLT"));
376 if (hltFilterIndex < trigEvent->sizeFilters()) {
379 const unsigned nTriggers = vids.size();
381 for (
unsigned iTrig = 0; iTrig < nTriggers; ++iTrig) {
const std::string & triggerName(unsigned int triggerIndex) const
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
dictionary config
Read in AllInOne config in JSON format.
auto conditionalGet(const edm::Event &ev) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void addColumn(std::unique_ptr< nanoaod::FlatTable > &table, const std::string name, const std::vector< T > &vec, const std::string descr)
Single trigger physics object (e.g., an isolated muon)
nano_mu::EDTokenHandle< DTRecSegment4DCollection > m_dtSegmentToken
void getFromES(const edm::Run &, const edm::EventSetup &) final
Get info from the ES by run.
MuDTMuonExtTableProducer(const edm::ParameterSet &)
Constructor.
unsigned int size() const
number of trigger paths in trigger table
nano_mu::EDTokenHandle< edm::View< reco::Muon > > m_muToken
Tokens.
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
static std::string const triggerResults
HLTConfigProvider m_hltConfig
HLT config provider.
static void fillDescriptions(edm::ConfigurationDescriptions &)
Fill descriptors.
nano_mu::EDTokenHandle< edm::TriggerResults > m_trigResultsToken
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
std::vector< int > m_isoTrigIndices
std::vector< size_type > Keys
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
std::string m_isoTrigName
std::string m_name
The label name of the FlatTableProducer.
void getFromES(const edm::EventSetup &environment)
Get Handle from ES.
void fillTable(edm::Event &) final
Fill tree branches for a given events.
nano_mu::ESTokenHandle< DTGeometry, MuonGeometryRecord, edm::Transition::BeginRun > m_dtGeometry
DT Geometry.
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
bool m_fillMatches
Fill matches table.
bool hasTrigger(std::vector< int > &, const trigger::TriggerObjectCollection &, edm::Handle< trigger::TriggerEvent > &, const reco::Muon &)
nano_mu::EDTokenHandle< trigger::TriggerEvent > m_trigEventToken
std::vector< int > m_trigIndices
Indices of the triggers used by muon filler for trigger matching.
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
std::string m_trigName
Name of the triggers used by muon filler for trigger matching.