CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

Conv4HitsReco2 Class Reference

#include <Conv4HitsReco2.h>

List of all members.

Public Member Functions

 Conv4HitsReco2 (math::XYZVector &, math::XYZVector &, math::XYZVector &, math::XYZVector &, math::XYZVector &)
 Conv4HitsReco2 ()
int ConversionCandidate (math::XYZVector &, double &, double &)
void Dump ()
int GetLoop ()
math::XYZVector GetMinusCenter (double &)
math::XYZVector GetPlusCenter (double &)
double GetRecPhi ()
double GetRecR ()
double GetRecR1 ()
double GetRecR2 ()
void Reconstruct ()
void Refresh (math::XYZVector &vPhotVertex, math::XYZVector &h1, math::XYZVector &h2, math::XYZVector &h3, math::XYZVector &h4)
bool RegisterBadConverge (int &num)
bool RegisterBadConverge ()
bool RegisterBadSign (int &num)
bool RegisterBadSign ()
bool RegisterUnsolvable ()
bool RegisterUnsolvable (int &num)
void SetBField (double val)
void SetFixedNumberOfIterations (double val)
void SetMaxNumberOfIterations (int val)
void SetPhiECut (double val)
void SetRadiusECut (double val)
void SetRECut (double val)
 ~Conv4HitsReco2 ()

Private Member Functions

void LocalTransformation (math::XYZVector v11, math::XYZVector v12, math::XYZVector v21, math::XYZVector v22, math::XYZVector &V11, math::XYZVector &V12, math::XYZVector &V21, math::XYZVector &V22, double Phi)

Private Attributes

double fBField
int fCutSatisfied
int fFixedNumberOfIterations
math::XYZVector fHitv11
math::XYZVector fHitv12
math::XYZVector fHitv21
math::XYZVector fHitv22
int fLoop
int fMaxNumberOfIterations
double fPhiE
double fPhiECut
math::XYZVector fPV
double fRadiusE
double fRadiusECut
double fRE
math::XYZVector fRecC1
math::XYZVector fRecC2
double fRecPhi
double fRecR
double fRecR1
double fRecR2
double fRECut
math::XYZVector fRecV
int fSignSatisfied
int fSolved

Detailed Description

Definition at line 18 of file Conv4HitsReco2.h.


Constructor & Destructor Documentation

Conv4HitsReco2::Conv4HitsReco2 ( math::XYZVector vPhotVertex,
math::XYZVector h1,
math::XYZVector h2,
math::XYZVector h3,
math::XYZVector h4 
)

Definition at line 16 of file Conv4HitsReco2.cc.

References Refresh().

{
        Refresh(vPhotVertex, h1, h2, h3, h4);
}
Conv4HitsReco2::Conv4HitsReco2 ( )
Conv4HitsReco2::~Conv4HitsReco2 ( )

Definition at line 21 of file Conv4HitsReco2.cc.

{ }

Member Function Documentation

int Conv4HitsReco2::ConversionCandidate ( math::XYZVector vtx,
double &  ptplus,
double &  ptminus 
)

Definition at line 90 of file Conv4HitsReco2.cc.

References fBField, fLoop, fRecR1, fRecR2, fRecV, and Reconstruct().

Referenced by SeedForPhotonConversionFromQuadruplets::trajectorySeed().

{
        Reconstruct();

        ptplus = fRecR2 * fBField * 0.01 * 0.3;         // 2 - positron
        ptminus = fRecR1 * fBField * 0.01 * 0.3;        // 1 - electron
        vtx = fRecV;
        //std::cout << ".";
        return fLoop;
}
void Conv4HitsReco2::Dump ( void  )

Definition at line 244 of file Conv4HitsReco2.cc.

References gather_cfg::cout, fCutSatisfied, fSignSatisfied, and fSolved.

Referenced by SeedForPhotonConversionFromQuadruplets::trajectorySeed().

