ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Generators
Pythia8B_i
src
CheckCloningFactor.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
Pythia8B_i/CheckCloningFactor.h
"
6
#include "
GeneratorObjects/McEventCollection.h
"
7
#include "GaudiKernel/MsgStream.h"
8
#include "GaudiKernel/DataSvc.h"
9
10
#include <set>
11
12
CheckCloningFactor::CheckCloningFactor
(
const
std::string& name, ISvcLocator* pSvcLocator)
13
:
AthAlgorithm
(name, pSvcLocator)
14
{
15
// Set users' request
16
declareProperty
(
"McEventKey"
,
m_key
=
"GEN_EVENT"
);
17
declareProperty
(
"Tolerance"
,
m_tolerance
=0.000001);
18
m_eventCount
= 0;
19
}
20
21
StatusCode
CheckCloningFactor::initialize
(){
22
23
for
(
int
i=0; i<=2; ++i)
bqKinematics
[i].
clear
();
24
m_eventCount
= 0;
25
26
return
StatusCode::SUCCESS;
27
28
}
29
30
31
StatusCode
CheckCloningFactor::execute
(
const
EventContext&
/*ctx*/
) {
32
33
++
m_eventCount
;
34
35
// Read Data from Transient Store
36
const
McEventCollection
* mcCollptr =
nullptr
;
37
if
(
evtStore
()->retrieve(mcCollptr,
m_key
).isFailure()) {
38
ATH_MSG_ERROR
(
"Could not retrieve McEventCollection"
);
39
return
StatusCode::FAILURE;
40
}
41
42
// Loop over all events in McEventCollection
43
McEventCollection::const_iterator
itr;
44
std::vector<HepMC::ConstGenParticlePtr> bQuarks;
45
for
(itr = mcCollptr->
begin
(); itr!=mcCollptr->
end
(); ++itr) {
46
// Loop over all particles in the event and find the b-quarks
47
const
HepMC::GenEvent
* genEvt = (*itr);
48
for
(
auto
pitr: *genEvt) {
49
int
p_id = pitr->pdg_id();
50
if
( (std::abs(p_id)==5) && (pitr->status() == 62 || pitr->status() == 63) ) {
51
bQuarks.push_back(std::move(pitr));
52
}
53
}
54
}
55
//Unfortunately it is not clear what should happen in the case of absence of b quarks. To prevent bad things we return false.
56
if
( bQuarks.size()==0)
return
StatusCode::FAILURE;
57
// Loop over the b-quarks and find the one with higest pt
58
std::vector<HepMC::ConstGenParticlePtr>::iterator recordedBQuarkIt;
59
double
lastPt(-1.0);
60
for
(
auto
bItr = bQuarks.begin(); bItr!=bQuarks.end(); ++bItr) {
61
double
thisPt=(*bItr)->momentum().perp();
62
if
(thisPt>lastPt) { recordedBQuarkIt=bItr; }
63
}
64
//cppcheck-suppress uninitvar
65
auto
BQMom=(*recordedBQuarkIt)->momentum();
66
double
b_pt = BQMom.perp();
67
double
b_rapid = BQMom.pseudoRapidity();
68
double
b_phi = BQMom.phi();
69
70
unsigned
int
nAccumulatedEvents =
bqKinematics
[0].size();
71
bool
isUnique(
true
);
72
for
(
unsigned
int
i=0; i<nAccumulatedEvents; ++i) {
73
double
pt = (
bqKinematics
[0])[i];
74
double
rap = (
bqKinematics
[1])[i];
75
double
phi
= (
bqKinematics
[2])[i];
76
if
((std::abs(pt-b_pt)<
m_tolerance
) &&
77
(std::abs(rap-b_rapid)<
m_tolerance
) &&
78
(std::abs(
phi
-b_phi)<
m_tolerance
) ) isUnique=
false
;
79
if
(!isUnique)
break
;
80
}
81
82
if
(isUnique) {
83
bqKinematics
[0].push_back(b_pt);
84
bqKinematics
[1].push_back(b_rapid);
85
bqKinematics
[2].push_back(b_phi);
86
}
87
88
return
StatusCode::SUCCESS;
89
}
90
91
92
StatusCode
CheckCloningFactor::finalize
() {
93
94
int
uniqueEvents =
bqKinematics
[0].size();
95
ATH_MSG_INFO
(
"Total number of accepted events = "
<<
m_eventCount
);
96
ATH_MSG_INFO
(
"Total number of unique events = "
<< uniqueEvents);
97
ATH_MSG_INFO
(
"Ratio = "
<< (
double
)
m_eventCount
/ (
double
)uniqueEvents);
98
99
return
StatusCode::SUCCESS;
100
}
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
CheckCloningFactor.h
McEventCollection.h
clear
void clear()
Empty the pool.
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
CheckCloningFactor::m_tolerance
double m_tolerance
Definition
CheckCloningFactor.h:19
CheckCloningFactor::initialize
StatusCode initialize()
Definition
CheckCloningFactor.cxx:21
CheckCloningFactor::m_key
std::string m_key
Definition
CheckCloningFactor.h:18
CheckCloningFactor::bqKinematics
std::vector< double > bqKinematics[3]
Definition
CheckCloningFactor.h:21
CheckCloningFactor::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
CheckCloningFactor.cxx:31
CheckCloningFactor::m_eventCount
int m_eventCount
Definition
CheckCloningFactor.h:20
CheckCloningFactor::finalize
StatusCode finalize()
Definition
CheckCloningFactor.cxx:92
CheckCloningFactor::CheckCloningFactor
CheckCloningFactor(const std::string &name, ISvcLocator *pSvcLocator)
Definition
CheckCloningFactor.cxx:12
DataVector< HepMC::GenEvent >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:838
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
Definition
McEventCollection.h:31
HepMC::GenEvent
HepMC3::GenEvent GenEvent
Definition
GenEvent.h:39
Generated on
for ATLAS Offline Software by
1.17.0