Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes

WCSimVertexFinderPoint Class Reference

#include "WCSimVertexFinderPoint.hh"

List of all members.

Public Member Functions

void RunPrintParameters ()
void SetConeEdge (Double_t degrees)
WCSimRecoVertexRunPointFit1 (WCSimRecoEvent *myEvent, Double_t vx, Double_t vy, Double_t vz)
WCSimRecoVertexFindSimpleVertex (Double_t vx, Double_t vy, Double_t vz)
WCSimRecoVertexFindSimpleDirection (WCSimRecoVertex *vertex)
WCSimRecoVertexFitPointVertex (WCSimRecoEvent *myEvent, WCSimRecoVertex *myVertex)
WCSimRecoVertexFitPointVertex (WCSimRecoVertex *vertex)
WCSimRecoVertexFitPointVertexWithMinuitMatt (WCSimRecoVertex *vertex)
void PointVertexChi2 (Double_t vx, Double_t vy, Double_t vz, Double_t &vt, Double_t &chi2)
void PointVertexChi2 (Double_t &vt, Double_t &chi2)
Double_t FOMCalc (WCSimRecoEvent *myEvent, Double_t vX, Double_t vY, Double_t vZ, Double_t vT, TH1D *myTimeRes)
Double_t AndyFOM (Double_t vX, Double_t vY, Double_t vZ, Double_t vT, TH1D *myTimeRes)
void AndyFOM (Double_t vX, Double_t vY, Double_t vZ, Double_t vT, Double_t &chi2)
void AndyFOM (WCSimRecoEvent *myEvent, Double_t vX, Double_t vY, Double_t vZ, Double_t vT, Double_t &chi2)
Int_t GetNDigits ()
Double_t GetDigitX (Int_t idigit)
Double_t GetDigitY (Int_t idigit)
Double_t GetDigitZ (Int_t idigit)
Double_t GetDigitT (Int_t idigit)
Double_t GetDigitQ (Int_t idigit)
Double_t GetDistAngle (Int_t idigit)
Double_t GetDistPoint (Int_t idigit)
Double_t GetDistTrack (Int_t idigit)
Double_t GetDistPhoton (Int_t idigit)
Double_t GetDeltaT (Int_t idigit)
Double_t GetDeltaR (Int_t idigit)
Double_t GetDeltaTrack (Int_t idigit)
Double_t GetDeltaPhoton (Int_t idigit)
Double_t GetDelta (Int_t idigit)
Double_t GetDeltaAngle (Int_t idigit)
Double_t GetDeltaWeight (Int_t idigit)
Double_t GetDeltaDeweight (Int_t idigit)
WCSimRecoVertexGetSimpleVertex ()
WCSimRecoVertexGetSimpleDirection ()
WCSimRecoVertexGetPointVertex ()
WCSimRecoVertexGetPointDirection ()
WCSimRecoVertexGetExtendedVertex ()
void FillArrays (std::vector< WCSimRecoDigit * > *digitlist)
void FillArrays (WCSimRecoEvent *myEvent)
void PointResiduals (Double_t vx, Double_t vy, Double_t vz)
void FindSimpleTimeProperties (Double_t &vtime, Double_t &vtimerms)
void FitTimeProperties (Double_t &vtime, Double_t &chi2)
void TimePropertiesChi2 (Double_t vtime, Double_t &chi2)
void PenaltyChi2 (Double_t vtxX, Double_t vtxY, Double_t vtxZ, Double_t &chi2)
void PenaltyChi2Matt (Double_t vx, Double_t vy, Double_t vz, Double_t &chi2)
void PenaltyChi2Matt2 (Double_t vx, Double_t vy, Double_t vz, Double_t &chi2)
void GlbPeakGeo (Double_t *trV, Double_t *dir, Double_t *ftV, Double_t &fopenangle, Double_t &fD, Double_t &fd)
Double_t TrackL (Double_t vx, Double_t vy, Double_t vz, Double_t dirx, Double_t diry, Double_t dirz)
Double_t Openagl (Double_t vx, Double_t vy, Double_t vz, Double_t dirx, Double_t diry, Double_t dirz, WCSimRecoEvent *myEvent)
Double_t DistHit (Double_t vx, Double_t vy, Double_t vz, WCSimRecoEvent *myEvent)
Double_t BotFrac (WCSimRecoEvent *myEvent)
Int_t GetIterations ()
void point_vertex_itr ()
void vertex_gaus_itr ()
void point_vertex_reset_itr ()
void vertex_gaus_reset_itr ()
Int_t point_vertex_iterations ()
Int_t vertex_gaus_iterations ()
void Reset ()

Static Public Member Functions

static WCSimVertexFinderPointInstance ()
static void PrintParameters ()

Public Attributes

Double_t fVtxX
Double_t fVtxY
Double_t fVtxZ
Double_t fVtxTime
Double_t fDirX
Double_t fDirY
Double_t fDirZ
Double_t fDirAngle
Double_t ffakex
Double_t ffakey
Double_t ffakez
Double_t fVtxFOM

Private Member Functions

 WCSimVertexFinderPoint ()
 ~WCSimVertexFinderPoint ()
void Clear ()

Private Attributes

Double_t fBaseFOM
Double_t fConeEdgeDegrees
Bool_t fPass
Int_t fNdigits
Double_t fMeanQ
Double_t fMeanRes
Double_t fInputVtxX
Double_t fInputVtxY
Double_t fInputVtxZ
Double_t fInputVtxTime
Double_t fInputDirX
Double_t fInputDirY
Double_t fInputDirZ
Double_t fInputDirAngle
Double_t fInputVtxFOM
Double_t * fDigitX
Double_t * fDigitY
Double_t * fDigitZ
Double_t * fDigitT
Double_t * fDigitQ
Double_t * fDistAngle
Double_t * fDistPoint
Double_t * fDistTrack
Double_t * fDistPhoton
Double_t * fDeltaT
Double_t * fDeltaR
Double_t * fDeltaTrack
Double_t * fDeltaPhoton
Double_t fsign
Double_t * fDelta
Double_t * fDeltaAngle
Double_t * fDeltaWeight
Double_t * fDeltaDeweight
Double_t * fAngle
Double_t * fAngleWeight
Double_t * fAngleDeweight
WCSimRecoVertexfSimpleVertex
WCSimRecoVertexfSimpleDirection
WCSimRecoVertexfPointVertex
WCSimRecoVertexfPointDirection
WCSimRecoVertexfExtendedVertex
TMinuit * fMinuitPointVertex
TMinuit * fMinuitPointDirection
TMinuit * fMinuitExtendedVertex
TMinuit * fMinuitExtendedVertexNested
TMinuit * fMinuitTimeFit
Int_t fItr
Int_t fPointVtxItr
Int_t fPointDirItr
Int_t fExtendedVtxItr
std::vector< WCSimRecoVertex * > vVertexList

Detailed Description

Definition at line 17 of file WCSimVertexFinderPoint.hh.


Constructor & Destructor Documentation

WCSimVertexFinderPoint::WCSimVertexFinderPoint (  )  [private]

Definition at line 112 of file WCSimVertexFinderPoint.cc.

References fAngle, fAngleDeweight, fAngleWeight, fBaseFOM, fConeEdgeDegrees, fDelta, fDeltaAngle, fDeltaDeweight, fDeltaPhoton, fDeltaR, fDeltaT, fDeltaTrack, fDeltaWeight, fDigitQ, fDigitT, fDigitX, fDigitY, fDigitZ, fDistAngle, fDistPhoton, fDistPoint, fDistTrack, fExtendedVertex, fItr, fMeanQ, fMeanRes, fMinuitExtendedVertex, fMinuitExtendedVertexNested, fMinuitPointDirection, fMinuitPointVertex, fMinuitTimeFit, fNdigits, fPass, fPointDirection, fPointVertex, fSimpleDirection, fSimpleVertex, fVtxX, fVtxY, and fVtxZ.

Referenced by Instance().

