ATLAS Offline Software
Loading...
Searching...
No Matches
JpsiExample Class Reference

#include <JpsiExample.h>

Inheritance diagram for JpsiExample:
Collaboration diagram for JpsiExample:

Public Member Functions

 JpsiExample (const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize () override
StatusCode execute () override
StatusCode finalize () override
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

void initializeBranches (void)
void clearBranches (void)
TVector3 trackMomentum (const xAOD::Vertex *vxCandidate, uint trkIndex) const
TLorentzVector track4Momentum (const xAOD::Vertex *vxCandidate, int trkIndex, double mass) const
TVector3 origTrackMomentum (const xAOD::Vertex *vxCandidate, int trkIndex) const
TLorentzVector origTrack4Momentum (const xAOD::Vertex *vxCandidate, int trkIndex, double mass) const
double invariantMassError (const xAOD::Vertex *vxCandidate, const std::vector< double > &masses) const
double massErrorVKalVrt (const xAOD::Vertex *vxCandidate, const std::vector< double > &masses) const
double trackCharge (const xAOD::Vertex *vxCandidate, int i) const
Amg::MatrixXconvertVKalCovMatrix (int NTrk, const std::vector< float > &Matrix) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

double m_muonMass
std::string m_userFName
int m_eventCntr
int m_jpsiCntr
std::vector< double > * m_jpsiMass
std::vector< double > * m_jpsiMassError
std::vector< double > * m_jpsiMassRec
std::vector< double > * m_jpsiMassPullRec
std::vector< double > * m_jpsiMassPullMC
std::vector< double > * m_jpsiChi2
std::vector< double > * m_trkRefitPx1
std::vector< double > * m_trkRefitPy1
std::vector< double > * m_trkRefitPz1
std::vector< double > * m_trkRefitPx2
std::vector< double > * m_trkRefitPy2
std::vector< double > * m_trkRefitPz2
std::vector< double > * m_vx
std::vector< double > * m_vy
std::vector< double > * m_vz
std::vector< double > * m_trkOrigCharge1
std::vector< double > * m_trkOrigPx1
std::vector< double > * m_trkOrigPy1
std::vector< double > * m_trkOrigPz1
std::vector< double > * m_trkOrigCharge2
std::vector< double > * m_trkOrigPx2
std::vector< double > * m_trkOrigPy2
std::vector< double > * m_trkOrigPz2
TFile * m_outputFile
TTree * m_auxTree
SG::ReadHandleKey< xAOD::VertexContainerm_JpsiCandidatesKey
 Name of J/psi container.
SG::ReadDecorHandleKey< xAOD::VertexContainerm_refPX
SG::ReadDecorHandleKey< xAOD::VertexContainerm_refPY
SG::ReadDecorHandleKey< xAOD::VertexContainerm_refPZ
DataObjIDColl m_extendedExtraObjects
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 22 of file JpsiExample.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ JpsiExample()

JpsiExample::JpsiExample ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 29 of file JpsiExample.cxx.

29 :
30 AthAlgorithm(name, pSvcLocator),
32{
33
34 // Declare user-defined properties - cuts and vertexing method
35 declareProperty("muonMass" , m_muonMass);
36 declareProperty("outputNTupleName", m_userFName);
37 declareProperty("JpsiCandidates" ,m_JpsiCandidatesKey = "JpsiCandidates");
38
39 declareProperty("RefTrackPx", m_refPX);
40 declareProperty("RefTrackPy", m_refPY);
41 declareProperty("RefTrackPz", m_refPZ);
42
43 // Global Counters; for truth statistics
44 m_eventCntr = 0;
45 m_jpsiCntr = 0;
46
47 m_jpsiMass = 0;
49 m_jpsiMassRec = 0;
52 m_jpsiChi2 = 0;
53
54 m_trkRefitPx1 = 0;
55 m_trkRefitPy1 = 0;
56 m_trkRefitPz1 = 0;
57 m_trkRefitPx2 = 0;
58 m_trkRefitPy2 = 0;
59 m_trkRefitPz2 = 0;
60
61 m_vx = 0;
62 m_vy = 0;
63 m_vz = 0;
64
66 m_trkOrigPx1 = 0;
67 m_trkOrigPy1 = 0;
68 m_trkOrigPz1 = 0;
70 m_trkOrigPx2 = 0;
71 m_trkOrigPy2 = 0;
72 m_trkOrigPz2 = 0;
73
74 m_outputFile = 0;
75 m_auxTree = 0;
76}
AthAlgorithm()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::vector< double > * m_trkOrigPz1
Definition JpsiExample.h:74
std::vector< double > * m_trkOrigCharge2
Definition JpsiExample.h:75
std::vector< double > * m_jpsiMassPullMC
Definition JpsiExample.h:55
std::vector< double > * m_trkRefitPx1
Definition JpsiExample.h:59
std::vector< double > * m_vx
Definition JpsiExample.h:67
std::vector< double > * m_jpsiMass
Definition JpsiExample.h:51
TTree * m_auxTree
Definition JpsiExample.h:84
std::string m_userFName
Definition JpsiExample.h:46
std::vector< double > * m_jpsiChi2
Definition JpsiExample.h:56
std::vector< double > * m_vy
Definition JpsiExample.h:68
std::vector< double > * m_trkOrigPx1
Definition JpsiExample.h:72
std::vector< double > * m_trkOrigCharge1
Definition JpsiExample.h:71
std::vector< double > * m_jpsiMassPullRec
Definition JpsiExample.h:54
SG::ReadDecorHandleKey< xAOD::VertexContainer > m_refPY
Definition JpsiExample.h:88
SG::ReadHandleKey< xAOD::VertexContainer > m_JpsiCandidatesKey
Name of J/psi container.
Definition JpsiExample.h:86
std::vector< double > * m_trkOrigPy2
Definition JpsiExample.h:77
std::vector< double > * m_trkRefitPz1
Definition JpsiExample.h:61
std::vector< double > * m_trkOrigPy1
Definition JpsiExample.h:73
std::vector< double > * m_trkRefitPx2
Definition JpsiExample.h:63
SG::ReadDecorHandleKey< xAOD::VertexContainer > m_refPX
Definition JpsiExample.h:87
std::vector< double > * m_trkOrigPz2
Definition JpsiExample.h:78
std::vector< double > * m_trkOrigPx2
Definition JpsiExample.h:76
std::vector< double > * m_trkRefitPy2
Definition JpsiExample.h:64
std::vector< double > * m_vz
Definition JpsiExample.h:69
std::vector< double > * m_trkRefitPz2
Definition JpsiExample.h:65
std::vector< double > * m_jpsiMassError
Definition JpsiExample.h:52
std::vector< double > * m_trkRefitPy1
Definition JpsiExample.h:60
double m_muonMass
Definition JpsiExample.h:45
std::vector< double > * m_jpsiMassRec
Definition JpsiExample.h:53
SG::ReadDecorHandleKey< xAOD::VertexContainer > m_refPZ
Definition JpsiExample.h:89
TFile * m_outputFile
Definition JpsiExample.h:83
constexpr double muonMassInMeV
the mass of the muon (in MeV)

Member Function Documentation

◆ clearBranches()

void JpsiExample::clearBranches ( void )
private

Definition at line 230 of file JpsiExample.cxx.

230 {
231
232 m_jpsiMass->clear();
233 m_jpsiMassError->clear();
234 m_jpsiMassRec->clear();
235 m_jpsiMassPullRec->clear();
236 m_jpsiMassPullMC->clear();
237 m_jpsiChi2->clear();
238
239// m_trkRefitCharge1->clear();
240 m_trkRefitPx1->clear();
241 m_trkRefitPy1->clear();
242 m_trkRefitPz1->clear();
243// m_trkRefitCharge2->clear();
244 m_trkRefitPx2->clear();
245 m_trkRefitPy2->clear();
246 m_trkRefitPz2->clear();
247
248 m_vx->clear();
249 m_vy->clear();
250 m_vz->clear();
251
252 m_trkOrigCharge1->clear();
253 m_trkOrigPx1->clear();
254 m_trkOrigPy1->clear();
255 m_trkOrigPz1->clear();
256 m_trkOrigCharge2->clear();
257 m_trkOrigPx2->clear();
258 m_trkOrigPy2->clear();
259 m_trkOrigPz2->clear();
260
261// m_rxyError->clear();
262
263 return;
264
265}

◆ convertVKalCovMatrix()

Amg::MatrixX * JpsiExample::convertVKalCovMatrix ( int NTrk,
const std::vector< float > & Matrix ) const
private

Definition at line 497 of file JpsiExample.cxx.

498{
499 // stolen from VKalVrtFitter
500 Amg::MatrixX * mtx = new Amg::MatrixX(3+3*NTrk,3+3*NTrk);
501 long int ij=0;
502 for(int i=1; i<=(3+3*NTrk); i++){
503 for(int j=1; j<=i; j++){
504 if(i==j) {
505 (*mtx)(i-1,j-1)=Matrix[ij];
506 }else{
507 (*mtx).fillSymmetric(i-1,j-1,Matrix[ij]);
508 }
509 ij++;
510 }
511 }
512
513 return mtx;
514}
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode JpsiExample::execute ( )
override

Definition at line 128 of file JpsiExample.cxx.

128 {
129
130
131 ATH_MSG_DEBUG("in execute()");
132
133 // Read in the Jpsis from StoreGate
134 const xAOD::VertexContainer* jpsiContainer(0);
135 SG::ReadHandle<xAOD::VertexContainer> handle(m_JpsiCandidatesKey);
136 jpsiContainer = handle.cptr();
137
138 if (!jpsiContainer) {
139 ATH_MSG_ERROR("No Jpsi Container Found, skipping event");
140 return StatusCode::RECOVERABLE;
141 } else {
142 ATH_MSG_DEBUG("Obtained jpsiContainer");
143 }
144 ATH_MSG_DEBUG("number of jpsi candidates " << jpsiContainer->size());
145 m_jpsiCntr += jpsiContainer->size(); // Count the Jpsis
146
147
148 // Set the auxilliary branches of the ntuple to zero
149 // to avoid accumulation
151
152 ++m_eventCntr; // Increment event counter
153
154 // Extract information from the Jpsi candidates
155 for (const xAOD::Vertex* jpsiCandidate : *jpsiContainer) {
156 //ATH_MSG_INFO("Cov. matrix " << jpsiCandidate->covariance().size());
157
158 // refitted track parameters
159 TLorentzVector refTrk1 = track4Momentum(jpsiCandidate, 0, m_muonMass);
160 m_trkRefitPx1->push_back(refTrk1.Px());
161 m_trkRefitPy1->push_back(refTrk1.Py());
162 m_trkRefitPz1->push_back(refTrk1.Pz());
163
164 TLorentzVector refTrk2 = track4Momentum(jpsiCandidate, 1, m_muonMass);
165 m_trkRefitPx2->push_back(refTrk2.Px());
166 m_trkRefitPy2->push_back(refTrk2.Py());
167 m_trkRefitPz2->push_back(refTrk2.Pz());
168
169 //vertex position
170 m_vx->push_back(jpsiCandidate->x());
171 m_vy->push_back(jpsiCandidate->y());
172 m_vz->push_back(jpsiCandidate->z());
173
174 TLorentzVector origTrk1 = origTrack4Momentum(jpsiCandidate, 0, m_muonMass);
175 m_trkOrigCharge1->push_back(trackCharge(jpsiCandidate, 0));
176 m_trkOrigPx1->push_back(origTrk1.Px());
177 m_trkOrigPy1->push_back(origTrk1.Py());
178 m_trkOrigPz1->push_back(origTrk1.Pz());
179
180 TLorentzVector origTrk2 = origTrack4Momentum(jpsiCandidate, 1, m_muonMass);
181 m_trkOrigCharge2->push_back(trackCharge(jpsiCandidate, 1));
182 m_trkOrigPx2->push_back(origTrk2.Px());
183 m_trkOrigPy2->push_back(origTrk2.Py());
184 m_trkOrigPz2->push_back(origTrk2.Pz());
185
186 // Calculate the invariant masses and their errors
187 double orig_mass = (origTrk1+origTrk2).M(); // mass from original tracks
188 double mass = (refTrk1+refTrk2).M(); // mass from refitted tracks
189 double error = invariantMassError(jpsiCandidate, std::vector<double>(2, m_muonMass)); // invariant mass error
190
191 m_jpsiMass->push_back(mass);
192 m_jpsiMassError->push_back(error);
193 m_jpsiChi2->push_back(jpsiCandidate->chiSquared());
194 m_jpsiMassRec->push_back(orig_mass);
195 m_jpsiMassPullRec->push_back((mass-orig_mass)/error);
196 m_jpsiMassPullMC->push_back((mass-ParticleConstants::JpsiMassInMeV)/error);
197
198 }
199
200 // Write all data to the nTuple
201 m_auxTree->Fill();
202
203 // END OF ANALYSIS
204 return StatusCode::SUCCESS;
205}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
double invariantMassError(const xAOD::Vertex *vxCandidate, const std::vector< double > &masses) const
TLorentzVector track4Momentum(const xAOD::Vertex *vxCandidate, int trkIndex, double mass) const
TLorentzVector origTrack4Momentum(const xAOD::Vertex *vxCandidate, int trkIndex, double mass) const
double trackCharge(const xAOD::Vertex *vxCandidate, int i) const
void clearBranches(void)
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ finalize()

StatusCode JpsiExample::finalize ( )
override

Definition at line 209 of file JpsiExample.cxx.

209 {
210
211 ATH_MSG_DEBUG("in finalize()");
212
213 std::cout << "===================" << std::endl;
214 std::cout << "SUMMARY OF ANALYSIS" << std::endl;
215 std::cout << "===================" << std::endl;
216 std::cout << " " << std::endl;
217 std::cout << "Total number of events analysed: " << m_eventCntr << std::endl;
218 std::cout << "Total number of jpsi candidates: " << m_jpsiCntr << std::endl;
219 // Save auxiliary n-tuple
220 m_outputFile->cd();
221 m_auxTree->Write();
222 m_auxTree->Print();
223 // Close file
224 m_outputFile->Close();
225 return StatusCode::SUCCESS;
226}

◆ initialize()

StatusCode JpsiExample::initialize ( )
override

Definition at line 80 of file JpsiExample.cxx.

80 {
81
82
83 ATH_MSG_DEBUG("in initialize()");
84
85 // Open n-tuple file
86 m_outputFile = new TFile(m_userFName.c_str(),"recreate");
87 // Auxiliary n-tuples not covered by the automatic n-tuple makers
88 // Decay angles
90 m_auxTree = new TTree("AUX","AUX");
91 m_auxTree->Branch("jpsiMass", &m_jpsiMass);
92 m_auxTree->Branch("jpsiMassError", &m_jpsiMassError);
93 m_auxTree->Branch("jpsiMassRec", &m_jpsiMassRec);
94 m_auxTree->Branch("jpsiMassPullRec", &m_jpsiMassPullRec);
95 m_auxTree->Branch("jpsiMassPullMC", &m_jpsiMassPullMC);
96 m_auxTree->Branch("jpsiChi2", &m_jpsiChi2);
97
98// m_auxTree->Branch("trkRefitCharge1", &m_trkRefitCharge1);
99 m_auxTree->Branch("trkRefitPx1", &m_trkRefitPx1);
100 m_auxTree->Branch("trkRefitPy1", &m_trkRefitPy1);
101 m_auxTree->Branch("trkRefitPz1", &m_trkRefitPz1);
102// m_auxTree->Branch("trkRefitCharge2", &m_trkRefitCharge2);
103 m_auxTree->Branch("trkRefitPx2", &m_trkRefitPx2);
104 m_auxTree->Branch("trkRefitPy2", &m_trkRefitPy2);
105 m_auxTree->Branch("trkRefitPz2", &m_trkRefitPz2);
106
107 m_auxTree->Branch("vx",m_vx);
108 m_auxTree->Branch("vy",m_vy);
109 m_auxTree->Branch("vz",m_vz);
110
111 m_auxTree->Branch("trkOrigCharge1", &m_trkOrigCharge1);
112 m_auxTree->Branch("trkOrigPx1", &m_trkOrigPx1);
113 m_auxTree->Branch("trkOrigPy1", &m_trkOrigPy1);
114 m_auxTree->Branch("trkOrigPz1", &m_trkOrigPz1);
115 m_auxTree->Branch("trkOrigCharge2", &m_trkOrigCharge2);
116 m_auxTree->Branch("trkOrigPx2", &m_trkOrigPx2);
117 m_auxTree->Branch("trkOrigPy2", &m_trkOrigPy2);
118 m_auxTree->Branch("trkOrigPz2", &m_trkOrigPz2);
119
120// m_auxTree->Branch("rxyError", &m_rxyError);
121 ATH_CHECK(m_JpsiCandidatesKey.initialize());
122 return StatusCode::SUCCESS;
123
124}
#define ATH_CHECK
Evaluate an expression and check for errors.
void initializeBranches(void)

◆ initializeBranches()

void JpsiExample::initializeBranches ( void )
private

Definition at line 272 of file JpsiExample.cxx.

272 {
273
274 m_jpsiMass = new std::vector<double>;
275 m_jpsiMassError = new std::vector<double>;
276 m_jpsiMassRec = new std::vector<double>;
277 m_jpsiMassPullRec = new std::vector<double>;
278 m_jpsiMassPullMC = new std::vector<double>;
279 m_jpsiChi2 = new std::vector<double>;
280
281// m_trkRefitCharge1 = new std::vector<double>;
282 m_trkRefitPx1 = new std::vector<double>;
283 m_trkRefitPy1 = new std::vector<double>;
284 m_trkRefitPz1 = new std::vector<double>;
285// m_trkRefitCharge2 = new std::vector<double>;
286 m_trkRefitPx2 = new std::vector<double>;
287 m_trkRefitPy2 = new std::vector<double>;
288 m_trkRefitPz2 = new std::vector<double>;
289
290 m_vx = new std::vector<double>;
291 m_vy = new std::vector<double>;
292 m_vz = new std::vector<double>;
293
294 m_trkOrigCharge1 = new std::vector<double>;
295 m_trkOrigPx1 = new std::vector<double>;
296 m_trkOrigPy1 = new std::vector<double>;
297 m_trkOrigPz1 = new std::vector<double>;
298 m_trkOrigCharge2 = new std::vector<double>;
299 m_trkOrigPx2 = new std::vector<double>;
300 m_trkOrigPy2 = new std::vector<double>;
301 m_trkOrigPz2 = new std::vector<double>;
302
303// m_rxyError = new std::vector<double>;
304
305 return;
306
307}

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ invariantMassError()

double JpsiExample::invariantMassError ( const xAOD::Vertex * vxCandidate,
const std::vector< double > & masses ) const
private

Definition at line 390 of file JpsiExample.cxx.

391{
392 uint NTrk = vxCandidate->vxTrackAtVertex().size();
393 if (masses.size() != NTrk) {
394 ATH_MSG_WARNING("The provided number of masses does not match the number of tracks in the vertex");
395 return -999999.;
396 }
397
398 uint ndim = vxCandidate->covariance().size();
399 uint ndimExp = (3*NTrk+3)*(3*NTrk+3+1)/2;
400 if (ndim == ndimExp) {
401 return massErrorVKalVrt(vxCandidate,masses);
402 } else {
403 ATH_MSG_WARNING("Unknown covariance matrix dimension: " << ndim << ", expected: " << ndimExp);
404 return -999999.;
405 }
406}
#define ATH_MSG_WARNING(x)
unsigned int uint
double massErrorVKalVrt(const xAOD::Vertex *vxCandidate, const std::vector< double > &masses) const
std::vector< Trk::VxTrackAtVertex > & vxTrackAtVertex()
Non-const access to the VxTrackAtVertex vector.
const std::vector< float > & covariance() const
Returns the covariance matrix as a simple vector of values.

◆ massErrorVKalVrt()

double JpsiExample::massErrorVKalVrt ( const xAOD::Vertex * vxCandidate,
const std::vector< double > & masses ) const
private

Definition at line 412 of file JpsiExample.cxx.

413{
414 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
415
416 // construct the full covariance matrix
417 Amg::MatrixX* fullCov = convertVKalCovMatrix(NTrk, vxCandidate->covariance());
418
419 std::vector<CLHEP::HepLorentzVector> particleMom(NTrk);
420 std::vector<CLHEP::HepMatrix> particleDeriv(NTrk);
421 CLHEP::HepLorentzVector totalMom;
422 CLHEP::HepMatrix tmpDeriv(3,3);
423
424 double phi=0.,theta=0.,invP=0.;
425 for( unsigned int it=0; it<NTrk; it++){
426 const Trk::TrackParameters* bPer = vxCandidate->vxTrackAtVertex()[it].perigeeAtVertex();
427 phi = bPer->parameters()[Trk::phi];
428 theta = bPer->parameters()[Trk::theta];
429 invP = bPer->parameters()[Trk::qOverP];
430 CLHEP::HepLorentzVector tmp( cos(phi)*sin(theta)/fabs(invP),
431 sin(phi)*sin(theta)/fabs(invP),
432 cos(theta)/fabs(invP) );
433 double esq = tmp.px()*tmp.px() + tmp.py()*tmp.py() + tmp.pz()*tmp.pz() + masses[it]*masses[it];
434 double e = (esq>0.) ? sqrt(esq) : 0.;
435 tmp.setE(e);
436 particleMom[it] = tmp;
437 totalMom += tmp;
438
439// d(Px,Py,Pz)/d(Phi,Theta,InvP)
440 tmpDeriv(1,1) = - tmp.py();
441 tmpDeriv(2,1) = tmp.px();
442 tmpDeriv(3,1) = 0.;
443 tmpDeriv(1,2) = cos(phi) * tmp.pz();
444 tmpDeriv(2,2) = sin(phi) * tmp.pz();
445 tmpDeriv(3,2) = - sin(theta)/fabs(invP);
446 tmpDeriv(1,3) = - tmp.px()/invP;
447 tmpDeriv(2,3) = - tmp.py()/invP;
448 tmpDeriv(3,3) = - tmp.pz()/invP;
449 particleDeriv[it] = tmpDeriv;
450 }
451
452 double dMdPx=0., dMdPy=0., dMdPz=0., dMdPhi=0., dMdTheta=0., dMdInvP=0.;
453 std::vector<double> Deriv(3*NTrk+3, 0.);
454 for(unsigned int it=0; it<NTrk; it++){
455 dMdPx = ( totalMom.e() * particleMom[it].px()/particleMom[it].e() - totalMom.px() ) / totalMom.m();
456 dMdPy = ( totalMom.e() * particleMom[it].py()/particleMom[it].e() - totalMom.py() ) / totalMom.m();
457 dMdPz = ( totalMom.e() * particleMom[it].pz()/particleMom[it].e() - totalMom.pz() ) / totalMom.m();
458
459 dMdPhi = dMdPx*particleDeriv[it](1,1) + dMdPy*particleDeriv[it](2,1) + dMdPz*particleDeriv[it](3,1);
460 dMdTheta = dMdPx*particleDeriv[it](1,2) + dMdPy*particleDeriv[it](2,2) + dMdPz*particleDeriv[it](3,2);
461 dMdInvP = dMdPx*particleDeriv[it](1,3) + dMdPy*particleDeriv[it](2,3) + dMdPz*particleDeriv[it](3,3);
462
463 Deriv[3*it + 3 + 0] = dMdPhi; Deriv[3*it + 3 + 1] = dMdTheta; Deriv[3*it + 3 + 2] = dMdInvP;
464 }
465
466 double err = 0;
467 for(unsigned int i=0; i<3*NTrk+3; i++){
468 for(unsigned int j=0; j<3*NTrk+3; j++){
469 err += Deriv[i]*( (*fullCov)(i,j))*Deriv[j];
470 }
471 }
472
473 // cleanup
474 delete fullCov;
475
476 return (err>0.) ? sqrt(err) : 0.;
477}
Scalar phi() const
phi method
Scalar theta() const
theta method
Amg::MatrixX * convertVKalCovMatrix(int NTrk, const std::vector< float > &Matrix) const
@ theta
Definition ParamDefs.h:66
@ qOverP
perigee
Definition ParamDefs.h:67
@ phi
Definition ParamDefs.h:75
ParametersBase< TrackParametersDim, Charged > TrackParameters

◆ msg()

MsgStream & AthCommonMsg< Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ origTrack4Momentum()

TLorentzVector JpsiExample::origTrack4Momentum ( const xAOD::Vertex * vxCandidate,
int trkIndex,
double mass ) const
private

Definition at line 378 of file JpsiExample.cxx.

379{
380 TVector3 mom = origTrackMomentum(vxCandidate, trkIndex);
381 TLorentzVector lorentz;
382 lorentz.SetVectM(mom, mass);
383 return lorentz;
384}
TVector3 origTrackMomentum(const xAOD::Vertex *vxCandidate, int trkIndex) const

◆ origTrackMomentum()

TVector3 JpsiExample::origTrackMomentum ( const xAOD::Vertex * vxCandidate,
int trkIndex ) const
private

Definition at line 362 of file JpsiExample.cxx.

363{
364 TVector3 mom;
365 const xAOD::TrackParticle* origTrack = vxCandidate->trackParticle(trkIndex);
366 if(origTrack==NULL) {
367 return mom;
368 }
369
370 mom.SetPtEtaPhi(origTrack->pt(), origTrack->eta(), origTrack->phi());
371 return mom;
372}
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .)
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
TrackParticle_v1 TrackParticle
Reference the current persistent version:

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
static Double_t sc
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ track4Momentum()

