31 #include "CLHEP/Geometry/Point3D.h"
32 #include "CLHEP/Geometry/Transform3D.h"
33 #include "CLHEP/Geometry/Vector3D.h"
34 #include "CLHEP/Units/GlobalSystemOfUnits.h"
35 #include "CLHEP/Units/GlobalPhysicalConstants.h"
71 std::map<std::pair<int, int>, TH1D*>
h_phi_;
79 caloHitSource_(iConfig.getParameter<std::
string>(
"caloHitSource")),
80 ietaMin_(iConfig.getUntrackedParameter<int>(
"ietaMin", -41)),
81 ietaMax_(iConfig.getUntrackedParameter<int>(
"ietaMax", 41)),
82 depthMax_(iConfig.getUntrackedParameter<int>(
"depthMax", 7)),
83 rmin_(iConfig.getUntrackedParameter<double>(
"rMin", 0.0)),
84 rmax_(iConfig.getUntrackedParameter<double>(
"rMax", 5500.0)),
85 zmin_(iConfig.getUntrackedParameter<double>(
"zMin", -12500.0)),
86 zmax_(iConfig.getUntrackedParameter<double>(
"zMax", 12500.0)),
87 nbinR_(iConfig.getUntrackedParameter<int>(
"nBinR", 550)),
88 nbinZ_(iConfig.getUntrackedParameter<int>(
"nBinZ", 2500)),
89 verbosity_(iConfig.getUntrackedParameter<int>(
"verbosity", 0)) {
92 tok_HRNDC_ = esConsumes<HcalDDDRecConstants, HcalRecNumberingRecord, edm::Transition::BeginRun>();
108 descriptions.
add(
"hcalGeomCheck", desc);
115 if (theCaloHitContainer.
isValid()) {
117 edm::LogVerbatim(
"HcalValidation") <<
" PcalohitItr = " << theCaloHitContainer->size();
120 std::map<HcalDetId, hitsinfo> map_hits;
121 unsigned int nused(0);
122 for (
auto const&
hit : *(theCaloHitContainer.
product())) {
123 unsigned int id =
hit.
id();
126 double time =
hit.time();
127 int subdet = detId.
subdet();
128 int ieta = detId.
ieta();
129 int iphi = detId.
iphi();
134 edm::LogVerbatim(
"HcalValidation") <<
"i/p " << subdet <<
":" << ieta <<
":" << iphi <<
":" << depth <<
" o/p "
135 << etaphi.first <<
":" << etaphi.second <<
":" << rz;
136 HepGeom::Point3D<float> gcoord = HepGeom::Point3D<float>(rz *
cos(etaphi.second) / cosh(etaphi.first),
137 rz *
sin(etaphi.second) / cosh(etaphi.first),
138 rz * tanh(etaphi.first));
140 double tof = (gcoord.mag() * CLHEP::mm) / CLHEP::c_light;
143 <<
"Detector " << subdet <<
" ieta = " << ieta <<
" iphi = " << iphi <<
" depth = " << depth
144 <<
" positon = " << gcoord <<
" energy = " << energy <<
" time = " << time <<
":" << tof;
149 if (map_hits.count(detId) != 0) {
150 hinfo = map_hits[detId];
152 hinfo.
phi = gcoord.getPhi();
153 hinfo.
eta = gcoord.getEta();
157 map_hits[detId] = hinfo;
159 h_RZ_->Fill(gcoord.z(), gcoord.rho());
163 for (
auto const&
hit : map_hits) {
165 int subdet =
hit.first.subdet();
166 if (subdet > 0 && subdet < static_cast<int>(
h_E_.size())) {
168 int ieta =
hit.first.ieta();
169 int iphi =
hit.first.iphi();
172 <<
" ---------------------- eta = " << ieta <<
":" << hinfo.
eta <<
" phi = " << iphi <<
":" << hinfo.
phi
173 <<
" depth = " << depth <<
" E = " << hinfo.
energy <<
" T = " << hinfo.
time;
176 auto itr1 =
h_phi_.find(std::pair<int, int>(ieta, depth));
178 itr1->second->Fill(iphi);
179 auto itr2 =
h_eta_.find(depth);
181 itr2->second->Fill(ieta);
195 edm::LogVerbatim(
"HcalValidation") <<
"Obtain HcalDDDRecConstants from Event Setup";
204 edm::LogVerbatim(
"HcalValidation") <<
"HcalGeomCheck: booked scatterplot RZ";
208 sprintf(name,
"phi%d%d", ieta,
depth);
209 sprintf(title,
"i#phi (i#eta = %d, depth = %d)", ieta,
depth);
210 h_phi_[std::pair<int, int>(ieta,
depth)] = fs->
make<TH1D>(name, title, 400, -20, 380);
214 sprintf(name,
"eta%d",
depth);
215 sprintf(title,
"i#eta (depth = %d)",
depth);
221 std::vector<std::string> dets = {
"HCAL",
"HB",
"HE",
"HF",
"HO"};
222 for (
unsigned int ih = 0; ih < dets.size(); ++ih) {
223 sprintf(name,
"E_%s", dets[ih].c_str());
224 sprintf(title,
"Energy deposit in %s (MeV)", dets[ih].c_str());
225 h_E_.emplace_back(fs->
make<TH1D>(name, title, 1000, 0.0, 1.0));
228 sprintf(name,
"T_%s", dets[ih].c_str());
229 sprintf(title,
"Time of hit in %s (ns)", dets[ih].c_str());
230 h_T_.emplace_back(fs->
make<TH1D>(name, title, 1000, 0.0, 200.0));
std::pair< T, T > etaphi(T x, T y, T z)
static const std::string kSharedResource
Log< level::Info, true > LogVerbatim
std::vector< TH1D * > h_T_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::pair< double, double > getEtaPhi(const int &subdet, const int &ieta, const int &iphi) const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hits_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
Sin< T >::type sin(const T &t)
T * make(const Args &...args) const
make new ROOT object
void beginRun(edm::Run const &, edm::EventSetup const &) override
const HcalDDDRecConstants * hcons_
bool getData(T &iHolder) const
void analyze(edm::Event const &, edm::EventSetup const &) override
constexpr HcalSubdetector subdet() const
get the subdetector
constexpr int iphi() const
get the cell iphi
std::map< std::pair< int, int >, TH1D * > h_phi_
void analyzeHits(int, const std::string &, const std::vector< PCaloHit > &)
double getRZ(const int &subdet, const int &ieta, const int &depth) const
std::map< int, TH1D * > h_eta_
Cos< T >::type cos(const T &t)
constexpr int ieta() const
get the cell ieta
std::vector< TH1D * > h_E_
void endRun(edm::Run const &, edm::EventSetup const &) override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
~HcalGeomCheck() override
T const * product() const
edm::ESGetToken< HcalDDDRecConstants, HcalRecNumberingRecord > tok_HRNDC_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const std::string caloHitSource_
DetId relabel(const uint32_t testId) const
constexpr int depth() const
get the tower depth
HcalGeomCheck(const edm::ParameterSet &)