Problem 1447 - G4ErrorFreeTrajParam looses sign of Y-position
Summary: G4ErrorFreeTrajParam looses sign of Y-position
Status: RESOLVED FIXED
Alias: None
Product: Examples/Extended
Classification: Unclassified
Component: errorpropagation (show other problems)
Version: 9.6
Hardware: PC Linux
: P5 normal
Assignee: Pedro.Arce
URL:
Depends on:
Blocks:
 
Reported: 2013-02-22 22:02 CET by janstar1122
Modified: 2013-04-05 14:40 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description janstar1122 2013-02-22 22:02:48 CET
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;
}
Comment 1 janstar1122 2013-02-22 22:19:33 CET
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