Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion inc/MCStepInfo.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ namespace mu2e {
XYZVectorF pos; // particle position at the start of this step
void reset() {*this = MCStepInfo(); }
bool valid() { return vid>=0; }
int simid = -1; // SimParticle id
int simid = -1; // SimParticle id (the simulation-stage piece that made this step)
int originid = -1; // id of the first simulation-stage piece of this SimParticle, matching <trk>mcsim id; equals simid unless the particle crossed a simulation stage boundary
int pdg = -1; // true PDG code
int startCode = -1; // creation process code
int stopCode = -1; // stop process code
Expand Down
9 changes: 5 additions & 4 deletions inc/SimInfo.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@ namespace mu2e
// general info about the SimParticle which was simulated
struct SimInfo {
bool valid = false; // true/false as to whether the data is valid
int id = -1; // id number for SimParticle
int id = -1; // id number for SimParticle; for a particle split across simulation stages, the first stage, where the start values come from
int endid = -1; // id number of the SimParticle that stopCode, endpos and endmom come from; equals id unless the particle crossed a simulation stage boundary
int nhits = -1; // number of matched hits in the track generated by this particle
int nactive = -1; // number of active matched hits in the track generated by this particle
int rank = -1; // rank of this particle, by # of associated hits
int pdg = -1; // true PDG code
int startCode = -1; // creation process code
int stopCode = -1; // stop process code
int stopCode = -1; // stop process code (of the endid SimParticle)
int gen = -1; // generator code
float time = -1.0; // Origin time of the SimParticle [ns]
int index = -1; // index into the SimInfo vector
XYZVectorF mom = XYZVectorF(); // origin momentumof the SimParticle [MeV/c]
XYZVectorF pos = XYZVectorF(); // origin position of the SimParticle [mm, in detector coords]
XYZVectorF endmom = XYZVectorF(); // end momentumof the SimParticle [MeV/c]
XYZVectorF endpos = XYZVectorF(); // end position of the SimParticle [mm, in detector coords]
XYZVectorF endmom = XYZVectorF(); // end momentum of the endid SimParticle [MeV/c]
XYZVectorF endpos = XYZVectorF(); // end position of the endid SimParticle [mm, in detector coords]
MCRelationship prirel = MCRelationship(); // relationship to the event primary particles
MCRelationship trkrel = MCRelationship(); // relationship to the particle that created hits in the track
void reset() { *this = SimInfo(); }
Expand Down
19 changes: 16 additions & 3 deletions src/InfoMCStructHelper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@

namespace mu2e {

namespace {
// id of the first simulation-stage piece of this particle, as in
// SimParticle::originParticle(), but stopping at a parent piece that was not kept
int originId(SimParticle const& sp) {
SimParticle const* piece = &sp;
while (piece->selfParent() && piece->parent().isAvailable()) {
piece = piece->parent().get();
}
return piece->id().asInt();
}
}

InfoMCStructHelper::InfoMCStructHelper(const Config& conf) :
_spctag(conf.spctag()), _mingood(conf.mingood()),
_maxdt(conf.maxvddt()),
Expand Down Expand Up @@ -291,17 +303,16 @@ namespace mu2e {
siminfo.id = sp.id().asInt();
if(sp.genParticle().isNonnull()) { siminfo.gen = sp.genParticle()->generatorId().id(); }
siminfo.startCode = sp.creationCode();
siminfo.stopCode = sp.stoppingCode();
siminfo.pdg = sp.pdgId();
siminfo.time = sp.startGlobalTime();
siminfo.mom = XYZVectorF(sp.startMomentum());
siminfo.pos = XYZVectorF(det->toDetector(sp.startPosition()));
siminfo.endpos = XYZVectorF(det->toDetector(sp.endPosition()));
siminfo.endmom = XYZVectorF(sp.endMomentum());
fillSimInfoEnd(sp, siminfo);
}

void InfoMCStructHelper::fillSimInfoEnd(const SimParticle& sp, SimInfo& siminfo) {
GeomHandle<DetectorSystem> det;
siminfo.endid = sp.id().asInt();
siminfo.stopCode = sp.stoppingCode();
siminfo.endpos = XYZVectorF(det->toDetector(sp.endPosition()));
siminfo.endmom = XYZVectorF(sp.endMomentum());
Expand Down Expand Up @@ -577,6 +588,7 @@ namespace mu2e {
mcsi.mom = mcstep.momentum();
mcsi.pos = spos;
mcsi.simid = mcstep.simParticle()->id().asInt();
mcsi.originid = originId(*mcstep.simParticle());
mcsi.pdg = mcstep.simParticle()->pdgId();
mcsi.startCode = mcstep.simParticle()->creationCode();
mcsi.stopCode = mcstep.simParticle()->stoppingCode();
Expand Down Expand Up @@ -618,6 +630,7 @@ namespace mu2e {
mcstepinfo.pos = XYZVectorF(det->toDetector(mcstep.position()));
const auto& simParticle = mcstep.simParticle();
mcstepinfo.simid = simParticle->id().asInt();
mcstepinfo.originid = originId(*simParticle);
mcstepinfo.pdg = simParticle->pdgId();
mcstepinfo.startCode = simParticle->creationCode();
mcstepinfo.stopCode = simParticle->stoppingCode();
Expand Down
4 changes: 4 additions & 0 deletions validation/create_val_file_rooutil.C
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ void create_val_file_rooutil(std::string filename, std::string outfilename) {

TH1F* h_trkmcsim_valid = new TH1F("h_trkmcsim_valid", "", 100,0,100);
TH1F* h_trkmcsim_id = new TH1F("h_trkmcsim_id", "", 100,0,100);
TH1F* h_trkmcsim_endid = new TH1F("h_trkmcsim_endid", "", 100,0,100);
TH1F* h_trkmcsim_nhits = new TH1F("h_trkmcsim_nhits", "", 100,0,100);
TH1F* h_trkmcsim_nactive = new TH1F("h_trkmcsim_nactive", "", 100,0,100);
TH1F* h_trkmcsim_rank = new TH1F("h_trkmcsim_rank", "", 100,0,100);
Expand Down Expand Up @@ -636,6 +637,7 @@ void create_val_file_rooutil(std::string filename, std::string outfilename) {
TH1F* h_mcsteps_virtualdetector_pos_y = new TH1F("h_mcsteps_virtualdetector_pos_y", "", 100,-1000,1000);
TH1F* h_mcsteps_virtualdetector_pos_z = new TH1F("h_mcsteps_virtualdetector_pos_z", "", 320,-1600,1600);
TH1F* h_mcsteps_virtualdetector_simid = new TH1F("h_mcsteps_virtualdetector_simid", "", 100,0,100);
TH1F* h_mcsteps_virtualdetector_originid = new TH1F("h_mcsteps_virtualdetector_originid", "", 100,0,100);
TH1F* h_mcsteps_virtualdetector_pdg = new TH1F("h_mcsteps_virtualdetector_pdg", "", 100,0,100);
TH1F* h_mcsteps_virtualdetector_startCode = new TH1F("h_mcsteps_virtualdetector_startCode", "", 100,0,100);
TH1F* h_mcsteps_virtualdetector_stopCode = new TH1F("h_mcsteps_virtualdetector_stopCode", "", 100,0,100);
Expand Down Expand Up @@ -847,6 +849,7 @@ void create_val_file_rooutil(std::string filename, std::string outfilename) {
for (const auto& trkmcsim : trkmcsims) {
h_trkmcsim_valid->Fill(trkmcsim.valid);
h_trkmcsim_id->Fill(trkmcsim.id);
h_trkmcsim_endid->Fill(trkmcsim.endid);
h_trkmcsim_nhits->Fill(trkmcsim.nhits);
h_trkmcsim_nactive->Fill(trkmcsim.nactive);
h_trkmcsim_rank->Fill(trkmcsim.rank);
Expand Down Expand Up @@ -1422,6 +1425,7 @@ void create_val_file_rooutil(std::string filename, std::string outfilename) {
h_mcsteps_virtualdetector_pos_y->Fill(vdstep.pos.y());
h_mcsteps_virtualdetector_pos_z->Fill(vdstep.pos.z());
h_mcsteps_virtualdetector_simid->Fill(vdstep.simid);
h_mcsteps_virtualdetector_originid->Fill(vdstep.originid);
h_mcsteps_virtualdetector_pdg->Fill(vdstep.pdg);
h_mcsteps_virtualdetector_startCode->Fill(vdstep.startCode);
h_mcsteps_virtualdetector_stopCode->Fill(vdstep.stopCode);
Expand Down