ATLAS Offline Software
Loading...
Searching...
No Matches
TrackOverlayDecisionAlg::TrackOverlayDecisionAlg Class Reference

#include <TrackOverlayDecisionAlg.h>

Inheritance diagram for TrackOverlayDecisionAlg::TrackOverlayDecisionAlg:
Collaboration diagram for TrackOverlayDecisionAlg::TrackOverlayDecisionAlg:

Public Member Functions

 TrackOverlayDecisionAlg (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor with parameters.
virtual ~TrackOverlayDecisionAlg ()=default
 Destructor.
virtual StatusCode initialize () override final
 Athena algorithm's interface method initialize().
virtual StatusCode execute (const EventContext &ctx) const override final
 Athena algorithm's interface method execute().
virtual StatusCode finalize () override final
 Athena algorithm's interface method finalize().
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
virtual bool filterPassed (const EventContext &ctx) const
 Get filter decision:
virtual void setFilterPassed (bool state, const EventContext &ctx) const
 Set filter decision:
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvc > StoreGateSvc_t

Private Member Functions

void markSelectedByPileupSwitch (const std::vector< const xAOD::TruthParticle * > &truthParticles) const
const std::vector< const xAOD::TruthParticle * > getTruthParticles () const
std::tuple< std::vector< int64_t >, std::vector< char * > > GetInputNodeInfo (const std::unique_ptr< Ort::Session > &session)
std::tuple< std::vector< int64_t >, std::vector< char * > > GetOutputNodeInfo (const std::unique_ptr< Ort::Session > &session)
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ToolHandle< IAthSelectionTool > m_truthSelectionTool {this, "TruthSelectionTool","AthTruthSelectionTool", "Truth selection tool (for efficiencies and resolutions)"}
SG::Decorator< bool > m_dec_selectedByPileupSwitch {"selectedByPileupSwitch"}
bool m_usingSpecialPileupSwitch {false}
BooleanProperty m_useTrackSelection {this, "useTrackSelection", false, "plot only tracks accepted by selection tool"}
StringProperty m_pileupSwitch {this, "PileupSwitch", "HardScatter", "Pileup truth strategy to use. May be \"All\", \"HardScatter\", or \"PileUp\""}
FloatProperty m_lowProb {this,"LowProb",0.5,"Truth match prob. cutoff for efficiency (lower bound) and fake (upper bound) classification."}
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoContainerName {this,"EventInfoContainerName", "EventInfo", ""}
SG::ReadHandleKey< xAOD::TruthPileupEventContainer > m_truthPileUpEventName {this, "TruthPileupEvents", "TruthPileupEvents","Name of the truth pileup events container probably TruthPileupEvent(s)"}
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleName {this, "TruthParticleContainerName", "TruthParticles", ""}
SG::ReadHandleKey< xAOD::TruthEventContainer > m_truthEventName {this, "TruthEvents", "TruthEvents","Name of the truth events container probably either TruthEvent or TruthEvents"}
FilterReporterParams m_filterParams {this, "TrackOverlayDecisionAlg", "Decides whether events should be reconstructed in track-overlay workflow or MC-overlay."}
Gaudi::Property< bool > m_invertfilter {this, "InvertFilter", false, "Invert filter decision."}
 invert filter decision at the end
Gaudi::Property< float > m_MLthreshold {this, "MLThreshold", 0.74201, "ML threshold for bad/good tracks decision. ML scores larger than this threshold are considered as bad tracks."}
SG::WriteDecorHandleKey< xAOD::EventInfo > m_decIsMCOverlayKey {this, "IsMCOverlayDecor", m_eventInfoContainerName, "TrackOverlayIsMCOverlay", "1 if the event is reconstructed in the MC-overlay workflow"}
ServiceHandle< AthOnnx::IOnnxRuntimeSvc > m_svc {this, "ONNXRuntimeSvc", "AthOnnx::OnnxRuntimeSvc", "CaloMuonScoreTool ONNXRuntimeSvc"}
std::tuple< std::vector< int64_t >, std::vector< char * > > m_inputInfo
std::tuple< std::vector< int64_t >, std::vector< char * > > m_outputInfo
std::unique_ptr< Ort::Session > m_session
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 58 of file TrackOverlayDecisionAlg.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 376 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TrackOverlayDecisionAlg()

TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::TrackOverlayDecisionAlg ( const std::string & name,
ISvcLocator * pSvcLocator )

Constructor with parameters.

Definition at line 23 of file TrackOverlayDecisionAlg.cxx.

23 :
24 ::AthReentrantAlgorithm( name, pSvcLocator )
25 {
26 }

◆ ~TrackOverlayDecisionAlg()

virtual TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::~TrackOverlayDecisionAlg ( )
virtualdefault

Destructor.

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::execute ( const EventContext & ctx) const
finaloverridevirtual

Athena algorithm's interface method execute().

Definition at line 119 of file TrackOverlayDecisionAlg.cxx.

120{
121 ATH_MSG_DEBUG ("Executing ...");
122
123 std::vector<const xAOD::TruthParticle*> truthParticlesVec = TrackOverlayDecisionAlg::getTruthParticles();
124
125 //Access truth info for the NN input
126 float eventPxSum = 0.0;
127 float eventPySum = 0.0;
128 float eventPt = 0.0;
129 float puEvents = 0.0;
130 std::vector<float> pxValues, pyValues, pzValues, eValues, etaValues, phiValues, ptValues;
131 float truthMultiplicity = 0.0;
132 const int truthParticles = truthParticlesVec.size();
133 for (int itruth = 0; itruth < truthParticles; itruth++) {
134 const xAOD::TruthParticle* thisTruth = truthParticlesVec[itruth];
135 const IAthSelectionTool::CutResult accept = m_truthSelectionTool->accept(thisTruth);
136 if(accept){
137 pxValues.push_back((thisTruth->px()*0.001-1.46988000e+03)* px_diff); //as MinMaxScaler: 1.46988000e+03 is the lowest value of px from a J7 sample; *(0.001) is used to convert unit rather than *(1/1000) to speed up.
138 pyValues.push_back((thisTruth->py()*0.001-1.35142000e+03)* py_diff); //the lowest value of py: 1.35142000e+03
139 pzValues.push_back((thisTruth->pz()*0.001-1.50464000e+03)* pz_diff); //the lowest value of pz: 1.50464000e+03
140 ptValues.push_back((thisTruth->pt()*0.001-5.00006000e-01)* pt_diff); //the lowest value of pt: 5.00006000e-01
141
142 etaValues.push_back(thisTruth->eta());
143 phiValues.push_back(thisTruth->phi());
144 eValues.push_back((thisTruth->e()*0.001-5.08307000e-01)*e_diff); //the lowest value of energy: 5.08307000e-01
145
146 eventPxSum += thisTruth->px();
147 eventPySum += thisTruth->py();
148 truthMultiplicity++;
149 }//accept
150 }//for itruth
151 SG::ReadHandle<xAOD::TruthPileupEventContainer> truthPileupEventContainer;
152 SG::ReadHandle<xAOD::EventInfo> pie = SG::ReadHandle<xAOD::EventInfo>(m_eventInfoContainerName, ctx);
153 if (!m_truthPileUpEventName.key().empty()) {
154 truthPileupEventContainer = SG::ReadHandle<xAOD::TruthPileupEventContainer>(m_truthPileUpEventName, ctx);
155 }
156 puEvents = !m_truthPileUpEventName.key().empty() and truthPileupEventContainer.isValid() ? static_cast<int>( truthPileupEventContainer->size() ) : pie.isValid() ? pie->actualInteractionsPerCrossing() : 0;
157 eventPt = std::sqrt(eventPxSum*eventPxSum + eventPySum*eventPySum)*0.001;
158
159 std::vector<float> puEventsVec(pxValues.size(), (puEvents-1.55000000e+01)*pu_diff); //min of puEvents= 15.5, max of puEvents=84.5
160 std::vector<float> truthMultiplicityVec(pxValues.size(), (truthMultiplicity-1.80000000e+01)*multi_diff);
161 std::vector<float> eventPtVec(pxValues.size(), (eventPt-3.42359395e-01)*eventPt_diff);
162 std::vector<float> predictions;
163
164 //Compute the distances using Eigen for Eigen's optimized operations. Initialize matrices. Observed a significant improvement on computing calculation.
165 Eigen::VectorXf ptEigen = Eigen::VectorXf::Map(ptValues.data(), ptValues.size());
166 Eigen::VectorXf phiEigen = Eigen::VectorXf::Map(phiValues.data(), phiValues.size());
167 Eigen::VectorXf etaEigen = Eigen::VectorXf::Map(etaValues.data(), etaValues.size());
168 for (std::size_t i = 0; i < truthMultiplicity; ++i) {
169 float multiplicity_0p05 = 0.0, multiplicity_0p2 = 0.0;
170 float sum_0p05 = 0.0, sum_0p2 = 0.0;
171 float pt_0p05 = 0.0, pt_0p2 = 0.0;
172 float deltaEtaI = etaEigen[i];
173 float phiI = phiEigen[i];
174 for (std::size_t j = 0; j < truthMultiplicity; ++j) {
175 if (i == j) continue; // Skip the particle itself
176 float deltaEta = deltaEtaI - etaEigen[j];
177 float deltaPhi = phiI - phiEigen[j];
178 if (deltaPhi > M_PI) {
179 deltaPhi -= 2.0 * M_PI;
180 }
181 else if (deltaPhi < -M_PI) {
182 deltaPhi += 2.0 * M_PI;
183 }
184 float distances = std::sqrt(deltaEta * deltaEta + deltaPhi * deltaPhi);
185 if (distances < 0.05){
186 multiplicity_0p05++;
187 sum_0p05 += distances;
188 pt_0p05 += ptEigen[j];
189 }
190 if (distances < 0.2){
191 multiplicity_0p2++;
192 sum_0p2 += distances;
193 pt_0p2 += ptEigen[j];
194 }
195 }// for j
196
197 std::vector<float> featData;
198 featData.push_back(pxValues[i]);
199 featData.push_back(pyValues[i]);
200 featData.push_back(pzValues[i]);
201 featData.push_back(eValues[i]);
202 featData.push_back(ptValues[i]);
203 featData.push_back((multiplicity_0p2 * area0p2) * constant1);
204 featData.push_back((multiplicity_0p05 * area0p05) * constant2);
205 featData.push_back((sum_0p2 * area0p2) * constant3);
206 featData.push_back((sum_0p05 * area0p05) * constant4);
207 featData.push_back(pt_0p2 * constant5);
208 featData.push_back(pt_0p05 * constant6);
209
210 featData.push_back(puEventsVec[i]);
211 featData.push_back(truthMultiplicityVec[i]);
212 featData.push_back(eventPtVec[i]);
213
214 std::vector<int64_t> input_node_dims;
215 std::vector<char*> input_node_names;
216 input_node_dims = std::get<0>(m_inputInfo);
217 input_node_names = std::get<1>(m_inputInfo);
218
219 std::vector<int64_t> output_node_dims;
220 std::vector<char*> output_node_names;
221 output_node_dims = std::get<0>(m_outputInfo);
222 output_node_names = std::get<1>(m_outputInfo);
223
224 Ort::MemoryInfo memoryInfo = Ort::MemoryInfo::CreateCpu(OrtArenaAllocator, OrtMemTypeCPU);
225 input_node_dims[0]=1;
226 Ort::Value input_data = Ort::Value::CreateTensor(memoryInfo, featData.data(), featData.size(), input_node_dims.data(), input_node_dims.size());
227 Ort::RunOptions run_options(nullptr);
228 //Run the inference
229 Ort::Session& mysession ATLAS_THREAD_SAFE = *m_session;
230 auto output_values = mysession.Run(run_options, input_node_names.data(), &input_data, input_node_names.size(), output_node_names.data(), output_node_names.size());
231 float* predictionData = output_values[0].GetTensorMutableData<float>();
232 float prediction = predictionData[0];
233
234 predictions.push_back(prediction);
235 }//for i
236 float threshold = m_MLthreshold;
237 int badTracks = 0;
238 for (float prediction : predictions) {
239 if (prediction > threshold) {
240 badTracks++;
241 }
242 }
243 if (truthMultiplicity == 0){
244 ATH_MSG_ERROR("truthMultiplicity is zero!");
245 return StatusCode::FAILURE;
246 }
247 float rouletteScore = static_cast<float>(badTracks) / static_cast<float>(truthMultiplicity);
248
249 FilterReporter filter(m_filterParams, false, ctx);
250 bool pass = false;
251 int decision = rouletteScore == 0;
252 if (decision==0){ //if ML decision is False, it goes to the MC-overlay workflow
253 pass = true;
254 }
255 else{
256 pass = false;
257 }
258 if (!m_invertfilter) {
259 SG::WriteDecorHandle<xAOD::EventInfo, char> decIsMCOverlay(m_decIsMCOverlayKey, ctx);
260 decIsMCOverlay(*pie) = pass;
261 }
262
263 if (m_invertfilter) {
264 pass =! pass;
265 }
266 filter.setPassed(pass);
267 ATH_MSG_DEBUG("End TrackOverlayDecisionAlg, difference in filters: "<<(pass ? "found" : "not found")<<"="<<pass<<", invert="<<m_invertfilter);
268 return StatusCode::SUCCESS;
269}
#define M_PI
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATLAS_THREAD_SAFE
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoContainerName
Gaudi::Property< bool > m_invertfilter
invert filter decision at the end
SG::WriteDecorHandleKey< xAOD::EventInfo > m_decIsMCOverlayKey
std::tuple< std::vector< int64_t >, std::vector< char * > > m_outputInfo
std::tuple< std::vector< int64_t >, std::vector< char * > > m_inputInfo
const std::vector< const xAOD::TruthParticle * > getTruthParticles() const
SG::ReadHandleKey< xAOD::TruthPileupEventContainer > m_truthPileUpEventName
float px() const
The x component of the particle's momentum.
virtual double e() const override final
The total energy of the particle.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
float py() const
The y component of the particle's momentum.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
float pz() const
The z component of the particle's momentum.
StatusCode accept(const xAOD::Muon *mu)
double deltaEta(const I4Momentum &p1, const I4Momentum &p2)
Computes efficiently .
Definition P4Helpers.h:66
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
TruthParticle_v1 TruthParticle
Typedef to implementation.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthCommonAlgorithm< Gaudi::Algorithm >::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 89 of file AthCommonAlgorithm.cxx.

54{
55 // If we didn't find any symlinks to add, just return the collection
56 // from the base class. Otherwise, return the extended collection.
57 if (!m_extendedExtraObjects.empty()) {
59 }
61}
Common base class for algorithms.

◆ filterPassed()

virtual bool AthCommonAlgorithm< Gaudi::Algorithm >::filterPassed ( const EventContext & ctx) const
inlinevirtualinherited

Get filter decision:

Definition at line 93 of file AthCommonAlgorithm.h.

93 {
94 return execState( ctx ).filterPassed();
95 }
virtual bool filterPassed(const EventContext &ctx) const
Get filter decision:

◆ finalize()

StatusCode TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::finalize ( )
finaloverridevirtual

Athena algorithm's interface method finalize().

Definition at line 48 of file TrackOverlayDecisionAlg.cxx.

49{
50 ATH_MSG_VERBOSE ( "Finalizing ..." );
51 ATH_MSG_VERBOSE("-----------------------------------------------------------------");
52 ATH_MSG_VERBOSE("m_filterParams.summary()" << m_filterParams.summary());
53 ATH_MSG_VERBOSE("-----------------------------------------------------------------");
55 ATH_MSG_VERBOSE(" =====================================================================");
56
57 return StatusCode::SUCCESS;
58}
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)

