00001 #ifndef ST_CTB_MATCHER_H
00002 #define ST_CTB_MATCHER_H
00003
00004 #include <vector>
00005 #include "StEvent/StTrack.h"
00006 #include "StarClassLibrary/StPhysicalHelixD.hh"
00007 #include "StarClassLibrary/StThreeVectorD.hh"
00008 #include "TMath.h"
00009 struct ctbHit{
00010 double phi;
00011 double eta;
00012 float adc;
00013 };
00014
00015
00016 unsigned int EtaAndPhiToOrriginAtCTB(StTrack* rTrack,
00017 vector<ctbHit>* ctbHits,
00018 bool & shouldHit,
00019 double & trackEtaInCTBFrame){
00020
00021 const double Rctb=213.6;
00022
00023
00024 if(rTrack->geometry()->momentum().perp() < .20)
00025 return false;
00026
00027 StPhysicalHelixD theHelix = rTrack->geometry()->helix();
00028 pairD pathLength = theHelix.pathLength(Rctb);
00029
00030 if(pathLength.second < 0){
00031 cout << "pathLength is bad" << endl;
00032 return false;
00033 }
00034
00035 StThreeVectorD pos = theHelix.at(pathLength.second);
00036
00037 double phi = atan2(pos.y(),pos.x())*180/TMath::Pi();
00038 if(phi < 0)
00039 phi+= 360;
00040
00041 double theta = atan2(pos.perp(),pos.z());
00042 double eta = -::log(tan(theta/2.0));
00043 trackEtaInCTBFrame = eta;
00044
00045
00046 if(fabs(eta) < 1)
00047 shouldHit = true;
00048 else
00049 shouldHit = false;
00050
00051
00052 float deta,dphi;
00053 for(unsigned int i = 0; i < ctbHits->size() ; i++){
00054 ctbHit curHit = (*ctbHits)[i];
00055 deta = fabs(curHit.eta - eta);
00056 if(curHit.phi != 0){
00057 dphi = fabs(curHit.phi - phi);
00058 if( dphi < 3 && deta < .25){
00059 return static_cast<unsigned int>(curHit.adc);
00060 }
00061 }
00062 else{
00063 if( (phi < 3 || phi > 357) && deta < .25){
00064 return static_cast<unsigned int>(curHit.adc);
00065 }
00066 }
00067 }
00068
00069
00070 return 0;
00071 }
00072
00073 void ctb_get_slat_from_data(int slat, int tray, double & ctbphi, double & ctbeta) {
00074
00075
00076 float phiZero1 = 72 ;
00077 float phiZero2 = 108 ;
00078 float deltaPhi = 6 ;
00079
00080
00081
00082 int iz ;
00083 double phi,eta ;
00084
00085 if ( tray < 60 ) {
00086 phi = phiZero1 - tray * deltaPhi ;
00087 iz = 0 ;
00088 } else {
00089 phi = phiZero2 + (tray-60) * deltaPhi ;
00090 iz = 1 ;
00091 }
00092
00093 if ( phi < 0. ) phi += 360 ;
00094 if ( phi > 360. ) phi -= 360 ;
00095
00096 ctbphi=phi;
00097 eta = (1-2*iz)*(1+2*slat)*0.25;
00098 ctbeta =(1-2*iz)*(1+2*slat)*0.25;
00099
00100
00101
00102 }
00103
00104 #endif