ATLAS Offline Software
Loading...
Searching...
No Matches
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
7#include "GaudiKernel/MsgStream.h"
8#include "GaudiKernel/DataSvc.h"
9
10#include <set>
11
12CheckCloningFactor::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
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
32
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
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
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}
Scalar phi() const
phi method
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::vector< double > bqKinematics[3]
CheckCloningFactor(const std::string &name, ISvcLocator *pSvcLocator)
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...