{
        std::cout << std::endl<< "================================================" << std::endl;
        std::cout << "  Nothing happend here.";
        if (fSolved==1) std::cout << "Solved.";
        if (fCutSatisfied==1) std::cout << "Cut good.";
        if (fSignSatisfied==1) std::cout << "Sign good.";
        
}
int Conv4HitsReco2::GetLoop ( ) [inline]

Definition at line 46 of file Conv4HitsReco2.h.

References fLoop.

{ return fLoop; };
math::XYZVector Conv4HitsReco2::GetMinusCenter ( double &  minusR)

Definition at line 260 of file Conv4HitsReco2.cc.

References fRecC2, and fRecR2.

{
        minusR = fRecR2;
        return fRecC2;
}
math::XYZVector Conv4HitsReco2::GetPlusCenter ( double &  plusR)

Definition at line 254 of file Conv4HitsReco2.cc.

References fRecC1, and fRecR1.

{
        plusR = fRecR1;
        return fRecC1;
        
}
double Conv4HitsReco2::GetRecPhi ( ) [inline]

Definition at line 42 of file Conv4HitsReco2.h.

References fRecPhi.

{ return fRecPhi; };
double Conv4HitsReco2::GetRecR ( ) [inline]

Definition at line 43 of file Conv4HitsReco2.h.

References fRecR.

{ return fRecR; };      
double Conv4HitsReco2::GetRecR1 ( ) [inline]

Definition at line 44 of file Conv4HitsReco2.h.

References fRecR1.

{ return fRecR1; };
double Conv4HitsReco2::GetRecR2 ( ) [inline]

Definition at line 45 of file Conv4HitsReco2.h.

References fRecR2.

{ return fRecR2; };
void Conv4HitsReco2::LocalTransformation ( math::XYZVector  v11,
math::XYZVector  v12,
math::XYZVector  v21,
math::XYZVector  v22,
math::XYZVector V11,
math::XYZVector V12,
math::XYZVector V21,
math::XYZVector V22,
double  Phi 
) [private]

Definition at line 55 of file Conv4HitsReco2.cc.

References funct::cos(), and funct::sin().

{
        double x11,x12,x21,x22,y11,y12,y21,y22;

        x11 = v11.X(); y11 = v11.Y();
        x12 = v12.X(); y12 = v12.Y();
        x21 = v21.X(); y21 = v21.Y();
        x22 = v22.X(); y22 = v22.Y();

        double SINP = std::sin(NextPhi);
        double COSP = std::cos(NextPhi);
        double SignCOSP = 1.; if(COSP < 0.) SignCOSP = -1.;
        double AbsCOSP = std::fabs(COSP);

        double X11 = -std::fabs(x11*SINP*SignCOSP - y11*AbsCOSP);
        double Y11 =  std::fabs(y11*SINP*SignCOSP + x11*AbsCOSP);

        double X21 = -std::fabs(x21*SINP*SignCOSP - y21*AbsCOSP);
        double Y21 =  std::fabs(y21*SINP*SignCOSP + x21*AbsCOSP);

        double X12 =  std::fabs(x12*SINP*SignCOSP - y12*AbsCOSP);
        double Y12 =  std::fabs(y12*SINP*SignCOSP + x12*AbsCOSP);

        double X22 =  std::fabs(x22*SINP*SignCOSP - y22*AbsCOSP);
        double Y22 =  std::fabs(y22*SINP*SignCOSP + x22*AbsCOSP);

        V11.SetXYZ(X11,Y11,0.);
        V12.SetXYZ(X12,Y12,0.);
        V21.SetXYZ(X21,Y21,0.);
        V22.SetXYZ(X22,Y22,0.);
}
void Conv4HitsReco2::Reconstruct ( )

Definition at line 102 of file Conv4HitsReco2.cc.

References funct::cos(), fCutSatisfied, fFixedNumberOfIterations, fHitv11, fHitv12, fHitv21, fHitv22, fLoop, fMaxNumberOfIterations, fPhiE, fPhiECut, fPV, fRadiusE, fRadiusECut, fRE, fRecC1, fRecC2, fRecPhi, fRecR, fRecR1, fRecR2, fRECut, fRecV, fSignSatisfied, fSolved, i, funct::pow(), funct::sin(), and mathSSE::sqrt().

