ATLAS Offline Software
TagNtupleDumper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
15 
17 
18 #include "GaudiKernel/IToolSvc.h"
19 #include "GaudiKernel/ITHistSvc.h"
20 #include "GaudiKernel/ServiceHandle.h"
21 
22 #include "TTree.h"
23 
24 #include <utility>
25 #include <set>
26 
27 namespace Analysis {
28 
29  TagNtupleDumper::TagNtupleDumper(const std::string& name, const std::string& n, const IInterface* p):
30  base_class(name, n,p),
31  m_hist_svc("THistSvc", name)
32  {
33  // setup stream
34  declareProperty("Stream", m_stream = "FTAG");
35  }
36 
38  for (auto& pair: m_features) {
39  delete pair.second;
40  }
41  // no idea how the hist service handles trees, do I have to delete them?
42  // for (auto& tree: m_trees) {
43  // delete tree.second;
44  // }
45  }
46 
48  CHECK( m_hist_svc.retrieve() );
49  return StatusCode::SUCCESS;
50  }
51 
52  StatusCode TagNtupleDumper::finalize() { // all taken care of in destructor
53  return StatusCode::SUCCESS;
54  }
55  typedef std::map<std::string,double> var_map;
57  const var_map &inputs,
58  const std::string &jetauthor) const
59  {
60  std::lock_guard<std::mutex> lock (m_mutex);
61 
62  TTree* & tree = m_trees[jetauthor];
63  if (tree == nullptr) {
64  tree = new TTree(jetauthor.c_str(), "who cares");
65  if (m_hist_svc->regTree("/" + m_stream + "/" + jetauthor,
66  tree).isFailure()) {
67  ATH_MSG_ERROR("Cannot register tree " + m_stream + "/" + jetauthor);
68  return;
69  }
70  }
71  for (const auto& in: inputs) {
72  const auto idx = std::make_pair(in.first, jetauthor);
73  // add this branch if it doesn't exist
74  float* & feature = m_features[idx];
75  if (feature == nullptr) {
76  feature = new float;
77  m_trees.at(jetauthor)->Branch(in.first.c_str(), feature);
78  ATH_MSG_INFO("Added Branch " + jetauthor + ": " + in.first );
79  }
80  *feature = in.second;
81  }
82  // fill tree
83  m_trees.at(jetauthor)->Fill();
84  } //end assign_probability
85 }
86 
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Analysis::TagNtupleDumper::m_hist_svc
ServiceHandle< ITHistSvc > m_hist_svc
Definition: TagNtupleDumper.h:54
tree
TChain * tree
Definition: tile_monitor.h:30
postInclude.inputs
inputs
Definition: postInclude.SortInput.py:15
Analysis::TagNtupleDumper::finalize
virtual StatusCode finalize() override
Definition: TagNtupleDumper.cxx:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TagNtupleDumper.h
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
xAOD::BTagging_v1
Definition: BTagging_v1.h:39
Analysis
The namespace of all packages in PhysicsAnalysis/JetTagging.
Definition: BTaggingCnvAlg.h:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
Analysis::var_map
std::map< std::string, double > var_map
Definition: TagNtupleDumper.cxx:55
Analysis::TagNtupleDumper::~TagNtupleDumper
virtual ~TagNtupleDumper()
Definition: TagNtupleDumper.cxx:37
Analysis::TagNtupleDumper::m_stream
std::string m_stream
Definition: TagNtupleDumper.h:55
Analysis::TagNtupleDumper::assignProbability
virtual void assignProbability(xAOD::BTagging *BTag, const std::map< std::string, double > &inputs, const std::string &jetauthor) const override
Definition: TagNtupleDumper.cxx:56
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
Analysis::TagNtupleDumper::TagNtupleDumper
TagNtupleDumper(const std::string &name, const std::string &n, const IInterface *)
Definition: TagNtupleDumper.cxx:29
Analysis::TagNtupleDumper::initialize
virtual StatusCode initialize() override
Definition: TagNtupleDumper.cxx:47
readCCLHist.float
float
Definition: readCCLHist.py:83