ATLAS Offline Software
SystematicsHandles/Root/CopyHelpers.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 //
9 // includes
10 //
11 
13 
16 #include <xAODJet/JetContainer.h>
17 #include <xAODMuon/MuonContainer.h>
21 
22 //
23 // method implementations
24 //
25 
26 namespace CP
27 {
28  namespace detail
29  {
31  getCopy (MsgStream& msgStream, StoreType& store,
32  xAOD::IParticleContainer*& object,
33  const xAOD::IParticleContainer *inputObject,
34  const std::string& outputName, const std::string& auxName)
35  {
36  // this is probably not the best way to do this, but doing this
37  // the proper way will require an xAOD expert to do it.
38 
39  // Set up a lambda for providing a msg(...) function.
40  // Suppress thread-checker warning because this provides just a wrapper to MsgStream.
41  const auto msg = [&] ATLAS_NOT_THREAD_SAFE (MSG::Level lvl) -> MsgStream& {
42  msgStream << lvl;
43  return msgStream;
44  };
45 
46  // using a macro is a bit awkward, but doing this as a template
47  // is not practical either
48 #define COPY(TYPE) \
49  do { \
50  const TYPE *in = dynamic_cast< const TYPE* >( inputObject ); \
51  if( in ) { \
52  TYPE *out = nullptr; \
53  ANA_CHECK( ShallowCopy<TYPE>::getCopy( msgStream, store, out, in, \
54  outputName, auxName ) ); \
55  object = out; \
56  return StatusCode::SUCCESS; \
57  } \
58  } while( false )
59 
67 
68 #undef COPY
69 
70  ANA_MSG_ERROR ("could not determine type to create shallow copy " << outputName);
71  ANA_MSG_ERROR ("please extend CopyHelpers.cxx with the appropriate type");
72  return StatusCode::FAILURE;
73  }
74  }
75 }
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:71
ATLAS_NOT_THREAD_SAFE
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
Definition: checker_macros.h:212
TruthParticleContainer.h
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
detail
Definition: extract_histogram_tag.cxx:14
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
CP::detail::ShallowCopy
a helper class to create shallow copies and register them in the event store
Definition: SystematicsHandles/SystematicsHandles/CopyHelpers.h:61
CP::detail::ShallowCopy< xAOD::IParticleContainer >::StoreType
std::decay< decltype(*(std::declval< EL::AnaAlgorithm >).evtStore()))>::type StoreType
the type of the event store we use
Definition: SystematicsHandles/SystematicsHandles/CopyHelpers.h:315
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
COPY
#define COPY(TYPE)
ElectronContainer.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TauJetContainer.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
lumiFormat.outputName
string outputName
Definition: lumiFormat.py:65
MuonContainer.h
CopyHelpers.h
JetContainer.h
PhotonContainer.h
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
TrackParticleContainer.h