CMS 3D CMS Logo

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

#include <EcalSimHitsValidation.h>

Inheritance diagram for EcalSimHitsValidation:
edm::EDAnalyzer edm::EDConsumerBase

Public Types

typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 
- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 EcalSimHitsValidation (const edm::ParameterSet &ps)
 Constructor. More...
 
 ~EcalSimHitsValidation () override
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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)
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 Analyze. More...
 
void beginJob () override
 
void endJob (void) override
 
- 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)
 

Private Types

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

Private Attributes

DQMStoredbe_
 
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_
 
std::string outputFile_
 
bool verbose_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 

Detailed Description

Definition at line 40 of file EcalSimHitsValidation.h.

Member Typedef Documentation

Definition at line 44 of file EcalSimHitsValidation.h.

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

Definition at line 41 of file EcalSimHitsValidation.h.

Definition at line 45 of file EcalSimHitsValidation.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 20 of file EcalSimHitsValidation.cc.

References dbe_, EBHitsCollectionToken, EEHitsCollectionToken, ESHitsCollectionToken, g4InfoLabel, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), timingPdfMaker::histo, HLT_2018_cff::InputTag, meEBEnergyFraction_, meEEEnergyFraction_, meESEnergyFraction_, meGunEnergy_, meGunEta_, meGunPhi_, Utilities::operator, outputFile_, AlCaHLTBitMon_QueryRunRegistry::string, and verbose_.

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  // DQM ROOT output
31  outputFile_ = ps.getUntrackedParameter<std::string>("outputFile", "");
32 
33  if (!outputFile_.empty()) {
34  edm::LogInfo("OutputInfo") << " Ecal SimHits Task histograms will be saved to " << outputFile_.c_str();
35  } else {
36  edm::LogInfo("OutputInfo") << " Ecal SimHits Task histograms will NOT be saved";
37  }
38 
39  // verbosity switch
40  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
41 
42  // DQMServices
43  dbe_ = nullptr;
44 
45  // get hold of back-end interface
46  dbe_ = edm::Service<DQMStore>().operator->();
47 
48  if (dbe_) {
49  if (verbose_)
51  }
52 
53  meGunEnergy_ = nullptr;
54  meGunEta_ = nullptr;
55  meGunPhi_ = nullptr;
56  meEBEnergyFraction_ = nullptr;
57  meEEEnergyFraction_ = nullptr;
58  meESEnergyFraction_ = nullptr;
59 
60  Char_t histo[200];
61 
62  if (dbe_) {
63  dbe_->setCurrentFolder("EcalHitsV/EcalSimHitsValidation");
64 
65  sprintf(histo, "EcalSimHitsValidation Gun Momentum");
66  meGunEnergy_ = dbe_->book1D(histo, histo, 100, 0., 1000.);
67 
68  sprintf(histo, "EcalSimHitsValidation Gun Eta");
69  meGunEta_ = dbe_->book1D(histo, histo, 700, -3.5, 3.5);
70 
71  sprintf(histo, "EcalSimHitsValidation Gun Phi");
72  meGunPhi_ = dbe_->book1D(histo, histo, 360, 0., 360.);
73 
74  sprintf(histo, "EcalSimHitsValidation Barrel fraction of energy");
75  meEBEnergyFraction_ = dbe_->book1D(histo, histo, 100, 0., 1.1);
76 
77  sprintf(histo, "EcalSimHitsValidation Endcap fraction of energy");
78  meEEEnergyFraction_ = dbe_->book1D(histo, histo, 100, 0., 1.1);
79 
80  sprintf(histo, "EcalSimHitsValidation Preshower fraction of energy");
81  meESEnergyFraction_ = dbe_->book1D(histo, histo, 60, 0., 0.001);
82  }
83 }
MonitorElement * meEBEnergyFraction_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::PCaloHitContainer > EBHitsCollectionToken
edm::EDGetTokenT< edm::HepMCProduct > HepMCToken
MonitorElement * meGunEnergy_
edm::EDGetTokenT< edm::PCaloHitContainer > EEHitsCollectionToken
edm::EDGetTokenT< edm::PCaloHitContainer > ESHitsCollectionToken
MonitorElement * meEEEnergyFraction_
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:639
void showDirStructure() const
Definition: DQMStore.cc:2926
MonitorElement * book1D(char_string const &name, char_string const &title, int const nchX, double const lowX, double const highX)
Book 1D histogram.
Definition: DQMStore.cc:1121
MonitorElement * meESEnergyFraction_
EcalSimHitsValidation::~EcalSimHitsValidation ( )
override

Destructor.

Definition at line 85 of file EcalSimHitsValidation.cc.

References dbe_, outputFile_, and dqm::dqmstoreimpl::DQMStore::save().

85  {
86  if (!outputFile_.empty() && dbe_)
88 }
void save(std::string const &filename, std::string const &path="", std::string const &pattern="", std::string const &rewrite="", uint32_t run=0, uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, std::string const &fileupdate="RECREATE")
Definition: DQMStore.cc:2244

Member Function Documentation

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

Analyze.

Definition at line 94 of file EcalSimHitsValidation.cc.

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

