00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00032 class StChain;
00033 TNtuple *MakeTrsNtuple() {
00034 TNtuple *trstest;
00035 trstest = new TNtuple("trs","trs",
00036 "xgeant:ygeant:zgeant:crossAngle:tanl:xtphit:ytphit:ztphit:q");
00037 return trstest;
00038 }
00039 void FillTrsNtuple(StChain *theChain,TNtuple *trstest) {
00040
00041 int tphitIdx,indexIdx,geantIdx,indexIdx,geantNrow,tphitNrow,indexNrow;
00042 int geantKey,tphitKey;
00043 Float_t p0,p1,p2;
00044
00045 St_DataSetIter *iter0=new St_DataSetIter(theChain); if(!iter0) return;
00046
00047 St_g2t_tpc_hit *geantObj=
00048 (St_g2t_tpc_hit*)iter0(".make/geant/.data/g2t_tpc_hit");
00049 if(!geantObj) { printf("Error 96.\n"); return; }
00050 g2t_tpc_hit_st *geantTbl=(g2t_tpc_hit_st*) geantObj->GetTable();
00051 if(!geantTbl) { printf("Error 396.\n"); return; }
00052 geantNrow=geantObj->GetNRows();
00053
00054 St_tcl_tpc_index *indexObj=iter0(".make/tpc_hits/.data/index");
00055 if(!indexObj) { printf("Error 66.\n"); return; }
00056 tcl_tpc_index_st *indexTbl=(tcl_tpc_index_st*) indexObj->GetTable();
00057 if(!indexTbl) { printf("Error 396.\n"); return; }
00058 indexNrow=indexObj->GetNRows();
00059
00060 St_tcl_tphit *tphitObj=iter0(".make/tpc_hits/.data/tphit");
00061 if(!tphitObj) { printf("Error 76.\n"); return; }
00062 tcl_tphit_st *tphitTbl=(tcl_tphit_st*) tphitObj->GetTable();
00063 if(!tphitTbl) { printf("Error 396.\n"); return; }
00064 tphitNrow=tphitObj->GetNRows();
00065
00066 for(indexIdx=0;indexIdx<indexNrow;indexIdx++) {
00067
00068 geantKey=indexTbl[indexIdx].key1;
00069 for(geantIdx=geantNrow-1;geantIdx>=0;geantIdx--) {
00070 if(geantTbl[geantIdx].id==geantKey) break;
00071 }
00072 if(geantIdx<0) { printf("no match key1 (%d).\n",geantKey); continue; }
00073
00074 tphitKey=indexTbl[indexIdx].key2;
00075 for(tphitIdx=tphitNrow-1;tphitIdx>=0;tphitIdx--) {
00076 if(tphitTbl[tphitIdx].id==tphitKey) break;
00077 }
00078 if(tphitIdx<0) { printf("no match key2 (%d).\n",tphitKey); continue; }
00079
00080 p0=geantTbl[geantIdx].p[0];
00081 p1=geantTbl[geantIdx].p[1];
00082 p2=geantTbl[geantIdx].p[2];
00083
00084 trstest->Fill(
00085 (Float_t)(geantTbl[geantIdx].x[0]),
00086 (Float_t)(geantTbl[geantIdx].x[1]),
00087 (Float_t)(geantTbl[geantIdx].x[2]),
00088 (Float_t)(atan2(p0,p1)),
00089 (Float_t)(atan(p2/sqrt(p0*p0+p1*p1))),
00090 (Float_t)(tphitTbl[tphitIdx].x),
00091 (Float_t)(tphitTbl[tphitIdx].y),
00092 (Float_t)(tphitTbl[tphitIdx].z),
00093 (Float_t)(tphitTbl[tphitIdx].q)
00094 );
00095 }
00096 }