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

Reduce dependence on HistogramTools #795

Merged
merged 24 commits into from Apr 16, 2024
Merged

Conversation

sdobbs
Copy link
Contributor

@sdobbs sdobbs commented Apr 2, 2024

We've seen that when using newer versions of gcc and/or ROOT, that sometimes we run into segfaults that seem to be linked to the HistogramTools package. Also, even though it's convenient, its locking behavior is not the most efficient.

So this is a first attempt to rewrite plugins to remove the dependence on this header.

I suggest that this PR not be merged until after the next tagged release
I've checked to make sure that the new plugins run correctly, but haven't done more detailed checks - this PR can provide a starting point for those.

@aaust
Copy link
Contributor

aaust commented Apr 8, 2024

The plugin BCAL_ADC_4ns is not included in the SConscript file, and it does not compile either.
@markdalton Is the plugin still in use, and is it worth fixing?

@sdobbs
Copy link
Contributor Author

sdobbs commented Apr 8, 2024

For what it's worth, that plugin uses the old-style DReferenceTrajectory track extrapolations, which causes the compilation problems. Also, we haven't had to worry about the 4 ns shifts this plugin corrects for in the past 4 years or so, so it's probably okay to not fix it right now.

@aaust
Copy link
Contributor

aaust commented Apr 8, 2024

Ok thanks, I will test all other plugins.

@aaust
Copy link
Contributor

aaust commented Apr 8, 2024

  • TrackingPulls crashes in the first 30 events
  • CDC_Efficiency seems to be stuck in an infinite loop

The remaining list of plugins is running with a similar speed as the master:

  • CDC_PerStrawReco
  • FDC_Efficiency
  • CDC_TimeToDistance
  • BCAL_SiPM_saturation
  • BCAL_attenlength_gainratio
  • FCALLEDTree (needs -PFCALLED:Tree=1 to run, should be fixed)

The individual histograms still have to be validated.

@sdobbs
Copy link
Contributor Author

sdobbs commented Apr 10, 2024

Thanks for checking - how did you run these? Just one plugin at a time?
I tried mostly running all of them together, but these concurrency problems can show up in odd ways.

…ginal histograms were TH1I/TH2I. Lots of names changed.
@aaust
Copy link
Contributor

aaust commented Apr 10, 2024

All plugins were run together, but there should not be any interference afaict.
I corrected and validated FDC_Efficiency and TrackingPulls.

@sdobbs
Copy link
Contributor Author

sdobbs commented Apr 10, 2024

OK, thanks for fixing those.

@aaust
Copy link
Contributor

aaust commented Apr 10, 2024

This lock is responsible for the "infinite loop". It is opened inside an if statement:

if(foundHit)
{
const DCDCDigiHit *thisDigiHit = NULL;
const Df125CDCPulse *thisPulse = NULL;
locHit->GetSingle(thisDigiHit);
if (thisDigiHit != NULL)
thisDigiHit->GetSingle(thisPulse);
if (thisPulse != NULL)
{
ROCIDFromRingStraw[ringNum - 1][wireNum - 1] = thisPulse->rocid;
SlotFromRingStraw[ringNum - 1][wireNum - 1] = thisPulse->slot;
ChannelFromRingStraw[ringNum - 1][wireNum - 1] = thisPulse->channel;
}
japp->RootFillLock(this); //ACQUIRE ROOT FILL LOCK

but released outside of it:
japp->RootFillUnLock(this); //RELEASE ROOT FILL LOCK

@sdobbs
Copy link
Contributor Author

sdobbs commented Apr 11, 2024

OK, I pushed a fix for CDC_Efficiency. I don't think FCALLEDTree needs to be changed - by default it just fills some histograms, so I think it's up to the original author(s) to say if they want the default behavior changed.

@aaust
Copy link
Contributor

aaust commented Apr 11, 2024

@sdobbs Thanks. I missed that you actually fixed FCALLEDTree in one of your commits.

@aaust
Copy link
Contributor

aaust commented Apr 15, 2024

Why is this commented out?

/*
// fill per-straw histograms
hStrawDriftTimeVsPhiDOCA[region][ring-1][straw-1]->Fill(docaphi, time);
hStrawPredictedDistanceVsPhiDOCA[region][ring-1][straw-1]->Fill(docaphi, predictedDistance);
hStrawResidual[region][ring-1][straw-1]->Fill(residual);
hStrawResidualVsZ[region][ring-1][straw-1]->Fill(dz,residual);
//Time to distance relation in bins
// Calcuate delta
double delta = max_sag[ring - 1][straw - 1]*(1.-dz*dz/5625.)
*cos(docaphi + sag_phi_offset[ring - 1][straw - 1]);
if ( 2 * max_sag[ring - 1][straw - 1] > binwidth){
hStrawResidualVsDelta[region][ring-1][straw-1]->Fill(delta, residual);
}
hStrawPredictedDriftDistanceVsDriftTime[region][ring-1][straw-1]->Fill(time, predictedDistance);
hStrawPredictedDriftDistanceVsDelta[region][ring-1][straw-1]->Fill(delta, predictedDistance - 0.78);
if (delta > 0){ // Long side of straw
hPredictedDriftDistanceVsDriftTime_PosDelta[region][ring-1][straw-1]->Fill(time, predictedDistance);
hResidualVsDriftTime_PosDelta[region][ring-1][straw-1]->Fill(time, residual);
hResidual_PosDelta[region][ring-1][straw-1]->Fill(residual);
}
else { // Short side of straw
hPredictedDriftDistanceVsDriftTime_NegDelta[region][ring-1][straw-1]->Fill(time, predictedDistance);
hPredictedDriftDistanceVsDriftTime_NegDelta[region][ring-1][straw-1]->Fill(time, residual);
hResidual_NegDelta[region][ring-1][straw-1]->Fill(residual);
}
*/

@sdobbs
Copy link
Contributor Author

sdobbs commented Apr 15, 2024

That's a mistake which slipped in during debugging some of these other problems - those lines should be uncommented.

Copy link
Contributor

@aaust aaust left a comment

Choose a reason for hiding this comment

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

Thoroughly tested. The only obvious differences that remain concern histogram types, e.g. TH1I instead of TH1F or similar.

@aaust aaust merged commit 3d1a2dc into master Apr 16, 2024
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.

None yet

3 participants