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::impl::MonitorElement
Definition: MonitorElement.h:98
zmumugammaAnalyzer_cfi.pfCandidates
pfCandidates
Definition: zmumugammaAnalyzer_cfi.py:11
PFCandidate.h
Histogram_TICLPFValidation::eta_
dqm::reco::MonitorElement * eta_
Definition: TICLPFValidation.cc:24
TICLPFValidation::folder_
std::string folder_
Definition: TICLPFValidation.cc:48
edm::Run
Definition: Run.h:45
edm::EDGetTokenT< reco::PFCandidateCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
TICLPFValidation::pfCandidates_
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidates_
Definition: TICLPFValidation.cc:49
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:85964
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
TICLPFValidation::TICLPFValidation
TICLPFValidation(const edm::ParameterSet &)
Definition: TICLPFValidation.cc:63
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
Histogram_TICLPFValidation::energy_
dqm::reco::MonitorElement * energy_
Definition: TICLPFValidation.cc:22
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
TICLPFValidation
Definition: TICLPFValidation.cc:32
Histogram_TICLPFValidation::pt_
dqm::reco::MonitorElement * pt_
Definition: TICLPFValidation.cc:23
reco::PFCandidate::X
Definition: PFCandidate.h:45
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
TICLPFValidation::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: TICLPFValidation.cc:127
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TICLPFValidation::~TICLPFValidation
~TICLPFValidation() override
Definition: TICLPFValidation.cc:69
folder_
std::string folder_
Definition: DQMEDAnalyzer.cc:60
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
Histograms_TICLPFValidation
std::unordered_map< int, Histogram_TICLPFValidation > Histograms_TICLPFValidation
Definition: TICLPFValidation.cc:30
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:39
reco::PFCandidate::egamma_HF
Definition: PFCandidate.h:52
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
l1t::PFCandidateCollection
std::vector< l1t::PFCandidate > PFCandidateCollection
Definition: PFCandidate.h:57
combine.histos
histos
Definition: combine.py:4
TICLPFValidation::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, Histograms_TICLPFValidation &) const override
Definition: TICLPFValidation.cc:108
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
Histogram_TICLPFValidation::vect_sum_pt_
dqm::reco::MonitorElement * vect_sum_pt_
Definition: TICLPFValidation.cc:27
Frameworkfwd.h
Histogram_TICLPFValidation::type_
dqm::reco::MonitorElement * type_
Definition: TICLPFValidation.cc:21
reco::PFCandidateCollection
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
Definition: PFCandidateFwd.h:12
dqm::implementation::IBooker
Definition: DQMStore.h:43
DQMGlobalEDAnalyzer
Definition: DQMGlobalEDAnalyzer.h:76
ParameterSet.h
TICLPFValidation::dqmAnalyze
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, Histograms_TICLPFValidation const &) const override
Definition: TICLPFValidation.cc:80
edm::Event
Definition: Event.h:73
Histogram_TICLPFValidation::phi_
dqm::reco::MonitorElement * phi_
Definition: TICLPFValidation.cc:25
edm::InputTag
Definition: InputTag.h:15
Histogram_TICLPFValidation
Definition: TICLPFValidation.cc:20
PFCandidateFwd.h
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
DQMGlobalEDAnalyzer.h
Histogram_TICLPFValidation::charge_
dqm::reco::MonitorElement * charge_
Definition: TICLPFValidation.cc:26