CP3-llbb Framework
HLTProducer.h
1 #ifndef HLT_PRODUCER
2 #define HLT_PRODUCER
3 
4 #include <cp3_llbb/Framework/interface/CandidatesProducer.h>
5 #include <cp3_llbb/Framework/interface/HLTService.h>
6 
7 #include <FWCore/Common/interface/TriggerNames.h>
8 #include <DataFormats/Common/interface/TriggerResults.h>
9 #include <DataFormats/PatCandidates/interface/PackedTriggerPrescales.h>
10 #include <DataFormats/PatCandidates/interface/TriggerObjectStandAlone.h>
11 
13  public:
14  HLTProducer(const std::string& name, const ROOT::TreeGroup& tree, const edm::ParameterSet& config):
15  Producer(name, tree, config)
16  {
17  if (config.exists("triggers")) {
18  m_hlt_service.reset(new HLTService(config.getUntrackedParameter<edm::FileInPath>("triggers").fullPath()));
19  std::cout << "HLT configuration: " << std::endl;
20  m_hlt_service->print();
21  std::cout << std::endl;
22  }
23  }
24 
25  virtual ~HLTProducer() {}
26 
27  virtual void doConsumes(const edm::ParameterSet& config, edm::ConsumesCollector&& collector) override {
28  m_hlt_token = collector.consumes<edm::TriggerResults>(config.getUntrackedParameter<edm::InputTag>("hlt", edm::InputTag("TriggerResults", "", "HLT")));
29  m_prescales_token = collector.consumes<pat::PackedTriggerPrescales>(config.getUntrackedParameter<edm::InputTag>("prescales", edm::InputTag("patTrigger")));
30  m_trigger_objects_token = collector.consumes<pat::TriggerObjectStandAloneCollection>(config.getUntrackedParameter<edm::InputTag>("objects", edm::InputTag("selectedPatTrigger")));
31  }
32 
33  virtual void produce(edm::Event& event, const edm::EventSetup& eventSetup) override;
34 
35  private:
36 
37  // Tokens
38  edm::EDGetTokenT<edm::TriggerResults> m_hlt_token;
39  edm::EDGetTokenT<pat::PackedTriggerPrescales> m_prescales_token;
40  edm::EDGetTokenT<pat::TriggerObjectStandAloneCollection> m_trigger_objects_token;
41 
42  // Service
43  std::shared_ptr<HLTService> m_hlt_service;
44 
45  public:
46  // Tree members
47  std::vector<std::string>& paths = tree["paths"].write<std::vector<std::string>>();
48  std::vector<uint16_t>& prescales = tree["prescales"].write<std::vector<uint16_t>>();
49 
50  BRANCH(object_paths, std::vector<std::vector<std::string>>);
51  TRANSIENT_BRANCH(object_filters, std::vector<std::vector<std::string>>);
52  BRANCH(object_p4, std::vector<LorentzVector>);
53  BRANCH(object_pdg_id, std::vector<int>);
54 };
55 
56 #endif
Base class for Framework producers.
Definition: Producer.h:33
ROOT::TreeGroup tree
Access point to output tree.
Definition: Producer.h:132
Producer(const std::string &name, const ROOT::TreeGroup &tree_, const edm::ParameterSet &config)
Base constructor.
Definition: Producer.h:46
Definition: HLTProducer.h:12
virtual void doConsumes(const edm::ParameterSet &config, edm::ConsumesCollector &&collector) override
Hook for the CMSSW consumes interface.
Definition: HLTProducer.h:27
virtual void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
Main method of the producer, called for each event.
Definition: HLTProducer.cc:4
Definition: HLTService.h:48