// @(#)codeTDv2Final/CTDR_Animation :$Name:  $:$Id: CTDR_Animation.h,v 1.7 2006/11/25 16:10:44 Benoit Exp $
// Author: Mathieu Benoit   24/11/06

/*************************************************************************
 * . Class CTDR_Animation					                 *
 *   Written by : Mathieu Benoit                                         *
 *   m.benoit@umontreal.ca						 *
 *************************************************************************/

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <string>
#include "CTDR_Animation.h"
using namespace std;

//////////////////////////////////////////////////////////////////////////
// This class is used to produce a root file containing the tracks of  	//
// the charge elements simulated. It creates a geometry, defined in the //
// the constructor, and everything needed to draw image and animation   //
// of the simulated event in the geometry . The root file can be read  	//
// using cint interpreter, and the geometry and the charge tracks can	//
// then be manipulated using functions provided with root's geometry  	//
// packages , see TGeoManager and TGeoTracks classes.	 		//
//////////////////////////////////////////////////////////////////////////

ClassImp(CTDR_Animation)

//______________________________________________________________________________
CTDR_Animation::CTDR_Animation(double lx, double ly, double lz,CTDR_Interaction &inter,int i , int j )
{
// This class builds a geometry and tracks object to put simulated data
// Lx,Ly,Lz are the dimensions of the box, inter, the interaction to be simulated, i and j ae ID for the
// root file name
                       char nom[50];
                        Lx=lx;
                        Ly=ly;
                        Lz=lz;
                        sprintf(nom,"CTDR_Animation_%i_%i.root",i,j);
                        f2= new TFile(nom,"RECREATE");
                        sprintf(nom,"Evenement_%i_%i",i,j);
                        Geo= new TGeoManager(nom,"CTDR_Animation du detecteur");

                        TGeoMedium *medium=0;
                        top = Geo->MakeBox("TOP",medium,1,1,(Lz/Lx));
                        Geo->SetTopVolume(top);
                        Double_t ori[3]={-0.5*3*(125.0/225)/2,-0.5*3*(125.0/225)/2,(Lz/Lx)-1e-9};



                        for(int i=0;i<4;i++){
                                for(int j=0;j<4;j++){
                                        sprintf(nom,"pix_%i_%i",i,j);
                                        ori[0]=-0.5*(3.0/2)+ 0.5*i;
                                        ori[1]=-0.5*(3.0/2)+ 0.5*j;;
                                        ori[2]=(Lz/Lx)-1e-9;
                                        Pix= new TGeoBBox(nom,0.25*125/225,0.25*125/225,1e-9,ori);
                                        sprintf(nom,"Pix_%i_%i",i,j);
                                        pix =new  TGeoVolume(nom,Pix);
                                        pix->SetLineColor(kRed);
                                        top->AddNode(pix,1);
                                        };};


                     Geo->CloseGeometry();
                     top->SetLineColor(kMagenta);

                     Geo->SetTopVisible();
                     for(int i=0;i<inter.GetN();i++){
                                  Geo->AddTrack(i,100);
                                  //Geo->GetCurrentTrack()->SetLineWidth(1);
                                  //Geo->GetCurrentTrack()->SetMarkerSize(4);
                                  };

};

//______________________________________________________________________________
void CTDR_Animation::AjoutePas(CTDR_Interaction &inter)
{
// This method adds a step to the animation by reading the data from the simulated interaction

     for(int i=0;i<inter.GetN();i++){
             if(inter.GetCharge(i).GetZ()<Lz){
             Geo->GetTrack(i)->AddPoint
             (2*inter.GetCharge(i).GetX()/Lx,2*inter.GetCharge(i).GetY()/Ly,2*(Lz/Lx)*(inter.GetCharge(i).GetZ()/Lz-0.5),inter.Gett());
             }
             else{Geo->GetTrack(i)->AddPoint
             (2*inter.GetCharge(i).GetX()/Lx,2*inter.GetCharge(i).GetY()/Ly,(Lz/Lx),inter.Gett());



                  };
                  };
};

//______________________________________________________________________________
void CTDR_Animation::Anime(int Npas,double Tmax)
{
// This function write the final objects to a root file 

     Geo->AnimateTracks(0,Tmax,Npas,"");
     Geo->Write();
};             





ROOT page - Class index - Class Hierarchy - 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.