43 #include "CLHEP/Geometry/Point3D.h" 44 #include "CLHEP/Geometry/Transform3D.h" 45 #include "CLHEP/Geometry/Vector3D.h" 46 #include "CLHEP/Units/GlobalSystemOfUnits.h" 47 #include "CLHEP/Units/GlobalPhysicalConstants.h" 54 for (
int i = 0;
i < 6; ++
i)
82 void fillHitsInfo(std::pair<hitsinfo, energysum> hit_,
unsigned int itimeslice,
double esum);
89 const char* yTitle =
"",
95 const char* yTitle =
"",
129 : nameDetector_(iConfig.getParameter<
std::
string>(
"DetectorName")),
130 caloHitSource_(iConfig.getParameter<
std::
string>(
"CaloHitSource")),
131 times_(iConfig.getParameter<
std::
vector<double> >(
"TimeSlices")),
132 verbosity_(iConfig.getUntrackedParameter<
int>(
"Verbosity", 0)),
133 fromDDD_(iConfig.getUntrackedParameter<
bool>(
"fromDDD",
true)),
136 tok_cpv_(esConsumes<DDCompactView, IdealGeometryRecord, edm::Transition::BeginRun>()),
137 tok_cpvc_(esConsumes<cms::DDCompactView, IdealGeometryRecord, edm::Transition::BeginRun>()),
140 tok_hepMC_ = consumes<edm::HepMCProduct>(
edm::InputTag(
"generatorSmeared"));
141 tok_hits_ = consumes<edm::PCaloHitContainer>(
edm::InputTag(
"g4SimHits", caloHitSource_));
142 nTimes_ = (times_.size() > maxTime_) ? maxTime_ : times_.size();
147 std::vector<double> times = {25.0, 1000.0};
150 desc.add<std::vector<double> >(
"TimeSlices", times);
151 desc.addUntracked<
int>(
"Verbosity", 0);
152 desc.addUntracked<
bool>(
"TestNumber",
true);
153 desc.addUntracked<
bool>(
"fromDDD",
true);
154 descriptions.
add(
"hgcalSimHitValidationEE",
desc);
167 for (HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
p != myGenEvent->particles_end();
169 edm::LogVerbatim(
"HGCalValidation") <<
"Particle[" <<
k <<
"] with pt " << (*p)->momentum().perp() <<
" eta " 170 << (*p)->momentum().eta() <<
" phi " << (*p)->momentum().phi();
178 if (theCaloHitContainers.
isValid()) {
180 edm::LogVerbatim(
"HGCalValidation") <<
" PcalohitItr = " << theCaloHitContainers->size();
181 std::vector<PCaloHit> caloHits;
182 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), theCaloHitContainers->end());
190 std::map<int, int> OccupancyMap_plus, OccupancyMap_minus;
191 OccupancyMap_plus.clear();
192 OccupancyMap_minus.clear();
194 std::map<uint32_t, std::pair<hitsinfo, energysum> > map_hits;
199 unsigned int nused(0);
200 for (
unsigned int i = 0;
i <
hits.size();
i++) {
203 uint32_t id_ =
hits[
i].id();
208 cell = detId.
cellU();
211 subsector = detId.
waferV();
230 <<
"Detector " <<
nameDetector_ <<
" zside = " <<
zside <<
" sector|wafer = " << sector <<
":" << subsector
231 <<
" type = " <<
type <<
" layer = " <<
layer <<
" cell = " << cell <<
":" <<
cell2 <<
" energy = " <<
energy 232 <<
" energyem = " <<
hits[
i].energyEM() <<
" energyhad = " <<
hits[
i].energyHad() <<
" time = " <<
time;
234 HepGeom::Point3D<float> gcoord;
235 std::pair<float, float>
xy;
246 float xp = (zp < 0) ? -
xy.first :
xy.first;
247 gcoord = HepGeom::Point3D<float>(xp,
xy.second, zp);
248 double tof = (gcoord.mag() * CLHEP::mm) / CLHEP::c_light;
251 << std::hex << id_ <<
std::dec <<
" global coordinate " << gcoord <<
" time " <<
time <<
":" << tof;
256 if (map_hits.count(id_) != 0) {
257 hinfo = map_hits[id_].first;
258 esum = map_hits[id_].second;
260 hinfo.x = gcoord.x();
261 hinfo.y = gcoord.y();
262 hinfo.z = gcoord.z();
263 hinfo.sector = sector;
264 hinfo.sector2 = subsector;
269 hinfo.phi = gcoord.getPhi();
270 hinfo.eta = gcoord.getEta();
280 <<
" gz = " <<
hinfo.z <<
" phi = " <<
hinfo.phi <<
" eta = " <<
hinfo.eta;
281 map_hits[id_] = std::pair<hitsinfo, energysum>(
hinfo, esum);
285 <<
" detector elements being hit";
287 std::map<uint32_t, std::pair<hitsinfo, energysum> >::iterator itr;
288 for (itr = map_hits.begin(); itr != map_hits.end(); ++itr) {
294 int partialType = -1;
301 for (
unsigned int itimeslice = 0; itimeslice <
nTimes_; itimeslice++) {
313 edm::LogVerbatim(
"HGCalValidation") <<
"With map:used:total " <<
hits.size() <<
"|" << nused <<
"|" 314 << map_hits.size() <<
" hits";
316 for (
auto const& itr : OccupancyMap_plus) {
317 int layer = itr.first;
318 int occupancy = itr.second;
321 for (
auto const& itr : OccupancyMap_minus) {
322 int layer = itr.first;
323 int occupancy = itr.second;
329 if (OccupancyMap.find(
layer) != OccupancyMap.end()) {
330 ++OccupancyMap[
layer];
332 OccupancyMap[
layer] = 1;
337 unsigned int ilayer =
hits.first.layer;
339 energy_[itimeslice].at(ilayer)->Fill(esum);
340 if (itimeslice == 0) {
347 <<
"Problematic Hit for " <<
nameDetector_ <<
" at sector " <<
hits.first.sector <<
":" <<
hits.first.sector2
348 <<
" layer " <<
hits.first.layer <<
" cell " <<
hits.first.cell <<
":" <<
hits.first.cell2 <<
" energy " 349 <<
hits.second.etotal;
357 esum.
eTime[0] * CLHEP::GeV /
360 unsigned int ilayer =
hinfo.layer;
361 double x =
hinfo.x * CLHEP::mm / CLHEP::cm;
362 double y =
hinfo.y * CLHEP::mm / CLHEP::cm;
366 if (!TMath::AreEqualAbs(edep, 0.0, 1.
e-5)) {
368 if (partialType == 0)
374 if (partialType == 0)
380 if (partialType == 0)
424 int nsiz =
static_cast<int>(
copy.size());
425 int lay = (nsiz > 0) ?
copy[nsiz - 1] : -1;
426 int sec = (nsiz > 1) ?
copy[nsiz - 2] : -1;
427 int zp = (nsiz > 3) ?
copy[nsiz - 4] : -1;
431 int subs = (trp.
alpha1() > 0 ? 1 : 0);
436 const CLHEP::HepRep3x3
rotation(
x.X(),
y.X(),
z.X(),
x.Y(),
y.Y(),
z.Y(),
x.Z(),
y.Z(),
z.Z());
437 const CLHEP::HepRotation hr(
rotation);
439 const HepGeom::Transform3D ht3d(hr, h3v);
440 transMap_.insert(std::make_pair(
id, ht3d));
467 int nsiz =
static_cast<int>(
copy.size());
468 int lay = (nsiz > 0) ?
copy[0] : -1;
469 int sec = (nsiz > 1) ?
copy[1] : -1;
470 int zp = (nsiz > 3) ?
copy[3] : -1;
474 int subs = (pars[6] > 0 ? 1 : 0);
479 const CLHEP::HepRep3x3
rotation(
x.X(),
y.X(),
z.X(),
x.Y(),
y.Y(),
z.Y(),
x.Z(),
y.Z(),
z.Z());
480 const CLHEP::HepRotation hr(
rotation);
482 const HepGeom::Transform3D ht3d(hr, h3v);
483 transMap_.insert(std::make_pair(
id, ht3d));
514 std::ostringstream histoname;
515 for (
unsigned int il = 0; il <
layers_; ++il) {
518 while (istr1.size() < 2) {
519 istr1.insert(0,
"0");
522 histoname <<
"HitOccupancy_Plus_layer_" << istr1;
525 histoname <<
"HitOccupancy_Minus_layer_" << istr1;
529 histoname <<
"EtaPhi_Plus_" 530 <<
"layer_" << istr1;
533 histoname <<
"EtaPhi_Minus_" 534 <<
"layer_" << istr1;
538 for (
unsigned int itimeslice = 0; itimeslice <
nTimes_; itimeslice++) {
540 histoname <<
"energy_time_" << itimeslice <<
"_layer_" << istr1;
541 energy_[itimeslice].push_back(iB.
book1D(histoname.str().c_str(),
"energy_", 100, 0, 0.1));
547 histoname <<
"energy_FullWafer_Fine_layer_" << istr1;
548 TH1F* hEdepFWF =
createHisto(histoname.str(), 100, 0., 400.,
false);
549 histoSetting(hEdepFWF,
"Eloss (keV)",
"", kRed, kRed, 2);
554 histoname <<
"energy_FullWafer_CoarseThin_layer_" << istr1;
555 TH1F* hEdepFWCN =
createHisto(histoname.str(), 100, 0., 400.,
false);
556 histoSetting(hEdepFWCN,
"Eloss (keV)",
"", kGreen + 1, kGreen + 1, 2);
561 histoname <<
"energy_FullWafer_CoarseThick_layer_" << istr1;
562 TH1F* hEdepFWCK =
createHisto(histoname.str(), 100, 0., 400.,
false);
563 histoSetting(hEdepFWCK,
"Eloss (keV)",
"", kMagenta, kMagenta, 2);
573 histoname <<
"energy_PartialWafer_Fine_layer_" << istr1;
574 TH1F* hEdepPWF =
createHisto(histoname.str(), 100, 0., 400.,
false);
575 histoSetting(hEdepPWF,
"Eloss (keV)",
"", kRed, kRed, 2);
580 histoname <<
"energy_PartialWafer_CoarseThin_layer_" << istr1;
581 TH1F* hEdepPWCN =
createHisto(histoname.str(), 100, 0., 400.,
false);
582 histoSetting(hEdepPWCN,
"Eloss (keV)",
"", kGreen + 1, kGreen + 1, 2);
587 histoname <<
"energy_PartialWafer_CoarseThick_layer_" << istr1;
588 TH1F* hEdepPWCK =
createHisto(histoname.str(), 100, 0., 400.,
false);
589 histoSetting(hEdepPWCK,
"Eloss (keV)",
"", kMagenta, kMagenta, 2);
598 histoname <<
"hitXY_FullWafer_Fine_layer_" << istr1;
599 TH2F* hitXYFWF =
new TH2F(
600 Form(
"hitXYFWF_%s", histoname.str().c_str()), histoname.str().c_str(), 100, -300., 300., 100, -300., 300.);
606 histoname <<
"hitXY_FullWafer_CoarseThin_layer_" << istr1;
607 TH2F* hitXYFWCN =
new TH2F(
608 Form(
"hitXYFWCN_%s", histoname.str().c_str()), histoname.str().c_str(), 100, -300., 300., 100, -300., 300.);
609 histoSetting(hitXYFWCN,
"x (cm)",
"y (cm)", kGreen + 1, kGreen + 1);
614 histoname <<
"hitXY_FullWafer_CoarseThick_layer_" << istr1;
615 TH2F* hitXYFWCK =
new TH2F(
616 Form(
"hitXYFWCK_%s", histoname.str().c_str()), histoname.str().c_str(), 100, -300., 300., 100, -300., 300.);
617 histoSetting(hitXYFWCK,
"x (cm)",
"y (cm)", kMagenta, kMagenta);
624 histoname <<
"hitXY_Scintillator_layer_" << istr1;
625 TH2F* hitXYB =
new TH2F(
626 Form(
"hitXYB_%s", histoname.str().c_str()), histoname.str().c_str(), 100, -300., 300., 100, -300., 300.);
628 hitXYB_.push_back(iB.
book2D(histoname.str().c_str(), hitXYB));
638 std::string histname,
const int nbins,
float minIndexX,
float maxIndexX,
bool isLogX) {
639 TH1F*
hist =
nullptr;
642 double dx = (maxIndexX - minIndexX) /
nbins;
644 xbins[
i] = TMath::Power(10, (minIndexX +
i *
dx));
646 hist =
new TH1F(Form(
"hEdep_%s", histname.c_str()), histname.c_str(),
nbins,
xbins);
648 hist =
new TH1F(Form(
"hEdep_%s", histname.c_str()), histname.c_str(),
nbins, minIndexX, maxIndexX);
659 histo->GetXaxis()->SetTitle(xTitle);
660 histo->GetYaxis()->SetTitle(yTitle);
669 histo->SetMarkerStyle(kFullCircle);
670 histo->SetMarkerSize(0.6);
671 histo->GetXaxis()->SetTitle(xTitle);
672 histo->GetYaxis()->SetTitle(yTitle);
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MonitorElement * MeanHitOccupancy_Plus_
double waferZ(int layer, bool reco) const
Log< level::Info, true > LogVerbatim
bool defineGeometry(const DDCompactView *ddViewH)
nav_type copyNumbers() const
return the stack of copy numbers
void fillOccupancyMap(std::map< int, int > &OccupancyMap, int layer)
std::vector< MonitorElement * > HitOccupancy_Plus_
void analyze(const edm::Event &, const edm::EventSetup &) override
const std::vector< int > copyNos() const
The list of the volume copy numbers.
const std::vector< double > times_
virtual void setCurrentFolder(std::string const &fullpath)
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< edm::HepMCProduct > tok_hepMC_
int cellU() const
get the cell #'s in u,v or in x,y
std::string to_string(const V &value)
bool waferHexagon8() const
void analyzeHits(std::vector< PCaloHit > &hits)
std::vector< MonitorElement * > energyPWF_
std::vector< MonitorElement * > HitOccupancy_Minus_
int type() const
get/set the type
HGCalGeometryMode::GeometryMode geomMode() const
Compact representation of the geometrical detector hierarchy.
A DDSolid represents the shape of a part.
MonitorElement * MeanHitOccupancy_Minus_
constexpr std::array< uint8_t, layerIndexSize > layer
std::vector< MonitorElement * > energyPWCN_
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
std::string_view name() const
int layer() const
get the layer #
const std::string nameDetector_
int iphi() const
get the phi index
bool next()
set current node to the next node in the filtered tree
std::vector< MonitorElement * > hitXYFWCK_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
static const unsigned int maxTime_
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
int layer() const
get the layer #
TH1F * createHisto(std::string histname, const int nbins, float minIndexX, float maxIndexX, bool isLogX=true)
int waferType(DetId const &id, bool fromFile=false) const
Interface to a Trapezoid.
~HGCalSimHitValidation() override
unsigned int layers(bool reco) const
bool getData(T &iHolder) const
int zside() const
get the z-side of the cell (1/-1)
std::vector< MonitorElement * > energyFWF_
bool tileTrapezoid() const
std::vector< MonitorElement * > EtaPhi_Plus_
std::vector< MonitorElement * > energyFWCN_
bool firstChild()
set the current node to the first child
const HepMC::GenEvent * GetEvent() const
HGCalSimHitValidation(const edm::ParameterSet &)
std::vector< MonitorElement * > energyFWCK_
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
std::vector< MonitorElement * > hitXYFWF_
const std::string caloHitSource_
int zside() const
get the z-side of the cell (1/-1)
std::vector< MonitorElement * > energyPWCK_
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
double alpha1(void) const
Angle with respect to the y axis from the centre of the side at y=-pDy1 to the centre at y=+pDy1 of t...
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hits_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
std::vector< MonitorElement * > energy_[maxTime_]
const RotationMatrix rotation() const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
std::map< uint32_t, HepGeom::Transform3D > transMap_
bool firstChild()
set the current node to the first child ...
const edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > tok_cpvc_
void histoSetting(TH1F *&histo, const char *xTitle, const char *yTitle="", Color_t lineColor=kBlack, Color_t markerColor=kBlack, int linewidth=1)
const HGCalDDDConstants * hgcons_
std::vector< MonitorElement * > EtaPhi_Minus_
int type() const
get the type
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
static uint32_t packSquareIndex(int z, int lay, int sec, int subsec, int cell)
std::vector< MonitorElement * > hitXYFWCN_
const DDTranslation & translation() const
The absolute translation of the current node.
void fillMuonTomoHistos(int partialType, std::pair< hitsinfo, energysum > hit_)
const std::vector< double > parameters() const
extract shape parameters
std::vector< MonitorElement * > hitXYB_
const edm::ESGetToken< DDCompactView, IdealGeometryRecord > tok_cpv_
void fillHitsInfo(std::pair< hitsinfo, energysum > hit_, unsigned int itimeslice, double esum)
const edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecord > tok_hgcal_
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
std::pair< float, float > locateCellTrap(int lay, int ieta, int iphi, bool reco) const
const Translation translation() const