ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
AANTEventSelector Class Reference

#include <AANTEventSelector.h>

Inheritance diagram for AANTEventSelector:
Collaboration diagram for AANTEventSelector:

Public Member Functions

 AANTEventSelector (const std::string &name, ISvcLocator *svcloc)
 
 ~AANTEventSelector ()
 
virtual StatusCode initialize ()
 
virtual StatusCode createContext (Context *&it) const
 
virtual StatusCode next (Context &it) const
 
virtual StatusCode next (Context &it, int jump) const
 
virtual StatusCode previous (Context &it) const
 
virtual StatusCode previous (Context &it, int jump) const
 
virtual StatusCode last (Context &it) const
 
virtual StatusCode rewind (Context &it) const
 
virtual StatusCode createAddress (const Context &it, IOpaqueAddress *&iop) const
 
virtual StatusCode releaseContext (Context *&it) const
 
virtual StatusCode resetCriteria (const std::string &criteria, Context &context) const
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Private Attributes

StoreGateSvcm_storeGate
 
StringArrayProperty m_inputCollectionsProp
 
int m_skipEvents
 
long m_numEvents
 
long m_totalNEvents
 
std::string m_strConverter
 
std::string m_strSelection
 
TChain * m_tree
 
Long64_t m_runNumber
 
Long64_t m_eventNumber
 
PyObjectm_convFunc
 
PyObjectm_selectionFunc
 

Detailed Description

Definition at line 34 of file AANTEventSelector.h.

Constructor & Destructor Documentation

◆ AANTEventSelector()

AANTEventSelector::AANTEventSelector ( const std::string &  name,
ISvcLocator *  svcloc 
)

Definition at line 30 of file AANTEventSelector.cxx.

31  : AthService(name, svcloc),
32  m_storeGate(0),
34  m_tree(0),
35  m_runNumber(0),
36  m_eventNumber(0),
38 {
39  declareProperty("InputCollections", m_inputCollectionsProp);
40  declareProperty("SkipEvents", m_skipEvents = 0);
41  declareProperty("Converter", m_strConverter = "");
42  declareProperty("Selection", m_strSelection = "");
43 }

◆ ~AANTEventSelector()

AANTEventSelector::~AANTEventSelector ( )

Definition at line 47 of file AANTEventSelector.cxx.

48 {
49  if (m_tree)
50  delete m_tree;
51 }

Member Function Documentation

◆ createAddress()

StatusCode AANTEventSelector::createAddress ( const Context &  it,
IOpaqueAddress *&  iop 
) const
virtual

Definition at line 259 of file AANTEventSelector.cxx.

261 {
262  return StatusCode::SUCCESS;
263 }

◆ createContext()

StatusCode AANTEventSelector::createContext ( IEvtSelector::Context *&  it) const
virtual

Definition at line 141 of file AANTEventSelector.cxx.

142 {
143  it = new AANTEventContext(this);
144  return StatusCode::SUCCESS;
145 }

◆ initialize()

StatusCode AANTEventSelector::initialize ( )
virtual

Definition at line 55 of file AANTEventSelector.cxx.

