ATLAS Offline Software
Loading...
Searching...
No Matches
Derclc1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
11#include <array>
12#include <algorithm>
13#include <cmath>
14#include <iostream>
15
16namespace 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 = static_cast<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 */
std::vector< std::vector< Vect3DF > > f0t
Definition Derivt.h:39
const VKVertex * getOriginVertex() const
Definition Derivt.h:32
std::vector< Vect3DF > h0t
Definition Derivt.h:40
std::vector< double > aa
Definition Derivt.h:38
const std::vector< int > & getUsedParticles() const
Definition Derivt.h:60
double getTargetMass() const
Definition Derivt.h:59
std::vector< std::unique_ptr< VKTrack > > TrackList
void Scale(TH1 *h, double d=1)
Ensure that the ATLAS eigen extensions are properly loaded.
std::vector< T, boost::noinit_adaptor< std::allocator< T > > > noinit_vector
A variant on std::vector which leaves its contents uninitialized by default.
void calcMassConstraint(VKMassConstraint *cnst)
Definition Derclc1.cxx:24
std::array< double, 4 > getCnstParticleMom(const VKTrack *trk, const VKVertex *vk)