{
  std::cout << " *** WCSimVertexFinder::WCSimVertexFinder() *** " << std::endl;

  // default configuration
  fBaseFOM = 100.0;
  fConeEdgeDegrees = 2.0;

  fVtxX = 0.0;
  fVtxY = 0.0;
  fVtxZ = 0.0;

  fPass = 0;

  fNdigits = 0;
  fMeanQ = 0.0;
  fMeanRes = 2.0;
  
  fDigitX = 0;
  fDigitY = 0;
  fDigitZ = 0;
  fDigitT = 0;
  fDigitQ = 0;
  
  fDistAngle = 0;
  fDistPoint = 0;
  fDistTrack = 0;
  fDistPhoton = 0;

  fDeltaT = 0;
  fDeltaR = 0;
  fDeltaTrack = 0;
  fDeltaPhoton = 0;

  fDelta = 0;
  fDeltaAngle = 0;
  fDeltaWeight = 0;
  fDeltaDeweight = 0;

  fAngle = 0;
  fAngleWeight = 0;
  fAngleDeweight = 0;
  
  fSimpleVertex = 0;
  fSimpleDirection = 0;
  fPointVertex = 0;
  fPointDirection = 0;
  fExtendedVertex = 0;

  fMinuitPointVertex = new TMinuit();
  fMinuitPointVertex->SetPrintLevel(-1);
  fMinuitPointVertex->SetMaxIterations(5000);

  fMinuitPointDirection = new TMinuit();
  fMinuitPointDirection->SetPrintLevel(-1);
  fMinuitPointDirection->SetMaxIterations(5000);

  fMinuitExtendedVertex = new TMinuit();
  fMinuitExtendedVertex->SetPrintLevel(-1);
  fMinuitExtendedVertex->SetMaxIterations(5000); 

  fMinuitExtendedVertexNested = new TMinuit();
  fMinuitExtendedVertexNested->SetPrintLevel(-1);
  fMinuitExtendedVertexNested->SetMaxIterations(5000);

  fMinuitTimeFit = new TMinuit();
  fMinuitTimeFit->SetPrintLevel(-1);
  fMinuitTimeFit->SetMaxIterations(5000);

  fItr = 0;
}

WCSimVertexFinderPoint::~WCSimVertexFinderPoint (  )  [private]

Member Function Documentation

Double_t WCSimVertexFinderPoint::AndyFOM ( Double_t  vX,
Double_t  vY,
Double_t  vZ,
Double_t  vT,
TH1D *  myTimeRes 
)

Definition at line 722 of file WCSimVertexFinderPoint.cc.

References fDelta, fDigitT, fDigitX, fDigitY, fDigitZ, fNdigits, PenaltyChi2Matt2(), and WCSimParameters::SpeedOfLight().

Referenced by FitPointVertexWithMinuitMatt(), and FOMCalc().

{
  if( fDelta  ) delete [] fDelta;
  fDelta = new Double_t[fNdigits];
  myTimeRes->Reset();
  Double_t mean0 = 0.0;

  for( Int_t idigit=0; idigit<fNdigits; idigit++ ){
    Double_t dx = fDigitX[idigit]-vX;
    Double_t dy = fDigitY[idigit]-vY;
    Double_t dz = fDigitZ[idigit]-vZ;
    Double_t ds = sqrt(dx*dx+dy*dy+dz*dz);
    Double_t phoT = 1.33*ds/(WCSimParameters::SpeedOfLight());
    fDelta[idigit] = fDigitT[idigit] - phoT - vT;
    myTimeRes->TH1::Fill(fDelta[idigit]);
    mean0 += fDelta[idigit];
  }
  mean0 = mean0/fNdigits;
  Double_t newfom = 0.;
  Double_t sigma0 = 2.0*8.75;
  for( Int_t idigit=0; idigit<fNdigits; idigit++ ){
    newfom += 0.25*exp(-((fDelta[idigit]-mean0)*(fDelta[idigit]-mean0))/(2*sigma0*sigma0));
  }
  Double_t penal = 0.0;
  //this->PenaltyChi2Matt(vX,vY,vZ,penal);
  this->PenaltyChi2Matt2(vX,vY,vZ,penal); //don't use penaltyFOM when checking timeresidual distribution
 
  Double_t chi2 = newfom + penal;

  return (chi2);
}

void WCSimVertexFinderPoint::AndyFOM ( WCSimRecoEvent myEvent,
Double_t  vX,
Double_t  vY,
Double_t  vZ,
Double_t  vT,
Double_t &  chi2 
)

Definition at line 804 of file WCSimVertexFinderPoint.cc.

References fDelta, fDigitT, fDigitX, fDigitY, fDigitZ, FillArrays(), fNdigits, and WCSimParameters::SpeedOfLight().

{
  this->FillArrays(myEvent);
  
  if( fDelta  ) delete [] fDelta;
  fDelta = new Double_t[fNdigits];
  Double_t mean0 = 0.0;
  Double_t newfom = 0.0;
 
  //TH1D* myTimeRes = new TH1D;
  for( Int_t idigit=0; idigit<fNdigits; idigit++ ){
    Double_t dx = fDigitX[idigit]-vX;
    Double_t dy = fDigitY[idigit]-vY;
    Double_t dz = fDigitZ[idigit]-vZ;
    Double_t ds = sqrt(dx*dx+dy*dy+dz*dz);
    Double_t phoT = 1.33*ds/(WCSimParameters::SpeedOfLight());
    fDelta[idigit] = fDigitT[idigit] - phoT - vT;
    mean0 += fDelta[idigit];
  }
  //std::cout << "sumdelta" << mean0 << std::endl;
  //std::cout << "meandelta" << mean0 << std::endl;
  
  mean0 = mean0/fNdigits;
  Double_t sigma0 = 2.0*9.0;
  for( Int_t idigit=0; idigit<fNdigits; idigit++ ){
    //if( fDelta[idigit] >= 0 )
      newfom += 0.25*exp(-((fDelta[idigit]-mean0)*(fDelta[idigit]-mean0))/(2*sigma0*sigma0));
    //else newfom += -999999.9;
  }

  chi2 = newfom;

  std::cout << "vertex: (" << vX << " " << vY << " " << vZ << " " << vT << ")= " << chi2 << std::endl;

  return;
}

void WCSimVertexFinderPoint::AndyFOM ( Double_t  vX,
Double_t  vY,
Double_t  vZ,
Double_t  vT,
Double_t &  chi2 
)

Definition at line 765 of file WCSimVertexFinderPoint.cc.

References fDelta, fDigitT, fDigitX, fDigitY, fDigitZ, fNdigits, fsign, PenaltyChi2Matt2(), and WCSimParameters::SpeedOfLight().

{
  if( fDelta  ) delete [] fDelta;
  fDelta = new Double_t[fNdigits];
  Double_t mean0 = 0.0;
  Double_t newfom = 0.0;
 
  //TH1D* myTimeRes = new TH1D;
  for( Int_t idigit=0; idigit<fNdigits; idigit++ ){
    Double_t dx = fDigitX[idigit]-vX;
    Double_t dy = fDigitY[idigit]-vY;
    Double_t dz = fDigitZ[idigit]-vZ;
    Double_t ds = sqrt(dx*dx+dy*dy+dz*dz);
    Double_t phoT = 1.33*ds/(WCSimParameters::SpeedOfLight());
    fDelta[idigit] = fDigitT[idigit] - phoT - vT;
    mean0 += fDelta[idigit];
  }
  //std::cout << "sumdelta" << mean0 << std::endl;
  //std::cout << "meandelta" << mean0 << std::endl;
  
  mean0 = mean0/fNdigits;
  Double_t sigma0 = 2.0*8.75;
  for( Int_t idigit=0; idigit<fNdigits; idigit++ ){
    //if( fDelta[idigit] >= 0 )
      newfom += 0.25*exp(-((fDelta[idigit]-mean0)*(fDelta[idigit]-mean0))/(2*sigma0*sigma0));
    //else newfom += -999999.9;
  }
  
  Double_t penal = 0.0;
  //this->PenaltyChi2Matt(vX,vY,vZ,penal);
  this->PenaltyChi2Matt2(vX,vY,vZ,penal);
 
  chi2 = newfom + penal;

  std::cout << "vertex: (" << vX << " " << vY << " " << vZ << " " << vT << ")= " << chi2 << " " << newfom << " " << penal << " " << fsign << std::endl;

  return;
}

Double_t WCSimVertexFinderPoint::BotFrac ( WCSimRecoEvent myEvent  ) 

Definition at line 1342 of file WCSimVertexFinderPoint.cc.

References fDigitZ, FillArrays(), and fNdigits.

{
  this->FillArrays(myEvent);

  Double_t NBot = 0.;
  for( Int_t idigit=0; idigit<fNdigits; idigit++ ){
  if ( (fDigitZ[idigit]>=3150.)||(fDigitZ[idigit]<-3150.) ) NBot+=1.0;
  }
  Double_t ffrac = NBot/fNdigits;
  //std::cout << NBot << "/" << fNdigits << " " << ffrac << std::endl;
  return ffrac;
}

