ATLAS Offline Software
Loading...
Searching...
No Matches
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
virtual StatusCode prepareEvent (const EventContext &ctx, unsigned int nInputEvents) override final
 called before the subevts loop.
virtual StatusCode mergeEvent (const EventContext &ctx) override final
 called at the end of the subevts loop.
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
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

Private Member Functions

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

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
virtual bool filterPassed () const override
 dummy implementation of passing filter
virtual void resetFilter () override
 dummy implementation of filter reset
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 :
12 PileUpToolBase(type, name, parent),
13 m_pMergeSvc("PileUpMergeSvc", name),
14 m_firstSubEvent(true)
15{
16 declareProperty("SimHitContainerNames", m_SimHitContainerNamesProp);
17}
ServiceHandle< PileUpMergeSvc > m_pMergeSvc
PileUpToolBase(const std::string &type, const std::string &name, const IInterface *parent)

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}
#define ATH_MSG_VERBOSE(x)
std::vector< std::string > m_SimHitContainerNames
std::vector< GenericMuonSimHitCollection * > m_outputContainers

◆ 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}
#define ATH_MSG_ERROR(x)

◆ 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}
#define ATH_MSG_DEBUG(x)

◆ processAllSubEvents()

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}
#define ATH_MSG_FATAL(x)
AtlasHitsVector< GenericMuonSimHit > GenericMuonSimHitCollection
std::vector< std::pair< double, SimHitHandleBase * > > SimHitList
virtual void processGenericMuonSimHitColl(const GenericMuonSimHitCollection *inputCollection, GenericMuonSimHitCollection *outputCollection, const double &timeOfBCID)
share code between two approaches
bool first
Definition DeMoScan.py:534
std::list< value_t > type
type of the collection of timed data object

◆ 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) {
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}
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition IPileUpTool.h:22
static Double_t sc
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ 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}
const_iterator begin() const
const_iterator end() const

◆ 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 }
Gaudi::Property< int > m_firstXing
Gaudi::Property< int > m_lastXing

Member Data Documentation

◆ m_filterPassed

bool PileUpToolBase::m_filterPassed {true}
protectedinherited

Definition at line 60 of file PileUpToolBase.h.

60{true};

◆ 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.

54 {this, "FirstXing", -999,
55 "First bunch-crossing in which det is live"};

◆ 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.

56 {this, "LastXing", 999,
57 "Last bunch-crossing in which det is live"};

◆ 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.

58 {this, "VetoPileUpTruthLinks", true,
59 "Ignore links to suppressed pile-up truth"};

The documentation for this class was generated from the following files: