CMS 3D CMS Logo

L1AXOTreeProducer.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 
4 // {fmt} headers
5 #include <fmt/printf.h>
6 
7 // ROOT
8 #include <TTree.h>
9 
10 // framework and data formats
23 
24 //
25 // class declaration
26 //
27 
28 class L1AXOTreeProducer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
29 public:
30  explicit L1AXOTreeProducer(edm::ParameterSet const &);
31  ~L1AXOTreeProducer() override = default;
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 
53  : anomaly_score(0.0f),
54  tree_(nullptr),
55  scoreToken_(consumes<AXOL1TLScoreBxCollection>(config.getUntrackedParameter<edm::InputTag>("axoscoreToken"))) {
56  usesResource(TFileService::kSharedResource);
57  // set up the TTree and its branches
58  tree_ = fs_->make<TTree>("L1AXOTree", "L1AXOTree");
59  tree_->Branch("axo_score", &anomaly_score, "axo_score/F");
60 }
61 
62 //
63 // member functions
64 //
65 
66 // ------------ method called to for each event ------------
68  //save axo score
70  event.getByToken(scoreToken_, axo);
71 
72  float const *ptr;
73 
74  if (axo.isValid()) {
75  ptr = &axo->at(0, 0).getAXOScore();
76  anomaly_score = *ptr;
77 
78  } else {
79  edm::LogWarning("MissingProduct") << "AXOL1TLScoreBxCollection not found. Branch will not be filled" << std::endl;
80  }
81 
82  tree_->Fill();
83 }
84 
85 // ------------ method called once each job just before starting event loop ------------
87 
88 // ------------ method called once each job just after ending the event loop ------------
90 
91 //define this as a plug-in
static const std::string kSharedResource
Definition: TFileService.h:76
void endJob() override
~L1AXOTreeProducer() override=default
edm::Service< TFileService > fs_
Definition: config.py:1
double f[11][100]
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
L1AXOTreeProducer(edm::ParameterSet const &)
const T & at(int bx, unsigned i) const
const edm::EDGetTokenT< AXOL1TLScoreBxCollection > scoreToken_
void analyze(edm::Event const &, edm::EventSetup const &) override
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
Log< level::Warning, false > LogWarning
void beginJob() override
Definition: event.py:1