void WCSimVertexFinderPoint::Clear (  )  [private]

Definition at line 238 of file WCSimVertexFinderPoint.cc.

References fExtendedVertex, fPointDirection, fPointVertex, fSimpleDirection, fSimpleVertex, and vVertexList.

Referenced by Reset().

{
  // clear vertices
  // ==============
  for(UInt_t i=0; i<vVertexList.size(); i++ ){
    delete (WCSimRecoVertex*)(vVertexList.at(i));
  }

  fSimpleVertex = 0;
  fSimpleDirection = 0;
  fPointVertex = 0;
  fPointDirection = 0;
  fExtendedVertex = 0;

  vVertexList.clear();

  return;
}

Double_t WCSimVertexFinderPoint::DistHit ( Double_t  vx,
Double_t  vy,
Double_t  vz,
WCSimRecoEvent myEvent 
)

Definition at line 1326 of file WCSimVertexFinderPoint.cc.

References fDigitX, fDigitY, fDigitZ, FillArrays(), and fNdigits.

{
  this->FillArrays(myEvent);
  Double_t fhitdist = 0.0;
  for( Int_t idigit=0; idigit<fNdigits; idigit++ ){
  
  Double_t dx = fDigitX[idigit]-vx;
  Double_t dy = fDigitY[idigit]-vy;
  Double_t dz = fDigitZ[idigit]-vz;
  Double_t ds = sqrt(dx*dx+dy*dy+dz*dz);
  fhitdist += ds;
  }
  fhitdist = fhitdist/fNdigits;
  return fhitdist;
}

void WCSimVertexFinderPoint::FillArrays ( std::vector< WCSimRecoDigit * > *  digitlist  ) 

Definition at line 890 of file WCSimVertexFinderPoint.cc.

References fDigitQ, fDigitT, fDigitX, fDigitY, fDigitZ, fMeanQ, fMeanRes, fNdigits, WCSimRecoDigit::GetQPEs(), WCSimRecoDigit::GetTime(), WCSimRecoDigit::GetX(), WCSimRecoDigit::GetY(), WCSimRecoDigit::GetZ(), and WCSimParameters::TimeResolution().

Referenced by AndyFOM(), BotFrac(), DistHit(), FitPointVertex(), FOMCalc(), and Openagl().

{
  // clear arrays
  // ============
  if( fDigitX ) delete [] fDigitX;
  if( fDigitY ) delete [] fDigitY;
  if( fDigitZ ) delete [] fDigitZ;
  if( fDigitT ) delete [] fDigitT;
  if( fDigitQ ) delete [] fDigitQ;

  if( myDigitList->size()==0 ){
    std::cout << "   <warning> vertex finder found no digits! " << std::endl;
  }

  fNdigits = myDigitList->size();
  fDigitX = new Double_t[fNdigits];
  fDigitY = new Double_t[fNdigits];
  fDigitZ = new Double_t[fNdigits];
  fDigitT = new Double_t[fNdigits];
  fDigitQ = new Double_t[fNdigits];

  fMeanQ = 0.0;
  fMeanRes = 2.5;

  Double_t Swx = 0.0;
  Double_t Sw = 0.0;
  
  // store digit data
  // ================
  for( UInt_t idigit=0; idigit<myDigitList->size(); idigit++ ){
    WCSimRecoDigit* recoDigit = (WCSimRecoDigit*)(myDigitList->at(idigit));    
    fDigitX[idigit] = recoDigit->GetX();
    fDigitY[idigit] = recoDigit->GetY();
    fDigitZ[idigit] = recoDigit->GetZ();
    fDigitT[idigit] = recoDigit->GetTime();
    fDigitQ[idigit] = recoDigit->GetQPEs();

    Swx += recoDigit->GetQPEs();
    Sw += 1.0;
  }

  if( Sw>0.0 ){
    fMeanQ = Swx/Sw;
    fMeanRes = WCSimParameters::TimeResolution(fMeanQ);
  }

  return;
}  

void WCSimVertexFinderPoint::FillArrays ( WCSimRecoEvent myEvent  ) 

Definition at line 939 of file WCSimVertexFinderPoint.cc.

References fDigitQ, fDigitT, fDigitX, fDigitY, fDigitZ, fMeanQ, fMeanRes, fNdigits, WCSimRecoEvent::GetFilterDigit(), WCSimRecoEvent::GetNFilterDigits(), WCSimRecoDigit::GetQPEs(), WCSimRecoDigit::GetTime(), WCSimRecoDigit::GetX(), WCSimRecoDigit::GetY(), WCSimRecoDigit::GetZ(), and WCSimParameters::TimeResolution().

{
  // clear arrays
  // ============
  if( fDigitX ) delete [] fDigitX;
  if( fDigitY ) delete [] fDigitY;
  if( fDigitZ ) delete [] fDigitZ;
  if( fDigitT ) delete [] fDigitT;
  if( fDigitQ ) delete [] fDigitQ;

  if( myEvent->GetNFilterDigits()==0 ){
    std::cout << "   <warning> vertex finder found no digits! " << std::endl;
  }

  fNdigits = myEvent->GetNFilterDigits();
  fDigitX = new Double_t[fNdigits];
  fDigitY = new Double_t[fNdigits];
  fDigitZ = new Double_t[fNdigits];
  fDigitT = new Double_t[fNdigits];
  fDigitQ = new Double_t[fNdigits];

  fMeanQ = 0.0;
  fMeanRes = 2.5;

  Double_t Swx = 0.0;
  Double_t Sw = 0.0;

  // store digit data
  // ================
  for( Int_t idigit=0; idigit<fNdigits; idigit++ ){
    WCSimRecoDigit* recoDigit = (WCSimRecoDigit*)(myEvent->GetFilterDigit(idigit));    
    fDigitX[idigit] = recoDigit->GetX();
    fDigitY[idigit] = recoDigit->GetY();
    fDigitZ[idigit] = recoDigit->GetZ();
    fDigitT[idigit] = recoDigit->GetTime();
    fDigitQ[idigit] = recoDigit->GetQPEs();

    Swx += recoDigit->GetQPEs();
    Sw += 1.0;
  }

  if( Sw>0.0 ){
    fMeanQ = Swx/Sw;
    fMeanRes = WCSimParameters::TimeResolution(fMeanQ);
  }

  return;
}  

WCSimRecoVertex * WCSimVertexFinderPoint::FindSimpleDirection ( WCSimRecoVertex vertex  ) 

Definition at line 338 of file WCSimVertexFinderPoint.cc.

References fDigitQ, fDigitX, fDigitY, fDigitZ, fItr, fNdigits, fPass, fSimpleDirection, WCSimRecoVertex::GetStatus(), WCSimRecoVertex::GetTime(), WCSimRecoVertex::GetX(), WCSimRecoVertex::GetY(), WCSimRecoVertex::GetZ(), WCSimRecoVertex::SetDirection(), WCSimRecoVertex::SetFOM(), WCSimRecoVertex::SetStatus(), WCSimRecoVertex::SetVertex(), and vVertexList.

Referenced by RunPointFit1().

