-
Notifications
You must be signed in to change notification settings - Fork 490
TRD: updates in vdrift and ExB calibration + possibility to use slope in chi2 matching #14989
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
Changes from all commits
b8c6cad
04150c8
f364ce5
f4ec8f3
8ed8d3e
3c5ceb0
984060e
cefb1d6
6a2a47c
37a5c05
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,12 +33,52 @@ class CalGain | |
|
|
||
| void setMPVdEdx(int iDet, float mpv) { mMPVdEdx[iDet] = mpv; } | ||
|
|
||
| float getMPVdEdx(int iDet) const { return mMPVdEdx[iDet]; } | ||
| float getMPVdEdx(int iDet, bool defaultAvg = true) const | ||
| { | ||
| // if defaultAvg = false, we take the value stored whatever it is | ||
| // if defaultAvg = true and we have default value or bad value stored, we take the average on all chambers instead | ||
| if (!defaultAvg || isGoodGain(iDet)) | ||
| return mMPVdEdx[iDet]; | ||
| else { | ||
| if (TMath::Abs(mMeanGain + 999.) < 1e-6) | ||
| mMeanGain = getAverageGain(); | ||
| return mMeanGain; | ||
| } | ||
| } | ||
|
|
||
| float getAverageGain() const | ||
| { | ||
| float averageGain = 0.; | ||
| int ngood = 0; | ||
|
|
||
| for (int iDet = 0; iDet < constants::MAXCHAMBER; iDet++) { | ||
| if (isGoodGain(iDet)) { | ||
| // The chamber has correct calibration | ||
| ngood++; | ||
| averageGain += mMPVdEdx[iDet]; | ||
| } | ||
| } | ||
| if (ngood == 0) { | ||
| // we should make sure it never happens | ||
| return constants::MPVDEDXDEFAULT; | ||
| } | ||
| averageGain /= ngood; | ||
| return averageGain; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should not the averages be precalculated at initialisation and assigned to a non-persistent data member?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A static variable in o2::trd compiles, I cant run it from where i am though. Not a fan of global variables, so maybe it's best to leave as is 🤷 |
||
| } | ||
|
|
||
| bool isGoodGain(int iDet) const | ||
| { | ||
| if (TMath::Abs(mMPVdEdx[iDet] - constants::MPVDEDXDEFAULT) > 1e-6) | ||
| return true; | ||
| else | ||
| return false; | ||
| } | ||
|
|
||
| private: | ||
| std::array<float, constants::MAXCHAMBER> mMPVdEdx{}; ///< Most probable value of dEdx distribution per TRD chamber | ||
| mutable float mMeanGain{-999.}; ///! average gain, calculated only once | ||
|
|
||
| ClassDefNV(CalGain, 1); | ||
| ClassDefNV(CalGain, 2); | ||
| }; | ||
|
|
||
| } // namespace trd | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,14 +34,102 @@ class CalVdriftExB | |
| void setVdrift(int iDet, float vd) { mVdrift[iDet] = vd; } | ||
| void setExB(int iDet, float exb) { mExB[iDet] = exb; } | ||
|
|
||
| float getVdrift(int iDet) const { return mVdrift[iDet]; } | ||
| float getExB(int iDet) const { return mExB[iDet]; } | ||
| float getVdrift(int iDet, bool defaultAvg = true) const | ||
| { | ||
| // if defaultAvg = false, we take the value stored whatever it is | ||
| // if defaultAvg = true and we have default value or bad value stored, we take the average on all chambers instead | ||
| if (!defaultAvg || (isGoodExB(iDet) && isGoodVdrift(iDet))) | ||
| return mVdrift[iDet]; | ||
| else { | ||
| if (TMath::Abs(mMeanVdrift + 999.) < 1e-6) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| mMeanVdrift = getAverageVdrift(); | ||
| return mMeanVdrift; | ||
| } | ||
| } | ||
| float getExB(int iDet, bool defaultAvg = true) const | ||
| { | ||
| if (!defaultAvg || (isGoodExB(iDet) && isGoodVdrift(iDet))) | ||
| return mExB[iDet]; | ||
| else { | ||
| if (TMath::Abs(mMeanExB + 999.) < 1e-6) | ||
| mMeanExB = getAverageExB(); | ||
| return mMeanExB; | ||
| } | ||
| } | ||
|
|
||
| float getAverageVdrift() const | ||
| { | ||
| float averageVdrift = 0.; | ||
| int ngood = 0; | ||
|
|
||
| for (int iDet = 0; iDet < constants::MAXCHAMBER; iDet++) { | ||
| if (isGoodExB(iDet) && isGoodVdrift(iDet)) { | ||
| // Both values need to be correct to declare a chamber as well calibrated | ||
| ngood++; | ||
| averageVdrift += mVdrift[iDet]; | ||
| } | ||
| } | ||
| if (ngood == 0) { | ||
| // we should make sure it never happens | ||
| return constants::VDRIFTDEFAULT; | ||
| } | ||
| averageVdrift /= ngood; | ||
| return averageVdrift; | ||
| } | ||
|
|
||
| float getAverageExB() const | ||
| { | ||
| float averageExB = 0.; | ||
| int ngood = 0; | ||
|
|
||
| for (int iDet = 0; iDet < constants::MAXCHAMBER; iDet++) { | ||
| if (isGoodExB(iDet) && isGoodVdrift(iDet)) { | ||
| // Both values need to be correct to declare a chamber as well calibrated | ||
| ngood++; | ||
| averageExB += mExB[iDet]; | ||
| } | ||
| } | ||
| if (ngood == 0) { | ||
| // we should make sure it never happens | ||
| return constants::EXBDEFAULT; | ||
| } | ||
| averageExB /= ngood; | ||
| return averageExB; | ||
| } | ||
|
|
||
| bool isGoodExB(int iDet) const | ||
| { | ||
| // check if value is well calibrated or not | ||
| // default calibration if not enough entries | ||
| // close to boundaries indicate a failed fit | ||
| if (TMath::Abs(mExB[iDet] - constants::EXBDEFAULT) > 1e-6 && | ||
| TMath::Abs(mExB[iDet] - constants::EXBMIN) > 0.01 && | ||
| TMath::Abs(mExB[iDet] - constants::EXBMAX) > 0.01) | ||
| return true; | ||
| else | ||
| return false; | ||
| } | ||
|
|
||
| bool isGoodVdrift(int iDet) const | ||
| { | ||
| // check if value is well calibrated or not | ||
| // default calibration if not enough entries | ||
| // close to boundaries indicate a failed fit | ||
| if (TMath::Abs(mVdrift[iDet] - constants::VDRIFTDEFAULT) > 1e-6 && | ||
| TMath::Abs(mVdrift[iDet] - constants::VDRIFTMIN) > 0.1 && | ||
| TMath::Abs(mVdrift[iDet] - constants::VDRIFTMAX) > 0.1) | ||
| return true; | ||
| else | ||
| return false; | ||
| } | ||
|
|
||
| private: | ||
| std::array<float, constants::MAXCHAMBER> mVdrift{}; ///< calibrated drift velocity per TRD chamber | ||
| std::array<float, constants::MAXCHAMBER> mExB{}; ///< calibrated Lorentz angle per TRD chamber | ||
| mutable float mMeanVdrift{-999.}; ///! average drift velocity, calculated only once | ||
| mutable float mMeanExB{-999.}; ///! average lorentz angle, calculated only once | ||
|
|
||
| ClassDefNV(CalVdriftExB, 1); | ||
| ClassDefNV(CalVdriftExB, 2); | ||
| }; | ||
|
|
||
| } // namespace trd | ||
|
|
||
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.
TMathis undeclared.std:::abs?