ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/HLTConfigProvider.cc
Revision: 1.2
Committed: Wed Mar 3 13:50:28 2010 UTC (15 years, 2 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +2 -2 lines
State: FILE REMOVED
Error occurred while calculating annotation data.
Log Message:
Cleanup use of HLTConfigProvider and remove hacked version

File Contents

# Content
1 /** \class HLTConfigProvider
2 *
3 * See header file for documentation
4 *
5 * $Date: 2009/12/15 00:45:50 $
6 * $Revision: 1.1 $
7 *
8 * \author Martin Grunewald
9 *
10 */
11
12 #include "MitProd/TreeFiller/interface/HLTConfigProvider.h"
13 #include "FWCore/MessageLogger/interface/MessageLogger.h"
14 #include <iostream>
15
16 using namespace mitedm;
17
18 bool HLTConfigProvider::init(const edm::ParameterSetID &psetid)
19 {
20 using namespace std;
21 using namespace edm;
22
23 // clear data members
24
25 processName_ = "";
26 registry_ = pset::Registry::instance();
27
28 ProcessPSet_ = ParameterSet();
29 tableName_ = "/dev/null";
30
31 triggerNames_.clear();
32 moduleLabels_.clear();
33
34 triggerIndex_.clear();
35 moduleIndex_.clear();
36
37 pathNames_.clear();
38 endpathNames_.clear();
39
40 // initialise
41
42 LogInfo("HLTConfigProvider") << " called with processName '"
43 << processName_
44 << "'." << endl;
45
46 // Obtain ParameterSetID for requested process (with name
47 // processName) from pset registry
48 ParameterSetID ProcessPSetID;
49 for (edm::pset::Registry::const_iterator i = registry_->begin(); i != registry_->end(); ++i) {
50 if (i->second.existsAs<ParameterSet>("@trigger_paths") && i->second.getParameter<ParameterSet>("@trigger_paths").id() == psetid)
51 ProcessPSetID = i->first;
52 }
53 if (ProcessPSetID==ParameterSetID()) {
54 LogError("HLTConfigProvider") << " Process matching trigger_paths '"
55 << "' not found in registry!" << endl;
56 return false;
57 }
58
59 // Obtain ParameterSet from ParameterSetID
60 if (!(registry_->getMapped(ProcessPSetID,ProcessPSet_))) {
61 LogError("HLTConfigProvider") << " ProcessPSet for ProcessPSetID '"
62 << ProcessPSetID
63 << "' not found in registry!" << endl;
64 return false;
65 }
66
67 processName_ = ProcessPSet_.getParameter<string>("@process_name");
68
69 // Obtain PSet containing table name (available only in 2_1_10++ files)
70 if (ProcessPSet_.exists("HLTConfigVersion")) {
71 const ParameterSet HLTPSet(ProcessPSet_.getParameter<ParameterSet>("HLTConfigVersion"));
72 if (HLTPSet.exists("tableName")) {
73 tableName_=HLTPSet.getParameter<string>("tableName");
74 }
75 }
76 LogInfo("HLTConfigProvider") << " HLT-ConfDB TableName = '"
77 << tableName_
78 << "'." << endl;
79
80 // Extract trigger paths, which are paths but with endpaths to be
81 // removed, from ParameterSet
82 pathNames_ = ProcessPSet_.getParameter<vector<string> >("@paths");
83 endpathNames_= ProcessPSet_.getParameter<vector<string> >("@end_paths");
84 const unsigned int nP(pathNames_.size());
85 const unsigned int nE(endpathNames_.size());
86 for (unsigned int iE=0; iE!=nE; ++iE) {
87 const std::string& endpath(endpathNames_[iE]);
88 for (unsigned int iP=0; iP!=nP; ++iP) {
89 if (pathNames_[iP]==endpath) {
90 pathNames_[iP]=""; // erase endpaths
91 }
92 }
93 }
94 triggerNames_.reserve(nP);
95 for (unsigned int iP=0; iP!=nP; ++iP) {
96 if (pathNames_[iP]!="") {triggerNames_.push_back(pathNames_[iP]);}
97 }
98 pathNames_ = ProcessPSet_.getParameter<vector<string> >("@paths");
99
100 // Obtain module labels of all modules on all trigger paths
101 const unsigned int n(size());
102 moduleLabels_.reserve(n);
103 for (unsigned int i=0;i!=n; ++i) {
104 moduleLabels_.push_back(ProcessPSet_.getParameter<vector<string> >(triggerNames_[i]));
105 }
106
107 // Fill index maps for fast lookup
108 moduleIndex_.resize(n);
109 for (unsigned int i=0; i!=n; ++i) {
110 triggerIndex_[triggerNames_[i]]=i;
111 moduleIndex_[i].clear();
112 const unsigned int m(size(i));
113 for (unsigned int j=0; j!=m; ++j) {
114 moduleIndex_[i][moduleLabels_[i][j]]=j;
115 }
116 }
117
118 return true;
119 }
120
121 void HLTConfigProvider::dump (const std::string& what) const {
122 using namespace std;
123 using namespace edm;
124
125 if (what=="processName") {
126 cout << "HLTConfigProvider::dump: ProcessName = " << processName_ << endl;
127 } else if (what=="ProcessPSet") {
128 cout << "HLTConfigProvider::dump: ProcessPSet = " << endl << ProcessPSet_ << endl;
129 } else if (what=="TableName") {
130 cout << "HLTConfigProvider::dump: TableName = " << tableName_ << endl;
131 } else if (what=="Triggers") {
132 const unsigned int n(size());
133 cout << "HLTConfigProvider::dump: Triggers: " << n << endl;
134 for (unsigned int i=0; i!=n; ++i) {
135 cout << " " << i << " " << triggerNames_[i] << endl;
136 }
137 } else if (what=="Modules") {
138 const unsigned int n(size());
139 cout << "HLTConfigProvider::dump Triggers and Modules: " << n << endl;
140 for (unsigned int i=0; i!=n; ++i) {
141 const unsigned int m(size(i));
142 cout << i << " " << triggerNames_[i] << " " << m << endl;
143 cout << " - Modules: ";
144 unsigned int nHLTPrescalers(0);
145 unsigned int nHLTLevel1GTSeed(0);
146 for (unsigned int j=0; j!=m; ++j) {
147 const string& label(moduleLabels_[i][j]);
148 const string type(moduleType(label));
149 cout << " " << j << ":" << label << "/" << type ;
150 if (type=="HLTPrescaler") nHLTPrescalers++;
151 if (type=="HLTLevel1GTSeed") nHLTLevel1GTSeed++;
152 }
153 cout << endl;
154 cout << " - Number of HLTPrescaler/HLTLevel1GTSeed modules: "
155 << nHLTPrescalers << "/" << nHLTLevel1GTSeed << endl;
156 }
157 } else {
158 cout << "HLTConfigProvider::dump: Unkown dump request: " << what << endl;
159 }
160 return;
161 }
162
163 unsigned int HLTConfigProvider::size() const {
164 return triggerNames_.size();
165 }
166 unsigned int HLTConfigProvider::size(unsigned int trigger) const {
167 return moduleLabels_.at(trigger).size();
168 }
169 unsigned int HLTConfigProvider::size(const std::string& trigger) const {
170 return size(triggerIndex(trigger));
171 }
172
173 const std::string& HLTConfigProvider::tableName() const {
174 return tableName_;
175 }
176 const std::vector<std::string>& HLTConfigProvider::triggerNames() const {
177 return triggerNames_;
178 }
179 const std::string& HLTConfigProvider::triggerName(unsigned int trigger) const {
180 return triggerNames_.at(trigger);
181 }
182 unsigned int HLTConfigProvider::triggerIndex(const std::string& trigger) const {
183 const std::map<std::string,unsigned int>::const_iterator index(triggerIndex_.find(trigger));
184 if (index==triggerIndex_.end()) {
185 return size();
186 } else {
187 return index->second;
188 }
189 }
190
191 const std::vector<std::string>& HLTConfigProvider::moduleLabels(unsigned int trigger) const {
192 return moduleLabels_.at(trigger);
193 }
194 const std::vector<std::string>& HLTConfigProvider::moduleLabels(const std::string& trigger) const {
195 return moduleLabels_.at(triggerIndex(trigger));
196 }
197
198 const std::string& HLTConfigProvider::moduleLabel(unsigned int trigger, unsigned int module) const {
199 return moduleLabels_.at(trigger).at(module);
200 }
201 const std::string& HLTConfigProvider::moduleLabel(const std::string& trigger, unsigned int module) const {
202 return moduleLabels_.at(triggerIndex(trigger)).at(module);
203 }
204
205 unsigned int HLTConfigProvider::moduleIndex(unsigned int trigger, const std::string& module) const {
206 const std::map<std::string,unsigned int>::const_iterator index(moduleIndex_.at(trigger).find(module));
207 if (index==moduleIndex_.at(trigger).end()) {
208 return size(trigger);
209 } else {
210 return index->second;
211 }
212 }
213 unsigned int HLTConfigProvider::moduleIndex(const std::string& trigger, const std::string& module) const {
214 return moduleIndex(triggerIndex(trigger),module);
215 }
216
217 const std::string HLTConfigProvider::moduleType(const std::string& module) const {
218 if (ProcessPSet_.exists(module)) {
219 return modulePSet(module).getParameter<std::string>("@module_type");
220 } else {
221 return "";
222 }
223 }
224
225 const edm::ParameterSet HLTConfigProvider::modulePSet(const std::string& module) const {
226 if (ProcessPSet_.exists(module)) {
227 return ProcessPSet_.getParameter<edm::ParameterSet>(module);
228 } else {
229 return edm::ParameterSet();
230 }
231 }