Referenced by ConversionCandidate().

{
        double x11,x12,x21,x22,y11,y12,y21,y22;
        //double X11,X12,X21,X22,Y11,Y12,Y21,Y22;
        x11 = fHitv11.X();      y11 = fHitv11.Y();
        x12 = fHitv12.X();      y12 = fHitv12.Y();
        x21 = fHitv21.X();      y21 = fHitv21.Y();
        x22 = fHitv22.X();      y22 = fHitv22.Y(); 

        if (fFixedNumberOfIterations==0)
        fLoop = fMaxNumberOfIterations;
        else fLoop = fFixedNumberOfIterations;

        // Setting Phi1, Phi2 initial guess range, and first guess
        double tempr1 = std::sqrt(y11*y11 + x11*x11);
        double tempr2 = std::sqrt(y12*y12 + x12*x12);

        double Phi1 = 2.0 * std::atan(y11 / (x11+tempr1));
        double Phi2 = 2.0 * std::atan(y12 / (x12+tempr2));

        if (Phi1<Phi2) Phi1 += 2.0 * 3.141592653;       // stupid Atan correction

        fPhiE = std::fabs((Phi1-Phi2)) / std::pow(2.0, fLoop + 1);

        double NextPhi = ( Phi1 + Phi2 ) / 2.0; // first guess
        double D1, D2 = 0.0;
        double prevR1 = 0; double prevR2 = 0;
        double R1 = 0; double R2 = 0;

        // Iterations
        for (int i=0; i<fLoop; i++) {

                // LOCAL TRANFORMATION & EXTRACTION
                double SINP = std::sin(NextPhi);
                double COSP = std::cos(NextPhi);
                double SignCOSP = 1.; if(COSP < 0.) SignCOSP = -1.;
                double AbsCOSP = std::fabs(COSP);

                double X11 = -std::fabs(x11*SINP*SignCOSP - y11*AbsCOSP);
                double Y11 =  std::fabs(y11*SINP*SignCOSP + x11*AbsCOSP);

                double X21 = -std::fabs(x21*SINP*SignCOSP - y21*AbsCOSP);
                double Y21 =  std::fabs(y21*SINP*SignCOSP + x21*AbsCOSP);

                double X12 =  std::fabs(x12*SINP*SignCOSP - y12*AbsCOSP);
                double Y12 =  std::fabs(y12*SINP*SignCOSP + x12*AbsCOSP);

                double X22 =  std::fabs(x22*SINP*SignCOSP - y22*AbsCOSP);
                double Y22 =  std::fabs(y22*SINP*SignCOSP + x22*AbsCOSP);
                // I'm not using LocalTransform() function because this direct way turns out to be faster




                // SOLVING EQUATIONS
                double d1 = Y21 - Y11;
                double d2 = Y22 - Y12;

                if ( ( (X11*X11*d1*d1/(X21-X11)/(X21-X11) + X11*X21 + X11*d1*d1/(X21-X11)) < 0 ) || 
                         ( (X12*X12*d2*d2/(X22-X12)/(X22-X12) + X12*X22 + X12*d2*d2/(X22-X12)) < 0 )    )       
                        { fSolved = -1; fLoop = i;      return; } // No real root.  Break out.
        
                else {
                        fSolved = 1;
                        D1 = X11*d1/(X21-X11);
                        D1 = D1 + std::sqrt(X11*X11*d1*d1/(X21-X11)/(X21-X11) + X11*X21 + X11*d1*d1/(X21-X11));
                        D2 = X12*d2/(X22-X12);
                        D2 = D2 + std::sqrt(X12*X12*d2*d2/(X22-X12)/(X22-X12) + X12*X22 + X12*d2*d2/(X22-X12));
        
                        R1 = std::fabs((X11+X21)/2.0+(D1+d1/2.0)*d1/(X21-X11));
                        R2 = std::fabs((X12+X22)/2.0+(D2+d2/2.0)*d2/(X22-X12));

                        if ((Y11-D1)>=(Y12-D2)) {  // Moving RIGHT
                                Phi1 = NextPhi;
                                Phi2 = Phi2;
                                NextPhi = (Phi1+Phi2)/2.0;
                        }
                        else if ((Y11-D1)<(Y12-D2)) {  // Moving LEFT
                                Phi1 = Phi1;
                                Phi2 = NextPhi;
                                NextPhi = (Phi1+Phi2)/2.0; 
                        } 
                        
                        // CHECK STOP CONDITION
                        double tmpPhiE = std::fabs(Phi1-Phi2);
                        double tmpRE = std::fabs( (Y11 - D1) - (Y12 - D2) );
                        double tmpRadiusE = ( std::fabs(R1-prevR1) + std::fabs(R2-prevR2) ) / 2.;
                        
                        // A. Cut threshold satisfied - STOP - record
                        if (( tmpPhiE <= fPhiECut ) && ( tmpRE <= fRECut ) && ( tmpRadiusE <= fRadiusECut ) && ( fFixedNumberOfIterations ==0 ))
                        {
                                fSolved = 1;  
                                fCutSatisfied = 1; 
                                fLoop = i+1;
                                fPhiE = tmpPhiE; 
                                fRE = tmpRE;    
                                fRadiusE = tmpRadiusE;                          
                                fRecR1 = R1; 
                                fRecR2 = R2; 
                                fRecR = ( (Y11 - D1) + (Y12 - D2) ) / 2.0; 
                                fRecPhi = NextPhi;
                                fRecV.SetX( fRecR * cos(fRecPhi) );
                                fRecV.SetY( fRecR * sin(fRecPhi) );
                                fRecC1.SetXYZ( fRecV.X()-fRecR1*sin(fRecPhi), fRecV.Y()+fRecR1*cos(fRecPhi), 0.);
                                fRecC2.SetXYZ( fRecV.X()+fRecR2*sin(fRecPhi), fRecV.Y()-fRecR2*cos(fRecPhi), 0.);
                                fRecV = fRecV + fPV;
                                fRecC1 = fRecC1 + fPV;
                                fRecC2 = fRecC2 + fPV;
                                fCutSatisfied = 1;
                                if ( (R1>0)&&(R2>0)&&(D1>0)&&(D2>0)&&((Y11-D1)>0)&&((Y12-D2)>0) ) fSignSatisfied = 1;
                                else fSignSatisfied = 0;
                        }
                        else if (i==fLoop-1) {
                                fSolved = 1;  
                                fCutSatisfied = 1; 
                                fLoop = i+1;
                                fPhiE = tmpPhiE; 
                                fRE = tmpRE;    
                                fRadiusE = tmpRadiusE;                          
                                fRecR1 = R1; 
                                fRecR2 = R2; 
                                fRecR = ( (Y11 - D1) + (Y12 - D2) ) / 2.0; 
                                fRecPhi = NextPhi;
                                fRecV.SetX( fRecR * cos(fRecPhi) );
                                fRecV.SetY( fRecR * sin(fRecPhi) );
                                fRecC1.SetXYZ( fRecV.X()-fRecR1*sin(fRecPhi), fRecV.Y()+fRecR1*cos(fRecPhi), 0.);
                                fRecC2.SetXYZ( fRecV.X()+fRecR2*sin(fRecPhi), fRecV.Y()-fRecR2*cos(fRecPhi), 0.);
                                fRecV = fRecV + fPV;
                                fRecC1 = fRecC1 + fPV;
                                fRecC2 = fRecC2 + fPV;
                                fCutSatisfied = 0;
                                if ( (R1>0)&&(R2>0)&&(D1>0)&&(D2>0)&&((Y11-D1)>0)&&((Y12-D2)>0) ) fSignSatisfied = 1;
                                else fSignSatisfied = 0;
                        }
                        // B. Cut threshold NOT satisfied - prepare for next loop
                        prevR1 = R1;   prevR2 = R2; 

                }
        }
}
void Conv4HitsReco2::Refresh ( math::XYZVector vPhotVertex,
math::XYZVector h1,
math::XYZVector h2,
math::XYZVector h3,
math::XYZVector h4 
)

