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

Update clock jump correction, add new method for hit manipulation on counter level #457

Conversation

YannickSoehngen
Copy link
Contributor

Added feedback method from Match to Hit-Maker as well as "double-jump" correction and method to modify Hits on counter level steered by Db table

@starsdong
Copy link
Member

Yannick, thanks for putting this PR out. It seems a few checks broke. Could you please help take some investigations on this? Thanks

@YannickSoehngen
Copy link
Contributor Author

YannickSoehngen commented Dec 6, 2022 via email

@starsdong
Copy link
Member

Thank you, Yannick.
Philipp, would appreciate if you can review and approve this PR.
In the meantime, Yannick, I wonder whether you can do the MuDst->picoDst conversion test for Run21 7.7 GeV data and Run20 FXT data? This will be helpful for the readiness of reproduction.

@starsdong
Copy link
Member

Philipp and Yannick, are we ready to merge? I would still like to see if you have tried a test run with the Run20 FXT data using this for MuDst->picoDst conversion and checked out the output?

StRoot/StETofHitMaker/StETofHitMaker.cxx Outdated Show resolved Hide resolved
StRoot/StETofHitMaker/StETofHitMaker.cxx Outdated Show resolved Hide resolved
StRoot/StETofHitMaker/StETofHitMaker.h Outdated Show resolved Hide resolved
StRoot/StETofHitMaker/StETofHitMaker.cxx Outdated Show resolved Hide resolved

std::map< Int_t, Int_t > mClockJumpDirection; // stores direction of clock jump for time correction

std::map< Int_t, int > mModMatrix; // stores mode of modification for hits on striplevel (flip)
Copy link
Member

Choose a reason for hiding this comment

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

The modes should be represented using an enum

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that magic numbers aren't optimal here but I would like to keep the integers as they will allow me to increase the granularity of that method to Get4 level (if need be).

Copy link
Member

Choose a reason for hiding this comment

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

I don't see how an enum would constrain the granularity... You currently have 5 modes modifying the hit coordinates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not as the method currently is. But If I'll have to increase it I can stick with our "default integer" naming scheme and wont have to introduce jet another db-table. I dont think those 5 modes will cause too much confusion, but retaining the flexibility here will allow for more easy and consistent solutions in the future.

StRoot/StETofUtil/etofHelperFunctions.cxx Outdated Show resolved Hide resolved
StRoot/StETofUtil/etofHelperFunctions.cxx Outdated Show resolved Hide resolved
StRoot/StETofUtil/etofHelperFunctions.cxx Outdated Show resolved Hide resolved
StRoot/StETofUtil/etofHelperFunctions.h Outdated Show resolved Hide resolved
StRoot/StETofUtil/etofHelperFunctions.h Outdated Show resolved Hide resolved
@starsdong
Copy link
Member

Hi Yannick, thank you for addressing the comments.
Currently the failed jobs seem to be related to the StrangeMuDst. Dmitri and Gene, I see the same issue with the DEV library has been addressed by setting back in the main branch. Is it safe to merge this PR now? Thanks

Copy link
Member

@plexoos plexoos left a comment

Choose a reason for hiding this comment

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

There are still warnings in StETofHitMaker, please address

Comment on lines 2405 to 2434
if(modMode == 0) {return;}

if(modMode == 1){
localX *= -1;
localY *= -1;
}
if(modMode == 2){

localX *= -1;
}
if(modMode == 3){
localY *= -1;
}
if(modMode == 4){
double x = localX;
double y = localY;
localX = y;
localY = -1*x;
}
if(modMode == 5){
double x = localX;
double y = localY;
localX = -1*y;
localY = x;
}
if(modMode == 99){
localX = 9999;
localY = 9999;
}

Copy link
Member

Choose a reason for hiding this comment

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

The above suggestions are reasonable. Is there any reason not to take them?

StRoot/StETofMatchMaker/StETofMatchMaker.cxx Outdated Show resolved Hide resolved
StRoot/StETofUtil/etofHelperFunctions.cxx Outdated Show resolved Hide resolved
StRoot/StETofHitMaker/StETofHitMaker.h Show resolved Hide resolved
StRoot/StETofUtil/etofHelperFunctions.cxx Outdated Show resolved Hide resolved
StRoot/StETofUtil/etofHelperFunctions.cxx Outdated Show resolved Hide resolved
StRoot/StETofUtil/etofHelperFunctions.cxx Outdated Show resolved Hide resolved
StRoot/StETofUtil/etofHelperFunctions.cxx Outdated Show resolved Hide resolved
StRoot/StETofHitMaker/StETofHitMaker.cxx Outdated Show resolved Hide resolved
StRoot/StETofHitMaker/StETofHitMaker.cxx Outdated Show resolved Hide resolved
Copy link
Member

@plexoos plexoos left a comment

Choose a reason for hiding this comment

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

There are warnings in StETofHitMaker, please address

