Skip to content
Snippets Groups Projects
THcDC.cxx 39.9 KiB
Newer Older
  • Learn to ignore specific revisions
  • 	      if(fFixPropagationCorrection) {
    		coord = hit->GetPos()
    		  + hit->GetLR()*theDCTrack1->GetHitDist(ihit);
    	      } else {
    		coord = hit->GetCoord();
    	      }
    	    }
    	    theDCTrack2->SetDoubleResidual(plane,coord - pos);
    
    	    //  hdc_dbl_res(pln) = hdc_double_residual(1,pln)  for hists
    	  }
    	}
          }
        }
      }
    
        Double_t chi_max=1000000;
    
        for (UInt_t itrack = 0; itrack < fNDCTracks; itrack++) {
          //for(Int_t ip=0;ip<fNPlanes;ip++) {
          THcDCTrack *theDCTrack = static_cast <THcDCTrack*> (fDCTracks->At(itrack));
    
    	if (theDCTrack->GetChisq() < chi_max) {
                chi_max = theDCTrack->GetChisq();
             for (UInt_t ihit = 0; ihit < UInt_t (theDCTrack->GetNHits()); ihit++) {
    
    	//fResiduals[ip] = theDCTrack->GetResidual(ip);
    	THcDCHit *hit = theDCTrack->GetHit(ihit);
    	Int_t plane = hit->GetPlaneNum() - 1;
    	// fResiduals[ip] = theDCTrack->GetResidual(ip);
    
                 fResiduals[plane] = theDCTrack->GetResidual(plane);
     	}
    	//	cout << "track = " << itrack+1 << "plane = " << plane << ", fResiduals[plane] = " << fResiduals[plane] << "chi =  "  << theDCTrack->GetChisq()<< endl;
    
      //
          if (fdebugtrackprint) {
            printf("%5s %-14s %-14s %-14s %-14s  %-10s %-10s \n","Track","x_t","y_t","xp_t","yp_t","chi2","DOF");
            printf("%5s %-14s %-14s %-14s %-14s  %-10s %-10s \n","     ","[cm]","[cm]","[rad]","[rad]"," "," ");
    
    	for(UInt_t itr=0;itr < fNDCTracks;itr++) {
    
            THcDCTrack *theDCTrack = static_cast<THcDCTrack*>( fDCTracks->At(itr));
    	printf("%-5d %14.6e %14.6e %14.6e %14.6e %10.3e %3d \n", itr+1,theDCTrack->GetX(),theDCTrack->GetY(),theDCTrack->GetXP(),theDCTrack->GetYP(),theDCTrack->GetChisq(),theDCTrack->GetNFree());
            }
    
    	for(UInt_t itr=0;itr < fNDCTracks;itr++) {
    
    	  printf("%s %5d \n","Hit info for track number = ",itr+1);
              printf("%5s %-15s %-15s %-15s \n","Plane","WIRE_COORD","Fit postiion","Residual");
             THcDCTrack *theDCTrack = static_cast<THcDCTrack*>( fDCTracks->At(itr));
    	 for(Int_t ihit=0;ihit < theDCTrack->GetNHits();ihit++) {
    	  THcDCHit* hit=theDCTrack->GetHit(ihit);
    	  Int_t plane=hit->GetPlaneNum()-1;
    	  Double_t coords_temp;
          if(fFixLR) {
    	if(fFixPropagationCorrection) {
    	  coords_temp = hit->GetPos()
    	    + theDCTrack->GetHitLR(ihit)*theDCTrack->GetHitDist(ihit);
    	} else {
    	  coords_temp = hit->GetPos()
    	    + theDCTrack->GetHitLR(ihit)*hit->GetDist();
    	}
          } else {
    	if(fFixPropagationCorrection) {
    	  coords_temp = hit->GetPos()
    	    + hit->GetLR()*theDCTrack->GetHitDist(ihit);
    	} else {
    	  coords_temp = hit->GetCoord();
    	}
          }
          printf("%-5d %15.7e %15.7e %15.7e \n",plane+1,coords_temp,theDCTrack->GetCoord(plane),theDCTrack->GetResidual(plane));
    	 }
            }
          }
    
      //
    
    Double_t THcDC::DpsiFun(Double_t ray[4], Int_t plane)
    {
      /*
        this function calculates the psi coordinate of the intersection
        of a ray (defined by ray) with a hms wire chamber plane. the geometry
        of the plane is contained in the coeff array calculated in the
        array hplane_coeff
        Note it is call by MINUIT via H_FCNCHISQ and so uses double precision
        variables
    
        the ray is defined by
        x = (z-zt)*tan(xp) + xt
        y = (z-zt)*tan(yp) + yt
         at some fixed value of zt*
        ray(1) = xt
        ray(2) = yt
        ray(3) = tan(xp)
        ray(4) = tan(yp)
      */
    
      Double_t infinity = 1.0E+20;
      Double_t cinfinity = 1/infinity;
    
        ray[2]*ray[1]*fPlaneCoeffs[plane][0] +
        ray[3]*ray[0]*fPlaneCoeffs[plane][1] +
        ray[2]*fPlaneCoeffs[plane][2] +
        ray[3]*fPlaneCoeffs[plane][3] +
        ray[0]*fPlaneCoeffs[plane][4] +
        ray[1]*fPlaneCoeffs[plane][5];
      Double_t denom = ray[2]*fPlaneCoeffs[plane][6]
        + ray[3]*fPlaneCoeffs[plane][7]
        + fPlaneCoeffs[plane][8];
      if(TMath::Abs(denom) < cinfinity) {
        DpsiFun = infinity;
    
        DpsiFun = DpsiFun/denom;
      }
      return(DpsiFun);
    
    //_____________________________________________________________________________
    Int_t THcDC::End(THaRunBase* run)
    {
      //  EffCalc();
    
    }
    
    //_____________________________________________________________________________
    void THcDC::EffInit()
    {
      // Create, and initialize counters used to calculate
      // efficiencies.  Register the counters in gHcParms so that the
      // variables can be used in end of run reports.
    
    
      delete [] fNChamHits; fNChamHits = new Int_t [fNChambers];
    
      delete [] fPlaneEvents; fPlaneEvents = new Int_t [fNPlanes];
    
      for(UInt_t i=0;i<fNChambers;i++) {
    
      for(Int_t i=0;i<fNPlanes;i++) {
    
        fPlaneEvents[i] = 0;
    
      }
      gHcParms->Define(Form("%sdc_tot_events",fPrefix),"Total DC Events",fTotEvents);
      gHcParms->Define(Form("%sdc_cham_hits[%d]",fPrefix,fNChambers),"N events with hits per chamber",*fNChamHits);
    
      gHcParms->Define(Form("%sdc_events[%d]",fPrefix,fNPlanes),"N events with hits per plane",*fPlaneEvents);
    
    }
    
    //_____________________________________________________________________________
    void THcDC::Eff()
    {
      // Accumulate statistics for efficiency calculations
    
      fTotEvents++;
    
      for(UInt_t i=0;i<fNChambers;i++) {
    
        if(fChambers[i]->GetNHits()>0) fNChamHits[i]++;
      }
    
      for(Int_t i=0;i<fNPlanes;i++) {
    
        if(fPlanes[i]->GetNHits() > 0) fPlaneEvents[i]++;
    
    ClassImp(THcDC)
    ////////////////////////////////////////////////////////////////////////////////