Fork me on GitHub

source: svn/trunk/external/Hector/H_EllipticAperture.cc@ 1360

Last change on this file since 1360 was 1360, checked in by Pavel Demin, 11 years ago

add Hector module

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision Date
File size: 3.0 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_EllipticAperture.cc
20/// \brief Defines the elliptic aperture of beamline elements.
21
22// C++ #includes
23#include <iostream>
24
25// ROOT #includes
26#include "TEllipse.h"
27
28// local #includes
29#include "H_Parameters.h"
30#include "H_Aperture.h"
31#include "H_EllipticAperture.h"
32using namespace std;
33
34H_EllipticAperture::H_EllipticAperture(const int type, const float l, const float h, const float posx, const float posy) :
35 H_Aperture(type,l,h,0,0,posx,posy) {
36 /// @param type is the aperture type (ELLIPTIC or CIRCULAR)
37 /// @param l, h are the length and height of the elliptic shape
38 /// @param posx, posy are the (x,y) coordinates of the center of the ellipse
39
40 if (type!= ELLIPTIC && type != CIRCULAR) {
41 cout << "Warning: trying to define an EllipticalAperture which is neither elliptical nor circular." << endl;
42 cout << "'Elliptical' type forced\n";
43 type_ = ELLIPTIC;
44 aptypestring = getApertureString();
45 }
46}
47
48H_EllipticAperture::H_EllipticAperture(const float l, const float h, const float posx, const float posy) :
49 H_Aperture(ELLIPTIC,l,h,0,0,posx,posy) {
50 /// @param l, h are the length and height of the elliptic shape
51 /// @param posx, posy are the (x,y) coordinates of the center of the ellipse
52}
53
54H_EllipticAperture* H_EllipticAperture::clone() const {
55 return new H_EllipticAperture(x1,x2,fx,fy);
56}
57
58bool H_EllipticAperture::isInside(const float x, const float y) const {
59 /// @param x, y are the (x,y) coordinates of the proton
60 return (((x-fx)/x1)*((x-fx)/x1) + ((y-fy)/x2)*((y-fy)/x2) < 1);
61}
62
63void H_EllipticAperture::draw(const float scale) const {
64 TEllipse* te = new TEllipse(fx*scale,fy*scale,x1*scale,x2*scale);
65 te->SetFillStyle(3003);
66 te->SetLineColor(39);
67 te->SetFillColor(39);
68 te->Draw("f");
69 return;
70}
71
72std::ostream& operator<< (std::ostream& os, const H_EllipticAperture& ap) {
73 os<< "Aperture shape:" << ap.aptypestring << ", ellipse axes : "<< ap.x1 <<", " << ap.x2 << endl;
74 os << " \t Center : " << ap.fx << "," << ap.fy << endl;
75 return os;
76}
Note: See TracBrowser for help on using the repository browser.