Skip to content

Commit

Permalink
Implement cross-POG suggetsions
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlo Battilana committed Apr 5, 2023
1 parent 4476e41 commit 2c9d5bd
Show file tree
Hide file tree
Showing 19 changed files with 950 additions and 73 deletions.
3 changes: 3 additions & 0 deletions DPGAnalysis/MuonTools/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
<use name="CommonTools/Utils"/>
<use name="CommonTools/UtilAlgos"/>
<use name="DataFormats/NanoAOD"/>
<use name="PhysicsTools/NanoAOD"/>
<use name="CalibMuon/DTDigiSync"/>
<use name="Geometry/Records"/>
<use name="Utilities/General"/>
<use name="TrackingTools/GeomPropagators"/>
<use name="DataFormats/Common"/>
<use name="DataFormats/DTDigi"/>
Expand All @@ -25,6 +27,7 @@
<use name="RecoMuon/TrackingTools"/>
<use name="DataFormats/RPCDigi"/>
<use name="DataFormats/RPCRecHit"/>
<use name="boost"/>

<export>
<lib name="1"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
/** \class MuNtupleDTTPGPhiFiller MuNtupleDTTPGPhiFiller.cc DPGAnalysis/MuonTools/src/MuNtupleDTTPGPhiFiller.cc
/** \class MuDTTPGPhiFlatTableProducer MuDTTPGPhiFlatTableProducer.cc DPGAnalysis/MuonTools/src/MuDTTPGPhiFlatTableProducer.cc
*
* Helper class : the Phase-1 local trigger filler for TwinMux in/out and BMTF in (the DataFormat is the same)
* Helper class : the Phase-1 local trigger FlatTableProducer for TwinMux in/out and BMTF in (the DataFormat is the same)
*
* \author C. Battilana (INFN BO)
*
*
*/

#include "DPGAnalysis/MuonTools/plugins/MuNtupleDTTPGPhiFiller.h"
#include "DPGAnalysis/MuonTools/plugins/MuDTTPGPhiFlatTableProducer.h"
#include "FWCore/ParameterSet/interface/allowedValues.h"

#include <iostream>
#include <vector>

MuNtupleDTTPGPhiFiller::MuNtupleDTTPGPhiFiller(const edm::ParameterSet& config)
: MuNtupleBaseFiller{config},
MuDTTPGPhiFlatTableProducer::MuDTTPGPhiFlatTableProducer(const edm::ParameterSet& config)
: MuBaseFlatTableProducer{config},
m_tag{getTag(config)},
m_token{config, consumesCollector(), "dtTpTag"},
m_token{config, consumesCollector(), "src"},
m_trigGeomUtils{consumesCollector()} {
produces<nanoaod::FlatTable>();
}

void MuNtupleDTTPGPhiFiller::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
void MuDTTPGPhiFlatTableProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;

desc.add<std::string>("label", "ltBmtfIn");
desc.add<std::string>("name", "ltBmtfIn");
desc.ifValue(edm::ParameterDescription<std::string>("tag", "BMTF_IN", true),
edm::allowedValues<std::string>("BMTF_IN", "TM_IN", "TM_OUT"));
desc.add<edm::InputTag>("dtTpTag", edm::InputTag{"bmtfDigis"});
desc.add<edm::InputTag>("src", edm::InputTag{"bmtfDigis"});

descriptions.addWithDefaultLabel(desc);
}

