99 <<
" MaxEnergy: " << maxEnergy_ <<
" Tmax: " <<
tmax_ <<
" Select " <<
selX_;
111 descriptions.
add(
"EcalSimHitStudy", desc);
118 <<
"please add it to config file";
120 sprintf(title,
"Incident PT (GeV)");
122 ptInc_->GetXaxis()->SetTitle(title);
123 ptInc_->GetYaxis()->SetTitle(
"Events");
124 sprintf(title,
"Incident Energy (GeV)");
126 eneInc_->GetXaxis()->SetTitle(title);
127 eneInc_->GetYaxis()->SetTitle(
"Events");
128 sprintf(title,
"Incident #eta");
130 etaInc_->GetXaxis()->SetTitle(title);
131 etaInc_->GetYaxis()->SetTitle(
"Events");
132 sprintf(title,
"Incident #phi");
134 phiInc_->GetXaxis()->SetTitle(title);
135 phiInc_->GetYaxis()->SetTitle(
"Events");
138 sprintf(name,
"Hit%d",
i);
139 sprintf(title,
"Number of hits in %s", dets[
i].c_str());
140 hit_[
i] = tfile->
make<TH1F>(
name, dets[
i].c_str(), 1000, 0., 20000.);
141 hit_[
i]->GetXaxis()->SetTitle(title);
142 hit_[
i]->GetYaxis()->SetTitle(
"Events");
144 sprintf(name,
"Time%d",
i);
145 sprintf(title,
"Time of the hit (ns) in %s", dets[
i].c_str());
147 time_[
i]->GetXaxis()->SetTitle(title);
148 time_[
i]->GetYaxis()->SetTitle(
"Hits");
150 sprintf(name,
"TimeAll%d",
i);
151 sprintf(title,
"Hit time (ns) in %s (for first hit in the cell)", dets[
i].c_str());
153 timeAll_[
i]->GetXaxis()->SetTitle(title);
154 timeAll_[
i]->GetYaxis()->SetTitle(
"Hits");
156 sprintf(name,
"Edep%d",
i);
157 sprintf(title,
"Energy deposit (GeV) in %s", dets[
i].c_str());
159 edep_[
i]->GetXaxis()->SetTitle(title);
160 edep_[
i]->GetYaxis()->SetTitle(
"Hits");
162 sprintf(name,
"EdepAll%d",
i);
163 sprintf(title,
"Total Energy deposit in the cell (GeV) in %s", dets[
i].c_str());
165 edepAll_[
i]->GetXaxis()->SetTitle(title);
166 edepAll_[
i]->GetYaxis()->SetTitle(
"Hits");
168 sprintf(name,
"EdepEM%d",
i);
169 sprintf(title,
"Energy deposit (GeV) by EM particles in %s", dets[
i].c_str());
171 edepEM_[
i]->GetXaxis()->SetTitle(title);
172 edepEM_[
i]->GetYaxis()->SetTitle(
"Hits");
174 sprintf(name,
"EdepHad%d",
i);
175 sprintf(title,
"Energy deposit (GeV) by hadrons in %s", dets[
i].c_str());
177 edepHad_[
i]->GetXaxis()->SetTitle(title);
178 edepHad_[
i]->GetYaxis()->SetTitle(
"Hits");
180 sprintf(name,
"Etot%d",
i);
181 sprintf(title,
"Total energy deposit (GeV) in %s", dets[
i].c_str());
183 etot_[
i]->GetXaxis()->SetTitle(title);
184 etot_[
i]->GetYaxis()->SetTitle(
"Events");
186 sprintf(name,
"EtotG%d",
i);
187 sprintf(title,
"Total energy deposit (GeV) in %s (t < 100 ns)", dets[
i].c_str());
189 etotg_[
i]->GetXaxis()->SetTitle(title);
190 etotg_[
i]->GetYaxis()->SetTitle(
"Events");
192 sprintf(name,
"r1by9%d",
i);
193 sprintf(title,
"E1/E9 in %s", dets[
i].c_str());
195 r1by9_[
i]->GetXaxis()->SetTitle(title);
196 r1by9_[
i]->GetYaxis()->SetTitle(
"Events");
198 sprintf(name,
"r1by25%d",
i);
199 sprintf(title,
"E1/E25 in %s", dets[
i].c_str());
201 r1by25_[
i]->GetXaxis()->SetTitle(title);
202 r1by25_[
i]->GetYaxis()->SetTitle(
"Events");
204 sprintf(name,
"r9by25%d",
i);
205 sprintf(title,
"E9/E25 in %s", dets[
i].c_str());
207 r9by25_[
i]->GetXaxis()->SetTitle(title);
208 r9by25_[
i]->GetYaxis()->SetTitle(
"Events");
210 double ymax = (
i == 0) ? 0.0005 : 0.005;
211 sprintf(name,
"sEtaEta%d",
i);
212 sprintf(title,
"Cov(#eta,#eta) in %s", dets[
i].c_str());
214 sEtaEta_[
i]->GetXaxis()->SetTitle(title);
215 sEtaEta_[
i]->GetYaxis()->SetTitle(
"Events");
217 sprintf(name,
"sEtaPhi%d",
i);
218 sprintf(title,
"Cov(#eta,#phi) in %s", dets[
i].c_str());
220 sEtaPhi_[
i]->GetXaxis()->SetTitle(title);
221 sEtaPhi_[
i]->GetYaxis()->SetTitle(
"Events");
223 ymax = (
i == 0) ? 0.001 : 0.01;
224 sprintf(name,
"sPhiPhi%d",
i);
225 sprintf(title,
"Cov(#phi,#phi) in %s", dets[
i].c_str());
227 sPhiPhi_[
i]->GetXaxis()->SetTitle(title);
228 sPhiPhi_[
i]->GetYaxis()->SetTitle(
"Events");
231 sprintf(title,
"%s+", dets[
i].c_str());
233 poszp_[
i]->GetXaxis()->SetTitle(
"i#eta");
234 poszp_[
i]->GetYaxis()->SetTitle(
"i#phi");
235 sprintf(title,
"%s-", dets[
i].c_str());
237 poszn_[
i]->GetXaxis()->SetTitle(
"i#eta");
238 poszn_[
i]->GetYaxis()->SetTitle(
"i#phi");
240 sprintf(title,
"%s+", dets[
i].c_str());
241 poszp_[
i] = tfile->
make<TH2F>(
"poszp1",
title, 100, -200, 200, 100, -200, 200);
242 poszp_[
i]->GetXaxis()->SetTitle(
"x (cm)");
243 poszp_[
i]->GetYaxis()->SetTitle(
"y (cm)");
244 sprintf(title,
"%s-", dets[
i].c_str());
245 poszn_[
i] = tfile->
make<TH2F>(
"poszn1",
title, 100, -200, 200, 100, -200, 200);
246 poszn_[
i]->GetXaxis()->SetTitle(
"x (cm)");
247 poszn_[
i]->GetYaxis()->SetTitle(
"y (cm)");
249 poszp_[
i]->GetYaxis()->SetTitleOffset(1.2);
251 poszn_[
i]->GetYaxis()->SetTitleOffset(1.2);
263 double eInc = 0, etaInc = 0, phiInc = 0;
270 HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
271 if (p != myGenEvent->particles_end()) {
272 eInc = (*p)->momentum().e();
273 etaInc = (*p)->momentum().eta();
274 phiInc = (*p)->momentum().phi();
276 double ptInc = eInc / std::cosh(etaInc);
288 int typeMin = (type < 0) ? 0 : type;
289 int typeMax = (type < 0) ? 1 : type;
290 for (
int type = typeMin; type <= typeMax; ++
type) {
293 bool getHits = (hitsCalo.
isValid());
295 edm::LogVerbatim(
"HitStudy") <<
"EcalSimHitStudy: Input flags Hits " << getHits <<
" with " << hitsCalo->size()
299 std::vector<PCaloHit> caloHits;
300 caloHits.insert(caloHits.end(), hitsCalo->begin(), hitsCalo->end());
301 if (!caloHits.empty())
309 std::map<unsigned int, EcalHit> hitMap;
310 double etot(0), etotG(0);
311 for (
auto hit : hits) {
312 double edep =
hit.energy();
313 double time =
hit.time();
314 unsigned int id_ =
hit.
id();
315 double edepEM =
hit.energyEM();
316 double edepHad =
hit.energyHad();
318 if ((
hit.depth() == 1) || (
hit.depth() == 2))
322 auto it = hitMap.find(id_);
323 if (it == hitMap.end()) {
324 uint16_t dep =
hit.depth();
325 hitMap[id_] =
EcalHit(dep, time, edep);
327 (it->second).
energy += edep;
332 time_[indx]->Fill(time);
333 edep_[indx]->Fill(edep);
342 for (
auto it : hitMap) {
343 if (it.second.energy > edepM) {
345 edepM = it.second.energy;
352 if ((depM & 0X4) != 0)
353 select = (
selX_ > 0);
355 select = (
selX_ == 0);
358 edm::LogVerbatim(
"HitStudy") <<
"EcalSimHitStudy::analyzeHits: Index " << indx <<
" Emax " << edepM <<
" IDMax "
359 << std::hex << idM <<
":" << depM <<
std::dec <<
" Select " << select <<
":" <<
selX_
360 <<
" Hits " << hits.size() <<
":" << nEC <<
":" << hitMap.size() <<
" ETotal " << etot
364 etot_[indx]->Fill(etot);
365 etotg_[indx]->Fill(etotG);
366 hit_[indx]->Fill(
double(nEC));
367 for (
auto it : hitMap) {
368 timeAll_[indx]->Fill((it.second).time);
369 edepAll_[indx]->Fill((it.second).energy);
379 poszp_[indx]->Fill(gpos.
x(), gpos.
y());
381 poszn_[indx]->Fill(gpos.
x(), gpos.
y());
386 std::vector<math::XYZVector>
position;
387 std::vector<double>
energy;
388 double e9(0), e25(0);
389 for (
auto it : hitMap) {
391 int deta(99), dphi(99),
dz(0);
403 if (deta <= 1 && dphi <= 1 && dz < 1)
404 e9 += (it.second).energy;
405 if (deta <= 2 && dphi <= 2 && dz < 1) {
406 e25 += (it.second).energy;
409 meanPosition += (it.second).energy * pos;
410 position.push_back(pos);
411 energy.push_back((it.second).energy);
414 double r1by9 = (e9 > 0) ? (edepM / e9) : -1;
415 double r1by25 = (e25 > 0) ? (edepM / e25) : -1;
416 double r9by25 = (e25 > 0) ? (e9 / e25) : -1;
419 double denom(0), numEtaEta(0), numEtaPhi(0), numPhiPhi(0);
420 for (
unsigned int k = 0;
k < position.size(); ++
k) {
421 double dEta = position[
k].eta() - meanPosition.eta();
422 double dPhi = position[
k].phi() - meanPosition.phi();
424 dPhi = 2 *
M_PI - dPhi;
427 dPhi = 2 *
M_PI + dPhi;
432 numEtaEta +=
std::abs(w * dEta * dEta);
433 numEtaPhi +=
std::abs(w * dEta * dPhi);
434 numPhiPhi +=
std::abs(w * dPhi * dPhi);
436 edm::LogVerbatim(
"HitStudy") <<
"[" <<
k <<
"] dEta " << dEta <<
" dPhi " << dPhi <<
" Wt " << energy[
k] / e25
437 <<
":" <<
std::log(energy[
k] / e25) <<
":" <<
w;
440 double sEtaEta = (
denom > 0) ? (numEtaEta /
denom) : -1.0;
441 double sEtaPhi = (
denom > 0) ? (numEtaPhi /
denom) : -1.0;
442 double sPhiPhi = (
denom > 0) ? (numPhiPhi /
denom) : -1.0;
445 edm::LogVerbatim(
"HitStudy") <<
"EcalSimHitStudy::Ratios " << r1by9 <<
" : " << r1by25 <<
" : " << r9by25
446 <<
" Covariances " << sEtaEta <<
" : " << sEtaPhi <<
" : " << sPhiPhi;
448 r1by9_[indx]->Fill(r1by9);
static const std::string kSharedResource
Log< level::Info, true > LogVerbatim
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
static std::vector< std::string > checklist log
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
uint16_t *__restrict__ id
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const CaloGeometry * geometry_
#define DEFINE_FWK_MODULE(type)
T * make(const Args &...args) const
make new ROOT object
EcalSimHitStudy(const edm::ParameterSet &ps)
void beginRun(edm::Run const &, edm::EventSetup const &) override
bool getData(T &iHolder) const
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
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > tokGeom_
void analyzeHits(std::vector< PCaloHit > &, int)
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_
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