TLorentzVector JpsiExample::track4Momentum ( const xAOD::Vertex * vxCandidate,
int trkIndex,
double mass ) const
private

Definition at line 349 of file JpsiExample.cxx.

350{
351 TVector3 mom = trackMomentum(vxCandidate, trkIndex);
352 TLorentzVector lorentz;
353 lorentz.SetVectM(mom, mass);
354 return lorentz;
355}
TVector3 trackMomentum(const xAOD::Vertex *vxCandidate, uint trkIndex) const

◆ trackCharge()

double JpsiExample::trackCharge ( const xAOD::Vertex * vxCandidate,
int i ) const
private

Definition at line 483 of file JpsiExample.cxx.

484{
485 if(vxCandidate!=NULL && vxCandidate->trackParticle(i)!=NULL) {
486 return vxCandidate->trackParticle(i)->charge();
487 }
488
489 return -999999;
490}
float charge() const
Returns the charge.

◆ trackMomentum()

TVector3 JpsiExample::trackMomentum ( const xAOD::Vertex * vxCandidate,
uint trkIndex ) const
private

Definition at line 314 of file JpsiExample.cxx.

315{
316 float px = 0., py = 0., pz = 0.;
317// assert(vxCandidate!=0);
318// assert(i<vxCandidate->vxTrackAtVertex().size());
319
320// if (0 != vxCandidate) {
321// const Trk::TrackParameters* aPerigee = vxCandidate->vxTrackAtVertex()[trkIndex].perigeeAtVertex();
322// px = aPerigee->momentum()[Trk::px];
323// py = aPerigee->momentum()[Trk::py];
324// pz = aPerigee->momentum()[Trk::pz];
325// }
326
327 SG::ReadDecorHandle<xAOD::VertexContainer, std::vector<float>> hx (m_refPX);
328 SG::ReadDecorHandle<xAOD::VertexContainer, std::vector<float>> hy (m_refPY);
329 SG::ReadDecorHandle<xAOD::VertexContainer, std::vector<float>> hz (m_refPZ);
330
331 const std::vector<float>& refTrackPx = hx(*vxCandidate);
332 const std::vector<float>& refTrackPy = hy(*vxCandidate);
333 const std::vector<float>& refTrackPz = hz(*vxCandidate);
334
335 if(trkIndex < refTrackPx.size() && refTrackPx.size() == refTrackPy.size() && refTrackPz.size()) {
336 px = refTrackPx[trkIndex];
337 py = refTrackPy[trkIndex];
338 pz = refTrackPz[trkIndex];
339 }
340
341 TVector3 mom(px,py,pz);
342 return mom;
343}

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_auxTree

