Skip to content
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

Merged
merged 46 commits into from
Dec 18, 2024
Merged

Conversation

YannickSoehngen
Copy link
Contributor

No description provided.

Yannick Soehngen and others added 30 commits December 5, 2022 13:49
Copy link
Contributor

@genevb genevb left a 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.

StRoot/StETofCalibMaker/StETofCalibMaker.cxx Outdated Show resolved Hide resolved
StRoot/StETofCalibMaker/StETofCalibMaker.h Outdated Show resolved Hide resolved
StRoot/StETofCalibMaker/StETofCalibMaker.cxx Outdated Show resolved Hide resolved
Get4Id2 = -1;
get4state2 = -1;

if(stateInt1 < 6912){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(stateInt1 < 6912){
if(stateInt1 < eTofConst::nChannelsInSystem){

Get4Id1 = stateInt1 % (eTofConst::nGet4sInSystem/2);
get4state1 = stateInt1 / (eTofConst::nGet4sInSystem/2);
}
if(stateInt2 < 6912){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(stateInt2 < 6912){
if(stateInt1 < eTofConst::nChannelsInSystem){

StRoot/StETofHitMaker/StETofHitMaker.cxx Outdated Show resolved Hide resolved
Comment on lines +1328 to +1332
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 );
Copy link
Contributor

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....

Suggested change
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;

StRoot/StETofHitMaker/StETofHitMaker.cxx Outdated Show resolved Hide resolved
Comment on lines +1356 to +1375
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;
}
}
Copy link
Contributor

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:

Suggested change
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 ) );
Copy link
Contributor

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.

Suggested change
timeDiff -= eTofConst::coarseClockCycle * ( ( timeDiff < 0 ) ? -1 : ( timeDiff > 0 ) );
timeDiff -= eTofConst::coarseClockCycle * ( ( timeDiff < 0 ) ? -1 : ( timeDiff > 0 ? 1 : 0) );

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I found this

Suggested change
timeDiff -= eTofConst::coarseClockCycle * ( ( timeDiff < 0 ) ? -1 : ( timeDiff > 0 ) );
timeDiff -= (timeDiff == 0 ? 0 : TMath::Sign(eTofConst::coarseClockCycle , timeDiff));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or similarly...

Suggested change
timeDiff -= eTofConst::coarseClockCycle * ( ( timeDiff < 0 ) ? -1 : ( timeDiff > 0 ) );
if (timeDiff != 0) timeDiff -= TMath::Sign(eTofConst::coarseClockCycle , timeDiff);

@fgeurts fgeurts self-requested a review December 17, 2024 20:26
Copy link
Member

@fgeurts fgeurts left a 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.

@plexoos
Copy link
Member

plexoos commented Dec 18, 2024

@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.

@YannickSoehngen YannickSoehngen merged commit eac1ee1 into star-bnl:main Dec 18, 2024
148 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants