9 #include <boost/format.hpp> 34 if (strcasecmp(splitmode.c_str(),
"NearestLayer") == 0) {
36 }
else if (strcasecmp(splitmode.c_str(),
"InnerLayer") == 0) {
38 }
else if (strcasecmp(splitmode.c_str(),
"OuterLayer") == 0) {
43 <<
"Invalid SplitMode \"" << splitmode
44 <<
"\". Acceptable values are \"NearestLayer\", \"InnerLayer\", \"OuterLayer\".";
52 if (m_saveSummaryPlot)
68 for (
unsigned int i = 0;
i <
m_groups.size(); ++
i) {
81 parameters <<
boost::format(
"%-20s\t%7d\t%5.1f ± %5.1f cm\t%6.4f ± %6.4f \t%6.4fe-03 ± %6.4fe-03 GeV") %
94 std::ofstream xml(name);
95 xml <<
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" << std::endl;
96 xml <<
"<Groups>" << std::endl;
97 for (
unsigned int i = 0;
i <
m_groups.size(); ++
i) {
99 xml <<
" <Group name=\"" << layer.
name() <<
"\">\n" 101 <<
" <Parameter name=\"TrackerXi\" value=\"" << layer.
averageEnergyLoss() <<
"\"/>\n" 105 xml <<
"</Groups>" << std::endl;
110 for (
unsigned int i = 0;
i <
m_groups.size(); ++
i) {
128 m_plotter->normalize();
149 LogInfo(
"TrackingMaterialAnalyser") <<
"TrackingMaterialAnalyser: List of the tracker groups: " << std::endl;
150 for (
unsigned int i = 0; i <
m_groups.size(); ++
i)
151 LogInfo(
"TrackingMaterialAnalyser") << i <<
" TrackingMaterialAnalyser:\t" <<
m_groups[
i]->info() << std::endl;
156 for (std::vector<MaterialAccountingTrack>::const_iterator
t = h_tracks->begin(),
end = h_tracks->end();
t !=
end;
176 for (
unsigned int i = 0;
i < track.
detectors().size(); ++
i)
179 for (
unsigned int i = 0;
i <
group.size(); ++
i)
181 LogInfo(
"TrackingMaterialAnalyser") <<
"For detector i: " <<
i <<
" index: " <<
group[
i]
182 <<
" R-ranges: " <<
m_groups[
group[
i] - 1]->getBoundingR().first <<
", " 184 <<
" Z-ranges: " <<
m_groups[
group[
i] - 1]->getBoundingZ().first <<
", " 188 if (detectors == 0) {
192 for (
unsigned int i = 1;
i < track.
steps().size(); ++
i)
195 const double TOLERANCE = 0.0001;
196 std::vector<double> limits(detectors + 2);
200 limits[0] = track.
detectors()[0].m_curvilinearIn - TOLERANCE;
202 limits[0] = -TOLERANCE;
207 limits[detectors + 1] = INFINITY;
223 limits[
i] = track.
detectors()[
i].m_curvilinearIn - TOLERANCE;
230 limits[
i] = track.
detectors()[
i - 1].m_curvilinearOut + TOLERANCE;
244 while (end < limits[0]) {
246 end = begin + step.
length();
255 unsigned int index = 0;
256 while (i < track.
steps().size()) {
259 end = begin + step.
length();
261 if (begin > limits[detectors]) {
273 if (begin < limits[index]
or end > limits[index + 2]) {
275 std::cerr <<
"MaterialAccountingTrack::split(): ERROR: internal logic error, expected " << limits[
index]
276 <<
" < " << begin <<
" < " << limits[index + 1] << std::endl;
280 if (limits[index] <= begin and end <= limits[index + 1]) {
287 double fraction = (limits[index + 1] -
begin) / (end - begin);
288 assert(fraction < 1.);
289 std::pair<MaterialAccountingStep, MaterialAccountingStep>
parts = step.
split(fraction);
298 if (index + 1 < detectors)
305 track.
detectors()[
index].account(parts.first, begin, limits[index + 1]);
307 if (index < detectors)
308 track.
detectors()[
index].account(parts.second, limits[index + 1], end);
315 for (
unsigned int i = 0;
i < track.
detectors().size(); ++
i)
338 std::cerr <<
"TrackingMaterialAnalyser::findLayer(...): ERROR: detector does not belong to any DetLayer" 341 <<
" (r: " << std::setprecision(1) << std::setw(5) << detector.
position().
perp()
342 <<
", z: " << std::setprecision(1) << std::setw(6) << detector.
position().
z()
343 <<
", phi: " << std::setprecision(3) << std::setw(6) << detector.
position().
phi() <<
")" << std::endl;
347 std::cerr <<
"TrackingMaterialAnalyser::findLayer(...): ERROR: detector belongs to " << inside <<
" DetLayers" 350 <<
" (r: " << std::setprecision(1) << std::setw(5) << detector.
position().
perp()
351 <<
", z: " << std::setprecision(1) << std::setw(6) << detector.
position().
z()
352 <<
", phi: " << std::setprecision(3) << std::setw(6) << detector.
position().
phi() <<
")" << std::endl;
void plotSegmentUnassigned(const MaterialAccountingStep &step)
T getParameter(std::string const &) const
const std::vector< MaterialAccountingDetector > & detectors() const
bool m_skipAfterLastDetector
const std::vector< MaterialAccountingStep > & steps() const
double averageRadiationLengths(void) const
return the average normalized number of radiation lengths
double sigmaLength(void) const
return the sigma of the normalized layer thickness
double sigmaRadiationLengths(void) const
return the sigma of the normalized number of radiation lengths
~TrackingMaterialAnalyser() override
Geom::Phi< T > phi() const
double length(void) const
double sigmaEnergyLoss(void) const
return the sigma of the normalized energy loss density factor for Bethe-Bloch
def setup(process, global_tag, zero_tesla=False)
void split(MaterialAccountingTrack &track)
unsigned int tracks(void) const
return the number of tracks that hit this layer
double averageLength(void) const
return the average normalized layer thickness
void saveXml(const char *name)
void saveParameters(const char *name)
int findLayer(const MaterialAccountingDetector &detector)
#define DEFINE_FWK_MODULE(type)
def detectors(dt=True, csc=True, me42=False, chambers=True, superlayers=False, layers=False)
double averageEnergyLoss(void) const
return the average normalized energy loss density factor for Bethe-Bloch
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
format
Some error handling for the usage.
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< std::vector< MaterialAccountingTrack > > m_materialToken
const std::string & name(void) const
get the layer name
std::vector< std::string > m_groupNames
TrackingMaterialPlotter * m_plotter
std::vector< MaterialAccountingGroup * > m_groups
bool m_skipBeforeFirstDetector
void savePlots(void)
save the plots
std::pair< MaterialAccountingStep, MaterialAccountingStep > split(double fraction) const
split the step (0..1) in (0..f) + (f..1) using linear interpolation
const GlobalPoint & position() const
TrackingMaterialAnalyser(const edm::ParameterSet &)
void plotSegmentInLayer(const MaterialAccountingStep &step, int layer)
const MaterialAccountingStep & summary() const