{
  // load vertex
  // ===========
  Double_t vtxX = myVertex->GetX();
  Double_t vtxY = myVertex->GetY();
  Double_t vtxZ = myVertex->GetZ();
  Double_t vtxTime = myVertex->GetTime();
    
  // current status
  // ==============
  Int_t status = myVertex->GetStatus();

  // create new vertex
  // =================
  WCSimRecoVertex* newVertex = new WCSimRecoVertex();
  vVertexList.push_back(newVertex);
  fSimpleDirection = newVertex;

  // loop over digits
  // ================
  Double_t Swx = 0.0;
  Double_t Swy = 0.0;
  Double_t Swz = 0.0;
  Double_t Sw = 0.0;

  for( Int_t idigit=0; idigit<fNdigits; idigit++ ){
    Double_t q = fDigitQ[idigit];

    Double_t dx = fDigitX[idigit] - vtxX;
    Double_t dy = fDigitY[idigit] - vtxY;
    Double_t dz = fDigitZ[idigit] - vtxZ;
    Double_t ds = sqrt(dx*dx+dy*dy+dz*dz);

    Double_t px = dx/ds;
    Double_t py = dy/ds;
    Double_t pz = dz/ds;

    Swx += q*px;
    Swy += q*py;
    Swz += q*pz;
    Sw += q;
  }

  // average direction
  // =================
  Double_t dirX = 0.0;
  Double_t dirY = 0.0;
  Double_t dirZ = 0.0;
  Double_t angle = 0.0;
  Double_t fom = 0.0;

  fItr = 0;
  fPass = 0; // pass/fail

  if( Sw>0.0 ){
    Double_t qx = Swx/Sw;
    Double_t qy = Swy/Sw;
    Double_t qz = Swz/Sw;
    Double_t qs = sqrt(qx*qx+qy*qy+qz*qz);

    dirX = qx/qs;
    dirY = qy/qs;
    dirZ = qz/qs;
    angle = 42.0;
    //fom = fBaseFOM;

    fItr = 1;
    fPass = 1; 
  }

  std::cout << "  simple direction = (" << dirX << "," << dirY << "," << dirZ << ") angle=" << angle << " fom=" << fom << std::endl;

  if( !fPass ) std::cout << "   <warning> simple direction calculation failed! " << std::endl;

  // set vertex and direction
  // ========================
  if( fPass ){
    newVertex->SetVertex(vtxX,vtxY,vtxZ,vtxTime);
    newVertex->SetDirection(dirX,dirY,dirZ,angle);
    newVertex->SetFOM(fom,fItr,fPass);
  }

  // set status
  // ==========
  if( !fPass ) status |= WCSimRecoVertex::kFailSimpleDirection;
  newVertex->SetStatus(status);

  // return vertex
  // =============
  return newVertex;
}

void WCSimVertexFinderPoint::FindSimpleTimeProperties ( Double_t &  vtime,
Double_t &  vtimerms 
)

Definition at line 1049 of file WCSimVertexFinderPoint.cc.

References fDelta, fDeltaDeweight, fDeltaWeight, and fNdigits.

Referenced by FitTimeProperties().

{
  // reset mean and rms
  // ================== 
  Double_t meanTime = 950.0;
  Double_t rmsTime = -99999.9;

  // calculate rms time
  // ==================
  Double_t Swx2 = 0.0;
  Double_t Swx = 0.0;
  Double_t Sw = 0.0;

  for( Int_t idigit=0; idigit<fNdigits; idigit++ ){
    Double_t delta = fDelta[idigit];
    Double_t weight = fDeltaWeight[idigit];
    Double_t deweight = fDeltaDeweight[idigit];

    Swx2 += deweight*weight*delta*delta;
    Swx += deweight*weight*delta;
    Sw += deweight*weight;
  }

  if( Sw>0.0 ){
    meanTime = Swx/Sw;
    rmsTime = sqrt( (Swx2/Sw)-(Swx/Sw)*(Swx/Sw) );
  }

  // return mean and rms
  // ===================
  vtxTime = meanTime;
  vtxTimeRms = rmsTime;

  return;
}

WCSimRecoVertex * WCSimVertexFinderPoint::FindSimpleVertex ( Double_t  vx,
Double_t  vy,
Double_t  vz 
)

Definition at line 301 of file WCSimVertexFinderPoint.cc.

References fBaseFOM, fItr, fPass, fSimpleVertex, WCSimRecoVertex::SetFOM(), WCSimRecoVertex::SetStatus(), WCSimRecoVertex::SetVertex(), and vVertexList.

Referenced by RunPointFit1().

{
  // simple vertex
  // =============
  // just calculate average position of digits

  // create new vertex
  // =================
  WCSimRecoVertex* newVertex = new WCSimRecoVertex();
  vVertexList.push_back(newVertex);
  fSimpleVertex = newVertex;

  Double_t vtxX = vX;
  Double_t vtxY = vY;
  Double_t vtxZ = vZ;
  Double_t vtxTime = 0.0;
  fItr = 1;
  fPass = 1;
  std::cout << "  simple vertex = (" << vtxX << "," << vtxY << "," << vtxZ << ") vtime=" << vtxTime << std::endl;

  // set vertex
  // ==========
  newVertex->SetVertex(vtxX,vtxY,vtxZ,vtxTime);
  newVertex->SetFOM(fBaseFOM,fItr,fPass);  
  

  // set status
  // ==========
  Int_t status = WCSimRecoVertex::kOK;
  if( !fPass ) status |= WCSimRecoVertex::kFailSimpleVertex;
  newVertex->SetStatus(status);

  // return vertex
  // =============
  return newVertex;
}

WCSimRecoVertex * WCSimVertexFinderPoint::FitPointVertex ( WCSimRecoEvent myEvent,
WCSimRecoVertex myVertex 
)

Definition at line 442 of file WCSimVertexFinderPoint.cc.

References FillArrays().

Referenced by RunPointFit1().

{  
  // set up arrays
  // =============
  this->FillArrays(myEvent);
  
  // reconstruct vertex
  // ==================
  return (WCSimRecoVertex*)(this->FitPointVertex(myVertex));
}

WCSimRecoVertex * WCSimVertexFinderPoint::FitPointVertex ( WCSimRecoVertex vertex  ) 

Definition at line 453 of file WCSimVertexFinderPoint.cc.

References FitPointVertexWithMinuitMatt().

{
  //return (WCSimRecoVertex*)(this->FitPointVertexWithMinuit(myVertex)); //for old fom
  return (WCSimRecoVertex*)(this->FitPointVertexWithMinuitMatt(myVertex)); //for new fom
}

WCSimRecoVertex * WCSimVertexFinderPoint::FitPointVertexWithMinuitMatt ( WCSimRecoVertex vertex  ) 

Definition at line 580 of file WCSimVertexFinderPoint.cc.

References AndyFOM(), fDirX, fDirY, fDirZ, ffakex, ffakey, ffakez, fItr, fMinuitPointVertex, WCSimRecoVertex::FoundVertex(), fPass, fPointVertex, WCSimRecoVertex::GetDirX(), WCSimRecoVertex::GetDirY(), WCSimRecoVertex::GetDirZ(), WCSimRecoVertex::GetStatus(), WCSimRecoVertex::GetTime(), WCSimRecoVertex::GetX(), WCSimRecoVertex::GetY(), WCSimRecoVertex::GetZ(), WCSimRecoVertex::SetDirection(), WCSimRecoVertex::SetFOM(), WCSimRecoVertex::SetStatus(), WCSimRecoVertex::SetVertex(), vertex_gaus_iterations(), vertex_gaus_reset_itr(), and vVertexList.

Referenced by FitPointVertex().

