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

an algorithm to merge MC track record collTool in the overlay store More...

#include <MergeGenericMuonSimHitCollTool.h>

Inheritance diagram for MergeGenericMuonSimHitCollTool:
Collaboration diagram for MergeGenericMuonSimHitCollTool:

Public Member Functions

 MergeGenericMuonSimHitCollTool (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual StatusCode initialize () override final
 called before the event loop More...
 
virtual StatusCode prepareEvent (const EventContext &ctx, unsigned int nInputEvents) override final
 called before the subevts loop. More...
 
virtual StatusCode mergeEvent (const EventContext &ctx) override final
 called at the end of the subevts loop. More...
 
virtual StatusCode processBunchXing (int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents) override final
 called for each active bunch-crossing to process current SubEvents bunchXing is in ns More...
 
virtual StatusCode processAllSubEvents (const EventContext &ctx) override final
 return false if not interested in certain xing times (in ns) implemented by default in PileUpToolBase as FirstXing<=bunchXing<=LastXing More...
 

Private Member Functions

virtual void processGenericMuonSimHitColl (const GenericMuonSimHitCollection *inputCollection, GenericMuonSimHitCollection *outputCollection, const double &timeOfBCID)
 share code between two approaches More...
 

Private Attributes

ServiceHandle< PileUpMergeSvcm_pMergeSvc
 
bool m_firstSubEvent
 
std::vector< GenericMuonSimHitCollection * > m_outputContainers
 
StringArrayProperty m_SimHitContainerNamesProp
 
std::vector< std::string > m_SimHitContainerNames
 

structors and AlgTool implementation

virtual bool toProcess (int bunchXing) const override
 the method this base class helps implementing More...
 
virtual StatusCode processAllSubEvents (const EventContext &ctx)=0
 dummy implementation to allow compilation while all Digitization packages are migrated to use this new interface. More...
 
virtual bool filterPassed () const override
 dummy implementation of passing filter More...
 
virtual void resetFilter () override
 dummy implementation of filter reset More...
 
Gaudi::Property< int > m_firstXing
 
Gaudi::Property< int > m_lastXing
 
Gaudi::Property< int > m_vetoPileUpTruthLinks
 
bool m_filterPassed {true}
 

Detailed Description

an algorithm to merge MC track record collTool in the overlay store

$Id:

Author
DCost.nosp@m.anzo.nosp@m.@bnl..nosp@m.gov (from Paolo's MergeMcEventCollTool)

Definition at line 25 of file MergeGenericMuonSimHitCollTool.h.

Constructor & Destructor Documentation

◆ MergeGenericMuonSimHitCollTool()

MergeGenericMuonSimHitCollTool::MergeGenericMuonSimHitCollTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 9 of file MergeGenericMuonSimHitCollTool.cxx.

11  :
13  m_pMergeSvc("PileUpMergeSvc", name),
14  m_firstSubEvent(true)
15 {
16  declareProperty("SimHitContainerNames", m_SimHitContainerNamesProp);
17 }

Member Function Documentation

◆ filterPassed()

virtual bool PileUpToolBase::filterPassed ( ) const
inlineoverridevirtualinherited

dummy implementation of passing filter

Definition at line 49 of file PileUpToolBase.h.

49 { return m_filterPassed; }

◆ initialize()

StatusCode MergeGenericMuonSimHitCollTool::initialize ( )
finaloverridevirtual

called before the event loop

Reimplemented from PileUpToolBase.

Definition at line 19 of file MergeGenericMuonSimHitCollTool.cxx.

19  {
20  ATH_MSG_VERBOSE ( "initialize()" );
21  // list of CaloCalibrationHit containers
22  if (m_SimHitContainerNamesProp.value().empty()) {
23  m_SimHitContainerNames.reserve(2);
24  m_SimHitContainerNames.push_back("MM_Hits");
25  m_SimHitContainerNames.push_back("sTGC_Hits");
26  }
27  else {
29  }
31  return StatusCode::SUCCESS;
32 }

◆ mergeEvent()

StatusCode MergeGenericMuonSimHitCollTool::mergeEvent ( const EventContext &  ctx)
finaloverridevirtual

called at the end of the subevts loop.

Not (necessarily) able to access SubEvents

Definition at line 77 of file MergeGenericMuonSimHitCollTool.cxx.

77  {
78  for (unsigned int iHitContainer=0;iHitContainer<m_SimHitContainerNames.size();++iHitContainer) {
79  if ( m_outputContainers[iHitContainer]==0 ) { continue; } //don't bother recording unused containers!
80  if (!(evtStore()->record(m_outputContainers[iHitContainer],m_SimHitContainerNames[iHitContainer]).isSuccess())) {
81  ATH_MSG_ERROR ( " Cannot record new GenericMuonSimHitCollection in overlayed event " );
82  return StatusCode::FAILURE;
83  }
84  } // end of loop over the various types of calo calibration hits
85  return StatusCode::SUCCESS;
86 }

◆ prepareEvent()

StatusCode MergeGenericMuonSimHitCollTool::prepareEvent ( const EventContext &  ctx,
unsigned int  nInputEvents 
)
finaloverridevirtual

called before the subevts loop.

Not (necessarily) able to access SubEvents

Definition at line 34 of file MergeGenericMuonSimHitCollTool.cxx.

34  {
35  ATH_MSG_DEBUG ( "Calling prepareEvent()" );
36  ATH_MSG_DEBUG( "prepareEvent: there are " << nInputEvents << " subevents in this event.");
37  m_firstSubEvent = true;
38  //clean up pointers from the last event
39  m_outputContainers.clear();
40  for (unsigned int iHitContainer=0;iHitContainer<m_SimHitContainerNames.size(); ++iHitContainer) {
41  m_outputContainers.push_back(NULL);
42  }
43  return StatusCode::SUCCESS;
44 }

◆ processAllSubEvents() [1/2]

StatusCode MergeGenericMuonSimHitCollTool::processAllSubEvents ( const EventContext &  ctx)
finaloverridevirtual

return false if not interested in certain xing times (in ns) implemented by default in PileUpToolBase as FirstXing<=bunchXing<=LastXing

Merge the GenericMuonSimHitColl

Reimplemented from PileUpToolBase.

Definition at line 88 of file MergeGenericMuonSimHitCollTool.cxx.

89 {
90  ATH_MSG_VERBOSE ( "processAllSubEvents()" );
91  if(!m_pMergeSvc) {
92  if (!(m_pMergeSvc.retrieve()).isSuccess()) {
93  ATH_MSG_FATAL ( "processAllSubEvents: Could not find PileUpMergeSvc" );
94  return StatusCode::FAILURE;
95  }
96  }
97 
98  // loop over containers
99  for (unsigned int iHitContainer=0;iHitContainer<m_SimHitContainerNames.size();iHitContainer++) {
100 
101  ATH_MSG_DEBUG(" Process CalibrationHit container " << m_SimHitContainerNames[iHitContainer]);
103  SimHitList simHitList;
104  if ( (m_pMergeSvc->retrieveSubEvtsData(m_SimHitContainerNames[iHitContainer], simHitList)).isSuccess() ) {
106  if (!simHitList.empty()) {
107  //now merge all collections into one
108  SimHitList::const_iterator simHitColl_iter(simHitList.begin());
109  const SimHitList::const_iterator endOfSimHitColls(simHitList.end());
110  while (simHitColl_iter!=endOfSimHitColls) {
111  const double timeOfBCID(static_cast<double>((simHitColl_iter)->first.time()));
112  this->processGenericMuonSimHitColl(&(*((simHitColl_iter)->second)), m_outputContainers[iHitContainer], timeOfBCID);
113  }
114  }
115  // record new container in overlayed event
116  if (!(evtStore()->record(newContainer,m_SimHitContainerNames[iHitContainer]).isSuccess())) {
117  ATH_MSG_ERROR(" Cannot record new GenericMuonSimHitCollection in overlayed event ");
118  delete newContainer;
119  return StatusCode::FAILURE;
120  }
121  }
122  } // end of loop over the various types of calo calibration hits
123  return StatusCode::SUCCESS;
124 }

◆ processAllSubEvents() [2/2]

virtual StatusCode IPileUpTool::processAllSubEvents
inherited

dummy implementation to allow compilation while all Digitization packages are migrated to use this new interface.

◆ processBunchXing()

StatusCode MergeGenericMuonSimHitCollTool::processBunchXing ( int  bunchXing,
SubEventIterator  bSubEvents,
SubEventIterator  eSubEvents 
)
finaloverridevirtual

called for each active bunch-crossing to process current SubEvents bunchXing is in ns

Reimplemented from PileUpToolBase.

Definition at line 45 of file MergeGenericMuonSimHitCollTool.cxx.

48 {
49  StatusCode sc(StatusCode::SUCCESS);
50  //if this is the first SubEvent for this Event then create the hitContainers;
51  ATH_MSG_VERBOSE ( "processBunchXing()" );
52  SubEventIterator iEvt(bSubEvents);
53  while (iEvt != eSubEvents) {
54  // loop over containers
55  for (unsigned int iHitContainer=0;iHitContainer<m_SimHitContainerNames.size();++iHitContainer) {
56  ATH_MSG_VERBOSE ( " Bunch Crossing: " <<bunchXing << ". Process GenericMuonSimHitCollection " << m_SimHitContainerNames[iHitContainer] );
57  const GenericMuonSimHitCollection* hitCont = nullptr;
58  if (!m_pMergeSvc->retrieveSingleSubEvtData(m_SimHitContainerNames[iHitContainer], hitCont,
59  bunchXing, iEvt).isSuccess()){
60  ATH_MSG_ERROR("GenericMuonSimHitCollection not found for event key " << m_SimHitContainerNames[iHitContainer]);
61  return StatusCode::FAILURE;
62  }
63 
64  //if this is the first SubEvent for this Event then create the hitContainers;
65  if(m_firstSubEvent) {
66  m_outputContainers[iHitContainer] = new GenericMuonSimHitCollection(m_SimHitContainerNames[iHitContainer]);
67  }
68  const double timeOfBCID(static_cast<double>(iEvt->time()));
69  this->processGenericMuonSimHitColl(hitCont, m_outputContainers[iHitContainer], timeOfBCID);
70  }
71  ++iEvt;
72  m_firstSubEvent=false;
73  }
74  return sc;
75 }

◆ processGenericMuonSimHitColl()

void MergeGenericMuonSimHitCollTool::processGenericMuonSimHitColl ( const GenericMuonSimHitCollection inputCollection,
GenericMuonSimHitCollection outputCollection,
const double &  timeOfBCID 
)
privatevirtual

share code between two approaches

Definition at line 126 of file MergeGenericMuonSimHitCollTool.cxx.

127 {
128  for (GenericMuonSimHitCollection::const_iterator simhitIter = inputCollection->begin(); simhitIter != inputCollection->end(); ++simhitIter) {
129  const int idHit = simhitIter->GenericId();
130  outputCollection->Emplace(idHit, simhitIter->globalTime()+timeOfBCID, simhitIter->globalpreTime()+timeOfBCID, simhitIter->globalPosition(), simhitIter->localPosition(), simhitIter->globalPrePosition(),simhitIter->localPrePosition(), simhitIter->particleEncoding(),simhitIter->kineticEnergy(), simhitIter->globalDirection(),simhitIter->depositEnergy(), simhitIter->StepLength(),simhitIter->truthBarcode() );
131  }
132  return;
133 }

◆ resetFilter()

virtual void PileUpToolBase::resetFilter ( )
inlineoverridevirtualinherited

dummy implementation of filter reset

Reimplemented in MergeTruthJetsTool.

Definition at line 51 of file PileUpToolBase.h.

51 { m_filterPassed=true; }

◆ toProcess()

virtual bool PileUpToolBase::toProcess ( int  bunchXing) const
inlineoverridevirtualinherited

the method this base class helps implementing

Reimplemented in MergeHijingParsTool, and MergeTrackRecordCollTool.

Definition at line 32 of file PileUpToolBase.h.

32  {
33  //closed interval [m_firstXing,m_lastXing]
34  return !((m_firstXing > bunchXing) || (bunchXing > m_lastXing));
35  }

Member Data Documentation

◆ m_filterPassed

bool PileUpToolBase::m_filterPassed {true}
protectedinherited

Definition at line 60 of file PileUpToolBase.h.

◆ m_firstSubEvent

bool MergeGenericMuonSimHitCollTool::m_firstSubEvent
private

Definition at line 52 of file MergeGenericMuonSimHitCollTool.h.

◆ m_firstXing

Gaudi::Property<int> PileUpToolBase::m_firstXing
protectedinherited
Initial value:
{this, "FirstXing", -999,
"First bunch-crossing in which det is live"}

Definition at line 54 of file PileUpToolBase.h.

◆ m_lastXing

Gaudi::Property<int> PileUpToolBase::m_lastXing
protectedinherited
Initial value:
{this, "LastXing", 999,
"Last bunch-crossing in which det is live"}

Definition at line 56 of file PileUpToolBase.h.

◆ m_outputContainers

std::vector<GenericMuonSimHitCollection*> MergeGenericMuonSimHitCollTool::m_outputContainers
private

Definition at line 53 of file MergeGenericMuonSimHitCollTool.h.

◆ m_pMergeSvc

ServiceHandle<PileUpMergeSvc> MergeGenericMuonSimHitCollTool::m_pMergeSvc
private

Definition at line 51 of file MergeGenericMuonSimHitCollTool.h.

◆ m_SimHitContainerNames

std::vector<std::string> MergeGenericMuonSimHitCollTool::m_SimHitContainerNames
private

Definition at line 55 of file MergeGenericMuonSimHitCollTool.h.

◆ m_SimHitContainerNamesProp

StringArrayProperty MergeGenericMuonSimHitCollTool::m_SimHitContainerNamesProp
private

Definition at line 54 of file MergeGenericMuonSimHitCollTool.h.

◆ m_vetoPileUpTruthLinks

Gaudi::Property<int> PileUpToolBase::m_vetoPileUpTruthLinks
protectedinherited
Initial value:
{this, "VetoPileUpTruthLinks", true,
"Ignore links to suppressed pile-up truth"}

Definition at line 58 of file PileUpToolBase.h.


The documentation for this class was generated from the following files:
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
PileUpToolBase::m_filterPassed
bool m_filterPassed
Definition: PileUpToolBase.h:60
MergeGenericMuonSimHitCollTool::m_outputContainers
std::vector< GenericMuonSimHitCollection * > m_outputContainers
Definition: MergeGenericMuonSimHitCollTool.h:53
MergeGenericMuonSimHitCollTool::m_SimHitContainerNamesProp
StringArrayProperty m_SimHitContainerNamesProp
Definition: MergeGenericMuonSimHitCollTool.h:54
GenericMuonSimHitCollection
AtlasHitsVector< GenericMuonSimHit > GenericMuonSimHitCollection
Definition: GenericMuonSimHitCollection.h:15
AtlasHitsVector
Definition: AtlasHitsVector.h:33
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
PileUpToolBase::m_lastXing
Gaudi::Property< int > m_lastXing
Definition: PileUpToolBase.h:56
SimHitList
std::vector< std::pair< double, SimHitHandleBase * > > SimHitList
Definition: SimHitHandleBase.h:76
AtlasHitsVector::begin
const_iterator begin() const
Definition: AtlasHitsVector.h:131
AtlasHitsVector::const_iterator
CONT::const_iterator const_iterator
Definition: AtlasHitsVector.h:43
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
PileUpMergeSvc::TimedList::type
std::list< value_t > type
type of the collection of timed data object
Definition: PileUpMergeSvc.h:75
MergeGenericMuonSimHitCollTool::processGenericMuonSimHitColl
virtual void processGenericMuonSimHitColl(const GenericMuonSimHitCollection *inputCollection, GenericMuonSimHitCollection *outputCollection, const double &timeOfBCID)
share code between two approaches
Definition: MergeGenericMuonSimHitCollTool.cxx:126
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
PileUpToolBase::PileUpToolBase
PileUpToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Definition: PileUpToolBase.cxx:7
postInclude.outputCollection
outputCollection
Definition: postInclude.SortInput.py:27
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
AtlasHitsVector::end
const_iterator end() const
Definition: AtlasHitsVector.h:134
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DeMoScan.first
bool first
Definition: DeMoScan.py:536
MergeGenericMuonSimHitCollTool::m_pMergeSvc
ServiceHandle< PileUpMergeSvc > m_pMergeSvc
Definition: MergeGenericMuonSimHitCollTool.h:51
PileUpToolBase::m_firstXing
Gaudi::Property< int > m_firstXing
Definition: PileUpToolBase.h:54
MergeGenericMuonSimHitCollTool::m_SimHitContainerNames
std::vector< std::string > m_SimHitContainerNames
Definition: MergeGenericMuonSimHitCollTool.h:55
SubEventIterator
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition: IPileUpTool.h:22
MergeGenericMuonSimHitCollTool::m_firstSubEvent
bool m_firstSubEvent
Definition: MergeGenericMuonSimHitCollTool.h:52