Skip to content

Commit 774e317

Browse files
committed
fix debug print and better format code
1 parent 349f19c commit 774e317

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

SimDataFormats/Track/interface/SimTrack.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class SimTrack : public CoreSimTrack {
3434
bool noVertex() const { return ivert == -1; }
3535

3636
/// index of the corresponding Generator particle in the Event container (-1 if no Genpart)
37+
bool isPrimary() const { return (trackInfo_ >> 1) & 1; }
3738
int genpartIndex() const { return isPrimary() ? igenpart : -1; }
3839
bool noGenpart() const { return isPrimary() ? igenpart == -1 : true; }
3940

@@ -52,7 +53,7 @@ class SimTrack : public CoreSimTrack {
5253
math::XYZTLorentzVectorF positionAtBoundary,
5354
math::XYZTLorentzVectorF momentumAtBoundary) {
5455
if (crossedBoundary)
55-
trackInfo_ |= 1 << 2;
56+
trackInfo_ |= (1 << 2);
5657
idAtBoundary_ = idAtBoundary;
5758
positionAtBoundary_ = positionAtBoundary;
5859
momentumAtBoundary_ = momentumAtBoundary;
@@ -62,11 +63,10 @@ class SimTrack : public CoreSimTrack {
6263
const math::XYZTLorentzVectorF& getMomentumAtBoundary() const { return momentumAtBoundary_; }
6364
int getIDAtBoundary() const { return idAtBoundary_; }
6465

65-
bool isFromBackScattering() const { return (trackInfo_ >> 0) & 1; }
66-
void setFromBackScattering() { trackInfo_ |= 1 << 0; }
66+
bool isFromBackScattering() const { return trackInfo_ & 1; }
67+
void setFromBackScattering() { trackInfo_ |= 1; }
6768

68-
bool isPrimary() const { return (trackInfo_ >> 1) & 1; }
69-
void setIsPrimary() { trackInfo_ |= 1 << 1; }
69+
void setIsPrimary() { trackInfo_ |= (1 << 1); }
7070
void setGenParticleID(const int idx) { igenpart = idx; }
7171
int getPrimaryID() const { return igenpart; }
7272
uint8_t getTrackInfo() const { return trackInfo_; }

SimG4Core/Application/plugins/OscarMTProducer.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ void OscarMTProducer::produce(edm::Event& e, const edm::EventSetup& es) {
251251

252252
if (0 < m_verbose) {
253253
edm::LogVerbatim("SimG4CoreApplication")
254-
<< "Produced " << p2->size() << " SimVertecies: position(cm), time(s), parentID, vertexID, processType";
254+
<< "Produced " << p2->size() << " SimVertices: position(cm), time(s), parentID, vertexID, processType";
255255
if (1 < m_verbose) {
256256
int nn = p2->size();
257257
for (int i = 0; i < nn; ++i) {
@@ -260,12 +260,15 @@ void OscarMTProducer::produce(edm::Event& e, const edm::EventSetup& es) {
260260
}
261261
edm::LogVerbatim("SimG4CoreApplication")
262262
<< "Produced " << p1->size()
263-
<< " SimTracks: pdg, 4-momentum(GeV), vertexID, mcTruthID, flagBoundary, trackID at boundary";
263+
<< " SimTracks: G4 Id, pdg, 4-momentum(GeV), vertexID, mcTruthID, crossedBoundary, trackID at boundary, from "
264+
"backscattering, isPrimary, getPrimary";
264265
if (1 < m_verbose) {
265266
int nn = p1->size();
266267
for (int i = 0; i < nn; ++i) {
267-
edm::LogVerbatim("Track") << " " << i << ". " << (*p1)[i] << " " << (*p1)[i].crossedBoundary() << " "
268-
<< (*p1)[i].getIDAtBoundary();
268+
edm::LogVerbatim("Track") << " " << i << ". " << (*p1)[i].trackId() << " " << (*p1)[i] << " "
269+
<< (*p1)[i].crossedBoundary() << " " << (*p1)[i].getIDAtBoundary() << " "
270+
<< (*p1)[i].isFromBackScattering() << " " << (*p1)[i].isPrimary() << " "
271+
<< (*p1)[i].getPrimaryID();
269272
}
270273
}
271274
}

SimG4Core/Notification/src/SimTrackManager.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void SimTrackManager::addTrack(TrackWithHistory* iTrack, const G4Track* track, b
7373
std::pair<int, int> thePair(iTrack->trackID(), iTrack->parentID());
7474
idsave.push_back(thePair);
7575
if (inHistory) {
76-
auto info = static_cast<const TrackInformation *>(track->GetUserInformation());
76+
auto info = static_cast<const TrackInformation*>(track->GetUserInformation());
7777
if (info->isInTrkFromBackscattering())
7878
iTrack->setFromBackScattering();
7979
// set there *for all the tracks* the genParticle ID associated with the G4Track
@@ -131,18 +131,18 @@ void SimTrackManager::storeTracks() {
131131
void SimTrackManager::reallyStoreTracks() {
132132
// loop over the (now ordered) vector and really save the tracks
133133
#ifdef DebugLog
134-
edm::LogVerbatim("SimTrackManager") << "reallyStoreTracks() NtracksWithHistory= " << m_trackContainer->size();
134+
edm::LogVerbatim("SimTrackManager") << "reallyStoreTracks() NtracksWithHistory= " << m_trackContainer.size();
135135
#endif
136136

137137
int nn = m_endPoints.size();
138138
for (auto& trkH : m_trackContainer) {
139139
// at this stage there is one vertex per track,
140140
// so the vertex id of track N is also N
141141
int iParentID = trkH->parentID();
142-
int ig = trkH->genParticleID(); // filled only for primary tracks
142+
int ig = trkH->genParticleID(); // filled only for primary tracks
143143
bool isBackScatter = trkH->isFromBackScattering();
144144
bool isPrimary = trkH->isPrimary();
145-
int primaryGenPartId = trkH->getPrimaryID(); // filled if the G4Track had this info
145+
int primaryGenPartId = trkH->getPrimaryID(); // filled if the G4Track had this info
146146
int ivertex = getOrCreateVertex(trkH, iParentID);
147147

148148
auto ptr = trkH;
@@ -319,7 +319,7 @@ void SimTrackManager::cleanTracksWithHistory() {
319319
std::stable_sort(idsave.begin(), idsave.end());
320320

321321
#ifdef DebugLog
322-
LogDebug("SimTrackManager") << " SimTrackManager::cleanTracksWithHistory knows " << m_trksForThisEvent->size()
322+
LogDebug("SimTrackManager") << " SimTrackManager::cleanTracksWithHistory knows " << m_trackContainer.size()
323323
<< " tracks with history before branching";
324324
for (unsigned int it = 0; it < m_trackContainer.size(); it++) {
325325
LogDebug("SimTrackManager") << " 1 - Track in position " << it << " G4 track number "

SimG4Core/Notification/src/TmpSimEvent.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void TmpSimEvent::load(edm::SimTrackContainer& c) const {
3737
int id = trk->id();
3838
bool isBackScatter = trk->isFromBackScattering();
3939
bool isPrimary = trk->isPrimary();
40-
int primaryGenPartId = trk->getPrimaryID(); // filled if the G4Track had this info
40+
int primaryGenPartId = trk->getPrimaryID(); // filled if the G4Track had this info
4141
// ip = particle ID as PDG
4242
// p = 4-momentum in GeV
4343
// iv = corresponding TmpSimVertex index

0 commit comments

Comments
 (0)