00001
00012 #include "HLTrigger/HLTcore/interface/HLTConfigData.h"
00013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00014
00015 #include <iostream>
00016
00017 static const edm::ParameterSet* s_dummyPSet()
00018 {
00019 static edm::ParameterSet dummyPSet;
00020 dummyPSet.registerIt();
00021 return &dummyPSet;
00022 }
00023
00024 HLTConfigData::HLTConfigData():
00025 processPSet_(s_dummyPSet()),
00026 processName_(""),
00027 tableName_(), triggerNames_(), moduleLabels_(),
00028 triggerIndex_(), moduleIndex_(),
00029 hltL1GTSeeds_(),
00030 streamNames_(), streamIndex_(), streamContents_(),
00031 datasetNames_(), datasetIndex_(), datasetContents_(),
00032 hltPrescaleTable_()
00033 {
00034 if (processPSet_->id().isValid()) {
00035 extract();
00036 }
00037 }
00038
00039 HLTConfigData::HLTConfigData(const edm::ParameterSet* iPSet):
00040 processPSet_(iPSet),
00041 processName_(""),
00042 tableName_(), triggerNames_(), moduleLabels_(),
00043 triggerIndex_(), moduleIndex_(),
00044 hltL1GTSeeds_(),
00045 streamNames_(), streamIndex_(), streamContents_(),
00046 datasetNames_(), datasetIndex_(), datasetContents_(),
00047 hltPrescaleTable_()
00048 {
00049 if (processPSet_->id().isValid()) {
00050 extract();
00051 }
00052 }
00053
00054 void HLTConfigData::extract()
00055 {
00056 using namespace std;
00057 using namespace edm;
00058 using namespace trigger;
00059
00060
00061 if (processPSet_->existsAs<string>("@process_name",true)) {
00062 processName_= processPSet_->getParameter<string>("@process_name");
00063 }
00064
00065
00066 if (processPSet_->existsAs<ParameterSet>("HLTConfigVersion",true)) {
00067 const ParameterSet& HLTPSet(processPSet_->getParameterSet("HLTConfigVersion"));
00068 if (HLTPSet.existsAs<string>("tableName",true)) {
00069 tableName_=HLTPSet.getParameter<string>("tableName");
00070 }
00071 }
00072 LogVerbatim("HLTConfigData") << "ProcessPSet with: "
00073 << processName_ << " "
00074 << tableName();
00075
00076
00077 if (processPSet_->existsAs<ParameterSet>("@trigger_paths",true)) {
00078 const ParameterSet& HLTPSet(processPSet_->getParameterSet("@trigger_paths"));
00079 if (HLTPSet.existsAs<vector<string> >("@trigger_paths",true)) {
00080 triggerNames_= HLTPSet.getParameter<vector<string> >("@trigger_paths");
00081 }
00082 }
00083
00084
00085 const unsigned int n(size());
00086 moduleLabels_.reserve(n);
00087 for (unsigned int i=0;i!=n; ++i) {
00088 if (processPSet_->existsAs<vector<string> >(triggerNames_[i],true)) {
00089 moduleLabels_.push_back(processPSet_->getParameter<vector<string> >(triggerNames_[i]));
00090 }
00091 }
00092
00093
00094 moduleIndex_.resize(n);
00095 for (unsigned int i=0; i!=n; ++i) {
00096 triggerIndex_[triggerNames_[i]]=i;
00097 moduleIndex_[i].clear();
00098 const unsigned int m(size(i));
00099 for (unsigned int j=0; j!=m; ++j) {
00100 moduleIndex_[i][moduleLabels_[i][j]]=j;
00101 }
00102 }
00103
00104
00105 hltL1GTSeeds_.resize(n);
00106 for (unsigned int i=0; i!=n; ++i) {
00107 hltL1GTSeeds_[i].clear();
00108 const unsigned int m(size(i));
00109 for (unsigned int j=0; j!=m; ++j) {
00110 const string& label(moduleLabels_[i][j]);
00111 if (moduleType(label) == "HLTLevel1GTSeed") {
00112 const ParameterSet& pset(modulePSet(label));
00113 if (pset!=ParameterSet()) {
00114 const bool l1Tech(pset.getParameter<bool>("L1TechTriggerSeeding"));
00115 const string l1Seed(pset.getParameter<string>("L1SeedsLogicalExpression"));
00116 hltL1GTSeeds_[i].push_back(pair<bool,string>(l1Tech,l1Seed));
00117 }
00118 }
00119 }
00120 }
00121
00122
00123 if (processPSet_->existsAs<ParameterSet>("streams",true)) {
00124 const ParameterSet& streams(processPSet_->getParameterSet("streams"));
00125 streamNames_=streams.getParameterNamesForType<vector<string> >();
00126 sort(streamNames_.begin(),streamNames_.end());
00127 const unsigned int n(streamNames_.size());
00128 streamContents_.resize(n);
00129 for (unsigned int i=0; i!=n; ++i) {
00130 streamIndex_[streamNames_[i]]=i;
00131 streamContents_[i]=streams.getParameter<vector<string> >(streamNames_[i]);
00132 sort(streamContents_[i].begin(),streamContents_[i].end());
00133 }
00134
00135 }
00136
00137
00138 if (processPSet_->existsAs<ParameterSet>("datasets",true)) {
00139 const ParameterSet& datasets(processPSet_->getParameterSet("datasets"));
00140 datasetNames_=datasets.getParameterNamesForType<vector<string> >();
00141 sort(datasetNames_.begin(),datasetNames_.end());
00142 const unsigned int n(datasetNames_.size());
00143 datasetContents_.resize(n);
00144 for (unsigned int i=0; i!=n; ++i) {
00145 datasetIndex_[datasetNames_[i]]=i;
00146 datasetContents_[i]=datasets.getParameter< vector<string> >(datasetNames_[i]);
00147 sort(datasetContents_[i].begin(),datasetContents_[i].end());
00148 }
00149 }
00150
00151
00152
00153
00154 string prescaleName("");
00155 const string preS("PrescaleService");
00156 const string preT("PrescaleTable");
00157 if (processPSet_->existsAs<ParameterSet>(preS,true)) {
00158 prescaleName=preS;
00159 } else if ( processPSet_->existsAs<ParameterSet>(preT,true)) {
00160 prescaleName=preT;
00161 }
00162 if (prescaleName=="") {
00163 hltPrescaleTable_=HLTPrescaleTable();
00164 } else {
00165 const ParameterSet& iPS(processPSet_->getParameterSet(prescaleName));
00166 string defaultLabel(iPS.getUntrackedParameter<string>("lvl1DefaultLabel",""));
00167 vector<string> labels;
00168 if (iPS.existsAs<vector<string> >("lvl1Labels",true)) {
00169 labels = iPS.getParameter<vector<string> >("lvl1Labels");
00170 }
00171 unsigned int set(0);
00172 const unsigned int n(labels.size());
00173 for (unsigned int i=0; i!=n; ++i) {
00174 if (labels[i]==defaultLabel) set=i;
00175 }
00176 map<string,vector<unsigned int> > table;
00177 if (iPS.existsAs< vector<ParameterSet> >("prescaleTable",true)) {
00178 const vector<ParameterSet>& vpTable(iPS.getParameterSetVector("prescaleTable"));
00179 const unsigned int m (vpTable.size());
00180 for (unsigned int i=0; i!=m; ++i) {
00181 table[vpTable[i].getParameter<std::string>("pathName")] =
00182 vpTable[i].getParameter<std::vector<unsigned int> >("prescales");
00183 }
00184 }
00185 if (n>0) {
00186 hltPrescaleTable_=HLTPrescaleTable(set,labels,table);
00187 } else {
00188 hltPrescaleTable_=HLTPrescaleTable();
00189 }
00190
00191 }
00192
00193 return;
00194 }
00195
00196 void HLTConfigData::dump(const std::string& what) const {
00197 using namespace std;
00198 using namespace edm;
00199
00200 if (what=="ProcessPSet") {
00201 cout << "HLTConfigData::dump: ProcessPSet = " << endl << *processPSet_ << endl;
00202 } else if (what=="ProcessName") {
00203 cout << "HLTConfigData::dump: ProcessName = " << processName_ << endl;
00204
00205 } else if (what=="TableName") {
00206 cout << "HLTConfigData::dump: TableName = " << tableName_ << endl;
00207 } else if (what=="Triggers") {
00208 const unsigned int n(size());
00209 cout << "HLTConfigData::dump: Triggers: " << n << endl;
00210 for (unsigned int i=0; i!=n; ++i) {
00211 cout << " " << i << " " << triggerNames_[i] << endl;
00212 }
00213 } else if (what=="TriggerSeeds") {
00214 const unsigned int n(size());
00215 cout << "HLTConfigData::dump: TriggerSeeds: " << n << endl;
00216 for (unsigned int i=0; i!=n; ++i) {
00217 const unsigned int m(hltL1GTSeeds_[i].size());
00218 cout << " " << i << " " << triggerNames_[i] << " " << m << endl;
00219 for (unsigned int j=0; j!=m; ++j) {
00220 cout << " " << j
00221 << " " << hltL1GTSeeds_[i][j].first
00222 << "/" << hltL1GTSeeds_[i][j].second << endl;
00223 }
00224 }
00225 } else if (what=="Modules") {
00226 const unsigned int n(size());
00227 cout << "HLTConfigData::dump Triggers and Modules: " << n << endl;
00228 for (unsigned int i=0; i!=n; ++i) {
00229 const unsigned int m(size(i));
00230 cout << i << " " << triggerNames_[i] << " " << m << endl;
00231 cout << " - Modules: ";
00232 unsigned int nHLTPrescalers(0);
00233 unsigned int nHLTLevel1GTSeed(0);
00234 for (unsigned int j=0; j!=m; ++j) {
00235 const string& label(moduleLabels_[i][j]);
00236 const string type(moduleType(label));
00237 const string edmtype(moduleEDMType(label));
00238 cout << " " << j << ":" << label << "/" << type << "/" << edmtype;
00239 if (type=="HLTPrescaler") nHLTPrescalers++;
00240 if (type=="HLTLevel1GTSeed") nHLTLevel1GTSeed++;
00241 }
00242 cout << endl;
00243 cout << " - Number of HLTPrescaler/HLTLevel1GTSeed modules: "
00244 << nHLTPrescalers << "/" << nHLTLevel1GTSeed << endl;
00245 }
00246 } else if (what=="StreamNames") {
00247 const unsigned int n(streamNames_.size());
00248 cout << "HLTConfigData::dump: StreamNames: " << n << endl;
00249 for (unsigned int i=0; i!=n; ++i) {
00250 cout << " " << i << " " << streamNames_[i] << endl;
00251 }
00252 } else if (what=="Streams") {
00253 const unsigned int n(streamNames_.size());
00254 cout << "HLTConfigData::dump: Streams: " << n << endl;
00255 for (unsigned int i=0; i!=n; ++i) {
00256 const unsigned int m(streamContents_[i].size());
00257 cout << " " << i << " " << streamNames_[i] << " " << m << endl;
00258 for (unsigned int j=0; j!=m; ++j) {
00259 cout << " " << j << " " << streamContents_[i][j] << endl;
00260 }
00261 }
00262 } else if (what=="DatasetNames") {
00263 const unsigned int n(datasetNames_.size());
00264 cout << "HLTConfigData::dump: DatasetNames: " << n << endl;
00265 for (unsigned int i=0; i!=n; ++i) {
00266 cout << " " << i << " " << datasetNames_[i] << endl;
00267 }
00268 } else if (what=="Datasets") {
00269 const unsigned int n(datasetNames_.size());
00270 cout << "HLTConfigData::dump: Datasets: " << n << endl;
00271 for (unsigned int i=0; i!=n; ++i) {
00272 const unsigned int m(datasetContents_[i].size());
00273 cout << " " << i << " " << datasetNames_[i] << " " << m << endl;
00274 for (unsigned int j=0; j!=m; ++j) {
00275 cout << " " << j << " " << datasetContents_[i][j] << endl;
00276 }
00277 }
00278 } else if (what=="PrescaleTable") {
00279 const unsigned int n (hltPrescaleTable_.size());
00280 cout << "HLTConfigData::dump: PrescaleTable: # of sets : " << n << endl;
00281 const vector<string>& labels(hltPrescaleTable_.labels());
00282 for (unsigned int i=0; i!=n; ++i) {
00283 cout << " " << i << "/'" << labels.at(i) << "'";
00284 }
00285 if (n>0) cout << endl;
00286 const map<string,vector<unsigned int> >& table(hltPrescaleTable_.table());
00287 cout << "HLTConfigData::dump: PrescaleTable: # of paths: " << table.size() << endl;
00288 const map<string,vector<unsigned int> >::const_iterator tb(table.begin());
00289 const map<string,vector<unsigned int> >::const_iterator te(table.end());
00290 for (map<string,vector<unsigned int> >::const_iterator ti=tb; ti!=te; ++ti) {
00291 for (unsigned int i=0; i!=n; ++i) {
00292 cout << " " << ti->second.at(i);
00293 }
00294 cout << " " << ti->first << endl;
00295 }
00296 } else {
00297 cout << "HLTConfigData::dump: Unkown dump request: " << what << endl;
00298 }
00299 return;
00300 }
00301
00302 const std::string& HLTConfigData::processName() const {
00303 return processName_;
00304 }
00305
00306 unsigned int HLTConfigData::size() const {
00307 return triggerNames_.size();
00308 }
00309 unsigned int HLTConfigData::size(unsigned int trigger) const {
00310 return moduleLabels_.at(trigger).size();
00311 }
00312 unsigned int HLTConfigData::size(const std::string& trigger) const {
00313 return size(triggerIndex(trigger));
00314 }
00315
00316 const std::string& HLTConfigData::tableName() const {
00317 return tableName_;
00318 }
00319 const std::vector<std::string>& HLTConfigData::triggerNames() const {
00320 return triggerNames_;
00321 }
00322 const std::string& HLTConfigData::triggerName(unsigned int trigger) const {
00323 return triggerNames_.at(trigger);
00324 }
00325 unsigned int HLTConfigData::triggerIndex(const std::string& trigger) const {
00326 const std::map<std::string,unsigned int>::const_iterator index(triggerIndex_.find(trigger));
00327 if (index==triggerIndex_.end()) {
00328 return size();
00329 } else {
00330 return index->second;
00331 }
00332 }
00333
00334 const std::vector<std::string>& HLTConfigData::moduleLabels(unsigned int trigger) const {
00335 return moduleLabels_.at(trigger);
00336 }
00337 const std::vector<std::string>& HLTConfigData::moduleLabels(const std::string& trigger) const {
00338 return moduleLabels_.at(triggerIndex(trigger));
00339 }
00340
00341 const std::string& HLTConfigData::moduleLabel(unsigned int trigger, unsigned int module) const {
00342 return moduleLabels_.at(trigger).at(module);
00343 }
00344 const std::string& HLTConfigData::moduleLabel(const std::string& trigger, unsigned int module) const {
00345 return moduleLabels_.at(triggerIndex(trigger)).at(module);
00346 }
00347
00348 unsigned int HLTConfigData::moduleIndex(unsigned int trigger, const std::string& module) const {
00349 const std::map<std::string,unsigned int>::const_iterator index(moduleIndex_.at(trigger).find(module));
00350 if (index==moduleIndex_.at(trigger).end()) {
00351 return size(trigger);
00352 } else {
00353 return index->second;
00354 }
00355 }
00356 unsigned int HLTConfigData::moduleIndex(const std::string& trigger, const std::string& module) const {
00357 return moduleIndex(triggerIndex(trigger),module);
00358 }
00359
00360 const std::string HLTConfigData::moduleType(const std::string& module) const {
00361 if (modulePSet(module).existsAs<std::string>("@module_type",true)) {
00362 return modulePSet(module).getParameter<std::string>("@module_type");
00363 } else {
00364 return "";
00365 }
00366 }
00367
00368 const std::string HLTConfigData::moduleEDMType(const std::string& module) const {
00369 if (modulePSet(module).existsAs<std::string>("@module_edm_type",true)) {
00370 return modulePSet(module).getParameter<std::string>("@module_edm_type");
00371 } else {
00372 return "";
00373 }
00374 }
00375
00376 const edm::ParameterSet& HLTConfigData::processPSet() const {
00377 return *processPSet_;
00378 }
00379
00380 const edm::ParameterSet& HLTConfigData::modulePSet(const std::string& module) const {
00381 if (processPSet_->exists(module)) {
00382 return processPSet_->getParameterSet(module);
00383 } else {
00384 return *s_dummyPSet();
00385 }
00386 }
00387
00388 const std::vector<std::vector<std::pair<bool,std::string> > >& HLTConfigData::hltL1GTSeeds() const {
00389 return hltL1GTSeeds_;
00390 }
00391
00392 const std::vector<std::pair<bool,std::string> >& HLTConfigData::hltL1GTSeeds(const std::string& trigger) const {
00393 return hltL1GTSeeds(triggerIndex(trigger));
00394 }
00395
00396 const std::vector<std::pair<bool,std::string> >& HLTConfigData::hltL1GTSeeds(unsigned int trigger) const {
00397 return hltL1GTSeeds_.at(trigger);
00398 }
00399
00401 const std::vector<std::string>& HLTConfigData::streamNames() const {
00402 return streamNames_;
00403 }
00404
00405 const std::string& HLTConfigData::streamName(unsigned int stream) const {
00406 return streamNames_.at(stream);
00407 }
00408
00409 unsigned int HLTConfigData::streamIndex(const std::string& stream) const {
00410 const std::map<std::string,unsigned int>::const_iterator index(streamIndex_.find(stream));
00411 if (index==streamIndex_.end()) {
00412 return streamNames_.size();
00413 } else {
00414 return index->second;
00415 }
00416 }
00417
00418 const std::vector<std::vector<std::string> >& HLTConfigData::streamContents() const {
00419 return streamContents_;
00420 }
00421
00422 const std::vector<std::string>& HLTConfigData::streamContent(unsigned int stream) const {
00423 return streamContents_.at(stream);
00424 }
00425
00426 const std::vector<std::string>& HLTConfigData::streamContent(const std::string& stream) const {
00427 return streamContent(streamIndex(stream));
00428 }
00429
00431 const std::vector<std::string>& HLTConfigData::datasetNames() const {
00432 return datasetNames_;
00433 }
00434
00435 const std::string& HLTConfigData::datasetName(unsigned int dataset) const {
00436 return datasetNames_.at(dataset);
00437 }
00438
00439 unsigned int HLTConfigData::datasetIndex(const std::string& dataset) const {
00440 const std::map<std::string,unsigned int>::const_iterator index(datasetIndex_.find(dataset));
00441 if (index==datasetIndex_.end()) {
00442 return datasetNames_.size();
00443 } else {
00444 return index->second;
00445 }
00446 }
00447
00448 const std::vector<std::vector<std::string> >& HLTConfigData::datasetContents() const {
00449 return datasetContents_;
00450 }
00451
00452 const std::vector<std::string>& HLTConfigData::datasetContent(unsigned int dataset) const {
00453 return datasetContents_.at(dataset);
00454 }
00455
00456 const std::vector<std::string>& HLTConfigData::datasetContent(const std::string& dataset) const {
00457 return datasetContent(datasetIndex(dataset));
00458 }
00459
00460
00461 unsigned int HLTConfigData::prescaleSize() const {
00462 return hltPrescaleTable_.size();
00463 }
00464 unsigned int HLTConfigData::prescaleValue(unsigned int set, const std::string& trigger) const {
00465 return hltPrescaleTable_.prescale(set,trigger);
00466 }
00467
00468 const std::vector<std::string>& HLTConfigData::prescaleLabels() const {
00469 return hltPrescaleTable_.labels();
00470 }
00471 const std::map<std::string,std::vector<unsigned int> >& HLTConfigData::prescaleTable() const {
00472 return hltPrescaleTable_.table();
00473 }
00474
00475 edm::ParameterSetID HLTConfigData::id() const {
00476 return processPSet_->id();
00477 }