CMS 3D CMS Logo

TriggerNamesService.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Implementation:
00004 //
00005 // Original Author:  Jim Kowalkowski
00006 // $Id: TriggerNamesService.cc,v 1.12 2007/11/07 08:04:55 wmtan Exp $
00007 //
00008 
00009 #include "FWCore/Framework/interface/TriggerNamesService.h"
00010 #include "DataFormats/Common/interface/TriggerResults.h"
00011 #include "FWCore/ParameterSet/interface/Registry.h"
00012 #include "FWCore/Utilities/interface/ThreadSafeRegistry.h"
00013 #include "FWCore/Utilities/interface/Exception.h"
00014 #include "FWCore/Utilities/interface/Algorithms.h"
00015 
00016 
00017 namespace edm {
00018   namespace service {
00019 
00020     TriggerNamesService::TriggerNamesService(const ParameterSet& pset) {
00021 
00022       trigger_pset_ = 
00023         pset.getUntrackedParameter<ParameterSet>("@trigger_paths");
00024 
00025       trignames_ = trigger_pset_.getParameter<Strings>("@trigger_paths");
00026       end_names_ = pset.getParameter<Strings>("@end_paths");
00027 
00028       ParameterSet defopts;
00029       ParameterSet opts = 
00030         pset.getUntrackedParameter<ParameterSet>("options", defopts);
00031       wantSummary_ =
00032         opts.getUntrackedParameter("wantSummary",false);
00033 
00034       process_name_ = pset.getParameter<std::string>("@process_name");
00035 
00036       loadPosMap(trigpos_,trignames_);
00037       loadPosMap(end_pos_,end_names_);
00038 
00039       const unsigned int n(trignames_.size());
00040       for(unsigned int i=0;i!=n;++i) {
00041         modulenames_.push_back(pset.getParameter<Strings>(trignames_[i]));
00042       }
00043     }
00044 
00045     bool
00046     TriggerNamesService::getTrigPaths(TriggerResults const& triggerResults,
00047                                       Strings& trigPaths,
00048                                       bool& fromPSetRegistry) {
00049 
00050       // Get the parameter set containing the trigger names from the parameter set registry
00051       // using the ID from TriggerResults as the key used to find it.
00052       ParameterSet pset;
00053       pset::Registry* psetRegistry = pset::Registry::instance();
00054       if (psetRegistry->getMapped(triggerResults.parameterSetID(),
00055                                   pset)) {
00056 
00057         // Check to make sure the parameter set contains
00058         // a Strings parameter named "trigger_paths".
00059         // We do not want to throw an exception if it is not there
00060         // for reasons of backward compatibility
00061         Strings psetNames = pset.getParameterNamesForType<Strings>();
00062         std::string name("@trigger_paths");
00063         if (search_all(psetNames, name)) {
00064           // It is there, get it
00065           trigPaths = pset.getParameter<Strings>("@trigger_paths");
00066 
00067           // This should never happen
00068           if (trigPaths.size() != triggerResults.size()) {
00069             throw edm::Exception(edm::errors::Unknown)
00070               << "TriggerNamesService::getTrigPaths, Trigger names vector and\n"
00071                  "TriggerResults are different sizes.  This should be impossible,\n"
00072                  "please send information to reproduce this problem to\n"
00073                  "the edm developers.\n";
00074           }
00075 
00076           fromPSetRegistry = true;
00077           return true;
00078         }
00079       }
00080 
00081       fromPSetRegistry = false;
00082 
00083       // In older versions of the code the the trigger names were stored
00084       // inside of the TriggerResults object.  This will provide backward
00085       // compatibility.
00086       if (triggerResults.size() == triggerResults.getTriggerNames().size()) {
00087         trigPaths = triggerResults.getTriggerNames();
00088         return true;
00089       }
00090 
00091       return false;
00092     }
00093 
00094     bool
00095     TriggerNamesService::getTrigPaths(TriggerResults const& triggerResults,
00096                                       Strings& trigPaths) {
00097       bool dummy;
00098       return getTrigPaths(triggerResults, trigPaths, dummy);
00099     }
00100   }
00101 }

Generated on Tue Jun 9 17:36:12 2009 for CMSSW by  doxygen 1.5.4