CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Types | Private Attributes
EcalSimHitsValidation Class Reference

#include <EcalSimHitsValidation.h>

Inheritance diagram for EcalSimHitsValidation:
DQMEDAnalyzer edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >

Public Member Functions

 EcalSimHitsValidation (const edm::ParameterSet &ps)
 Constructor. More...
 
- Public Member Functions inherited from DQMEDAnalyzer
void accumulate (edm::Event const &event, edm::EventSetup const &setup) final
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void beginRun (edm::Run const &run, edm::EventSetup const &setup) final
 
void beginStream (edm::StreamID id) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer ()
 
void endLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void endRun (edm::Run const &run, edm::EventSetup const &setup) final
 
virtual bool getCanSaveByLumi ()
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 Analyze. More...
 
void bookHistograms (DQMStore::IBooker &ib, edm::Run const &, edm::EventSetup const &c) override
 
- Protected Member Functions inherited from DQMEDAnalyzer
uint64_t meId () const
 

Private Types

typedef std::map< uint32_t, float, std::less< uint32_t > > MapType
 

Private Attributes

edm::EDGetTokenT< edm::PCaloHitContainerEBHitsCollectionToken
 
edm::EDGetTokenT< edm::PCaloHitContainerEEHitsCollectionToken
 
edm::EDGetTokenT< edm::PCaloHitContainerESHitsCollectionToken
 
std::string g4InfoLabel
 
edm::EDGetTokenT< edm::HepMCProductHepMCToken
 
MonitorElementmeEBEnergyFraction_
 
MonitorElementmeEEEnergyFraction_
 
MonitorElementmeESEnergyFraction_
 
MonitorElementmeGunEnergy_
 
MonitorElementmeGunEta_
 
MonitorElementmeGunPhi_
 
bool verbose_
 

Additional Inherited Members

- Public Types inherited from DQMEDAnalyzer
typedef dqm::reco::DQMStore DQMStore
 
typedef dqm::reco::MonitorElement MonitorElement
 
- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static void globalEndJob (DQMEDAnalyzerGlobalCache const *)
 
static void globalEndLuminosityBlockProduce (edm::LuminosityBlock &lumi, edm::EventSetup const &setup, LuminosityBlockContext const *context)
 
static void globalEndRunProduce (edm::Run &run, edm::EventSetup const &setup, RunContext const *context)
 
static std::unique_ptr< DQMEDAnalyzerGlobalCacheinitializeGlobalCache (edm::ParameterSet const &)
 
- Protected Attributes inherited from DQMEDAnalyzer
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 
unsigned int streamId_
 

Detailed Description

Definition at line 37 of file EcalSimHitsValidation.h.

Member Typedef Documentation

◆ MapType

typedef std::map<uint32_t, float, std::less<uint32_t> > EcalSimHitsValidation::MapType
private

Definition at line 38 of file EcalSimHitsValidation.h.

Constructor & Destructor Documentation

◆ EcalSimHitsValidation()

EcalSimHitsValidation::EcalSimHitsValidation ( const edm::ParameterSet ps)

Constructor.

Definition at line 20 of file EcalSimHitsValidation.cc.

21  : g4InfoLabel(ps.getParameter<std::string>("moduleLabelG4")),
22  HepMCToken(consumes<edm::HepMCProduct>(ps.getParameter<std::string>("moduleLabelMC"))) {
24  consumes<edm::PCaloHitContainer>(edm::InputTag(g4InfoLabel, ps.getParameter<std::string>("EBHitsCollection")));
26  consumes<edm::PCaloHitContainer>(edm::InputTag(g4InfoLabel, ps.getParameter<std::string>("EEHitsCollection")));
28  consumes<edm::PCaloHitContainer>(edm::InputTag(g4InfoLabel, ps.getParameter<std::string>("ESHitsCollection")));
29 
30  // verbosity switch
31  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
32 }

References EBHitsCollectionToken, EEHitsCollectionToken, ESHitsCollectionToken, g4InfoLabel, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), AlCaHLTBitMon_QueryRunRegistry::string, and verbose_.

Member Function Documentation

◆ analyze()

void EcalSimHitsValidation::analyze ( const edm::Event e,
const edm::EventSetup c 
)
overrideprotectedvirtual

Analyze.

Reimplemented from DQMEDAnalyzer.

Definition at line 57 of file EcalSimHitsValidation.cc.

