9 #include <fmt/printf.h>
32 if (strcasecmp(splitmode.c_str(),
"NearestLayer") == 0) {
34 }
else if (strcasecmp(splitmode.c_str(),
"InnerLayer") == 0) {
36 }
else if (strcasecmp(splitmode.c_str(),
"OuterLayer") == 0) {
41 <<
"Invalid SplitMode \"" << splitmode
42 <<
"\". Acceptable values are \"NearestLayer\", \"InnerLayer\", \"OuterLayer\".";
55 m_plotter = std::make_unique<DD4hep_TrackingMaterialPlotter>(550., 300., 10);
57 m_plotter = std::make_unique<DD4hep_TrackingMaterialPlotter>(1200., 350., 10);
59 m_plotter = std::make_unique<DD4hep_TrackingMaterialPlotter>(300., 120., 10);
72 edm::LogVerbatim(
"TrackerMaterialAnalysis") <<
"TrackingMaterialAnalyser" << std::endl;
73 for (
unsigned int i = 0;
i <
m_groups.size(); ++
i) {
75 edm::LogVerbatim(
"TrackerMaterialAnalysis") <<
"TrackingMaterialAnalyser" <<
layer.name() << std::endl;
77 <<
"TrackingMaterialAnalyser" << fmt::sprintf(
"\tnumber of hits: %9d",
layer.tracks())
80 <<
"TrackingMaterialAnalyser"
81 << fmt::sprintf(
"\tnormalized segment length: %9.1f ± %9.1f cm",
layer.averageLength(),
layer.sigmaLength())
84 << fmt::sprintf(
"\tnormalized radiation lengths: %9.3f ± %9.3f",
85 layer.averageRadiationLengths(),
86 layer.sigmaRadiationLengths())
89 <<
"TrackingMaterialAnalyser"
90 << fmt::sprintf(
"\tnormalized energy loss: %6.5fe-03 ± %6.5fe-03 GeV",
91 layer.averageEnergyLoss(),
92 layer.sigmaEnergyLoss())
94 parameters << fmt::sprintf(
"%-20s\t%7d\t%5.1f ± %5.1f cm\t%6.4f ± %6.4f \t%6.4fe-03 ± %6.4fe-03 GeV",
97 layer.averageLength(),
99 layer.averageRadiationLengths(),
100 layer.sigmaRadiationLengths(),
101 layer.averageEnergyLoss(),
102 layer.sigmaEnergyLoss())
105 edm::LogVerbatim(
"TrackerMaterialAnalysis") <<
"TrackingMaterialAnalyser" << std::endl;
112 std::ofstream xml(
name);
113 xml <<
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" << std::endl;
114 xml <<
"<Groups>" << std::endl;
115 for (
unsigned int i = 0;
i <
m_groups.size(); ++
i) {
117 xml <<
" <Group name=\"" <<
layer.name() <<
"\">\n"
118 <<
" <Parameter name=\"TrackerRadLength\" value=\"" <<
layer.averageRadiationLengths() <<
"\"/>\n"
119 <<
" <Parameter name=\"TrackerXi\" value=\"" <<
layer.averageEnergyLoss() <<
"\"/>\n"
123 xml <<
"</Groups>" << std::endl;
128 for (
unsigned int i = 0;
i <
m_groups.size(); ++
i) {
168 <<
"TrackingMaterialAnalyser: List of the tracker groups: " << std::endl;
171 <<
i <<
" TrackingMaterialAnalyser:\t" <<
m_groups[
i]->info() << std::endl;
176 for (std::vector<MaterialAccountingTrack>::const_iterator
t = h_tracks->begin(),
end = h_tracks->end();
t !=
end;
195 std::vector<int>
group(
track.detectors().size());
196 for (
unsigned int i = 0;
i <
track.detectors().size(); ++
i)
199 for (
unsigned int i = 0;
i <
group.size(); ++
i)
201 edm::LogVerbatim(
"TrackerMaterialAnalysis") <<
"TrackingMaterialAnalyser:\n"
202 <<
"For detector i: " <<
i <<
" index: " <<
group[
i]
206 <<
", " <<
m_groups[
group[
i] - 1]->getBoundingZ().second << std::endl;
213 for (
unsigned int i = 1;
i <
track.steps().size(); ++
i)
216 const double TOLERANCE = 0.0001;
221 limits[0] =
track.detectors()[0].m_curvilinearIn - TOLERANCE;
236 limits[
i] = (
track.detectors()[
i - 1].m_curvilinearOut +
track.detectors()[
i].m_curvilinearIn) / 2.;
244 limits[
i] =
track.detectors()[
i].m_curvilinearIn - TOLERANCE;
251 limits[
i] =
track.detectors()[
i - 1].m_curvilinearOut + TOLERANCE;
278 unsigned int index = 0;
279 while (
i <
track.steps().size()) {
299 <<
"TrackingMaterialAnalyser::split(): ERROR: internal logic error, expected " <<
limits[
index] <<
" < "
300 << begin <<
" < " <<
limits[
index + 1] << std::endl;
313 std::pair<MaterialAccountingStep, MaterialAccountingStep>
parts =
step.split(
fraction);
339 for (
unsigned int i = 0;
i <
track.detectors().size(); ++
i)
363 <<
"TrackingMaterialAnalyser::findLayer(...): ERROR: detector does not belong to any DetLayer" << std::endl;
365 <<
"TrackingMaterialAnalyser::findLayer(...): detector position: " <<
std::fixed
366 <<
" (r: " << std::setprecision(1) << std::setw(5) <<
detector.position().perp()
367 <<
", z: " << std::setprecision(1) << std::setw(6) <<
detector.position().z()
368 <<
", phi: " << std::setprecision(3) << std::setw(6) <<
detector.position().phi() <<
")" << std::endl;
372 edm::LogError(
"TrackerMaterialAnalysis") <<
"TrackingMaterialAnalyser::findLayer(...): ERROR: detector belongs to "
373 << inside <<
" DetLayers" << std::endl;
375 <<
"TrackingMaterialAnalyser::findLayer(...): detector position: " <<
std::fixed
376 <<
" (r: " << std::setprecision(1) << std::setw(5) <<
detector.position().perp()
377 <<
", z: " << std::setprecision(1) << std::setw(6) <<
detector.position().z()
378 <<
", phi: " << std::setprecision(3) << std::setw(6) <<
detector.position().phi() <<
")" << std::endl;