Definition at line 24 of file Conv4HitsReco2.cc.

References fBField, fCutSatisfied, fFixedNumberOfIterations, fHitv11, fHitv12, fHitv21, fHitv22, fMaxNumberOfIterations, fPhiE, fPhiECut, fPV, fRadiusE, fRadiusECut, fRE, fRecPhi, fRecR, fRecR1, fRecR2, fRECut, fSignSatisfied, and fSolved.

Referenced by Conv4HitsReco2().

{
        // Fix 2D plane, make primary vertex the original point
        fPV = vPhotVertex;      fPV.SetZ(0.);
        fHitv11 = h3;           fHitv11.SetZ(0.);       fHitv11 = fHitv11 - fPV;
        fHitv21 = h4;           fHitv21.SetZ(0.);       fHitv21 = fHitv21 - fPV;
        fHitv12 = h2;           fHitv12.SetZ(0.);       fHitv12 = fHitv12 - fPV;
        fHitv22 = h1;           fHitv22.SetZ(0.);       fHitv22 = fHitv22 - fPV;

        // DEFAULT setup
        fMaxNumberOfIterations = 40;
        fFixedNumberOfIterations = 0;
        fRadiusECut = 10.0;//cm
        fPhiECut = 0.03;//rad
        fRECut = 0.5;//cm       
        fBField = 3.8;//T       

        // TRIVIAL initialization
        fCutSatisfied = 0;
        fSignSatisfied = 0;
        fSolved = 0;

        fRecPhi = 0.;
        fRecR = 0.;
        fRecR1 = 0.;
        fRecR2 = 0.;
        fRadiusE = 0.;
        fRE = 0.;
        fPhiE = 0.;
}
bool Conv4HitsReco2::RegisterBadConverge ( ) [inline]

