CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTRangeT0.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author Paolo Ronchese INFN Padova
5  *
6  */
7 
8 //----------------------
9 // This Class' Header --
10 //----------------------
12 
13 //-------------------------------
14 // Collaborating Class Headers --
15 //-------------------------------
17 
18 //---------------
19 // C++ Headers --
20 //---------------
21 #include <iostream>
22 #include <sstream>
23 
24 //-------------------
25 // Initializations --
26 //-------------------
27 
28 
29 //----------------
30 // Constructors --
31 //----------------
33  dataVersion( " " ),
34  dBuf(new DTBufferTree<int,int>) {
35  dataList.reserve( 1000 );
36 }
37 
38 
40  dataVersion( version ),
41  dBuf(new DTBufferTree<int,int>) {
42  dataList.reserve( 1000 );
43 }
44 
45 
47  wheelId( 0 ),
48  stationId( 0 ),
49  sectorId( 0 ),
50  slId( 0 ) {
51 }
52 
53 
55  t0min( 0 ),
56  t0max( 0 ) {
57 }
58 
59 
60 //--------------
61 // Destructor --
62 //--------------
64 }
65 
66 
68 }
69 
70 
72 }
73 
74 
75 //--------------
76 // Operations --
77 //--------------
78 int DTRangeT0::get( int wheelId,
79  int stationId,
80  int sectorId,
81  int slId,
82  int& t0min,
83  int& t0max ) const {
84 
85  t0min =
86  t0max = 0;
87 
88  std::vector<int> chanKey;
89  chanKey.reserve(4);
90  chanKey.push_back( wheelId );
91  chanKey.push_back( stationId );
92  chanKey.push_back( sectorId );
93  chanKey.push_back( slId );
94  int ientry;
95  //Guarantee const correctness for thread-safety
96  const DTBufferTree<int,int>* constDBuf = dBuf;
97  int searchStatus = constDBuf->find( chanKey.begin(), chanKey.end(), ientry );
98  if ( !searchStatus ) {
99  const DTRangeT0Data& data( dataList[ientry].second );
100  t0min = data.t0min;
101  t0max = data.t0max;
102  }
103 
104  return searchStatus;
105 
106 }
107 
108 
110  int& t0min,
111  int& t0max ) const {
112  return get( id.wheel(),
113  id.station(),
114  id.sector(),
115  id.superLayer(),
116  t0min, t0max );
117 }
118 
119 
120 const
122  return dataVersion;
123 }
124 
125 
127  return dataVersion;
128 }
129 
130 
132  dataList.clear();
133  initialize();
134  return;
135 }
136 
137 
138 int DTRangeT0::set( int wheelId,
139  int stationId,
140  int sectorId,
141  int slId,
142  int t0min,
143  int t0max ) {
144 
145  std::vector<int> chanKey;
146  chanKey.reserve(4);
147  chanKey.push_back( wheelId );
148  chanKey.push_back( stationId );
149  chanKey.push_back( sectorId );
150  chanKey.push_back( slId );
151  int ientry;
152  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
153 
154  if ( !searchStatus ) {
155  DTRangeT0Data& data( dataList[ientry].second );
156  data.t0min = t0min;
157  data.t0max = t0max;
158  return -1;
159  }
160  else {
162  key. wheelId = wheelId;
163  key.stationId = stationId;
164  key. sectorId = sectorId;
165  key. slId = slId;
167  data.t0min = t0min;
168  data.t0max = t0max;
169  ientry = dataList.size();
170  dataList.push_back( std::pair<DTRangeT0Id,DTRangeT0Data>( key, data ) );
171  dBuf->insert( chanKey.begin(), chanKey.end(), ientry );
172  return 0;
173  }
174 
175  return 99;
176 
177 }
178 
179 
181  int t0min,
182  int t0max ) {
183  return set( id.wheel(),
184  id.station(),
185  id.sector(),
186  id.superLayer(),
187  t0min, t0max );
188 }
189 
190 
192  return dataList.begin();
193 }
194 
195 
197  return dataList.end();
198 }
199 
200 
202  std::stringstream name;
203  name << dataVersion << "_map_RangeT0" << this;
204  return name.str();
205 }
206 
207 
209 
210  dBuf->clear();
211 
212  int entryNum = 0;
213  int entryMax = dataList.size();
214  std::vector<int> chanKey;
215  chanKey.reserve(4);
216  while ( entryNum < entryMax ) {
217 
218  const DTRangeT0Id& chan = dataList[entryNum].first;
219 
220  chanKey.clear();
221  chanKey.push_back( chan. wheelId );
222  chanKey.push_back( chan.stationId );
223  chanKey.push_back( chan. sectorId );
224  chanKey.push_back( chan. slId );
225  dBuf->insert( chanKey.begin(), chanKey.end(), entryNum++ );
226  }
227  return;
228 }
std::string mapName() const
read and store full content
Definition: DTRangeT0.cc:201
const_iterator end() const
Definition: DTRangeT0.cc:196
std::vector< std::pair< DTRangeT0Id, DTRangeT0Data > >::const_iterator const_iterator
Access methods to data.
Definition: DTRangeT0.h:141
int get(int wheelId, int stationId, int sectorId, int slId, int &t0min, int &t0max) const
Definition: DTRangeT0.cc:78
std::string dataVersion
Definition: DTRangeT0.h:152
const std::string & version() const
access version
Definition: DTRangeT0.cc:121
int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait< Content >::outputTypeOfConstFind &cont) const
U second(std::pair< T, U > const &p)
void initialize()
Definition: DTRangeT0.cc:208
std::vector< std::pair< DTRangeT0Id, DTRangeT0Data > > dataList
Definition: DTRangeT0.h:154
~DTRangeT0()
Definition: DTRangeT0.cc:63
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
void clear()
reset content
Definition: DTRangeT0.cc:131
const_iterator begin() const
Definition: DTRangeT0.cc:191
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
int insert(ElementKey fKey, ElementKey lKey, Content cont)
int set(int wheelId, int stationId, int sectorId, int slId, int t0min, int t0max)
Definition: DTRangeT0.cc:138
int stationId
Definition: DTRangeT0.h:47
DTBufferTree< int, int > * dBuf
Definition: DTRangeT0.h:156