void XRayWithROOT(int axis,
                 Vector3D<Precision> origin,
                 Vector3D<Precision> bbox,
                 Vector3D<Precision> dir,
                 double axis1_start, double axis1_end,
                 double axis2_start, double axis2_end,
                 int data_size_x,
                 int data_size_y,
                 double pixel_axis,
                 int * image) {

if(VERBOSE){
    std::cout << "from [" << axis1_start << ";" << axis2_start
              << "] to [" << axis1_end   << ";" << axis2_end << "]\n";
    std::cout << "Xpixels " << data_size_x << " YPixels " << data_size_y << "\n";

    std::cout << pixel_axis << "\n";
}

double pixel_width_1 = (axis1_end-axis1_start)/data_size_x;
double pixel_width_2 = (axis2_end-axis2_start)/data_size_y;

    if(VERBOSE){
    std::cout << pixel_width_1 << "\n";
    std::cout << pixel_width_2 << "\n";
    }

    for( int pixel_count_2 = 0; pixel_count_2 < data_size_y; ++pixel_count_2 ){
        for( int pixel_count_1 = 0; pixel_count_1 < data_size_x; ++pixel_count_1 )
        {
            double axis1_count = axis1_start + pixel_count_1 * pixel_width_1 + 1E-6;
            double axis2_count = axis2_start + pixel_count_2 * pixel_width_2 + 1E-6;

            if(VERBOSE) {
                std::cout << "\n OutputPoint("<< axis1_count<< ", "<< axis2_count<< ")\n";
            }
            // set start point of XRay
            Vector3D<Precision> p;

            if( axis== 1 )
              p.Set( origin[0]-bbox[0], axis1_count, axis2_count);
            else if( axis== 2)
              p.Set( axis1_count, origin[1]-bbox[1], axis2_count);
            else if( axis== 3)
              p.Set( axis1_count, axis2_count, origin[2]-bbox[2]);

            TGeoNavigator * nav = gGeoManager->GetCurrentNavigator();
            nav->SetCurrentPoint( p.x(), p.y(), p.z() );
            nav->SetCurrentDirection( dir.x(), dir.y(), dir.z() );

            double distancetravelled=0.;
            int crossedvolumecount=0;
            double accumulateddensity =0.;

            if(VERBOSE) {
              std::cout << " StartPoint(" << p[0] << ", " << p[1] << ", " << p[2] << ")";
              std::cout << " Direction <" << dir[0] << ", " << dir[1] << ", " << dir[2] << ">"<< std::endl;
            }

            // propagate until we leave detector
            TGeoNode const * node = nav->FindNode();
            TGeoMaterial const * curmat = node->GetVolume()->GetMaterial();

          //  std::cout << pixel_count_1 << " " << pixel_count_2 << " " << dir << "\t" << p << "\t";
          //  std::cout << "IN|OUT" << nav->IsOutside() << "\n";
          //  if( node ) std::cout <<    node->GetVolume()->GetName() << "\t";
            while( node !=NULL ) {
                node = nav->FindNextBoundaryAndStep( vecgeom::kInfinity );
                distancetravelled+=nav->GetStep();
                accumulateddensity+=curmat->GetDensity() * distancetravelled;

                if(VERBOSE) {
                    if( node != NULL ){
                        std::cout << "  VolumeName: "<< node->GetVolume()->GetName();
                    }
                    else
                       std::cout << "  NULL: ";

                    std::cout << " step[" << nav->GetStep()<< "]"<< std::endl;
                    double const * pROOT = nav->GetCurrentPoint();
                    p = Vector3D<Precision>(pROOT[0],pROOT[1],pROOT[2]);
                    std::cout << " point(" << p[0] << ", " << p[1] << ", " << p[2] << ")";
                }
                // Increase passed_volume
                // TODO: correct counting of travel in "world" bounding box
                crossedvolumecount++;
                curmat = (node!=0) ? node->GetVolume()->GetMaterial() : 0;
            } // end while
            // std::cout << crossedvolumecount << "\n";

            ///////////////////////////////////
            // Store the number of passed volume at 'volume_result'
            *(image+pixel_count_2*data_size_x+pixel_count_1) = crossedvolumecount;// accumulateddensity ;// crossedvolumecount;

            if(VERBOSE) {
                std::cout << "  EndOfBoundingBox:";
                std::cout << " PassedVolume:" << "<"<< crossedvolumecount << " ";
                std::cout << " step[" << nav->GetStep()<< "]";
                std::cout << " Distance: " << distancetravelled<< std::endl;
            }
      } // end inner loop
    } // end outer loop
} // end XRayWithROOT
Пример #2
0
void XRayWithROOT(int axis,
                 Vector3D<Precision> origin,
                 Vector3D<Precision> bbox,
                 Vector3D<Precision> dir,
                 double axis1_start, double axis1_end,
                 double axis2_start, double axis2_end,
                 int data_size_x,
                 int data_size_y,
                 double pixel_axis,
                 int * image) {

    int counter=0;

    // set start point of geantino
    Vector3D<Precision> p(0.,0.,0);

    TGeoNavigator * nav = gGeoManager->GetCurrentNavigator();
    nav->SetCurrentPoint( p.x(), p.y(), p.z() );
    nav->SetCurrentDirection( dir.x(), dir.y(), dir.z() );

    double distancetravelled=0.;
    int crossedvolumecount=0;

    if(VERBOSE) {
       std::cout << " StartPoint(" << p[0] << ", " << p[1] << ", " << p[2] << ")";
       std::cout << " Direction <" << dir[0] << ", " << dir[1] << ", " << dir[2] << ">"<< std::endl;
    }

    // propagate until we leave detector
    TGeoNode const * node = nav->FindNode();

    std::cout << "INITIAL MAT :" <<  node->GetVolume()->GetMaterial()->GetName() << "\n";

    //  if( node ) std::cout <<    node->GetVolume()->GetName() << "\t";
    while( node !=NULL ) {
       node = nav->FindNextBoundaryAndStep( vecgeom::kInfinity );
       distancetravelled+=nav->GetStep();
       counter++;

       if(VERBOSE) {
          if( node != NULL )
              std::cout << " *R " << counter << " * " << " point(" << p[0] << ", " << p[1] << ", " << p[2] << ") goes to " << " VolumeName: "<< node->GetVolume()->GetName()
              << " (MAT: " << node->GetVolume()->GetMaterial()->GetName() << ") :";
          else
              std::cout << "  NULL: ";

          std::cout << " step[" << nav->GetStep()<< "]"<< std::endl;
          double const * pROOT = nav->GetCurrentPoint();
          p = Vector3D<Precision>(pROOT[0],pROOT[1],pROOT[2]);
       }
       // Increase passed_volume
       // TODO: correct counting of travel in "world" bounding box
       crossedvolumecount++;
   } // end while
   // std::cout << crossedvolumecount << "\n";

    if(VERBOSE) {
        std::cout << " PassedVolume:" << "<"<< crossedvolumecount << " ";
        std::cout << " total distance travelled: " << distancetravelled<< std::endl;
    }
} // end XRayWithROOT