24#include "GaudiKernel/MsgStream.h"
25#include "GaudiKernel/AlgFactory.h"
31#include "CLHEP/Alist/AIterator.h"
34#include "AIDA/IHistogram1D.h"
35#include "AIDA/IHistogram2D.h"
42 ncalc(0), nadded(0), sumpull(0.0), thot(0), tuot(0)
45 nhits = hitl.length();
53 hitl[
kkl]->SetUsedOnHel(0);
60 thot += dchitlist.length();
62 while (dchitlist[
kkl]) dchitlist[
kkl++]->SetUsedOnHel(1);
67 ncalc(0), nadded(0), sumpull(0.0)
74 nhits = hitl.length();
90 if ((whichtrack >=
ntracks) || (whichtrack < 0)) {
91 cout <<
"asked for associates of track " << whichtrack
92 <<
" while there are only " <<
ntracks <<
" tracks in list " << endl;
96 double m_2pi = 2.0*
M_PI;
99 if(5 == debug) temphel->
print();
101 double lmax = temphel->
Lmax();
109 double rmin = fabs(temphel->
D0());
110 double rmax, pc, rc, rhel;
112 rmax = fabs(temphel->
D0() + 2.0/temphel->
Omega());
113 double xc = temphel->
Xc();
114 double yc = temphel->
Yc();
116 rc = fabs(temphel->
D0() + 1.0/temphel->
Omega());
117 rhel = fabs(1.0/temphel->
Omega());
120 pc = temphel->
Phi0();
125 std::cout<<
"==Test add hit phi: rmin >?"<<rmin <<
" gvin "<<gvin
126 <<
" rmax >?"<<rmax <<
" gvout "<<gvout << std::endl;
129 if ((rmin<gvin) && (rmax>gvout)) {
131 if(5 == debug) std::cout<<
" case A (exiter) "<<std::endl;
134 double lstep = m_2pi*rhel/16.;
135 if (lstep>10.) lstep = 10.;
136 double xl = temphel->
Xh(len);
137 double yl = temphel->
Yh(len);
138 double phil = atan2(yl, xl);
139 double rl = sqrt(xl*xl + yl*yl);
141 double philast = phil;
144 while ((notout) && (nstep<20)) {
147 xl = temphel->
Xh(len);
148 yl = temphel->
Yh(len);
149 phil = atan2(yl, xl);
150 rl = sqrt(xl*xl + yl*yl);
151 if ((rl<gvin) && (!isin)) {
153 }
else if ((rl>gvin) && (!isin)) {
154 isin = 1; phim = philast; phip = philast;
157 double deltap = phil - philast;
158 if (deltap >
M_PI) phil -= m_2pi;
159 if (deltap < -
M_PI) phil += m_2pi;
161 if (rl > gvout) notout = 0;
162 if (phil < phim) phim = phil;
163 if (phil > phip) phip = phil;
166 }
else if ((rmin>gvin) && (rmax>gvout)) {
167 if(5 == debug) std::cout<<
" case B (albedo) "<<std::endl;
169 double len=0;
double lstep=m_2pi*rhel/16.;
if (lstep>10.)lstep=10.;
170 double xl=temphel->
Xh(len);
double yl=temphel->
Yh(len);
171 double phil=atan2(yl,xl);
double rl=sqrt(xl*xl+yl*yl);
172 phim=phil; phip=phil;
double phis=phil;
double deltap,dp1,dp2;
173 int nstep=0;
double philast=phil;
174 while ((rl<gvout)&&(nstep<20)){
175 len+=lstep; nstep++; xl=temphel->
Xh(len); yl=temphel->
Yh(len);
176 phil=atan2(yl,xl); rl=sqrt(xl*xl+yl*yl);
177 deltap=phil-philast;
if (deltap>
M_PI)phil-=m_2pi;
178 if (deltap<-
M_PI)phil+=m_2pi; philast=phil;
179 if (phil<phim)phim=phil;
if (phil>phip)phip=phil;
181 dp1=fabs(phis-phim); dp2=fabs(phip-phis); deltap=dp1;
182 if(dp2>dp1)deltap=dp2; phim=phis-deltap; phip=phis+deltap;
183 }
else if ((rmin<gvin) && (rmax<gvout)) {
185 if(5 == debug) std::cout<<
" case C (looper) "<<std::endl;
187 double alp=asin(rhel/rc); phim=pc-alp; phip=pc+alp;
191 double lstep=m_2pi*rhel/16.;
192 if (lstep>10.)lstep=10.;
193 if(5 == debug) std::cout<<
"ini step "<<m_2pi*rhel/16.<<
" lstep " << lstep <<
"cm"<<std::endl;
194 double xl=temphel->
Xh(len);
double yl=temphel->
Yh(len);
195 double phil=atan2(yl,xl);
double rl=sqrt(xl*xl+yl*yl);
196 int nstep=0;
double philast=phil;
int isin=0;
int notout=1;
197 while ((notout)&&(nstep<33)){
198 len+=lstep; nstep++; xl=temphel->
Xh(len); yl=temphel->
Yh(len);
199 phil=atan2(yl,xl); rl=sqrt(xl*xl+yl*yl);
201 std::cout<< nstep<<
" rl "<<rl<<
" gvin " <<gvin<<
" isin "<<isin;
203 if ((rl<gvin)&&(!isin)){
205 }
else if((rl>gvin)&&(!isin)){
206 isin=1; phim=philast; phip=philast;
209 double deltap=phil-philast;
if (deltap>
M_PI)phil-=m_2pi;
210 if (deltap<-
M_PI)phil+=m_2pi; philast=phil;
if (rl<gvin)notout=0;
211 if (phil<phim)phim=phil;
if (phil>phip)phip=phil;
214 if(len >
M_PI*rhel*0.75) {
216 std::cout<<
" len "<<len<<
" >pi*R_helix "<<
M_PI*rhel<<
" rhel "<<rhel<<
" break"<<std::endl;
221 std::cout<<
" philast "<<philast<<
" phim "<<phim <<
" phip "<<phip <<
" len "<<len<<std::endl;
226 }
else if ((rmin>gvin) && (rmax<gvout)) {
229 double alp = asin(rhel/rc);
239 std::cout<<
"add hits phim "<<phim <<
" phip "<<phip<< std::endl;
244 if(5 == debug) std::cout<<
"===== try to add hits:"<< std::endl;
249 if(5 == debug) std::cout<<
" len<0 " << temphel->
Doca_Len()<<
" continue"<<std::endl;
256 temphit->
print(std::cout);
257 std::cout<<
" pull "<<temphit->
pull(*temphel)
264 double pw = temphit->
pw();
265 if((phip-pw) > m_2pi) pw += m_2pi;
266 if((phim-pw) < -m_2pi) pw -= m_2pi;
268 std::cout<<
"phi wire "<<pw <<
" phim "<<phim<<
" phip "<<phip<<
" len "<<temphel->
Doca_Len();
270 if ( (pw>phim) && (pw<phip) ) {
273 <<
" pull " << fabs(temphit->
pull(*temphel))
278 double pull = temphit->
pull( *temphel );
283 int layer = temphit->
Layer();
286 std::cout<<
" pull "<<pull
290 <<
" >? lmax "<< lmax
308 temphit->
print(std::cout);
309 std::cout<<
"Added "<< std::endl;
AIDA::IHistogram1D * g_addHitCut
AIDA::IHistogram2D * g_addHitCut2d
AIDA::IHistogram1D * g_addHitCut
AIDA::IHistogram2D * g_addHitCut2d
HepAList< MdcxHit > listoasses
const HepAList< MdcxHit > & GetAssociates(int i=0)
MdcxAddHits(HepAList< MdcxFittedHel > &f, const HepAList< MdcxHit > &h, float addit=1.5)
double Yh(double l) const
double Xh(double l) const
float pull(MdcxHel &hel) const
void print(std::ostream &o, int i=0) const
static const double firstMdcAxialRadius
static const double maxTrkLength
static const double maxMdcRadius
MDC Geometry.
static double nSigAddHitTrk