CMS 3D CMS Logo

TriggerBxVsOrbitMonitor.cc
Go to the documentation of this file.
1 // C++ headers
2 #include <string>
3 #include <cstring>
4 
5 // boost headers
6 #include <boost/regex.hpp>
7 #include <boost/format.hpp>
8 #include <boost/lexical_cast.hpp>
9 
10 // Root headers
11 #include <TH1F.h>
12 
13 // CMSSW headers
36 
37 // helper functions
38 template <typename T>
39 static
40 const T & get(const edm::Event & event, const edm::EDGetTokenT<T> & token) {
42  event.getByToken(token, handle);
43  if (not handle.isValid())
44  throw * handle.whyFailed();
45  return * handle.product();
46 }
47 
48 template <typename R, typename T>
49 static
50 const T & get(const edm::EventSetup & setup) {
52  setup.get<R>().get(handle);
53  return * handle.product();
54 }
55 
56 
58 public:
60  ~TriggerBxVsOrbitMonitor() override = default;
61 
62  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
63 
64 private:
65  void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override;
66  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
67  void analyze(edm::Event const &, edm::EventSetup const &) override;
68 
69  // number of bunch crossings
70  static const unsigned int s_bx_range = 3564;
71  static const unsigned int s_orbit_range = 262144; // 2**18 orbits in 1 LS
72 
73  // TCDS trigger types
74  // see https://twiki.cern.ch/twiki/bin/viewauth/CMS/TcdsEventRecord
75  static constexpr const char * const s_tcds_trigger_types[] = {
76  "Empty", // 0 - No trigger
77  "Physics", // 1 - GT trigger
78  "Calibration", // 2 - Sequence trigger (calibration)
79  "Random", // 3 - Random trigger
80  "Auxiliary", // 4 - Auxiliary (CPM front panel NIM input) trigger
81  nullptr, // 5 - reserved
82  nullptr, // 6 - reserved
83  nullptr, // 7 - reserved
84  "Cyclic", // 8 - Cyclic trigger
85  "Bunch-pattern", // 9 - Bunch-pattern trigger
86  "Software", // 10 - Software trigger
87  "TTS", // 11 - TTS-sourced trigger
88  nullptr, // 12 - reserved
89  nullptr, // 13 - reserved
90  nullptr, // 14 - reserved
91  nullptr // 15 - reserved
92  };
93 
94  // module configuration
98  const int m_minLS;
99  const int m_maxLS;
100  const int m_minBX;
101  const int m_maxBX;
102 
103  // L1T and HLT configuration
106 
107  std::vector<TH2F *> m_orbit_bx_all_byLS;
109  std::vector<TH2F *> m_orbit_bx;
110 };
111 
112 // definition
114 
115 
117 {
119  desc.addUntracked<edm::InputTag>( "l1tResults", edm::InputTag("gtStage2Digis"));
120  desc.addUntracked<edm::InputTag>( "hltResults", edm::InputTag("TriggerResults"));
121  desc.addUntracked<std::string>( "dqmPath", "HLT/TriggerBx" );
122  desc.addUntracked<int>( "minLS", 134 );
123  desc.addUntracked<int>( "maxLS", 136 );
124  desc.addUntracked<int>( "minBX", 894 );
125  desc.addUntracked<int>( "maxBX", 912 );
126  descriptions.add("triggerBxVsOrbitMonitor", desc);
127 }
128 
130  // module configuration
131  m_l1t_results( consumes<GlobalAlgBlkBxCollection>( config.getUntrackedParameter<edm::InputTag>( "l1tResults" ) ) ),
132  m_hlt_results( consumes<edm::TriggerResults>( config.getUntrackedParameter<edm::InputTag>( "hltResults" ) ) ),
133  m_dqm_path( config.getUntrackedParameter<std::string>( "dqmPath" ) ),
134  m_minLS( config.getUntrackedParameter<int>( "minLS" ) ),
135  m_maxLS( config.getUntrackedParameter<int>( "maxLS" ) ),
136  m_minBX( config.getUntrackedParameter<int>( "minBX" ) ),
137  m_maxBX( config.getUntrackedParameter<int>( "maxBX" ) ),
138  // L1T and HLT configuration
140  m_hltConfig(),
143  m_orbit_bx()
144 {
145 }
146 
148 {
149  size_t nLS = m_maxLS-m_minLS+1;
150 
151  m_orbit_bx_all_byLS.clear();
152  m_orbit_bx_all_byLS.resize(nLS,nullptr);
153 
154  m_orbit_bx.clear();
155  m_orbit_bx.resize(sizeof(s_tcds_trigger_types) / sizeof(const char *), nullptr);
156 
157 
158 }
159 
161 {
162  // TCDS trigger type plots
163  {
164  size_t size = sizeof(s_tcds_trigger_types) / sizeof(const char *);
165  size_t nLS = m_maxLS-m_minLS+1;
166 
167  unsigned int nBX = m_maxBX-m_minBX+1;
168  // book 2D histogram to monitor all TCDS trigger types in a single plot
169  booker.setCurrentFolder( m_dqm_path + "/orbitVsBX" );
170  m_orbit_bx_all = booker.book2D("OrbitVsBX", "Event orbits vs. bunch crossing", nBX, float(m_minBX)-0.5, float(m_maxBX)+0.5, s_orbit_range+1, -0.5, float(s_orbit_range)+0.5)->getTH2F();
171  m_orbit_bx_all->GetXaxis()->SetTitle("BX");
172  m_orbit_bx_all->GetYaxis()->SetTitle("orbit");
173  m_orbit_bx_all->SetCanExtend(TH1::kAllAxes);
174 
175  for (unsigned int i = 0; i < nLS; ++i) {
176  std::string iname = std::to_string(i);
177  m_orbit_bx_all_byLS.at(i) = booker.book2D("OrbitVsBX_LS"+iname, "OrbitVsBX_LS"+iname, nBX, float(m_minBX)-0.5, float(m_maxBX)+0.5, s_orbit_range+1, -0.5, float(s_orbit_range)+0.5)->getTH2F();
178  m_orbit_bx_all_byLS.at(i)->GetXaxis()->SetTitle("BX");
179  m_orbit_bx_all_byLS.at(i)->GetYaxis()->SetTitle("orbit");
180  }
181 
182  booker.setCurrentFolder( m_dqm_path + "/orbitVsBX/TCDS" );
183  for (unsigned int i = 0; i < size; ++i) {
184  if (s_tcds_trigger_types[i]) {
185  m_orbit_bx.at(i) = booker.book2D("OrbitVsBX_"+std::string(s_tcds_trigger_types[i]), "Event orbits vs. bunch crossing "+std::string(s_tcds_trigger_types[i]), nBX, float(m_minBX)-0.5, float(m_maxBX)+0.5,s_orbit_range+1, -0.5, float(s_orbit_range)+0.5)->getTH2F();
186  m_orbit_bx.at(i)->GetXaxis()->SetTitle("BX");
187  m_orbit_bx.at(i)->GetYaxis()->SetTitle("orbit");
188  }
189  }
190  }
191 }
192 
193 
195 {
196  unsigned int bx = event.bunchCrossing();
197  unsigned int orbit = event.orbitNumber();
198  unsigned int ls = event.id().luminosityBlock();
199  int orbit_in_ls = orbit-(s_orbit_range*(ls-1));
200  m_orbit_bx_all->Fill(bx,orbit_in_ls);
201 
202  int iLS = ls-m_minLS;
203  if (iLS >= 0 && iLS < int(m_orbit_bx_all_byLS.size()))
204  m_orbit_bx_all_byLS.at(iLS)->Fill(bx,orbit_in_ls);
205 
206 
207  // monitor the bx distribution for the TCDS trigger types
208  size_t size = sizeof(s_tcds_trigger_types) / sizeof(const char *);
209  unsigned int type = event.experimentType();
210  if (type < size and m_orbit_bx[type]) {
211  m_orbit_bx[type]->Fill(bx,orbit_in_ls);
212  }
213 
214 }
215 
216 
217 //define this as a plug-in
size
Write out results.
std::vector< TH2F * > m_orbit_bx
type
Definition: HCALResponse.h:21
static const char *const s_tcds_trigger_types[]
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void analyze(edm::Event const &, edm::EventSetup const &) override
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
static const unsigned int s_orbit_range
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
static const unsigned int s_bx_range
Definition: config.py:1
#define nullptr
#define constexpr
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
std::vector< TH2F * > m_orbit_bx_all_byLS
~TriggerBxVsOrbitMonitor() override=default
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:74
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > m_l1t_results
TriggerBxVsOrbitMonitor(edm::ParameterSet const &)
L1TUtmTriggerMenu const * m_l1tMenu
def ls(path, rec=False)
Definition: eostools.py:348
const edm::EDGetTokenT< edm::TriggerResults > m_hlt_results
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
T const * product() const
Definition: Handle.h:81
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
std::shared_ptr< cms::Exception > whyFailed() const
Definition: HandleBase.h:106
TH2F * getTH2F(void) const
long double T
T const * product() const
Definition: ESHandle.h:86
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: event.py:1
Definition: Run.h:43