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) {
167 <<
"TrackingMaterialAnalyser: List of the tracker groups: " << std::endl;
170 <<
i <<
" TrackingMaterialAnalyser:\t" <<
m_groups[
i]->info() << std::endl;
175 for (std::vector<MaterialAccountingTrack>::const_iterator
t = h_tracks->begin(),
end = h_tracks->end();
t !=
end;
194 std::vector<int>
group(
track.detectors().size());
195 for (
unsigned int i = 0;
i <
track.detectors().size(); ++
i)
198 for (
unsigned int i = 0;
i <
group.size(); ++
i)
200 edm::LogVerbatim(
"TrackerMaterialAnalysis") <<
"TrackingMaterialAnalyser:\n" 201 <<
"For detector i: " <<
i <<
" index: " <<
group[
i]
205 <<
", " <<
m_groups[
group[
i] - 1]->getBoundingZ().second << std::endl;
212 for (
unsigned int i = 1;
i <
track.steps().size(); ++
i)
215 const double TOLERANCE = 0.0001;
220 limits[0] =
track.detectors()[0].m_curvilinearIn - TOLERANCE;
235 limits[
i] = (
track.detectors()[
i - 1].m_curvilinearOut +
track.detectors()[
i].m_curvilinearIn) / 2.;
243 limits[
i] =
track.detectors()[
i].m_curvilinearIn - TOLERANCE;
250 limits[
i] =
track.detectors()[
i - 1].m_curvilinearOut + TOLERANCE;
277 unsigned int index = 0;
278 while (
i <
track.steps().size()) {
298 <<
"TrackingMaterialAnalyser::split(): ERROR: internal logic error, expected " <<
limits[
index] <<
" < " 299 << begin <<
" < " <<
limits[
index + 1] << std::endl;
312 std::pair<MaterialAccountingStep, MaterialAccountingStep>
parts =
step.split(
fraction);
338 for (
unsigned int i = 0;
i <
track.detectors().size(); ++
i)
362 <<
"TrackingMaterialAnalyser::findLayer(...): ERROR: detector does not belong to any DetLayer" << std::endl;
364 <<
"TrackingMaterialAnalyser::findLayer(...): detector position: " <<
std::fixed 365 <<
" (r: " << std::setprecision(1) << std::setw(5) <<
detector.position().perp()
366 <<
", z: " << std::setprecision(1) << std::setw(6) <<
detector.position().z()
367 <<
", phi: " << std::setprecision(3) << std::setw(6) <<
detector.position().phi() <<
")" << std::endl;
371 edm::LogError(
"TrackerMaterialAnalysis") <<
"TrackingMaterialAnalyser::findLayer(...): ERROR: detector belongs to " 372 << inside <<
" DetLayers" << std::endl;
374 <<
"TrackingMaterialAnalyser::findLayer(...): detector position: " <<
std::fixed 375 <<
" (r: " << std::setprecision(1) << std::setw(5) <<
detector.position().perp()
376 <<
", z: " << std::setprecision(1) << std::setw(6) <<
detector.position().z()
377 <<
", phi: " << std::setprecision(3) << std::setw(6) <<
detector.position().phi() <<
")" << std::endl;
Log< level::Info, true > LogVerbatim
void analyze(const edm::Event &, const edm::EventSetup &) override
void split(MaterialAccountingTrack &track)
T getParameter(std::string const &) const
std::unique_ptr< DD4hep_TrackingMaterialPlotter > m_plotter
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > m_dddToken
DD4hep_TrackingMaterialAnalyser(const edm::ParameterSet &)
bool m_skipBeforeFirstDetector
std::vector< DD4hep_MaterialAccountingGroup * > m_groups
bool m_skipAfterLastDetector
Log< level::Error, false > LogError
edm::EDGetTokenT< std::vector< MaterialAccountingTrack > > m_materialToken
constexpr std::array< uint8_t, layerIndexSize > layer
int findLayer(const MaterialAccountingDetector &detector)
void saveParameters(const char *name)
def detectors(dt=True, csc=True, me42=False, chambers=True, superlayers=False, layers=False)
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
#define DEFINE_FWK_MODULE(type)
std::vector< std::string > m_groupNames
~DD4hep_TrackingMaterialAnalyser() override
void saveXml(const char *name)