StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StCtbMatcher.h
1 #ifndef ST_CTB_MATCHER_H
2 #define ST_CTB_MATCHER_H
3 
4 #include <vector>
5 
6 #include <TMath.h>
7 
8 #include "StEvent/StTrack.h"
9 #include "StEvent/StTrackGeometry.h"
10 #include "StarClassLibrary/StPhysicalHelixD.hh"
11 #include "StarClassLibrary/StThreeVectorD.hh"
12 
13 
14 struct ctbHit{
15  double phi;
16  double eta;
17  float adc;
18 };
19 
20 
21 unsigned int EtaAndPhiToOrriginAtCTB(StTrack* rTrack, // Pointer to Track
22  vector<ctbHit>* ctbHits,
23  bool & shouldHit,
24  double & trackEtaInCTBFrame){
25 
26  const double Rctb=213.6; // (cm) radius of the CTB
27 
28  // Set Minimum pt to look at
29  if(rTrack->geometry()->momentum().perp() < .20)
30  return false;
31 
32  StPhysicalHelixD theHelix = rTrack->geometry()->helix();
33  pairD pathLength = theHelix.pathLength(Rctb);
34 
35  if(pathLength.second < 0){
36  cout << "pathLength is bad" << endl;
37  return false;
38  }
39 
40  StThreeVectorD pos = theHelix.at(pathLength.second);
41 
42  double phi = atan2(pos.y(),pos.x())*180/TMath::Pi();
43  if(phi < 0)
44  phi+= 360;
45 
46  double theta = atan2(pos.perp(),pos.z());
47  double eta = -::log(tan(theta/2.0));
48  trackEtaInCTBFrame = eta;
49 
50  // if |eta| < 1 then track should have hit the CTB.
51  if(fabs(eta) < 1)
52  shouldHit = true;
53  else
54  shouldHit = false;
55 
56  // Loop over CTB Hits To see if a match
57  float deta,dphi;
58  for(unsigned int i = 0; i < ctbHits->size() ; i++){
59  ctbHit curHit = (*ctbHits)[i];
60  deta = fabs(curHit.eta - eta);
61  if(curHit.phi != 0){
62  dphi = fabs(curHit.phi - phi);
63  if( dphi < 3 && deta < .25){
64  return static_cast<unsigned int>(curHit.adc);
65  }
66  }
67  else{
68  if( (phi < 3 || phi > 357) && deta < .25){
69  return static_cast<unsigned int>(curHit.adc);
70  }
71  }
72  }
73  // cout << endl;
74  // Else return 0
75  return 0;
76 }
77 
78 void ctb_get_slat_from_data(int slat, int tray, double & ctbphi, double & ctbeta) {
79  // Function copied verbatum from St_dst_Maker/CtbResponce. We may want to clean this up.
80 
81  float phiZero1 = 72 ; // magic lines from Pablo & Herb
82  float phiZero2 = 108 ;
83  float deltaPhi = 6 ;
84  // tray=0,1
85  // slat=0,...,119
86 
87  int iz ;
88  double phi;
89 
90  if ( tray < 60 ) {
91  phi = phiZero1 - tray * deltaPhi ;
92  iz = 0 ;
93  } else {
94  phi = phiZero2 + (tray-60) * deltaPhi ;
95  iz = 1 ;
96  }
97 
98  if ( phi < 0. ) phi += 360 ;
99  if ( phi > 360. ) phi -= 360 ;
100 
101  ctbphi=phi;
102  ctbeta =(1-2*iz)*(1+2*slat)*0.25;
103 
104  //printf("CTB hit: slat=%d, tray=%d, phiDeg=%f/deg, eta=%f\n",slat,tray,ctbphi,ctbeta);
105 
106 }
107 
108 #endif
pair< double, double > pathLength(double r) const
path length at given r (cylindrical r)
Definition: StHelix.cc:351