{  
  // initialization
  // ==============
  Double_t vtxX = 0.0;
  Double_t vtxY = 0.0;
  Double_t vtxZ = 0.0;
  Double_t vtxTime = 950.0; 

  Double_t dirX = 0.0;
  Double_t dirY = 0.0;
  Double_t dirZ = 0.0;
  Double_t angle = 0.0;

  Double_t vtxFOM = 0.0;

  // seed vertex
  // ===========
  Bool_t foundSeed = myVertex->FoundVertex();//check the vertex seed is existed?
  Double_t seedX = myVertex->GetX();
  Double_t seedY = myVertex->GetY();
  Double_t seedZ = myVertex->GetZ();
  Double_t seedT = myVertex->GetTime();

  fDirX = myVertex->GetDirX();
  fDirY = myVertex->GetDirY();
  fDirZ = myVertex->GetDirZ();
  ffakex = seedX - 100.0*fDirX;
  ffakey = seedY - 100.0*fDirY;
  ffakez = seedZ - 100.0*fDirZ;

  // current status
  // ==============
  Int_t status = myVertex->GetStatus();

  // reset counter
  // =============
  vertex_gaus_reset_itr(); 

  // create new vertex
  // =================
  WCSimRecoVertex* newVertex = new WCSimRecoVertex();
  vVertexList.push_back(newVertex);
  fPointVertex = newVertex;

  // abort if necessary
  // ==================
  if( foundSeed==0 ){
    std::cout << "   <warning> point vertex fit failed to find input vertex " << std::endl;    
    status |= WCSimRecoVertex::kFailPointVertex;
    newVertex->SetStatus(status);
    return newVertex;
  }

  // run Minuit
  // ==========  
  // three-parameter fit to vertex coordinates

  Int_t err = 0;
  Int_t flag = 0;

  Double_t fitXpos = 0.0;
  Double_t fitYpos = 0.0;
  Double_t fitZpos = 0.0;
  Double_t fitTime = 0.0;

  Double_t fitXposErr = 0.0;
  Double_t fitYposErr = 0.0;
  Double_t fitZposErr = 0.0;
  Double_t fitTimeErr = 0.0;
  //std::cout << "check the array is good: " << fDigitX[3] << std::endl; //array is good so far.

  Double_t* arglist = new Double_t[10];
  arglist[0]=1;  // 1: standard minimization
                 // 2: try to improve minimum

  // re-initialize everything...
  fMinuitPointVertex->mncler(); //call the minuit
  fMinuitPointVertex->SetFCN(vertex_gaus_chi2); //set the minimization function, what's this function, which is the function according to which data is fitted
  fMinuitPointVertex->mnexcm("SET STR",arglist,1,err); //don't understand...
  fMinuitPointVertex->mnparm(0,"x",seedX,2.0,(seedX-1000.0),(seedX+1000.0),err); //set the initial parameter of minimization
  fMinuitPointVertex->mnparm(1,"y",seedY,2.0,(seedY-1000.0),(seedY+1000.0),err);
  fMinuitPointVertex->mnparm(2,"z",seedZ,2.0,(seedZ-1000.0),(seedZ+1000.0),err);
  //fMinuitPointVertex->mnparm(3,"t",seedT,10,0.0,(seedT+200.0),err);

  flag = fMinuitPointVertex->Migrad();
  fMinuitPointVertex->GetParameter(0,fitXpos,fitXposErr);
  fMinuitPointVertex->GetParameter(1,fitYpos,fitYposErr);
  fMinuitPointVertex->GetParameter(2,fitZpos,fitZposErr);
  //fMinuitPointVertex->GetParameter(3,fitTime,fitTimeErr);

  delete [] arglist;

  // sort results
  // ============
  vtxX = fitXpos; 
  vtxY = fitYpos;
  vtxZ = fitZpos;
  vtxTime = fitTime;
  //std::cout << "fitted vtxX " << vtxX << "; seed vtxX: " << seedX << std::endl;

  vtxFOM = 0.0;
  
  fPass = 0;               // flag = 0: normal termination
  if( flag==0 ) fPass = 1; // anything else: abnormal termination 

  fItr = vertex_gaus_iterations();

  // calculate vertex?/fom?
  // ======================
  this->AndyFOM(vtxX,vtxY,vtxZ,vtxTime,vtxFOM);

  std::cout << "  fitted point vertex = (" << vtxX << "," << vtxY << "," << vtxZ << ") vtime=" << vtxTime << " fom=" << vtxFOM << " number of iteration=" << fItr << std::endl;

  if( !fPass ) std::cout << "   <warning> point vertex fit failed to converge! Error code: " << flag << std::endl;

  // set vertex and direction
  // ========================
  newVertex->SetVertex(vtxX,vtxY,vtxZ,vtxTime);
  newVertex->SetDirection(dirX,dirY,dirZ,angle);
  newVertex->SetFOM(vtxFOM,fItr,fPass); //fItr is the number of steps? why is it important??

  // set status
  // ==========
  if( !fPass ) status |= WCSimRecoVertex::kFailPointVertex;
  newVertex->SetStatus(status);

  // return vertex
  // =============  
  return newVertex;
}

void WCSimVertexFinderPoint::FitTimeProperties ( Double_t &  vtime,
Double_t &  chi2 
)

Definition at line 1085 of file WCSimVertexFinderPoint.cc.

References FindSimpleTimeProperties(), fMinuitTimeFit, and TimePropertiesChi2().

Referenced by PointVertexChi2().

{ 
  // calculate mean and rms
  // ====================== 
  Double_t meanTime = 950.0;
  Double_t rmsTime = -99999.9;

  this->FindSimpleTimeProperties(meanTime,rmsTime); 
  //std::cout << "vtxTime before fit " << meanTime << std::endl;

  // run Minuit
  // ==========  
  // three-parameter fit to vertex coordinates

  Int_t err = 0;
  Int_t flag = 0;

  Double_t seedTime = meanTime;
  seedTime = 50.453;
  Double_t fitTime = 0.0;
  Double_t fitTimeErr = 0.0;
  
  Double_t* arglist = new Double_t[10];
  arglist[0]=1;  // 1: standard minimization
                 // 2: try to improve minimum

  // re-initialize everything...
  fMinuitTimeFit->mncler();
  fMinuitTimeFit->SetFCN(vertex_time_chi2);
  fMinuitTimeFit->mnexcm("SET STR",arglist,1,err);
  fMinuitTimeFit->mnparm(0,"vtxTime",seedTime,50.0,0.0,2000.0,err);
  
  flag = fMinuitTimeFit->Migrad();
  fMinuitTimeFit->GetParameter(0,fitTime,fitTimeErr);
  // fitTime = meanTime; 
  // fitTimeErr = 0.0;
 
  delete [] arglist;


  // calculate figure of merit
  // =========================
  Double_t fom = -99999.9;
  //std::cout << "the fitted time got from FitTimeProperties: " << fitTime << std::endl;
  this->TimePropertiesChi2(fitTime,fom);  


  // return figure of merit
  // ======================
  vtxTime = fitTime;
  vtxFOM = fom;

  return;
}

Double_t WCSimVertexFinderPoint::FOMCalc ( WCSimRecoEvent myEvent,
Double_t  vX,
Double_t  vY,
Double_t  vZ,
Double_t  vT,
TH1D *  myTimeRes 
)

Definition at line 713 of file WCSimVertexFinderPoint.cc.

References AndyFOM(), and FillArrays().

{
  /*std::vector<WCSimRecoDigit*>* myDigitList = (std::vector<WCSimRecoDigit*>*)(myEvent->GetFilterDigitList());
  this->FillArrays(myDigitList);*/
  this->FillArrays(myEvent);
  return (Double_t)(this->AndyFOM(vX, vY, vZ, vT, myTimeRes));
  //std::cout << "digit2" << fDigitX[1] << " " << fDigitY[1] << " " << fDigitZ[1] << " " << fDigitT[1] << std::endl;
}

Double_t WCSimVertexFinderPoint::GetDelta ( Int_t  idigit  )  [inline]

Definition at line 72 of file WCSimVertexFinderPoint.hh.

References fDelta.

{ return fDelta[idigit]; } 

Double_t WCSimVertexFinderPoint::GetDeltaAngle ( Int_t  idigit  )  [inline]

Definition at line 73 of file WCSimVertexFinderPoint.hh.

References fDeltaAngle.

{ return fDeltaAngle[idigit]; } 

Double_t WCSimVertexFinderPoint::GetDeltaDeweight ( Int_t  idigit  )  [inline]

Definition at line 75 of file WCSimVertexFinderPoint.hh.

References fDeltaDeweight.

{ return fDeltaDeweight[idigit]; } 

Double_t WCSimVertexFinderPoint::GetDeltaPhoton ( Int_t  idigit  )  [inline]

Definition at line 71 of file WCSimVertexFinderPoint.hh.

References fDeltaPhoton.

{ return fDeltaPhoton[idigit]; } 

Double_t WCSimVertexFinderPoint::GetDeltaR ( Int_t  idigit  )  [inline]

Definition at line 69 of file WCSimVertexFinderPoint.hh.

References fDeltaR.

{ return fDeltaR[idigit]; } 

Double_t WCSimVertexFinderPoint::GetDeltaT ( Int_t  idigit  )  [inline]

Definition at line 68 of file WCSimVertexFinderPoint.hh.

References fDeltaT.

{ return fDeltaT[idigit]; }

Double_t WCSimVertexFinderPoint::GetDeltaTrack ( Int_t  idigit  )  [inline]

Definition at line 70 of file WCSimVertexFinderPoint.hh.

References fDeltaTrack.

{ return fDeltaTrack[idigit]; } 

Double_t WCSimVertexFinderPoint::GetDeltaWeight ( Int_t  idigit  )  [inline]

Definition at line 74 of file WCSimVertexFinderPoint.hh.

References fDeltaWeight.

{ return fDeltaWeight[idigit]; } 

Double_t WCSimVertexFinderPoint::GetDigitQ ( Int_t  idigit  )  [inline]

Definition at line 63 of file WCSimVertexFinderPoint.hh.

References fDigitQ.

{ return fDigitQ[idigit]; }

Double_t WCSimVertexFinderPoint::GetDigitT ( Int_t  idigit  )  [inline]

Definition at line 62 of file WCSimVertexFinderPoint.hh.

References fDigitT.

{ return fDigitT[idigit]; }

Double_t WCSimVertexFinderPoint::GetDigitX ( Int_t  idigit  )  [inline]

Definition at line 59 of file WCSimVertexFinderPoint.hh.

References fDigitX.

