Fork me on GitHub

source: svn/trunk/Utilities/Hector/src/H_RectangularAperture.cc@ 271

Last change on this file since 271 was 3, checked in by Xavier Rouby, 16 years ago

first commit

File size: 1.6 KB
Line 
1/*
2---- Hector the simulator ----
3 A fast simulator of particles through generic beamlines.
4 J. de Favereau, X. Rouby ~~~ hector_devel@cp3.phys.ucl.ac.be
5
6 http://www.fynu.ucl.ac.be/hector.html
7
8 Centre de Physique des Particules et de Phénoménologie (CP3)
9 Université Catholique de Louvain (UCL)
10*/
11
12/// \file H_RectangularAperture.cc
13/// \brief Defines the rectangular aperture of beamline elements.
14
15// C++ #includes
16#include <iostream>
17
18// C #includes
19#include <cmath> // needed for fabs
20
21// ROOT #includes
22#include "TPave.h"
23
24// local #includes
25#include "H_RectangularAperture.h"
26using namespace std;
27
28H_RectangularAperture::H_RectangularAperture(const float l, const float h, const float posx, const float posy) :H_Aperture(RECTANGULAR,l,h,0,0,posx,posy) {
29 /// @param l, h are the length and height of the rectangular shape
30 /// @param posx, posy are the (x,y) coordinates of the center of the rectangular shape
31}
32
33H_RectangularAperture* H_RectangularAperture::clone() const {
34 return new H_RectangularAperture(x1,x2,fx,fy);
35}
36
37bool H_RectangularAperture::isInside(const float x, const float y) const {
38 /// @param x, y are the (x,y) coordinates of the proton, in [m]
39 return (fabs(x-fx)<x1&&fabs(y-fy)<x2);
40}
41
42void H_RectangularAperture::draw(const float scale) const {
43 TPave* tp = new TPave((fx-x1)*scale,(fy-x2)*scale,(fx+x1)*scale,(fy+x2)*scale,1);
44 tp->SetFillStyle(3003);
45 tp->SetLineColor(2);
46 tp->SetFillColor(2);
47 tp->Draw();
48 return;
49}
50void H_RectangularAperture::printProperties() const {
51 cout << "Aperture shape:" << getTypeString() << ", rectangle Sides : "<<x1<<", "<<x2<<endl;
52 cout << " \t Center : " << fx << "," << fy << endl;
53 return;
54}
Note: See TracBrowser for help on using the repository browser.