StRoot/StETofUtil/etofHelperFunctions.cxx Outdated Show resolved Hide resolved
StRoot/StETofMatchMaker/StETofMatchMaker.cxx Outdated Show resolved Hide resolved
StRoot/StETofMatchMaker/StETofMatchMaker.cxx Outdated Show resolved Hide resolved
StRoot/StETofMatchMaker/StETofMatchMaker.cxx Outdated Show resolved Hide resolved
StRoot/StETofHitMaker/StETofHitMaker.cxx Outdated Show resolved Hide resolved
StRoot/StETofMatchMaker/StETofMatchMaker.cxx Outdated Show resolved Hide resolved
StRoot/StETofMatchMaker/StETofMatchMaker.cxx Outdated Show resolved Hide resolved
StRoot/StETofMatchMaker/StETofMatchMaker.cxx Outdated Show resolved Hide resolved
StRoot/StETofMatchMaker/StETofMatchMaker.cxx Outdated Show resolved Hide resolved
StRoot/StETofUtil/etofHelperFunctions.cxx Outdated Show resolved Hide resolved
@plexoos plexoos changed the title ClockJump_correction update and new method for Hit manipulation on counter level Update clock jump correction, add new method for hit manipulation on counter level Dec 22, 2022
StRoot/StETofHitMaker/StETofHitMaker.h Outdated Show resolved Hide resolved
StRoot/StETofMatchMaker/StETofMatchMaker.cxx Outdated Show resolved Hide resolved
StRoot/StETofMatchMaker/StETofMatchMaker.h Show resolved Hide resolved
Comment on lines 367 to 368
const double safetyMargins[ 2 ] = { 0., 0. };
mETofGeom->init( gGeoManager, safetyMargins, 0 ); //don't use helix swimmer here. Probably needs an additional include
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const double safetyMargins[ 2 ] = { 0., 0. };
mETofGeom->init( gGeoManager, safetyMargins, 0 ); //don't use helix swimmer here. Probably needs an additional include
mETofGeom->init( gGeoManager);

Looks like you pass default parameters, see