◆ GetInputNodeInfo()

std::tuple< std::vector< int64_t >, std::vector< char * > > TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::GetInputNodeInfo ( const std::unique_ptr< Ort::Session > & session)
inlineprivate

Definition at line 95 of file TrackOverlayDecisionAlg.h.

95 {
96 std::vector<int64_t> input_node_dims;
97 size_t num_input_nodes = session->GetInputCount();
98 std::vector<char*> input_node_names(num_input_nodes);
99 Ort::AllocatorWithDefaultOptions allocator;
100 for( std::size_t i = 0; i < num_input_nodes; i++ ) {
101 char* input_name = session->GetInputNameAllocated(i, allocator).release();
102 input_node_names[i] = input_name;
103 Ort::TypeInfo type_info = session->GetInputTypeInfo(i);
104 auto tensor_info = type_info.GetTensorTypeAndShapeInfo();
105 input_node_dims = tensor_info.GetShape();
106 }
107 return std::make_tuple(input_node_dims, input_node_names);
108 }

◆ GetOutputNodeInfo()

std::tuple< std::vector< int64_t >, std::vector< char * > > TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::GetOutputNodeInfo ( const std::unique_ptr< Ort::Session > & session)
inlineprivate

Definition at line 110 of file TrackOverlayDecisionAlg.h.

