#include #include #include #include #include #include #include namespace RAT { UserTrackInformation::UserTrackInformation() : G4VUserTrackInformation() { photonHistory = 0; } UserTrackInformation::UserTrackInformation(const G4Track *aTrack) : G4VUserTrackInformation() { // Check if the input track has user info photonHistory = 0; const UserTrackInformation *trackHistory = dynamic_cast(aTrack->GetUserInformation()); if (trackHistory) { photonHistory = trackHistory->GetHistory(); } } UserTrackInformation::UserTrackInformation(const UserTrackInformation *aTrackInfo) : G4VUserTrackInformation() { // Check if the input track has user info photonHistory = 0; if (aTrackInfo) { photonHistory = aTrackInfo->GetHistory(); } } UserTrackInformation& UserTrackInformation::operator=(const UserTrackInformation &right) { photonHistory = right.photonHistory; return *this; } UserTrackInformation::~UserTrackInformation() { } void UserTrackInformation::ImportHistory(const UserTrackInformation *aTrackInfo) { // Do a bitwise or to contain both local and parent history if (aTrackInfo) { photonHistory |= aTrackInfo->GetHistory(); } } void UserTrackInformation::AddProcessToHistory(const G4Track *aTrack) { const G4VProcess *process = aTrack->GetCreatorProcess(); if (!process) { warn << "UserTrackInformation::AddProcessToHistory : Track does not yet have a process attached. Ignoring." << newline; return; } if (process->GetProcessType() == fOptical) { if ( process->GetProcessSubType() == fOpRayleigh) { AddToHistory(DS::MCPE::hRayleighScatt); } else if (process->GetProcessSubType() == fOpMieHG) { AddToHistory(DS::MCPE::hMieScatt); } else { warn << "UserTrackInformation::AddProcessToHistory : Unknown optical process subtype : " << process->GetProcessName() << newline; AddToHistory(DS::MCPE::hUnknown); } } else if (process->GetProcessType() == fUserDefined) { const G4String &pname = process->GetProcessName(); // This could means re-emission or scintillation if (pname == "Scintillation") { AddToHistory(DS::MCPE::hScintillation); } else if (pname.find("Reemission") != std::string::npos) { // This envelopes several types of reemission (from the different components) AddToHistory(DS::MCPE::hWLS); // Now should parse which component did that // The name of the process is of the type: 'Reemission_from_comp%d' // We just need to grab the %d // NFB: I hate this procedure, but I can't think of a faster one int component = atoi(pname.substr(pname.find_last_not_of("0123456789")+1).c_str()); // The component bits are all sequential // So we can use the component number as the offset // from the first component AddToHistory(static_cast(DS::MCPE::hWLSCOMP0+component)); } else { warn << "UserTrackInformation::AddProcessToHistory : Unknown user process : " << process->GetProcessName() << newline; AddToHistory(DS::MCPE::hUnknown); } } else if (process->GetProcessType() == fElectromagnetic) { if (process->GetProcessSubType() == fCerenkov) { AddToHistory(DS::MCPE::hCherenkov); } else { warn << "UserTrackInformation::AddProcessToHistory : Unknown EM process : " << process->GetProcessName() << newline; AddToHistory(DS::MCPE::hUnknown); } } else { warn << "UserTrackInformation::AddProcessToHistory : Unknown process : " << process->GetProcessName() << newline; AddToHistory(DS::MCPE::hUnknown); } } } /* namespace RAT */