Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:46:42

0001 // -*- C++ -*-
0002 //
0003 // Package:     FWCore/Common
0004 // Class  :     LuminosityBlockBase
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Eric Vaandering
0010 //         Created:  Tue Jan 12 15:31:00 CDT 2010
0011 //
0012 
0013 // system include files
0014 #include <vector>
0015 #include <map>
0016 
0017 // user include files
0018 #include "FWCore/Common/interface/LuminosityBlockBase.h"
0019 //#include "FWCore/Common/interface/TriggerNames.h"
0020 //#include "DataFormats/Provenance/interface/ParameterSetID.h"
0021 //#include "DataFormats/Common/interface/TriggerResults.h"
0022 //#include "FWCore/Utilities/interface/Exception.h"
0023 //#include "FWCore/Utilities/interface/ThreadSafeRegistry.h"
0024 //#include "FWCore/ParameterSet/interface/ParameterSet.h"
0025 //#include "FWCore/ParameterSet/interface/Registry.h"
0026 
0027 namespace edm {
0028   //    typedef std::map<edm::ParameterSetID, edm::TriggerNames> TriggerNamesMap;
0029   //    static TriggerNamesMap triggerNamesMap;
0030   //    static TriggerNamesMap::const_iterator previousTriggerName;
0031 
0032   LuminosityBlockBase::LuminosityBlockBase() {}
0033 
0034   LuminosityBlockBase::~LuminosityBlockBase() {}
0035 
0036   /*   TriggerNames const*
0037    EventBase::triggerNames_(edm::TriggerResults const& triggerResults) {
0038 
0039       // If the current and previous requests are for the same TriggerNames
0040       // then just return it.
0041       if (!triggerNamesMap.empty() &&
0042           previousTriggerName->first == triggerResults.parameterSetID()) {
0043          return &previousTriggerName->second;
0044       }
0045 
0046       // If TriggerNames was already created and cached here in the map,
0047       // then look it up and return that one
0048       TriggerNamesMap::const_iterator iter =
0049          triggerNamesMap.find(triggerResults.parameterSetID());
0050       if (iter != triggerNamesMap.end()) {
0051          previousTriggerName = iter;
0052          return &iter->second;
0053       }
0054 
0055       // Look for the parameter set containing the trigger names in the parameter
0056       // set registry using the ID from TriggerResults as the key used to find it.
0057       edm::ParameterSet pset;
0058       edm::pset::Registry* psetRegistry = edm::pset::Registry::instance();
0059       if (psetRegistry->getMapped(triggerResults.parameterSetID(),
0060                                   pset)) {
0061 
0062          if (pset.existsAs<std::vector<std::string> >("@trigger_paths", true)) {
0063             TriggerNames triggerNames(pset);
0064 
0065             // This should never happen
0066             if (triggerNames.size() != triggerResults.size()) {
0067                throw cms::Exception("LogicError")
0068                   << "edm::EventBase::triggerNames_ Encountered vector\n"
0069                      "of trigger names and a TriggerResults object with\n"
0070                      "different sizes.  This should be impossible.\n"
0071                      "Please send information to reproduce this problem to\n"
0072                      "the edm developers.\n";
0073             }
0074 
0075             std::pair<TriggerNamesMap::iterator, bool> ret =
0076                triggerNamesMap.insert(std::pair<edm::ParameterSetID, edm::TriggerNames>(triggerResults.parameterSetID(), triggerNames));
0077             previousTriggerName = ret.first;
0078             return &(ret.first->second);
0079          }
0080       }
0081       // For backward compatibility to very old data
0082       if (triggerResults.getTriggerNames().size() > 0U) {
0083          edm::ParameterSet fakePset;
0084          fakePset.addParameter<std::vector<std::string> >("@trigger_paths", triggerResults.getTriggerNames());
0085          fakePset.registerIt();
0086          TriggerNames triggerNames(fakePset);
0087 
0088          // This should never happen
0089          if (triggerNames.size() != triggerResults.size()) {
0090             throw cms::Exception("LogicError")
0091                << "edm::EventBase::triggerNames_ Encountered vector\n"
0092                   "of trigger names and a TriggerResults object with\n"
0093                   "different sizes.  This should be impossible.\n"
0094                   "Please send information to reproduce this problem to\n"
0095                   "the edm developers (2).\n";
0096          }
0097 
0098          std::pair<TriggerNamesMap::iterator, bool> ret =
0099             triggerNamesMap.insert(std::pair<edm::ParameterSetID, edm::TriggerNames>(fakePset.id(), triggerNames));
0100          previousTriggerName = ret.first;
0101          return &(ret.first->second);
0102       }
0103       return 0;
0104    }*/
0105 }  // namespace edm