40 #include "CLHEP/Geometry/Point3D.h" 41 #include "CLHEP/Geometry/Transform3D.h" 42 #include "CLHEP/Geometry/Vector3D.h" 43 #include "CLHEP/Units/GlobalSystemOfUnits.h" 44 #include "CLHEP/Units/GlobalPhysicalConstants.h" 79 std::vector<const HGCalDDDConstants*>
hgcons_;
82 std::vector<edm::EDGetTokenT<edm::PCaloHitContainer> >
tok_hits_;
94 rmin_(iConfig.getUntrackedParameter<double>(
"rMin", 0.0)),
95 rmax_(iConfig.getUntrackedParameter<double>(
"rMax", 3000.0)),
96 zmin_(iConfig.getUntrackedParameter<double>(
"zMin", 3000.0)),
97 zmax_(iConfig.getUntrackedParameter<double>(
"zMax", 6000.0)),
98 etamin_(iConfig.getUntrackedParameter<double>(
"etaMin", 1.0)),
99 etamax_(iConfig.getUntrackedParameter<double>(
"etaMax", 3.0)),
100 nbinR_(iConfig.getUntrackedParameter<
int>(
"nBinR", 300)),
101 nbinZ_(iConfig.getUntrackedParameter<
int>(
"nBinZ", 300)),
102 nbinEta_(iConfig.getUntrackedParameter<
int>(
"nBinEta", 200)),
103 nLayers_(iConfig.getUntrackedParameter<
int>(
"layers", 50)),
104 verbosity_(iConfig.getUntrackedParameter<
int>(
"verbosity", 0)),
122 std::vector<std::string>
names = {
"HGCalEESensitive",
"HGCalHESiliconSensitive",
"Hcal"};
123 std::vector<std::string>
sources = {
"HGCHitsEE",
"HGCHitsHEfront",
"HcalHits"};
124 desc.
add<std::vector<std::string> >(
"detectorNames",
names);
125 desc.
add<std::vector<std::string> >(
"caloHitSources",
sources);
139 descriptions.
add(
"hgcalSimHitStudy", desc);
147 if (theCaloHitContainers.
isValid()) {
149 edm::LogVerbatim(
"HGCalValidation") <<
" PcalohitItr = " << theCaloHitContainers->size();
150 std::vector<PCaloHit> caloHits;
152 for (
auto const&
hit : *(theCaloHitContainers.
product())) {
153 unsigned int id =
hit.
id();
156 caloHits.emplace_back(
hit);
157 caloHits.back().setID(hid.
rawId());
159 edm::LogVerbatim(
"HGCalValidation") <<
"Hit[" << caloHits.size() <<
"] " << hid;
163 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), theCaloHitContainers->end());
175 edm::LogVerbatim(
"HGCalValidation") << name <<
" with " << hits.size() <<
" PcaloHit elements";
177 std::map<uint32_t, hitsinfo> map_hits;
180 unsigned int nused(0);
181 for (
auto const&
hit : hits) {
184 uint32_t
id =
hit.
id();
187 HepGeom::Point3D<float> gcoord;
192 sector = detId.
iphi();
193 layer = detId.
depth();
194 zside = detId.
zside();
196 double rz =
hcons_->
getRZ(subdet, zside * cell, layer);
198 edm::LogVerbatim(
"HGCalValidation") <<
"i/p " << subdet <<
":" << zside <<
":" << cell <<
":" << sector <<
":" 199 << layer <<
" o/p " << etaphi.first <<
":" << etaphi.second <<
":" << rz;
200 gcoord = HepGeom::Point3D<float>(rz *
cos(etaphi.second) / cosh(etaphi.first),
201 rz *
sin(etaphi.second) / cosh(etaphi.first),
202 rz * tanh(etaphi.first));
204 std::pair<float, float>
xy;
208 cell = detId.
cellU();
213 layer = detId.
layer();
214 zside = detId.
zside();
222 subdet =
static_cast<int>(detId.
det());
223 cell = detId.
cellU();
228 layer = detId.
layer();
229 zside = detId.
zside();
235 subdet =
static_cast<int>(detId.
det());
236 sector = detId.
ieta();
239 layer = detId.
layer();
240 zside = detId.
zside();
241 xy =
hgcons_[ih]->locateCellTrap(layer, sector, cell,
false);
244 xy =
hgcons_[ih]->locateCell(cell, layer, sector,
false);
246 double zp =
hgcons_[ih]->waferZ(layer,
false);
249 double xp = (zp < 0) ? -xy.first : xy.first;
250 gcoord = HepGeom::Point3D<float>(xp, xy.second, zp);
253 <<
"i/p " << subdet <<
":" << zside <<
":" << layer <<
":" << sector <<
":" <<
sector2 <<
":" << cell <<
":" 254 <<
cell2 <<
" o/p " << xy.first <<
":" << xy.second <<
":" << zp;
257 double tof = (gcoord.mag() * CLHEP::mm) / CLHEP::c_light;
260 <<
"Detector " << name <<
" zside = " << zside <<
" layer = " << layer <<
" type = " << type
261 <<
" wafer = " << sector <<
":" <<
sector2 <<
" cell = " << cell <<
":" <<
cell2 <<
" positon = " << gcoord
262 <<
" energy = " << energy <<
" time = " << time <<
":" << tof;
267 if (map_hits.count(
id) != 0) {
268 hinfo = map_hits[
id];
271 hinfo.
phi = gcoord.getPhi();
272 hinfo.
eta = gcoord.getEta();
276 map_hits[
id] = hinfo;
282 if (hinfo.
layer <= static_cast<int>(
h_XY_.size()))
283 h_XY_[hinfo.
layer-1]->Fill(gcoord.x(), gcoord.y());
288 h_Ly_[ih]->Fill(layer);
289 h_W1_[ih]->Fill(sector);
290 h_C1_[ih]->Fill(cell);
293 edm::LogVerbatim(
"HGCalValidation") << name <<
" with " << map_hits.size() <<
":" << nused <<
" detector elements" 296 for (
auto const&
hit : map_hits) {
300 <<
" ---------------------- eta = " << hinfo.
eta <<
" phi = " << hinfo.
phi <<
" layer = " << hinfo.
layer 301 <<
" E = " << hinfo.
energy <<
" T = " << hinfo.
time;
337 hgcons_.emplace_back(&(*pHGDC));
358 name <<
"RZ_AllDetectors";
359 title <<
"R vs Z for All Detectors";
362 title <<
"R vs Z for " << nameDetectors_[ih - 1];
368 for (
int ly = 0; ly <
nLayers_; ++ly) {
371 name <<
"XY_L" << (ly + 1);
372 title <<
"Y vs X at Layer " << (ly + 1);
381 name <<
"EtaPhi_AllDetectors";
382 title <<
"#phi vs #eta for All Detectors";
385 title <<
"#phi vs #eta for " << nameDetectors_[ih - 1];
392 name <<
"EtFiZp_AllDetectors";
393 title <<
"#phi vs #eta (+z) for All Detectors";
396 title <<
"#phi vs #eta (+z) for " << nameDetectors_[ih - 1];
403 name <<
"EtFiZm_AllDetectors";
404 title <<
"#phi vs #eta (-z) for All Detectors";
407 title <<
"#phi vs #eta (-z) for " << nameDetectors_[ih - 1];
415 name <<
"LayerZp_AllDetectors";
416 title <<
"Energy vs Layer (+z) for All Detectors";
419 title <<
"Energy vs Layer (+z) for " << nameDetectors_[ih - 1];
421 h_LayerZp_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 60, 0.0, 60.0));
425 name <<
"LayerZm_AllDetectors";
426 title <<
"Energy vs Layer (-z) for All Detectors";
429 title <<
"Energy vs Layer (-z) for " << nameDetectors_[ih - 1];
431 h_LayerZm_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 60, 0.0, 60.0));
436 name <<
"E_AllDetectors";
437 title <<
"Energy Deposit for All Detectors";
440 title <<
"Energy Deposit for " << nameDetectors_[ih - 1];
442 h_E_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 1000, 0.0, 1.0));
447 name <<
"T_AllDetectors";
448 title <<
"Time for All Detectors";
451 title <<
"Time for " << nameDetectors_[ih - 1];
453 h_T_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 1000, 0.0, 200.0));
460 title <<
"Layer number for " << nameDetectors_[ih];
461 h_Ly_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 200, 0, 100));
462 if ((nameDetectors_[ih] ==
"HGCalHEScintillatorSensitive") ||
heRebuild_[ih]) {
465 name <<
"IR_" << nameDetectors_[ih];
466 title <<
"Radius index for " << nameDetectors_[ih];
467 h_W1_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 200, -50, 50));
470 name <<
"FI_" << nameDetectors_[ih];
471 title <<
"#phi index for " << nameDetectors_[ih];
472 h_C1_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 720, 0, 360));
476 name <<
"WU_" << nameDetectors_[ih];
477 title <<
"u index of wafers for " << nameDetectors_[ih];
478 h_W1_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 200, -50, 50));
481 name <<
"WV_" << nameDetectors_[ih];
482 title <<
"v index of wafers for " << nameDetectors_[ih];
483 h_W2_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 100, -50, 50));
486 name <<
"CU_" << nameDetectors_[ih];
487 title <<
"u index of cells for " << nameDetectors_[ih];
488 h_C1_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 100, 0, 50));
491 name <<
"CV_" << nameDetectors_[ih];
492 title <<
"v index of cells for " << nameDetectors_[ih];
493 h_C2_.emplace_back(fs->
make<TH1D>(name.str().c_str(), title.str().c_str(), 100, 0, 50));
std::pair< T, T > etaphi(T x, T y, T z)
static const std::string kSharedResource
const std::vector< std::string > nameDetectors_
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)
std::pair< double, double > getEtaPhi(const int &subdet, const int &ieta, const int &iphi) const
void beginRun(edm::Run const &, edm::EventSetup const &) override
HcalSubdetector subdet() const
get the subdetector
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::vector< TH2D * > h_EtFiZm_
std::vector< int > layerFront_
std::vector< TH1D * > h_C1_
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
int zside() const
get the z-side of the cell (1/-1)
std::vector< edm::EDGetTokenT< edm::PCaloHitContainer > > tok_hits_
Sin< T >::type sin(const T &t)
constexpr uint32_t rawId() const
get the raw id
~HGCalSimHitStudy() override
int type() const
get 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
HGCalSimHitStudy(const edm::ParameterSet &)
int depth() const
get the tower depth
#define DEFINE_FWK_MODULE(type)
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 > &)
double getRZ(const int &subdet, const int &ieta, const int &depth) const
Cos< T >::type cos(const T &t)
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_
std::vector< bool > heRebuild_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
int ietaAbs() const
get the absolute value of the cell ieta
std::vector< int > layers_
const HcalDDDRecConstants * hcons_
int iphi() const
get the cell iphi
T const * product() const
int getMaxDepth(const int &type) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
int layer() const
get the layer #
int zside() const
get the z-side of the cell (1/-1)
std::vector< TH1D * > h_Ly_
std::vector< TH1D * > h_E_
DetId relabel(const uint32_t testId) const
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