test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTConfigManager.cc
Go to the documentation of this file.
1 //----------------------------------------------------------------------
2 //
3 // Class: DTConfigManager
4 //
5 // Description: DT Configuration manager includes config classes for every single chip
6 //
7 //
8 // Author List:
9 // C.Battilana
10 //
11 // april 07 : SV DTConfigTrigUnit added
12 // april 07 : CB Removed DTGeometry dependecies
13 //-----------------------------------------------------------------------
14 
15 //-----------------------
16 // This Class's Header --
17 //-----------------------
19 
20 //---------------
21 // C++ Headers --
22 //---------------
23 #include <iostream>
24 #include <iomanip>
25 #include <fstream>
26 #include <sstream>
27 
28 
29 //-------------------------------
30 // Collaborating Class Headers --
31 //-------------------------------
33 
34 using namespace std;
35 
36 //----------------
37 // Constructors --
38 //----------------
39 
41 
42 }
43 
44 //--------------
45 // Destructor --
46 //--------------
47 
49 
50  my_sectcollmap.clear();
51  my_trigunitmap.clear();
52  my_tsphimap.clear();
53  my_tsthetamap.clear();
54  my_tracomap.clear();
55  my_btimap.clear();
56 
57 }
58 
59 //--------------
60 // Operations --
61 //--------------
62 
64 
65  DTChamberId chambid = btiid.SLId().chamberId();
66  BtiMap::const_iterator biter1 = my_btimap.find(chambid);
67  if (biter1 == my_btimap.end()){
68  std::cout << "DTConfigManager::getConfigBti : Chamber (" << chambid.wheel()
69  << "," << chambid.sector()
70  << "," << chambid.station()
71  << ") not found, return 0" << std::endl;
72  return 0;
73  }
74 
75  innerBtiMap::const_iterator biter2 = (*biter1).second.find(btiid);
76  if (biter2 == (*biter1).second.end()){
77  std::cout << "DTConfigManager::getConfigBti : BTI (" << btiid.wheel()
78  << "," << btiid.sector()
79  << "," << btiid.station()
80  << "," << btiid.superlayer()
81  << "," << btiid.bti()
82  << ") not found, return 0" << std::endl;
83  return 0;
84  }
85  return &(*biter2).second;
86 
87 }
88 
89 const std::map<DTBtiId,DTConfigBti>& DTConfigManager::getDTConfigBtiMap(DTChamberId chambid) const {
90 
91  BtiMap::const_iterator biter = my_btimap.find(chambid);
92  if (biter == my_btimap.end()){
93  std::cout << "DTConfigManager::getConfigBtiMap : Chamber (" << chambid.wheel()
94  << "," << chambid.sector()
95  << "," << chambid.station()
96  << ") not found, return a reference to the end of the map" << std::endl;
97  }
98 
99  return (*biter).second;
100 
101 }
102 
104 
105  DTChamberId chambid = tracoid.ChamberId();
106  TracoMap::const_iterator titer1 = my_tracomap.find(chambid);
107  if (titer1 == my_tracomap.end()){
108  std::cout << "DTConfigManager::getConfigTraco : Chamber (" << chambid.wheel()
109  << "," << chambid.sector()
110  << "," << chambid.station()
111  << ") not found, return 0" << std::endl;
112  return 0;
113  }
114 
115  innerTracoMap::const_iterator titer2 = (*titer1).second.find(tracoid);
116  if (titer2 == (*titer1).second.end()){
117  std::cout << "DTConfigManager::getConfigTraco : TRACO (" << tracoid.wheel()
118  << "," << tracoid.sector()
119  << "," << tracoid.station()
120  << "," << tracoid.traco()
121  << ") not found, return a reference to the end of the map" << std::endl;
122  return 0;
123  }
124  return &(*titer2).second;
125 
126 }
127 
128 const std::map<DTTracoId,DTConfigTraco>& DTConfigManager::getDTConfigTracoMap(DTChamberId chambid) const {
129 
130  TracoMap::const_iterator titer = my_tracomap.find(chambid);
131  if (titer == my_tracomap.end()){
132  std::cout << "DTConfigManager::getConfigTracoMap : Chamber (" << chambid.wheel()
133  << "," << chambid.sector()
134  << "," << chambid.station()
135  << ") not found, return 0" << std::endl;
136  }
137 
138  return (*titer).second;
139 
140 }
141 
143 
144  TSThetaMap::const_iterator thiter = my_tsthetamap.find(chambid);
145  if (thiter == my_tsthetamap.end()){
146  std::cout << "DTConfigManager::getConfigTSTheta : Chamber (" << chambid.wheel()
147  << "," << chambid.sector()
148  << "," << chambid.station()
149  << ") not found, return 0" << std::endl;
150  return 0;
151  }
152 
153  return &(*thiter).second;
154 
155 }
156 
158 
159  TSPhiMap::const_iterator phiter = my_tsphimap.find(chambid);
160  if (phiter == my_tsphimap.end()){
161  std::cout << "DTConfigManager::getConfigTSPhi : Chamber (" << chambid.wheel()
162  << "," << chambid.sector()
163  << "," << chambid.station()
164  << ") not found, return 0" << std::endl;
165  return 0;
166  }
167 
168  return &(*phiter).second;
169 
170 }
171 
173 
174  TrigUnitMap::const_iterator tuiter = my_trigunitmap.find(chambid);
175  if (tuiter == my_trigunitmap.end()){
176  std::cout << "DTConfigManager::getConfigTrigUnit : Chamber (" << chambid.wheel()
177  << "," << chambid.sector()
178  << "," << chambid.station()
179  << ") not found, return 0" << std::endl;
180  return 0;
181  }
182 
183  return &(*tuiter).second;
184 
185 }
186 
188 
189  LUTMap::const_iterator lutiter = my_lutmap.find(chambid);
190  if (lutiter == my_lutmap.end()){
191  std::cout << "DTConfigManager::getConfigLUTs : Chamber (" << chambid.wheel()
192  << "," << chambid.sector()
193  << "," << chambid.station()
194  << ") not found, return 0" << std::endl;
195  return 0;
196  }
197 
198  return &(*lutiter).second;
199 
200 }
201 
203 
204  SectCollMap::const_iterator sciter = my_sectcollmap.find(scid);
205  if (sciter == my_sectcollmap.end()){
206  std::cout << "DTConfigManager::getConfigSectColl : SectorCollector (" << scid.wheel()
207  << "," << scid.sector()
208  << ") not found, return 0" << std::endl;
209  return 0;
210  }
211 
212  return &(*sciter).second;
213 
214 }
215 
217 
218  return &my_pedestals;
219 
220 }
221 
223 
224  int ST = static_cast<int>(getDTConfigBti(DTBtiId(1,1,1,1,1))->ST());
225  return (ST/2 + ST%2);
226 
227 }
228 
230 
231  DTChamberId chambid = btiid.SLId().chamberId();
232  my_btimap[chambid][btiid] = conf;
233 
234 }
235 
237 
238  DTChamberId chambid = tracoid.ChamberId();
239  my_tracomap[chambid][tracoid] = conf;
240 
241 }
242 
244 
245  // open txt file
246  string name = "Lut_from_param";
247  name += ".txt";
248 
249  ofstream fout;
250  fout.open(name.c_str(),ofstream::app);
251 
252  // get wheel, station, sector from chamber
253  int wh = chambid.wheel();
254  int st = chambid.station();
255  int se = chambid.sector();
256 
257  //cout << "Dumping lut command for wh " << wh << " st " << st << " se " << se << endl;
258 
259  fout << wh;
260  fout << "\t" << st;
261  fout << "\t" << se;
262 
263  // get parameters from configuration
264  // get DTConfigLUTs for this chamber
265  const DTConfigLUTs* _confLUTs = getDTConfigLUTs(chambid);
266  short int btic = getDTConfigTraco(DTTracoId(wh,st,se,1))->BTIC();
267  float d = _confLUTs->D();
268  float xcn = _confLUTs->Xcn();
269  //fout << "\td\t" << d << "\txcn\t" << xcn << "\t";
270  //fout << "btic\t" << btic << "\t";
271 
272  // *** dump TRACO LUT command
273  fout << "\tA8";
274  short int Low_byte = (btic & 0x00FF); // output in hex bytes format with zero padding
275  short int High_byte =( btic>>8 & 0x00FF);
276  fout << setw(2) << setfill('0') << hex << High_byte << setw(2) << setfill('0') << Low_byte;
277 
278  // convert parameters from IEE32 float to DSP float format
279  short int DSPmantissa = 0;
280  short int DSPexp = 0;
281 
282  // d parameter conversion and dump
283  _confLUTs->IEEE32toDSP(d, DSPmantissa, DSPexp);
284  Low_byte = (DSPmantissa & 0x00FF); // output in hex bytes format with zero padding
285  High_byte =( DSPmantissa>>8 & 0x00FF);
286  fout << setw(2) << setfill('0') << hex << High_byte << setw(2) << setfill('0') << Low_byte;
287  Low_byte = (DSPexp & 0x00FF);
288  High_byte =( DSPexp>>8 & 0x00FF);
289  fout << setw(2) << setfill('0') << High_byte << setw(2) << setfill('0') << Low_byte;
290 
291  // xnc parameter conversion and dump
292  DSPmantissa = 0;
293  DSPexp = 0;
294  _confLUTs->IEEE32toDSP(xcn, DSPmantissa, DSPexp);
295  Low_byte = (DSPmantissa & 0x00FF); // output in hex bytes format with zero padding
296  High_byte =( DSPmantissa>>8 & 0x00FF);
297  fout << setw(2) << setfill('0') << hex << High_byte << setw(2) << setfill('0') << Low_byte;
298  Low_byte = (DSPexp & 0x00FF);
299  High_byte =( DSPexp>>8 & 0x00FF);
300  fout << setw(2) << setfill('0') << High_byte << setw(2) << setfill('0') << Low_byte;
301 
302  // sign bits
303  short int xcn_sign = _confLUTs->Wheel();
304  Low_byte = (xcn_sign & 0x00FF); // output in hex bytes format with zero padding
305  High_byte =( xcn_sign>>8 & 0x00FF);
306  fout << setw(2) << setfill('0') << hex << High_byte << setw(2) << setfill('0') << Low_byte << dec << "\n";
307 
308  fout.close();
309 
310  return;
311 
312 }
const DTConfigLUTs * getDTConfigLUTs(DTChamberId) const
Get desired LUT configuration.
void dumpLUTParam(DTChamberId &chambid) const
Dump luts string commands from configuration parameters.
const DTConfigSectColl * getDTConfigSectColl(DTSectCollId) const
Get desired SectorCollector configuration.
DTChamberId chamberId() const
Return the corresponding ChamberId.
int getBXOffset() const
Get BX Offset for a given vdrift config.
int Wheel() const
wheel sign (-1 or +1)
Definition: DTConfigLUTs.h:65
int sector() const
Returns sector number.
Definition: DTTracoId.h:68
int traco() const
Returns the traco.
Definition: DTTracoId.h:70
void setDTConfigTraco(DTTracoId, DTConfigTraco)
Set DTConfigTraco for desired chip.
tuple d
Definition: ztail.py:151
int wheel() const
Returns wheel number.
Definition: DTBtiId.h:67
int superlayer() const
Returns the superlayer.
Definition: DTBtiId.h:73
int station() const
Returns station number.
Definition: DTTracoId.h:66
int sector() const
Returns sector number.
Definition: DTBtiId.h:71
DTChamberId ChamberId() const
Returns the chamber id.
Definition: DTTracoId.h:72
void setDTConfigBti(DTBtiId, DTConfigBti)
Set DTConfigBti for desired chip.
int station() const
Returns station number.
Definition: DTBtiId.h:69
void IEEE32toDSP(float f, short int &DSPmantissa, short int &DSPexp) const
IEEE32 to DSP conversion.
const DTConfigTraco * getDTConfigTraco(DTTracoId) const
Get desired TRACO configuration.
const std::map< DTBtiId, DTConfigBti > & getDTConfigBtiMap(DTChamberId) const
Get desired BTI configuration map for a given DTChamber.
int wheel() const
Returns wheel number.
Definition: DTTracoId.h:64
const std::map< DTTracoId, DTConfigTraco > & getDTConfigTracoMap(DTChamberId) const
Get desired TRACO configuration map for a given DTChamber.
const DTConfigBti * getDTConfigBti(DTBtiId) const
Get desired BTI configuration.
int sector() const
Definition: DTSectCollId.h:41
int bti() const
Returns the bti.
Definition: DTBtiId.h:75
int wheel() const
Definition: DTSectCollId.h:40
int sector() const
Definition: DTChamberId.h:61
DTConfigManager()
Constructor.
float Xcn() const
Xcn: distance vertex to normal, unit cm.
Definition: DTConfigLUTs.h:62
const DTConfigTSPhi * getDTConfigTSPhi(DTChamberId) const
Get desired Trigger Server Phi configuration.
tuple cout
Definition: gather_cfg.py:145
~DTConfigManager()
Destructor.
int station() const
Return the station number.
Definition: DTChamberId.h:51
const DTConfigTSTheta * getDTConfigTSTheta(DTChamberId) const
Get desired Trigger Server Theta configuration.
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
const DTConfigPedestals * getDTConfigPedestals() const
Get desired Pedestals configuration.
float D() const
d: distance vertex to normal, unit cm.
Definition: DTConfigLUTs.h:59
const DTConfigTrigUnit * getDTConfigTrigUnit(DTChamberId) const
Get desired Trigger Unit configuration.
DTSuperLayerId SLId() const
Returns the superlayer id.
Definition: DTBtiId.h:77