void MuNtupleDTTPGPhiFiller::getFromES(const edm::Run& run, const edm::EventSetup& environment) {
void MuDTTPGPhiFlatTableProducer::getFromES(const edm::Run& run, const edm::EventSetup& environment) {
m_trigGeomUtils.getFromES(run, environment);
}

void MuNtupleDTTPGPhiFiller::fill(edm::Event& ev) {
void MuDTTPGPhiFlatTableProducer::fillTable(edm::Event& ev) {
unsigned int nTrigs{0};

std::vector<int8_t> wheel;
Expand Down Expand Up @@ -86,7 +86,7 @@ void MuNtupleDTTPGPhiFiller::fill(edm::Event& ev) {
}
}

auto table = std::make_unique<nanoaod::FlatTable>(nTrigs, m_label, false, false);
auto table = std::make_unique<nanoaod::FlatTable>(nTrigs, m_name, false, false);

table->setDoc("DT trigger primitive information (phi view)");

Expand Down Expand Up @@ -145,13 +145,14 @@ void MuNtupleDTTPGPhiFiller::fill(edm::Event& ev) {
ev.put(std::move(table));
}

MuNtupleDTTPGPhiFiller::TriggerTag MuNtupleDTTPGPhiFiller::getTag(const edm::ParameterSet& config) {
MuDTTPGPhiFlatTableProducer::TriggerTag MuDTTPGPhiFlatTableProducer::getTag(const edm::ParameterSet& config) {
auto tag{TriggerTag::TM_IN};

auto tagName = config.getParameter<std::string>("tag");

if (tagName != "TM_IN" && tagName != "TM_OUT" && tagName != "BMTF_IN")
edm::LogError("") << "[MuNtupleDTTPGPhiFiller]::getTag: " << tagName << " is not a valid tag, defaulting to TM_IN";
edm::LogError("") << "[MuDTTPGPhiFlatTableProducer]::getTag: " << tagName
<< " is not a valid tag, defaulting to TM_IN";

if (tagName == "TM_OUT") {
tag = TriggerTag::TM_OUT;
Expand All @@ -165,4 +166,4 @@ MuNtupleDTTPGPhiFiller::TriggerTag MuNtupleDTTPGPhiFiller::getTag(const edm::Par
#include "FWCore/PluginManager/interface/ModuleDef.h"
#include "FWCore/Framework/interface/MakerMacros.h"

DEFINE_FWK_MODULE(MuNtupleDTTPGPhiFiller);
DEFINE_FWK_MODULE(MuDTTPGPhiFlatTableProducer);
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
#ifndef MuNtuple_MuNtupleDTTPGPhiFiller_h
#define MuNtuple_MuNtupleDTTPGPhiFiller_h
#ifndef Mu_MuDTTPGPhiFlatTableProducer_h
#define Mu_MuDTTPGPhiFlatTableProducer_h

/** \class MuNtupleDTTPGPhiFiller MuNtupleDTTPGPhiFiller.h DPGAnalysis/MuonTools/plugins/MuNtupleDTTPGPhiFiller.h
/** \class MuDTTPGPhiFlatTableProducer MuDTTPGPhiFlatTableProducer.h DPGAnalysis/MuonTools/plugins/MuDTTPGPhiFlatTableProducer.h
*
* Helper class : the Phase-1 local trigger filler for TwinMux in/out and BMTF in (the DataFormat is the same)
* Helper class : the Phase-1 local trigger FlatTableProducer for TwinMux in/out and BMTF in (the DataFormat is the same)
*
* \author C. Battilana (INFN BO)
*
*
*/

#include "DPGAnalysis/MuonTools/src/MuNtupleBaseFiller.h"
#include "DPGAnalysis/MuonTools/src/MuBaseFlatTableProducer.h"

#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"

#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h"

class MuNtupleDTTPGPhiFiller : public MuNtupleBaseFiller {
class MuDTTPGPhiFlatTableProducer : public MuBaseFlatTableProducer {
public:
enum class TriggerTag { TM_IN = 0, TM_OUT, BMTF_IN };

/// Constructor
MuNtupleDTTPGPhiFiller(const edm::ParameterSet&);
MuDTTPGPhiFlatTableProducer(const edm::ParameterSet&);

/// Fill descriptors
static void fillDescriptions(edm::ConfigurationDescriptions&);

protected:
/// Fill tree branches for a given event
void fill(edm::Event&) final;
void fillTable(edm::Event&) final;

/// Get info from the ES by run
void getFromES(const edm::Run&, const edm::EventSetup&) final;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
/** \class MuNtupleDTTPGThetaFiller MuNtupleDTTPGThetaFiller.cc DPGAnalysis/MuonTools/plugins/MuNtupleDTTPGThetaFiller.cc
/** \class MuDTTPGThetaFlatTableProducer MuDTTPGThetaFlatTableProducer.cc DPGAnalysis/MuonTools/plugins/MuDTTPGThetaFlatTableProducer.cc
*
* Helper class : the Phase-1 local trigger filler for TwinMux in/out and BMTF in (the DataFormat is the same)
* Helper class : the Phase-1 local trigger FlatTableProducer for TwinMux in/out and BMTF in (the DataFormat is the same)
*
* \author C. Battilana (INFN BO)
*
*
*/

#include "DPGAnalysis/MuonTools/plugins/MuNtupleDTTPGThetaFiller.h"
#include "DPGAnalysis/MuonTools/plugins/MuDTTPGThetaFlatTableProducer.h"
#include "FWCore/ParameterSet/interface/allowedValues.h"

#include <iostream>
#include <vector>

MuNtupleDTTPGThetaFiller::MuNtupleDTTPGThetaFiller(const edm::ParameterSet& config)
: MuNtupleBaseFiller{config}, m_tag{getTag(config)}, m_token{config, consumesCollector(), "dtTpTag"} {
MuDTTPGThetaFlatTableProducer::MuDTTPGThetaFlatTableProducer(const edm::ParameterSet& config)
: MuBaseFlatTableProducer{config}, m_tag{getTag(config)}, m_token{config, consumesCollector(), "src"} {
produces<nanoaod::FlatTable>();
}

void MuNtupleDTTPGThetaFiller::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
void MuDTTPGThetaFlatTableProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;

desc.add<std::string>("label", "ltBmtfInTh");
desc.add<std::string>("name", "ltBmtfInTh");
desc.ifValue(edm::ParameterDescription<std::string>("tag", "BMTF_IN", true),
edm::allowedValues<std::string>("BMTF_IN", "TM_IN"));
desc.add<edm::InputTag>("dtTpTag", edm::InputTag{"bmtfDigis"});
desc.add<edm::InputTag>("src", edm::InputTag{"bmtfDigis"});

descriptions.addWithDefaultLabel(desc);
}

void MuNtupleDTTPGThetaFiller::fill(edm::Event& ev) {
void MuDTTPGThetaFlatTableProducer::fillTable(edm::Event& ev) {
unsigned int nTrigs{0};

std::vector<int8_t> wheel;
Expand Down Expand Up @@ -72,7 +72,7 @@ void MuNtupleDTTPGThetaFiller::fill(edm::Event& ev) {
}
}

auto table = std::make_unique<nanoaod::FlatTable>(nTrigs, m_label, false, false);
auto table = std::make_unique<nanoaod::FlatTable>(nTrigs, m_name, false, false);

table->setDoc("DT trigger primitive information (theta view)");

Expand Down Expand Up @@ -103,13 +103,13 @@ void MuNtupleDTTPGThetaFiller::fill(edm::Event& ev) {
ev.put(std::move(table));
}

MuNtupleDTTPGThetaFiller::TriggerTag MuNtupleDTTPGThetaFiller::getTag(const edm::ParameterSet& config) {
MuDTTPGThetaFlatTableProducer::TriggerTag MuDTTPGThetaFlatTableProducer::getTag(const edm::ParameterSet& config) {
auto tag{TriggerTag::TM_IN};

auto tagName = config.getParameter<std::string>("tag");

if (tagName != "TM_IN" && tagName != "BMTF_IN")
edm::LogError("") << "[MuNtupleDTTPGThetaFiller]::getTag: " << tagName
edm::LogError("") << "[MuDTTPGThetaFlatTableProducer]::getTag: " << tagName
<< " is not a valid tag, defaulting to TM_IN";

if (tagName == "BMTF_IN")
Expand All @@ -121,4 +121,4 @@ MuNtupleDTTPGThetaFiller::TriggerTag MuNtupleDTTPGThetaFiller::getTag(const edm:
#include "FWCore/PluginManager/interface/ModuleDef.h"
#include "FWCore/Framework/interface/MakerMacros.h"

DEFINE_FWK_MODULE(MuNtupleDTTPGThetaFiller);
DEFINE_FWK_MODULE(MuDTTPGThetaFlatTableProducer);
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
#ifndef MuNtuple_MuNtupleDTTPGThetaFiller_h
#define MuNtuple_MuNtupleDTTPGThetaFiller_h
#ifndef Mu_MuDTTPGThetaFlatTableProducer_h
#define Mu_MuDTTPGThetaFlatTableProducer_h

/** \class MuNtupleDTTPGThetaFiller MuNtupleDTTPGThetaFiller.h DPGAnalysis/MuonTools/plugins/MuNtupleDTTPGThetaFiller.h
/** \class MuDTTPGThetaFlatTableProducer MuDTTPGThetaFlatTableProducer.h DPGAnalysis/MuonTools/plugins/MuDTTPGThetaFlatTableProducer.h
*
* Helper class : the Phase-1 local trigger filler for TwinMux and BMTF in (the DataFormat is the same)
* Helper class : the Phase-1 local trigger FlatTableProducer for TwinMux and BMTF in (the DataFormat is the same)
*
* \author C. Battilana (INFN BO)
*
*
*/

#include "DPGAnalysis/MuonTools/src/MuNtupleBaseFiller.h"
#include "DPGAnalysis/MuonTools/src/MuBaseFlatTableProducer.h"

#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"

#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h"

class MuNtupleDTTPGThetaFiller : public MuNtupleBaseFiller {
class MuDTTPGThetaFlatTableProducer : public MuBaseFlatTableProducer {
public:
enum class TriggerTag { TM_IN = 0, BMTF_IN };

/// Constructor
MuNtupleDTTPGThetaFiller(const edm::ParameterSet&);
MuDTTPGThetaFlatTableProducer(const edm::ParameterSet&);

/// Fill descriptors
static void fillDescriptions(edm::ConfigurationDescriptions&);

protected:
/// Fill tree branches for a given events
void fill(edm::Event&) final;
void fillTable(edm::Event&) final;

private:
/// Enum to activate "flavour-by-flavour"
Expand Down
34 changes: 34 additions & 0 deletions DPGAnalysis/MuonTools/plugins/MuDigiFlatTableProducers.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/** \class MuDigiFlatTableProducers.cc MuDigiFlatTableProducers.cc DPGAnalysis/MuonTools/src/MuDigiFlatTableProducers.cc
*
* EDProducers : the flat table producers for CSC, DT, GEM and RPC digis
*
* \author C. Battilana (INFN BO)
*
*
*/

#include "DPGAnalysis/MuonTools/src/MuDigiBaseProducer.h"

#include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
using CSCWireDigiFlatTableProducer = MuDigiBaseProducer<CSCDetId,CSCWireDigi>;

#include "DataFormats/CSCDigi/interface/CSCALCTDigiCollection.h"
using CSCALCTDigiFlatTableProducer = MuDigiBaseProducer<CSCDetId,CSCALCTDigi>;

#include "DataFormats/DTDigi/interface/DTDigiCollection.h"
using DTDigiFlatTableProducer = MuDigiBaseProducer<DTLayerId,DTDigi>;

#include "DataFormats/RPCDigi/interface/RPCDigiCollection.h"
using RPCDigiFlatTableProducer = MuDigiBaseProducer<RPCDetId,RPCDigi>;

#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h"
using GEMDigiFlatTableProducer = MuDigiBaseProducer<GEMDetId,GEMDigi>;

#include "FWCore/PluginManager/interface/ModuleDef.h"
#include "FWCore/Framework/interface/MakerMacros.h"

DEFINE_FWK_MODULE(CSCWireDigiFlatTableProducer);
DEFINE_FWK_MODULE(CSCALCTDigiFlatTableProducer);
DEFINE_FWK_MODULE(DTDigiFlatTableProducer);
DEFINE_FWK_MODULE(RPCDigiFlatTableProducer);
DEFINE_FWK_MODULE(GEMDigiFlatTableProducer);
43 changes: 43 additions & 0 deletions DPGAnalysis/MuonTools/plugins/MuRecoTableProducers.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/** \class MuRecoFlatTableProducers.ccMuRecoFlatTableProducers DPGAnalysis/MuonTools/src/MuRecoFlatTableProducers.cc
*
* EDProducers : the flat table producers for DT, GEM and RPC RecHits and Segments
*
* \author C. Battilana (INFN BO)
*
*
*/

#include "DPGAnalysis/MuonTools/src/MuRecObjBaseProducer.h"


#include "Geometry/DTGeometry/interface/DTGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"

using DTSegmentFlatTableProducer = MuRecObjBaseProducer<DTChamberId,DTRecSegment4D,DTGeometry>;

#include "Geometry/RPCGeometry/interface/RPCGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"

using RPCRecHitFlatTableProducer = MuRecObjBaseProducer<RPCDetId,RPCRecHit,RPCGeometry>;

#include "Geometry/GEMGeometry/interface/GEMGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h"

using GEMRecHitFlatTableProducer = MuRecObjBaseProducer<GEMDetId,GEMRecHit,GEMGeometry>;

#include "Geometry/GEMGeometry/interface/GEMGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "DataFormats/GEMRecHit/interface/GEMSegmentCollection.h"

using GEMSegmentFlatTableProducer = MuRecObjBaseProducer<GEMDetId,GEMSegment,GEMGeometry>;

#include "FWCore/PluginManager/interface/ModuleDef.h"
#include "FWCore/Framework/interface/MakerMacros.h"

DEFINE_FWK_MODULE(DTSegmentFlatTableProducer);
DEFINE_FWK_MODULE(RPCRecHitFlatTableProducer);
DEFINE_FWK_MODULE(GEMRecHitFlatTableProducer);
DEFINE_FWK_MODULE(GEMSegmentFlatTableProducer);
42 changes: 42 additions & 0 deletions DPGAnalysis/MuonTools/python/common_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from PhysicsTools.NanoAOD.common_cff import *
from typing import NamedTuple

class DEFAULT_VAL(NamedTuple):
INT: int = -999
INT8: int = -99
INT_POS: int = -1
FLOAT: int = -999.0
FLOAT_POS: int = -1.0

defaults = DEFAULT_VAL()

def DetIdVar(expr, type, doc=None):
""" Create a PSet for a DetId variable in the tree:
- expr is the expression to evaluate to compute the variable,
- type of the value (int, bool, or a string that the table producer understands),
- doc is a docstring, that will be passed to the table producer
"""
if type == float: type = "float"
elif type == bool: type = "bool"
elif type == int: type = "int"
return cms.PSet(
type = cms.string(type),
expr = cms.string(expr),
doc = cms.string(doc if doc else expr)
)

def GlobGeomVar(expr, doc=None, precision=-1):
""" Create a PSet for a Global position/direction variable in the tree ,
- expr is the expression to evaluate to compute the variable,
- doc is a docstring, that will be passed to the table producer,
- precision is an int handling mantissa reduction.
"""
return cms.PSet(
expr = cms.string(expr),
doc = cms.string(doc if doc else expr),
precision=cms.string(precision) if type(precision)==str else cms.int32(precision)
)




Loading

0 comments on commit 2c9d5bd

Please sign in to comment.