CMS 3D CMS Logo

HLTMuonOfflineAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTMuonOfflineAnalyzer
4 // Class: HLTMuonOfflineAnalyzer
5 //
6 
7 //
8 // Jason Slaunwhite and Jeff Klukas
9 //
10 //
11 
12 // system include files
13 #include <memory>
14 #include <iostream>
15 
16 // user include files
18 
20 
27 
30 
31 #include "TFile.h"
32 #include "TDirectory.h"
33 #include "TPRegexp.h"
34 
37 
39 public:
40  explicit HLTMuonOfflineAnalyzer(const edm::ParameterSet &);
41 
42 private:
43  // Analyzer Methods
44  void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override;
45  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
46  void analyze(const edm::Event &, const edm::EventSetup &) override;
47 
48  // Extra Methods
49  std::vector<std::string> moduleLabels(const std::string &);
50 
51  // Input from Configuration File
54  std::vector<std::string> hltPathsToCheck_;
55 
56  // Member Variables
59 };
60 
63 
64 using namespace std;
65 using namespace edm;
66 using namespace reco;
67 using namespace trigger;
68 
69 using vstring = vector<string>;
70 
73 
75  : pset_(pset),
76  hltProcessName_(pset.getParameter<string>("hltProcessName")),
77  hltPathsToCheck_(pset.getParameter<vstring>("hltPathsToCheck")),
78  plotterContainer_(consumesCollector(), pset) {}
79 
80 vector<string> HLTMuonOfflineAnalyzer::moduleLabels(const string &path) {
81  vector<string> modules = hltConfig_.moduleLabels(path);
82  auto iter = modules.begin();
83  while (iter != modules.end()) {
84  if ((iter->find("Filtered") == string::npos) && (iter->find("hltL1s") == string::npos)) {
85  iter = modules.erase(iter);
86  } else if (iter->find("L1Filtered0") != string::npos) {
87  iter = modules.erase(iter);
88  } else if (iter->find("TracksFiltered") != string::npos)
89  iter = modules.erase(iter);
90  else
91  ++iter;
92  }
93  // iter = modules.begin();
94  // while (iter != modules.end()){
95  // if ((iter->find("Filtered0") == string::npos)){
96  // std::cout<< *iter << std::endl;
97  // iter = modules.erase(iter);
98  // }
99  // else ++iter;
100  // }
101 
102  return modules;
103 }
104 
106  // Initialize hltConfig
107  bool changedConfig;
108  if (!hltConfig_.init(iRun, iSetup, hltProcessName_, changedConfig)) {
109  LogError("HLTMuonVal") << "Initialization of HLTConfigProvider failed!!";
110  return;
111  }
112 
113  // Get the set of trigger paths we want to make plots for
114  set<string> hltPaths;
115  for (auto const &i : hltPathsToCheck_) {
116  for (auto const &j : hltConfig_.triggerNames()) {
117  if (j.find(i) != std::string::npos) {
118  hltPaths.insert(j);
119  }
120  }
121  }
122 
123  // Initialize the plotters
124  set<string>::iterator iPath;
125  vector<string>::const_iterator ilabel;
126  for (iPath = hltPaths.begin(); iPath != hltPaths.end(); iPath++) {
127  const string &path = *iPath;
128  vector<string> labels = moduleLabels(path);
129  bool isLastLabel = false;
130  for (ilabel = labels.begin(); ilabel != labels.end(); ilabel++) {
131  if (*ilabel == labels.back())
132  isLastLabel = true;
133  plotterContainer_.addPlotter(pset_, path, *ilabel, isLastLabel);
134  }
135  }
136 }
137 
139  edm::Run const &iRun,
140  edm::EventSetup const &iSetup) {
141  plotterContainer_.beginRun(iBooker, iRun, iSetup);
142 }
143 
146 }
147 
148 //define this as a plug-in
HLTMuonMatchAndPlotContainer plotterContainer_
vector< string > vstring
Definition: ExoticaDQM.cc:7
Log< level::Error, false > LogError
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:224
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void analyze(const edm::Event &, const edm::EventSetup &)
void analyze(const edm::Event &, const edm::EventSetup &) override
HLTMuonOfflineAnalyzer(const edm::ParameterSet &)
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
const std::vector< std::string > & triggerNames() const
names of trigger paths
void beginRun(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
fixed size matrix
HLT enums.
std::vector< std::string > moduleLabels(const std::string &)
Container Class Definition (this is what is used by the DQM module) ///////.
void addPlotter(const edm::ParameterSet &, std::string, std::string, bool)
Add a HLTMuonMatchAndPlot for a given path.
Definition: Run.h:45
std::vector< std::string > hltPathsToCheck_