57  {
58  edm::LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
59 
60  std::vector<PCaloHit> theEBCaloHits;
61  std::vector<PCaloHit> theEECaloHits;
62  std::vector<PCaloHit> theESCaloHits;
63 
68 
69  e.getByToken(HepMCToken, MCEvt);
70  e.getByToken(EBHitsCollectionToken, EcalHitsEB);
71  e.getByToken(EEHitsCollectionToken, EcalHitsEE);
72  e.getByToken(ESHitsCollectionToken, EcalHitsES);
73 
74  for (HepMC::GenEvent::particle_const_iterator p = MCEvt->GetEvent()->particles_begin();
75  p != MCEvt->GetEvent()->particles_end();
76  ++p) {
77  double htheta = (*p)->momentum().theta();
78  double heta = -99999.;
79  if (tan(htheta * 0.5) > 0) {
80  heta = -log(tan(htheta * 0.5));
81  }
82  double hphi = (*p)->momentum().phi();
83  hphi = (hphi >= 0) ? hphi : hphi + 2 * M_PI;
84  hphi = hphi / M_PI * 180.;
85 
86  LogDebug("EventInfo") << "Particle gun type form MC = " << abs((*p)->pdg_id()) << "\n"
87  << "Energy = " << (*p)->momentum().e() << " Eta = " << heta << " Phi = " << hphi;
88 
89  meGunEnergy_->Fill((*p)->momentum().e());
90  meGunEta_->Fill(heta);
91  meGunPhi_->Fill(hphi);
92  }
93 
94  double EBEnergy_ = 0.;
95  if (EcalHitsEB.isValid()) {
96  theEBCaloHits.insert(theEBCaloHits.end(), EcalHitsEB->begin(), EcalHitsEB->end());
97  for (std::vector<PCaloHit>::iterator isim = theEBCaloHits.begin(); isim != theEBCaloHits.end(); ++isim) {
98  EBEnergy_ += isim->energy();
99  }
100  }
101 
102  double EEEnergy_ = 0.;
103  if (EcalHitsEE.isValid()) {
104  theEECaloHits.insert(theEECaloHits.end(), EcalHitsEE->begin(), EcalHitsEE->end());
105  for (std::vector<PCaloHit>::iterator isim = theEECaloHits.begin(); isim != theEECaloHits.end(); ++isim) {
106  EEEnergy_ += isim->energy();
107  }
108  }
109 
110  double ESEnergy_ = 0.;
111  if (EcalHitsES.isValid()) {
112  theESCaloHits.insert(theESCaloHits.end(), EcalHitsES->begin(), EcalHitsES->end());
113  for (std::vector<PCaloHit>::iterator isim = theESCaloHits.begin(); isim != theESCaloHits.end(); ++isim) {
114  ESEnergy_ += isim->energy();
115  }
116  }
117 
118  double etot = EBEnergy_ + EEEnergy_ + ESEnergy_;
119  double fracEB = 0.0;
120  double fracEE = 0.0;
121  double fracES = 0.0;
122 
123  if (etot > 0.0) {
124  fracEB = EBEnergy_ / etot;
125  fracEE = EEEnergy_ / etot;
126  fracES = ESEnergy_ / etot;
127  }
128 
129  meEBEnergyFraction_->Fill(fracEB);
130  meEEEnergyFraction_->Fill(fracEE);
131  meESEnergyFraction_->Fill(fracES);
132 }

References funct::abs(), MillePedeFileConverter_cfg::e, EBHitsCollectionToken, EEHitsCollectionToken, ESHitsCollectionToken, dqm::impl::MonitorElement::Fill(), edm::HepMCProduct::GetEvent(), HepMCToken, edm::HandleBase::isValid(), dqm-mbProfile::log, LogDebug, M_PI, meEBEnergyFraction_, meEEEnergyFraction_, meESEnergyFraction_, meGunEnergy_, meGunEta_, meGunPhi_, AlCaHLTBitMon_ParallelJobs::p, and funct::tan().

◆ bookHistograms()

void EcalSimHitsValidation::bookHistograms ( DQMStore::IBooker ib,
edm::Run const &  ,
edm::EventSetup const &  c 
)
overrideprotectedvirtual

Implements DQMEDAnalyzer.

Definition at line 34 of file EcalSimHitsValidation.cc.

34  {
35  ib.setCurrentFolder("EcalHitsV/EcalSimHitsValidation");
36  ib.setScope(MonitorElementData::Scope::RUN);
37 
38  std::string histo = "EcalSimHitsValidation Gun Momentum";
39  meGunEnergy_ = ib.book1D(histo, histo, 100, 0., 1000.);
40 
41  histo = "EcalSimHitsValidation Gun Eta";
42  meGunEta_ = ib.book1D(histo, histo, 700, -3.5, 3.5);
43 
44  histo = "EcalSimHitsValidation Gun Phi";
45  meGunPhi_ = ib.book1D(histo, histo, 360, 0., 360.);
46 
47  histo = "EcalSimHitsValidation Barrel fraction of energy";
48  meEBEnergyFraction_ = ib.book1D(histo, histo, 100, 0., 1.1);
49 
50  histo = "EcalSimHitsValidation Endcap fraction of energy";
51  meEEEnergyFraction_ = ib.book1D(histo, histo, 100, 0., 1.1);
52 
53  histo = "EcalSimHitsValidation Preshower fraction of energy";
54  meESEnergyFraction_ = ib.book1D(histo, histo, 60, 0., 0.001);
55 }

