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 > > 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 > >
 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
 
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)
 
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::ConcurrentBooker &, 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 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 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 55 of file CaloParticleValidation.cc.

Constructor & Destructor Documentation

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

Definition at line 97 of file CaloParticleValidation.cc.

98  : folder_(iConfig.getParameter<std::string>("folder")),
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"))),
103  simPFCandidates_(consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("simPFCandidates"))),
104  recHitsEE_(consumes<HGCRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsEE"))),
105  recHitsFH_(consumes<HGCRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsFH"))),
106  recHitsBH_(consumes<HGCRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsBH")))
107 {
108  //now do what ever initialization is needed
109 }
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 112 of file CaloParticleValidation.cc.

113 {
114  // do anything here that needs to be done at desctruction time
115  // (e.g. close files, deallocate resources etc.)
116 }

Member Function Documentation

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

Implements DQMGlobalEDAnalyzer< Histograms_CaloParticleValidation >.

Definition at line 217 of file CaloParticleValidation.cc.

References DQMStore::ConcurrentBooker::book1D(), DQMStore::ConcurrentBooker::book2D(), reco::PFCandidate::egamma_HF, folder_, reco::PFCandidate::h, trackerHits::histo, PFRecoTauDiscriminationByIsolation_cfi::offset, particles_to_monitor_, and DQMStore::IBooker::setCurrentFolder().

221 {
222  for (auto const particle : particles_to_monitor_) {
223  ibook.setCurrentFolder(folder_ + "CaloParticles/" + std::to_string(particle));
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.);
233  }
234  int offset = 100000;
235  ibook.setCurrentFolder(folder_ + "PFCandidates");
236  histos[offset].pfcandidateType_ = ibook.book1D("PFCandidateType", "PFCandidateType", 10, 0, 10);
238  ibook.setCurrentFolder(folder_ + "PFCandidates/" + std::to_string(type));
239  auto & histo = histos[offset + type];
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.);
245  }
246  // Folder '0' is meant to be cumulative, with no connection to pdgId
247  ibook.setCurrentFolder(folder_ + std::to_string(0));
248  histos[0].simPFSuperClusterSize_ = ibook.book1D("SimPFSuperClusterSize", "SimPFSuperClusterSize", 40, 0., 40.);
249  histos[0].simPFSuperClusterEnergy_ = ibook.book1D("SimPFSuperClusterEnergy", "SimPFSuperClusterEnergy", 250, 0., 500.);
250 }
type
Definition: HCALResponse.h:21
ConcurrentMonitorElement book2D(Args &&...args)
Definition: DQMStore.h:244
ConcurrentMonitorElement book1D(Args &&...args)
Definition: DQMStore.h:223
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
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 126 of file CaloParticleValidation.cc.

References caloTruthProducer_cfi::caloParticles, caloParticles_, edm::Event::getByToken(), trackerHits::histo, SimCluster::hits_and_fractions(), mps_fire::i, PFRecoTauDiscriminationByIsolation_cfi::offset, position, recHitsBH_, recHitsEE_, recHitsFH_, SimDataFormats::CaloAnalysis::sc, trackerHits::simHits, simPFCandidates_, simPFClusters_, and simVertices_.

