StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTrsSector.cc
1 /***************************************************************************
2  *
3  * $Id: StTrsSector.cc,v 1.10 2007/07/12 20:25:05 fisyak Exp $
4  *
5  * Author:
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StTrsSector.cc,v $
13  * Revision 1.10 2007/07/12 20:25:05 fisyak
14  * Use StarLogger, use time of flight, fix cluster shape
15  *
16  * Revision 1.9 2005/10/06 19:59:10 fisyak
17  * adjust for ICC
18  *
19  * Revision 1.8 2005/09/09 22:12:49 perev
20  * Bug fix + IdTruth added
21  *
22  * Revision 1.7 1999/12/08 02:10:42 calderon
23  * Modified to eliminate warnings on Linux.
24  *
25  * Revision 1.6 1999/11/11 19:45:12 calderon
26  * Made variables-> data members in analog signal generator to avoid
27  * initialization time when member functions are called.
28  * Inlined:
29  * StTrsParameterizedAnalogSignalGenerator::signalSampler()
30  * StTrsSector::addEntry()
31  * StTrsSector::assignTimeBins()
32  *
33  * Revision 1.5 1999/02/16 23:36:42 lasiuk
34  * carefull...row>0
35  *
36  * Revision 1.4 1999/02/12 01:26:37 lasiuk
37  * Limit debug output
38  *
39  * Revision 1.3 1999/01/18 21:02:57 lasiuk
40  * comment diagnostics
41  *
42  * Revision 1.2 1998/11/16 14:49:06 lasiuk
43  * make sure of index when filling sector
44  *
45  * Revision 1.1 1998/11/10 17:12:26 fisyak
46  * Put Brian trs versin into StRoot
47  *
48  * Revision 1.3 1998/11/08 17:06:41 lasiuk
49  * use resize() for LINUX compatibiltiy
50  * allocator specification for vector<>
51  *
52  * Revision 1.2 1998/11/04 18:49:40 lasiuk
53  * modify constructors
54  * macro ST_SECTOR_BOUND_CHECK
55  * addEntry()
56  * addTimeBins()
57  *
58  * Revision 1.1 1998/06/30 22:46:50 lasiuk
59  * Initial Revision
60  *
61  **************************************************************************/
62 #include "StTrsSector.hh"
63 #include "StMCTruth.h"
64 //______________________________________________________________________________
65 StTrsSector::StTrsSector(StTpcGeometry* geoDb)
66 {
67  tpcTimeBins timeBins;
68  tpcPadRow padRow;
69  int irow;
70 
71  for(irow=0; irow< geoDb->numberOfRows(); irow++) {
72  //cout << " NumberOfPadsAtRow(" << irow << "): " << geoDb->numberOfPadsAtRow(irow+1) << endl;
73  //padRow.assign(geoDb->numberOfPadsAtRow(irow+1), timeBins);
74  padRow.resize(geoDb->numberOfPadsAtRow(irow+1), timeBins);
75  mSector.push_back(padRow);
76  }
77 
78  // tmp
79  // check size at creation?
80 // cout << " NumberOfRows in Sector: " << mSector.size() << endl;
81 // for(int ii=0; ii<mSector.size(); ii++) {
82 // cout << " PadsInRow(" << ii << "): " << mSector[ii].size() << endl;
83 // }
84 }
85 
86 //______________________________________________________________________________
87 StTrsSector::~StTrsSector() {/* nopt */}
88 
89 //______________________________________________________________________________
90 void StTrsSector::clear() // clears only the time bins
91 {
92  //cout << "in StTrsSector::clear()" << endl;
93  for(unsigned int irow=0; irow<mSector.size(); irow++) {
94  for(unsigned int ipad=0; ipad<mSector[irow].size(); ipad++) {
95  mSector[irow][ipad].clear();
96  }
97  }
98 }
99 
100 // Caution: rowN specifies rowNumber 1..45
101 // Below, rowIndex specifies index 0..44
102 // void StTrsSector::addEntry(int rowN, int padN, StTrsAnalogSignal& signl)
103 // {
104 // //cout << "rowN " << rowN << " padN " << padN << endl;
105 // #ifdef ST_SECTOR_BOUNDS_CHECK
106 // if( (rowN > 0 && row <= mSector.size()) )
107 // if( (padN > 0 && pad <= mSector[(rowN-1)].size()) )
108 // #endif
109 // mSector[(rowN-1)][(padN-1)].push_back(signl);
110 // }
111 
112 //______________________________________________________________________________
113 void StTrsSector::addEntry(StTpcPadCoordinate& coord, StTrsAnalogSignal& sig)
114 {
115  addEntry(coord.row(), coord.pad(), sig);
116 }
117 
118 // Caution: rowIndex specifies index 0..44
119 // Above: rowN specifies rowNumber 1..45
120 // void StTrsSector::assignTimeBins(int rowN, int padN, tpcTimeBins& tbins)
121 // {
122 // #ifdef ST_SECTOR_BOUNDS_CHECK
123 // if( (rowIndex > 0 && rowIndex <= mSector.size()) )
124 // if( (padIndex > 0 && padIndex <= mSector[rowIndex].size()) )
125 // #endif
126 // mSector[(rowN-1)][(padN-1)] = tbins;
127 // }
128 
129 //______________________________________________________________________________
130 void StTrsSector::assignTimeBins(StTpcPadCoordinate& coord, tpcTimeBins& tbins)
131 {
132  assignTimeBins(coord.row(), coord.pad(), tbins);
133 }
134 //______________________________________________________________________________
135 int StTrsSector::sort()
136 {
137  int nadd=0;
138  StMCPivotTruth pivo(1);
139  int nrows = mSector.size();
140  for (int irow=0;irow<nrows;irow++) {
141  int npads = mSector[irow].size();
142  for (int ipad=0; ipad<npads; ipad++) {
143  tpcTimeBins &tb = mSector[irow][ipad];
144  int ntb = tb.size();
145  if (ntb<2) continue;
146 #if defined( __ICC ) && __ICC < 910
147  sort(tb.begin(), tb.end(),StTrsAnalogSignalComparator());
148 #else
149  std::sort(tb.begin(), tb.end(),StTrsAnalogSignalComparator());
150 #endif
151  int jl=0,jr=1;
152  for (;1;jr++) {
153  assert(jr==ntb || tb[jl].time() <= tb[jr].time());
154  if (jr==ntb || tb[jl].time() < tb[jr].time()) {
155  if (pivo.Size()) {tb[jl].setId(pivo.Get()); pivo.Reset();}
156  if (jr==ntb) break;
157  jl++; if (jl != jr) tb[jl] = tb[jr];
158  } else {
159  nadd++;
160  if (!pivo.Size()) pivo.Add(tb[jl].id(),tb[jl].amplitude());
161  pivo.Add(tb[jr].id(),tb[jr].amplitude());
162  tb[jl]+=tb[jr];
163  }
164  }
165  tb.resize(jl+1);
166  }
167  }
168  return nadd;
169 }