Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

PSFtailCuts.cxx

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/merit/src/PSFtailCuts.cxx,v 1.3 2001/10/31 17:04:08 usher Exp $
00002 // PSFtailCuts.cxx: implementation of the PSFtailCuts class.
00003 //
00005 
00006 #include "PSFtailCuts.h"
00007 #include "Cut.h"
00008 #include <strstream>
00009 #include <cmath>
00010 //=============================================================================
00011 class AbsValueCut : public Analyze {
00012     friend class PSFtailCuts;
00013     AbsValueCut(const Tuple& t, const std::string& name, double value)
00014         : Analyze(t,name)
00015         , m_value(value)
00016     {
00017         std::strstream label;
00018         label << "abs(" << name << ")<" << value << '\0';
00019         set_name(std::string(label.str()));
00020     }
00021 
00022     virtual bool apply() {
00023         return fabs(item()) < m_value;
00024     }
00025     double m_value;
00026 };
00027 
00028 
00029 //This function calculates the energy/angle dependent cut for FitKink and Tangle
00030 static float kalError(float kalEne, int kplane, float cosz) 
00031 {
00032         if (kalEne <0) return 1e6;
00033 
00034     //Convert from MeV to GeV for calculation
00035     kalEne *= 0.001;
00036 
00037     //Calculate the cut value depending on top or bottom
00038     float kalFit;
00039 
00040     if (kplane  < 12) kalFit = (2.8 /kalEne) + (2.1 /sqrt(kalEne));
00041     else              kalFit = kalFit = (6.35/kalEne) + (3.75/sqrt(kalEne));
00042 
00043     kalFit = - (0.001*kalFit) / cosz;
00044 
00045     return 3.5 * kalFit;
00046 }
00047 
00048 
00049 class FitKinkCut : public Analyze
00050 {
00051     friend class PSFtailCuts;
00052 
00053     FitKinkCut(const Tuple& t) : Analyze(t, "TKR_Fit_Kink", "Tracker Fit Kink"),
00054                                  m_CalEne  (t.tupleItem("Cal_Energy_Deposit")),
00055                                  m_1stPlane(t.tupleItem("TKR_First_XHit")),
00056                                  m_cosTheta(t.tupleItem("TKR_Gamma_zdir"))
00057     { }
00058 
00059     virtual bool apply()
00060     {
00061         float fitKink = item();
00062         float calEne  = *m_CalEne;
00063         int   frstLyr = *m_1stPlane;
00064         float cosZ    = *m_cosTheta;
00065 
00066         return fabs(fitKink) <= kalError(calEne, frstLyr, cosZ);
00067     }
00068 
00069     const TupleItem* m_CalEne;
00070     const TupleItem* m_1stPlane;
00071     const TupleItem* m_cosTheta;
00072 };
00073 
00074 class TAngleCut : public Analyze
00075 {
00076     friend class PSFtailCuts;
00077 
00078     TAngleCut(const Tuple& t) : Analyze(t, "TKR_t_angle", "Tracker t0-t1 angle"),
00079                                 m_CalEne  (t.tupleItem("Cal_Energy_Deposit")),
00080                                 m_1stPlane(t.tupleItem("TKR_First_XHit")),
00081                                 m_cosTheta(t.tupleItem("TKR_Gamma_zdir"))
00082     { }
00083 
00084     virtual bool apply()
00085     {
00086         float tangle  = item();
00087         float calEne  = *m_CalEne;
00088         int   frstLyr = *m_1stPlane;
00089         float cosZ    = *m_cosTheta;
00090 
00091         return fabs(tangle) <= kalError(calEne, frstLyr, cosZ);
00092     }
00093 
00094     const TupleItem* m_CalEne;
00095     const TupleItem* m_1stPlane;
00096     const TupleItem* m_cosTheta;
00097 };
00098 
00100 // Construction/Destruction
00102 
00103 PSFtailCuts::PSFtailCuts(const Tuple& t): AnalysisList(" PSF tail cuts")
00104 {
00105 
00106     push_back( new Cut(t, "TKR_Fit_Type>0") );
00107     //push_back( new AbsValueCut(t, "TKR_Fit_Kink" , 3*0.0041 ) );
00108    
00109     // allow either name for the opening angle difference
00110     //std::string tname="t0-t1_Angle";
00111     //if (t.find(tname)==t.end()) tname = "TKR_t_angle"; 
00112     //push_back( new Cut(t, tname, Cut::LT, 4*0.0041 ) );
00113 
00114     push_back( new FitKinkCut(t) );
00115     push_back( new TAngleCut(t)  );
00116 }

Generated at Wed Nov 21 12:20:39 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000