128 {
129  using namespace edm;
130 
131  Handle<HGCRecHitCollection> recHitHandleEE;
132  Handle<HGCRecHitCollection> recHitHandleFH;
133  Handle<HGCRecHitCollection> recHitHandleBH;
134  // make a map detid-rechit
135 
136  iEvent.getByToken(recHitsEE_, recHitHandleEE);
137  iEvent.getByToken(recHitsFH_, recHitHandleFH);
138  iEvent.getByToken(recHitsBH_, recHitHandleBH);
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];
145  }
146  for (unsigned int i = 0; i < rechitsFH.size(); ++i) {
147  hitmap[rechitsFH[i].detid()] = &rechitsFH[i];
148  }
149  for (unsigned int i = 0; i < rechitsBH.size(); ++i) {
150  hitmap[rechitsBH[i].detid()] = &rechitsBH[i];
151  }
152 
153  Handle<std::vector<SimVertex>> simVerticesHandle;
154  iEvent.getByToken(simVertices_, simVerticesHandle);
155  std::vector<SimVertex> const & simVertices = *simVerticesHandle;
156 
157  Handle<std::vector<CaloParticle> > caloParticleHandle;
158  iEvent.getByToken(caloParticles_, caloParticleHandle);
159  std::vector<CaloParticle> const & caloParticles = *caloParticleHandle;
160 
161  Handle<std::vector<reco::SuperCluster>> simPFClustersHandle;
162  iEvent.getByToken(simPFClusters_, simPFClustersHandle);
163  std::vector<reco::SuperCluster> const & simPFClusters = *simPFClustersHandle;
164 
165  Handle<reco::PFCandidateCollection> simPFCandidatesHandle;
166  iEvent.getByToken(simPFCandidates_, simPFCandidatesHandle);
167  reco::PFCandidateCollection const & simPFCandidates = *simPFCandidatesHandle;
168 
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());
177  // Find the corresponding vertex.
178  histo.eta_Zorigin_map_.fill(
179  simVertices.at(caloParticle.g4Tracks()[0].vertIndex()).position().z(), caloParticle.eta());
180  int simHits = 0;
181  float energy = 0.;
182  for (auto const sc : caloParticle.simClusters()) {
183  simHits += sc->hits_and_fractions().size();
184  for (auto const h_and_f : sc->hits_and_fractions()) {
185  if (hitmap.count(h_and_f.first))
186  energy += hitmap[h_and_f.first]->energy() * h_and_f.second;
187  }
188  }
189  histo.nHitInSimClusters_.fill((float)simHits);
190  histo.selfEnergy_.fill(energy);
191  histo.energyDifference_.fill(1.- energy/caloParticle.energy());
192  }
193  }
194 
195  // simPFSuperClusters
196  for (auto const sc : simPFClusters) {
197  histos.at(0).simPFSuperClusterSize_.fill((float)sc.clustersSize());
198  histos.at(0).simPFSuperClusterEnergy_.fill(sc.rawEnergy());
199  }
200 
201  // simPFCandidates
202  int offset = 100000;
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());
212  }
213 }
type
Definition: HCALResponse.h:21
edm::EDGetTokenT< HGCRecHitCollection > recHitsEE_
std::vector< std::pair< uint32_t, float > > hits_and_fractions() const
Returns list of rechit IDs and fractions for this SimCluster.
Definition: SimCluster.h:210
edm::EDGetTokenT< std::vector< reco::SuperCluster > > simPFClusters_
edm::EDGetTokenT< std::vector< SimVertex > > simVertices_
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< reco::PFCandidateCollection > simPFCandidates_
edm::EDGetTokenT< std::vector< CaloParticle > > caloParticles_
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
edm::EDGetTokenT< HGCRecHitCollection > recHitsFH_
HLT enums.
static int position[264][3]
Definition: ReadPGInfo.cc:509
edm::EDGetTokenT< HGCRecHitCollection > recHitsBH_
void CaloParticleValidation::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 254 of file CaloParticleValidation.cc.

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

254  {
255  //The following says we do not know what parameters are allowed so do no validation
256  // Please change this to state exactly what you do use, even if it is no parameters
258  desc.add<std::string>("folder", "HGCAL/"); // Please keep the trailing '/'
259  desc.add<std::vector<int> > ("particles_to_monitor", {11, -11, 13, 22, 111, 211, -211, 321, -321});
260  desc.add<edm::InputTag>("simVertices", edm::InputTag("g4SimHits"));
261  desc.add<edm::InputTag>("caloParticles", edm::InputTag("mix", "MergedCaloTruth"));
262  desc.add<edm::InputTag>("simPFClusters", edm::InputTag("simPFProducer", "perfect"));
263  desc.add<edm::InputTag>("simPFCandidates", edm::InputTag("simPFProducer"));
264  desc.add<edm::InputTag>("recHitsEE", edm::InputTag("HGCalRecHit","HGCEERecHits"));
265  desc.add<edm::InputTag>("recHitsFH", edm::InputTag("HGCalRecHit","HGCHEFRecHits"));
266  desc.add<edm::InputTag>("recHitsBH", edm::InputTag("HGCalRecHit","HGCHEBRecHits"));
267  descriptions.add("caloparticlevalidationDefault", desc);
268 }
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 78 of file CaloParticleValidation.cc.

Referenced by dqmAnalyze().

std::string CaloParticleValidation::folder_
private

Definition at line 74 of file CaloParticleValidation.cc.

Referenced by bookHistograms().

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

Definition at line 75 of file CaloParticleValidation.cc.

Referenced by bookHistograms().

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

Definition at line 83 of file CaloParticleValidation.cc.

Referenced by dqmAnalyze().

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

Definition at line 81 of file CaloParticleValidation.cc.

Referenced by dqmAnalyze().

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

Definition at line 82 of file CaloParticleValidation.cc.

Referenced by dqmAnalyze().

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

Definition at line 80 of file CaloParticleValidation.cc.

Referenced by dqmAnalyze().

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

Definition at line 79 of file CaloParticleValidation.cc.

Referenced by dqmAnalyze().

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

Definition at line 77 of file CaloParticleValidation.cc.

Referenced by dqmAnalyze().