{ return fDigitX[idigit]; }

Double_t WCSimVertexFinderPoint::GetDigitY ( Int_t  idigit  )  [inline]

Definition at line 60 of file WCSimVertexFinderPoint.hh.

References fDigitY.

{ return fDigitY[idigit]; }

Double_t WCSimVertexFinderPoint::GetDigitZ ( Int_t  idigit  )  [inline]

Definition at line 61 of file WCSimVertexFinderPoint.hh.

References fDigitZ.

{ return fDigitZ[idigit]; }

Double_t WCSimVertexFinderPoint::GetDistAngle ( Int_t  idigit  )  [inline]

Definition at line 64 of file WCSimVertexFinderPoint.hh.

References fDistAngle.

{ return fDistAngle[idigit]; }

Double_t WCSimVertexFinderPoint::GetDistPhoton ( Int_t  idigit  )  [inline]

Definition at line 67 of file WCSimVertexFinderPoint.hh.

References fDistPhoton.

{ return fDistPhoton[idigit]; }

Double_t WCSimVertexFinderPoint::GetDistPoint ( Int_t  idigit  )  [inline]

Definition at line 65 of file WCSimVertexFinderPoint.hh.

References fDistPoint.

{ return fDistPoint[idigit]; }

Double_t WCSimVertexFinderPoint::GetDistTrack ( Int_t  idigit  )  [inline]

Definition at line 66 of file WCSimVertexFinderPoint.hh.

References fDistTrack.

{ return fDistTrack[idigit]; }

WCSimRecoVertex* WCSimVertexFinderPoint::GetExtendedVertex (  )  [inline]

Definition at line 82 of file WCSimVertexFinderPoint.hh.

References fExtendedVertex.

{ return fExtendedVertex; }

Int_t WCSimVertexFinderPoint::GetIterations (  )  [inline]

Definition at line 102 of file WCSimVertexFinderPoint.hh.

References fItr.

{ return fItr; }

Int_t WCSimVertexFinderPoint::GetNDigits (  )  [inline]

Definition at line 58 of file WCSimVertexFinderPoint.hh.

References fNdigits.

{ return fNdigits; }

WCSimRecoVertex* WCSimVertexFinderPoint::GetPointDirection (  )  [inline]

Definition at line 81 of file WCSimVertexFinderPoint.hh.

References fPointDirection.

{ return fPointDirection; }

WCSimRecoVertex* WCSimVertexFinderPoint::GetPointVertex (  )  [inline]

Definition at line 80 of file WCSimVertexFinderPoint.hh.

References fPointVertex.

{ return fPointVertex; }

WCSimRecoVertex* WCSimVertexFinderPoint::GetSimpleDirection (  )  [inline]

Definition at line 79 of file WCSimVertexFinderPoint.hh.

References fSimpleDirection.

{ return fSimpleDirection; }

WCSimRecoVertex* WCSimVertexFinderPoint::GetSimpleVertex (  )  [inline]

Definition at line 78 of file WCSimVertexFinderPoint.hh.

References fSimpleVertex.

{ return fSimpleVertex; }

void WCSimVertexFinderPoint::GlbPeakGeo ( Double_t *  trV,
Double_t *  dir,
Double_t *  ftV,
Double_t &  fopenangle,
Double_t &  fD,
Double_t &  fd 
)

Definition at line 1279 of file WCSimVertexFinderPoint.cc.

References WCSimMathUtil::DotProduct(), WCSimMathUtil::Magnitude(), and WCSimMathUtil::SubtractVec().

{
  Double_t Sub1[3];
  WCSimMathUtil::SubtractVec(ftV,trV,Sub1);
  Double_t prod1 = WCSimMathUtil::DotProduct(dir,Sub1);
  Double_t prod2 = WCSimMathUtil::DotProduct(Sub1,Sub1);
  fopenangle = acos(prod1/sqrt(prod2));
  fD = WCSimMathUtil::Magnitude(ftV,trV);
  fd = fD*sin(fopenangle);

  return;

}

WCSimVertexFinderPoint * WCSimVertexFinderPoint::Instance (  )  [static]

Definition at line 90 of file WCSimVertexFinderPoint.cc.

References WCSimVertexFinderPoint().

Referenced by PenaltyChi2(), PenaltyChi2Matt(), and PrintParameters().

{
  if( !fgVertexFinder ){
    fgVertexFinder = new WCSimVertexFinderPoint();
  }

  if( !fgVertexFinder ){
    assert(fgVertexFinder);
  }

  if( fgVertexFinder ){

  }

  return fgVertexFinder;
}

Double_t WCSimVertexFinderPoint::Openagl ( Double_t  vx,
Double_t  vy,
Double_t  vz,
Double_t  dirx,
Double_t  diry,
Double_t  dirz,
WCSimRecoEvent myEvent 
)

Definition at line 1309 of file WCSimVertexFinderPoint.cc.

References fDigitX, fDigitY, fDigitZ, FillArrays(), and fNdigits.

{ 
  this->FillArrays(myEvent);
  Double_t fangle = 0.0;
  for( Int_t idigit=0; idigit<fNdigits; idigit++ ){
  
  Double_t dx = fDigitX[idigit]-vx;
  Double_t dy = fDigitY[idigit]-vy;
  Double_t dz = fDigitZ[idigit]-vz;
  Double_t ds = sqrt(dx*dx+dy*dy+dz*dz);
  fangle += acos((dirx*dx + diry*dy + dirz*dz)/ds);
  }
  fangle = fangle*180/(TMath::Pi()*fNdigits);
  return (fangle);

}

void WCSimVertexFinderPoint::PenaltyChi2 ( Double_t  vtxX,
Double_t  vtxY,
Double_t  vtxZ,
Double_t &  chi2 
)

Definition at line 1200 of file WCSimVertexFinderPoint.cc.

References WCSimGeometry::DistanceToEdge(), fBaseFOM, WCSimGeometry::InsideDetector(), and Instance().

{  
  // default penalty
  // ===============
  Double_t deltaChi2 = 0;
  Double_t deltaR = 0.;

  // check vertex position
  // =====================
  WCSimGeometry* fGeometryHandle = WCSimGeometry::Instance();
  Bool_t inDetector = fGeometryHandle->InsideDetector(vtxX,vtxY,vtxZ);//should it be inside the loop or outside the loop?
  if( inDetector==0 ){
    
    deltaR = fGeometryHandle->DistanceToEdge(vtxX,vtxY,vtxZ);  // [cm]
    Double_t deltaRbase = 500.0; // [cm]
 
    deltaChi2 += -fBaseFOM*(deltaR/deltaRbase)*(deltaR/deltaRbase);
  }
  //std::cout << "distancetoedge: " << deltaR << "; deltaChi2: " << deltaChi2 << std::endl;
  
  // return penalty
  // ==============
  chi2 = deltaChi2;

  return;
}

void WCSimVertexFinderPoint::PenaltyChi2Matt ( Double_t  vx,
Double_t  vy,
Double_t  vz,
Double_t &  chi2 
)

Definition at line 1227 of file WCSimVertexFinderPoint.cc.

References fBaseFOM, fsign, and Instance().

Referenced by PointVertexChi2().

{  
  // default penalty
  // ===============
  Double_t deltaChi2 = 0;
  Double_t deltaR = 0.;
//  Double_t coef = 0.0;
  Double_t coef = 0.000000030;

  // check vertex position
  // =====================
  WCSimGeometry* fGeometryHandle = WCSimGeometry::Instance();

  deltaR = fGeometryHandle->DistanceToEdgeMatt(vtxX,vtxY,vtxZ);  // [cm]
  Double_t deltaRbase = 500.0; // [cm]
 
  deltaChi2 += -fsign*fBaseFOM*coef*deltaR*deltaR;
  //std::cout << "distancetoedge: " << deltaR << "; deltaChi2: " << deltaChi2 << std::endl;
  
  // return penalty
  // ==============
  chi2 = deltaChi2;

  return;
}

void WCSimVertexFinderPoint::PenaltyChi2Matt2 ( Double_t  vx,
Double_t  vy,
Double_t  vz,
Double_t &  chi2 
)

Definition at line 1253 of file WCSimVertexFinderPoint.cc.

References fDirX, fDirY, fDirZ, ffakex, ffakey, and ffakez.

Referenced by AndyFOM().