94  {
95  edm::LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
96 
97  std::vector<PCaloHit> theEBCaloHits;
98  std::vector<PCaloHit> theEECaloHits;
99  std::vector<PCaloHit> theESCaloHits;
100 
105 
106  e.getByToken(HepMCToken, MCEvt);
107  e.getByToken(EBHitsCollectionToken, EcalHitsEB);
108  e.getByToken(EEHitsCollectionToken, EcalHitsEE);
109  e.getByToken(ESHitsCollectionToken, EcalHitsES);
110 
111  for (HepMC::GenEvent::particle_const_iterator p = MCEvt->GetEvent()->particles_begin();
112  p != MCEvt->GetEvent()->particles_end();
113  ++p) {
114  double htheta = (*p)->momentum().theta();
115  double heta = -99999.;
116  if (tan(htheta * 0.5) > 0) {
117  heta = -log(tan(htheta * 0.5));
118  }
119  double hphi = (*p)->momentum().phi();
120  hphi = (hphi >= 0) ? hphi : hphi + 2 * M_PI;
121  hphi = hphi / M_PI * 180.;
122 
123  LogDebug("EventInfo") << "Particle gun type form MC = " << abs((*p)->pdg_id()) << "\n"
124  << "Energy = " << (*p)->momentum().e() << " Eta = " << heta << " Phi = " << hphi;
125 
126  if (meGunEnergy_)
127  meGunEnergy_->Fill((*p)->momentum().e());
128  if (meGunEta_)
129  meGunEta_->Fill(heta);
130  if (meGunPhi_)
131  meGunPhi_->Fill(hphi);
132  }
133 
134  double EBEnergy_ = 0.;
135  if (EcalHitsEB.isValid()) {
136  theEBCaloHits.insert(theEBCaloHits.end(), EcalHitsEB->begin(), EcalHitsEB->end());
137  for (std::vector<PCaloHit>::iterator isim = theEBCaloHits.begin(); isim != theEBCaloHits.end(); ++isim) {
138  EBEnergy_ += isim->energy();
139  }
140  }
141 
142  double EEEnergy_ = 0.;
143  if (EcalHitsEE.isValid()) {
144  theEECaloHits.insert(theEECaloHits.end(), EcalHitsEE->begin(), EcalHitsEE->end());
145  for (std::vector<PCaloHit>::iterator isim = theEECaloHits.begin(); isim != theEECaloHits.end(); ++isim) {
146  EEEnergy_ += isim->energy();
147  }
148  }
149 
150  double ESEnergy_ = 0.;
151  if (EcalHitsES.isValid()) {
152  theESCaloHits.insert(theESCaloHits.end(), EcalHitsES->begin(), EcalHitsES->end());
153  for (std::vector<PCaloHit>::iterator isim = theESCaloHits.begin(); isim != theESCaloHits.end(); ++isim) {
154  ESEnergy_ += isim->energy();
155  }
156  }
157 
158  double etot = EBEnergy_ + EEEnergy_ + ESEnergy_;
159  double fracEB = 0.0;
160  double fracEE = 0.0;
161  double fracES = 0.0;
162 
163  if (etot > 0.0) {
164  fracEB = EBEnergy_ / etot;
165  fracEE = EEEnergy_ / etot;
166  fracES = ESEnergy_ / etot;
167  }
168 
170  meEBEnergyFraction_->Fill(fracEB);
171 
173  meEEEnergyFraction_->Fill(fracEE);
174 
176  meESEnergyFraction_->Fill(fracES);
177 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:38
MonitorElement * meEBEnergyFraction_
EventNumber_t event() const
Definition: EventID.h:40
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void Fill(long long x)
edm::EDGetTokenT< edm::PCaloHitContainer > EBHitsCollectionToken
edm::EDGetTokenT< edm::HepMCProduct > HepMCToken
MonitorElement * meGunEnergy_
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< edm::PCaloHitContainer > EEHitsCollectionToken
#define M_PI
edm::EDGetTokenT< edm::PCaloHitContainer > ESHitsCollectionToken
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
MonitorElement * meEEEnergyFraction_
edm::EventID id() const
Definition: EventBase.h:59
MonitorElement * meESEnergyFraction_
void EcalSimHitsValidation::beginJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 90 of file EcalSimHitsValidation.cc.

90 {}
void EcalSimHitsValidation::endJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 92 of file EcalSimHitsValidation.cc.

92 {}

Member Data Documentation

DQMStore* EcalSimHitsValidation::dbe_
private

Definition at line 72 of file EcalSimHitsValidation.h.

Referenced by EcalSimHitsValidation(), and ~EcalSimHitsValidation().

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

Definition at line 66 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

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

Definition at line 67 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

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

Definition at line 68 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

std::string EcalSimHitsValidation::g4InfoLabel
private

Definition at line 64 of file EcalSimHitsValidation.h.

Referenced by EcalSimHitsValidation().

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

Definition at line 65 of file EcalSimHitsValidation.h.

Referenced by analyze().

MonitorElement* EcalSimHitsValidation::meEBEnergyFraction_
private

Definition at line 80 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

MonitorElement* EcalSimHitsValidation::meEEEnergyFraction_
private

Definition at line 81 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

MonitorElement* EcalSimHitsValidation::meESEnergyFraction_
private

Definition at line 82 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

MonitorElement* EcalSimHitsValidation::meGunEnergy_
private

Definition at line 76 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

MonitorElement* EcalSimHitsValidation::meGunEta_
private

Definition at line 77 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

MonitorElement* EcalSimHitsValidation::meGunPhi_
private

Definition at line 78 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

std::string EcalSimHitsValidation::outputFile_
private

Definition at line 74 of file EcalSimHitsValidation.h.

Referenced by EcalSimHitsValidation(), and ~EcalSimHitsValidation().

bool EcalSimHitsValidation::verbose_
private

Definition at line 70 of file EcalSimHitsValidation.h.

Referenced by EcalSimHitsValidation().