19 #include "TPolyLine3D.h" 
   20 #include "TPolyMarker3D.h" 
   41 int main( 
int argc, 
char** argv ) {
 
   42   cout << 
"JMarkovPathDisplayer" << endl 
 
   43        << 
"Written by Martijn Jongen" << endl 
 
   45   cout << 
"Type '" << argv[0] << 
" -h!' to display the command-line options." << endl ;
 
   49   string ofname = 
"out.root" ;
 
   54     zap[
"f"] = 
make_field(ifnames,
"input file name (binary file containing JPhotonPaths)") ;
 
   55     zap[
"o"] = 
make_field(ofname,
"output file name") ;
 
   56     zap[
"n"] = 
make_field(npaths_to_draw,
"max number of paths to draw") = 200 ;
 
   58     if (zap.
read(argc, argv) != 0) {
 
   62   catch(
const exception &error) {
 
   68   cout << 
"Reading files." << endl ;
 
   71     cout << 
"Reading '" << *it << 
"'." << endl ;
 
   74     reader.open(it->c_str()) ;
 
   75     if( !reader.is_open() ) {
 
   76       cerr << 
"FATAL ERROR: unable to open input file '" << *it << 
"'." << endl ;
 
   81     while( reader.hasNext() && nread_total<=npaths_to_draw ) {
 
   87     cout << 
"--> read " << nread << 
" paths." << endl ;
 
   91   cout << 
"Done reading paths." << endl ;
 
   94   if( nread_total == 0 ) {
 
   95     cerr << 
"FATAL ERROR: could not read any JPhotonPaths from the file(s)." << endl ;
 
   99   cout << 
"Done reading files. Read " << nread_total << 
" paths from it." << endl ;
 
  103   double xmin    = 1.0/0.0  ;
 
  104   double xmax    = -1.0/0.0 ;
 
  105   double ymin    = 1.0/0.0  ;
 
  106   double ymax    = -1.0/0.0 ;
 
  107   double zmin    = 1.0/0.0  ;
 
  108   double zmax    = -1.0/0.0 ;
 
  114   TRandom3* ran = 
new TRandom3(0) ;
 
  117   npaths_to_draw = min(npaths_to_draw,nread_total) ;
 
  120   for( 
int i=0 ; i<npaths_to_draw ; ++i ) {
 
  121     int nvert = paths[i].size() ; 
 
  124     TPolyLine3D* pl = 
new TPolyLine3D(nvert) ;
 
  125     pl->SetLineWidth(1) ;
 
  126     pl->SetLineColor(kCyan) ;
 
  127     to_draw.push_back(pl) ;
 
  129     for( 
int j=0 ; 
j<nvert ; ++
j ) {
 
  130       double x = paths[i][
j].getX() ;
 
  131       double y = paths[i][
j].getY() ;
 
  132       double z = paths[i][
j].getZ() ;
 
  134       if( 
y>ymax ) ymax = 
y ;
 
  136       if( 
y<ymin ) ymin = 
y ;
 
  137       if( z<zmin )  zmin = z  ;
 
  138       if( z>zmax )  zmax = z  ;
 
  139       pl->SetPoint( 
j, 
x, 
y, z ) ;
 
  141     xsource = paths[i][0] ;
 
  142     xtarget = paths[i][nvert-1] ;
 
  149   if( ymax-ymin > range ) range = ymax-ymin ;
 
  150   if( zmax-zmin > range ) range = zmax-zmin ;
 
  158   extra = 0.5*(range-ymax-ymin) ;
 
  162   extra = 0.5*(range-zmax-zmin) ;
 
  166   cout << 
"DIMENSIONS: " << endl
 
  167        << 
"x = [ " << 
xmin << 
" , " << 
xmax << 
" ] [m]" << endl 
 
  168        << 
"y = [ " << ymin << 
" , " << 
xmax << 
" ] [m]" << endl 
 
  169        << 
"z = [ " << zmin << 
" , " << 
xmax << 
" ] [m]" << endl ;
 
  173   cout << 
"Creating and filling TH3F" << endl ;
 
  175   TH3F* h3 = 
new TH3F(
"hPathDensity_Z",
 
  176                       "Local path density;X [m];Y [m];Z [m]",
 
  179                       nbinsh3,zmin,zmax ) ;
 
  180   h3->SetOption(
"colz") ;
 
  181   for( Int_t zbin=1 ; zbin<=nbinsh3 ; ++zbin ) {
 
  182     double z = h3->GetZaxis()->GetBinCenter(zbin) ;
 
  183     for( 
int i=0 ; i<nread_total ; ++i ) {
 
  186         h3->Fill( it->getX(), it->getY(), it->getZ() ) ;
 
  190   cout << 
"TH3F filled!" << endl ;
 
  194   cout << 
"Creating and filling TH3F" << endl ;
 
  195   TH3F* h3X = 
new TH3F(
"hPathDensity_X",
 
  196                       "Local path density;X [m];Y [m];Z [m]",
 
  199                       nbinsh3,zmin,zmax ) ;
 
  200   h3X->SetOption(
"colz") ;
 
  201   for( Int_t xbin=1 ; xbin<=nbinsh3 ; ++xbin ) {
 
  202     double x = h3X->GetXaxis()->GetBinCenter(xbin) ;
 
  203     for( 
int i=0 ; i<nread_total ; ++i ) {
 
  206         h3X->Fill( it->getX(), it->getY(), it->getZ() ) ;
 
  210   cout << 
"TH3F filled!" << endl ;
 
  243   double csize = 2048 ;
 
  244   TCanvas* cDisplay = 
new TCanvas(
"cDisplay",
"Display",10,10,csize,csize) ;
 
  245   TPad* pad1 = 
new TPad(
"pad1",
"pad1",0,0,1,1,kBlue+4) ;
 
  248   TView3D* view = (TView3D*)TView::CreateView(1) ;
 
  250   view->SetRange(
xmin,ymin,zmin,
 
  256   TPolyMarker3D* pm = 
new TPolyMarker3D(2,1) ;
 
  257   pm->SetPoint(0, xsource.
getX(), xsource.
getY(), xsource.
getZ() ) ;
 
  258   pm->SetPoint(1, xtarget.
getX(), xtarget.
getY(), xtarget.
getZ() ) ;
 
  259   pm->SetMarkerSize(2) ;
 
  260   pm->SetMarkerColor(kRed) ;
 
  261   pm->SetMarkerStyle(20) ;
 
  268   cDisplay->SaveAs(
"display.png") ;
 
  269   cDisplay->SaveAs(
"display.pdf") ;
 
  270   cout << 
"Output in 'display.png'." << endl ;
 
  289   TFile* fout = 
new TFile(ofname.c_str(),
"recreate") ;
 
  295   cout << 
"Output written to '" << ofname << 
"'." << endl ;
 
  297   cout << 
"Done!" << endl ;
 
int main(int argc, char **argv)
 
Utility class to parse command line options.
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
Data structure for position in three dimensions.
 
double getY() const
Get y position.
 
double getZ() const
Get z position.
 
double getX() const
Get x position.
 
Utility class to parse command line options.
 
int read(const int argc, const char *const argv[])
Parse the program's command line options.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).