ATLAS Offline Software
CorrectionTool.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /// @author Nils Krumnack
6 
7 
8 #ifndef PATINTERFACES_CORRECTIONTOOL_ICC
9 #define PATINTERFACES_CORRECTIONTOOL_ICC
10 
11 #include <memory>
12 
13 namespace CP {
14 
15  template< class T >
16  CorrectionCode CorrectionTool< T >::
17  correctedCopy( const xAODObjectType& inputObject,
18  xAODObjectType*& outputObject ) {
19 
20  // Choose a smart pointer type according to the standard used:
21  std::unique_ptr< xAODObjectType > myobject( new xAODObjectType );
22 
23  // Make a deep copy of the input object:
24  myobject->makePrivateStore( inputObject );
25 
26  // Call the function implemented in the concrete tool:
27  CorrectionCode result = applyCorrection( *myobject );
28  if( result != CorrectionCode::Error ) {
29  outputObject = myobject.release();
30  }
31 
32  return result;
33  }
34 
35  template< class T >
36  CorrectionCode CorrectionTool< T >::
37  applyContainerCorrection( xAODContainerType& inputContainer ) {
38 
39  // Loop over the container:
40  typename xAODContainerType::iterator itr = inputContainer.begin();
41  typename xAODContainerType::iterator end = inputContainer.end();
42  for( ; itr != end; ++itr ) {
43  // Apply the correction for this object:
44  CorrectionCode subresult = applyCorrection( **itr );
45  if( subresult == CorrectionCode::Error ) {
46  return subresult;
47  }
48  }
49 
50  // We were successful:
51  return CorrectionCode::Ok;
52  }
53 
54 } // namespace CP
55 
56 #endif // PATINTERFACES_CORRECTIONTOOL_ICC