CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
CaloParticleValidation Class Reference
Inheritance diagram for CaloParticleValidation:
DQMGlobalEDAnalyzer< Histograms_CaloParticleValidation > edm::global::EDAnalyzer< edm::RunCache< Histograms_CaloParticleValidation >, Args... > edm::global::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 CaloParticleValidation (const edm::ParameterSet &)
 
 ~CaloParticleValidation () override
 
- Public Member Functions inherited from edm::global::EDAnalyzer< edm::RunCache< Histograms_CaloParticleValidation >, Args... >
 EDAnalyzer ()=default
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, Histograms_CaloParticleValidation &) const override
 
void dqmAnalyze (edm::Event const &, edm::EventSetup const &, Histograms_CaloParticleValidation const &) const override
 

Private Attributes

edm::EDGetTokenT< std::vector< CaloParticle > > caloParticles_
 
std::string folder_
 
std::vector< int > particles_to_monitor_
 
edm::EDGetTokenT< HGCRecHitCollectionrecHitsBH_
 
edm::EDGetTokenT< HGCRecHitCollectionrecHitsEE_
 
edm::EDGetTokenT< HGCRecHitCollectionrecHitsFH_
 
edm::EDGetTokenT< reco::PFCandidateCollectionsimPFCandidates_
 
edm::EDGetTokenT< std::vector< reco::SuperCluster > > simPFClusters_
 
edm::EDGetTokenT< std::vector< SimVertex > > simVertices_
 

Additional Inherited Members

- Public Types inherited from DQMGlobalEDAnalyzer< Histograms_CaloParticleValidation >
typedef dqm::reco::DQMStore DQMStore
 
typedef dqm::reco::MonitorElement MonitorElement
 
- Public Types inherited from edm::global::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 56 of file CaloParticleValidation.cc.

Constructor & Destructor Documentation

CaloParticleValidation::CaloParticleValidation ( const edm::ParameterSet iConfig)
explicit

Definition at line 95 of file CaloParticleValidation.cc.