56 {
57  // Initialize the Service base class.
59 
60  // Create a message stream.
61  MsgStream log(msgSvc(), name());
62 
63  log << MSG::DEBUG << "initialize()" << endmsg;
64 
65  if (sc.isFailure())
66  {
67  log << MSG::ERROR << "Unable to initialize Service base class" << endmsg;
68  return sc;
69  }
70 
71  sc = service("StoreGateSvc", m_storeGate);
72  if (sc.isFailure())
73  {
74  log << MSG::ERROR << "Unable to retrieve pointer to StoreGateSvc" << endmsg;
75  return sc;
76  }
77 
78 
79  // parse jobO
80  if (m_inputCollectionsProp.value().size() == 0)
81  {
82  log << MSG::ERROR << "Use the property:"
83  << " EventSelector.InputCollections = [ \"<collectionName>\" ] (list of collections)"
84  << endmsg;
85  return StatusCode::FAILURE;
86  }
87  // create TChain
88  m_tree = new TChain("CollectionTree");
89  std::vector<std::string> inputColl = m_inputCollectionsProp.value();
90  std::vector<std::string>::iterator it = inputColl.begin();
91  std::vector<std::string>::iterator itE = inputColl.end();
92  for (; it!=itE; ++it)
93  {
94  log << MSG::DEBUG << "Add : " << *it << endmsg;
95  m_tree->Add(it->c_str());
96  }
97 
98  // get total number of events
99  m_totalNEvents = m_tree->GetEntries();
100 
101  log << MSG::DEBUG << "Total Events : " << m_totalNEvents << endmsg;
102 
103  // RunNumber and EventNumber
104  m_tree->SetBranchAddress("EventNumber",&m_eventNumber);
105  m_tree->SetBranchAddress("RunNumber", &m_runNumber);
106 
107  // set TTree to AANTTreeGate
109 
110  // selection criteria
111  log << MSG::DEBUG << "Load Sel: " << m_strSelection << " from __main__" << endmsg;
112  char smain[] = "__main__";
113 #if PY_MAJOR_VERSION < 3
114  m_selectionFunc = PyObject_GetAttr(PyImport_AddModule(smain),PyString_FromString(m_strSelection.c_str()));
115 #else
116  m_selectionFunc = PyObject_GetAttr(PyImport_AddModule(smain),PyUnicode_FromString(m_strSelection.c_str()));
117 #endif
118  if (m_selectionFunc == NULL)
119  {
120  log << MSG::ERROR << "Could not load sel : " << m_strSelection << endmsg;
121  return StatusCode::FAILURE;
122  }
123 
124  log << MSG::DEBUG << "Load Cnv: " << m_strConverter << " from __main__" << endmsg;
125 #if PY_MAJOR_VERSION < 3
126  m_convFunc = PyObject_GetAttr(PyImport_AddModule(smain),PyString_FromString(m_strConverter.c_str()));
127 #else
128  m_convFunc = PyObject_GetAttr(PyImport_AddModule(smain),PyUnicode_FromString(m_strConverter.c_str()));
129 #endif
130  if (m_convFunc == NULL)
131  {
132  log << MSG::ERROR << "Could not load conv : " << m_strConverter << endmsg;
133  return StatusCode::FAILURE;
134  }
135 
136  return StatusCode::SUCCESS;
137 }

◆ last()

StatusCode AANTEventSelector::last ( IEvtSelector::Context &  it) const
virtual

Definition at line 232 of file AANTEventSelector.cxx.

233 {
234  MsgStream log(msgSvc(), name());
235  log << MSG::ERROR << "AANTEventSelector::last() not implemented" << endmsg;
236  return StatusCode::FAILURE;
237 }

◆ msg() [1/2]

MsgStream& AthCommonMsg< Service >::msg
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

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

◆ msg() [2/2]

MsgStream& AthCommonMsg< Service >::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< Service >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

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

◆ next() [1/2]

StatusCode AANTEventSelector::next ( IEvtSelector::Context &  it) const
virtual

Definition at line 149 of file AANTEventSelector.cxx.

150 {
151  return this->next(it,0);
152 }

◆ next() [2/2]

StatusCode AANTEventSelector::next ( IEvtSelector::Context &  it,
int  jump 
) const
virtual

Definition at line 156 of file AANTEventSelector.cxx.