110 {
111 std::vector<int64_t> output_node_dims;
112 size_t num_output_nodes = session->GetOutputCount();
113 std::vector<char*> output_node_names(num_output_nodes);
114 Ort::AllocatorWithDefaultOptions allocator;
115 for( std::size_t i = 0; i < num_output_nodes; i++ ) {
116 char* output_name = session->GetOutputNameAllocated(i, allocator).release();
117 output_node_names[i] = output_name;
118 Ort::TypeInfo type_info = session->GetOutputTypeInfo(i);
119 auto tensor_info = type_info.GetTensorTypeAndShapeInfo();
120 output_node_dims = tensor_info.GetShape();
121 }
122 return std::make_tuple(output_node_dims, output_node_names);
123 }

◆ getTruthParticles()

const std::vector< const xAOD::TruthParticle * > TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::getTruthParticles ( ) const
private

Definition at line 60 of file TrackOverlayDecisionAlg.cxx.

60 {
61 std::vector<const xAOD::TruthParticle*> tempVec {};
62 if (m_pileupSwitch == "All") {
63 if (m_truthParticleName.key().empty()) {
64 return tempVec;
65 }
66 SG::ReadHandle<xAOD::TruthParticleContainer> truthParticleContainer( m_truthParticleName);
67 if (not truthParticleContainer.isValid()) {
68 return tempVec;
69 }
70 tempVec.insert(tempVec.begin(), truthParticleContainer->begin(), truthParticleContainer->end());
71 } else {
72 if (m_pileupSwitch == "HardScatter") {
73 if (not m_truthEventName.key().empty()) {
74 ATH_MSG_VERBOSE("Getting TruthEvents container.");
75 SG::ReadHandle<xAOD::TruthEventContainer> truthEventContainer( m_truthEventName);
76 const xAOD::TruthEvent* event = (truthEventContainer.isValid()) ? truthEventContainer->at(0) : nullptr;
77 if (not event) {
78 return tempVec;
79 }
80 const auto& links = event->truthParticleLinks();
81 tempVec.reserve(event->nTruthParticles());
82 for (const auto& link : links) {
83 if (link.isValid()){
84 tempVec.push_back(*link);
85 }
86 }
87 }
88 }else if (m_pileupSwitch == "PileUp") {
89 if (not m_truthPileUpEventName.key().empty()) {
90 ATH_MSG_VERBOSE("getting TruthPileupEvents container");
91 // get truth particles from all pileup events
92 SG::ReadHandle<xAOD::TruthPileupEventContainer> truthPileupEventContainer(m_truthPileUpEventName);
93 if (truthPileupEventContainer.isValid()) {
94 const unsigned int nPileup = truthPileupEventContainer->size();
95 tempVec.reserve(nPileup * 200); // quick initial guess, will still save some time
96 for (unsigned int i(0); i != nPileup; ++i) {
97 const auto *eventPileup = truthPileupEventContainer->at(i);
98 // get truth particles from each pileup event
99 int ntruth = eventPileup->nTruthParticles();
100 ATH_MSG_VERBOSE("Adding " << ntruth << " truth particles from TruthPileupEvents container");
101 const auto& links = eventPileup->truthParticleLinks();
102 for (const auto& link : links) {
103 if (link.isValid()){
104 tempVec.push_back(*link);
105 }
106 }
107 }
108 } else {
109 ATH_MSG_ERROR("no entries in TruthPileupEvents container!");
110 }
111 }
112 } else {
113 ATH_MSG_ERROR("bad value for PileUpSwitch");
114 }
115 }
116 return tempVec;
117}
SG::ReadHandleKey< xAOD::TruthEventContainer > m_truthEventName
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleName
pointer & link(pointer p) const
Return a reference to the link for an element.
TruthEvent_v1 TruthEvent
Typedef to implementation.
Definition TruthEvent.h:17