96  : folder_(iConfig.getParameter<std::string>("folder")),
97  particles_to_monitor_(iConfig.getParameter<std::vector<int>>("particles_to_monitor")),
98  simVertices_(consumes<std::vector<SimVertex>>(iConfig.getParameter<edm::InputTag>("simVertices"))),
99  caloParticles_(consumes<std::vector<CaloParticle>>(iConfig.getParameter<edm::InputTag>("caloParticles"))),
100  simPFClusters_(consumes<std::vector<reco::SuperCluster>>(iConfig.getParameter<edm::InputTag>("simPFClusters"))),
101  simPFCandidates_(consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("simPFCandidates"))),
102  recHitsEE_(consumes<HGCRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsEE"))),
103  recHitsFH_(consumes<HGCRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsFH"))),
104  recHitsBH_(consumes<HGCRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsBH"))) {
105  //now do what ever initialization is needed
106 }
T getParameter(std::string const &) const
edm::EDGetTokenT< HGCRecHitCollection > recHitsEE_
edm::EDGetTokenT< std::vector< reco::SuperCluster > > simPFClusters_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< std::vector< SimVertex > > simVertices_
edm::EDGetTokenT< reco::PFCandidateCollection > simPFCandidates_
edm::EDGetTokenT< std::vector< CaloParticle > > caloParticles_
edm::EDGetTokenT< HGCRecHitCollection > recHitsFH_
std::vector< int > particles_to_monitor_
edm::EDGetTokenT< HGCRecHitCollection > recHitsBH_
CaloParticleValidation::~CaloParticleValidation ( )
override

Definition at line 108 of file CaloParticleValidation.cc.

108  {
109  // do anything here that needs to be done at desctruction time
110  // (e.g. close files, deallocate resources etc.)
111 }

Member Function Documentation

void CaloParticleValidation::bookHistograms ( DQMStore::IBooker ibook,
edm::Run const &  run,
edm::EventSetup const &  iSetup,
Histograms_CaloParticleValidation histos 
) const
overrideprivatevirtual

Implements DQMGlobalEDAnalyzer< Histograms_CaloParticleValidation >.

Definition at line 222 of file CaloParticleValidation.cc.

References dqm::dqmstoreimpl::DQMStore::IBooker::book1D(), dqm::dqmstoreimpl::DQMStore::IBooker::book2D(), reco::PFCandidate::egamma_HF, folder_, reco::PFCandidate::h, timingPdfMaker::histo, hltrates_dqm_sourceclient-live_cfg::offset, particles_to_monitor_, and dqm::dqmstoreimpl::DQMStore::IBooker::setCurrentFolder().

225  {
226  for (auto const particle : particles_to_monitor_) {
227  ibook.setCurrentFolder(folder_ + "CaloParticles/" + std::to_string(particle));
228  auto& histo = histos[particle];
229  histo.eta_ = ibook.book1D("Eta", "Eta", 80, -4., 4.);
230  histo.energy_ = ibook.book1D("Energy", "Energy", 250, 0., 500.);
231  histo.pt_ = ibook.book1D("Pt", "Pt", 100, 0., 100.);
232  histo.nSimClusters_ = ibook.book1D("NSimClusters", "NSimClusters", 100, 0., 100.);
233  histo.nHitInSimClusters_ = ibook.book1D("NHitInSimClusters", "NHitInSimClusters", 100, 0., 100.);
234  histo.selfEnergy_ = ibook.book1D("SelfEnergy", "SelfEnergy", 250, 0., 500.);
235  histo.energyDifference_ = ibook.book1D("EnergyDifference", "(Energy-SelfEnergy)/Energy", 300, -5., 1.);
236  histo.eta_Zorigin_map_ = ibook.book2D("Eta vs Zorigin", "Eta vs Zorigin", 80, -4., 4., 1100, -550., 550.);
237  }
238  int offset = 100000;
239  ibook.setCurrentFolder(folder_ + "PFCandidates");
240  histos[offset].pfcandidateType_ = ibook.book1D("PFCandidateType", "PFCandidateType", 10, 0, 10);
241  histos[offset].pfcandidate_vect_sum_pt_ = ibook.book1D("PFCandidatePtVectSum", "PFCandidatePtVectSum", 200, 0., 200.);
243  ibook.setCurrentFolder(folder_ + "PFCandidates/" + std::to_string(type));
244  auto& histo = histos[offset + type];
245  histo.pfcandidateEnergy_ = ibook.book1D("PFCandidateEnergy", "PFCandidateEnergy", 250, 0., 250.);
246  histo.pfcandidatePt_ = ibook.book1D("PFCandidatePt", "PFCandidatePt", 250, 0., 250.);
247  histo.pfcandidateEta_ = ibook.book1D("PFCandidateEta", "PFCandidateEta", 100, -5., 5.);
248  histo.pfcandidatePhi_ = ibook.book1D("PFCandidatePhi", "PFCandidatePhi", 100, -4., 4.);
249  histo.pfcandidateElementsInBlocks_ = ibook.book1D("PFCandidateElements", "PFCandidateElements", 20, 0., 20.);
250  }
251  // Folder '0' is meant to be cumulative, with no connection to pdgId
252  ibook.setCurrentFolder(folder_ + std::to_string(0));
253  histos[0].simPFSuperClusterSize_ = ibook.book1D("SimPFSuperClusterSize", "SimPFSuperClusterSize", 40, 0., 40.);
254  histos[0].simPFSuperClusterEnergy_ =
255  ibook.book1D("SimPFSuperClusterEnergy", "SimPFSuperClusterEnergy", 250, 0., 500.);
256 }
type
Definition: HCALResponse.h:21
histos
Definition: combine.py:4
std::vector< int > particles_to_monitor_
void CaloParticleValidation::dqmAnalyze ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup,
Histograms_CaloParticleValidation const &  histos 
) const
overrideprivate

Definition at line 119 of file CaloParticleValidation.cc.

References caloTruthCellsProducer_cfi::caloParticles, caloParticles_, HCALHighEnergyHPDFilter_cfi::energy, edm::Event::getByToken(), timingPdfMaker::histo, SimCluster::hits_and_fractions(), mps_fire::i, LogDebug, hltrates_dqm_sourceclient-live_cfg::offset, or, position, recHitsBH_, recHitsEE_, recHitsFH_, SimDataFormats::CaloAnalysis::sc, FastTrackerRecHitCombiner_cfi::simHits, simPFCandidates_, simPFClusters_, HGCalValidator_cfi::simVertices, simVertices_, and mathSSE::sqrt().