{  
  // default penalty
  // ===============
  Double_t deltaChi2 = 0.;
  Double_t devx = 0.;
  Double_t devy = 0.;
  Double_t devz = 0.;
  if( fDirX>=0. && fDirX<=0.3 ) devx = fDirX*666.7;
  else devx = fDirX*171.4;
  if( fDirY>=0. && fDirY<=0.3 ) devy = fDirX*666.7;
  else devy = fDirY*171.4;
  if( fDirZ>=0. && fDirZ<=0.3 ) devz = fDirZ*333.4;
  else { if( fDirZ>0.3 && fDirZ<=0.4 ) devz = fDirZ*500.0;
         else devz = fDirZ*1000.0;}
  Double_t fBASE = 16.0;

  deltaChi2 += -fBASE*( ((vtxX-ffakex)*(vtxX-ffakex))/(devx*devx) + ((vtxY-ffakey)*(vtxY-ffakey))/(devy*devy) + ((vtxZ-ffakez)*(vtxZ-ffakez))/(devz*devz) );
  
  // return penalty
  // ==============
  chi2 = deltaChi2;

  return;
}

Int_t WCSimVertexFinderPoint::point_vertex_iterations (  )  [inline]

Definition at line 110 of file WCSimVertexFinderPoint.hh.

References fPointVtxItr.

{ return fPointVtxItr; }

void WCSimVertexFinderPoint::point_vertex_itr (  )  [inline]

Definition at line 104 of file WCSimVertexFinderPoint.hh.

References fPointVtxItr.

{ fPointVtxItr++; }

void WCSimVertexFinderPoint::point_vertex_reset_itr (  )  [inline]

Definition at line 107 of file WCSimVertexFinderPoint.hh.

References fPointVtxItr.

{ fPointVtxItr = 0; }

void WCSimVertexFinderPoint::PointResiduals ( Double_t  vx,
Double_t  vy,
Double_t  vz 
)

Definition at line 988 of file WCSimVertexFinderPoint.cc.

References fDelta, fDeltaAngle, fDeltaDeweight, fDeltaPhoton, fDeltaR, fDeltaT, fDeltaTrack, fDeltaWeight, fDigitQ, fDigitT, fDigitX, fDigitY, fDigitZ, fNdigits, WCSimParameters::RefractiveIndex(), WCSimParameters::SpeedOfLight(), and WCSimParameters::TimeResolution().

Referenced by PointVertexChi2().

{
  // clear arrays
  // ============
  if( fDelta  ) delete [] fDelta;
  if( fDeltaAngle  ) delete [] fDeltaAngle;
  if( fDeltaWeight ) delete [] fDeltaWeight;
  if( fDeltaDeweight ) delete [] fDeltaDeweight;

  if( fDeltaT ) delete [] fDeltaT;
  if( fDeltaR ) delete [] fDeltaR;
  if( fDeltaTrack ) delete [] fDeltaTrack;
  if( fDeltaPhoton ) delete [] fDeltaPhoton;

  // make new arrays
  // ===============
  fDelta = new Double_t[fNdigits];
  fDeltaAngle = new Double_t[fNdigits];
  fDeltaWeight = new Double_t[fNdigits];
  fDeltaDeweight = new Double_t[fNdigits];

  fDeltaT = new Double_t[fNdigits];
  fDeltaR = new Double_t[fNdigits];
  fDeltaTrack = new Double_t[fNdigits];
  fDeltaPhoton = new Double_t[fNdigits];

  // calculate residuals (assuming point vertex)
  // ===========================================
  for( Int_t idigit=0; idigit<fNdigits; idigit++ ){
    Double_t dx = fDigitX[idigit]-vtxX;
    Double_t dy = fDigitY[idigit]-vtxY;
    Double_t dz = fDigitZ[idigit]-vtxZ;
    Double_t ds = sqrt(dx*dx+dy*dy+dz*dz);       

    Double_t Lphoton = ds;//the length of photon as well as the wavelength of the photon, why??

    Double_t fC = WCSimParameters::SpeedOfLight();
    Double_t fN = WCSimParameters::RefractiveIndex(Lphoton);//the index looks not right

    Double_t dt = fDigitT[idigit];
    Double_t delta = dt - Lphoton/(fC/fN);

    Double_t qpes = fDigitQ[idigit];
    Double_t res = WCSimParameters::TimeResolution(qpes);
    Double_t weight = 1.0/(res*res);

    fDeltaT[idigit] = dt;
    fDeltaR[idigit] = Lphoton/(fC/fN);
    fDeltaTrack[idigit] = 0.0;
    fDeltaPhoton[idigit] = Lphoton/(fC/fN);

    fDelta[idigit] = delta;
    fDeltaAngle[idigit] = -45.0;
    fDeltaWeight[idigit] = weight;   
    fDeltaDeweight[idigit] = 1.0;   
    //std::cout << "refractive index: " << fN << std::endl;
  }       
  
  return;
}

void WCSimVertexFinderPoint::PointVertexChi2 ( Double_t &  vt,
Double_t &  chi2 
)

Definition at line 877 of file WCSimVertexFinderPoint.cc.

References FitTimeProperties().

{
  // just return RMS of distribution
  // ===============================
  // this->FindSimpleTimeProperties(vtxTime,fom); fom = -fom;

  // improved figure of merit
  // ========================
  this->FitTimeProperties(vtxTime,fom);

  return;
}

void WCSimVertexFinderPoint::PointVertexChi2 ( Double_t  vx,
Double_t  vy,
Double_t  vz,
Double_t &  vt,
Double_t &  chi2 
)

Definition at line 842 of file WCSimVertexFinderPoint.cc.

References PenaltyChi2Matt(), and PointResiduals().

{  
  // check vertex position
  // =====================
  // moved to PenaltyChi2(...)

  // figure of merit
  // ===============
  Double_t vtxFOM = 0.0;
  Double_t penaltyFOM = 0.0;

  // calculate residuals
  // ===================
  this->PointResiduals(vtxX,vtxY,vtxZ);

  // calculate figure of merit
  // =========================
  this->PointVertexChi2(vtxTime,vtxFOM);

  // calculate penalty
  // =================
  //this->PenaltyChi2(vtxX,vtxY,vtxZ,penaltyFOM); //general case
  this->PenaltyChi2Matt(vtxX,vtxY,vtxZ,penaltyFOM); //just for Matt's samples
 
  penaltyFOM = 0.0; //only for modified Andy's fom function
  // calculate overall figure of merit
  // =================================
  fom = vtxFOM + penaltyFOM;

  // truncate
  if( fom<-99999.9 ) fom = -99999.9;

  return;
}

void WCSimVertexFinderPoint::PrintParameters (  )  [static]
void WCSimVertexFinderPoint::Reset (  ) 

Definition at line 231 of file WCSimVertexFinderPoint.cc.

References Clear().

{
  this->Clear();

  return;
}

WCSimRecoVertex * WCSimVertexFinderPoint::RunPointFit1 ( WCSimRecoEvent myEvent,
Double_t  vx,
Double_t  vy,
Double_t  vz 
)

Definition at line 257 of file WCSimVertexFinderPoint.cc.

References FindSimpleDirection(), FindSimpleVertex(), and FitPointVertex().

{
  // get filter digit list
  // =====================
  WCSimRecoVertex* simpleVtx = (WCSimRecoVertex*)(this->FindSimpleVertex(vtxX, vtxY, vtxZ));
  simpleVtx = (WCSimRecoVertex*)(this->FindSimpleDirection(simpleVtx));
  WCSimRecoVertex* pointVtx  = (WCSimRecoVertex*)(this->FitPointVertex(myEvent,simpleVtx));
  
  // return vertex
  // =============
  return pointVtx;
}

void WCSimVertexFinderPoint::RunPrintParameters (  ) 

Definition at line 220 of file WCSimVertexFinderPoint.cc.

References fBaseFOM, and fConeEdgeDegrees.

Referenced by PrintParameters().

{
  std::cout << " *** WCSimVertexFinder::PrintParameters() *** " << std::endl;

  std::cout << "  Vertex Finder Parameters: " << std::endl
            << "   ConeEdgeDegrees = " << fConeEdgeDegrees << std::endl
            << "   BaseFOM = " << fBaseFOM << std::endl;

  return;
}

void WCSimVertexFinderPoint::SetConeEdge ( Double_t  degrees  )  [inline]

Definition at line 24 of file WCSimVertexFinderPoint.hh.

References fConeEdgeDegrees.

{ fConeEdgeDegrees = degrees; }

void WCSimVertexFinderPoint::TimePropertiesChi2 ( Double_t  vtime,
Double_t &  chi2 
)

