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"
|
---|
33 | using namespace std;
|
---|
34 |
|
---|
35 | H_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 |
|
---|
40 | H_RectangularAperture* H_RectangularAperture::clone() const {
|
---|
41 | return new H_RectangularAperture(x1,x2,fx,fy);
|
---|
42 | }
|
---|
43 |
|
---|
44 | bool 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 |
|
---|
49 | void 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 |
|
---|
58 | std::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 |
|
---|