14 using namespace fastjet;
18 namespace SColdQcdCorrelatorAnalysis {
22 void SEnergyCorrelator::DoCorrelatorCalculation() {
25 if (m_inDebugMode) PrintDebug(31);
28 const uint64_t nEvts = m_inChain -> GetEntriesFast();
29 PrintMessage(7, nEvts);
33 for (uint64_t iEvt = 0; iEvt < nEvts; iEvt++) {
38 const uint64_t bytes =
GetEntry(iEvt);
47 uint64_t nJets = (int) m_evtNumJets;
48 for (uint64_t iJet = 0; iJet < nJets; iJet++) {
51 m_jetCstVector.clear();
54 const uint64_t nCsts = m_jetNumCst ->
at(iJet);
55 const double ptJet = m_jetPt ->
at(iJet);
56 const double etaJet = m_jetEta ->
at(iJet);
59 const uint32_t iPtJetBin = GetJetPtBin(ptJet);
60 const bool isGoodJet = ApplyJetCuts(ptJet, etaJet);
61 if (!isGoodJet)
continue;
64 for (uint64_t iCst = 0; iCst < nCsts; iCst++) {
67 const double drCst = (m_cstDr ->
at(iJet)).
at(iCst);
68 const double etaCst = (m_cstEta ->
at(iJet)).
at(iCst);
69 const double phiCst = (m_cstPhi ->
at(iJet)).
at(iCst);
70 const double ptCst = (m_cstPt ->
at(iJet)).
at(iCst);
73 if (m_doSecondCstLoop) {
74 for (uint64_t jCst = 0; jCst < nCsts; jCst++) {
77 if (jCst == iCst)
continue;
80 const double etaCstB = (m_cstEta ->
at(iJet)).
at(jCst);
81 const double phiCstB = (m_cstPhi ->
at(iJet)).
at(jCst);
82 const double ptCstB = (m_cstPt ->
at(iJet)).
at(jCst);
85 const double dhCstAB = (etaCst - etaCstB);
86 const double dfCstAB = (phiCst - phiCstB);
87 const double drCstAB = sqrt((dhCstAB * dhCstAB) + (dfCstAB * dfCstAB));
88 const double ptFrac = ptCst / ptCstB;
89 const double ztJetA = ptCst / ptJet;
90 const double ztJetB = ptCstB / ptJet;
91 const double ptWeight = (ptCst * ptCstB) / (ptJet * ptJet);
92 hCstPtOneVsDr ->
Fill(drCstAB, ptCst);
93 hCstPtTwoVsDr ->
Fill(drCstAB, ptCstB);
94 hCstPtFracVsDr ->
Fill(drCstAB, ptFrac);
95 hCstPhiOneVsDr ->
Fill(drCstAB, phiCst);
96 hCstPhiTwoVsDr ->
Fill(drCstAB, phiCstB);
97 hCstEtaOneVsDr ->
Fill(drCstAB, etaCst);
98 hCstEtaTwoVsDr ->
Fill(drCstAB, etaCstB);
99 hDeltaPhiOneVsDr ->
Fill(drCstAB, dfCstAB);
100 hDeltaPhiTwoVsDr ->
Fill(drCstAB, dfCstAB);
101 hDeltaEtaOneVsDr ->
Fill(drCstAB, dhCstAB);
102 hDeltaEtaTwoVsDr ->
Fill(drCstAB, dhCstAB);
103 hJetPtFracOneVsDr ->
Fill(drCstAB, ztJetA);
104 hJetPtFracTwoVsDr ->
Fill(drCstAB, ztJetB);
105 hCstPairWeightVsDr ->
Fill(drCstAB, ptWeight);
110 ROOT::Math::PtEtaPhiMVector rVecCst(ptCst, etaCst, phiCst, 0.140);
113 if (m_isInputTreeTruth && m_selectSubEvts) {
114 const int embedCst = (m_cstEmbedID ->
at(iJet)).
at(iCst);
115 const bool isSubEvtGood = CheckIfSubEvtGood(embedCst);
116 if (!isSubEvtGood)
continue;
120 const bool isGoodCst = ApplyCstCuts(ptCst, drCst);
121 if (m_applyCstCuts && !isGoodCst)
continue;
124 PseudoJet constituent(rVecCst.Px(), rVecCst.Py(), rVecCst.Pz(), rVecCst.E());
125 constituent.set_user_index(iCst);
126 m_jetCstVector.push_back(constituent);
130 for (
size_t iPtBin = 0; iPtBin < m_nBinsJetPt; iPtBin++) {
131 const bool isInPtBin = ((ptJet >= m_ptJetBins[iPtBin].first) && (ptJet < m_ptJetBins[iPtBin].second));
133 if (m_jetCstVector.size() > 0) {
134 m_eecLongSide[iPtJetBin] -> compute(m_jetCstVector);
149 void SEnergyCorrelator::ExtractHistsFromCorr() {
152 if (m_inDebugMode) PrintDebug(25);
154 vector<double> drBinEdges;
155 vector<double> lnDrBinEdges;
156 pair<vector<double>, vector<double>> histContentAndVariance;
157 pair<vector<double>, vector<double>> histContentAndError;
158 for (
size_t iPtBin = 0; iPtBin < m_nBinsJetPt; iPtBin++) {
161 TString sPtJetBin(
"_ptJet");
162 sPtJetBin += floor(m_ptJetBins[iPtBin].first);
164 TString sVarDrAxisName(
"hCorrelatorVarianceDrAxis");
165 TString sErrDrAxisName(
"hCorrelatorErrorDrAxis");
166 TString sVarLnDrAxisName(
"hCorrelatorVarianceLnDrAxis");
167 TString sErrLnDrAxisName(
"hCorrelatorErrorLnDrAxis");
168 sVarDrAxisName.Append(sPtJetBin.Data());
169 sErrDrAxisName.Append(sPtJetBin.Data());
170 sVarLnDrAxisName.Append(sPtJetBin.Data());
171 sErrLnDrAxisName.Append(sPtJetBin.Data());
175 lnDrBinEdges.clear();
176 histContentAndVariance.first.clear();
177 histContentAndVariance.second.clear();
178 histContentAndError.first.clear();
179 histContentAndError.second.clear();
182 drBinEdges = m_eecLongSide[iPtBin] -> bin_edges();
183 histContentAndVariance = m_eecLongSide[iPtBin] -> get_hist_vars();
184 histContentAndError = m_eecLongSide[iPtBin] -> get_hist_errs();
187 const size_t nDrBinEdges = drBinEdges.size();
188 for (
size_t iDrEdge = 0; iDrEdge < nDrBinEdges; iDrEdge++) {
189 const double drEdge = drBinEdges.at(iDrEdge);
190 const double lnDrEdge = log(drEdge);
191 lnDrBinEdges.push_back(lnDrEdge);
195 double drBinEdgeArray[nDrBinEdges];
196 double lnDrBinEdgeArray[nDrBinEdges];
197 for (
size_t iDrEdge = 0; iDrEdge < nDrBinEdges; iDrEdge++) {
198 drBinEdgeArray[iDrEdge] = drBinEdges.at(iDrEdge);
199 lnDrBinEdgeArray[iDrEdge] = lnDrBinEdges.at(iDrEdge);
203 const bool isNumBinEdgesGood = ((nDrBinEdges - 1) == m_nBinsDr);
204 if (!isNumBinEdgesGood) {
205 PrintError(12, nDrBinEdges);
206 assert(isNumBinEdgesGood);
210 m_outHistVarDrAxis[iPtBin] =
new TH1D(sVarDrAxisName.Data(),
"", m_nBinsDr, drBinEdgeArray);
211 m_outHistErrDrAxis[iPtBin] =
new TH1D(sErrDrAxisName.Data(),
"", m_nBinsDr, drBinEdgeArray);
212 m_outHistVarLnDrAxis[iPtBin] =
new TH1D(sVarLnDrAxisName.Data(),
"", m_nBinsDr, lnDrBinEdgeArray);
213 m_outHistErrLnDrAxis[iPtBin] =
new TH1D(sErrLnDrAxisName.Data(),
"", m_nBinsDr, lnDrBinEdgeArray);
214 m_outHistVarDrAxis[iPtBin] -> Sumw2();
215 m_outHistErrDrAxis[iPtBin] -> Sumw2();
216 m_outHistVarLnDrAxis[iPtBin] -> Sumw2();
217 m_outHistErrLnDrAxis[iPtBin] -> Sumw2();
220 for (
size_t iDrEdge = 0; iDrEdge < m_nBinsDr; iDrEdge++) {
221 const size_t iDrBin = iDrEdge + 1;
222 const double binVarContent = histContentAndVariance.first.at(iDrEdge);
223 const double binVarError = histContentAndVariance.second.at(iDrEdge);
224 const double binErrContent = histContentAndError.first.at(iDrEdge);
225 const double binErrError = histContentAndError.second.at(iDrEdge);
228 const bool areVarBinValuesNans = (isnan(binVarContent) || isnan(binVarError));
229 if (areVarBinValuesNans) {
230 PrintError(13, 0, iDrBin);
232 m_outHistVarDrAxis[iPtBin] ->
SetBinContent(iDrBin, binVarContent);
233 m_outHistVarLnDrAxis[iPtBin] ->
SetBinContent(iDrBin, binVarContent);
234 m_outHistVarDrAxis[iPtBin] ->
SetBinError(iDrBin, binVarError);
235 m_outHistVarLnDrAxis[iPtBin] ->
SetBinError(iDrBin, binVarError);
239 const bool areErrBinValuesNans = (isnan(binErrContent) || isnan(binErrError));
240 if (areErrBinValuesNans) {
241 PrintError(14, 0, iDrBin);
243 m_outHistErrDrAxis[iPtBin] ->
SetBinContent(iDrBin, binErrContent);
244 m_outHistErrLnDrAxis[iPtBin] ->
SetBinContent(iDrBin, binErrContent);
245 m_outHistErrDrAxis[iPtBin] ->
SetBinError(iDrBin, binErrError);
246 m_outHistErrLnDrAxis[iPtBin] ->
SetBinError(iDrBin, binErrError);
251 if (m_inStandaloneMode) PrintMessage(14);
258 bool SEnergyCorrelator::ApplyJetCuts(
const double ptJet,
const double etaJet) {
261 if (m_inDebugMode && (m_verbosity > 7)) PrintDebug(26);
263 const bool isInPtRange = ((ptJet >= m_ptJetRange.first) && (ptJet < m_ptJetRange.second));
264 const bool isInEtaRange = ((etaJet > m_etaJetRange.first) && (etaJet < m_etaJetRange.second));
265 const bool isGoodJet = (isInPtRange && isInEtaRange);
272 bool SEnergyCorrelator::ApplyCstCuts(
const double momCst,
const double drCst) {
275 if (m_inDebugMode && (m_verbosity > 7)) PrintDebug(27);
277 const bool isInMomRange = ((momCst >= m_momCstRange.first) && (momCst < m_momCstRange.second));
278 const bool isInDrRange = ((drCst >= m_drCstRange.first) && (drCst < m_drCstRange.second));
279 const bool isGoodCst = (isInMomRange && isInDrRange);
286 bool SEnergyCorrelator::CheckIfSubEvtGood(
const int embedID) {
289 if (m_inDebugMode && (m_verbosity > 7)) PrintDebug(33);
293 if (m_isInputTreeEmbed) {
296 const int bkgdID = 0;
298 bool isSubEvtGood =
true;
299 switch (m_subEvtOpt) {
303 isSubEvtGood = (embedID == signalID);
308 isSubEvtGood = (embedID <= bkgdID);
313 isSubEvtGood = (embedID == bkgdID);
318 isSubEvtGood = (embedID < bkgdID);
323 isSubEvtGood =
false;
324 for (
const int evtToUse : m_subEvtsToUse) {
325 if (embedID == evtToUse) {
343 uint32_t SEnergyCorrelator::GetJetPtBin(
const double ptJet) {
346 if (m_inDebugMode && (m_verbosity > 7)) PrintDebug(28);
348 bool isInPtBin(
false);
349 uint32_t iJetPtBin(0);
350 for (
size_t iPtBin = 0; iPtBin < m_nBinsJetPt; iPtBin++) {
351 isInPtBin = ((ptJet >= m_ptJetBins[iPtBin].first) && (ptJet < m_ptJetBins[iPtBin].second));