6 #include "GaudiKernel/SystemOfUnits.h"
28 const std::string&
name,
31 , m_jetCalibrationTools()
78 ATH_MSG_WARNING(
"Number of collections to calibrate differs from the number of calibration tools... switching "
88 std::string myname =
name;
89 if (
name.find(
"AntiKt10LCTopo") != std::string::npos and
name.find(
"My") == std::string::npos)
92 if (
name ==
"AntiKt10TrackCaloClustersChargedJets")
93 myname =
"AntiKt10TrackCaloClustersCombinedJets";
94 if (
name ==
"AntiKt10TrackCaloClustersChargedTrimmedJets")
95 myname =
"AntiKt10TrackCaloClustersCombinedTrimmedJets";
105 m_tccPlots.insert(std::pair<std::string, TCCPlots*>(
113 m_tccPlots.insert(std::pair<std::string, TCCPlots*>(
127 return StatusCode::SUCCESS;
135 if (!
evt.isValid()) {
138 float mcEventWeight =
evt->mcEventWeight();
152 const auto *
const jets_beforeCalib = getContainer<xAOD::JetContainer>(
name);
153 if (not jets_beforeCalib) {
154 return StatusCode::FAILURE;
165 ATH_MSG_WARNING(
"Unable to create calibrated jet shallow copy container");
166 return StatusCode::SUCCESS;
171 const auto *
const caloclusters = (
name.find(
"Trimmed") == std::string::npos)
174 const auto *
const truths = (
name.find(
"Trimmed") == std::string::npos)
179 return StatusCode::FAILURE;
182 if (not caloclusters) {
183 return StatusCode::FAILURE;
196 if (truth_matched_nocuts)
207 for (
const auto truth : *truths)
237 std::vector<const xAOD::Jet*> leadings = {
nullptr,
nullptr };
238 std::vector<const xAOD::Jet*> leadings_nocuts = {
nullptr,
nullptr };
240 std::vector<const xAOD::Jet*> tmp_leadings;
241 if (!
jets->empty()) {
242 tmp_leadings.push_back(
jets->at(0));
244 if (
jets->size() > 1) {
245 tmp_leadings.push_back(
jets->at(1));
248 if (tmp_leadings.size() > 1 and tmp_leadings.at(0)->m() < tmp_leadings.at(1)->m()) {
249 std::swap(tmp_leadings.at(0), tmp_leadings.at(1));
253 if (!tmp_leadings.empty() and fabs(tmp_leadings.at(0)->eta()) <
m_maxEta) {
254 leadings_nocuts.at(0) = tmp_leadings.at(0);
257 if (tmp_leadings.size() > 1 and fabs(tmp_leadings.at(1)->eta()) <
m_maxEta) {
258 leadings_nocuts.at(1) = tmp_leadings.at(1);
261 std::vector<const xAOD::Jet*> truth_matches_nocuts = {
nullptr,
nullptr };
262 unsigned int pos = 0;
263 for (
const auto&
jet : leadings_nocuts) {
268 if (truth_matched_nocuts)
269 truth_matches_nocuts.at(
pos - 1) = truth_matched_nocuts;
272 if (leadings_nocuts.at(0)) {
274 if (truth_matches_nocuts.at(0))
275 m_tccPlots.at(
name)->fillResponseNoPtNoMassCutsLeading(*leadings_nocuts.at(0), *truth_matches_nocuts.at(0));
276 ATH_MSG_DEBUG(
"Leading jet w/o cuts histograms filled! ...");
279 if (leadings_nocuts.at(1)) {
281 if (truth_matches_nocuts.at(1))
282 m_tccPlots.at(
name)->fillResponseNoPtNoMassCutsSubLeading(*leadings_nocuts.at(1),
283 *truth_matches_nocuts.at(1));
284 ATH_MSG_DEBUG(
"SubLeading jet w/o cuts histograms filled! ...");
288 if (!tmp_leadings.empty() and fabs(tmp_leadings.at(0)->eta()) <
m_maxEta and tmp_leadings.at(0)->pt() >
m_minPt)
289 leadings.at(0) = tmp_leadings.at(0);
291 if (tmp_leadings.size() > 1 and fabs(tmp_leadings.at(1)->eta()) <
m_maxEta and tmp_leadings.at(1)->pt() >
m_minPt)
292 leadings.at(1) = tmp_leadings.at(1);
294 if (leadings.at(0)) {
299 if (leadings.at(1)) {
304 std::vector<const xAOD::Jet*> truth_matches = {
nullptr,
nullptr };
305 std::vector<const xAOD::Jet*> calo_matches = {
nullptr,
nullptr };
307 for (
const auto&
jet : leadings) {
313 truth_matches.at(
pos - 1) = truth_matched;
316 calo_matches.at(
pos - 1) = calo_matched;
319 if (leadings.at(0)) {
321 if (truth_matches.at(0) and (truth_matches.at(0)->m() >
m_minMass and truth_matches.at(0)->m() <
m_maxMass)) {
322 m_tccPlots.at(
name)->fillMomentsLeadingWithMassCut(*leadings.at(0));
323 m_tccPlots.at(
name)->fillResponseLeading(*leadings.at(0), *truth_matches.at(0));
325 m_tccPlots.at(
name)->fillResponseLeadingNPV(*leadings.at(0), *truth_matches.at(0), vertices->size());
326 if (calo_matches.at(0))
327 m_tccPlots.at(
name)->fillPseudoResponseLeading(*leadings.at(0), *calo_matches.at(0));
332 if (leadings.at(1)) {
334 if (truth_matches.at(1) and (truth_matches.at(1)->m() >
m_minMass and truth_matches.at(1)->m() <
m_maxMass)) {
335 m_tccPlots.at(
name)->fillMomentsSubLeadingWithMassCut(*leadings.at(1));
336 m_tccPlots.at(
name)->fillResponseSubLeading(*leadings.at(1), *truth_matches.at(1));
338 m_tccPlots.at(
name)->fillResponseSubLeadingNPV(*leadings.at(1), *truth_matches.at(1), vertices->size());
339 if (calo_matches.at(1))
340 m_tccPlots.at(
name)->fillPseudoResponseSubLeading(*leadings.at(1), *calo_matches.at(1));
351 return StatusCode::FAILURE;
352 for (
const auto track : *tracks) {
372 return StatusCode::FAILURE;
373 for (
const auto cluster : *
clusters) {
383 const auto *
const tccs = getContainer<xAOD::TrackCaloClusterContainer>(
name);
385 return StatusCode::FAILURE;
387 std::vector<const xAOD::TrackParticle*> allpv0tracks;
388 for (
const auto tcc : *tccs) {
389 allpv0tracks.push_back(*tcc->trackParticleLink());
392 for (
const auto tcc : *tccs) {
402 return StatusCode::SUCCESS;
408 std::vector<const xAOD::Jet*> myjets = {};
409 for (
const auto tomatch : *
jets)
410 myjets.push_back(tomatch);
419 for (
const auto& tomatch :
jets) {
420 if (
jet->p4().DeltaR(tomatch->p4()) < minDeltaR) {
421 minDeltaR =
jet->p4().DeltaR(tomatch->p4());
433 plots.second->setDetailLevel(100);
434 plots.second->initialize();
435 std::vector<HistData>
hists =
plots.second->retrieveBookedHistograms();
441 return StatusCode::SUCCESS;
451 plots.second->finalize();
455 return StatusCode::SUCCESS;
461 const std::string&
name)
469 if (
evtStore()->record(jetContainerShallowCopy,
name +
"_Calib").isFailure()) {
473 if (
evtStore()->record(jetAuxContainerShallowCopy,
name +
"_Calib" +
"Aux.").isFailure()) {
474 ATH_MSG_WARNING(
"Unable to record JetCalibratedAuxContainer: " <<
name +
"_Calib" +
"Aux.");
488 for (
xAOD::Jet* shallowCopyJet : *jetContainerShallowCopy) {
490 accSetOriginLink(*shallowCopyJet) = originLink;
493 if (
evtStore()->setConst(jetContainerShallowCopy).isFailure()) {
495 <<
")const in StoreGate!");
498 if (
evtStore()->setConst(jetAuxContainerShallowCopy).isFailure()) {
500 <<
")const in StoreGate!");
504 return jetContainerShallowCopy;