◆ initialize()

StatusCode TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::initialize ( )
finaloverridevirtual

Athena algorithm's interface method initialize().

Definition at line 28 of file TrackOverlayDecisionAlg.cxx.

29{
30 ATH_CHECK(m_filterParams.initialize(false));
31 ATH_CHECK( m_eventInfoContainerName.initialize() );
33 ATH_CHECK( m_truthParticleName.initialize( (m_pileupSwitch == "HardScatter" or m_pileupSwitch == "All") and not m_truthParticleName.key().empty() ) );
34 ATH_CHECK(m_truthSelectionTool.retrieve(EnableTool {not m_truthParticleName.key().empty()} ));
35 ATH_CHECK( m_truthEventName.initialize( (m_pileupSwitch == "HardScatter" or m_pileupSwitch == "All") and not m_truthEventName.key().empty() ) );
36 ATH_CHECK( m_truthPileUpEventName.initialize( (m_pileupSwitch == "PileUp" or m_pileupSwitch == "All") and not m_truthPileUpEventName.key().empty() ) );
37 ATH_CHECK(m_svc.retrieve());
38 std::string this_file = __FILE__;
39 const std::string model_path = PathResolverFindCalibFile("TrackOverlay/TrackOverlay_J7_model.onnx");
40 Ort::SessionOptions session_options;
41
42 m_session = std::make_unique<Ort::Session>(m_svc->env(), model_path.c_str(), session_options);
45 return StatusCode::SUCCESS;
46}
#define ATH_CHECK
Evaluate an expression and check for errors.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
std::tuple< std::vector< int64_t >, std::vector< char * > > GetInputNodeInfo(const std::unique_ptr< Ort::Session > &session)
std::tuple< std::vector< int64_t >, std::vector< char * > > GetOutputNodeInfo(const std::unique_ptr< Ort::Session > &session)
ServiceHandle< AthOnnx::IOnnxRuntimeSvc > m_svc

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isClonable()

