CMS 3D CMS Logo

TICLPFValidation.cc
Go to the documentation of this file.
1 #include <string>
2 #include <unordered_map>
3 
4 // user include files
7 
10 
12 
15 
16 //
17 // class declaration
18 //
19 
27  dqm::reco::MonitorElement* vect_sum_pt_; // cumulative histogram
28 };
29 
30 using Histograms_TICLPFValidation = std::unordered_map<int, Histogram_TICLPFValidation>;
31 
32 class TICLPFValidation : public DQMGlobalEDAnalyzer<Histograms_TICLPFValidation> {
33 public:
34  explicit TICLPFValidation(const edm::ParameterSet&);
35  ~TICLPFValidation() override;
36 
37  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
38 
39 private:
41  edm::Run const&,
42  edm::EventSetup const&,
43  Histograms_TICLPFValidation&) const override;
44 
45  void dqmAnalyze(edm::Event const&, edm::EventSetup const&, Histograms_TICLPFValidation const&) const override;
46 
47  // ----------member data ---------------------------
50 };
51 
52 //
53 // constants, enums and typedefs
54 //
55 
56 //
57 // static data member definitions
58 //
59 
60 //
61 // constructors and destructor
62 //
64  : folder_(iConfig.getParameter<std::string>("folder")),
65  pfCandidates_(consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("ticlPFCandidates"))) {
66  //now do what ever initialization is needed
67 }
68 
70  // do anything here that needs to be done at desctruction time
71  // (e.g. close files, deallocate resources etc.)
72 }
73 
74 //
75 // member functions
76 //
77 
78 // ------------ method called for each event ------------
79 
81  edm::EventSetup const& iSetup,
82  Histograms_TICLPFValidation const& histos) const {
83  using namespace edm;
84 
85  Handle<reco::PFCandidateCollection> pfCandidatesHandle;
86  iEvent.getByToken(pfCandidates_, pfCandidatesHandle);
87  reco::PFCandidateCollection const& pfCandidates = *pfCandidatesHandle;
88 
89  // pfCandidates
90  double ptx_tot = 0.;
91  double pty_tot = 0.;
92  for (auto const& pfc : pfCandidates) {
93  size_t type = pfc.particleId();
94  ptx_tot += pfc.px();
95  pty_tot += pfc.py();
96  histos.at(0).type_->Fill(type);
97  auto& histo = histos.at(type);
98  histo.energy_->Fill(pfc.energy());
99  histo.pt_->Fill(pfc.pt());
100  histo.eta_->Fill(pfc.eta());
101  histo.phi_->Fill(pfc.phi());
102  histo.charge_->Fill(pfc.charge());
103  }
104  auto& histo = histos.at(0);
105  histo.vect_sum_pt_->Fill(std::sqrt(ptx_tot * ptx_tot + pty_tot * pty_tot));
106 }
107 
109  edm::Run const& run,
110  edm::EventSetup const& iSetup,
112  ibook.setCurrentFolder(folder_ + "TICLPFCandidates/");
113  histos[0].type_ = ibook.book1D("Type", "Type", 10, -0.5, 9.5);
114  histos[0].vect_sum_pt_ = ibook.book1D("PtVectSum", "PtVectSum", 200, 0., 200.);
116  ibook.setCurrentFolder(folder_ + "TICLPFCandidates/" + std::to_string(type));
117  auto& histo = histos[type];
118  histo.energy_ = ibook.book1D("Energy", "Energy", 250, 0., 250.);
119  histo.pt_ = ibook.book1D("Pt", "Pt", 250, 0., 250.);
120  histo.eta_ = ibook.book1D("Eta", "Eta", 100, -5., 5.);
121  histo.phi_ = ibook.book1D("Phi", "Phi", 100, -4., 4.);
122  histo.charge_ = ibook.book1D("Charge", "Charge", 3, -1.5, 1.5);
123  }
124 }
125 
126 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
128  //The following says we do not know what parameters are allowed so do no validation
129  // Please change this to state exactly what you do use, even if it is no parameters
131  desc.add<std::string>("folder", "HGCAL/"); // Please keep the trailing '/'
132  desc.add<edm::InputTag>("ticlPFCandidates", edm::InputTag("pfTICL"));
133  descriptions.add("ticlPFValidationDefault", desc);
134 }
135 
136 //define this as a plug-in
dqm::reco::MonitorElement * type_
dqm::reco::MonitorElement * energy_
std::string folder_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, Histograms_TICLPFValidation const &) const override
std::vector< l1t::PFCandidate > PFCandidateCollection
Definition: PFCandidate.h:82
std::string to_string(const V &value)
Definition: OMSAccess.h:71
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, Histograms_TICLPFValidation &) const override
int iEvent
Definition: GenABIO.cc:224
T sqrt(T t)
Definition: SSEVec.h:19
dqm::reco::MonitorElement * eta_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::unordered_map< int, Histogram_TICLPFValidation > Histograms_TICLPFValidation
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidates_
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
dqm::reco::MonitorElement * charge_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
~TICLPFValidation() override
histos
Definition: combine.py:4
fixed size matrix
HLT enums.
dqm::reco::MonitorElement * vect_sum_pt_
TICLPFValidation(const edm::ParameterSet &)
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
dqm::reco::MonitorElement * phi_
dqm::reco::MonitorElement * pt_
Definition: Run.h:45