ATLAS Offline Software
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
python.LArBlobMergeAlg.LArBlobMergeAlg Class Reference
Inheritance diagram for python.LArBlobMergeAlg.LArBlobMergeAlg:
Collaboration diagram for python.LArBlobMergeAlg.LArBlobMergeAlg:

Public Member Functions

def __init__ (self, name="LArBlobMergeAlg", **kw)
 
def initialize (self)
 
def execute (self)
 
def finalize (self)
 
def stop (self)
 
virtual StatusCode initialize () override
 
virtual StatusCode reinitialize () override
 
virtual StatusCode start () override
 
virtual StatusCode execute () override
 
virtual StatusCode stop () override
 
virtual StatusCode finalize () override
 
virtual StatusCode sysInitialize () override
 Override sysInitialize. More...
 
virtual const char * typeName () const override
 return the std::type_info name of the underlying py-component This is used by concrete implementations to connect a python component to its C++ counter-part More...
 
virtual PyObjectself () override
 return associated python object. More...
 
 DeclareInterfaceID (IPyComponent, 1, 0)
 
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies. More...
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Public Attributes

 indb
 init the base class More...
 
 patchdb
 
 outdb
 
 folder
 
 run
 
 issc
 
 patchdet
 
 patchFT
 
 patchChan
 
 nEvts
 
 onlineID
 
 noid
 
 iovSince
 
 iovUntil
 
 larCabling
 

Protected Member Functions

virtual bool setPyAttr (PyObject *pyobj) override
 attach the C++ component to its python cousin More...
 
void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
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. More...
 

Protected Attributes

PyObjectm_self
 Pointer to self (from the python world) More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

 _detStore
 note that we are using the python logging service and that the PyAthena.Alg base class has already initialized it for us More...
 
 _condStore
 
DataObjIDColl m_extendedExtraObjects
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

Definition at line 89 of file LArBlobMergeAlg.py.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ __init__()

def python.LArBlobMergeAlg.LArBlobMergeAlg.__init__ (   self,
  name = "LArBlobMergeAlg",
**  kw 
)

Definition at line 91 of file LArBlobMergeAlg.py.

91  def __init__(self, name="LArBlobMergeAlg", **kw):
92 
93  kw['name'] = name
94  super(LArBlobMergeAlg,self).__init__(**kw)
95 
96  self.indb=kw.get('inputdb',"")
97  self.patchdb=kw.get('patchingdb',"")
98  self.outdb=kw.get('outputdb',"")
99  self.folder=kw.get('fld',"")
100  self.run=kw.get('runnum',999999)
101  self.issc=kw.get('isSC',False)
102  self.patchdet=kw.get('patchdet',[])
103  self.patchFT=kw.get('patchFT',[])
104  self.patchChan=kw.get('patchChan',[])
105  self.nEvts=0
106 
107  self.msg.info(f"indb: {self.indb}, patchdb:{self.patchdb}, patchdet: {self.patchdet}, patchFT: {self.patchFT}, patchChan: {self.patchChan}, outdb: {self.outdb}, folder: {self.folder}, run: {self.run}, issc: {self.issc}")
108  return
109 
110 
111 

Member Function Documentation

◆ declareGaudiProperty() [1/4]

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

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

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

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

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

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

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

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

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ DeclareInterfaceID()

IPyComponent::DeclareInterfaceID ( IPyComponent  ,
,
 
)
inherited

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

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

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ detStore()

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

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

Definition at line 95 of file AthCommonDataStore.h.

95 { return m_detStore; }

◆ evtStore() [1/2]

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

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

Definition at line 85 of file AthCommonDataStore.h.

85 { return m_evtStore; }

◆ evtStore() [2/2]

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

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

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ execute() [1/2]

StatusCode PyAthena::Alg::execute ( )
overridevirtualinherited

Definition at line 93 of file PyAthenaAlg.cxx.

94 {
95 // ATH_MSG_DEBUG("Executing " << name() << "...");
97  PyObject* pycontext = PyCapsule_New ( const_cast<EventContext*>(&getContext()), nullptr, nullptr);
98 
99  StatusCode sc = PyAthena::callPyMethod( m_self, "sysExecute", pycontext );
100  Py_DECREF (pycontext);
101  return sc;
102 }

