CMS 3D CMS Logo

L1uGTTreeProducer.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 #include <boost/format.hpp>
4 
5 // framework
13 
14 // data formats
18 
19 // ROOT output stuff
22 #include "TTree.h"
23 
24 //
25 // class declaration
26 //
27 
29 public:
30  explicit L1uGTTreeProducer(edm::ParameterSet const &);
31  ~L1uGTTreeProducer() override;
32 
33 private:
34  void beginJob() override;
35  void analyze(edm::Event const &, edm::EventSetup const &) override;
36  void endJob() override;
37 
38 private:
39  // output file
41 
42  // pointers to the objects that will be stored as branches within the tree
44 
45  // tree
46  TTree *tree_;
47 
48  // EDM input tokens
50 
51  // L1 uGT menu
52  unsigned long long cache_id_;
53 };
54 
56  : results_(nullptr),
57  tree_(nullptr),
58  ugt_token_(consumes<GlobalAlgBlkBxCollection>(config.getParameter<edm::InputTag>("ugtToken"))),
59  cache_id_(0) {
60  // set up the TTree and its branches
61  tree_ = fs_->make<TTree>("L1uGTTree", "L1uGTTree");
62  tree_->Branch("L1uGT", "GlobalAlgBlk", &results_, 32000, 3);
63 }
64 
66  //if (tree_) { delete tree_; tree_ = NULL; }
67  //if (results_) { delete results_; results_ = NULL; } // It seems TTree owns this pointer...
68 }
69 
70 //
71 // member functions
72 //
73 
74 // ------------ method called to for each event ------------
76  unsigned long long id = setup.get<L1TUtmTriggerMenuRcd>().cacheIdentifier();
77  if (id != cache_id_) {
78  cache_id_ = id;
81 
82  for (auto const &keyval : menu->getAlgorithmMap()) {
83  std::string const &name = keyval.second.getName();
84  unsigned int index = keyval.second.getIndex();
85  //std::cerr << (boost::format("bit %4d: %s") % index % name).str() << std::endl;
86  tree_->SetAlias(name.c_str(), (boost::format("L1uGT.m_algoDecisionInitial[%d]") % index).str().c_str());
87  }
88  }
89 
91 
92  event.getByToken(ugt_token_, ugt);
93 
94  if (ugt.isValid()) {
95  results_ = &ugt->at(0, 0);
96  }
97 
98  tree_->Fill();
99 }
100 
101 // ------------ method called once each job just before starting event loop ------------
103 
104 // ------------ method called once each job just after ending the event loop ------------
106 
107 //define this as a plug-in
L1uGTTreeProducer
Definition: L1uGTTreeProducer.cc:28
L1TUtmTriggerMenuRcd.h
MessageLogger.h
ESHandle.h
L1TUtmTriggerMenuRcd
Definition: L1TUtmTriggerMenuRcd.h:11
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
EDAnalyzer.h
edm::Handle
Definition: AssociativeIterator.h:50
L1uGTTreeProducer::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: L1uGTTreeProducer.cc:75
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
BXVector
Definition: BXVector.h:15
config
Definition: config.py:1
MakerMacros.h
L1uGTTreeProducer::results_
const GlobalAlgBlk * results_
Definition: L1uGTTreeProducer.cc:43
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
L1uGTTreeProducer::~L1uGTTreeProducer
~L1uGTTreeProducer() override
Definition: L1uGTTreeProducer.cc:65
Service.h
dqm-mbProfile.format
format
Definition: dqm-mbProfile.py:16
str
#define str(s)
Definition: TestProcessor.cc:48
edm::ESHandle
Definition: DTSurvey.h:22
L1uGTTreeProducer::ugt_token_
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > ugt_token_
Definition: L1uGTTreeProducer.cc:49
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TFileService.h
L1uGTTreeProducer::L1uGTTreeProducer
L1uGTTreeProducer(edm::ParameterSet const &)
Definition: L1uGTTreeProducer.cc:55
L1TUtmTriggerMenu.h
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
optionsL1T.menu
menu
Definition: optionsL1T.py:29
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
BXVector::at
const T & at(int bx, unsigned i) const
edm::Service< TFileService >
GlobalAlgBlk.h
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
L1uGTTreeProducer::cache_id_
unsigned long long cache_id_
Definition: L1uGTTreeProducer.cc:52
L1uGTTreeProducer::beginJob
void beginJob() override
Definition: L1uGTTreeProducer.cc:102
L1uGTTreeProducer::fs_
edm::Service< TFileService > fs_
Definition: L1uGTTreeProducer.cc:40
Frameworkfwd.h
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
L1uGTTreeProducer::endJob
void endJob() override
Definition: L1uGTTreeProducer.cc:105
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
ParameterSet.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
GlobalAlgBlk
Definition: GlobalAlgBlk.h:41
edm::Event
Definition: Event.h:73
L1uGTTreeProducer::tree_
TTree * tree_
Definition: L1uGTTreeProducer.cc:46
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64