21 g4InfoLabel(ps.getParameter<
std::
string>(
"moduleLabelG4")),
31 if ( !outputFile_.empty() ) {
32 edm::LogInfo(
"OutputInfo") <<
" Ecal SimHits Task histograms will be saved to " << outputFile_.c_str();
34 edm::LogInfo(
"OutputInfo") <<
" Ecal SimHits Task histograms will NOT be saved";
46 if (
verbose_ ) { dbe_->setVerbose(1); }
47 else { dbe_->setVerbose(0); }
51 if (
verbose_ ) dbe_->showDirStructure();
65 dbe_->setCurrentFolder(
"EcalHitsV/EcalSimHitsValidation");
67 sprintf (histo,
"EcalSimHitsValidation Gun Momentum" ) ;
68 meGunEnergy_ = dbe_->book1D(histo, histo, 100, 0., 1000.);
70 sprintf (histo,
"EcalSimHitsValidation Gun Eta" ) ;
71 meGunEta_ = dbe_->book1D(histo, histo, 700, -3.5, 3.5);
73 sprintf (histo,
"EcalSimHitsValidation Gun Phi" ) ;
74 meGunPhi_ = dbe_->book1D(histo, histo, 360, 0., 360.);
76 sprintf (histo,
"EcalSimHitsValidation Barrel fraction of energy" ) ;
79 sprintf (histo,
"EcalSimHitsValidation Endcap fraction of energy" ) ;
82 sprintf (histo,
"EcalSimHitsValidation Preshower fraction of energy" ) ;
106 std::vector<PCaloHit> theEBCaloHits;
107 std::vector<PCaloHit> theEECaloHits;
108 std::vector<PCaloHit> theESCaloHits;
120 for ( HepMC::GenEvent::particle_const_iterator
p = MCEvt->
GetEvent()->particles_begin();
121 p != MCEvt->
GetEvent()->particles_end(); ++
p ) {
123 double htheta = (*p)->momentum().theta();
124 double heta = -99999.;
125 if(
tan(htheta * 0.5) > 0 ) {
126 heta = -
log(
tan(htheta * 0.5));
128 double hphi = (*p)->momentum().phi();
129 hphi = (hphi>=0) ? hphi : hphi+2*
M_PI;
130 hphi = hphi /
M_PI * 180.;
132 LogDebug(
"EventInfo") <<
"Particle gun type form MC = " <<
abs((*p)->pdg_id()) <<
"\n" <<
"Energy = "<< (*p)->momentum().e() <<
" Eta = " << heta <<
" Phi = " << hphi;
140 double EBEnergy_ = 0.;
142 theEBCaloHits.insert(theEBCaloHits.end(), EcalHitsEB->begin(), EcalHitsEB->end());
143 for (std::vector<PCaloHit>::iterator isim = theEBCaloHits.begin();
144 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();
153 isim != theEECaloHits.end(); ++isim){
154 EEEnergy_ += isim->energy();
158 double ESEnergy_ = 0.;
160 theESCaloHits.insert(theESCaloHits.end(), EcalHitsES->begin(), EcalHitsES->end());
161 for (std::vector<PCaloHit>::iterator isim = theESCaloHits.begin();
162 isim != theESCaloHits.end(); ++isim){
163 ESEnergy_ += isim->energy();
167 double etot = EBEnergy_ + EEEnergy_ + ESEnergy_ ;
173 fracEB = EBEnergy_/etot;
174 fracEE = EEEnergy_/etot;
175 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.
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_