◆ execute() [2/2]

def python.LArBlobMergeAlg.LArBlobMergeAlg.execute (   self)

Definition at line 149 of file LArBlobMergeAlg.py.

149  def execute(self):
150  eid=ROOT.Gaudi.Hive.currentContext().eventID()
151 
152  try:
153  if self.issc:
154  condCont=self._condStore.retrieve("CondCont<LArOnOffIdMapping>","LArOnOffIdMapSC")
155  else:
156  condCont=self._condStore.retrieve("CondCont<LArOnOffIdMapping>","LArOnOffIdMap")
157  self.larCabling=condCont.find(eid)
158  except Exception:
159  print("ERROR, failed to get LArCabling")
160  return StatusCode.Failure
161 
162  if self.nEvts==0:
163  self.nEvts+=1
164  #Process one 'dummy' event to make sure all DB connections get closed
165  #print ("Dummy event...")
166  return StatusCode.Success
167 
168  self.onlineID.set_do_checks(True)
169  #self.offlineID.set_do_checks(True)
170 
171  return StatusCode.Success
172 
173 

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< 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 & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

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

Definition at line 50 of file AthAlgorithm.cxx.

51 {
52  // If we didn't find any symlinks to add, just return the collection
53  // from the base class. Otherwise, return the extended collection.
54  if (!m_extendedExtraObjects.empty()) {
56  }
57  return Algorithm::extraOutputDeps();
58 }

◆ finalize() [1/2]

StatusCode PyAthena::Alg::finalize ( )
overridevirtualinherited

Definition at line 86 of file PyAthenaAlg.cxx.

87 {
88  ATH_MSG_INFO("Finalizing " << name() << "...");
89  return PyAthena::callPyMethod( m_self, "sysFinalize" );
90 }

◆ finalize() [2/2]

def python.LArBlobMergeAlg.LArBlobMergeAlg.finalize (   self)

Definition at line 174 of file LArBlobMergeAlg.py.

174  def finalize(self):
175  self.msg.info('finalizing...')
176  return StatusCode.Success
177 

◆ initialize() [1/2]

StatusCode PyAthena::Alg::initialize ( )
overridevirtualinherited

Definition at line 60 of file PyAthenaAlg.cxx.

61 {
62  ATH_MSG_INFO("Initializing " << name() << "...");
63  return PyAthena::callPyMethod( m_self, "sysInitialize" );
64 }

◆ initialize() [2/2]

def python.LArBlobMergeAlg.LArBlobMergeAlg.initialize (   self)

Definition at line 112 of file LArBlobMergeAlg.py.

112  def initialize(self):
113 
116 
117  # Get DetectorStore...
118 
119  self._detStore = PyAthena.py_svc('StoreGateSvc/DetectorStore')
120  if self._detStore is None:
121  self.msg.error("Failed to get DetectorStore")
122  return StatusCode.Failure
123 
124  self._condStore = PyAthena.py_svc('StoreGateSvc/ConditionStore')
125  if (self._condStore is None):
126  self.msg.error("Failed to get ConditionStore")
127  return StatusCode.Failure
128 
129  # Get LArOnlineID helper class
130  if self.issc:
131  self.onlineID=self._detStore.retrieve("LArOnline_SuperCellID","LArOnline_SuperCellID")
132  else:
133  self.onlineID=self._detStore.retrieve("LArOnlineID","LArOnlineID")
134  if self.onlineID is None:
135  self.msg.error("Failed to get LArOnlineID")
136  return StatusCode.Failure
137 
138 
139  self.noid=Identifier()
140 
141 
142  # this could be also be a paramter from outside:
143  self.iovSince = 0
144  self.iovUntil = cool.ValidityKeyMax
145 
146  return StatusCode.Success
147 
148 

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< 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.

◆ msg() [1/2]

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msg() [2/2]

MsgStream& AthCommonMsg< Algorithm >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< 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< 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.

◆ reinitialize()

StatusCode PyAthena::Alg::reinitialize ( )
overridevirtualinherited

Definition at line 67 of file PyAthenaAlg.cxx.

