CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HGCalTriggerNtupleManager.cc
Go to the documentation of this file.
10 
12 
16 
18 public:
19  typedef std::unique_ptr<HGCalTriggerNtupleBase> ntuple_ptr;
20 
21 public:
22  explicit HGCalTriggerNtupleManager(const edm::ParameterSet& conf);
24  void beginRun(const edm::Run&, const edm::EventSetup&) override;
25  void analyze(const edm::Event&, const edm::EventSetup&) override;
26 
27 private:
29  std::vector<ntuple_ptr> hgc_ntuples_;
30  TTree* tree_;
31 
36 };
37 
39 
41  : pdtToken_(esConsumes<HepPDT::ParticleDataTable, PDTRecord, edm::Transition::BeginRun>()),
42  magfieldToken_(esConsumes<MagneticField, IdealMagneticFieldRecord, edm::Transition::BeginRun>()),
43  triggerGeomToken_(esConsumes<HGCalTriggerGeometryBase, CaloGeometryRecord, edm::Transition::BeginRun>()) {
44  tree_ = file_service_->make<TTree>("HGCalTriggerNtuple", "HGCalTriggerNtuple");
45  const std::vector<edm::ParameterSet>& ntuple_cfgs = conf.getParameterSetVector("Ntuples");
46  for (const auto& ntuple_cfg : ntuple_cfgs) {
47  const std::string& ntuple_name = ntuple_cfg.getParameter<std::string>("NtupleName");
48  hgc_ntuples_.emplace_back(HGCalTriggerNtupleFactory::get()->create(ntuple_name, ntuple_cfg));
49  hgc_ntuples_.back()->initialize(*tree_, ntuple_cfg, consumesCollector());
50  }
51 }
52 
57 }
58 
60  for (auto& hgc_ntuple : hgc_ntuples_) {
61  if (hgc_ntuple->accessEventSetup()) {
62  hgc_ntuple->fill(e, es);
63  } else {
64  hgc_ntuple->fill(e, ntuple_es_);
65  }
66  }
67 
68  tree_->Fill();
69 }
edm::ESGetToken< HGCalTriggerGeometryBase, CaloGeometryRecord > triggerGeomToken_
HGCalTriggerNtupleEventSetup ntuple_es_
VParameterSet const & getParameterSetVector(std::string const &name) const
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magfieldToken_
edm::ESHandle< MagneticField > magfield
HepPDT::ParticleDataTable ParticleDataTable
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
edm::ESHandle< HGCalTriggerGeometryBase > geometry
edm::Service< TFileService > file_service_
void beginRun(const edm::Run &, const edm::EventSetup &) override
std::unique_ptr< HGCalTriggerNtupleBase > ntuple_ptr
edm::ESGetToken< HepPDT::ParticleDataTable, PDTRecord > pdtToken_
void analyze(const edm::Event &, const edm::EventSetup &) override
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::ESHandle< HepPDT::ParticleDataTable > pdt
Transition
Definition: Transition.h:12
HGCalTriggerNtupleManager(const edm::ParameterSet &conf)
#define get
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
std::vector< ntuple_ptr > hgc_ntuples_
Definition: Run.h:45