StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StuFixTopoMap.cxx
1 /***************************************************************************
2  *
3  * $Id: StuFixTopoMap.cxx,v 1.13 2018/10/16 19:36:49 genevb Exp $
4  *
5  * Author: Thomas Ullrich, May 2000
6  ***************************************************************************
7  *
8  * Description: StuFixTopoMap rebuilds the StTrackTopologyMap
9  * stored for every track. It assumes that each
10  * track references a valid instance of StTrackDetectorInfo
11  * from which it takes the information to re-create
12  * the map.
13  *
14  * Syntax: bool StuFixTopoMap(StTrack*);
15  *
16  * Returns true if the topology map was rebuild
17  * successfully.
18  *
19  * The description on the format of the map as taken from the
20  * dst_track.idl file reads:
21  *
22  * SVT and/or SSD and/or TPC Tracks
23  * --------------------------------
24  * map[0] Bit number Quantity
25  * ------ ---------- --------
26  * 0 Primary Vertex used(1) or not(0);
27  * also used to indicate that a secondary
28  * vertex constraint was used for special
29  * track fitting methods for decay vertices
30  * (see method variable).
31  * 1-6 SVT 3 superlayers, inner/outer
32  * 7 SSD 4th layer
33  * 8-31 TPC, first 24 padrows
34  *
35  * map[1] Bit number Quantity
36  * ------ ---------- --------
37  * 0-20 TPC, remaining 21 padrows
38  * 21 Track extrapolates to MWC (no=0, yes=1)
39  * 22 Track extrapolates to CTB (no=0, yes=1)
40  * 23 Track extrapolates to TOF (no=0, yes=1)
41  * 24 Track extrapolates to RCH (no=0, yes=1)
42  * 25 Track extrapolates to EMCB (no=0, yes=1)
43  * 26 Track extrapolates to EMCEC (no=0, yes=1)
44  * 27-29 reserved for future use
45  * 30 Turn around flag, some elements used >1
46  * 31 Format interpreter; (SVT/SSD/TPC=0,FTPC=1)
47  *
48  * HFT and/or TPC Tracks
49  * --------------------------------
50  * map[0] Bit number Quantity
51  * ------ ---------- --------
52  * 0 Primary Vertex used(1) or not(0);
53  * also used to indicate that a secondary
54  * vertex constraint was used for special
55  * track fitting methods for decay vertices
56  * (see method variable).
57  * 1-3 PXL 2 layers, possible 2 hits on the second layer (overlapping ladders)
58  * 4-5 IST layer, possible 2 hits
59  * 6-7 SSD layer, possible 2 hits
60  * 8-31 TPC, first 24 padrows
61  *
62  * map[1] Bit number Quantity
63  * ------ ---------- --------
64  * 0-20 TPC, remaining 21 padrows
65  * 21 Track extrapolates to MWC (no=0, yes=1)
66  * 22 Track extrapolates to CTB (no=0, yes=1)
67  * 23 Track extrapolates to TOF (no=0, yes=1)
68  * 24 Track extrapolates to RCH (no=0, yes=1)
69  * 25 Track extrapolates to EMCB (no=0, yes=1)
70  * 26 Track extrapolates to EMCEC (no=0, yes=1)
71  * 27-28 reserved for future use
72  * 29 HFT flag (HFT=1, SVT/SSD=0)
73  * 30 Turn around flag, some elements used >1
74  * 31 Format interpreter; (SVT/SSD/TPC=0,FTPC=1)
75  *
76  *
77  * FTPC Tracks
78  * -----------
79  * map[0] Bit number Quantity
80  * ------ ---------- --------
81  * 0 Primary Vertex used or not
82  * 1-10 FTPC East pad rows, increasing away from
83  * STAR coord. sys. origin at (0,0,0)
84  * 11-20 FTPC West pad rows, increasing away from
85  * STAR coord. sys. origin at (0,0,0)
86  * 21-31 not used; for future use
87  *
88  * map[1] Bit number Quantity
89  * ------ ---------- --------
90  * 0-26 not used; for future use
91  * 27-29 reserved for future use
92  * 30 Turn around flag, some elements used >1
93  * 31 Format interpreter; (SVT/SSD/TPC=0,FTPC=1)
94  *
95  ***************************************************************************
96  *
97  * $Log: StuFixTopoMap.cxx,v $
98  * Revision 1.13 2018/10/16 19:36:49 genevb
99  * Remove erroneous previous commit changes, and add flexibility for iTpc hit determination
100  *
101  *
102  **************************************************************************/
103 #include "StEventTypes.h"
104 #include "StDetectorDbMaker/St_tpcPadConfigC.h"
105 
106 
107 bool StuFixTopoMap(StTrack* track)
108 {
109  if (!track) return false;
110 
111  const StTrackDetectorInfo *info = track->detectorInfo();
112  if (!info) return false;
113 
114  const StPtrVecHit& hits = info->hits();
115 
116  unsigned long word1 = 0;
117  unsigned long word2 = 0;
118  unsigned long long wordiTpc = 0;
119 
120  // Primary vertex used or not
121  if (track->type() == primary) word1 |= 1U;
122 
123  //
124  // Different coding for FTPC and TPC/SVT/SSD tracks
125  //
126  unsigned int i, k;
127  if (info->numberOfReferencedPoints(kFtpcWestId) ||
128  info->numberOfReferencedPoints(kFtpcEastId)) {
129 
130  //
131  // FTPC
132  //
133  word2 |= 1U<<31;
134  for (i=0; i<hits.size(); i++) {
135  if (hits[i]->detector() == kFtpcEastId ||
136  hits[i]->detector() == kFtpcEastId) {
137  k = dynamic_cast<const StFtpcHit*>(hits[i])->plane();
138  if (word1 & 1U<<k) word2 |= 1U<<30; // turnaround flag
139  word1 |= 1U<<k;
140  }
141  }
142  }
143  else {
144 
145  // ???
146  if (info->numberOfReferencedPoints(kPxlId) ||
147  info->numberOfReferencedPoints(kSstId) ||
148  info->numberOfReferencedPoints(kIstId)) {
149  LOG_DEBUG<<" HFT track!" << endm;
150  word2 |= 1U<<29;
151  }
152 
153  //
154  // TPC/SVT/SSD or TPC/SSD/IST/PXL
155  //
156 
157  for (i=0; i<hits.size(); i++) {
158  if (hits[i]->detector() == kSvtId) {
159  k = dynamic_cast<const StSvtHit*>(hits[i])->layer();
160  if (word1 & 1U<<k) word2 |= 1U<<30; // turnaround flag
161  word1 |= 1U<<k;
162  }
163  else if (hits[i]->detector() == kPxlId) {
164  k = dynamic_cast<const StPxlHit*>(hits[i])->layer();
165  LOG_DEBUG<<"track has hit in pixel detector, layer "<<k<<endm;
166  if (k==2 && (word1 & 1U<<k)) {
167  word1 |= 1U<<(k+1); // second layer, possible has two hits
168  LOG_DEBUG<<"set bit for PXL 3rd-layer to 1"<<endm;
169  } else {
170  word1 |= 1U<<k;
171  LOG_DEBUG<<"set bit for PXL "<<k<<"th-layer to 1"<<endm;
172  }
173  LOG_DEBUG<<"word1: "<<word1<<endm;
174  }
175  else if (hits[i]->detector() == kIstId) {
176  LOG_DEBUG<<"track has hit in ist" << endm;
177  if (word1 & 1U<<4) {
178  word1 |= 1U<<5; // second hit
179  LOG_DEBUG<<"set bit for IST 2nd-layer to 1"<<endm;
180  } else {
181  word1 |= 1U<<4;
182  LOG_DEBUG<<"set bit for IST 1st-layer to 1"<<endm;
183  }
184  LOG_DEBUG<<"word1: "<<word1<<endm;
185  }
186  else if (hits[i]->detector() == kSsdId ||
187  hits[i]->detector() == kSstId) {
188  if(word2 & 1U<<29) { // HFT format
189  LOG_DEBUG<<"HFT format for the SST hit map"<<endm;
190  if (word1 & 1U<<6) {
191  word1 |= 1U<<7; // second hit
192  LOG_DEBUG<<"set bit for SST 2nd-layer to 1"<<endm;
193  } else {
194  word1 |= 1U<<6;
195  LOG_DEBUG<<"set bit for SST 1st-layer to 1"<<endm;
196  }
197  } else {
198  if (word1 & 1U<<7) word2 |= 1U<<30; // turnaround flag
199  LOG_DEBUG<<"track has hit in ssd"<<endm;
200  word1 |= 1U<<7;
201  }
202  LOG_DEBUG<<"word1: "<<word1<<endm;
203  }
204  else if (hits[i]->detector() == kTpcId) {
205  unsigned int sector = static_cast<const StTpcHit*>(hits[i])->sector();
206  unsigned int padrow = static_cast<const StTpcHit*>(hits[i])->padrow();
207  bool isiTpc = St_tpcPadConfigC::instance()->isiTpcSector(sector);
208  bool isInner = St_tpcPadConfigC::instance()->isInnerPadRow(sector, padrow);
209  if (isiTpc && isInner) {
210  // Need to treat as iTPC even if not using kiTpcId
211  k = dynamic_cast<const StTpcHit*>(hits[i])->padrow();
212  if (wordiTpc & 1ULL<<k) word2 |= 1U<<30; // turnaround flag
213  wordiTpc |= 1ULL<<k;
214  continue;
215  }
216  k = isiTpc ? padrow - 40 + 13 : padrow; //outer rows of iTPC sector
217  if (k < 25) {
218  if (word1 & 1U<<(k+7)) word2 |= 1U<<30; // turnaround flag
219  word1 |= 1U<<(k+7);
220  }
221  else {
222  if (word2 & 1U<<(k-25)) word2 |= 1U<<30; // turnaround flag
223  word2 |= 1U<<(k-25);
224  }
225  }
226  else if (hits[i]->detector() == kiTpcId) {
227  k = dynamic_cast<const StTpcHit*>(hits[i])->padrow();
228  if (wordiTpc & 1ULL<<k) word2 |= 1U<<30; // turnaround flag
229  wordiTpc |= 1ULL<<k;
230  }
231  }
232  }
233 
234  StTrackTopologyMap newmap(word1, word2, wordiTpc);
235  track->setTopologyMap(newmap);
236  return true;
237 }