-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clock jump defaults #719
Clock jump defaults #719
Conversation
…ithub.com/YannickSoehngen/star-sw into ClockJumpCorrection-and-CounterMod-update
…ithub.com/YannickSoehngen/star-sw into ClockJumpCorrection-and-CounterMod-update
…ithub.com/YannickSoehngen/star-sw into ClockJumpCorrection-and-CounterMod-update
This reverts commit 79f22f2.
…ithub.com/YannickSoehngen/star-sw into ClockJumpCorrection-and-CounterMod-update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly just proposed code changes from me - I can't vouch for whether this does what it should for ETOF results. The decodeInt()
interface change is probably the most worthwhile.
Get4Id2 = -1; | ||
get4state2 = -1; | ||
|
||
if(stateInt1 < 6912){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(stateInt1 < 6912){ | |
if(stateInt1 < eTofConst::nChannelsInSystem){ |
Get4Id1 = stateInt1 % (eTofConst::nGet4sInSystem/2); | ||
get4state1 = stateInt1 / (eTofConst::nGet4sInSystem/2); | ||
} | ||
if(stateInt2 < 6912){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(stateInt2 < 6912){ | |
if(stateInt1 < eTofConst::nChannelsInSystem){ |
keyGet4 = 144 * ( sector - 13 ) + 48 * ( plane -1 ) + 16 * ( counter - 1 ) + 8 * ( 1 - 1 ) + ( ( strip - 1 ) / 4 ); | ||
keyGet4_comp = 144 * ( sector - 13 ) + 48 * ( plane -1 ) + 16 * ( counter - 1 ) + 8 * ( 2 - 1 ) + ( ( strip - 1 ) / 4 ); | ||
}else{ | ||
keyGet4 = 144 * ( sector - 13 ) + 48 * ( plane -1 ) + 16 * ( counter - 1 ) + 8 * ( 2 - 1 ) + ( ( strip - 1 ) / 4 ); | ||
keyGet4_comp = 144 * ( sector - 13 ) + 48 * ( plane -1 ) + 16 * ( counter - 1 ) + 8 * ( 1 - 1 ) + ( ( strip - 1 ) / 4 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're using the constants provided, I think this equates to....
keyGet4 = 144 * ( sector - 13 ) + 48 * ( plane -1 ) + 16 * ( counter - 1 ) + 8 * ( 1 - 1 ) + ( ( strip - 1 ) / 4 ); | |
keyGet4_comp = 144 * ( sector - 13 ) + 48 * ( plane -1 ) + 16 * ( counter - 1 ) + 8 * ( 2 - 1 ) + ( ( strip - 1 ) / 4 ); | |
}else{ | |
keyGet4 = 144 * ( sector - 13 ) + 48 * ( plane -1 ) + 16 * ( counter - 1 ) + 8 * ( 2 - 1 ) + ( ( strip - 1 ) / 4 ); | |
keyGet4_comp = 144 * ( sector - 13 ) + 48 * ( plane -1 ) + 16 * ( counter - 1 ) + 8 * ( 1 - 1 ) + ( ( strip - 1 ) / 4 ); | |
keyGet4 = (eTofConst::nStrips * (eTofConst::nSides * (eTofConst::nCounters * (eTofConst::nPlanes * ( sector - 13 ) + ( plane -1 )) + ( counter - 1 )) + ( 1 - 1 )) + ( strip - 1 )) / 4; | |
keyGet4_comp = (eTofConst::nStrips * (eTofConst::nSides * (eTofConst::nCounters * (eTofConst::nPlanes * ( sector - 13 ) + ( plane -1 )) + ( counter - 1 )) + ( 2 - 1 )) + ( strip - 1 )) / 4; | |
}else{ | |
keyGet4 = (eTofConst::nStrips * (eTofConst::nSides * (eTofConst::nCounters * (eTofConst::nPlanes * ( sector - 13 ) + ( plane -1 )) + ( counter - 1 )) + ( 2 - 1 )) + ( strip - 1 )) / 4; | |
keyGet4_comp = (eTofConst::nStrips * (eTofConst::nSides * (eTofConst::nCounters * (eTofConst::nPlanes * ( sector - 13 ) + ( plane -1 )) + ( counter - 1 )) + ( 1 - 1 )) + ( strip - 1 )) / 4; |
if(def == 1 ){ | ||
time -= eTofConst::coarseClockCycle * 0.5; | ||
} | ||
if(def == 3){ | ||
time += eTofConst::coarseClockCycle * 0.5; | ||
} | ||
if(def == 2){ | ||
if(posY > 0){ | ||
time -= eTofConst::coarseClockCycle * 0.5; | ||
}else{ | ||
time += eTofConst::coarseClockCycle * 0.5; | ||
} | ||
} | ||
if(def == 4){ | ||
if(posY > 0){ | ||
time += eTofConst::coarseClockCycle * 0.5; | ||
}else{ | ||
time -= eTofConst::coarseClockCycle * 0.5; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a shorter version of yours:
if(def == 1 ){ | |
time -= eTofConst::coarseClockCycle * 0.5; | |
} | |
if(def == 3){ | |
time += eTofConst::coarseClockCycle * 0.5; | |
} | |
if(def == 2){ | |
if(posY > 0){ | |
time -= eTofConst::coarseClockCycle * 0.5; | |
}else{ | |
time += eTofConst::coarseClockCycle * 0.5; | |
} | |
} | |
if(def == 4){ | |
if(posY > 0){ | |
time += eTofConst::coarseClockCycle * 0.5; | |
}else{ | |
time -= eTofConst::coarseClockCycle * 0.5; | |
} | |
} | |
bool POSY = (posY > 0); | |
double addOrSub = (def == 3 || (def == 4 && POSY) || (def == 2 && !POSY) ? 0.5 : -0.5); | |
time += addOrSub * eTofConst::coarseClockCycle; |
time -= eTofConst::coarseClockCycle * 0.5; | ||
} | ||
} | ||
timeDiff -= eTofConst::coarseClockCycle * ( ( timeDiff < 0 ) ? -1 : ( timeDiff > 0 ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're assuming ( timeDiff > 0)
evaluates to +1
? Just a step further is safer as suggested here. I looked for a C/C++ function that returns -1,0,1 for floats <0,0,>0, but didn't find any except this hack, that I don't really love: (x>>31) - (-x>>31);
. So maybe yours is better.
timeDiff -= eTofConst::coarseClockCycle * ( ( timeDiff < 0 ) ? -1 : ( timeDiff > 0 ) ); | |
timeDiff -= eTofConst::coarseClockCycle * ( ( timeDiff < 0 ) ? -1 : ( timeDiff > 0 ? 1 : 0) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I found this
timeDiff -= eTofConst::coarseClockCycle * ( ( timeDiff < 0 ) ? -1 : ( timeDiff > 0 ) ); | |
timeDiff -= (timeDiff == 0 ? 0 : TMath::Sign(eTofConst::coarseClockCycle , timeDiff)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or similarly...
timeDiff -= eTofConst::coarseClockCycle * ( ( timeDiff < 0 ) ? -1 : ( timeDiff > 0 ) ); | |
if (timeDiff != 0) timeDiff -= TMath::Sign(eTofConst::coarseClockCycle , timeDiff); |
Co-authored-by: Gene Van Buren <[email protected]>
Co-authored-by: Gene Van Buren <[email protected]>
Co-authored-by: Gene Van Buren <[email protected]>
Co-authored-by: Gene Van Buren <[email protected]>
Co-authored-by: Gene Van Buren <[email protected]>
Co-authored-by: Gene Van Buren <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No comments. Please go ahead and merge this PR.
@YannickSoehngen Did I understand correctly that you will merge this branch today? If so, I'll keep an eye on it and tag as requested by Gene. |
No description provided.