00001 #include "StSectorHitFilter.h"
00002 #include "TTableSorter.h"
00003 #include "TTableIter.h"
00004
00005 #include "StTclHitChair.h"
00006 #include "StDstPointChair.h"
00007
00008 #include "tables/St_tcl_tphit_Table.h"
00009 #include "tables/St_tpt_track_Table.h"
00010 #include "tables/St_dst_track_Table.h"
00011 #include "tables/St_dst_point_Table.h"
00012 #include "StCL.h"
00013
00014
00016
00017
00018
00019
00020
00021
00023
00024 ClassImp(StSectorHitFilter)
00025
00026
00027 Int_t StSectorHitFilter::SetSecRow(Int_t *sectorRows,Int_t n)
00028 {
00029 m_nRow = n;
00030 StCL::ucopy(sectorRows,m_row, m_nRow);
00031 printf( " # %d; ", m_nRow);
00032 if (m_nRow) printf( " Row %d", m_row[0]);
00033 printf("\n");
00034 return 0;
00035 }
00036
00037 Int_t StSectorHitFilter::Reset(Int_t reset)
00038 {
00039 printf(" bad hits = %d, # track %d\n",m_badCounter,m_trackId.size());
00040 m_Primtrk = 0;
00041 m_badCounter = 0;
00042 m_trackId.clear();
00043 m_TptTrackID.clear();
00044 return reset;
00045 }
00046
00047 Int_t StSectorHitFilter::HitSubChannel(const TTableSorter *tableObject, Int_t index,Size_t &size, Style_t &style)
00048 {
00049 Color_t color = -1;
00050 TString mStr = tableObject->GetTable()->GetName();
00051 St_tcl_tphit *hit = (St_tcl_tphit *)tableObject->GetTable();
00052 if (hit) {
00053
00054 StTclHitChair thisHit(hit);
00055 Int_t rowNumber = tableObject->GetIndex(UInt_t(index));
00056 if ( m_nRow) {
00057 UInt_t indx = UInt_t(index);
00058 for (int i =0; i < m_nRow; i++) {
00059 if (thisHit[rowNumber].row != m_row[i]) continue;
00060
00061 while (thisHit[rowNumber].row == m_row[i] && rowNumber >= 0 ) {
00062 long id = thisHit[rowNumber].id_globtrk;
00063 if (id)
00064 m_trackId.insert(id);
00065 else
00066 m_badCounter++;
00067 id = thisHit.TrackId(rowNumber);
00068 if (id)
00069 m_TptTrackID.insert(id);
00070
00071 indx++;
00072 rowNumber = tableObject->GetIndex(indx);
00073 }
00074 printf(" %d tracks have been found\n", m_trackId.size());
00075 style = 6;
00076
00077 color = 51+rowNumber%50;
00078 return color;
00079 }
00080 } else {printf(" No rows defined !!!\n"); }
00081
00082 }
00083 else
00084 Error("HitSubChannel","No hit table supplied");
00085 return 0;
00086 }
00087
00088 Int_t StSectorHitFilter::DstHitSubChannel(const TTableSorter *tableObject, Int_t index,Size_t &size, Style_t &style)
00089 {
00090 Color_t color = -1;
00091 St_dst_point *hit = (St_dst_point *)tableObject->GetTable();
00092 if (hit) {
00093
00094 StDstPointChair thisHit(hit);
00095 Int_t rowNumber = tableObject->GetIndex(UInt_t(index));
00096 if ( m_nRow) {
00097 UInt_t indx = UInt_t(index);
00098 color = 51+rowNumber%50;
00099 for (int i =0; i < m_nRow; i++) {
00100 UShort_t sectorRow = StTclHitChair::PckRow(UShort_t(thisHit.Sector(rowNumber))
00101 ,UShort_t(thisHit.PadRow(rowNumber)));
00102 if ( sectorRow != m_row[i]) continue;
00103
00104 while (sectorRow == m_row[i] && rowNumber >= 0 ) {
00105 long id = thisHit[rowNumber].id_track;
00106 if (id)
00107 m_trackId.insert(id);
00108 else
00109 m_badCounter++;
00110 indx++;
00111 rowNumber = tableObject->GetIndex(indx);
00112 sectorRow = StTclHitChair::PckRow(UShort_t(thisHit.Sector(rowNumber))
00113 ,UShort_t(thisHit.PadRow(rowNumber)));
00114 }
00115
00116 style = 6;
00117
00118 return color;
00119 }
00120 } else {printf(" No rows defined !!!\n"); }
00121
00122 }
00123 else
00124 Error("HitSubChannel","No hit table supplied");
00125 return 0;
00126 }
00127
00128 Int_t StSectorHitFilter::Channel(const TTableSorter *tableObject,Int_t index,Size_t &size,Style_t &style)
00129 {
00130
00131
00132
00133
00134 Color_t color = -1;
00135 TString mStr = tableObject->GetTable()->GetName();
00136
00137 if( mStr == "tphit" ) {
00138 color = HitSubChannel(tableObject,index,size,style);
00139 } else if( mStr == "point") {
00140 color = DstHitSubChannel(tableObject, index, size, style);
00141 } else if( !m_Primtrk && mStr == "primtrk") {
00142 m_Primtrk = tableObject;
00143 }
00144 return color;
00145 }
00146
00147
00148 Int_t StSectorHitFilter::Channel(const TTable *tableObject,Int_t rowNumber,Size_t &size,Style_t &style)
00149 {
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 int colorIndex = -1;
00169 TString mStr = tableObject->GetType();
00170 size = 1;
00171 if( mStr == "dst_track_st" ) {
00172 St_dst_track &track = *((St_dst_track *)tableObject);
00173 colorIndex = SubChannel(track, rowNumber, size, style);
00174 } else if (mStr == "tpt_track_st") {
00175 St_tpt_track &track = *((St_tpt_track *)tableObject);
00176 colorIndex = SubChannel(track, rowNumber,size, style);
00177 }
00178 return colorIndex;
00179 }
00180
00181 Int_t StSectorHitFilter::SubChannel(St_tpt_track &track, Int_t rowNumber,Size_t &size,Style_t &style)
00182 {
00183
00184
00185
00186
00187 static int colorIndex = -1;
00188 if (!m_TptTrackID.empty()) {
00189 for ( set<long>::iterator i = m_TptTrackID.begin(); i != m_TptTrackID.end(); i++ ) {
00190 if (track[rowNumber].id != *i) continue;
00191 style = 2;
00192
00193 colorIndex++;
00194 if (colorIndex > 20) colorIndex = 0;
00195 return kBlue+colorIndex;
00196 }
00197 }
00198 return 0;
00199 }
00200
00201 Int_t StSectorHitFilter::SubChannel(St_dst_track &track, Int_t rowNumber,Size_t &size,Style_t &style)
00202 {
00203
00204
00205
00206
00207
00208
00209
00210 int colorIndex = 0;
00211 if (!m_trackId.empty() ) {
00212 for ( set<long>::iterator i = m_trackId.begin(); i != m_trackId.end(); i++ ) {
00213 if (track[rowNumber].id != *i) continue;
00214 colorIndex = kYellow;
00215 if (m_Primtrk &&
00216 (*m_Primtrk)[track[rowNumber].id] < 0) colorIndex = kBlue;
00217
00218
00219 printf(" Track id = %d \n",int(track[rowNumber].id));
00220 return colorIndex;
00221 }
00222 }
00223 return colorIndex;
00224 }