121  {
122  using namespace edm;
123 
124  Handle<HGCRecHitCollection> recHitHandleEE;
125  Handle<HGCRecHitCollection> recHitHandleFH;
126  Handle<HGCRecHitCollection> recHitHandleBH;
127  // make a map detid-rechit
128 
129  iEvent.getByToken(recHitsEE_, recHitHandleEE);
130  iEvent.getByToken(recHitsFH_, recHitHandleFH);
131  iEvent.getByToken(recHitsBH_, recHitHandleBH);
132  const auto& rechitsEE = *recHitHandleEE;
133  const auto& rechitsFH = *recHitHandleFH;
134  const auto& rechitsBH = *recHitHandleBH;
135  std::map<DetId, const HGCRecHit*> hitmap;
136  for (unsigned int i = 0; i < rechitsEE.size(); ++i) {
137  hitmap[rechitsEE[i].detid()] = &rechitsEE[i];
138  }
139  for (unsigned int i = 0; i < rechitsFH.size(); ++i) {
140  hitmap[rechitsFH[i].detid()] = &rechitsFH[i];
141  }
142  for (unsigned int i = 0; i < rechitsBH.size(); ++i) {
143  hitmap[rechitsBH[i].detid()] = &rechitsBH[i];
144  }
145 
146  Handle<std::vector<SimVertex>> simVerticesHandle;
147  iEvent.getByToken(simVertices_, simVerticesHandle);
148  std::vector<SimVertex> const& simVertices = *simVerticesHandle;
149 
150  Handle<std::vector<CaloParticle>> caloParticleHandle;
151  iEvent.getByToken(caloParticles_, caloParticleHandle);
152  std::vector<CaloParticle> const& caloParticles = *caloParticleHandle;
153 
154  Handle<std::vector<reco::SuperCluster>> simPFClustersHandle;
155  iEvent.getByToken(simPFClusters_, simPFClustersHandle);
156  std::vector<reco::SuperCluster> const& simPFClusters = *simPFClustersHandle;
157 
158  Handle<reco::PFCandidateCollection> simPFCandidatesHandle;
159  iEvent.getByToken(simPFCandidates_, simPFCandidatesHandle);
160  reco::PFCandidateCollection const& simPFCandidates = *simPFCandidatesHandle;
161 
162  for (auto const caloParticle : caloParticles) {
163  if (caloParticle.g4Tracks()[0].eventId().event() != 0 or
164  caloParticle.g4Tracks()[0].eventId().bunchCrossing() != 0) {
165  LogDebug("CaloParticleValidation") << "Excluding CaloParticles from event: "
166  << caloParticle.g4Tracks()[0].eventId().event()
167  << " with BX: " << caloParticle.g4Tracks()[0].eventId().bunchCrossing()
168  << std::endl;
169  continue;
170  }
171  int id = caloParticle.pdgId();
172  if (histos.count(id)) {
173  auto& histo = histos.at(id);
174  histo.eta_->Fill(caloParticle.eta());
175  histo.pt_->Fill(caloParticle.pt());
176  histo.energy_->Fill(caloParticle.energy());
177  histo.nSimClusters_->Fill(caloParticle.simClusters().size());
178  // Find the corresponding vertex.
179  histo.eta_Zorigin_map_->Fill(simVertices.at(caloParticle.g4Tracks()[0].vertIndex()).position().z(),
180  caloParticle.eta());
181  int simHits = 0;
182  float energy = 0.;
183  for (auto const sc : caloParticle.simClusters()) {
184  simHits += sc->hits_and_fractions().size();
185  for (auto const h_and_f : sc->hits_and_fractions()) {
186  if (hitmap.count(h_and_f.first))
187  energy += hitmap[h_and_f.first]->energy() * h_and_f.second;
188  }
189  }
190  histo.nHitInSimClusters_->Fill((float)simHits);
191  histo.selfEnergy_->Fill(energy);
192  histo.energyDifference_->Fill(1. - energy / caloParticle.energy());
193  }
194  }
195 
196  // simPFSuperClusters
197  for (auto const sc : simPFClusters) {
198  histos.at(0).simPFSuperClusterSize_->Fill((float)sc.clustersSize());
199  histos.at(0).simPFSuperClusterEnergy_->Fill(sc.rawEnergy());
200  }
201 
202  // simPFCandidates
203  int offset = 100000;
204  double ptx_tot = 0.;
205  double pty_tot = 0.;
206  for (auto const pfc : simPFCandidates) {
207  size_t type = offset + pfc.particleId();
208  ptx_tot += pfc.px();
209  pty_tot += pfc.py();
210  histos.at(offset).pfcandidateType_->Fill(type - offset);
211  auto& histo = histos.at(type);
212  histo.pfcandidateEnergy_->Fill(pfc.energy());
213  histo.pfcandidatePt_->Fill(pfc.pt());
214  histo.pfcandidateEta_->Fill(pfc.eta());
215  histo.pfcandidatePhi_->Fill(pfc.phi());
216  histo.pfcandidateElementsInBlocks_->Fill(pfc.elementsInBlocks().size());
217  }
218  auto& histo = histos.at(offset);
219  histo.pfcandidate_vect_sum_pt_->Fill(std::sqrt(ptx_tot * ptx_tot + pty_tot * pty_tot));
220 }
#define LogDebug(id)
type
Definition: HCALResponse.h:21
edm::EDGetTokenT< HGCRecHitCollection > recHitsEE_
edm::EDGetTokenT< std::vector< reco::SuperCluster > > simPFClusters_
edm::EDGetTokenT< std::vector< SimVertex > > simVertices_
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::PFCandidateCollection > simPFCandidates_
T sqrt(T t)
Definition: SSEVec.h:19
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
edm::EDGetTokenT< std::vector< CaloParticle > > caloParticles_
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
edm::EDGetTokenT< HGCRecHitCollection > recHitsFH_
histos
Definition: combine.py:4
HLT enums.
static int position[264][3]
Definition: ReadPGInfo.cc:289
edm::EDGetTokenT< HGCRecHitCollection > recHitsBH_
std::vector< std::pair< uint32_t, float > > hits_and_fractions() const
Returns list of rechit IDs and fractions for this SimCluster.
Definition: SimCluster.h:181
void CaloParticleValidation::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 259 of file CaloParticleValidation.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), DEFINE_FWK_MODULE, HLT_2018_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

