34 #include "CLHEP/Geometry/Point3D.h"
35 #include "CLHEP/Geometry/Transform3D.h"
36 #include "CLHEP/Geometry/Vector3D.h"
37 #include "CLHEP/Units/GlobalSystemOfUnits.h"
38 #include "CLHEP/Units/GlobalPhysicalConstants.h"
73 std::vector<edm::ESGetToken<HGCalDDDConstants, IdealGeometryRecord> >
tok_hgcGeom_;
74 std::vector<const HGCalDDDConstants*>
hgcons_;
75 std::vector<edm::EDGetTokenT<edm::PCaloHitContainer> >
tok_hits_;
85 : nameDetectors_(iConfig.getParameter<std::
vector<std::
string> >(
"detectorNames")),
86 caloHitSources_(iConfig.getParameter<std::
vector<std::
string> >(
"caloHitSources")),
87 rmin_(iConfig.getUntrackedParameter<double>(
"rMin", 0.0)),
88 rmax_(iConfig.getUntrackedParameter<double>(
"rMax", 3000.0)),
89 zmin_(iConfig.getUntrackedParameter<double>(
"zMin", 3000.0)),
90 zmax_(iConfig.getUntrackedParameter<double>(
"zMax", 6000.0)),
91 etamin_(iConfig.getUntrackedParameter<double>(
"etaMin", 1.0)),
92 etamax_(iConfig.getUntrackedParameter<double>(
"etaMax", 3.0)),
93 nbinR_(iConfig.getUntrackedParameter<int>(
"nBinR", 300)),
94 nbinZ_(iConfig.getUntrackedParameter<int>(
"nBinZ", 300)),
95 nbinEta_(iConfig.getUntrackedParameter<int>(
"nBinEta", 200)),
96 nLayers_(iConfig.getUntrackedParameter<int>(
"layers", 50)),
97 verbosity_(iConfig.getUntrackedParameter<int>(
"verbosity", 0)),
98 ifNose_(iConfig.getUntrackedParameter<bool>(
"ifNose",
false)),
99 ifLayer_(iConfig.getUntrackedParameter<bool>(
"ifLayer",
false)) {
104 esConsumes<HGCalDDDConstants, IdealGeometryRecord, edm::Transition::BeginRun>(
edm::ESInputTag{
"",
name}));
111 std::vector<std::string>
names = {
"HGCalEESensitive",
"HGCalHESiliconSensitive",
"HGCalHEScintillatorSensitive"};
112 std::vector<std::string> sources = {
"HGCHitsEE",
"HGCHitsHEfront",
"HGCHitsHEback"};
113 desc.
add<std::vector<std::string> >(
"detectorNames",
names);
114 desc.
add<std::vector<std::string> >(
"caloHitSources", sources);
128 descriptions.
add(
"hgcalSimHitStudy", desc);
136 if (theCaloHitContainers.
isValid()) {
138 edm::LogVerbatim(
"HGCalValidation") <<
" PcalohitItr = " << theCaloHitContainers->size();
139 std::vector<PCaloHit> caloHits;
140 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), theCaloHitContainers->end());
151 edm::LogVerbatim(
"HGCalValidation") << name <<
" with " << hits.size() <<
" PcaloHit elements";
153 std::map<uint32_t, hitsinfo> map_hits;
156 unsigned int nused(0);
157 for (
auto const&
hit : hits) {
159 double time =
hit.time();
160 uint32_t
id =
hit.
id();
162 int subdet(0), cell2(0),
type(0);
163 HepGeom::Point3D<float> gcoord;
164 std::pair<float, float>
xy;
168 cell = detId.
cellU();
169 cell2 = detId.
cellV();
173 layer = detId.
layer();
174 zside = detId.
zside();
175 xy =
hgcons_[ih]->locateCell(layer, sector, sector2, cell, cell2,
false,
true);
176 h_W2_[ih]->Fill(sector2);
177 h_C2_[ih]->Fill(cell2);
178 }
else if (
hgcons_[ih]->waferHexagon8()) {
180 subdet =
static_cast<int>(detId.
det());
181 cell = detId.
cellU();
182 cell2 = detId.
cellV();
186 layer = detId.
layer();
187 zside = detId.
zside();
188 xy =
hgcons_[ih]->locateCell(layer, sector, sector2, cell, cell2,
false,
true);
189 h_W2_[ih]->Fill(sector2);
190 h_C2_[ih]->Fill(cell2);
191 }
else if (
hgcons_[ih]->tileTrapezoid()) {
193 subdet =
static_cast<int>(detId.
det());
194 sector = detId.
ieta();
197 layer = detId.
layer();
198 zside = detId.
zside();
199 xy =
hgcons_[ih]->locateCellTrap(layer, sector, cell,
false);
202 xy =
hgcons_[ih]->locateCell(cell, layer, sector,
false);
204 double zp =
hgcons_[ih]->waferZ(layer,
false);
207 double xp = (zp < 0) ? -xy.first : xy.first;
208 gcoord = HepGeom::Point3D<float>(xp, xy.second, zp);
211 <<
"i/p " << subdet <<
":" << zside <<
":" << layer <<
":" << sector <<
":" << sector2 <<
":" << cell <<
":"
212 << cell2 <<
" o/p " << xy.first <<
":" << xy.second <<
":" << zp;
214 double tof = (gcoord.mag() * CLHEP::mm) / CLHEP::c_light;
217 <<
"Detector " << name <<
" zside = " << zside <<
" layer = " << layer <<
" type = " << type
218 <<
" wafer = " << sector <<
":" << sector2 <<
" cell = " << cell <<
":" << cell2 <<
" positon = " << gcoord
219 <<
" energy = " << energy <<
" time = " << time <<
":" << tof;
224 if (map_hits.count(
id) != 0) {
225 hinfo = map_hits[
id];
228 hinfo.
phi = gcoord.getPhi();
229 hinfo.
eta = gcoord.getEta();
233 map_hits[
id] = hinfo;
239 if (hinfo.
layer <= static_cast<int>(
h_XY_.size()))
240 h_XY_[hinfo.
layer - 1]->Fill(gcoord.x(), gcoord.y());
245 h_Ly_[ih]->Fill(layer);
246 h_W1_[ih]->Fill(sector);
247 h_C1_[ih]->Fill(cell);
250 edm::LogVerbatim(
"HGCalValidation") << name <<
" with " << map_hits.size() <<
":" << nused <<
" detector elements"
253 for (
auto const&
hit : map_hits) {
257 <<
" ---------------------- eta = " << hinfo.
eta <<
" phi = " << hinfo.
phi <<
" layer = " << hinfo.
layer
258 <<
" E = " << hinfo.
energy <<
" T = " << hinfo.
time;
301 name <<
"RZ_AllDetectors";
302 title <<
"R vs Z for All Detectors";
305 title <<
"R vs Z for " << nameDetectors_[ih - 1];
311 for (
int ly = 0; ly <
nLayers_; ++ly) {
314 name <<
"XY_L" << (ly + 1);
315 title <<
"Y vs X at Layer " << (ly + 1);
324 name <<
"EtaPhi_AllDetectors";
325 title <<
"#phi vs #eta for All Detectors";
328 title <<
"#phi vs #eta for " << nameDetectors_[ih - 1];
335 name <<
"EtFiZp_AllDetectors";
336 title <<
"#phi vs #eta (+z) for All Detectors";
339 title <<
"#phi vs #eta (+z) for " << nameDetectors_[ih - 1];
346 name <<
"EtFiZm_AllDetectors";
347 title <<
"#phi vs #eta (-z) for All Detectors";
350 title <<
"#phi vs #eta (-z) for " << nameDetectors_[ih - 1];
358 name <<
"LayerZp_AllDetectors";
359 title <<
"Energy vs Layer (+z) for All Detectors";
362 title <<
"Energy vs Layer (+z) for " << nameDetectors_[ih - 1];
364 h_LayerZp_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 60, 0.0, 60.0));
368 name <<
"LayerZm_AllDetectors";
369 title <<
"Energy vs Layer (-z) for All Detectors";
372 title <<
"Energy vs Layer (-z) for " << nameDetectors_[ih - 1];
374 h_LayerZm_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 60, 0.0, 60.0));
379 name <<
"E_AllDetectors";
380 title <<
"Energy Deposit for All Detectors";
383 title <<
"Energy Deposit for " << nameDetectors_[ih - 1];
385 h_E_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 1000, 0.0, 1.0));
390 name <<
"T_AllDetectors";
391 title <<
"Time for All Detectors";
394 title <<
"Time for " << nameDetectors_[ih - 1];
396 h_T_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 1000, 0.0, 200.0));
403 title <<
"Layer number for " << nameDetectors_[ih];
404 h_Ly_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 200, 0, 100));
405 if (nameDetectors_[ih] ==
"HGCalHEScintillatorSensitive") {
408 name <<
"IR_" << nameDetectors_[ih];
409 title <<
"Radius index for " << nameDetectors_[ih];
410 h_W1_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 200, -50, 50));
413 name <<
"FI_" << nameDetectors_[ih];
414 title <<
"#phi index for " << nameDetectors_[ih];
415 h_C1_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 720, 0, 360));
419 name <<
"WU_" << nameDetectors_[ih];
420 title <<
"u index of wafers for " << nameDetectors_[ih];
421 h_W1_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 200, -50, 50));
424 name <<
"WV_" << nameDetectors_[ih];
425 title <<
"v index of wafers for " << nameDetectors_[ih];
426 h_W2_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 100, -50, 50));
429 name <<
"CU_" << nameDetectors_[ih];
430 title <<
"u index of cells for " << nameDetectors_[ih];
431 h_C1_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 100, 0, 50));
434 name <<
"CV_" << nameDetectors_[ih];
435 title <<
"v index of cells for " << nameDetectors_[ih];
436 h_C2_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 100, 0, 50));
static const std::string kSharedResource
const std::vector< std::string > nameDetectors_
Log< level::Info, true > LogVerbatim
std::vector< TH2D * > h_XY_
void analyze(edm::Event const &, edm::EventSetup const &) override
std::vector< TH1D * > h_LayerZm_
std::vector< TH2D * > h_RZ_
std::vector< TH1D * > h_T_
std::vector< TH1D * > h_W1_
int zside() const
get the z-side of the cell (1/-1)
void beginRun(edm::Run const &, edm::EventSetup const &) override
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::vector< TH2D * > h_EtFiZm_
std::vector< int > layerFront_
std::vector< TH1D * > h_C1_
uint16_t *__restrict__ id
int type() const
get the type
int cellU() const
get the cell #'s in u,v or in x,y
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
std::vector< edm::EDGetTokenT< edm::PCaloHitContainer > > tok_hits_
~HGCalSimHitStudy() override
int type() const
get/set the type
T * make(const Args &...args) const
make new ROOT object
int zside() const
get the z-side of the cell (1/-1)
const std::string names[nVars_]
int cellU() const
get the cell #'s in u,v or in x,y
constexpr std::array< uint8_t, layerIndexSize > layer
HGCalSimHitStudy(const edm::ParameterSet &)
bool getData(T &iHolder) const
int layer() const
get the layer #
std::vector< TH1D * > h_LayerZp_
int type() const
get the type
int layer() const
get the layer #
void analyzeHits(int, const std::string &, const std::vector< PCaloHit > &)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
Abs< T >::type abs(const T &t)
std::vector< TH2D * > h_EtFiZp_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int iphi() const
get the phi index
std::vector< TH1D * > h_C2_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< int > layers_
Basic2DVector< T > xy() const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
int layer() const
get the layer #
std::vector< edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecord > > tok_hgcGeom_
int zside() const
get the z-side of the cell (1/-1)
std::vector< TH1D * > h_Ly_
std::vector< TH1D * > h_E_
std::vector< const HGCalDDDConstants * > hgcons_
std::vector< TH1D * > h_W2_
static std::string const source
const std::vector< std::string > caloHitSources_
std::vector< TH2D * > h_EtaPhi_
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
void endRun(edm::Run const &, edm::EventSetup const &) override
constexpr Detector det() const
get the detector field from this detid