virtual bool AthCommonAlgorithm< Gaudi::Algorithm >::isClonable ( ) const
inlineoverridevirtualinherited

Specify if the algorithm is clonable.

Only relevant for non-reentrant algorithms. Actual number of clones needs to be set via the "Cardinality" property.

Reimplemented in AFP_DigiTop, AlgB, AlgT, BCM_Digitization, CscDigitBuilder, CscDigitToCscRDO, G4AtlasAlg, G4RunAlg, HGTD_Digitization, HiveAlgBase, InDet::GNNSeedingTrackMaker, InDet::SCT_Clusterization, InDet::SiSPGNNTrackMaker, InDet::SiSPSeededTrackFinder, InDet::SiTrackerSpacePointFinder, ISF::SimKernelMT, ITk::StripDigitization, ITkPixelCablingAlg, ITkStripCablingAlg, LArHitEMapMaker, LArTTL1Maker, LUCID_DigiTop, LVL1::L1TopoSimulation, MergeCalibHits, MergeGenericMuonSimHitColl, MergeHijingPars, MergeMcEventCollection, MergeTrackRecordCollection, MergeTruthJets, MergeTruthParticles, MuonDigitizer, PileUpMTAlg, PixelDigitization, RoIBResultToxAOD, SCT_ByteStreamErrorsTestAlg, SCT_CablingCondAlgFromCoraCool, SCT_CablingCondAlgFromText, SCT_ConditionsParameterTestAlg, SCT_ConditionsSummaryTestAlg, SCT_ConfigurationConditionsTestAlg, SCT_Digitization, SCT_FlaggedConditionTestAlg, SCT_LinkMaskingTestAlg, SCT_MajorityConditionsTestAlg, SCT_ModuleVetoTestAlg, SCT_MonitorConditionsTestAlg, SCT_PrepDataToxAOD, SCT_RawDataToxAOD, SCT_ReadCalibChipDataTestAlg, SCT_ReadCalibDataTestAlg, SCT_RODVetoTestAlg, SCT_SensorsTestAlg, SCT_SiliconConditionsTestAlg, SCT_StripVetoTestAlg, SCT_TdaqEnabledTestAlg, SCT_TestCablingAlg, SCTEventFlagWriter, SCTRawDataProvider, SCTSiLorentzAngleTestAlg, SCTSiPropertiesTestAlg, SGInputLoader, Simulation::BeamEffectsAlg, TileHitVecToCnt, TileMuonFitter, TilePulseForTileMuonReceiver, TileRawChannelMaker, TRTDigitization, and ZDC_DigiTop.