Definition at line 53 of file Conv4HitsReco2.h.

References fCutSatisfied.

{ if (fCutSatisfied==1) return true; else return false;};
bool Conv4HitsReco2::RegisterBadConverge ( int &  num) [inline]

Definition at line 52 of file Conv4HitsReco2.h.

References fCutSatisfied.

{ if (fCutSatisfied==1) return true; else {num+=1; return false;}};
bool Conv4HitsReco2::RegisterBadSign ( int &  num) [inline]

Definition at line 50 of file Conv4HitsReco2.h.

References fSignSatisfied.

{ if (fSignSatisfied==1) return true; else {num+=1; return false;}};
bool Conv4HitsReco2::RegisterBadSign ( ) [inline]

Definition at line 51 of file Conv4HitsReco2.h.

References fSignSatisfied.

{ if (fSignSatisfied==1) return true; else return false; };
bool Conv4HitsReco2::RegisterUnsolvable ( int &  num) [inline]

Definition at line 48 of file Conv4HitsReco2.h.

References fSolved.

{ if (fSolved==1) return true; else {num+=1; return false;}};
bool Conv4HitsReco2::RegisterUnsolvable ( ) [inline]

Definition at line 49 of file Conv4HitsReco2.h.

References fSolved.

{ if (fSolved==1) return true; else return false; };
void Conv4HitsReco2::SetBField ( double  val) [inline]

Definition at line 40 of file Conv4HitsReco2.h.

References fBField.

{ fBField=val; };
void Conv4HitsReco2::SetFixedNumberOfIterations ( double  val) [inline]

Definition at line 39 of file Conv4HitsReco2.h.

References fFixedNumberOfIterations.

void Conv4HitsReco2::SetMaxNumberOfIterations ( int  val) [inline]
void Conv4HitsReco2::SetPhiECut ( double  val) [inline]

Definition at line 37 of file Conv4HitsReco2.h.

References fPhiECut.

{ fPhiECut=val; };
void Conv4HitsReco2::SetRadiusECut ( double  val) [inline]

Definition at line 36 of file Conv4HitsReco2.h.

References fRadiusECut.

{ fRadiusECut=val; };
void Conv4HitsReco2::SetRECut ( double  val) [inline]

Definition at line 38 of file Conv4HitsReco2.h.

