10 #include <unordered_map> 99 particles_to_monitor_(iConfig.getParameter<
std::vector<
int> >(
"particles_to_monitor")),
100 simVertices_(consumes<
std::vector<
SimVertex>>(iConfig.getParameter<
edm::InputTag>(
"simVertices"))),
101 caloParticles_(consumes<
std::vector<
CaloParticle> >(iConfig.getParameter<
edm::InputTag>(
"caloParticles"))),
102 simPFClusters_(consumes<
std::vector<
reco::SuperCluster>>(iConfig.getParameter<
edm::InputTag>(
"simPFClusters"))),
139 const auto& rechitsEE = *recHitHandleEE;
140 const auto& rechitsFH = *recHitHandleFH;
141 const auto& rechitsBH = *recHitHandleBH;
142 std::map<DetId, const HGCRecHit*> hitmap;
143 for (
unsigned int i = 0;
i < rechitsEE.size(); ++
i) {
144 hitmap[rechitsEE[
i].detid()] = &rechitsEE[
i];
146 for (
unsigned int i = 0;
i < rechitsFH.size(); ++
i) {
147 hitmap[rechitsFH[
i].detid()] = &rechitsFH[
i];
149 for (
unsigned int i = 0;
i < rechitsBH.size(); ++
i) {
150 hitmap[rechitsBH[
i].detid()] = &rechitsBH[
i];
155 std::vector<SimVertex>
const & simVertices = *simVerticesHandle;
159 std::vector<CaloParticle>
const &
caloParticles = *caloParticleHandle;
163 std::vector<reco::SuperCluster>
const & simPFClusters = *simPFClustersHandle;
169 for (
auto const caloParticle : caloParticles) {
170 int id = caloParticle.pdgId();
171 if (histos.count(
id)) {
172 auto &
histo = histos.at(
id);
173 histo.eta_.fill(caloParticle.eta());
174 histo.pt_.fill(caloParticle.pt());
175 histo.energy_.fill(caloParticle.energy());
176 histo.nSimClusters_.fill(caloParticle.simClusters().size());
178 histo.eta_Zorigin_map_.fill(
179 simVertices.at(caloParticle.g4Tracks()[0].vertIndex()).
position().z(), caloParticle.eta());
182 for (
auto const sc : caloParticle.simClusters()) {
185 if (hitmap.count(h_and_f.first))
186 energy += hitmap[h_and_f.first]->energy() * h_and_f.second;
189 histo.nHitInSimClusters_.fill((
float)simHits);
190 histo.selfEnergy_.fill(energy);
191 histo.energyDifference_.fill(1.- energy/caloParticle.energy());
196 for (
auto const sc : simPFClusters) {
197 histos.at(0).simPFSuperClusterSize_.fill((
float)
sc.clustersSize());
198 histos.at(0).simPFSuperClusterEnergy_.fill(
sc.rawEnergy());
203 for (
auto const pfc : simPFCandidates) {
204 size_t type = offset + pfc.particleId();
205 histos.at(offset).pfcandidateType_.fill(type - offset);
206 auto &
histo = histos.at(type);
207 histo.pfcandidateEnergy_.fill(pfc.energy());
208 histo.pfcandidatePt_.fill(pfc.pt());
209 histo.pfcandidateEta_.fill(pfc.eta());
210 histo.pfcandidatePhi_.fill(pfc.phi());
211 histo.pfcandidateElementsInBlocks_.fill(pfc.elementsInBlocks().size());
224 auto &
histo = histos[particle];
225 histo.eta_ = ibook.
book1D(
"Eta",
"Eta", 80, -4., 4.);
226 histo.energy_ = ibook.
book1D(
"Energy",
"Energy", 250, 0., 500.);
227 histo.pt_ = ibook.
book1D(
"Pt",
"Pt", 100, 0., 100.);
228 histo.nSimClusters_ = ibook.
book1D(
"NSimClusters",
"NSimClusters", 100, 0., 100.);
229 histo.nHitInSimClusters_ = ibook.
book1D(
"NHitInSimClusters",
"NHitInSimClusters", 100, 0., 100.);
230 histo.selfEnergy_ = ibook.
book1D(
"SelfEnergy",
"SelfEnergy", 250, 0., 500.);
231 histo.energyDifference_ = ibook.
book1D(
"EnergyDifference",
"(Energy-SelfEnergy)/Energy", 300, -5., 1.);
232 histo.eta_Zorigin_map_ = ibook.
book2D(
"Eta vs Zorigin",
"Eta vs Zorigin", 80, -4., 4., 1100, -550., 550.);
236 histos[
offset].pfcandidateType_ = ibook.
book1D(
"PFCandidateType",
"PFCandidateType", 10, 0, 10);
240 histo.pfcandidateEnergy_ = ibook.
book1D(
"PFCandidateEnergy",
"PFCandidateEnergy", 250, 0., 250.);
241 histo.pfcandidatePt_ = ibook.
book1D(
"PFCandidatePt",
"PFCandidatePt", 250, 0., 250.);
242 histo.pfcandidateEta_ = ibook.
book1D(
"PFCandidateEta",
"PFCandidateEta", 100, -5., 5.);
243 histo.pfcandidatePhi_ = ibook.
book1D(
"PFCandidatePhi",
"PFCandidatePhi", 100, -4., 4.);
244 histo.pfcandidateElementsInBlocks_ = ibook.
book1D(
"PFCandidateElements",
"PFCandidateElements", 20, 0., 20.);
248 histos[0].simPFSuperClusterSize_ = ibook.
book1D(
"SimPFSuperClusterSize",
"SimPFSuperClusterSize", 40, 0., 40.);
249 histos[0].simPFSuperClusterEnergy_ = ibook.
book1D(
"SimPFSuperClusterEnergy",
"SimPFSuperClusterEnergy", 250, 0., 500.);
259 desc.
add<std::vector<int> > (
"particles_to_monitor", {11, -11, 13, 22, 111, 211, -211, 321, -321});
267 descriptions.
add(
"caloparticlevalidationDefault", desc);
std::unordered_map< int, Histogram_CaloParticleSingle > Histograms_CaloParticleValidation
ConcurrentMonitorElement simPFSuperClusterEnergy_
ConcurrentMonitorElement eta_Zorigin_map_
ConcurrentMonitorElement energyDifference_
edm::EDGetTokenT< HGCRecHitCollection > recHitsEE_
ConcurrentMonitorElement pfcandidatePhi_
ConcurrentMonitorElement pfcandidateElementsInBlocks_
CaloParticleValidation(const edm::ParameterSet &)
ConcurrentMonitorElement nHitInSimClusters_
std::vector< std::pair< uint32_t, float > > hits_and_fractions() const
Returns list of rechit IDs and fractions for this SimCluster.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
virtual example_global void dqmAnalyze(edm::Event const &,@example_global edm::EventSetup const &,@example_global Histograms___class__ const &) const override
edm::EDGetTokenT< std::vector< reco::SuperCluster > > simPFClusters_
~CaloParticleValidation() override
edm::EDGetTokenT< std::vector< SimVertex > > simVertices_
ConcurrentMonitorElement pfcandidateEta_
edm::EDGetTokenT< reco::PFCandidateCollection > simPFCandidates_
ConcurrentMonitorElement book2D(Args &&...args)
ConcurrentMonitorElement pfcandidateType_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual example_stream void bookHistograms(DQMStore::IBooker &,@example_stream edm::Run const &,@example_stream edm::EventSetup const &) override
ConcurrentMonitorElement book1D(Args &&...args)
ConcurrentMonitorElement pt_
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, Histograms_CaloParticleValidation const &) const override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< std::vector< CaloParticle > > caloParticles_
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
void setCurrentFolder(const std::string &fullpath)
edm::EDGetTokenT< HGCRecHitCollection > recHitsFH_
ConcurrentMonitorElement pfcandidateEnergy_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ConcurrentMonitorElement simPFSuperClusterSize_
static int position[264][3]
ConcurrentMonitorElement nSimClusters_
ConcurrentMonitorElement pfcandidatePt_
void bookHistograms(DQMStore::ConcurrentBooker &, edm::Run const &, edm::EventSetup const &, Histograms_CaloParticleValidation &) const override
ConcurrentMonitorElement energy_
std::vector< int > particles_to_monitor_
ConcurrentMonitorElement selfEnergy_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ConcurrentMonitorElement eta_
edm::EDGetTokenT< HGCRecHitCollection > recHitsBH_