157 {
158  MsgStream log(msgSvc(), name());
159  log << MSG::DEBUG << "next(" << jump << ") : iEvt " << m_numEvents << endmsg;
160 
161  // get EventContext
162  AANTEventContext* ct = dynamic_cast<AANTEventContext*>(&it);
163  if (ct == 0)
164  {
165  log << MSG::ERROR << "Could not dcast to AANTEventContext" << endmsg;
166  return StatusCode::FAILURE;
167  }
168  // jump
169  if (((m_numEvents + jump) >= 0) and ((m_numEvents + jump) < m_totalNEvents))
170  {
171  // move pointer
172  m_numEvents += jump;
173  // get entry
174  m_tree->GetEntry(m_numEvents);
175  // increment pointer
176  ++m_numEvents;
177  // convert C++ obj to Python obj
179  PyObject *pyObj = PyObject_CallObject(m_convFunc,NULL);
180  // execute Python code fragment
181  PyObject *tup = Py_BuildValue((char*)"(O)",pyObj);
182  PyObject *ret = PyObject_CallObject(m_selectionFunc,tup);
183  // decrement reference counters
184  Py_DECREF(pyObj);
185  Py_DECREF(tup);
186  if (ret != NULL and PyObject_IsTrue(ret))
187  {
188  // decrement reference counters
189  Py_DECREF(ret);
190  // EventInfo
191  EventType *peT = new EventType();
192  EventInfo *evtInfo = new EventInfo( new EventID(m_runNumber,m_eventNumber,0),peT);
193  StatusCode sc = m_storeGate->record(evtInfo, "AANTEventInfo");
194  if (sc.isFailure())
195  {
196  log << MSG::ERROR << "Could not record AANTEventInfo" << endmsg;
197  return sc;
198  }
199  // return
200  return StatusCode::SUCCESS;
201  }
202  else
203  {
204  // decrement reference counters
205  Py_XDECREF(ret);
206  // next
207  return this->next(it,0);
208  }
209  }
210 
211  // EOF
212  //ct = new AANTEventContext(0);
213  return StatusCode::FAILURE;
214 }

◆ previous() [1/2]

StatusCode AANTEventSelector::previous ( IEvtSelector::Context &  it) const
virtual

Definition at line 218 of file AANTEventSelector.cxx.

219 {
220  return this->next(it,-1);
221 }

◆ previous() [2/2]

StatusCode AANTEventSelector::previous ( IEvtSelector::Context &  it,
int  jump 
) const
virtual

Definition at line 225 of file AANTEventSelector.cxx.

226 {
227  return this->next(it,-jump);
228 }

◆ queryInterface()

StatusCode AANTEventSelector::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
)
virtual

Definition at line 276 of file AANTEventSelector.cxx.

277 {
278  if (riid == IEvtSelector::interfaceID())
279  {
280  *ppvInterface = (IEvtSelector*)this;
281  }
282  else if (riid == IProperty::interfaceID())
283  {
284  *ppvInterface = (IProperty*)this;
285  }
286  else
287  {
288  return Service::queryInterface(riid, ppvInterface);
289  }
290 
291  addRef();
292 
293  return StatusCode::SUCCESS;
294 }

◆ releaseContext()

StatusCode AANTEventSelector::releaseContext ( IEvtSelector::Context *&  it) const
virtual

Definition at line 267 of file AANTEventSelector.cxx.

268 {
269  MsgStream log(msgSvc(), name());
270  log << MSG::ERROR << "AANTEventSelector::releaseContext() not implemented" << endmsg;
271  return StatusCode::FAILURE;
272 }

◆ resetCriteria()

StatusCode AANTEventSelector::resetCriteria ( const std::string &  criteria,
IEvtSelector::Context &  context 
) const
virtual

Definition at line 241 of file AANTEventSelector.cxx.

242 {
243  MsgStream log(msgSvc(), name());
244  log << MSG::ERROR << "AANTEventSelector::resetCriteria() not implemented" << endmsg;
245  return StatusCode::FAILURE;
246 }

◆ rewind()

StatusCode AANTEventSelector::rewind ( IEvtSelector::Context &  it) const
virtual

Definition at line 250 of file AANTEventSelector.cxx.

251 {
252  MsgStream log(msgSvc(), name());
253  log << MSG::ERROR << "AANTEventSelector::rewind() not implemented" << endmsg;
254  return StatusCode::FAILURE;
255 }

Member Data Documentation

◆ m_convFunc

PyObject* AANTEventSelector::m_convFunc
private

Definition at line 95 of file AANTEventSelector.h.

◆ m_eventNumber

Long64_t AANTEventSelector::m_eventNumber
private

Definition at line 92 of file AANTEventSelector.h.

◆ m_inputCollectionsProp

