Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:58:03

0001 #ifndef PhysicsTools_NanoAOD_TriggerOutputFields_h
0002 #define PhysicsTools_NanoAOD_TriggerOutputFields_h
0003 
0004 #include "RNTupleFieldPtr.h"
0005 
0006 #include "FWCore/Utilities/interface/EDGetToken.h"
0007 
0008 namespace edm {
0009   class EventForOutput;
0010   class TriggerResults;
0011 }  // namespace edm
0012 
0013 class TriggerFieldPtr {
0014 public:
0015   TriggerFieldPtr() = default;
0016   TriggerFieldPtr(std::string name, int index, std::string fieldName, std::string fieldDesc, RNTupleModel& model);
0017   void fill(const edm::TriggerResults& triggers);
0018   const std::string& getTriggerName() const { return m_triggerName; }
0019   void setIndex(int newIndex) { m_triggerIndex = newIndex; }
0020 
0021 private:
0022   RNTupleFieldPtr<bool> m_field;
0023   // The trigger results name extracted from the TriggerResults with version suffixes trimmed
0024   std::string m_triggerName;
0025   int m_triggerIndex = -1;
0026 };
0027 
0028 class TriggerOutputFields {
0029 public:
0030   TriggerOutputFields() = default;
0031   explicit TriggerOutputFields(const std::string& processName, const edm::EDGetToken& token)
0032       : m_token(token), m_lastRun(-1), m_processName(processName) {}
0033   void createFields(const edm::EventForOutput& event, RNTupleModel& model);
0034   void fill(const edm::EventForOutput& event);
0035 
0036 private:
0037   static std::vector<std::string> getTriggerNames(const edm::TriggerResults& triggerResults);
0038   // Update trigger field information on run boundaries
0039   void updateTriggerFields(const edm::TriggerResults& triggerResults);
0040   void makeUniqueFieldName(/*const*/ RNTupleModel& model, std::string& name);
0041 
0042   edm::EDGetToken m_token;
0043   long m_lastRun;
0044   std::string m_processName;
0045   std::vector<TriggerFieldPtr> m_triggerFields;
0046 };
0047 
0048 #endif