Example #1
0
void EGS_ParticleTrackContainer::reportResults(bool with_header) {
    flushBuffer();

    // see how many tracks are still being scored
    int scoring = -1;
    if (m_isScoring) {
        scoring = 0;
        for (int i = 0; i < m_bufferSize; i++) {
            if (m_isScoring[i]) scoring++;
        }
    }

    if( with_header ) {
        egsInformation("\nParticle track scoring results:\n");
        egsInformation("=================================\n");
        egsInformation("   Total events scored:     %d\n", m_nEvents);
    }
    egsInformation("   Total tracks scored:     %d\n", m_totalTracks);
    egsInformation("   Still being scored:      ");
    if (scoring == -1) {
        egsInformation("Unknown!?\n");
    } else {
        egsInformation("%d\n", scoring);
        if (scoring > 0) {
            egsWarning("   *** There are particles still being tracked. This"
                       "   should never happen if this is the end of the simulation!");
        }
    }
    egsInformation("   Output file name:        %s\n\n", m_trspFilename.c_str());
}
EGS_SourceCollection::EGS_SourceCollection(EGS_Input *input,
        EGS_ObjectFactory *f) : EGS_BaseSource(input,f), nsource(0), count(0) {
    vector<EGS_BaseSource *> s;
    egsInformation("EGS_BaseSource::EGS_BaseSource: input is:\n");
    input->print(0,cout);
    EGS_Input *isource;
    while ((isource = input->takeInputItem("source",false))) {
        egsInformation("EGS_SourceCollection: got input\n");
        EGS_BaseSource *this_source = EGS_BaseSource::createSource(isource);
        if (!this_source) {
            egsWarning("EGS_SourceCollection: got null source\n");
        }
        else {
            s.push_back(this_source);
        }
        delete isource;
    }
    vector<string> snames;
    int err = input->getInput("source names",snames);
    if (!err) {
        for (unsigned int j=0; j<snames.size(); j++) {
            EGS_BaseSource *this_source = EGS_BaseSource::getSource(snames[j]);
            if (!this_source) {
                egsWarning("EGS_SourceCollection: got null source\n");
            }
            else {
                s.push_back(this_source);
            }
        }
    }
    if (s.size() < 1) {
        egsWarning("EGS_SourceCollection: no sources\n");
        return;
    }
    vector<EGS_Float> prob;
    err = input->getInput("weights",prob);
    if (err) {
        egsWarning("EGS_SourceCollection: missing 'weights' input\n");
        return;
    }
    if (prob.size() != s.size()) {
        egsWarning("EGS_SourceCollection: the number of sources (%d) is not"
                   " the same as the number of input probabilities (%d)\n",
                   s.size(),prob.size());
        return;
    }
    setUp(s,prob);
}
Example #3
0
    /*! Output of results.

     Here we simply use the reportResults() method of the scoring array
     object, which requires as argumenst a normalization constant, a
     title (reproduced in the output),
     a boolean flag and a format string. The format string will be used
     to output the result and its uncertainty in each region. The flag
     determines if absolute uncertainties should be printed (false) or
     relative uncertainties (true). The result in each region is multiplied
     by the normalization constant. Note that the reportResults()
     method of the scoring object automatically
     divides by the number of statistically independent events.
     We want our results to be normalized as fractions of the energy
     imparted into the geometry => we need last_case/Etot as a normalization
     constant. The quantities last_case and Etot are collected by the
     EGS_Application base class during the run.
    */
    void reportResults() {
        double norm = ((double)last_case)/Etot;
        egsInformation(" last case = %d Etot = %g\n",(int)last_case,Etot);
        edep->reportResults(norm,
                "Reflected/deposited/transmitted energy fraction",false,
                "  %d  %9.5f +/- %9.5f %c\n");
    };