TTree* JpsiExample::m_auxTree
private

Definition at line 84 of file JpsiExample.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_eventCntr

int JpsiExample::m_eventCntr
private

Definition at line 48 of file JpsiExample.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_JpsiCandidatesKey

SG::ReadHandleKey<xAOD::VertexContainer> JpsiExample::m_JpsiCandidatesKey
private

Name of J/psi container.

Definition at line 86 of file JpsiExample.h.

◆ m_jpsiChi2

std::vector<double>* JpsiExample::m_jpsiChi2
private

Definition at line 56 of file JpsiExample.h.

◆ m_jpsiCntr

int JpsiExample::m_jpsiCntr
private

Definition at line 49 of file JpsiExample.h.

◆ m_jpsiMass

std::vector<double>* JpsiExample::m_jpsiMass
private

Definition at line 51 of file JpsiExample.h.

◆ m_jpsiMassError

std::vector<double>* JpsiExample::m_jpsiMassError
private

Definition at line 52 of file JpsiExample.h.

◆ m_jpsiMassPullMC

std::vector<double>* JpsiExample::m_jpsiMassPullMC
private

Definition at line 55 of file JpsiExample.h.

◆ m_jpsiMassPullRec

std::vector<double>* JpsiExample::m_jpsiMassPullRec
private

