12 #include <DD4hep/DD4hepUnits.h>
35 bool firstChild = fv.firstChild();
39 for (
const auto&
j : fv.specpars()) {
40 for (
const auto&
k :
j.second->paths) {
42 std::vector<std::vector<cms::Node*>> children = fv.children(
k);
43 for (
auto const&
path : children) {
48 <<
"MaterialAccountingGroup:\t"
49 <<
"Adding element at (r,z) " << gp.
perp() <<
"," << gp.
z() << std::endl;
62 <<
"MaterialAccountingGroup:\t"
66 m_dedx_spectrum = std::make_shared<TH1F>((
m_name +
"_dedx_spectrum").c_str(),
"Energy loss spectrum", 1000, 0., 1.);
68 std::make_shared<TH1F>((
m_name +
"_radlen_spectrum").c_str(),
"Radiation lengths spectrum", 1000, 0., 1.);
69 m_dedx_vs_eta = std::make_shared<TProfile>((
m_name +
"_dedx_vs_eta").c_str(),
"Energy loss vs. eta", 600, -3., 3.);
70 m_dedx_vs_z = std::make_shared<TProfile>((
m_name +
"_dedx_vs_z").c_str(),
"Energy loss vs. Z", 6000, -300., 300.);
71 m_dedx_vs_r = std::make_shared<TProfile>((
m_name +
"_dedx_vs_r").c_str(),
"Energy loss vs. R", 1200, 0., 120.);
73 std::make_shared<TProfile>((
m_name +
"_radlen_vs_eta").c_str(),
"Radiation lengths vs. eta", 600, -3., 3.);
75 std::make_shared<TProfile>((
m_name +
"_radlen_vs_z").c_str(),
"Radiation lengths vs. Z", 6000, -300., 300.);
77 std::make_shared<TProfile>((
m_name +
"_radlen_vs_r").c_str(),
"Radiation lengths vs. R", 1200, 0., 120.);
93 <<
"Testing position: (x, y, z, r) = " << position.
x() <<
", " << position.
y() <<
", " << position.
z() <<
", "
94 << position.
perp() << std::endl;
136 (m_buffer.in().y() + m_buffer.out().y()) / 2.,
137 (m_buffer.in().z() + m_buffer.out().z()) / 2.);
141 m_dedx_vs_z->Fill(average.
z(), m_buffer.energyLoss(), 1.);
144 m_radlen_vs_z->Fill(average.
z(), m_buffer.radiationLengths(), 1.);
152 m_file = std::make_unique<TFile>((
m_name +
".root").c_str(),
"RECREATE");
166 TCanvas
canvas(name.c_str(), plot->GetTitle(), 1280, 1024);
167 plot->SetFillColor(15);
168 plot->SetLineColor(1);
170 canvas.GetFrame()->SetFillColor(kWhite);
172 canvas.SaveAs((name +
".png").c_str(),
"");
173 plot->SetDirectory(
m_file.get());
177 std::unique_ptr<TH1F>
line = std::make_unique<TH1F>(
178 (name +
"_par").c_str(),
"Parametrization", 1, plot->GetXaxis()->GetXmin(), plot->GetXaxis()->GetXmax());
180 line->SetBinContent(1, average);
182 TCanvas
canvas(name.c_str(), plot->GetTitle(), 1280, 1024);
183 plot->SetFillColor(15);
184 plot->SetLineColor(1);
185 plot->SetLineWidth(2);
187 line->SetLineColor(2);
188 line->SetLineWidth(2);
190 canvas.GetFrame()->SetFillColor(kWhite);
192 canvas.SaveAs((name +
".png").c_str(),
"");
193 plot->SetDirectory(
m_file.get());
194 line->SetDirectory(
m_file.get());
199 std::stringstream
out;
200 out << std::setw(48) << std::left <<
m_name << std::right << std::fixed;
202 out <<
"BBox: " << std::setprecision(1) << std::setw(6) <<
m_boundingbox.
range_z().first <<
" < Z < "
204 out <<
", " << std::setprecision(1) << std::setw(5) <<
m_boundingbox.
range_r().first <<
" < R < "
206 out <<
" Elements: " << std::setw(6) <<
m_elements.size();
Log< level::Info, true > LogVerbatim
MaterialAccountingStep m_buffer
std::shared_ptr< TH1F > m_radlen_spectrum
double sigmaRadiationLengths(void) const
std::shared_ptr< TProfile > m_dedx_vs_eta
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >> Translation
double length(void) const
Global3DPoint GlobalPoint
double radiationLengths(void) const
bool inside(const double &r, const double &z) const
double sigmaLength(void) const
bool addDetector(const MaterialAccountingDetector &detector)
DD4hep_MaterialAccountingGroup(const DD4hep_MaterialAccountingGroup &layer)=delete
double energyLoss(void) const
double averageEnergyLoss(void) const
static constexpr double s_tolerance
std::pair< double, double > range_r() const
MaterialAccountingStep m_accounting
const std::string & name(void) const
bool isInside(const MaterialAccountingDetector &detector) const
std::shared_ptr< TProfile > m_radlen_vs_r
std::pair< double, double > range_z() const
const MaterialAccountingStep & material() const
double sigmaEnergyLoss(void) const
double averageRadiationLengths(void) const
MaterialAccountingStep m_errors
MaterialAccountingStep average(void) const
std::string info(void) const
void grow(const double &r, const double &z)
std::unique_ptr< TFile > m_file
std::shared_ptr< TProfile > m_radlen_vs_eta
const GlobalPoint & position() const
std::vector< GlobalPoint > m_elements
T perp() const
Magnitude of transverse component.
static int position[264][3]
std::shared_ptr< TProfile > m_dedx_vs_r
double averageLength(void) const
std::shared_ptr< TProfile > m_radlen_vs_z
std::shared_ptr< TProfile > m_dedx_vs_z
BoundingBox m_boundingbox
std::shared_ptr< TH1F > m_dedx_spectrum
void savePlot(std::shared_ptr< TH1F > &plot, const std::string &name)