Definition at line 68 of file AthCommonAlgorithm.h.

68 {
69 return true;
70 }

◆ markSelectedByPileupSwitch()

void TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::markSelectedByPileupSwitch ( const std::vector< const xAOD::TruthParticle * > & truthParticles) const
private

◆ msg()

MsgStream & AthCommonMsg< Gaudi::Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Gaudi::Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 368 of file AthCommonDataStore.h.

369 {
370 h.renounce();
372 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 352 of file AthCommonDataStore.h.

352 {
354 }

◆ setFilterPassed()

virtual void AthCommonAlgorithm< Gaudi::Algorithm >::setFilterPassed ( bool state,
const EventContext & ctx ) const
inlinevirtualinherited

Set filter decision:

Definition at line 99 of file AthCommonAlgorithm.h.

99 {
101 }
virtual void setFilterPassed(bool state, const EventContext &ctx) const
Set filter decision:

◆ sysExecute()

StatusCode AthCommonAlgorithm< Gaudi::Algorithm >::sysExecute ( const EventContext & ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Reimplemented in AthAnalysisAlgorithm.

Definition at line 80 of file AthCommonAlgorithm.cxx.

41{
42 return BaseAlg::sysExecute (ctx);
43}

◆ sysInitialize()

StatusCode AthCommonAlgorithm< Gaudi::Algorithm >::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthHistogramAlgorithm, HypoBase, InputMakerBase, and PyAthena::Alg.

Definition at line 60 of file AthCommonAlgorithm.cxx.

71 {
73
74 if (sc.isFailure()) {
75 return sc;
76 }
77
78 ServiceHandle<ICondSvc> cs("CondSvc",name());
79 for (auto h : outputHandles()) {
80 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
81 // do this inside the loop so we don't create the CondSvc until needed
82 if ( cs.retrieve().isFailure() ) {
83 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
85 }
86 if (cs->regHandle(this,*h).isFailure()) {
88 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
89 << " with CondSvc");
90 }
91 }
92 }
93 return sc;
94}
#define ATH_MSG_WARNING(x,...)
virtual StatusCode sysInitialize() override
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 298 of file AthCommonDataStore.h.

