-
Notifications
You must be signed in to change notification settings - Fork 655
[PWGDQ,PWGEM] Tune MC TPC PID response to data #16146
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
Open
JinjooSeo
wants to merge
2
commits into
AliceO2Group:master
Choose a base branch
from
JinjooSeo:MCPIDtune
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
|
|
||
| #include <Math/Vector4D.h> // IWYU pragma: keep (do not replace with Math/Vector4Dfwd.h) | ||
| #include <Math/Vector4Dfwd.h> | ||
| #include <TH2.h> | ||
| #include <TH3.h> | ||
| #include <THn.h> | ||
| #include <TObject.h> | ||
|
|
@@ -72,7 +73,7 @@ | |
| o2::globaltracking::MatchGlobalFwd VarManager::mMatching; | ||
| std::map<VarManager::CalibObjects, TObject*> VarManager::fgCalibs; | ||
| bool VarManager::fgRunTPCPostCalibration[4] = {false, false, false, false}; | ||
| int VarManager::fgCalibrationType = 0; // 0 - no calibration, 1 - calibration vs (TPCncls,pIN,eta) typically for pp, 2 - calibration vs (eta,nPV,nLong,tLong) typically for PbPb | ||
| int VarManager::fgCalibrationType = 0; // 0 - no calibration, 1 - data calibration vs (TPCncls,pIN,eta), 2 - data calibration vs (eta,nPV,nLong,tLong), 3 - MC tuning vs (pIN,eta), 4 - MC tuning vs (pIN,eta,CentFT0C) | ||
| bool VarManager::fgUseInterpolatedCalibration = true; // use interpolated calibration histograms (default: true) | ||
|
|
||
| //__________________________________________________________________ | ||
|
|
@@ -191,8 +192,8 @@ | |
| // TO Do: add more systems | ||
|
|
||
| // set the beam 4-momentum vectors | ||
| float beamAEnergy = energy / 2.0 * sqrt(NumberOfProtonsA * NumberOfProtonsC / NumberOfProtonsC / NumberOfProtonsA); // GeV | ||
| float beamCEnergy = energy / 2.0 * sqrt(NumberOfProtonsC * NumberOfProtonsA / NumberOfProtonsA / NumberOfProtonsC); // GeV | ||
| float beamAMomentum = std::sqrt(beamAEnergy * beamAEnergy - NumberOfNucleonsA * NumberOfNucleonsA * MassProton * MassProton); | ||
| float beamCMomentum = std::sqrt(beamCEnergy * beamCEnergy - NumberOfNucleonsC * NumberOfNucleonsC * MassProton * MassProton); | ||
| fgBeamA.SetPxPyPzE(0, 0, beamAMomentum, beamAEnergy); | ||
|
|
@@ -250,20 +251,20 @@ | |
| CalibObjects calibMean, calibSigma; | ||
| switch (species) { | ||
| case 0: | ||
| calibMean = kTPCElectronMean; | ||
| calibSigma = kTPCElectronSigma; | ||
| calibMean = kTPCElectronMeanData; | ||
| calibSigma = kTPCElectronSigmaData; | ||
| break; | ||
| case 1: | ||
| calibMean = kTPCPionMean; | ||
| calibSigma = kTPCPionSigma; | ||
| calibMean = kTPCPionMeanData; | ||
| calibSigma = kTPCPionSigmaData; | ||
| break; | ||
| case 2: | ||
| calibMean = kTPCKaonMean; | ||
| calibSigma = kTPCKaonSigma; | ||
| calibMean = kTPCKaonMeanData; | ||
| calibSigma = kTPCKaonSigmaData; | ||
| break; | ||
| case 3: | ||
| calibMean = kTPCProtonMean; | ||
| calibSigma = kTPCProtonSigma; | ||
| calibMean = kTPCProtonMeanData; | ||
| calibSigma = kTPCProtonSigmaData; | ||
| break; | ||
| default: | ||
| LOG(fatal) << "Invalid species for PID calibration: " << species; | ||
|
|
@@ -291,29 +292,29 @@ | |
| double mean = calibMeanHist->GetBinContent(binTPCncls, binPin, binEta); | ||
| double sigma = calibSigmaHist->GetBinContent(binTPCncls, binPin, binEta); | ||
| return (nSigmaValue - mean) / sigma; // Return the calibrated nSigma value | ||
| } else if (fgCalibrationType == 2) { | ||
| // get the calibration histograms | ||
| CalibObjects calibMean, calibSigma, calibStatus; | ||
| switch (species) { | ||
| case 0: | ||
| calibMean = kTPCElectronMean; | ||
| calibSigma = kTPCElectronSigma; | ||
| calibStatus = kTPCElectronStatus; | ||
| calibMean = kTPCElectronMeanData; | ||
| calibSigma = kTPCElectronSigmaData; | ||
| calibStatus = kTPCElectronStatusData; | ||
| break; | ||
| case 1: | ||
| calibMean = kTPCPionMean; | ||
| calibSigma = kTPCPionSigma; | ||
| calibStatus = kTPCPionStatus; | ||
| calibMean = kTPCPionMeanData; | ||
| calibSigma = kTPCPionSigmaData; | ||
| calibStatus = kTPCPionStatusData; | ||
| break; | ||
| case 2: | ||
| calibMean = kTPCKaonMean; | ||
| calibSigma = kTPCKaonSigma; | ||
| calibStatus = kTPCKaonStatus; | ||
| calibMean = kTPCKaonMeanData; | ||
| calibSigma = kTPCKaonSigmaData; | ||
| calibStatus = kTPCKaonStatusData; | ||
| break; | ||
| case 3: | ||
| calibMean = kTPCProtonMean; | ||
| calibSigma = kTPCProtonSigma; | ||
| calibStatus = kTPCProtonStatus; | ||
| calibMean = kTPCProtonMeanData; | ||
| calibSigma = kTPCProtonSigmaData; | ||
| calibStatus = kTPCProtonStatusData; | ||
| break; | ||
| default: | ||
| LOG(fatal) << "Invalid species for PID calibration: " << species; | ||
|
|
@@ -373,6 +374,119 @@ | |
| return nSigmaValue; // unknown status, return the original nSigma value | ||
| break; | ||
| } | ||
| } else if (fgCalibrationType == 3) { | ||
| CalibObjects calibMeanSim, calibSigmaSim, calibMeanData, calibSigmaData; | ||
| switch (species) { | ||
| case 0: | ||
| calibMeanSim = kTPCElectronMeanMC; | ||
| calibSigmaSim = kTPCElectronSigmaMC; | ||
| calibMeanData = kTPCElectronMeanData; | ||
| calibSigmaData = kTPCElectronSigmaData; | ||
| break; | ||
| case 1: | ||
| calibMeanSim = kTPCPionMeanMC; | ||
| calibSigmaSim = kTPCPionSigmaMC; | ||
| calibMeanData = kTPCPionMeanData; | ||
| calibSigmaData = kTPCPionSigmaData; | ||
| break; | ||
| case 2: | ||
| calibMeanSim = kTPCKaonMeanMC; | ||
| calibSigmaSim = kTPCKaonSigmaMC; | ||
| calibMeanData = kTPCKaonMeanData; | ||
| calibSigmaData = kTPCKaonSigmaData; | ||
| break; | ||
| case 3: | ||
| calibMeanSim = kTPCProtonMeanMC; | ||
| calibSigmaSim = kTPCProtonSigmaMC; | ||
| calibMeanData = kTPCProtonMeanData; | ||
| calibSigmaData = kTPCProtonSigmaData; | ||
| break; | ||
| default: | ||
| LOG(fatal) << "Invalid species for PID calibration: " << species; | ||
| return -999.0; | ||
| } | ||
|
|
||
| TH2* calibMeanSimHist = reinterpret_cast<TH2*>(fgCalibs[calibMeanSim]); | ||
| TH2* calibSigmaSimHist = reinterpret_cast<TH2*>(fgCalibs[calibSigmaSim]); | ||
| TH2* calibMeanDataHist = reinterpret_cast<TH2*>(fgCalibs[calibMeanData]); | ||
| TH2* calibSigmaDataHist = reinterpret_cast<TH2*>(fgCalibs[calibSigmaData]); | ||
|
Comment on lines
+409
to
+412
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. Don't use |
||
| if (!calibMeanSimHist || !calibSigmaSimHist || !calibMeanDataHist || !calibSigmaDataHist) { | ||
| LOG(fatal) << "MC tuning histograms not found for species: " << species; | ||
| return -999.0; | ||
| } | ||
|
|
||
| int binPin = calibMeanSimHist->GetXaxis()->FindBin(fgValues[kPin]); | ||
| binPin = (binPin == 0 ? 1 : binPin); | ||
| binPin = (binPin > calibMeanSimHist->GetXaxis()->GetNbins() ? calibMeanSimHist->GetXaxis()->GetNbins() : binPin); | ||
| int binEta = calibMeanSimHist->GetYaxis()->FindBin(fgValues[kEta]); | ||
| binEta = (binEta == 0 ? 1 : binEta); | ||
| binEta = (binEta > calibMeanSimHist->GetYaxis()->GetNbins() ? calibMeanSimHist->GetYaxis()->GetNbins() : binEta); | ||
|
|
||
| double meanSim = calibMeanSimHist->GetBinContent(binPin, binEta); | ||
| double sigmaSim = calibSigmaSimHist->GetBinContent(binPin, binEta); | ||
| double meanData = calibMeanDataHist->GetBinContent(binPin, binEta); | ||
| double sigmaData = calibSigmaDataHist->GetBinContent(binPin, binEta); | ||
| return (nSigmaValue - meanSim) * (sigmaSim / sigmaData) + meanData; | ||
| } else if (fgCalibrationType == 4) { | ||
| CalibObjects calibMeanSim, calibSigmaSim, calibMeanData, calibSigmaData; | ||
| switch (species) { | ||
| case 0: | ||
| calibMeanSim = kTPCElectronMeanMC; | ||
| calibSigmaSim = kTPCElectronSigmaMC; | ||
| calibMeanData = kTPCElectronMeanData; | ||
| calibSigmaData = kTPCElectronSigmaData; | ||
| break; | ||
| case 1: | ||
| calibMeanSim = kTPCPionMeanMC; | ||
| calibSigmaSim = kTPCPionSigmaMC; | ||
| calibMeanData = kTPCPionMeanData; | ||
| calibSigmaData = kTPCPionSigmaData; | ||
| break; | ||
| case 2: | ||
| calibMeanSim = kTPCKaonMeanMC; | ||
| calibSigmaSim = kTPCKaonSigmaMC; | ||
| calibMeanData = kTPCKaonMeanData; | ||
| calibSigmaData = kTPCKaonSigmaData; | ||
| break; | ||
| case 3: | ||
| calibMeanSim = kTPCProtonMeanMC; | ||
| calibSigmaSim = kTPCProtonSigmaMC; | ||
| calibMeanData = kTPCProtonMeanData; | ||
| calibSigmaData = kTPCProtonSigmaData; | ||
| break; | ||
| default: | ||
| LOG(fatal) << "Invalid species for PID calibration: " << species; | ||
| return -999.0; | ||
| } | ||
|
|
||
| TH3F* calibMeanSimHist = reinterpret_cast<TH3F*>(fgCalibs[calibMeanSim]); | ||
| TH3F* calibSigmaSimHist = reinterpret_cast<TH3F*>(fgCalibs[calibSigmaSim]); | ||
| TH3F* calibMeanDataHist = reinterpret_cast<TH3F*>(fgCalibs[calibMeanData]); | ||
| TH3F* calibSigmaDataHist = reinterpret_cast<TH3F*>(fgCalibs[calibSigmaData]); | ||
| if (!calibMeanSimHist || !calibSigmaSimHist || !calibMeanDataHist || !calibSigmaDataHist) { | ||
| LOG(fatal) << "MC tuning histograms not found for species: " << species; | ||
| return -999.0; | ||
| } | ||
| if (fgValues[kCentFT0C] < -999.) { | ||
| LOG(fatal) << "TPC MC tuning calibration type 4 requires event centrality in VarManager::fgValues[kCentFT0C]."; | ||
| return -999.0; | ||
| } | ||
|
|
||
| int binPin = calibMeanSimHist->GetXaxis()->FindBin(fgValues[kPin]); | ||
| binPin = (binPin == 0 ? 1 : binPin); | ||
| binPin = (binPin > calibMeanSimHist->GetXaxis()->GetNbins() ? calibMeanSimHist->GetXaxis()->GetNbins() : binPin); | ||
| int binEta = calibMeanSimHist->GetYaxis()->FindBin(fgValues[kEta]); | ||
| binEta = (binEta == 0 ? 1 : binEta); | ||
| binEta = (binEta > calibMeanSimHist->GetYaxis()->GetNbins() ? calibMeanSimHist->GetYaxis()->GetNbins() : binEta); | ||
| int binCent = calibMeanSimHist->GetZaxis()->FindBin(fgValues[kCentFT0C]); | ||
| binCent = (binCent == 0 ? 1 : binCent); | ||
| binCent = (binCent > calibMeanSimHist->GetZaxis()->GetNbins() ? calibMeanSimHist->GetZaxis()->GetNbins() : binCent); | ||
|
|
||
| double meanSim = calibMeanSimHist->GetBinContent(binPin, binEta, binCent); | ||
| double sigmaSim = calibSigmaSimHist->GetBinContent(binPin, binEta, binCent); | ||
| double meanData = calibMeanDataHist->GetBinContent(binPin, binEta, binCent); | ||
| double sigmaData = calibSigmaDataHist->GetBinContent(binPin, binEta, binCent); | ||
| return (nSigmaValue - meanSim) * (sigmaSim / sigmaData) + meanData; | ||
| } else { | ||
| // unknown calibration type, return the original nSigma value | ||
| LOG(fatal) << "Unknown calibration type: " << fgCalibrationType; | ||
|
|
@@ -386,14 +500,14 @@ | |
| // Bimodality coefficient = (skewness^2 + 1) / kurtosis | ||
| // return a tuple including the coefficient, mean, RMS, skewness, and kurtosis | ||
| size_t n = data.size(); | ||
| if (n < 3) { | ||
| return std::make_tuple(-1.0, -1.0, -1.0, -1.0, -1.0); | ||
| } | ||
| float mean = std::accumulate(data.begin(), data.end(), 0.0) / n; | ||
|
|
||
| float m2 = 0.0, m3 = 0.0, m4 = 0.0; | ||
| float diff, diff2; | ||
| for (float x : data) { | ||
| diff = x - mean; | ||
| diff2 = diff * diff; | ||
| m2 += diff2; | ||
|
|
@@ -432,7 +546,7 @@ | |
| int nBins = static_cast<int>((max - min) / binWidth); | ||
| std::vector<int> counts(nBins, 0.0); | ||
|
|
||
| for (float x : data) { | ||
| if (x < min || x >= max) { | ||
| continue; // skip out-of-range values | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
These hard-coded case numbers are meaningless.