Example #4
0
void EGS_Octree::printInfo() const {
    EGS_BaseGeometry::printInfo();
    egsInformation(" bounding box minimum     = %g %g %g\n", bbxmin, bbymin, bbzmin);
    egsInformation(" bounding box maximum     = %g %g %g\n", bbxmax, bbymax, bbzmax);
    egsInformation(" bounding box resolution  = %d %d %d\n", nx, ny, nz);
    egsInformation(" octree leaf size         = %g %g %g\n", dx, dy, dz);
    egsInformation(" octree cells (no medium) = %d\n", nreg-nLeaf);
    egsInformation(" octree cells (medium)    = %d\n", nLeaf);
    egsInformation(" octree average cell size = %.2f\n", nLeafMax/(float)nLeaf);
    char percent = '%';
    egsInformation(" octree cell savings      = %.1f%c\n", 100*(1-(float)nLeaf/nLeafMax),percent);
    egsInformation("=======================================================\n");
}
Example #5
0
int EGS_ParticleTrackContainer::readDataFile(const char *filename) {
    const char *func_name = "EGS_ParticleTrackContainer::readDataFile()";
    ifstream *data = new ifstream(filename, ios::binary);
    if (!data || data->fail() || !data->good()) {
        egsWarning("%s: Unable to open track space file '%s'! No tracks loaded\n",
                    func_name, filename);
        return -1;
    }
    data->read((char *)&m_totalTracks, sizeof(int));
    egsInformation("%s: Reading %d tracks from '%s' ...\n", func_name, m_totalTracks, filename);
    m_nTracks = 0;
    int totalVertices = 0;
    m_bufferSize = m_totalTracks;
    m_buffer = new EGS_ParticleTrack* [m_totalTracks];
    m_stackMap = new int [m_totalTracks];
    m_isScoring = new bool [m_totalTracks];
    for (int i = 0; i < m_totalTracks; i++) {
        int nvertices;
        m_buffer[i] = new EGS_ParticleTrack();
        m_stackMap[i] = -1;
        m_isScoring[i] = false;
        EGS_ParticleTrack::ParticleInfo *pinfo = new EGS_ParticleTrack::ParticleInfo(0);
        data->read((char *)&nvertices,sizeof(int));
        totalVertices += nvertices;
        data->read((char *)pinfo,sizeof(EGS_ParticleTrack::ParticleInfo));
        startNewTrack(pinfo);
        for (int j = 0; j < nvertices; j++) {
            EGS_ParticleTrack::Vertex* v = new EGS_ParticleTrack::Vertex();
            data->read((char *)v,sizeof(EGS_ParticleTrack::Vertex));
            addVertex(v);
        }
    }
    egsInformation("%s: Tracks in memory: %d\n", func_name, m_nTracks);
    egsInformation("%s: Total Vertices  : %d\n", func_name, totalVertices);

    return 0;
}
Example #6
0
void IAEA_PhspSource::setSimulationChunk(EGS_I64 nstart, EGS_I64 nrun) {
    if( nstart < 0 || nrun < 1 || nstart + nrun > Nparticle ) {
        egsWarning("IAEA_PhspSource::setSimulationChunk(): illegal attempt "
            "to set the simulation chunk between %lld and %lld ignored\n",
            nstart+1,nstart+nrun); return;
    }
    Nfirst = nstart+1; Nlast = nstart + nrun; Npos = nstart;
    iaea_set_record(&iaea_fileid,&Nfirst,&iaea_iostat);
    if(iaea_iostat<0) {
          egsWarning("IAEA_PhspSource::setSimulationChunk(): error setting phase space chunk\n");
          return;
    }
    egsInformation("IAEA_PhspSource: using phsp portion between %lld and %lld\n",
            Nfirst,Nlast);
}
Example #7
0
void EGS_BaseSource::addKnownSource(EGS_BaseSource *o) {
    if(o) egsInformation("Adding known source of type %s\n",
            o->getObjectType().c_str());
    source_creator.addKnownObject(o);
}
Example #8
0
void EGS_Box::printInfo() const {
    EGS_BaseGeometry::printInfo();
    egsInformation(" box size = %g %g %g\n",ax,ay,az);
    egsInformation("=======================================================\n");
}
Example #9
0
void EGS_TrackScoring::reportResults() {
    egsInformation("\nParticle Track Scoring (%s)\n",name.c_str());
    egsInformation("======================================================\n");
    egsInformation("   Total events scored:     %lld\n",m_nScore);
    if( m_pts ) m_pts->reportResults(false);
}