ATLAS Offline Software
Loading...
Searching...
No Matches
TestAthenaConstraintFit.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5// EDM include(s):
6
7
12
13// local include
15
16TestAthenaConstraintFit::TestAthenaConstraintFit( const std::string& name, ISvcLocator* svcLoc )
17 : AthAlgorithm( name, svcLoc ),
18 m_constraintFit("ZMassConstraint::ConstraintFit/ConstraintFit", this)
19{
20 declareProperty( "ElectronContName", m_electronContName = "ElectronCollection" );
21 declareProperty( "PrimaryVertexContName", m_vertexContName = "PrimaryVertices" );
22 declareProperty( "ConstraintFit", m_constraintFit);
23}
24
25
27{
28 // Greet the user:
29 ATH_MSG_INFO( "Initialising..." );
30
31 // Retrieve the tools:
32 ATH_CHECK(m_constraintFit.retrieve());
33
34 return StatusCode::SUCCESS;
35}
36
37
39{
40 const xAOD::EventInfo* ei = 0;
41 ATH_CHECK( evtStore()->retrieve(ei) );
42
43 const xAOD::ElectronContainer* electrons;
44 ATH_CHECK( evtStore()->retrieve(electrons, m_electronContName) );
45
46
47 // get primary vertex
48 const xAOD::VertexContainer* vtxs = 0;
49 ATH_CHECK( evtStore()->retrieve( vtxs, m_vertexContName ) );
50
51 const xAOD::Vertex* primaryVtx = 0;
52 for ( auto vtx : *vtxs) if (vtx->vertexType() == xAOD::VxType::PriVtx) primaryVtx = vtx;
53
54
55 std::vector<const xAOD::Electron*> els;
56 els.reserve(electrons->size());
57
58 ATH_MSG_INFO("run,evt,nels " << ei->runNumber() << "," << ei->eventNumber() << "," << electrons->size());
59
60 for ( auto el : *electrons ) {
61
62 ATH_MSG_INFO("elpt/eta/phi " << el->pt() << "," << el->eta() << "," << el->phi());
63
64 const xAOD::TrackParticle* el_tp = el->trackParticle();
65
66 if (fabs(el->caloCluster()->eta()) >= 2.47) continue;
67 if (el->pt() <= 7000.) continue;
68
69 float d0 = el_tp->d0(); // no smearing for run 2 yet...
70 if (primaryVtx) d0 = (el_tp->z0() - primaryVtx->z() + el_tp->vz());
71
72 if (fabs(d0) > 10.) continue;
73
74 els.push_back(el);
75 }
76
77 ATH_MSG_INFO("nels passed cuts " << els.size());
78
79
80 if (els.size() > 1) {
81 // fit only the first two electrons and only if they have opposite charge
82 const xAOD::Electron* el0 = els[0];
83 const xAOD::Electron* el1 = els[1];
84
88 if (el0->charge() != el1->charge()) {
89 float res = el0->pt() * 0.1 / sqrt(el0->e());
90 m_constraintFit->addParticle(*el0, res, input);
91 res = el1->pt() * 0.1 / sqrt(el1->e());
92 m_constraintFit->addParticle(*el1, res, input);
93 if (m_constraintFit->doMassFit(input, result).isFailure()) {
94 ATH_MSG_DEBUG("execute: Unable to do mass contrained fit");
95 }
96 ATH_MSG_INFO("el0 pt,eta,phi " << el0->pt()/1000. << "/" << el0->eta() << "/" << el0->phi());
97 ATH_MSG_INFO("el1 pt,eta,phi " << el1->pt()/1000. << "/" << el1->eta() << "/" << el1->phi());
98 TLorentzVector fit4vec;
99 result.getCompositeFourVector(fit4vec);
100
101 ATH_MSG_INFO("mass, error " << fit4vec.M()/1000. << "/"
102 << m_constraintFit->getMassError(result, emptyInput)/1000.);
103
104 }
105 else ATH_MSG_INFO("not opposite charge ");
106
107 }
108
109 return StatusCode::SUCCESS;
110}
111
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
std::pair< std::vector< unsigned int >, bool > res
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
virtual StatusCode execute()
Function executing the algorithm.
TestAthenaConstraintFit(const std::string &name, ISvcLocator *svcLoc)
Regular Algorithm constructor.
ToolHandle< ZMassConstraint::IConstraintFit > m_constraintFit
virtual StatusCode initialize()
Function initialising the algorithm.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition Egamma_v1.cxx:66
virtual double e() const override
The total energy of the particle.
Definition Egamma_v1.cxx:86
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition Egamma_v1.cxx:71
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
Definition Egamma_v1.cxx:76
float charge() const
Obtain the charge of the object.
uint32_t runNumber() const
The current event's run number.
uint64_t eventNumber() const
The current event's event number.
float z0() const
Returns the parameter.
float vz() const
The z origin for the parameters.
float d0() const
Returns the parameter.
float z() const
Returns the z position.
@ PriVtx
Primary vertex.
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
EventInfo_v1 EventInfo
Definition of the latest event info version.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
Electron_v1 Electron
Definition of the current "egamma version".