298 {
299 for (auto &a : m_vhka) {
301 for (auto k : keys) {
302 k->setOwner(this);
303 }
304 }
305 }

Member Data Documentation

◆ m_dec_selectedByPileupSwitch

SG::Decorator<bool> TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::m_dec_selectedByPileupSwitch {"selectedByPileupSwitch"}
private

Definition at line 71 of file TrackOverlayDecisionAlg.h.

71{"selectedByPileupSwitch"};

◆ m_decIsMCOverlayKey

SG::WriteDecorHandleKey<xAOD::EventInfo> TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::m_decIsMCOverlayKey {this, "IsMCOverlayDecor", m_eventInfoContainerName, "TrackOverlayIsMCOverlay", "1 if the event is reconstructed in the MC-overlay workflow"}
private

Definition at line 89 of file TrackOverlayDecisionAlg.h.

89{this, "IsMCOverlayDecor", m_eventInfoContainerName, "TrackOverlayIsMCOverlay", "1 if the event is reconstructed in the MC-overlay workflow"};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 381 of file AthCommonDataStore.h.

◆ m_eventInfoContainerName

SG::ReadHandleKey<xAOD::EventInfo> TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::m_eventInfoContainerName {this,"EventInfoContainerName", "EventInfo", ""}
private

Definition at line 79 of file TrackOverlayDecisionAlg.h.

79{this,"EventInfoContainerName", "EventInfo", ""};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 378 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthCommonAlgorithm< Gaudi::Algorithm >::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 108 of file AthCommonAlgorithm.h.

◆ m_filterParams

FilterReporterParams TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::m_filterParams {this, "TrackOverlayDecisionAlg", "Decides whether events should be reconstructed in track-overlay workflow or MC-overlay."}
private

Definition at line 86 of file TrackOverlayDecisionAlg.h.

86{this, "TrackOverlayDecisionAlg", "Decides whether events should be reconstructed in track-overlay workflow or MC-overlay."};

◆ m_inputInfo

std::tuple<std::vector<int64_t>, std::vector<char*> > TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::m_inputInfo
private

Definition at line 92 of file TrackOverlayDecisionAlg.h.

◆ m_invertfilter

Gaudi::Property<bool> TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::m_invertfilter {this, "InvertFilter", false, "Invert filter decision."}
private

invert filter decision at the end

Definition at line 87 of file TrackOverlayDecisionAlg.h.

87{this, "InvertFilter", false, "Invert filter decision."};

◆ m_lowProb

FloatProperty TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::m_lowProb {this,"LowProb",0.5,"Truth match prob. cutoff for efficiency (lower bound) and fake (upper bound) classification."}
private

