21 : g4InfoLabel(ps.getParameter<
std::
string>(
"moduleLabelG4")),
33 if (!outputFile_.empty()) {
34 edm::LogInfo(
"OutputInfo") <<
" Ecal SimHits Task histograms will be saved to " << outputFile_.c_str();
36 edm::LogInfo(
"OutputInfo") <<
" Ecal SimHits Task histograms will NOT be saved";
57 dbe_->showDirStructure();
70 dbe_->setCurrentFolder(
"EcalHitsV/EcalSimHitsValidation");
72 sprintf(histo,
"EcalSimHitsValidation Gun Momentum");
73 meGunEnergy_ = dbe_->book1D(histo, histo, 100, 0., 1000.);
75 sprintf(histo,
"EcalSimHitsValidation Gun Eta");
76 meGunEta_ = dbe_->book1D(histo, histo, 700, -3.5, 3.5);
78 sprintf(histo,
"EcalSimHitsValidation Gun Phi");
79 meGunPhi_ = dbe_->book1D(histo, histo, 360, 0., 360.);
81 sprintf(histo,
"EcalSimHitsValidation Barrel fraction of energy");
84 sprintf(histo,
"EcalSimHitsValidation Endcap fraction of energy");
87 sprintf(histo,
"EcalSimHitsValidation Preshower fraction of energy");
104 std::vector<PCaloHit> theEBCaloHits;
105 std::vector<PCaloHit> theEECaloHits;
106 std::vector<PCaloHit> theESCaloHits;
118 for (HepMC::GenEvent::particle_const_iterator
p = MCEvt->
GetEvent()->particles_begin();
121 double htheta = (*p)->momentum().theta();
122 double heta = -99999.;
123 if (
tan(htheta * 0.5) > 0) {
124 heta = -
log(
tan(htheta * 0.5));
126 double hphi = (*p)->momentum().phi();
127 hphi = (hphi >= 0) ? hphi : hphi + 2 *
M_PI;
128 hphi = hphi /
M_PI * 180.;
130 LogDebug(
"EventInfo") <<
"Particle gun type form MC = " <<
abs((*p)->pdg_id()) <<
"\n" 131 <<
"Energy = " << (*p)->momentum().e() <<
" Eta = " << heta <<
" Phi = " << hphi;
141 double EBEnergy_ = 0.;
143 theEBCaloHits.insert(theEBCaloHits.end(), EcalHitsEB->begin(), EcalHitsEB->end());
144 for (std::vector<PCaloHit>::iterator isim = theEBCaloHits.begin(); isim != theEBCaloHits.end(); ++isim) {
145 EBEnergy_ += isim->energy();
149 double EEEnergy_ = 0.;
151 theEECaloHits.insert(theEECaloHits.end(), EcalHitsEE->begin(), EcalHitsEE->end());
152 for (std::vector<PCaloHit>::iterator isim = theEECaloHits.begin(); isim != theEECaloHits.end(); ++isim) {
153 EEEnergy_ += isim->energy();
157 double ESEnergy_ = 0.;
159 theESCaloHits.insert(theESCaloHits.end(), EcalHitsES->begin(), EcalHitsES->end());
160 for (std::vector<PCaloHit>::iterator isim = theESCaloHits.begin(); isim != theESCaloHits.end(); ++isim) {
161 ESEnergy_ += isim->energy();
165 double etot = EBEnergy_ + EEEnergy_ + ESEnergy_;
171 fracEB = EBEnergy_ / etot;
172 fracEE = EEEnergy_ / etot;
173 fracES = ESEnergy_ / etot;
MonitorElement * meEBEnergyFraction_
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
~EcalSimHitsValidation() override
Destructor.
edm::EDGetTokenT< edm::PCaloHitContainer > EBHitsCollectionToken
edm::EDGetTokenT< edm::HepMCProduct > HepMCToken
MonitorElement * meGunEnergy_
MonitorElement * meGunEta_
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
edm::EDGetTokenT< edm::PCaloHitContainer > EEHitsCollectionToken
EcalSimHitsValidation(const edm::ParameterSet &ps)
Constructor.
Namespace of DDCMS conversion namespace.
edm::EDGetTokenT< edm::PCaloHitContainer > ESHitsCollectionToken
const HepMC::GenEvent * GetEvent() const
MonitorElement * meEEEnergyFraction_
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
MonitorElement * meESEnergyFraction_
void endJob(void) override
MonitorElement * meGunPhi_