259  {
260  //The following says we do not know what parameters are allowed so do no validation
261  // Please change this to state exactly what you do use, even if it is no parameters
263  desc.add<std::string>("folder", "HGCAL/"); // Please keep the trailing '/'
264  desc.add<std::vector<int>>("particles_to_monitor", {11, -11, 13, -13, 22, 111, 211, -211, 321, -321});
265  desc.add<edm::InputTag>("simVertices", edm::InputTag("g4SimHits"));
266  desc.add<edm::InputTag>("caloParticles", edm::InputTag("mix", "MergedCaloTruth"));
267  desc.add<edm::InputTag>("simPFClusters", edm::InputTag("simPFProducer", "perfect"));
268  desc.add<edm::InputTag>("simPFCandidates", edm::InputTag("simPFProducer"));
269  desc.add<edm::InputTag>("recHitsEE", edm::InputTag("HGCalRecHit", "HGCEERecHits"));
270  desc.add<edm::InputTag>("recHitsFH", edm::InputTag("HGCalRecHit", "HGCHEFRecHits"));
271  desc.add<edm::InputTag>("recHitsBH", edm::InputTag("HGCalRecHit", "HGCHEBRecHits"));
272  descriptions.add("caloparticlevalidationDefault", desc);
273 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

edm::EDGetTokenT<std::vector<CaloParticle> > CaloParticleValidation::caloParticles_
private

Definition at line 76 of file CaloParticleValidation.cc.

Referenced by dqmAnalyze().

std::string CaloParticleValidation::folder_
private

Definition at line 72 of file CaloParticleValidation.cc.

Referenced by bookHistograms().

std::vector<int> CaloParticleValidation::particles_to_monitor_
private

Definition at line 73 of file CaloParticleValidation.cc.

Referenced by bookHistograms().

edm::EDGetTokenT<HGCRecHitCollection> CaloParticleValidation::recHitsBH_
private

Definition at line 81 of file CaloParticleValidation.cc.

Referenced by dqmAnalyze().

edm::EDGetTokenT<HGCRecHitCollection> CaloParticleValidation::recHitsEE_
private

Definition at line 79 of file CaloParticleValidation.cc.

Referenced by dqmAnalyze().

edm::EDGetTokenT<HGCRecHitCollection> CaloParticleValidation::recHitsFH_
private

Definition at line 80 of file CaloParticleValidation.cc.

Referenced by dqmAnalyze().

edm::EDGetTokenT<reco::PFCandidateCollection> CaloParticleValidation::simPFCandidates_
private

Definition at line 78 of file CaloParticleValidation.cc.

Referenced by dqmAnalyze().

edm::EDGetTokenT<std::vector<reco::SuperCluster> > CaloParticleValidation::simPFClusters_
private

Definition at line 77 of file CaloParticleValidation.cc.

Referenced by dqmAnalyze().

edm::EDGetTokenT<std::vector<SimVertex> > CaloParticleValidation::simVertices_
private

Definition at line 75 of file CaloParticleValidation.cc.

Referenced by dqmAnalyze().