Definition at line 54 of file JpsiExample.h.

◆ m_jpsiMassRec

std::vector<double>* JpsiExample::m_jpsiMassRec
private

Definition at line 53 of file JpsiExample.h.

◆ m_muonMass

double JpsiExample::m_muonMass
private

Definition at line 45 of file JpsiExample.h.

◆ m_outputFile

TFile* JpsiExample::m_outputFile
private

Definition at line 83 of file JpsiExample.h.

◆ m_refPX

SG::ReadDecorHandleKey<xAOD::VertexContainer> JpsiExample::m_refPX
private

Definition at line 87 of file JpsiExample.h.

◆ m_refPY

SG::ReadDecorHandleKey<xAOD::VertexContainer> JpsiExample::m_refPY
private

Definition at line 88 of file JpsiExample.h.

◆ m_refPZ

SG::ReadDecorHandleKey<xAOD::VertexContainer> JpsiExample::m_refPZ
private

Definition at line 89 of file JpsiExample.h.

◆ m_trkOrigCharge1

std::vector<double>* JpsiExample::m_trkOrigCharge1
private

Definition at line 71 of file JpsiExample.h.

◆ m_trkOrigCharge2

std::vector<double>* JpsiExample::m_trkOrigCharge2
private

Definition at line 75 of file JpsiExample.h.

