ATLAS Offline Software
Derclc1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
11 #include <array>
12 #include <algorithm>
13 #include <cmath>
14 #include <iostream>
15 
16 namespace Trk {
17 
18 
19 //
20 // Mass constraint calculation in new data model.
21 //
22 // cnstV and cnstP values are used!!!
23 //-----------------------------------------------
25 {
26  int it,itc;
27  double ptot[4]={0.,0.,0.,0.};
28  double cth, invR, pp2, pt;
29  VKConstraintBase * base_cnst = (VKConstraintBase*) cnst;
30  const VKVertex * vk=cnst->getOriginVertex();
31  const std::vector<int> &usedParticles=cnst->getUsedParticles();
32  int usedNTRK = usedParticles.size();
33  VKTrack * trk;
35  for( itc=0; itc<usedNTRK; itc++){
36  it = usedParticles[itc];
37  trk = vk->TrackList.at(it).get();
38  pp[itc]=getCnstParticleMom( trk , vk);
39  ptot[0] += pp[itc][0];
40  ptot[1] += pp[itc][1];
41  ptot[2] += pp[itc][2];
42  ptot[3] += pp[itc][3];
43  }
44 
45  double temp = 1.e-10;
46  int ip=0; if( std::abs(ptot[1]) > std::abs(ptot[ip]) )ip=1; if( std::abs(ptot[2]) > std::abs(ptot[ip]) )ip=2;
47  int im=0; if( std::abs(ptot[1]) < std::abs(ptot[im]) )im=1; if( std::abs(ptot[2]) < std::abs(ptot[im]) )im=2;
48  int id=4; for(int i=0;i<3;i++) if(i!=ip && i!=im)id=i;
49  if(id==4){
50  std::cout<<"ERROR in mass constraint!!!"<<'\n';
51  temp=ptot[3]*ptot[3]-ptot[0]*ptot[0]-ptot[1]*ptot[1]-ptot[2]*ptot[2];
52  } else {
53  temp = sqrt( (ptot[3]-ptot[ip])*(ptot[3]+ptot[ip]) );
54  temp = sqrt( ( temp -ptot[id])*( temp +ptot[id]) );
55  temp = ( temp -ptot[im])*( temp +ptot[im]);
56  }
57  if(temp<1.e-10)temp=1.e-10; //protection
58  temp=sqrt(temp); //system mass
59 //
60 //
61  int numCNST=0; //constraint number. Single constraint in this case
62 //
63 //Difference
64  base_cnst->aa[numCNST] = ( temp - cnst->getTargetMass() ) * ( temp + cnst->getTargetMass() );
65 //
66 //Derivatives Here pp[][3] - particle energy, pp[][4] - squared particle mom
67  for( itc=0; itc<usedNTRK; itc++){
68  it = usedParticles[itc];
69  trk = vk->TrackList.at(it).get();
70  invR = trk->cnstP[2];
71  cth = 1. / tan( trk->cnstP[0] );
72  pt = sqrt(pp[itc][0]*pp[itc][0] + pp[itc][1]*pp[itc][1]);
73  pp2 = pp[itc][0]*pp[itc][0] + pp[itc][1]*pp[itc][1] + pp[itc][2]*pp[itc][2];
74  base_cnst->f0t[it][numCNST].X = ptot[3] * (-pp2* cth / pp[itc][3])
75  - ptot[2] * (-pt * (cth*cth + 1.));
76  base_cnst->f0t[it][numCNST].Y = -ptot[0] * (-pp[itc][1])
77  - ptot[1] * pp[itc][0];
78  base_cnst->f0t[it][numCNST].Z = ptot[3] * (-pp2/ (invR * pp[itc][3]))
79  - ptot[0] * (-pp[itc][0] / invR)
80  - ptot[1] * (-pp[itc][1] / invR)
81  - ptot[2] * (-pp[itc][2] / invR);
82 
83  }
84  base_cnst->h0t[numCNST].X = 0.;
85  base_cnst->h0t[numCNST].Y = 0.;
86  base_cnst->h0t[numCNST].Z = 0.;
87 /* -- Relative normalisation. Now it is target mass (squared?) to make performance uniform */
88  double Scale=0.025/(2.*cnst->getTargetMass()+1.); //28.03.2011 wrong idea for cascade. VK 06.05.2011 actually correct!
89  //Scale=0.01;
90  for (it = 0; it < (int)vk->TrackList.size(); ++it) {
91  base_cnst->f0t[it][numCNST].X *= Scale * 2;
92  base_cnst->f0t[it][numCNST].Y *= Scale * 2;
93  base_cnst->f0t[it][numCNST].Z *= Scale * 2;
94  }
95  base_cnst->aa[numCNST] *= Scale;
96 //std::cout.precision(11);
97 //std::cout<<" mass="<<temp<<", "<<cnst->getTargetMass()<<", "<<base_cnst->aa[numCNST]<<'\n';
98 //std::cout<<base_cnst->f0t[0][numCNST].X<<", "<<base_cnst->f0t[0][numCNST].Y<<", "
99 // <<base_cnst->f0t[0][numCNST].Z<<'\n';
100 //std::cout<<base_cnst->f0t[1][numCNST].X<<", "<<base_cnst->f0t[1][numCNST].Y<<", "
101 // <<base_cnst->f0t[1][numCNST].Z<<'\n';
102 }
103 
104 
105 
106 
107 } /* End of namespace */
Trk::VKTrack::cnstP
double cnstP[3]
Definition: TrkVKalVrtCoreBase.h:80
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
CommonPars.h
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
skel.it
it
Definition: skel.GENtoEVGEN.py:396
test_pyathena.pt
pt
Definition: test_pyathena.py:11
python.atlas_oh.im
im
Definition: atlas_oh.py:167
Trk::VKMassConstraint
Definition: Derivt.h:46
Derclc1.h
Trk::VKTrack
Definition: TrkVKalVrtCoreBase.h:64
Trk::getCnstParticleMom
std::array< double, 4 > getCnstParticleMom(const VKTrack *trk, const VKVertex *vk)
Definition: cfMomentum.cxx:92
Trk::temp
Definition: V0VertexDict.h:23
Trk::VKConstraintBase
Definition: Derivt.h:24
TrkVKalVrtCoreBase.h
Trk::VKVertex::TrackList
std::vector< std::unique_ptr< VKTrack > > TrackList
Definition: TrkVKalVrtCoreBase.h:167
lumiFormat.i
int i
Definition: lumiFormat.py:85
Trk::noinit_vector
std::vector< T, boost::noinit_adaptor< std::allocator< T > > > noinit_vector
A variant on std::vector which leaves its contents uninitialized by default.
Definition: TrkVKalUtils.h:50
find_tgc_unfilled_channelids.ip
ip
Definition: find_tgc_unfilled_channelids.py:3
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
Scale
void Scale(TH1 *h, double d=1)
Definition: comparitor.cxx:76
Trk::VKConstraintBase::f0t
std::vector< std::vector< Vect3DF > > f0t
Definition: Derivt.h:37
Derivt.h
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::VKConstraintBase::aa
std::vector< double > aa
Definition: Derivt.h:36
Trk::VKMassConstraint::getTargetMass
double getTargetMass() const
Definition: Derivt.h:57
Trk::VKMassConstraint::getUsedParticles
const std::vector< int > & getUsedParticles() const
Definition: Derivt.h:58
Trk::VKConstraintBase::getOriginVertex
const VKVertex * getOriginVertex() const
Definition: Derivt.h:30
Trk::VKConstraintBase::h0t
std::vector< Vect3DF > h0t
Definition: Derivt.h:38
Trk::VKVertex
Definition: TrkVKalVrtCoreBase.h:128
TrkVKalUtils.h
Trk::calcMassConstraint
void calcMassConstraint(VKMassConstraint *cnst)
Definition: Derclc1.cxx:24
cfMomentum.h