CMS 3D CMS Logo

MuNtupleUtils.h
Go to the documentation of this file.
1 #ifndef MuNtuple_MuNtupleUtils_h
2 #define MuNtuple_MuNtupleUtils_h
3 
23 
26 
27 #include <array>
28 #include <string>
29 
30 class L1MuDTChambPhDigi;
31 class L1Phase2MuDTPhDigi;
32 
33 namespace nano_mu {
34 
35  template <class T>
36  class EDTokenHandle {
37  public:
40  : m_name{name}, m_inputTag{config.getParameter<edm::InputTag>(name)} {
41  if (m_inputTag.label() != "none") {
42  m_token = collector.template consumes<T>(m_inputTag);
43  }
44  }
45 
49  auto conditionalGet(const edm::Event& ev) const {
51 
52  if (!m_token.isUninitialized() && !ev.getByToken(m_token, collection))
53  edm::LogError("") << "[EDTokenHandle]::conditionalGet: " << m_inputTag.label()
54  << " collection does not exist !!!";
55 
56  return collection;
57  }
58 
59  private:
63  };
64 
65  template <class T, class R, edm::Transition TR = edm::Transition::Event>
66  class ESTokenHandle {
67  public:
70  : m_token{collector.template esConsumes<TR>(edm::ESInputTag{"", label})} {}
71 
74 
76  bool isValid() { return m_handle.isValid(); }
77 
79  T const* operator->() { return m_handle.product(); }
80 
81  private:
84  };
85 
87  public:
88  struct chambCoord {
89  double pos{};
90  double dir{};
91  };
92 
94  DTTrigGeomUtils(edm::ConsumesCollector&& collector, bool dirInDeg = true);
95 
97  chambCoord trigToReco(const L1MuDTChambPhDigi* trig);
98 
100  chambCoord trigToReco(const L1Phase2MuDTPhDigi* trig);
101 
103  bool hasPosRF(int wh, int sec) { return wh > 0 || (wh == 0 && sec % 4 > 1); };
104 
108  for (int i_st = 0; i_st != 4; ++i_st) {
109  const DTChamberId chId(-2, i_st + 1, 4);
110  const DTChamber* chamb = m_dtGeom->chamber(chId);
111  const DTSuperLayer* sl1 = chamb->superLayer(DTSuperLayerId(chId, 1));
112  const DTSuperLayer* sl3 = chamb->superLayer(DTSuperLayerId(chId, 3));
113  m_zsl1[i_st] = chamb->surface().toLocal(sl1->position()).z();
114  m_zsl3[i_st] = chamb->surface().toLocal(sl3->position()).z();
115  m_zcn[i_st] = 0.5 * (m_zsl1[i_st] + m_zsl3[i_st]);
116  }
117  };
118 
119  private:
121 
122  std::array<double, 4> m_zcn;
123  std::array<double, 4> m_zsl1;
124  std::array<double, 4> m_zsl3;
125 
126  static constexpr double PH1_PHI_R = 4096.;
127  static constexpr double PH1_PHIB_R = 512.;
128 
129  static constexpr double PH2_PHI_R = 65536. / 0.8;
130  static constexpr double PH2_PHIB_R = 2048. / 1.4;
131  };
132 
133 } // namespace nano_mu
134 
135 #endif
static constexpr double PH1_PHI_R
static constexpr double PH2_PHI_R
ESTokenHandle(edm::ConsumesCollector &&collector, const std::string &label="")
Constructor.
Definition: MuNtupleUtils.h:69
DTTrigGeomUtils(edm::ConsumesCollector &&collector, bool dirInDeg=true)
Constructor.
Definition: config.py:1
std::string const & label() const
Definition: InputTag.h:36
auto conditionalGet(const edm::Event &ev) const
Definition: MuNtupleUtils.h:49
LocalPoint toLocal(const GlobalPoint &gp) const
std::array< double, 4 > m_zsl3
char const * label
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return the superlayer corresponding to the given id.
Definition: DTChamber.cc:53
std::array< double, 4 > m_zcn
void getFromES(const edm::Run &run, const edm::EventSetup &environment)
Update EventSetup information.
EDTokenHandle(const edm::ParameterSet &config, edm::ConsumesCollector &&collector, std::string name)
Constructor.
Definition: MuNtupleUtils.h:39
edm::ESGetToken< T, R > m_token
Definition: MuNtupleUtils.h:82
edm::ESHandle< T > m_handle
Definition: MuNtupleUtils.h:83
bool hasPosRF(int wh, int sec)
Checks id the chamber has positive RF;.
T const * operator->()
Return handle.
Definition: MuNtupleUtils.h:79
edm::InputTag m_inputTag
Definition: MuNtupleUtils.h:61
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
bool isValid()
Check validity.
Definition: MuNtupleUtils.h:76
static constexpr double PH1_PHIB_R
void getFromES(const edm::EventSetup &environment)
Get Handle from ES.
Definition: MuNtupleUtils.h:73
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
std::array< double, 4 > m_zsl1
ESTokenHandle< DTGeometry, MuonGeometryRecord, edm::Transition::BeginRun > m_dtGeom
static constexpr double PH2_PHIB_R
edm::EDGetTokenT< T > m_token
Definition: MuNtupleUtils.h:62
long double T
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:90
chambCoord trigToReco(const L1MuDTChambPhDigi *trig)
Return local position and direction in chamber RF - legacy.
Definition: Run.h:45