References fRECut.

{ fRECut=val; };

Member Data Documentation

double Conv4HitsReco2::fBField [private]

Definition at line 82 of file Conv4HitsReco2.h.

Referenced by ConversionCandidate(), Refresh(), and SetBField().

Definition at line 68 of file Conv4HitsReco2.h.

Referenced by Dump(), Reconstruct(), Refresh(), and RegisterBadConverge().

Definition at line 74 of file Conv4HitsReco2.h.

Referenced by Reconstruct(), Refresh(), and SetFixedNumberOfIterations().

Definition at line 59 of file Conv4HitsReco2.h.

Referenced by Reconstruct(), and Refresh().

Definition at line 59 of file Conv4HitsReco2.h.

Referenced by Reconstruct(), and Refresh().

Definition at line 59 of file Conv4HitsReco2.h.

Referenced by Reconstruct(), and Refresh().

Definition at line 59 of file Conv4HitsReco2.h.

Referenced by Reconstruct(), and Refresh().

int Conv4HitsReco2::fLoop [private]

Definition at line 73 of file Conv4HitsReco2.h.

Referenced by ConversionCandidate(), GetLoop(), and Reconstruct().

Definition at line 72 of file Conv4HitsReco2.h.

Referenced by Reconstruct(), Refresh(), and SetMaxNumberOfIterations().

double Conv4HitsReco2::fPhiE [private]

Definition at line 80 of file Conv4HitsReco2.h.

Referenced by Reconstruct(), and Refresh().

double Conv4HitsReco2::fPhiECut [private]

Definition at line 76 of file Conv4HitsReco2.h.

Referenced by Reconstruct(), Refresh(), and SetPhiECut().

Definition at line 60 of file Conv4HitsReco2.h.

Referenced by Reconstruct(), and Refresh().

double Conv4HitsReco2::fRadiusE [private]

Definition at line 79 of file Conv4HitsReco2.h.

Referenced by Reconstruct(), and Refresh().

double Conv4HitsReco2::fRadiusECut [private]

Definition at line 75 of file Conv4HitsReco2.h.

Referenced by Reconstruct(), Refresh(), and SetRadiusECut().

double Conv4HitsReco2::fRE [private]

Definition at line 81 of file Conv4HitsReco2.h.

Referenced by Reconstruct(), and Refresh().

Definition at line 61 of file Conv4HitsReco2.h.

Referenced by GetPlusCenter(), and Reconstruct().

Definition at line 61 of file Conv4HitsReco2.h.

Referenced by GetMinusCenter(), and Reconstruct().

double Conv4HitsReco2::fRecPhi [private]

Definition at line 63 of file Conv4HitsReco2.h.

Referenced by GetRecPhi(), Reconstruct(), and Refresh().

double Conv4HitsReco2::fRecR [private]

Definition at line 64 of file Conv4HitsReco2.h.

Referenced by GetRecR(), Reconstruct(), and Refresh().

double Conv4HitsReco2::fRecR1 [private]

Definition at line 65 of file Conv4HitsReco2.h.

Referenced by ConversionCandidate(), GetPlusCenter(), GetRecR1(), Reconstruct(), and Refresh().

double Conv4HitsReco2::fRecR2 [private]

Definition at line 66 of file Conv4HitsReco2.h.

Referenced by ConversionCandidate(), GetMinusCenter(), GetRecR2(), Reconstruct(), and Refresh().

double Conv4HitsReco2::fRECut [private]

Definition at line 77 of file Conv4HitsReco2.h.

Referenced by Reconstruct(), Refresh(), and SetRECut().

Definition at line 61 of file Conv4HitsReco2.h.

Referenced by ConversionCandidate(), and Reconstruct().

Definition at line 69 of file Conv4HitsReco2.h.

Referenced by Dump(), Reconstruct(), Refresh(), and RegisterBadSign().

int Conv4HitsReco2::fSolved [private]

Definition at line 70 of file Conv4HitsReco2.h.

Referenced by Dump(), Reconstruct(), Refresh(), and RegisterUnsolvable().