◆ m_trkOrigPx1

std::vector<double>* JpsiExample::m_trkOrigPx1
private

Definition at line 72 of file JpsiExample.h.

◆ m_trkOrigPx2

std::vector<double>* JpsiExample::m_trkOrigPx2
private

Definition at line 76 of file JpsiExample.h.

◆ m_trkOrigPy1

std::vector<double>* JpsiExample::m_trkOrigPy1
private

Definition at line 73 of file JpsiExample.h.

◆ m_trkOrigPy2

std::vector<double>* JpsiExample::m_trkOrigPy2
private

Definition at line 77 of file JpsiExample.h.

◆ m_trkOrigPz1

std::vector<double>* JpsiExample::m_trkOrigPz1
private

Definition at line 74 of file JpsiExample.h.

◆ m_trkOrigPz2

std::vector<double>* JpsiExample::m_trkOrigPz2
private

Definition at line 78 of file JpsiExample.h.

◆ m_trkRefitPx1

std::vector<double>* JpsiExample::m_trkRefitPx1
private

Definition at line 59 of file JpsiExample.h.

◆ m_trkRefitPx2

std::vector<double>* JpsiExample::m_trkRefitPx2
private

Definition at line 63 of file JpsiExample.h.

◆ m_trkRefitPy1

std::vector<double>* JpsiExample::m_trkRefitPy1
private

Definition at line 60 of file JpsiExample.h.

◆ m_trkRefitPy2

std::vector<double>* JpsiExample::m_trkRefitPy2
private

Definition at line 64 of file JpsiExample.h.

◆ m_trkRefitPz1

std::vector<double>* JpsiExample::m_trkRefitPz1
private

Definition at line 61 of file JpsiExample.h.

◆ m_trkRefitPz2

std::vector<double>* JpsiExample::m_trkRefitPz2
private

Definition at line 65 of file JpsiExample.h.

◆ m_userFName

std::string JpsiExample::m_userFName
private

Definition at line 46 of file JpsiExample.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ m_vx

std::vector<double>* JpsiExample::m_vx
private

Definition at line 67 of file JpsiExample.h.

◆ m_vy

std::vector<double>* JpsiExample::m_vy
private

Definition at line 68 of file JpsiExample.h.

◆ m_vz

std::vector<double>* JpsiExample::m_vz
private

Definition at line 69 of file JpsiExample.h.


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