StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEEmcPointUtils.cxx
1 #include "StEEmcPointUtils.h"
2 #include <algorithm>
3 
4 // ----------------------------------------------------------------------------
5 StEEmcPointUtils::StEEmcPointUtils()
6 {
7 }
8 
9 // ----------------------------------------------------------------------------
10 Bool_t StEEmcPointUtils::opening_angle_cut ( StEEmcPoint &p1, StEEmcPoint &p2, Float_t energy, Float_t mass, Float_t frac )
11 {
12  Float_t oangle = p1.position().Angle( p2.position() );
13  Float_t oangle_min = 2.0 * mass * frac / energy;
14  return (oangle>oangle_min);
15 }
16 
17 // ----------------------------------------------------------------------------
18 StEEmcPointVec_t StEEmcPointUtils::find_best_points( StEEmcPointVec_t points, Float_t em_energy, Bool_t &stat, Float_t &chi2, Int_t npoint )
19 {
20 
23  chi2=1.0E9;
24  if ( npoint > (Int_t)points.size() ) {
25  stat=false;
26  return points;
27  }
28 
31  Bool_t go=true;
32  Float_t chi2_min=1.0E9;
33  StEEmcPointVec_t good_perm;
34  while ( go ) {
35 
38  if ( no_parallel_smd_clusters( points, npoint ) )
39  for ( Int_t ipoint=0; ipoint < npoint; ipoint++ ) {
40  Float_t edep_predict = 2.0 * kEEmcSmdSF * em_energy;
41  Float_t ediff1 = points[ipoint].energy() - edep_predict;
42  Float_t ediff2 = points[ipoint].cluster(0).energy() - points[ipoint].cluster(1).energy();
43  ediff2 *= 2.0;
44  Float_t mychi2=ediff1*ediff1 + ediff2*ediff2;
45  if ( mychi2 < chi2_min ) {
46  good_perm=points;
47  chi2_min=mychi2;
48  }
49 
50  }
51 
52  go = std::next_permutation ( points.begin(), points.end() );
53 
54  }
55 
56  return points;
57 
58 }
59 
60 // ----------------------------------------------------------------------------
61 Bool_t StEEmcPointUtils::no_parallel_smd_clusters( StEEmcPointVec_t points, Int_t npoint )
62 {
63 
64  if ( npoint <= 1 ) return true;
65 
66  for ( Int_t i = 0; i < npoint-1; i++ ) {
67  Float_t u1=points[i].cluster(0).mean();
68  Float_t v1=points[i].cluster(1).mean();
69  for ( Int_t j = i+1; j < npoint; j++ ) {
70  Float_t u2=points[j].cluster(0).mean();
71  Float_t v2=points[j].cluster(1).mean();
72  if ( u1==u2 ) return false;
73  if ( v1==v2 ) return false;
74  }
75  }
76 
78  return true;
79 
80 }
Base class for representing EEMC points.
Definition: StEEmcPoint.h:24
Bool_t opening_angle_cut(StEEmcPoint &p1, StEEmcPoint &p2, Float_t energy, Float_t mass=0.135, Float_t frac=0.3)
Bool_t no_parallel_smd_clusters(StEEmcPointVec_t points, Int_t npoint)
StEEmcPointVec_t find_best_points(StEEmcPointVec_t points, Float_t em_energy, Bool_t &stat, Float_t &chi2, Int_t npoint=1)
void position(const TVector3 &p)
Set the position of this point at the SMD plane.
Definition: StEEmcPoint.h:32