Fork me on GitHub

source: svn/trunk/Utilities/Hector/src/H_AbstractBeamLine.cc@ 108

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

first commit

File size: 21.0 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
13/// \file H_AbstractBeamLine.cc
14/// \brief Class describing ideal beamline.
15///
16/// Units : angles [rad], distances [m], energies [GeV], c=[1].
17
18// c++ #includes
19#include <iostream>
20#include <cmath>
21
22// ROOT #includes
23#include "TPaveLabel.h"
24#include "TLine.h"
25#include "TGaxis.h"
26#include "TLegend.h"
27#include "TF1.h"
28#include "TROOT.h"
29
30// local #includes
31#include "H_Parameters.h"
32#include "H_TransportMatrices.h"
33#include "H_Drift.h"
34#include "H_AbstractBeamLine.h"
35#include "H_RomanPot.h"
36using namespace std;
37
38void H_AbstractBeamLine::init(const float length) {
39 beam_mat.ResizeTo(MDIM,MDIM);
40 beam_mat = driftmat(length);
41 beam_length = length;
42 H_Drift * drift0 = new H_Drift("Drift0",0.,length);
43 add(drift0);
44 return;
45}
46
47H_AbstractBeamLine::H_AbstractBeamLine(const H_AbstractBeamLine& beamline) {
48 elements = beamline.elements;
49 matrices = beamline.matrices;
50 beam_mat.ResizeTo(MDIM,MDIM);
51 beam_mat = beamline.beam_mat;
52 beam_length = beamline.beam_length;
53}
54
55H_AbstractBeamLine& H_AbstractBeamLine::operator=(const H_AbstractBeamLine& beamline) {
56 if(this== &beamline) return *this;
57 elements = beamline.elements;
58 matrices = beamline.matrices;
59 beam_mat = beamline.beam_mat;
60 beam_length = beamline.beam_length;
61 return *this;
62}
63
64H_AbstractBeamLine* H_AbstractBeamLine::clone() const {
65 H_AbstractBeamLine* temp_beam = new H_AbstractBeamLine(beam_length);
66 vector<H_OpticalElement*>::const_iterator element_i;
67 for (element_i = elements.begin(); element_i<elements.end(); element_i++) {
68 if((*element_i)->getType()!=DRIFT) {
69 H_OpticalElement* temp_el = (*element_i)->clone();
70 temp_beam->add(temp_el);
71 }
72 }
73 temp_beam->beam_mat = beam_mat;
74 temp_beam->matrices = matrices;
75 return temp_beam;
76}
77
78H_AbstractBeamLine::~H_AbstractBeamLine() {
79 vector<H_OpticalElement*>::iterator element_i;
80 for (element_i = elements.begin(); element_i<elements.end(); element_i++) {
81 delete (*element_i);
82 }
83 elements.clear();
84 matrices.clear();
85}
86
87void H_AbstractBeamLine::add(H_OpticalElement * newElement) {
88 /// @param newElement is added to the beamline
89// H_OpticalElement * el = new H_OpticalElement(*newElement);
90// H_OpticalElement * el = const_cast<H_OpticalElement*> newElement;
91// H_OpticalElement * el = newElement;
92 elements.push_back(newElement);
93 float a = newElement->getS()+newElement->getLength();
94 if (a > beam_length) {
95 beam_length = a;
96 if(VERBOSE) cout<<"<H_AbstractBeamLine> WARNING : element ("<< newElement->getName()<<") too far away. The beam length has been extended to "<< beam_length << ". "<<endl;
97 }
98 calcSequence();
99 calcMatrix();
100}
101
102void H_AbstractBeamLine::add(H_OpticalElement & newElement) {
103 /// @param newElement is added to the beamline
104// H_OpticalElement * el = new H_OpticalElement(newElement);
105// elements.push_back(el);
106 elements.push_back(&newElement);
107 float a = newElement.getS()+newElement.getLength();
108 if (a > beam_length) {
109 beam_length = a;
110 if(VERBOSE) cout<<"<H_AbstractBeamLine> WARNING : element ("<< newElement.getName()<<") too far away. The beam length has been extended to "<< beam_length << ". "<<endl;
111 }
112 calcSequence();
113 calcMatrix();
114}
115
116const TMatrix H_AbstractBeamLine::getBeamMatrix() const {
117 return beam_mat;
118}
119
120const TMatrix H_AbstractBeamLine::getBeamMatrix(const float eloss,const float p_mass, const float p_charge) {
121
122 vector<H_OpticalElement*>::iterator element_i;
123 TMatrix calc_mat(MDIM,MDIM);
124
125 // initialization
126 calc_mat.UnitMatrix();
127
128 // multiplies the matrix of each beam's element
129 // and add each product matrix to the list of matrices.
130 for(element_i = elements.begin(); element_i < elements.end(); element_i++) {
131 calc_mat *= (*element_i)->getMatrix(eloss,p_mass,p_charge);
132 }
133 return calc_mat;
134}
135
136const TMatrix H_AbstractBeamLine::getPartialMatrix(const string elname, const float eloss, const float p_mass, const float p_charge) {
137
138 vector<H_OpticalElement*>::iterator element_i;
139 TMatrix calc_mat(MDIM,MDIM);
140
141 calc_mat.UnitMatrix();
142
143 for(element_i = elements.begin(); element_i < elements.end(); element_i++) {
144 calc_mat *= (*element_i)->getMatrix(eloss,p_mass,p_charge);
145 if(elname==(*element_i)->getName()) {
146 return calc_mat;
147 }
148 }
149 cout<<"<H_AbstractBeamLine> Element "<<elname<<" desn't exist. Returning full beam matrix"<<endl;
150 return calc_mat;
151}
152
153const TMatrix H_AbstractBeamLine::getPartialMatrix(const unsigned int element_position) const {
154 //const int N = (element_position<0)?0:(( (element_position)>elements.size()-1)?elements.size()-1:element_position);
155 const int N = (element_position>elements.size()-1)?elements.size()-1:element_position;
156 return *(matrices.begin()+N); // //for optimization of the code :same as return &matrices[N];
157}
158
159const TMatrix H_AbstractBeamLine::getPartialMatrix(const H_OpticalElement * element) const{
160 // returns the transport matrix to transport until the end of the specified element
161 // !!! 2 elements should never have the same name in "elements" !!!
162
163 vector<H_OpticalElement*>::const_iterator element_i;
164 vector<TMatrix>::const_iterator matrix_i;
165 TMatrix calc_mat(MDIM,MDIM);
166
167 // parses the list of optical elements and find the searched one
168 for(element_i = elements.begin(),matrix_i = matrices.begin(); element_i < elements.end(); element_i++, matrix_i++) {
169 if(element->getName() == (*element_i)->getName()) {
170 // element has been found
171 calc_mat = *matrix_i;
172 }
173 }
174 return calc_mat;
175}
176
177H_OpticalElement * H_AbstractBeamLine::getElement(const unsigned int element_position) {
178 const unsigned int N = (element_position>elements.size())?elements.size():element_position;
179 return *(elements.begin()+N);//for optimization of the code :same as return &elements[N];
180}
181
182H_OpticalElement * H_AbstractBeamLine::getElement(const unsigned int element_position) const {
183 const unsigned int N = (element_position>elements.size())?elements.size():element_position;
184 return *(elements.begin()+N);//for optimization of the code :same as return &elements[N];
185}
186
187
188H_OpticalElement * H_AbstractBeamLine::getElement(const string el_name) {
189 for(unsigned int i=0; i < elements.size(); i++) {
190 if( (*(elements.begin()+i))->getName() == el_name )
191 return *(elements.begin()+i);
192 } // if found -> return ; else : not found at all !
193 cout<<"<H_AbstractBeamLine> Element "<<el_name<<" not found"<<endl;
194 return *(elements.begin()+1);
195}
196
197H_OpticalElement * H_AbstractBeamLine::getElement(const string el_name) const {
198 for(unsigned int i=0; i < elements.size(); i++) {
199 if( (*(elements.begin()+i))->getName() == el_name)
200 return *(elements.begin()+i);
201 } // if found -> return ; else : not found at all !
202 cout<<"<H_AbstractBeamLine> Element "<<el_name<<" not found"<<endl;
203 return *(elements.begin()+1);
204}
205
206void H_AbstractBeamLine::printProperties() const {
207 vector<H_OpticalElement*>::const_iterator element_i;
208 cout << "Pointeurs des elements du faisceau" << endl;
209 for (element_i = elements.begin(); element_i < elements.end(); element_i++) {
210 cout << (int)(element_i-elements.begin()) << "\t" << (*element_i)->getName() << "\t" << (*element_i)->getS() << endl;
211 }
212 return;
213}
214
215void H_AbstractBeamLine::showElements() const{
216 vector<H_OpticalElement*>::const_iterator element_i;
217 for(element_i = elements.begin(); element_i < elements.end(); element_i++) {
218 (*element_i)->printProperties();
219 }
220 cout << "Beam length = " << beam_length << endl;
221 cout << "Number of elements (including drifts) = " << getNumberOfElements() << endl;
222 return;
223}
224
225void H_AbstractBeamLine::showElements(const int type_el) const{
226 vector<H_OpticalElement*>::const_iterator element_i;
227 for(element_i = elements.begin(); element_i < elements.end(); element_i++) {
228 if ((*element_i)->getType()==type_el)
229 (*element_i)->printProperties();
230 }
231 return;
232}
233
234void H_AbstractBeamLine::showMatrix() const {
235 cout << "Transport matrix for the whole beam : " << endl;
236 cout << "(x,x',...) = (x*,x'*,...) M " <<endl;
237 printMatrix(beam_mat);
238 return;
239}
240
241void H_AbstractBeamLine::showMatrices() const{
242 // prints the list of all transport matrices, from the whole beam.
243
244 vector<TMatrix>::const_iterator matrix_i;
245 vector<H_OpticalElement*>::const_iterator element_i;
246 TMatrix temp(MDIM,MDIM);
247
248 for(matrix_i = matrices.begin(), element_i = elements.begin(); matrix_i < matrices.end(); matrix_i++, element_i++) {
249 temp = *matrix_i;
250 cout << "Matrix for transport until s=" << (*element_i)->getS() + (*element_i)->getLength() << "m (" << (*element_i)->getName() << "). " << endl;
251 printMatrix(temp);
252 cout << endl;
253 }
254 return ;
255}
256
257void H_AbstractBeamLine::calcSequence() {
258 // reorders the elements, computes the drifts;
259
260 vector<H_OpticalElement*> temp_elements;
261 vector<H_OpticalElement*>::iterator element_i;
262 // element_i is a pointer to elements[i]
263
264 if(elements.size()==1) { return; }
265
266 // getting rid of drifts before calculating
267 for(element_i = elements.begin(); element_i < elements.end(); element_i++) {
268 if((*element_i)->getType() == DRIFT) {delete (*element_i); elements.erase(element_i); }
269 }
270
271 // ordering the elements in position
272 sort(elements.begin(),elements.end(),ordering());
273 // inserting the drifts before the other elements
274 float current_pos = 0;
275 float drift_length=0;
276
277 for(element_i=elements.begin(); element_i < elements.end(); element_i++) {
278 drift_length = (*element_i)->getS() - current_pos;
279 if(drift_length>0) {
280 H_Drift *dr = new H_Drift(current_pos,drift_length);
281 temp_elements.push_back(dr);
282 }
283 temp_elements.push_back(*element_i);
284 current_pos = (*element_i)->getS() + (*element_i)->getLength();
285 }
286
287 //adding the last drift
288 drift_length = beam_length - current_pos;
289 if (drift_length>0) {
290 H_Drift *dr = new H_Drift(current_pos,drift_length);
291 temp_elements.push_back(dr);
292 }
293
294 // cleaning : avoid some memory leaks
295 elements.clear();
296
297 for(element_i=temp_elements.begin(); element_i < temp_elements.end(); element_i++) {
298 elements.push_back(*element_i);
299 }
300}
301
302void H_AbstractBeamLine::calcMatrix() {
303 // computes the transport matrix for the beam upto here...
304 vector<H_OpticalElement*>::iterator element_i;
305 TMatrix calc_mat(MDIM,MDIM);
306
307 // initialization
308 matrices.clear();
309 calc_mat.UnitMatrix();
310
311 // multiplies the matrix of each beam's element
312 // and add each product matrix to the list of matrices.
313 for(element_i = elements.begin(); element_i < elements.end(); element_i++) {
314 calc_mat *= (*element_i)->getMatrix();
315 matrices.push_back(calc_mat);
316 }
317
318 beam_mat.ResizeTo(MDIM,MDIM);
319 beam_mat = calc_mat;
320 return;
321}
322
323float qh(float k) {
324 float beta = (log((float)10.0))/0.05;
325 // put (std::log((float)10.0)) instead of log(10) to avoid compilation errors
326 return 0.8*(1-exp(-beta*fabs(k)));
327}
328
329float dh(float k) {
330 float psi = (log((float)10.0))/0.002;
331 // put (std::log((float)10.0)) instead of log(10) to avoid compilation errors
332 return 0.8*(1-exp(-psi*fabs(k)));
333}
334
335void H_AbstractBeamLine::draw(const float xmin, const float ymin, const float xmax, const float ymax) const{
336 gROOT->SetStyle("Plain");
337 TLegend* leg = new TLegend(xmin,ymin,xmax,ymax,"");
338 leg->SetBorderSize(1);
339 leg->SetFillColor(kWhite);
340 TBox* b1 = new TBox();
341 TBox* b2 = new TBox(0,0,10,10);
342 TBox* b3 = new TBox(0,0,0,0);
343 TBox* b4 = new TBox(0,0,0,0);
344 TBox* b5 = new TBox(0,0,0,0);
345 TBox* b6 = new TBox(0,0,0,0);
346 TBox* b7 = new TBox(0,0,0,0);
347 b1->SetFillColor(RDIPOLE);
348 b2->SetFillColor(SDIPOLE);
349 b3->SetFillColor(VQUADRUPOLE);
350 b4->SetFillColor(HQUADRUPOLE);
351 b5->SetFillColor(HKICKER);
352 b6->SetFillColor(VKICKER);
353 b7->SetFillColor(RCOLLIMATOR);
354 leg->AddEntry(b1,"R-Dipole");
355 leg->AddEntry(b2,"S-Dipole");
356 leg->AddEntry(b3,"V-Quadrupole");
357 leg->AddEntry(b4,"H-Quadrupole");
358 leg->AddEntry(b5,HKICKERNAME);
359 leg->AddEntry(b6,VKICKERNAME);
360 leg->AddEntry(b7,"RCollimator");
361 leg->Draw();
362/* TLine* l1 = new TLine(0.05,0.5,0.95,0.5);
363 TLine* l2 = new TLine(0.1,0.1,0.1,0.9);
364 TLine* l3 = new TLine(0.9,0.1,0.9,0.9);
365 TPaveLabel* p1 = new TPaveLabel(0.05,0.5,0.1,0.6,"IP");
366 TPaveLabel* p2 = new TPaveLabel(0.9,0.5,0.95,0.6,"RP");
367 TGaxis* a1 = new TGaxis(0.1,0.1,0.9,0.1,0,beam_length);
368 a1->SetLabelSize(0.08);
369 p1->SetBorderSize(1);
370 p2->SetBorderSize(1);
371 p1->SetFillColor(0);
372 p2->SetFillColor(0);
373 l1->Draw();
374 l2->Draw();
375 l3->Draw();
376 p1->Draw();
377 p2->Draw();
378 float x1,x2,y1,y2;
379 vector<TPaveLabel*> boxes;
380 vector<H_OpticalElement*>::const_iterator element_i;
381 for(element_i = elements.begin(); element_i < elements.end(); element_i++) {
382 x1 = 0.1 + ((*element_i)->getS()/beam_length)*0.8;
383 x2 = x1 + ((*element_i)->getLength()/beam_length)*0.8;
384 if((*element_i)->getType()>5) {
385 y1 = 0.3;
386 y2 = 0.7;
387 }
388 else if((*element_i)->getType()>3) {
389 y1 = 0.5 - qh((*element_i)->getK()*(*element_i)->getLength())/2.;
390 y2 = 0.5 + qh((*element_i)->getK()*(*element_i)->getLength())/2.;
391 } else {
392 y1 = 0.5 - dh((*element_i)->getK()*(*element_i)->getLength())/2.;
393 y2 = 0.5 + dh((*element_i)->getK()*(*element_i)->getLength())/2.;
394 }
395 TPaveLabel* cur_box = new TPaveLabel(x1,y1,x2,y2,"");
396 cur_box->SetFillStyle(1);
397 cur_box->SetFillColor(((int)(*element_i)->getType()));
398 cur_box->SetBorderSize(1);
399 if((*element_i)->getType()!=DRIFT) boxes.push_back(cur_box);
400 }
401 vector<TPaveLabel*>::iterator box_i;
402 for(box_i = boxes.begin(); box_i < boxes.end(); box_i++) {
403 (*box_i)->Draw();
404 }
405 a1->Draw();
406*/
407 return;
408}
409
410void H_AbstractBeamLine::drawX(const float a_min, const float a_max, const float scale) const{
411 /// @param a_min defines the size of the drawing
412 /// @param a_max defines the size of the drawing
413 /// @param scale allows to multiply the drawing, i.e. changing the units
414 const int N = getNumberOfElements();
415 for(int i=0;i<N;i++) {
416 float height = fabs(a_max);
417 float meight = fabs(a_min);
418 float size = (height>meight)?meight:height;
419 float middle = getElement(i)->getX()*URAD*scale;
420 if(getElement(i)->getType()!=DRIFT) getElement(i)->draw(middle+size/2.,middle-size/2.);
421 }
422}
423
424void H_AbstractBeamLine::drawY(const float a_min, const float a_max) const{
425 /// @param a_min defines the size of the drawing
426 /// @param a_max defines the size of the drawing
427 const int N = getNumberOfElements();
428 for(int i=0;i<N;i++) {
429 float height = fabs(a_max);
430 float meight = fabs(a_min);
431 float size = (height>meight)?meight:height;
432 float middle = getElement(i)->getY()*URAD;
433 if(getElement(i)->getType()!=DRIFT) getElement(i)->draw(middle+size/2.,middle-size/2.);
434 }
435}
436
437void H_AbstractBeamLine::moveElement(const string name, const float new_s) {
438 /// @param name identifies the element to move
439 /// @param new_s is where to put it
440 vector<H_OpticalElement*>::iterator element_i;
441 for(element_i = elements.begin(); element_i < elements.end(); element_i++) {
442 if(name==(*element_i)->getName()) { (*element_i)->setS(new_s); }
443 }
444
445 calcSequence();
446 calcMatrix();
447 return;
448}
449
450void H_AbstractBeamLine::alignElement(const string name, const float disp_x, const float disp_y) {
451 /// @param name identifies the element to move
452 /// @param disp_x identifies the displacement to add in x [\f$ \mu m \f$]
453 /// @param disp_y identifies the displacement to add in y [\f$ \mu m \f$]
454 vector<H_OpticalElement*>::iterator element_i;
455 for(element_i = elements.begin(); element_i < elements.end(); element_i++) {
456 if(name==(*element_i)->getName()) {
457 (*element_i)->setX((*element_i)->getX()+disp_x);
458 (*element_i)->setY((*element_i)->getY()+disp_y);
459 return ;
460 }
461 }
462 cout<<"<H_AbstractBeamLine> WARNING : Element "<<name<<" not found."<<endl;
463 return;
464}
465
466void H_AbstractBeamLine::tiltElement(const string name, const float ang_x, const float ang_y) {
467 /// @param name identifies the element to move
468 /// @param ang_x identifies the angle to add in x
469 /// @param ang_y identifies the angle to add in y
470 vector<H_OpticalElement*>::iterator element_i;
471 for(element_i = elements.begin(); element_i < elements.end(); element_i++) {
472 if(name==(*element_i)->getName()) {
473 (*element_i)->setTX((*element_i)->getTX()+ang_x);
474 (*element_i)->setTY((*element_i)->getTY()+ang_y);
475 return ;
476 }
477 }
478 cout<<"<H_AbstractBeamLine> WARNING : Element "<<name<<" not found."<<endl;
479 return;
480}
481
482void H_AbstractBeamLine::offsetElements(const float start, const float offset) {
483 /// @param start After this s [m] coordinate, all elements will be offset.
484 /// @param offset In meters
485
486 extern int relative_energy;
487 if(!relative_energy) {
488 vector<H_OpticalElement*>::iterator element_i;
489 for(element_i = elements.begin(); element_i < elements.end(); element_i++) {
490 if((*element_i)->getS() > start ) {
491 (*element_i)->setX(offset);
492 }
493 }
494 }
495}
496
497TGraph * H_AbstractBeamLine::getBetaX() const{
498 const int N = elements.size();
499 float * s = new float[N], * b = new float[N], temp;
500 int i=0, n=N;
501
502 vector<H_OpticalElement*>::const_iterator element_i;
503 for(element_i = elements.begin(); element_i < elements.end(); element_i++) {
504 temp=(*element_i)->getBetaX();
505 if (temp !=0) {
506 b[i] = (*element_i)->getBetaX();
507 s[i] = (*element_i)->getS();
508 i++;
509 n=i;
510 }
511 }
512
513 TGraph * betax = new TGraph(n,s,b);
514 betax->SetLineColor(1);
515 betax->SetLineStyle(2);
516 delete [] s;
517 delete [] b;
518 return betax;
519}
520
521TGraph * H_AbstractBeamLine::getBetaY() const{
522 const int N = elements.size();
523 float * s = new float[N], * b = new float[N], temp;
524 int i=0, n=N;
525
526 vector<H_OpticalElement*>::const_iterator element_i;
527 for(element_i = elements.begin(); element_i < elements.end(); element_i++) {
528 temp=(*element_i)->getBetaY();
529 if (temp !=0) {
530 b[i] = (*element_i)->getBetaY();
531 s[i] = (*element_i)->getS();
532 i++;
533 n=i;
534 }
535 }
536
537 TGraph * betay = new TGraph(n,s,b);
538 betay->SetLineColor(2);
539 betay->SetLineStyle(2);
540 delete [] s;
541 delete [] b;
542 return betay;
543}
544
545TGraph * H_AbstractBeamLine::getDX() const{
546 const int N = elements.size();
547 float * s = new float[N], * d = new float[N], temp;
548 int i=0, n=N;
549
550 vector<H_OpticalElement*>::const_iterator element_i;
551 for(element_i = elements.begin(); element_i < elements.end(); element_i++) {
552 temp=(*element_i)->getDX();
553 if (temp !=0) {
554 d[i] = (*element_i)->getDX();
555 s[i] = (*element_i)->getS();
556 i++;
557 n=i;
558 }
559 }
560
561 TGraph * dispx = new TGraph(n,s,d);
562 dispx->SetLineColor(8);
563 dispx->SetLineStyle(2);
564 delete [] s;
565 delete [] d;
566 return dispx;
567}
568
569TGraph * H_AbstractBeamLine::getDY() const{
570 const int N = elements.size();
571 float * s = new float[N], * d = new float[N], temp;
572 int i=0, n=N;
573
574 vector<H_OpticalElement*>::const_iterator element_i;
575 for(element_i = elements.begin(); element_i < elements.end(); element_i++) {
576 temp=(*element_i)->getDY();
577 if (temp !=0) {
578 d[i] = (*element_i)->getDY();
579 s[i] = (*element_i)->getS();
580 i++;
581 n=i;
582 }
583 }
584
585 TGraph * dispy = new TGraph(n,s,d);
586 dispy->SetLineColor(kBlue);
587 dispy->SetLineStyle(2);
588 delete [] s;
589 delete [] d;
590 return dispy;
591}
592
593
594TGraph * H_AbstractBeamLine::getRelX() const{
595 const int N = elements.size();
596 float * s = new float[N], * r = new float[N], temp;
597 int i=0, n=N;
598
599 vector<H_OpticalElement*>::const_iterator element_i;
600 for(element_i = elements.begin(); element_i < elements.end(); element_i++) {
601 temp=(*element_i)->getRelX();
602 if((*element_i)->getType() != DRIFT) {
603 r[i] = (*element_i)->getRelX();
604 s[i] = (*element_i)->getS();
605 i++;
606 n=i;
607 }
608 }
609
610 TGraph * relx = new TGraph(n,s,r);
611 relx->SetLineColor(kBlack);
612 relx->SetMarkerStyle(kOpenSquare);
613 relx->SetMarkerSize(0.6);
614 relx->SetLineStyle(2);
615 delete [] s;
616 delete [] r;
617 return relx;
618}
619
620TGraph * H_AbstractBeamLine::getRelY() const{
621 const int N = elements.size();
622 float * s = new float[N], * r = new float[N], temp;
623 int i=0, n=N;
624
625 vector<H_OpticalElement*>::const_iterator element_i;
626 for(element_i = elements.begin(); element_i < elements.end(); element_i++) {
627 temp=(*element_i)->getRelY();
628 if((*element_i)->getType() != DRIFT) {
629 r[i] = (*element_i)->getRelY();
630 s[i] = (*element_i)->getS();
631 i++;
632 n=i;
633 }
634 }
635
636 TGraph * rely = new TGraph(n,s,r);
637 rely->SetLineColor(kRed);
638 rely->SetMarkerStyle(kOpenSquare);
639 rely->SetMarkerSize(0.6);
640 rely->SetLineStyle(2);
641 delete [] s;
642 delete [] r;
643 return rely;
644}
645
Note: See TracBrowser for help on using the repository browser.