Universita' di GenovaINFN Sezione di Genova  
AIRWATCH / EUSO Genova

EOpticsPhotonsPainter - source file

#include "EOpticsPhotonsPainter.hh"
#include "EDetPhoton.hh"
#include "Etypes.hh"

#include "TMath.h"
#include "TPad.h"
#include "TView.h"
#include "TPolyMarker3D.h"
#include "TAxis3D.h"
#include "TStyle.h"
#include "Riostream.h"

#include <TBuffer3D.h>
#include <TCanvas.h>
#include <TPaveText.h>
#include <map> 
#include <vector> 

using namespace TMath;

ClassImp(EOpticsPhotonsPainter)

//_____________________________________________________________________________
 EOpticsPhotonsPainter::EOpticsPhotonsPainter( EDetector *detector ) : fDetector(detector),fXmin(0),fXmax(0),fYmin(0),fYmax(0),fZmin(0),fZmax(0) {
  //
  // Constructor
  //

  BuildPoints();
}

//_____________________________________________________________________________
 EOpticsPhotonsPainter::~EOpticsPhotonsPainter() {
  //
  // Destructor
  //

}

//______________________________________________________________________________
 void EOpticsPhotonsPainter::BuildPoints() {
    //
    // Show photons in optics
    //


    if (fDetector->GetNumPhotons() < 1) {
        Info("BuildPoints","No photons loaded.");
        return;
    }

    map < Int_t, vector<Int_t> > fates;

    for (Int_t k = 0; k < fDetector->GetNumPhotons(); k++) {
        EDetPhoton *ph = fDetector->GetPhoton(k);
	if(ph->GetHistory() != kOptics) continue;

        fates[ph->GetFate()].push_back(k);
    }

    Int_t ncolor = 0;

    map < Int_t, vector<Int_t> >::const_iterator i;
    for (i = fates.begin(); i != fates.end(); i++){

        Int_t  color;

        if ( fates.size() == 1 ) color = kWhite;
        else 
            color = 51+(Int_t)(ncolor++*49/(fates.size()-1));
        fPoints[i->first] = new TPolyMarker3D(i->second.size()*3,fMarkerStyle,"");

        for ( UInt_t k(0); k < i->second.size(); k++) {
            EPhoton *ph = fDetector->GetPhoton(i->second[k]);

            fPoints[i->first]->SetPoint(k,ph->GetPos().X(),ph->GetPos().Y(),ph->GetPos().Z());
        } 

        fPoints[i->first]->SetMarkerColor(color);
    }

}

//______________________________________________________________________________
 void EOpticsPhotonsPainter::Draw( Option_t* option ) {
    //
    //
    //

    Bool_t has_pad = (gPad==0)?kFALSE:kTRUE;
    if (!gPad) {
        if (!gROOT->GetMakeDefCanvas()) return;
        (gROOT->GetMakeDefCanvas())();
    }
    
    AppendPad(option);

    // Create a 3-D view
    TView *view = gPad->GetView();
    if (!view) {
        view = new TView(11);
#if ( ROOT_VERSION_CODE <= ROOT_VERSION(4,03,02) )
        view->SetAutoRange(kTRUE);
        TBuffer3D *buff = gPad->GetBuffer3D();
        buff->fOption = TBuffer3D::kRANGE;
        Paint("range");
        buff->fOption = TBuffer3D::kPAD;
        view->SetAutoRange(kFALSE);
#else
        view->SetAutoRange(kTRUE);
        Paint("range");
        view->SetAutoRange(kFALSE);
#endif // ROOT_VERSION_CODE <= ROOT_VERSION(4,03,02)
        if (has_pad) gPad->Update();
    }

    if (!view->IsPerspective()) view->SetPerspective();

    TAxis3D::ToggleRulers();

}

//______________________________________________________________________________
 void EOpticsPhotonsPainter::Paint( Option_t* option ) {
    //
    //
    //

    map < Int_t, TPolyMarker3D* >::const_iterator j;
    for ( j=fPoints.begin(); j != fPoints.end(); j++ ) {
        j->second->Paint( option );
    }

}    
About Us | EUSO Official Website | Web pages created by Roberto Pesce and Alessandro Thea - Last Update Wed Nov 16 16:57:39 2005 Wed Nov 16 16:29:22 2005