Hi, the attached code proves that when I instantiate G4ErrorFreeTrajState with 2 different Y positions G4ThreeVector xv3( -25*cm, +32*cm,0); OR G4ThreeVector xv3( -25*cm, -32*cm,0); the value of YPerp remains the same: +320 mm. It means the G4ErrorFreeTrajParam looses information about Ytrans position. Perhaps I misunderstand the meaning of G4double fV; // projection of position in one direction G4double fW; // projection of position in one direction Please let me know Jan OUTPUT for Y=+32cm ------ myFreeParams: InvP= 0.012126781 Theta= 0.24497866 Phi= 0 YPerp= 320 ZPerp= 60.633906 momentum direction= (80,0,20) Position (mm): (-250,-320,0) phi/deg=-127.999 Rxy/cm=40.6079 OUTPUT for Y=-32cm ------ myFreeParams: InvP= 0.012126781 Theta= 0.24497866 Phi= 0 YPerp= 320 ZPerp= 60.633906 momentum direction= (80,0,20) Position (mm): (-250,320,0) phi/deg=127.999 Rxy/cm=40.6079 The code: //============================ void testBug1(double yPos){ printf("testFree2SurfRealtions() \n"); //............. Set the starting trajectory.......... G4ThreeVector xv3( -25*cm, yPos,0); G4ThreeVector pv3( 80*MeV, 0., 20.*MeV ); G4ErrorTrajErr error( 5, 1 ); G4ErrorFreeTrajState myFreeTrajState = G4ErrorFreeTrajState( "e-", xv3, pv3, error ); G4ErrorFreeTrajParam myFreeParams=myFreeTrajState.GetParameters(); G4cout << "myFreeParams: "<< myFreeParams<<G4endl; G4Point3D posLab = myFreeTrajState.GetPosition(); G4cout << "Position (mm): " << posLab <<" phi/deg="<<posLab.phi()/deg<<" Rxy/cm="<<posLab.perp()/cm<< G4endl; }
Once I wrote and thought about it, this is what the code does now: void G4ErrorFreeTrajParam::SetParameters( const G4Point3D& pos, const G4Vector3D& mom ) .... if( vyPerp.mag() != 0. ) { fYPerp = posv.project( vyPerp ).mag(); fZPerp = posv.project( vzPerp ).mag(); } .... This guarantees the signs are lost. Should those 2 lines not be a simple dot-products so if the direction of the position is opposite to the base vector the sign is negative? if( vyPerp.mag() != 0. ) { fYPerp = posv.dot( vyPerp ); fZPerp = posv.dot( vzPerp ); } thanks Jan