Definition at line 1140 of file WCSimVertexFinderPoint.cc.

References fDelta, fDeltaDeweight, fDeltaWeight, and fNdigits.

Referenced by FitTimeProperties().

{ 
  // calculate figure of merit
  // =========================
  Double_t Swx = 0.0;
  Double_t Sw = 0.0; 
  Double_t S = 0.0;

  Double_t delta = 0.0;
  Double_t sumdelta = 0.0;
  Double_t delta0 = 0.0;
  Double_t weight = 0.0;
  Double_t deweight = 0.0;
  Double_t penalty = 0.05;
  Double_t sigma = 0.;

  Double_t fom = 0.0;
//==========================================================================
//original fom
    /*Double_t meanres = 2.5;       // nominal timing resolution (ns)
    Double_t sigma = 1.5*meanres; // could also use fMeanRes = TimeResolution(fMeanQ) (ns)
    for( Int_t idigit=0; idigit<fNdigits; idigit++ ){
    delta = fDelta[idigit] - vtxTime;
    weight = fDeltaWeight[idigit];
    deweight = fDeltaDeweight[idigit];
 
    Swx += deweight*weight*(exp(-(delta*delta)/(2.0*sigma*sigma))-penalty);
    Sw  += deweight*weight;
    S   += weight;
  }

  if( Sw>0.0 ){
    fom += 0.9*fBaseFOM*Swx/Sw; // from timing, how is the baseFOM defined
  }

  if( S>0.0 ){
    fom += 0.1*fBaseFOM*Sw/S;   // from direction
  }*/

//==========================================================================
//modified Andy's fom
  sigma = 3.6;
  for( Int_t idigit=0; idigit<fNdigits; idigit++ ){
    sumdelta += fDelta[idigit] - vtxTime;
  }
  delta0 = sumdelta/fNdigits;


  for( Int_t idigit=0; idigit<fNdigits; idigit++ ){
    delta = fDelta[idigit] - vtxTime;
    weight = fDeltaWeight[idigit];
    deweight = fDeltaDeweight[idigit];
 
    fom += 0.25*(exp(-((delta-delta0)*(delta-delta0))/(2.0*sigma*sigma)));
  }
  // return figure of merit
  // ======================
  vtxFOM = fom;
}

Double_t WCSimVertexFinderPoint::TrackL ( Double_t  vx,
Double_t  vy,
Double_t  vz,
Double_t  dirx,
Double_t  diry,
Double_t  dirz 
)

Definition at line 1293 of file WCSimVertexFinderPoint.cc.

{  
  Double_t ftrkL = 0.0;
  Double_t newX = vx;
  Double_t newY = vy;
  Double_t newZ = vz;
  while( ((sqrt(newX*newX+newY*newY))<2750.) && (newZ<3200.) && (newZ>-3200.) ){
    newX += dirx;
    newY += diry;
    newZ += dirz;
    ftrkL += 1.0;
  }
  return ftrkL;

}

Int_t WCSimVertexFinderPoint::vertex_gaus_iterations (  )  [inline]

Definition at line 111 of file WCSimVertexFinderPoint.hh.

References fPointVtxItr.

Referenced by FitPointVertexWithMinuitMatt().

{ return fPointVtxItr; }

void WCSimVertexFinderPoint::vertex_gaus_itr (  )  [inline]

Definition at line 105 of file WCSimVertexFinderPoint.hh.

References fPointVtxItr.

{ fPointVtxItr++; }

void WCSimVertexFinderPoint::vertex_gaus_reset_itr (  )  [inline]

Definition at line 108 of file WCSimVertexFinderPoint.hh.

References fPointVtxItr.

Referenced by FitPointVertexWithMinuitMatt().

{ fPointVtxItr = 0; }


Member Data Documentation

Double_t* WCSimVertexFinderPoint::fAngle [private]

Definition at line 167 of file WCSimVertexFinderPoint.hh.

Referenced by WCSimVertexFinderPoint(), and ~WCSimVertexFinderPoint().

Definition at line 169 of file WCSimVertexFinderPoint.hh.

Referenced by WCSimVertexFinderPoint(), and ~WCSimVertexFinderPoint().

Definition at line 168 of file WCSimVertexFinderPoint.hh.

Referenced by WCSimVertexFinderPoint(), and ~WCSimVertexFinderPoint().

Double_t* WCSimVertexFinderPoint::fDelta [private]
Double_t* WCSimVertexFinderPoint::fDeltaR [private]
Double_t* WCSimVertexFinderPoint::fDeltaT [private]
Double_t* WCSimVertexFinderPoint::fDigitQ [private]
Double_t* WCSimVertexFinderPoint::fDigitT [private]
Double_t* WCSimVertexFinderPoint::fDigitX [private]
Double_t* WCSimVertexFinderPoint::fDigitY [private]
Double_t* WCSimVertexFinderPoint::fDigitZ [private]

Definition at line 200 of file WCSimVertexFinderPoint.hh.

Definition at line 197 of file WCSimVertexFinderPoint.hh.

Referenced by FitPointVertexWithMinuitMatt(), and PenaltyChi2Matt2().

Definition at line 198 of file WCSimVertexFinderPoint.hh.

Referenced by FitPointVertexWithMinuitMatt(), and PenaltyChi2Matt2().

Definition at line 199 of file WCSimVertexFinderPoint.hh.

Referenced by FitPointVertexWithMinuitMatt(), and PenaltyChi2Matt2().

Definition at line 175 of file WCSimVertexFinderPoint.hh.

Referenced by Clear(), GetExtendedVertex(), and WCSimVertexFinderPoint().

Definition at line 186 of file WCSimVertexFinderPoint.hh.

Definition at line 201 of file WCSimVertexFinderPoint.hh.

Referenced by FitPointVertexWithMinuitMatt(), and PenaltyChi2Matt2().

Definition at line 202 of file WCSimVertexFinderPoint.hh.

Referenced by FitPointVertexWithMinuitMatt(), and PenaltyChi2Matt2().

Definition at line 203 of file WCSimVertexFinderPoint.hh.

Referenced by FitPointVertexWithMinuitMatt(), and PenaltyChi2Matt2().

Definition at line 141 of file WCSimVertexFinderPoint.hh.

Definition at line 138 of file WCSimVertexFinderPoint.hh.

Definition at line 139 of file WCSimVertexFinderPoint.hh.

Definition at line 140 of file WCSimVertexFinderPoint.hh.

Definition at line 143 of file WCSimVertexFinderPoint.hh.

Definition at line 136 of file WCSimVertexFinderPoint.hh.

Definition at line 133 of file WCSimVertexFinderPoint.hh.

Definition at line 134 of file WCSimVertexFinderPoint.hh.

Definition at line 135 of file WCSimVertexFinderPoint.hh.

Double_t WCSimVertexFinderPoint::fMeanQ [private]

Definition at line 128 of file WCSimVertexFinderPoint.hh.

Referenced by FillArrays(), and WCSimVertexFinderPoint().

Definition at line 129 of file WCSimVertexFinderPoint.hh.

Referenced by FillArrays(), and WCSimVertexFinderPoint().

Definition at line 179 of file WCSimVertexFinderPoint.hh.

Referenced by WCSimVertexFinderPoint(), and ~WCSimVertexFinderPoint().

Definition at line 180 of file WCSimVertexFinderPoint.hh.

Referenced by WCSimVertexFinderPoint(), and ~WCSimVertexFinderPoint().

Definition at line 178 of file WCSimVertexFinderPoint.hh.

Referenced by WCSimVertexFinderPoint(), and ~WCSimVertexFinderPoint().

Definition at line 174 of file WCSimVertexFinderPoint.hh.

Referenced by Clear(), GetPointDirection(), and WCSimVertexFinderPoint().

Definition at line 185 of file WCSimVertexFinderPoint.hh.

Double_t WCSimVertexFinderPoint::fsign [private]

Definition at line 160 of file WCSimVertexFinderPoint.hh.

Referenced by AndyFOM(), and PenaltyChi2Matt().

Definition at line 205 of file WCSimVertexFinderPoint.hh.

Definition at line 195 of file WCSimVertexFinderPoint.hh.

Definition at line 192 of file WCSimVertexFinderPoint.hh.

Referenced by WCSimVertexFinderPoint().

Definition at line 193 of file WCSimVertexFinderPoint.hh.

Referenced by WCSimVertexFinderPoint().

Definition at line 194 of file WCSimVertexFinderPoint.hh.

Referenced by WCSimVertexFinderPoint().


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