- Timestamp:
- Feb 3, 2009, 2:35:44 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Utilities/Hector/src/H_BeamLine.cc
r216 r238 194 194 } 195 195 196 ap = 0; //init197 if(e.aper_1 !=0 || e.aper_2 !=0 || e.aper_3 !=0 || e.aper_4 != 0) {198 e.aper_1 *= URAD;199 e.aper_2 *= URAD;200 e.aper_3 *= URAD;201 e.aper_4 *= URAD; // in [m] in the tables !202 203 if(strstr(e.apertype.c_str(),"RECTELLIPSE")) ap = new H_RectEllipticAperture(e.aper_1,e.aper_2,e.aper_3,e.aper_4,0,0);204 else if(strstr(e.apertype.c_str(),"CIRCLE")) ap = new H_CircularAperture(e.aper_1,0,0);205 else if(strstr(e.apertype.c_str(),"RECTANGLE")) ap = new H_RectangularAperture(e.aper_1,e.aper_2,0,0);206 else if(strstr(e.apertype.c_str(),"ELLIPSE")) ap = new H_EllipticAperture(e.aper_1,e.aper_2,0,0);207 }208 209 196 if(el!=0) { 197 ap = 0; //init 198 if(e.aper_1 !=0 || e.aper_2 !=0 || e.aper_3 !=0 || e.aper_4 != 0) { 199 e.aper_1 *= URAD; 200 e.aper_2 *= URAD; 201 e.aper_3 *= URAD; 202 e.aper_4 *= URAD; // in [m] in the tables ! 203 204 if(strstr(e.apertype.c_str(),"RECTELLIPSE")) 205 ap = new H_RectEllipticAperture(e.aper_1,e.aper_2,e.aper_3,e.aper_4,0,0); 206 else if(strstr(e.apertype.c_str(),"CIRCLE")) 207 ap = new H_CircularAperture(e.aper_1,0,0); 208 else if(strstr(e.apertype.c_str(),"RECTANGLE")) 209 ap = new H_RectangularAperture(e.aper_1,e.aper_2,0,0); 210 else if(strstr(e.apertype.c_str(),"ELLIPSE")) 211 ap = new H_EllipticAperture(e.aper_1,e.aper_2,0,0); 212 } 213 210 214 if (direction<0) { 211 el->setBetaX(e.betx); 212 el->setBetaY(e.bety); 213 el->setDX(e.dx); 214 el->setDY(e.dy); 215 el->setRelX(e.x); 216 el->setRelY(e.y); 215 el->setBetaX(e.betx); el->setBetaY(e.bety); 216 el->setDX(e.dx); el->setDY(e.dy); 217 el->setRelX(e.x); el->setRelY(e.y); 217 218 } else { 218 el->setBetaX(previous_betax); 219 el->setBetaY(previous_betay); 220 el->setDX(previous_dx); 221 el->setDY(previous_dy); 222 el->setRelX(previous_x); 223 el->setRelY(previous_y); 219 el->setBetaX(previous_betax); el->setBetaY(previous_betay); 220 el->setDX(previous_dx); el->setDY(previous_dy); 221 el->setRelX(previous_x); el->setRelY(previous_y); 224 222 } 225 223 if(ap!=0) { 226 el->setAperture(ap); // makes a copy 227 delete ap; 228 } 224 el->setAperture(ap); 225 delete ap; 226 // if memory is allocated, i.e. if ap!=0, 227 // it wont be deallocated in H_OpticalElement::~H_OpticalElement 228 // ap should then be deleted here 229 } // memory leak-free! 229 230 230 /// Parses all the elements, but only keeps the ones from the IP till the desired length 231 if(e.s>=0 && e.s<beam_length) add(*el); 232 233 // delete el; // el deleted in H_AbstractBeamLine::~H_AbstractBeamLine 231 /// Parses all the elements from the beginning of the file, 232 /// but only keeps the ones from the IP till the desired length 233 if(e.s>=0 && e.s<beam_length) add(el); 234 else { delete el;} 235 // NB : if "el" is added to the beamline, it will be 236 // deleted by H_AbstractBeamLine::~H_AbstractBeamLine 237 // Otherwise, it should be deleted explicitly 238 234 239 } // if(el!=0) 235 240 } // if (found)
Note:
See TracChangeset
for help on using the changeset viewer.