StringArrayProperty AANTEventSelector::m_inputCollectionsProp
private

Definition at line 71 of file AANTEventSelector.h.

◆ m_numEvents

long AANTEventSelector::m_numEvents
mutableprivate

Definition at line 77 of file AANTEventSelector.h.

◆ m_runNumber

Long64_t AANTEventSelector::m_runNumber
private

Definition at line 91 of file AANTEventSelector.h.

◆ m_selectionFunc

PyObject* AANTEventSelector::m_selectionFunc
private

Definition at line 96 of file AANTEventSelector.h.

◆ m_skipEvents

int AANTEventSelector::m_skipEvents
private

Definition at line 74 of file AANTEventSelector.h.

◆ m_storeGate

StoreGateSvc* AANTEventSelector::m_storeGate
private

Definition at line 68 of file AANTEventSelector.h.

◆ m_strConverter

std::string AANTEventSelector::m_strConverter
private

Definition at line 83 of file AANTEventSelector.h.

◆ m_strSelection

std::string AANTEventSelector::m_strSelection
private

Definition at line 86 of file AANTEventSelector.h.

◆ m_totalNEvents

long AANTEventSelector::m_totalNEvents
private

Definition at line 80 of file AANTEventSelector.h.

◆ m_tree

TChain* AANTEventSelector::m_tree
private

Definition at line 89 of file AANTEventSelector.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
AthService::AthService
AthService()
StoreGateSvc::record
StatusCode record(T *p2BRegistered, const TKEY &key)
Record an object with a key.
AANTEventSelector::m_tree
TChain * m_tree
Definition: AANTEventSelector.h:89
AANTEventContext
Definition: AANTEventContext.h:13
AANTEventSelector::m_convFunc
PyObject * m_convFunc
Definition: AANTEventSelector.h:95
AANTTreeGate::setTree
static void setTree(TChain *chain)
Definition: AANTEventSelector.h:103
AANTEventSelector::m_strConverter
std::string m_strConverter
Definition: AANTEventSelector.h:83
EventType
This class represents the "type of event" where the type is given by one or more "characteristics".
Definition: EventType.h:92
initialize
void initialize()
Definition: run_EoverP.cxx:894
EventInfo
EventInfo
Definition: EventTPCnv.cxx:47
skel.it
it
Definition: skel.GENtoEVGEN.py:423
AANTEventSelector::m_storeGate
StoreGateSvc * m_storeGate
Definition: AANTEventSelector.h:68
AANTEventSelector::m_skipEvents
int m_skipEvents
Definition: AANTEventSelector.h:74
AANTEventSelector::m_inputCollectionsProp
StringArrayProperty m_inputCollectionsProp
Definition: AANTEventSelector.h:71
TruthTest.itE
itE
Definition: TruthTest.py:25
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AANTEventSelector::m_runNumber
Long64_t m_runNumber
Definition: AANTEventSelector.h:91
RootUtils::PyGILStateEnsure
Definition: PyAthenaGILStateEnsure.h:20
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
ret
T ret(T t)
Definition: rootspy.cxx:260
AANTEventSelector::m_selectionFunc
PyObject * m_selectionFunc
Definition: AANTEventSelector.h:96
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
AANTEventSelector::m_numEvents
long m_numEvents
Definition: AANTEventSelector.h:77
AANTEventSelector::m_strSelection
std::string m_strSelection
Definition: AANTEventSelector.h:86
AANTEventSelector::m_eventNumber
Long64_t m_eventNumber
Definition: AANTEventSelector.h:92
calibdata.ct
ct
Definition: calibdata.py:418
AANTEventSelector::m_totalNEvents
long m_totalNEvents
Definition: AANTEventSelector.h:80
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
EventInfo
This class provides general information about an event. Event information is provided by the accessor...
Definition: EventInfo/EventInfo/EventInfo.h:42
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
EventID
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventID.h:35
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
AANTEventSelector::next
virtual StatusCode next(Context &it) const
Definition: AANTEventSelector.cxx:149
PyObject
_object PyObject
Definition: IPyComponent.h:26