void
StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins = initializer_list<double>({0, 0}).begin(), const bool& useHelixSwimmer = false )
{

StRoot/StETofHitMaker/StETofHitMaker.cxx Outdated Show resolved Hide resolved
StRoot/StETofMatchMaker/StETofMatchMaker.h Show resolved Hide resolved
StRoot/StETofMatchMaker/StETofMatchMaker.h Outdated Show resolved Hide resolved
StRoot/StETofMatchMaker/StETofMatchMaker.h Show resolved Hide resolved
Comment on lines +308 to +315

// --------------------------------------------------------------------------------------------
// pointer to eTOF hit maker
// --------------------------------------------------------------------------------------------

mETofHitMaker = ( StETofHitMaker* ) GetMaker( "etofHit" );
LOG_DEBUG << "StETofMatchMaker::InitRun() -- pointer to eTOF hit maker: " << mETofHitMaker << endm;

Copy link
Member

Choose a reason for hiding this comment

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

No maker should directly access another maker. This would entangle the dependency between makers.

@plexoos plexoos added this to the SL23a milestone Jan 4, 2023
@plexoos
Copy link
Member

plexoos commented Jan 4, 2023

I already asked multiple times (see this thread) to fix the warnings produced by the modified code... Well now it is an error, cannot proceed before it is fixed

#10 831.4 .sl79_gcc485/OBJ/StRoot/StETofHitMaker/StETofHitMaker.cxx: In member function 'void StETofHitMaker::fillHitQA(bool, const double&)':
#10 831.4 .sl79_gcc485/OBJ/StRoot/StETofHitMaker/StETofHitMaker.cxx:1878:40: error: suggest parentheses around '&&' within '||' [-Werror=parentheses]
#10 831.4              if( fabs( tstart ) > 0.001 && fabs( tstart - ( eTofConst::bTofClockCycle - 9999. ) ) > 0.001 || mIsSim ) {
#10 831.4                                         ^
#10 831.4 .sl79_gcc485/OBJ/StRoot/StETofHitMaker/StETofHitMaker.cxx:1924:49: error: suggest parentheses around '&&' within '||' [-Werror=parentheses]
#10 831.4              if( mDoQA && fabs( tstart ) > 0.001 && fabs( tstart - ( eTofConst::bTofClockCycle - 9999. ) ) > 0.001 || mIsSim ) {
#10 831.4                                                  ^
#10 831.4 .sl79_gcc485/OBJ/StRoot/StETofHitMaker/StETofHitMaker.cxx:2022:40: error: suggest parentheses around '&&' within '||' [-Werror=parentheses]
#10 831.4              if( fabs( tstart ) > 0.001 && fabs( tstart - ( eTofConst::bTofClockCycle - 9999. ) ) > 0.001 || mIsSim ) {
#10 831.4                                         ^
#10 831.4 .sl79_gcc485/OBJ/StRoot/StETofHitMaker/StETofHitMaker.cxx:2064:49: error: suggest parentheses around '&&' within '||' [-Werror=parentheses]
#10 831.4              if( mDoQA && fabs( tstart ) > 0.001 && fabs( tstart - ( eTofConst::bTofClockCycle - 9999. ) ) > 0.001 || mIsSim ) {
#10 831.4                                                  ^
#10 831.9 cc1plus: all warnings being treated as errors


void setGet4MinTime( const double& minTime );
Copy link
Member

Choose a reason for hiding this comment

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

This is not how I suggested to fix the signature of this function. Adding 'const' is fine but passing a double by reference feels weird and superfluous

Comment on lines 367 to 368
mETofGeom->init( gGeoManager); //don't use helix swimmer here. Probably needs an additional include
LOG_DEBUG << " init done " << endm;
const double safetyMargins[ 2 ] = { 0., 0. };
mETofGeom->init( gGeoManager, safetyMargins, 0 ); //don't use helix swimmer here. Probably needs an additional include
Copy link
Member

Choose a reason for hiding this comment

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

Why did you decide to revert the changes as I suggested in #457 (comment)? What kind of bug does this fix?

It would be easier to understand your intentions and the problems you are trying to fix if you replied with some comments rather than just making changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, 2 of the tets crashed here and I wanted to see if the other changes pass them. The suggested change caused a:
"symbol lookup error: /direct/star+u/ysoehngen/Work/TestHitnew/.sl73_gcc485/lib/libStETofHitMaker.so: undefined symbol: _ZN14StETofGeometry4initEP11TGeoManager"

Comment on lines 1288 to 1293
StMuPrimaryVertex* pVtx = mMuDst->primaryVertex( 0 );
StThreeVectorD posGlo = mETofGeom->hitLocal2Master( constructedHit );
StThreeVectorD* posGlo = new StThreeVectorD( mETofGeom->hitLocal2Master( constructedHit ));

if( pVtx ) {
StThreeVectorD vtxPos = pVtx->position();
StThreeVectorD* vtxPos = new StThreeVectorD( pVtx->position());
exptof = tofPathLength(vtxPos , posGlo , 0) / ( nanosecond * c_light );
Copy link
Member

@plexoos plexoos Jan 6, 2023

Choose a reason for hiding this comment

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

You just introduced a memory leak. This must be fixed. If a function takes a pointer, you can pass the address of a variable.

std::string histName_t0corr_jump = "matchCand_t0corr_jump_s" + std::to_string( matchCand.sector ) + "m" + std::to_string( matchCand.plane ) + "c" + std::to_string( matchCand.counter );
mHistograms.at( histName_t0corr_jump )->Fill( matchCand.localX, tof - tofpi ); //cutdownYS

int get4Index = matchCand.sector * 1000 + matchCand.plane * 100 + matchCand.counter * 10 + ( matchCand.localX + 16 ) / 4 + 1;
Copy link
Member

Choose a reason for hiding this comment

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

Is the '16' in this expression the same as 'mLocalYmax'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this shifts the local x coordinate (-16 to 16) to strip-numbers (32 strips in total)

Comment on lines 102 to 106

Int_t idTruth;
Int_t idTruthHit;
Int_t nHitsFit;
bool isMissMatch;
Copy link
Member

Choose a reason for hiding this comment

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

I don't see how these new members are used in this PR. Are they needed? If not, please remove, i.e. don't add

}

if(mGet4doublejumpFlag.at(get4Nr) == 1){
constructedHit->setTime(constructedHit->time() + 6.25);
Copy link
Member

Choose a reason for hiding this comment

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

This '6.25' is already defined as a named constant, isn't it?

const double coarseClockCycle = 6.25; // [ns] -- needs to be double otherwise strange things happen ...

Comment on lines 1553 to 1554
bool IsMissmatch = false;
int IdTruth = 0;
Copy link
Member

Choose a reason for hiding this comment

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

According to STAR coding guidelines variables should start with a lower case letter: https://star-bnl.github.io/star-coding-guidelines/formatguide.xml#Variable_Names

Comment on lines 2389 to 2391
x = localX;
localX = localY;
localY = -1*x;
Copy link
Member

@plexoos plexoos Jan 6, 2023

Choose a reason for hiding this comment

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

How about this?

Suggested change
x = localX;
localX = localY;
localY = -1*x;
std::swap(localX, localY), localY = -localY;

@starsdong
Copy link
Member

Dmitri, could you please take a (final?) look at the new commits by Yannick? If OK, I think we are ready to merge this PR to main.

@plexoos
Copy link
Member

plexoos commented Jan 11, 2023

Xin, if you think it is ready just go ahead and approve. I am away this week and won't have a chance to look at it until later. From the thread it should be clear what's been addressed and what hasn't.

Copy link
Member

@starsdong starsdong left a comment

Choose a reason for hiding this comment

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

Thanks everyone for helping on this. To me, it looks ready to be merged.

@starsdong starsdong merged commit ccd8dc0 into star-bnl:main Jan 12, 2023
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