Definition at line 77 of file TrackOverlayDecisionAlg.h.

77{this,"LowProb",0.5,"Truth match prob. cutoff for efficiency (lower bound) and fake (upper bound) classification."};

◆ m_MLthreshold

Gaudi::Property<float> TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::m_MLthreshold {this, "MLThreshold", 0.74201, "ML threshold for bad/good tracks decision. ML scores larger than this threshold are considered as bad tracks."}
private

Definition at line 88 of file TrackOverlayDecisionAlg.h.

88{this, "MLThreshold", 0.74201, "ML threshold for bad/good tracks decision. ML scores larger than this threshold are considered as bad tracks."};

◆ m_outputInfo

std::tuple<std::vector<int64_t>, std::vector<char*> > TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::m_outputInfo
private

Definition at line 93 of file TrackOverlayDecisionAlg.h.

◆ m_pileupSwitch

StringProperty TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::m_pileupSwitch {this, "PileupSwitch", "HardScatter", "Pileup truth strategy to use. May be \"All\", \"HardScatter\", or \"PileUp\""}
private

Definition at line 76 of file TrackOverlayDecisionAlg.h.

76{this, "PileupSwitch", "HardScatter", "Pileup truth strategy to use. May be \"All\", \"HardScatter\", or \"PileUp\""};

◆ m_session

std::unique_ptr<Ort::Session> TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::m_session
private

Definition at line 94 of file TrackOverlayDecisionAlg.h.

◆ m_svc

ServiceHandle<AthOnnx::IOnnxRuntimeSvc> TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::m_svc {this, "ONNXRuntimeSvc", "AthOnnx::OnnxRuntimeSvc", "CaloMuonScoreTool ONNXRuntimeSvc"}
private

Definition at line 91 of file TrackOverlayDecisionAlg.h.

91{this, "ONNXRuntimeSvc", "AthOnnx::OnnxRuntimeSvc", "CaloMuonScoreTool ONNXRuntimeSvc"};

◆ m_truthEventName

SG::ReadHandleKey<xAOD::TruthEventContainer> TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::m_truthEventName {this, "TruthEvents", "TruthEvents","Name of the truth events container probably either TruthEvent or TruthEvents"}
private

Definition at line 83 of file TrackOverlayDecisionAlg.h.

83{this, "TruthEvents", "TruthEvents","Name of the truth events container probably either TruthEvent or TruthEvents"};

◆ m_truthParticleName

SG::ReadHandleKey<xAOD::TruthParticleContainer> TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::m_truthParticleName {this, "TruthParticleContainerName", "TruthParticles", ""}
private

Definition at line 82 of file TrackOverlayDecisionAlg.h.

82{this, "TruthParticleContainerName", "TruthParticles", ""};

◆ m_truthPileUpEventName

SG::ReadHandleKey<xAOD::TruthPileupEventContainer> TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::m_truthPileUpEventName {this, "TruthPileupEvents", "TruthPileupEvents","Name of the truth pileup events container probably TruthPileupEvent(s)"}
private

Definition at line 81 of file TrackOverlayDecisionAlg.h.

81{this, "TruthPileupEvents", "TruthPileupEvents","Name of the truth pileup events container probably TruthPileupEvent(s)"};

◆ m_truthSelectionTool

ToolHandle<IAthSelectionTool> TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::m_truthSelectionTool {this, "TruthSelectionTool","AthTruthSelectionTool", "Truth selection tool (for efficiencies and resolutions)"}
private

Definition at line 70 of file TrackOverlayDecisionAlg.h.

70{this, "TruthSelectionTool","AthTruthSelectionTool", "Truth selection tool (for efficiencies and resolutions)"};

◆ m_useTrackSelection

BooleanProperty TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::m_useTrackSelection {this, "useTrackSelection", false, "plot only tracks accepted by selection tool"}
private

Definition at line 75 of file TrackOverlayDecisionAlg.h.

75{this, "useTrackSelection", false, "plot only tracks accepted by selection tool"};

◆ m_usingSpecialPileupSwitch

bool TrackOverlayDecisionAlg::TrackOverlayDecisionAlg::m_usingSpecialPileupSwitch {false}
private

Definition at line 72 of file TrackOverlayDecisionAlg.h.

72{false};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 387 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_vhka
privateinherited

Definition at line 386 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: