62 EcalHit(uint16_t
i = 0,
double t = 0,
double e = 0) : id(
i), time(
t), energy(
e) {}
96 <<
" MaxEnergy: " << maxEnergy_ <<
" Tmax: " <<
tmax_ <<
" Select " <<
selX_;
108 descriptions.
add(
"EcalSimHitStudy", desc);
115 <<
"please add it to config file";
117 sprintf(title,
"Incident PT (GeV)");
119 ptInc_->GetXaxis()->SetTitle(title);
120 ptInc_->GetYaxis()->SetTitle(
"Events");
121 sprintf(title,
"Incident Energy (GeV)");
123 eneInc_->GetXaxis()->SetTitle(title);
124 eneInc_->GetYaxis()->SetTitle(
"Events");
125 sprintf(title,
"Incident #eta");
127 etaInc_->GetXaxis()->SetTitle(title);
128 etaInc_->GetYaxis()->SetTitle(
"Events");
129 sprintf(title,
"Incident #phi");
131 phiInc_->GetXaxis()->SetTitle(title);
132 phiInc_->GetYaxis()->SetTitle(
"Events");
135 sprintf(name,
"Hit%d",
i);
136 sprintf(title,
"Number of hits in %s", dets[
i].c_str());
138 hit_[
i]->GetXaxis()->SetTitle(title);
139 hit_[
i]->GetYaxis()->SetTitle(
"Events");
141 sprintf(name,
"Time%d",
i);
142 sprintf(title,
"Time of the hit (ns) in %s", dets[
i].c_str());
144 time_[
i]->GetXaxis()->SetTitle(title);
145 time_[
i]->GetYaxis()->SetTitle(
"Hits");
147 sprintf(name,
"TimeAll%d",
i);
148 sprintf(title,
"Hit time (ns) in %s (for first hit in the cell)", dets[
i].c_str());
150 timeAll_[
i]->GetXaxis()->SetTitle(title);
151 timeAll_[
i]->GetYaxis()->SetTitle(
"Hits");
153 sprintf(name,
"Edep%d",
i);
154 sprintf(title,
"Energy deposit (GeV) in %s", dets[
i].c_str());
156 edep_[
i]->GetXaxis()->SetTitle(title);
157 edep_[
i]->GetYaxis()->SetTitle(
"Hits");
159 sprintf(name,
"EdepAll%d",
i);
160 sprintf(title,
"Total Energy deposit in the cell (GeV) in %s", dets[
i].c_str());
162 edepAll_[
i]->GetXaxis()->SetTitle(title);
163 edepAll_[
i]->GetYaxis()->SetTitle(
"Hits");
165 sprintf(name,
"EdepEM%d",
i);
166 sprintf(title,
"Energy deposit (GeV) by EM particles in %s", dets[
i].c_str());
168 edepEM_[
i]->GetXaxis()->SetTitle(title);
169 edepEM_[
i]->GetYaxis()->SetTitle(
"Hits");
171 sprintf(name,
"EdepHad%d",
i);
172 sprintf(title,
"Energy deposit (GeV) by hadrons in %s", dets[
i].c_str());
174 edepHad_[
i]->GetXaxis()->SetTitle(title);
175 edepHad_[
i]->GetYaxis()->SetTitle(
"Hits");
177 sprintf(name,
"Etot%d",
i);
178 sprintf(title,
"Total energy deposit (GeV) in %s", dets[
i].c_str());
180 etot_[
i]->GetXaxis()->SetTitle(title);
181 etot_[
i]->GetYaxis()->SetTitle(
"Events");
183 sprintf(name,
"EtotG%d",
i);
184 sprintf(title,
"Total energy deposit (GeV) in %s (t < 100 ns)", dets[
i].c_str());
186 etotg_[
i]->GetXaxis()->SetTitle(title);
187 etotg_[
i]->GetYaxis()->SetTitle(
"Events");
189 sprintf(name,
"r1by9%d",
i);
190 sprintf(title,
"E1/E9 in %s", dets[
i].c_str());
192 r1by9_[
i]->GetXaxis()->SetTitle(title);
193 r1by9_[
i]->GetYaxis()->SetTitle(
"Events");
195 sprintf(name,
"r1by25%d",
i);
196 sprintf(title,
"E1/E25 in %s", dets[
i].c_str());
198 r1by25_[
i]->GetXaxis()->SetTitle(title);
199 r1by25_[
i]->GetYaxis()->SetTitle(
"Events");
201 sprintf(name,
"r9by25%d",
i);
202 sprintf(title,
"E9/E25 in %s", dets[
i].c_str());
204 r9by25_[
i]->GetXaxis()->SetTitle(title);
205 r9by25_[
i]->GetYaxis()->SetTitle(
"Events");
207 double ymax = (
i == 0) ? 0.0005 : 0.005;
208 sprintf(name,
"sEtaEta%d",
i);
209 sprintf(title,
"Cov(#eta,#eta) in %s", dets[
i].c_str());
211 sEtaEta_[
i]->GetXaxis()->SetTitle(title);
212 sEtaEta_[
i]->GetYaxis()->SetTitle(
"Events");
214 sprintf(name,
"sEtaPhi%d",
i);
215 sprintf(title,
"Cov(#eta,#phi) in %s", dets[
i].c_str());
217 sEtaPhi_[
i]->GetXaxis()->SetTitle(title);
218 sEtaPhi_[
i]->GetYaxis()->SetTitle(
"Events");
220 ymax = (
i == 0) ? 0.001 : 0.01;
221 sprintf(name,
"sPhiPhi%d",
i);
222 sprintf(title,
"Cov(#phi,#phi) in %s", dets[
i].c_str());
224 sPhiPhi_[
i]->GetXaxis()->SetTitle(title);
225 sPhiPhi_[
i]->GetYaxis()->SetTitle(
"Events");
243 double eInc = 0, etaInc = 0, phiInc = 0;
244 HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
245 if (p != myGenEvent->particles_end()) {
246 eInc = (*p)->momentum().e();
247 etaInc = (*p)->momentum().eta();
248 phiInc = (*p)->momentum().phi();
250 double ptInc = eInc / std::cosh(etaInc);
268 edm::LogVerbatim(
"HitStudy") <<
"EcalSimHitStudy: Input flags Hits " << getHits <<
" with " << hitsCalo->size()
272 std::vector<PCaloHit> caloHits;
273 caloHits.insert(caloHits.end(), hitsCalo->begin(), hitsCalo->end());
274 if (!caloHits.empty())
282 std::map<unsigned int, EcalHit> hitMap;
283 double etot(0), etotG(0);
284 for (
auto hit : hits) {
285 double edep =
hit.energy();
287 unsigned int id_ =
hit.
id();
288 double edepEM =
hit.energyEM();
289 double edepHad =
hit.energyHad();
291 if ((
hit.depth() == 1) || (
hit.depth() == 2))
295 auto it = hitMap.find(id_);
296 if (it == hitMap.end()) {
297 uint16_t dep =
hit.depth();
298 hitMap[id_] =
EcalHit(dep, time, edep);
300 (it->second).
energy += edep;
305 time_[indx]->Fill(time);
306 edep_[indx]->Fill(edep);
315 for (
auto it : hitMap) {
316 if (it.second.energy > edepM) {
318 edepM = it.second.energy;
325 if ((depM & 0X4) != 0)
326 select = (
selX_ > 0);
328 select = (
selX_ == 0);
331 edm::LogVerbatim(
"HitStudy") <<
"EcalSimHitStudy::analyzeHits: Index " << indx <<
" Emax " << edepM <<
" IDMax " 332 << std::hex << idM <<
":" << depM <<
std::dec <<
" Select " << select <<
":" <<
selX_ 333 <<
" Hits " << hits.size() <<
":" << nEC <<
":" << hitMap.size() <<
" ETotal " << etot
337 etot_[indx]->Fill(etot);
338 etotg_[indx]->Fill(etotG);
339 hit_[indx]->Fill(
double(nEC));
340 for (
auto it : hitMap) {
341 timeAll_[indx]->Fill((it.second).time);
342 edepAll_[indx]->Fill((it.second).energy);
346 std::vector<math::XYZVector>
position;
347 std::vector<double>
energy;
348 double e9(0), e25(0);
349 for (
auto it : hitMap) {
351 int deta(99), dphi(99),
dz(0);
363 if (deta <= 1 && dphi <= 1 && dz < 1)
364 e9 += (it.second).energy;
365 if (deta <= 2 && dphi <= 2 && dz < 1) {
366 e25 += (it.second).energy;
369 meanPosition += (it.second).energy *
pos;
370 position.push_back(
pos);
371 energy.push_back((it.second).energy);
374 double r1by9 = (e9 > 0) ? (edepM / e9) : -1;
375 double r1by25 = (e25 > 0) ? (edepM / e25) : -1;
376 double r9by25 = (e25 > 0) ? (e9 / e25) : -1;
379 double denom(0), numEtaEta(0), numEtaPhi(0), numPhiPhi(0);
380 for (
unsigned int k = 0;
k < position.size(); ++
k) {
381 double dEta = position[
k].eta() - meanPosition.eta();
382 double dPhi = position[
k].phi() - meanPosition.phi();
392 numEtaEta +=
std::abs(w * dEta * dEta);
393 numEtaPhi +=
std::abs(w * dEta * dPhi);
394 numPhiPhi +=
std::abs(w * dPhi * dPhi);
396 edm::LogVerbatim(
"HitStudy") <<
"[" <<
k <<
"] dEta " << dEta <<
" dPhi " << dPhi <<
" Wt " << energy[
k] / e25
397 <<
":" <<
std::log(energy[
k] / e25) <<
":" <<
w;
400 double sEtaEta = (
denom > 0) ? (numEtaEta /
denom) : -1.0;
401 double sEtaPhi = (
denom > 0) ? (numEtaPhi /
denom) : -1.0;
402 double sPhiPhi = (
denom > 0) ? (numPhiPhi /
denom) : -1.0;
405 edm::LogVerbatim(
"HitStudy") <<
"EcalSimHitStudy::Ratios " << r1by9 <<
" : " << r1by25 <<
" : " << r9by25
406 <<
" Covariances " << sEtaEta <<
" : " << sEtaPhi <<
" : " << sPhiPhi;
408 r1by9_[indx]->Fill(r1by9);
static const std::string kSharedResource
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const CaloGeometry * geometry_
T * make(const Args &...args) const
make new ROOT object
EcalSimHitStudy(const edm::ParameterSet &ps)
void beginRun(edm::Run const &, edm::EventSetup const &) override
#define DEFINE_FWK_MODULE(type)
void analyze(edm::Event const &, edm::EventSetup const &) override
Abs< T >::type abs(const T &t)
void endRun(edm::Run const &, edm::EventSetup const &) override
void analyzeHits(std::vector< PCaloHit > &, int)
const HepMC::GenEvent * GetEvent() const
std::string hitLab_[ndets_]
XYZVectorD XYZVector
spatial vector with cartesian internal representation
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< edm::HepMCProduct > tok_evt_
select
when omitted electron plots will be filled w/o cut on electronId electronId = cms.PSet( src = cms.InputTag("mvaTrigV0"), cutValue = cms.double(0.5) ), when omitted electron plots will be filled w/o additional pre- selection of the electron candidates
edm::EDGetTokenT< edm::PCaloHitContainer > toks_calo_[2]
static int position[264][3]
EcalHit(uint16_t i=0, double t=0, double e=0)
std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
~EcalSimHitStudy() override
T const * product() const