Fork me on GitHub

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

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

new Hector version

File size: 2.4 KB
Line 
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * *
3* --<--<-- A fast simulator --<--<-- *
4* / --<--<-- of particle --<--<-- *
5* ----HECTOR----< *
6* \ -->-->-- transport through -->-->-- *
7* -->-->-- generic beamlines -->-->-- *
8* *
9* JINST 2:P09005 (2007) *
10* X Rouby, J de Favereau, K Piotrzkowski (CP3) *
11* http://www.fynu.ucl.ac.be/hector.html *
12* *
13* Center for Cosmology, Particle Physics and Phenomenology *
14* Universite catholique de Louvain *
15* Louvain-la-Neuve, Belgium *
16 * *
17 * * * * * * * * * * * * * * * * * * * * * * * * * * * */
18
19/// \file H_RectangularAperture.cc
20/// \brief Defines the rectangular aperture of beamline elements.
21
22// C++ #includes
23#include <iostream>
24
25// C #includes
26#include <cmath> // needed for fabs
27
28// ROOT #includes
29#include "TPave.h"
30
31// local #includes
32#include "H_RectangularAperture.h"
33using namespace std;
34
35H_RectangularAperture::H_RectangularAperture(const float l, const float h, const float posx, const float posy) :H_Aperture(RECTANGULAR,l,h,0,0,posx,posy) {
36 /// @param l, h are the length and height of the rectangular shape
37 /// @param posx, posy are the (x,y) coordinates of the center of the rectangular shape
38}
39
40H_RectangularAperture* H_RectangularAperture::clone() const {
41 return new H_RectangularAperture(x1,x2,fx,fy);
42}
43
44bool H_RectangularAperture::isInside(const float x, const float y) const {
45 /// @param x, y are the (x,y) coordinates of the proton, in [m]
46 return (fabs(x-fx)<x1&&fabs(y-fy)<x2);
47}
48
49void H_RectangularAperture::draw(const float scale) const {
50 TPave* tp = new TPave((fx-x1)*scale,(fy-x2)*scale,(fx+x1)*scale,(fy+x2)*scale,1);
51 tp->SetFillStyle(3003);
52 tp->SetLineColor(2);
53 tp->SetFillColor(2);
54 tp->Draw();
55 return;
56}
57
58std::ostream& operator<< (std::ostream& os, const H_RectangularAperture& ap) {
59 os << "Aperture shape:" << ap.aptypestring << ", rectangle sides : " << ap. x1 <<", " << ap.x2 <<endl;
60 os << " \t Center : " << ap.fx << "," << ap.fy << endl;
61 return os;
62}
63
Note: See TracBrowser for help on using the repository browser.