68 {
69  ATH_MSG_INFO("Re-Initializing " << name() << "...");
70  return PyAthena::callPyMethod( m_self, "sysReinitialize" );
71 }

◆ 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< Algorithm > >::renounce ( T &  h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381  {
382  h.renounce();
383  PBASE::renounce (h);
384  }

◆ renounceArray()

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

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ self()

virtual PyObject* PyAthena::Alg::self ( )
inlineoverridevirtualinherited

return associated python object.

BORROWED reference.

Implements IPyComponent.

Definition at line 71 of file PyAthenaAlg.h.

71 { return m_self; }

◆ setPyAttr()

bool PyAthena::Alg::setPyAttr ( PyObject pyobj)
overrideprotectedvirtualinherited

attach the C++ component to its python cousin

Implements IPyComponent.

Definition at line 143 of file PyAthenaAlg.cxx.

144 {
145  // now we tell the PyObject which C++ object it is the cousin of.
147  PyObject* pyobj = TPython::CPPInstance_FromVoidPtr
148  ( (void*)this, this->typeName() );
149  if ( !pyobj ) {
150  PyErr_Clear();
151  // try PyAthena::Alg
152  pyobj = TPython::CPPInstance_FromVoidPtr ((void*)this, "PyAthena::Alg");
154  ("could not dyncast component [" << name() << "] to a python "
155  << "object of type [" << this->typeName() << "] (probably a missing "
156  << "dictionary)" << endmsg
157  << "fallback to [PyAthena::Alg]...");
158  }
159  if ( !pyobj ) {
160  PyErr_Clear();
161  ATH_MSG_WARNING("Could not dyncast component ["
162  << name() << "] to a pyobject of type ["
163  << this->typeName() << "]");
164  } else {
165  if ( -1 == PyObject_SetAttrString(o, "_cppHandle", pyobj) ) {
166  PyErr_Clear();
168  ("Could not attach C++ handle [" << name() << "] to its python "
169  << "cousin !");
170  if ( -1 == PyObject_SetAttrString(o, "_cppHandle", Py_None) ) {
171  PyErr_Clear();
173  ("could not attach a dummy C++ handle [" << name() << "] to its "
174  "python cousin !");
175  }
176  } else {
177  return true;
178  }
179  }
180  return false;
181 }

◆ start()

StatusCode PyAthena::Alg::start ( )
overridevirtualinherited

Definition at line 74 of file PyAthenaAlg.cxx.

75 {
76  return PyAthena::callPyMethod( m_self, "sysStart" );
77 }

◆ stop() [1/2]

StatusCode PyAthena::Alg::stop ( )
overridevirtualinherited

Definition at line 80 of file PyAthenaAlg.cxx.

81 {
82  return PyAthena::callPyMethod( m_self, "sysStop" );
83 }

◆ stop() [2/2]

def python.LArBlobMergeAlg.LArBlobMergeAlg.stop (   self)

Definition at line 178 of file LArBlobMergeAlg.py.

178  def stop(self): # here is all the code for the merging
179 
180  from CoolConvUtilities.AtlCoolLib import indirectOpen
181 
182  # reading main input blob
183  inconn = indirectOpen(self.indb, True)
184  if (inconn is None):
185  self.msg.error(f"Cannot connect to database {self.indb}")
186  raise RuntimeError(f"ERROR: Cannot connect to database {self.indb}")
187 
188  contents = {}
189  contents2 = {}
190  try:
191  folder=inconn.getFolder(self.folder)
192  runiov=self.run << 32
193  obj=folder.findObject(runiov,0)
194  payload=obj.payload()
195 
196  contents.update(payload_dict(payload))
197 
198  except Exception as e:
199  self.msg.warning(f"Could not decode {self.folder} from {self.indb}\n{e}")
200  return StatusCode.Failure
201 
202  # reading second input blob
203  if self.indb == self.patchdb:
204  inconn2=inconn
205  else:
206  inconn2 = indirectOpen(self.patchdb, True)
207  if (inconn2 is None):
208  self.msg.error(f"Cannot connect to database {self.patchdb}")
209  raise RuntimeError(f"ERROR: Cannot connect to database {self.patchdb}")
210 
211  try:
212  folder=inconn2.getFolder(self.folder)
213  runiov=self.run << 32
214  obj=folder.findObject(runiov,0)
215  payload=obj.payload()
216  contents2.update(payload_dict(payload))
217  except Exception:
218  self.msg.warning(f"Could not decode {self.folder} from {self.patchdb}")
219  return StatusCode.Failure
220 
221  # create folder
222  dbSvc = cool.DatabaseSvcFactory.databaseService()
223  try:
224  outconn = dbSvc.openDatabase(self.outdb,False)
225  outfolder = outconn.getFolder(self.folder)
226  except Exception:
227  #create one
228  outconn = dbSvc.createDatabase(self.outdb)
229  folder = inconn.getFolder(self.folder)
230  fspec = folder.folderSpecification()
231  from CaloCondBlobAlgs import CaloCondTools
232  desc = CaloCondTools.getAthenaFolderDescr()
233  outfolder = outconn.createFolder(self.folder, fspec, desc, True)
234 
235  # create new blobs
236  spec = cool.RecordSpecification()
237 
238  for k in contents.keys():
239  if isinstance(contents[k]["payload"], cppyy.gbl.coral.Blob):
240  spec.extend( k, cool.StorageType.Blob16M )
241  elif isinstance(contents[k]["payload"], int):
242  spec.extend( k, cool.StorageType.UInt32 )
243  else:
244  self.msg.error(f"CANNOT WORK OUT THE DATATYPE OF {k}: {contents[k]} FOR STORAGE")
245  return StatusCode.Failure
246 
247  data = cool.Record( spec )
248 
249  hash_max = self.onlineID.channelHashMax()
250  fsize = 4
251 
252  btype=getattr(ROOT,"coral::Blob")
253  outblob = {}
254  vVec = {}
255  blobvals = [ k for k in contents.keys() if isinstance( contents[k]["payload"], cppyy.gbl.coral.Blob) ]
256  blobvals2 = [ k for k in contents2.keys() if isinstance( contents2[k]["payload"], cppyy.gbl.coral.Blob) ]
257 
258  if len(blobvals) != len(blobvals2):
259  self.msg.error("The same blob payloads are not present in the two dbs!\n(1) {blobvals}\n(2) {blobvals2}")
260  return StatusCode.Failure
261 
262  for bv in blobvals:
263  vecLength = contents[bv]["size"]
264  blobsize = vecLength*hash_max*fsize
265  outblob[bv] = btype()
266  outblob[bv].resize(blobsize)
267 
268  if blobsize != len(contents[bv]["payload"]):
269  self.msg.error(f'Wrong size {len(contents[bv]["payload"])} of the input blob, should be {blobsize}')
270  return StatusCode.Failure
271 
272  vVec[bv] = ROOT.std.vector('float')(vecLength*hash_max)
273 
274  blobdata = contents[bv]["payload"].read()
275 
276  for i in range(0,hash_max):
277  if vecLength > 1:
278  for iv in range(0, vecLength):
279  vVec[bv][i*vecLength + iv] = float(struct.unpack('f',blobdata[(i*vecLength + iv)*fsize:((i*vecLength+iv)*fsize+fsize)])[0])
280  else:
281  vVec[bv][i] = float(struct.unpack('f',blobdata[i*fsize:(i*fsize+fsize)])[0])
282 
283  if blobsize != len(contents2[bv]["payload"]):
284  self.msg.error(f'Wrong size {len(contents2[bv]["payload"])} of the input blob, should be {blobsize}')
285  return StatusCode.Failure
286 
287  # patch what is needed from the second blob
288  blobdata2 = contents2[bv]["payload"].read()
289  vecLength2 = contents2[bv]["size"]
290  if vecLength != vecLength2:
291  self.msg.error(f"Item {bv} has a different shape in the base and patch dbs! {vecLength} & {vecLength2}")
292  return StatusCode.Failure
293 
294 
295  for i in range(0,hash_max):
296  doPatch = patchChannel(self.onlineID, i, self.patchdet, self.patchFT, self.patchChan)
297  if doPatch:
298  if vecLength > 1:
299  for iv in range(0, vecLength):
300  vVec[bv][i*vecLength + iv] = float(struct.unpack('f',blobdata2[(i*vecLength + iv)*fsize:((i*vecLength+iv)*fsize+fsize)])[0])
301  else:
302  vVec[bv][i] = float(struct.unpack('f', blobdata2[i*fsize:(i*fsize+fsize)])[0])
303 
304  #now trick with buffer
305  writable_buf = { k: array('f') for k in vVec.keys() }
306  buff = {}
307  for key in vVec.keys():
308  for i in range(0,vVec[key].size()):
309  writable_buf[key].append(vVec[key][i])
310  #and use buffers to fill blobs
311  buff[key] = writable_buf[key].tobytes()
312 
313  for j in range(0, len(buff[key])):
314  outblob[key][j] = buff[key][j]
315 
316  data[key] = outblob[key]
317 
318  tofill = [ k for k in contents.keys() if k not in outblob.keys() ]
319 
320  for tf in tofill:
321  if contents[tf]["payload"] != contents2[tf]["payload"]:
322  self.msg.warning(f'Setting {tf} to {contents[tf]["payload"]}, but beware: the value is {contents2[tf]["payload"]} in the patching db')
323  data[tf] = contents[tf]["payload"]
324 
325  #and record data
326  outfolder.storeObject(self.iovSince, self.iovUntil, data, cool.ChannelId(0))
327 
328  #=== close the database
329  outconn.closeDatabase()
330 
331  return StatusCode.Success
332 
333 
334 
335 
336 

◆ sysInitialize()

StatusCode PyAthena::Alg::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 AthAlgorithm.

Definition at line 105 of file PyAthenaAlg.cxx.

106 {
108  ( "PyAthena::PyComponentMgr/PyComponentMgr", name() );
109  if ( !pyMgr.retrieve().isSuccess() ) {
110  ATH_MSG_ERROR("Could not retrieve service [" << pyMgr.typeAndName()
111  << "] !!");
112  return StatusCode::FAILURE;
113  }
114 
115  // first retrieve our python object cousin...
116  m_self = pyMgr->pyObject( this );
117 
118  if ( m_self == Py_None ) {
119  ATH_MSG_ERROR("Wrapped PyObject is NONE !");
120  return StatusCode::FAILURE;
121  }
122 
123  // re-route to usual sysInit...
124  return AlgBase_t::sysInitialize();
125 }

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< 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.

◆ typeName()

const char * PyAthena::Alg::typeName ( ) const
overridevirtualinherited

return the std::type_info name of the underlying py-component This is used by concrete implementations to connect a python component to its C++ counter-part

Implements IPyComponent.

Definition at line 132 of file PyAthenaAlg.cxx.

133 {
134  static const std::string tname = System::typeinfoName(typeid(*this));
135  return tname.c_str();
136 }

◆ updateVHKA()

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

Definition at line 308 of file AthCommonDataStore.h.

308  {
309  // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310  // << " size: " << m_vhka.size() << endmsg;
311  for (auto &a : m_vhka) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

Member Data Documentation

◆ _condStore

python.LArBlobMergeAlg.LArBlobMergeAlg._condStore
private

Definition at line 124 of file LArBlobMergeAlg.py.

◆ _detStore

python.LArBlobMergeAlg.LArBlobMergeAlg._detStore
private

note that we are using the python logging service and that the PyAthena.Alg base class has already initialized it for us

Definition at line 119 of file LArBlobMergeAlg.py.

◆ folder

python.LArBlobMergeAlg.LArBlobMergeAlg.folder

Definition at line 99 of file LArBlobMergeAlg.py.

◆ indb

python.LArBlobMergeAlg.LArBlobMergeAlg.indb

init the base class

Definition at line 96 of file LArBlobMergeAlg.py.

◆ iovSince

python.LArBlobMergeAlg.LArBlobMergeAlg.iovSince

Definition at line 143 of file LArBlobMergeAlg.py.

◆ iovUntil

python.LArBlobMergeAlg.LArBlobMergeAlg.iovUntil

Definition at line 144 of file LArBlobMergeAlg.py.

◆ issc

python.LArBlobMergeAlg.LArBlobMergeAlg.issc

Definition at line 101 of file LArBlobMergeAlg.py.

◆ larCabling

python.LArBlobMergeAlg.LArBlobMergeAlg.larCabling

Definition at line 157 of file LArBlobMergeAlg.py.

◆ m_detStore

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

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

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

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_self

PyObject* PyAthena::Alg::m_self
protectedinherited

Pointer to self (from the python world)

Definition at line 96 of file PyAthenaAlg.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.

◆ nEvts

python.LArBlobMergeAlg.LArBlobMergeAlg.nEvts

Definition at line 105 of file LArBlobMergeAlg.py.

◆ noid

python.LArBlobMergeAlg.LArBlobMergeAlg.noid

Definition at line 139 of file LArBlobMergeAlg.py.

◆ onlineID

python.LArBlobMergeAlg.LArBlobMergeAlg.onlineID

Definition at line 131 of file LArBlobMergeAlg.py.

◆ outdb

python.LArBlobMergeAlg.LArBlobMergeAlg.outdb

Definition at line 98 of file LArBlobMergeAlg.py.

◆ patchChan

python.LArBlobMergeAlg.LArBlobMergeAlg.patchChan

Definition at line 104 of file LArBlobMergeAlg.py.

◆ patchdb

python.LArBlobMergeAlg.LArBlobMergeAlg.patchdb

Definition at line 97 of file LArBlobMergeAlg.py.

◆ patchdet

python.LArBlobMergeAlg.LArBlobMergeAlg.patchdet

Definition at line 102 of file LArBlobMergeAlg.py.

◆ patchFT

python.LArBlobMergeAlg.LArBlobMergeAlg.patchFT

Definition at line 103 of file LArBlobMergeAlg.py.

◆ run

python.LArBlobMergeAlg.LArBlobMergeAlg.run

Definition at line 100 of file LArBlobMergeAlg.py.


The documentation for this class was generated from the following file:
grepfile.info
info
Definition: grepfile.py:38
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
read
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)
Definition: openCoraCool.cxx:569
PyAthena::Alg::m_self
PyObject * m_self
Pointer to self (from the python world)
Definition: PyAthenaAlg.h:96
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
PyAthena::Alg::typeName
virtual const char * typeName() const override
return the std::type_info name of the underlying py-component This is used by concrete implementation...
Definition: PyAthenaAlg.cxx:132
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthCommonDataStore::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
initialize
void initialize()
Definition: run_EoverP.cxx:894
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
python.LArBlobMergeAlg.payload_dict
def payload_dict(payload, verbose=True)
Definition: LArBlobMergeAlg.py:40
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
RootUtils::PyGILStateEnsure
Definition: PyAthenaGILStateEnsure.h:20
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:29
LArG4FSStartPointFilterLegacy.execute
execute
Definition: LArG4FSStartPointFilterLegacy.py:20
python.LArBlobMergeAlg.patchChannel
def patchChannel(idhelper, channel, patchdet, patchFT, patchChan, verbose=False)
Definition: LArBlobMergeAlg.py:54
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
AthCommonDataStore
Definition: AthCommonDataStore.h:52
AthAlgorithm::sysInitialize
virtual StatusCode sysInitialize() override
Override sysInitialize.
Definition: AthAlgorithm.cxx:66
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Athena::typeinfoName
std::string typeinfoName(const std::type_info &ti)
Convert a type_info to a demangled string.
Definition: AthenaKernel/src/ClassName.cxx:23
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:23
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
array
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
AthAlgorithm::m_extendedExtraObjects
DataObjIDColl m_extendedExtraObjects
Definition: AthAlgorithm.h:79
a
TList * a
Definition: liststreamerinfos.cxx:10
h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:623
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
error
Definition: IImpactPoint3dEstimator.h:70
PyObject
_object PyObject
Definition: IPyComponent.h:26
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
python.AtlCoolLib.indirectOpen
def indirectOpen(coolstr, readOnly=True, debug=False)
Definition: AtlCoolLib.py:130
readCCLHist.float
float
Definition: readCCLHist.py:83
fitman.k
k
Definition: fitman.py:528
ServiceHandle
Definition: ClusterMakerTool.h:37