// Author: Egon Pavlica <http://www.ses-ng.si/~pavlica/>

#include "LMonitor.h"

//________________________________________
//
//     This class is used to visualize
//     particle track
//
// Logs:
//
//  $Log: LMonitor.cc,v $
//  Revision 1.2  2003/06/26 11:24:25  cvs
//  modified particle moving with LMiki and faster LDisorder operations
//

ClassImp(LMonitor)

 LMonitor::LMonitor(){
  //default constructor
  fline=0;
  fspace=0;
  fview=0;
  fcanvas=0;
  fcanvas2=0;
  fe=0;
};

 LMonitor::LMonitor(LSpace* space){
  //set a conection between lattice, particle and monitor, create canvas and view
  fcanvas=0;
  fcanvas2=0;
  fe=0;
  fspace=space;
  fline=0;
  fview=0;
  fenergy=0;
  feidx=1;
}


 LMonitor::~LMonitor(){
  //default destructor
  if (!fline) delete fline;
  if (!fview) delete fview;
  if (!fenergy) delete fenergy;
  fe=0;
  fcanvas=0;
  fcanvas2=0;
  fspace=0;
};

 void LMonitor::AddCurrent(){
  //add current position of e particle to the monitor if canvas is set
  //it draw line and update the canvas
  //if (fcanvas) fcanvas->cd(1);

  if (fcanvas) {
    fcanvas->cd();
    if (!fview){
      fview=new TView(1);
      fview->SetRange(1,1,1,fspace->GetX(),fspace->GetY(),fspace->GetZ());
      //    fview->SetRange(-fspace->GetX(),-fspace->GetY(),1,fspace->GetX(),fspace->GetY(),fspace->GetZ());
      if (fverbose) std::cout<<"view createdn";
      fview->ShowAxis();
    }    

    if (!fline) {
      fline=new TPolyLine3D(1);
      fline->SetPoint(0,fe->i,fe->j,fe->k);
      if (fverbose) std::cout<<"line createdn";
    }
    else
      fline->SetNextPoint(fe->i,fe->j,fe->k);
    fline->Draw();
    fcanvas->Update();
  }

  if (fcanvas2) { 
    fcanvas2->cd();
    if (!fenergy) {
      fenergy=new TH1F("energy","Particle Energy",100,1,100);  
      fenergy->SetBinContent(feidx++,fe->GetEnergy());
    } else 
      fenergy->SetBinContent(feidx++,fe->GetEnergy());

    if (feidx>100) feidx=1;
    fenergy->Draw();

    fcanvas2->Update();
  }
  
}


 void LMonitor::DrawProbability(float* prob,int n,int idx){
  //draws probability historgram
  TH1F proba("prob","Probability",n,1,n);
  for (int i=1;i<=n;i++) proba.SetBinContent(i,prob[i]);
  std::cout<<"Index:"<<idx<<std::endl;
  proba.Draw();
  if (fcanvas)  fcanvas->Update();
  while (!getchar());
}





ROOT page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.