CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 &);
32 
33 
34 private:
35  virtual void beginJob() override;
36  virtual void analyze(edm::Event const &, edm::EventSetup const &) override;
37  virtual void endJob() override;
38 
39 private:
40  // output file
42 
43  // pointers to the objects that will be stored as branches within the tree
45 
46  // tree
47  TTree * tree_;
48 
49  // EDM input tokens
51 
52  // L1 uGT menu
53  unsigned long long cache_id_;
54 };
55 
56 
57 
59  results_(NULL), tree_(NULL),
60  ugt_token_( consumes<GlobalAlgBlkBxCollection>(config.getParameter<edm::InputTag>("ugtToken"))),
61  cache_id_( 0 )
62 {
63  // set up the TTree and its branches
64  tree_ = fs_->make<TTree>("L1uGTTree", "L1uGTTree");
65  tree_->Branch("L1uGT", "GlobalAlgBlk", & results_, 32000, 3);
66 }
67 
68 
70 {
71  if (tree_) { delete tree_; tree_ = NULL; }
72  //if (results_) { delete results_; results_ = NULL; } // It seems TTree owns this pointer...
73 }
74 
75 
76 //
77 // member functions
78 //
79 
80 // ------------ method called to for each event ------------
81 void
83 {
84  unsigned long long id = setup.get<L1TUtmTriggerMenuRcd>().cacheIdentifier();
85  if (id != cache_id_) {
86  cache_id_ = id;
88  setup.get<L1TUtmTriggerMenuRcd>().get(menu);
89 
90  for (auto const & keyval: menu->getAlgorithmMap()) {
91  std::string const & name = keyval.second.getName();
92  unsigned int index = keyval.second.getIndex();
93  //std::cerr << (boost::format("bit %4d: %s") % index % name).str() << std::endl;
94  tree_->SetAlias(name.c_str(), (boost::format("L1uGT.m_algoDecisionInitial[%d]") % index).str().c_str());
95  }
96  }
97 
99 
100  event.getByToken(ugt_token_, ugt);
101  results_ = & ugt->at(0, 0);
102  tree_->Fill();
103 }
104 
105 // ------------ method called once each job just before starting event loop ------------
106 void
108 {
109 }
110 
111 // ------------ method called once each job just after ending the event loop ------------
112 void
114 }
115 
116 //define this as a plug-in
virtual void analyze(edm::Event const &, edm::EventSetup const &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
#define NULL
Definition: scimark2.h:8
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
string format
Some error handling for the usage.
GlobalAlgBlk const * results_
L1uGTTreeProducer(edm::ParameterSet const &)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
virtual void beginJob() override
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > ugt_token_
unsigned long long cache_id_
const T & get() const
Definition: EventSetup.h:56
edm::Service< TFileService > fs_
virtual void endJob() override