ATLAS Offline Software
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 
16 TestAthenaConstraintFit::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 
45 
46 
47  // get primary vertex
48  const xAOD::VertexContainer* vtxs = 0;
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 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TestAthenaConstraintFit::initialize
virtual StatusCode initialize()
Function initialising the algorithm.
Definition: TestAthenaConstraintFit.cxx:26
xAOD::Electron_v1::charge
float charge() const
Obtain the charge of the object.
get_generator_info.result
result
Definition: get_generator_info.py:21
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
xAOD::Egamma_v1::e
virtual double e() const override final
The total energy of the particle.
Definition: Egamma_v1.cxx:90
xAOD::TrackParticle_v1::vz
float vz() const
The z origin for the parameters.
ZMassConstraint::ConstraintFitOutput
Definition: ConstraintFitOutput.h:13
xAOD::TrackParticle_v1::z0
float z0() const
Returns the parameter.
ConstraintFit.h
xAOD::TrackParticle_v1::d0
float d0() const
Returns the parameter.
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ElectronContainer.h
TestAthenaConstraintFit.h
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
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:571
ZMassConstraint::ConstraintFitInput
Definition: ConstraintFitInput.h:12
TRT::Track::d0
@ d0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:62
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::Egamma_v1::phi
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
Definition: Egamma_v1.cxx:75
TestAthenaConstraintFit::m_constraintFit
ToolHandle< ZMassConstraint::IConstraintFit > m_constraintFit
Definition: TestAthenaConstraintFit.h:32
xAOD::Vertex_v1::z
float z() const
Returns the z position.
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
AthAlgorithm
Definition: AthAlgorithm.h:47
TestAthenaConstraintFit::m_electronContName
std::string m_electronContName
Definition: TestAthenaConstraintFit.h:29
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TestAthenaConstraintFit::execute
virtual StatusCode execute()
Function executing the algorithm.
Definition: TestAthenaConstraintFit.cxx:38
xAOD::Electron_v1
Definition: Electron_v1.h:34
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
VertexContainer.h
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
TestAthenaConstraintFit::TestAthenaConstraintFit
TestAthenaConstraintFit(const std::string &name, ISvcLocator *svcLoc)
Regular Algorithm constructor.
Definition: TestAthenaConstraintFit.cxx:16
xAOD::Egamma_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: Egamma_v1.cxx:65
xAOD::Egamma_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: Egamma_v1.cxx:70
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
TestAthenaConstraintFit::m_vertexContName
std::string m_vertexContName
Definition: TestAthenaConstraintFit.h:30