20 HepMCLabel(ps.getParameter<std::string>(
"moduleLabelMC")),
21 g4InfoLabel(ps.getParameter<std::string>(
"moduleLabelG4")),
22 EBHitsCollection(ps.getParameter<std::string>(
"EBHitsCollection")),
23 EEHitsCollection(ps.getParameter<std::string>(
"EEHitsCollection")),
24 ESHitsCollection(ps.getParameter<std::string>(
"ESHitsCollection")){
32 edm::LogInfo(
"OutputInfo") <<
" Ecal SimHits Task histograms will NOT be saved";
44 if (
verbose_ ) { dbe_->setVerbose(1); }
45 else { dbe_->setVerbose(0); }
49 if (
verbose_ ) dbe_->showDirStructure();
63 dbe_->setCurrentFolder(
"EcalHitsV/EcalSimHitsValidation");
65 sprintf (histo,
"EcalSimHitsValidation Gun Momentum" ) ;
66 meGunEnergy_ = dbe_->book1D(histo, histo, 100, 0., 1000.);
68 sprintf (histo,
"EcalSimHitsValidation Gun Eta" ) ;
69 meGunEta_ = dbe_->book1D(histo, histo, 700, -3.5, 3.5);
71 sprintf (histo,
"EcalSimHitsValidation Gun Phi" ) ;
72 meGunPhi_ = dbe_->book1D(histo, histo, 360, 0., 360.);
74 sprintf (histo,
"EcalSimHitsValidation Barrel fraction of energy" ) ;
77 sprintf (histo,
"EcalSimHitsValidation Endcap fraction of energy" ) ;
80 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();
119 p != MCEvt->GetEvent()->particles_end(); ++
p ) {
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" <<
"Energy = "<< (*p)->momentum().e() <<
" Eta = " << heta <<
" Phi = " << hphi;
138 double EBEnergy_ = 0.;
140 theEBCaloHits.insert(theEBCaloHits.end(), EcalHitsEB->begin(), EcalHitsEB->end());
141 for (std::vector<PCaloHit>::iterator isim = theEBCaloHits.begin();
142 isim != theEBCaloHits.end(); ++isim){
143 EBEnergy_ += isim->energy();
147 double EEEnergy_ = 0.;
149 theEECaloHits.insert(theEECaloHits.end(), EcalHitsEE->begin(), EcalHitsEE->end());
150 for (std::vector<PCaloHit>::iterator isim = theEECaloHits.begin();
151 isim != theEECaloHits.end(); ++isim){
152 EEEnergy_ += isim->energy();
156 double ESEnergy_ = 0.;
158 theESCaloHits.insert(theESCaloHits.end(), EcalHitsES->begin(), EcalHitsES->end());
159 for (std::vector<PCaloHit>::iterator isim = theESCaloHits.begin();
160 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_
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
std::string EBHitsCollection
std::string EEHitsCollection
MonitorElement * meGunEnergy_
MonitorElement * meGunEta_
Tan< T >::type tan(const T &t)
EcalSimHitsValidation(const edm::ParameterSet &ps)
Constructor.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
MonitorElement * meEEEnergyFraction_
std::string ESHitsCollection
MonitorElement * meESEnergyFraction_
~EcalSimHitsValidation()
Destructor.
MonitorElement * meGunPhi_