References timingPdfMaker::histo, cuy::ib, meEBEnergyFraction_, meEEEnergyFraction_, meESEnergyFraction_, meGunEnergy_, meGunEta_, meGunPhi_, and AlCaHLTBitMon_QueryRunRegistry::string.

Member Data Documentation

◆ EBHitsCollectionToken

edm::EDGetTokenT<edm::PCaloHitContainer> EcalSimHitsValidation::EBHitsCollectionToken
private

Definition at line 53 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

◆ EEHitsCollectionToken

edm::EDGetTokenT<edm::PCaloHitContainer> EcalSimHitsValidation::EEHitsCollectionToken
private

Definition at line 54 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

◆ ESHitsCollectionToken

edm::EDGetTokenT<edm::PCaloHitContainer> EcalSimHitsValidation::ESHitsCollectionToken
private

Definition at line 55 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

◆ g4InfoLabel

std::string EcalSimHitsValidation::g4InfoLabel
private

Definition at line 51 of file EcalSimHitsValidation.h.

Referenced by EcalSimHitsValidation().

◆ HepMCToken

edm::EDGetTokenT<edm::HepMCProduct> EcalSimHitsValidation::HepMCToken
private

Definition at line 52 of file EcalSimHitsValidation.h.

Referenced by analyze().

◆ meEBEnergyFraction_

MonitorElement* EcalSimHitsValidation::meEBEnergyFraction_
private

Definition at line 63 of file EcalSimHitsValidation.h.

Referenced by analyze(), and bookHistograms().

◆ meEEEnergyFraction_

MonitorElement* EcalSimHitsValidation::meEEEnergyFraction_
private

Definition at line 64 of file EcalSimHitsValidation.h.

Referenced by analyze(), and bookHistograms().

◆ meESEnergyFraction_

MonitorElement* EcalSimHitsValidation::meESEnergyFraction_
private

Definition at line 65 of file EcalSimHitsValidation.h.

Referenced by analyze(), and bookHistograms().

◆ meGunEnergy_

MonitorElement* EcalSimHitsValidation::meGunEnergy_
private

Definition at line 59 of file EcalSimHitsValidation.h.

Referenced by analyze(), and bookHistograms().

◆ meGunEta_

MonitorElement* EcalSimHitsValidation::meGunEta_
private

Definition at line 60 of file EcalSimHitsValidation.h.

Referenced by analyze(), and bookHistograms().

◆ meGunPhi_

MonitorElement* EcalSimHitsValidation::meGunPhi_
private

Definition at line 61 of file EcalSimHitsValidation.h.

Referenced by analyze(), and bookHistograms().

◆ verbose_

bool EcalSimHitsValidation::verbose_
private

Definition at line 57 of file EcalSimHitsValidation.h.

Referenced by EcalSimHitsValidation().

EcalSimHitsValidation::EBHitsCollectionToken
edm::EDGetTokenT< edm::PCaloHitContainer > EBHitsCollectionToken
Definition: EcalSimHitsValidation.h:53
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
EcalSimHitsValidation::meGunEnergy_
MonitorElement * meGunEnergy_
Definition: EcalSimHitsValidation.h:59
EcalSimHitsValidation::meGunEta_
MonitorElement * meGunEta_
Definition: EcalSimHitsValidation.h:60
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
EcalSimHitsValidation::meEEEnergyFraction_
MonitorElement * meEEEnergyFraction_
Definition: EcalSimHitsValidation.h:64
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle< edm::HepMCProduct >
EcalSimHitsValidation::meGunPhi_
MonitorElement * meGunPhi_
Definition: EcalSimHitsValidation.h:61
EcalSimHitsValidation::meEBEnergyFraction_
MonitorElement * meEBEnergyFraction_
Definition: EcalSimHitsValidation.h:63
EcalSimHitsValidation::verbose_
bool verbose_
Definition: EcalSimHitsValidation.h:57
EcalSimHitsValidation::ESHitsCollectionToken
edm::EDGetTokenT< edm::PCaloHitContainer > ESHitsCollectionToken
Definition: EcalSimHitsValidation.h:55
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
cuy.ib
ib
Definition: cuy.py:662
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
EcalSimHitsValidation::g4InfoLabel
std::string g4InfoLabel
Definition: EcalSimHitsValidation.h:51
EcalSimHitsValidation::meESEnergyFraction_
MonitorElement * meESEnergyFraction_
Definition: EcalSimHitsValidation.h:65
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
EcalSimHitsValidation::EEHitsCollectionToken
edm::EDGetTokenT< edm::PCaloHitContainer > EEHitsCollectionToken
Definition: EcalSimHitsValidation.h:54
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15
EcalSimHitsValidation::HepMCToken
edm::EDGetTokenT< edm::HepMCProduct > HepMCToken
Definition: EcalSimHitsValidation.h:52
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37