Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run3-alca222X Utilize MessageLogger rather than cout in Calibration/IsolatedParticles #37516

Merged
merged 1 commit into from Apr 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 12 additions & 5 deletions Calibration/IsolatedParticles/plugins/IsolatedTracksNxN.cc
Expand Up @@ -20,6 +20,7 @@
#include <cmath>
#include <map>
#include <memory>
#include <sstream>
#include <string>
#include <vector>

Expand Down Expand Up @@ -2760,18 +2761,24 @@ void IsolatedTracksNxN::printTrack(const reco::Track *pTrack) {
if (printTrkHitPattern_) {
const reco::HitPattern &p = pTrack->hitPattern();

edm::LogVerbatim("IsoTrack") << "default ";
std::ostringstream st1;
st1 << "default ";
Comment on lines +2764 to +2765
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this change? Is it that LogVerbatim didnt print out? You could use LogPrint instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We like to print the whole sequence through some messagelogger - we chose Verbatim - we are putting the header as well as the messages from printHitPattern from all tracks of the same category and put in the output stream

for (int i = 0; i < p.numberOfAllHits(reco::HitPattern::TRACK_HITS); i++) {
p.printHitPattern(reco::HitPattern::TRACK_HITS, i, std::cout);
}
edm::LogVerbatim("IsoTrack") << "trackerMissingInnerHits() ";
edm::LogVerbatim("IsoTrack") << st1.str();
std::ostringstream st2;
st2 << "trackerMissingInnerHits() ";
for (int i = 0; i < p.numberOfAllHits(reco::HitPattern::MISSING_INNER_HITS); i++) {
p.printHitPattern(reco::HitPattern::MISSING_INNER_HITS, i, std::cout);
p.printHitPattern(reco::HitPattern::MISSING_INNER_HITS, i, st2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldnt this be better just to rewrite the function printHitPattern so it can take the LogPrint as an input?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a tracker specific method and there are calls to this method from other places in CMSSW.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let me tag @mmusich to see what he thinks about this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess my question is whether the std::ostream is thread-safe or not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the way is done here is correct, also I don't see benefits in changing printHitPattern (which is not Tracker-specific code, by the way, but a method of any track), as doing it the way you propose would loose some generality.

}
edm::LogVerbatim("IsoTrack") << "trackerMissingOuterHits() ";
edm::LogVerbatim("IsoTrack") << st2.str();
std::ostringstream st3;
st3 << "trackerMissingOuterHits() ";
for (int i = 0; i < p.numberOfAllHits(reco::HitPattern::MISSING_OUTER_HITS); i++) {
p.printHitPattern(reco::HitPattern::MISSING_OUTER_HITS, i, std::cout);
p.printHitPattern(reco::HitPattern::MISSING_OUTER_HITS, i, st3);
}
edm::LogVerbatim("IsoTrack") << st3.str();

edm::LogVerbatim("IsoTrack") << "\n \t trackerLayersWithMeasurement() " << p.trackerLayersWithMeasurement()
<< "\n \t pixelLayersWithMeasurement() " << p.pixelLayersWithMeasurement()
Expand Down