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

removal of statics from FastSimulation/Event/interface/FBaseSimEvent.icc #1462

Merged
merged 1 commit into from Nov 14, 2013
Merged
Show file tree
Hide file tree
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
23 changes: 16 additions & 7 deletions FastSimulation/Event/interface/FBaseSimEvent.icc
Expand Up @@ -2,17 +2,26 @@
#include "FastSimulation/Event/interface/FSimVertex.h"
#include "FastSimDataFormats/NuclearInteractions/interface/FSimVertexType.h"

static FSimTrack oTrack;
inline FSimTrack& FBaseSimEvent::track(int i) const {
return (i>=0 && i<(int)nTracks()) ? (*theSimTracks)[i] : oTrack; }
if (i < 0 || i>=(int)nTracks()){
throw cms::Exception("FastSim") << "Index for FSimTracks out of range, please contact FastSim developers"<< std::endl;
}
return (*theSimTracks)[i];
}

static FSimVertex oVertex;
inline FSimVertex& FBaseSimEvent::vertex(int i) const {
return (i>=0 && i<(int)nVertices()) ? (*theSimVertices)[i] : oVertex; }
if (i < 0 || i>=(int)nVertices()){
throw cms::Exception("FastSim") << "Index for FSimVertex out of range, please contact FastSim developers"<< std::endl;
}
return (*theSimVertices)[i];
}

static FSimVertexType oVertexType;
inline FSimVertexType& FBaseSimEvent::vertexType(int i) const {
return (i>=0 && i<(int)nVertices()) ? (*theFSimVerticesType)[i] : oVertexType; }
inline FSimVertexType& FBaseSimEvent::vertexType(int i) const {
if (i < 0 || i >=(int)nVertices()){
throw cms::Exception("FastSim") << "Index for FSimVertexType out of range, please contact FastSim developers"<< std::endl;
}
return (*theFSimVerticesType)[i];
}

inline const SimTrack& FBaseSimEvent::embdTrack(int i) const {
return (*theSimTracks)[i].simTrack(); }
Expand Down
56 changes: 42 additions & 14 deletions FastSimulation/Event/interface/FSimTrack.icc
Expand Up @@ -3,33 +3,61 @@

inline const FSimVertex& FSimTrack::vertex() const{ return mom_->vertex(vertIndex()); }

inline const FSimVertex& FSimTrack::endVertex() const { return mom_->vertex(endv_); }
inline const FSimVertex& FSimTrack::endVertex() const {
if(endv_ < 0)
throw cms::Exception("FastSim") << "FSimTrack::endVertex() called for FSimTrack w/o end vertex, please contact FastSim developers" << std::endl;
return mom_->vertex(endv_);
}

inline const FSimTrack& FSimTrack::mother() const{ return vertex().parent(); }
inline const FSimTrack& FSimTrack::mother() const{
if(noMother()){
throw cms::Exception("FastSim") << "FSimTrack::mother() called for FSimTrack w/o mother, please contact FastSim developers" << std::endl;
}
return vertex().parent();
}

inline const FSimTrack& FSimTrack::daughter(int i) const {
return abs(type()) != 11 && abs(type()) != 13 ? endVertex().daughter(i) : mom_->track(daugh_[i]);
inline const FSimTrack& FSimTrack::daughter(int i) const {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Andrea,
would there be a particular reason why the special treatment is only for electrons and not for muons?
at all other places in this file, muons and electrons are treated equal

if(i < 0 || i >= nDaughters())
throw cms::Exception("FastSim") << "FSimTrack::daughter(int index) index out of range, please contact FastSim developers" << std::endl;
if(abs(type()) == 11 || abs(type()) == 13)
return mom_->track(daugh_[i]);
else
return endVertex().daughter(i);
}

inline int FSimTrack::nDaughters() const {
return abs(type()) != 11 && abs(type()) != 13 ? endVertex().nDaughters() : daugh_.size();
inline int FSimTrack::nDaughters() const {
if(abs(type()) == 11 || abs(type()) == 13)
return daugh_.size();
else{
if(noEndVertex())
return 0;
else
return endVertex().nDaughters();
}
}

inline const std::vector<int>& FSimTrack::daughters() const {
return abs(type()) != 11 ? endVertex().daughters() : daugh_;
inline const std::vector<int>& FSimTrack::daughters() const {
if(abs(type()) == 11)
return daugh_;
else{
if(noEndVertex())
throw cms::Exception("FastSim") << "FSimTrack::daughter(int index) called for FSimTrack w/o end vertex, please contact FastSim developers" << std::endl;
return endVertex().daughters();
}
}

inline bool FSimTrack::noEndVertex() const {

// The particle either has no end vertex index
if(endv_ < 0)
return true;

// or it's an electron/muon that has just Brem'ed, but continues its way
// ... but not those intermediate e/mu PYTHIA entries with prompt Brem
bool bremOutOfPipe = true;
if( (mom_->vertex(endv_)).position().Perp2() < 1.0 ) bremOutOfPipe = false;

return
// The particle either has no end vertex index
endv_ == -1 ||
// or it's an electron/muon that has just Brem'ed, but continues its way
// ... but not those intermediate e/mu PYTHIA entries with prompt Brem
( (abs(type())==11 || abs(type())==13) &&
( (abs(type())==11 || abs(type())==13) &&
bremOutOfPipe &&
endVertex().nDaughters()>0 &&
endVertex().daughter(endVertex().nDaughters()-1).type()==22);
Expand Down
2 changes: 1 addition & 1 deletion FastSimulation/Event/src/FSimEvent.cc
Expand Up @@ -73,7 +73,7 @@ FSimEvent::load(edm::SimTrackContainer & c, edm::SimTrackContainer & m) const
fabs(t.momentum().eta()) < 3.0 &&
track(i).noEndVertex() ) {
// Actually save the muon mother (and the attached muon) in case
if ( track(i).mother().closestDaughterId() == (int)i ) {
if ( !track(i).noMother() && track(i).mother().closestDaughterId() == (int)i ) {
const SimTrack& T = embdTrack(track(i).mother().id());
m.push_back(T);
}
Expand Down
2 changes: 1 addition & 1 deletion FastSimulation/TrajectoryManager/src/TrajectoryManager.cc
Expand Up @@ -679,7 +679,7 @@ TrajectoryManager::makeSinglePSimHit( const GeomDetUnit& det,
// daughter to the mother's track. The same applies to a charged particle decay into
// another charged particle.
int localTkID = tkID;
if ( mySimEvent->track(tkID).mother().closestDaughterId() == tkID )
if ( !mySimEvent->track(tkID).noMother() && mySimEvent->track(tkID).mother().closestDaughterId() == tkID )
localTkID = mySimEvent->track(tkID).mother().id();

// FIXME: fix the track ID and the particle ID
Expand Down