CMS 3D CMS Logo

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 // Collaborating Class Headers --
30 //-------------------------------
32 
33 using namespace std;
34 
35 //----------------
36 // Constructors --
37 //----------------
38 
40 
41 //--------------
42 // Destructor --
43 //--------------
44 
46  my_sectcollmap.clear();
47  my_trigunitmap.clear();
48  my_tsphimap.clear();
49  my_tsthetamap.clear();
50  my_tracomap.clear();
51  my_btimap.clear();
52 }
53 
54 //--------------
55 // Operations --
56 //--------------
57 
59  DTChamberId chambid = btiid.SLId().chamberId();
60  BtiMap::const_iterator biter1 = my_btimap.find(chambid);
61  if (biter1 == my_btimap.end()) {
62  std::cout << "DTConfigManager::getConfigBti : Chamber (" << chambid.wheel() << "," << chambid.sector() << ","
63  << chambid.station() << ") not found, return 0" << std::endl;
64  return nullptr;
65  }
66 
67  innerBtiMap::const_iterator biter2 = (*biter1).second.find(btiid);
68  if (biter2 == (*biter1).second.end()) {
69  std::cout << "DTConfigManager::getConfigBti : BTI (" << btiid.wheel() << "," << btiid.sector() << ","
70  << btiid.station() << "," << btiid.superlayer() << "," << btiid.bti() << ") not found, return 0"
71  << std::endl;
72  return nullptr;
73  }
74  return &(*biter2).second;
75 }
76 
77 const std::map<DTBtiId, DTConfigBti>& DTConfigManager::getDTConfigBtiMap(DTChamberId chambid) const {
78  BtiMap::const_iterator biter = my_btimap.find(chambid);
79  if (biter == my_btimap.end()) {
80  std::cout << "DTConfigManager::getConfigBtiMap : Chamber (" << chambid.wheel() << "," << chambid.sector() << ","
81  << chambid.station() << ") not found, return a reference to the end of the map" << std::endl;
82  }
83 
84  return (*biter).second;
85 }
86 
88  DTChamberId chambid = tracoid.ChamberId();
89  TracoMap::const_iterator titer1 = my_tracomap.find(chambid);
90  if (titer1 == my_tracomap.end()) {
91  std::cout << "DTConfigManager::getConfigTraco : Chamber (" << chambid.wheel() << "," << chambid.sector() << ","
92  << chambid.station() << ") not found, return 0" << std::endl;
93  return nullptr;
94  }
95 
96  innerTracoMap::const_iterator titer2 = (*titer1).second.find(tracoid);
97  if (titer2 == (*titer1).second.end()) {
98  std::cout << "DTConfigManager::getConfigTraco : TRACO (" << tracoid.wheel() << "," << tracoid.sector() << ","
99  << tracoid.station() << "," << tracoid.traco() << ") not found, return a reference to the end of the map"
100  << std::endl;
101  return nullptr;
102  }
103  return &(*titer2).second;
104 }
105 
106 const std::map<DTTracoId, DTConfigTraco>& DTConfigManager::getDTConfigTracoMap(DTChamberId chambid) const {
107  TracoMap::const_iterator titer = my_tracomap.find(chambid);
108  if (titer == my_tracomap.end()) {
109  std::cout << "DTConfigManager::getConfigTracoMap : Chamber (" << chambid.wheel() << "," << chambid.sector() << ","
110  << chambid.station() << ") not found, return 0" << std::endl;
111  }
112 
113  return (*titer).second;
114 }
115 
117  TSThetaMap::const_iterator thiter = my_tsthetamap.find(chambid);
118  if (thiter == my_tsthetamap.end()) {
119  std::cout << "DTConfigManager::getConfigTSTheta : Chamber (" << chambid.wheel() << "," << chambid.sector() << ","
120  << chambid.station() << ") not found, return 0" << std::endl;
121  return nullptr;
122  }
123 
124  return &(*thiter).second;
125 }
126 
128  TSPhiMap::const_iterator phiter = my_tsphimap.find(chambid);
129  if (phiter == my_tsphimap.end()) {
130  std::cout << "DTConfigManager::getConfigTSPhi : Chamber (" << chambid.wheel() << "," << chambid.sector() << ","
131  << chambid.station() << ") not found, return 0" << std::endl;
132  return nullptr;
133  }
134 
135  return &(*phiter).second;
136 }
137 
139  TrigUnitMap::const_iterator tuiter = my_trigunitmap.find(chambid);
140  if (tuiter == my_trigunitmap.end()) {
141  std::cout << "DTConfigManager::getConfigTrigUnit : Chamber (" << chambid.wheel() << "," << chambid.sector() << ","
142  << chambid.station() << ") not found, return 0" << std::endl;
143  return nullptr;
144  }
145 
146  return &(*tuiter).second;
147 }
148 
150  LUTMap::const_iterator lutiter = my_lutmap.find(chambid);
151  if (lutiter == my_lutmap.end()) {
152  std::cout << "DTConfigManager::getConfigLUTs : Chamber (" << chambid.wheel() << "," << chambid.sector() << ","
153  << chambid.station() << ") not found, return 0" << std::endl;
154  return nullptr;
155  }
156 
157  return &(*lutiter).second;
158 }
159 
161  SectCollMap::const_iterator sciter = my_sectcollmap.find(scid);
162  if (sciter == my_sectcollmap.end()) {
163  std::cout << "DTConfigManager::getConfigSectColl : SectorCollector (" << scid.wheel() << "," << scid.sector()
164  << ") not found, return 0" << std::endl;
165  return nullptr;
166  }
167 
168  return &(*sciter).second;
169 }
170 
171 const DTConfigPedestals* DTConfigManager::getDTConfigPedestals() const { return &my_pedestals; }
172 
174  int ST = static_cast<int>(getDTConfigBti(DTBtiId(1, 1, 1, 1, 1))->ST());
175  return (ST / 2 + ST % 2);
176 }
177 
179  DTChamberId chambid = btiid.SLId().chamberId();
180  my_btimap[chambid][btiid] = conf;
181 }
182 
184  DTChamberId chambid = tracoid.ChamberId();
185  my_tracomap[chambid][tracoid] = conf;
186 }
187 
189  // open txt file
190  string name = "Lut_from_param";
191  name += ".txt";
192 
193  ofstream fout;
194  fout.open(name.c_str(), ofstream::app);
195 
196  // get wheel, station, sector from chamber
197  int wh = chambid.wheel();
198  int st = chambid.station();
199  int se = chambid.sector();
200 
201  //cout << "Dumping lut command for wh " << wh << " st " << st << " se " << se << endl;
202 
203  fout << wh;
204  fout << "\t" << st;
205  fout << "\t" << se;
206 
207  // get parameters from configuration
208  // get DTConfigLUTs for this chamber
209  const DTConfigLUTs* _confLUTs = getDTConfigLUTs(chambid);
210  short int btic = getDTConfigTraco(DTTracoId(wh, st, se, 1))->BTIC();
211  float d = _confLUTs->D();
212  float xcn = _confLUTs->Xcn();
213  //fout << "\td\t" << d << "\txcn\t" << xcn << "\t";
214  //fout << "btic\t" << btic << "\t";
215 
216  // *** dump TRACO LUT command
217  fout << "\tA8";
218  short int Low_byte = (btic & 0x00FF); // output in hex bytes format with zero padding
219  short int High_byte = (btic >> 8 & 0x00FF);
220  fout << setw(2) << setfill('0') << hex << High_byte << setw(2) << setfill('0') << Low_byte;
221 
222  // convert parameters from IEE32 float to DSP float format
223  short int DSPmantissa = 0;
224  short int DSPexp = 0;
225 
226  // d parameter conversion and dump
227  _confLUTs->IEEE32toDSP(d, DSPmantissa, DSPexp);
228  Low_byte = (DSPmantissa & 0x00FF); // output in hex bytes format with zero padding
229  High_byte = (DSPmantissa >> 8 & 0x00FF);
230  fout << setw(2) << setfill('0') << hex << High_byte << setw(2) << setfill('0') << Low_byte;
231  Low_byte = (DSPexp & 0x00FF);
232  High_byte = (DSPexp >> 8 & 0x00FF);
233  fout << setw(2) << setfill('0') << High_byte << setw(2) << setfill('0') << Low_byte;
234 
235  // xnc parameter conversion and dump
236  DSPmantissa = 0;
237  DSPexp = 0;
238  _confLUTs->IEEE32toDSP(xcn, DSPmantissa, DSPexp);
239  Low_byte = (DSPmantissa & 0x00FF); // output in hex bytes format with zero padding
240  High_byte = (DSPmantissa >> 8 & 0x00FF);
241  fout << setw(2) << setfill('0') << hex << High_byte << setw(2) << setfill('0') << Low_byte;
242  Low_byte = (DSPexp & 0x00FF);
243  High_byte = (DSPexp >> 8 & 0x00FF);
244  fout << setw(2) << setfill('0') << High_byte << setw(2) << setfill('0') << Low_byte;
245 
246  // sign bits
247  short int xcn_sign = _confLUTs->Wheel();
248  Low_byte = (xcn_sign & 0x00FF); // output in hex bytes format with zero padding
249  High_byte = (xcn_sign >> 8 & 0x00FF);
250  fout << setw(2) << setfill('0') << hex << High_byte << setw(2) << setfill('0') << Low_byte << dec << "\n";
251 
252  fout.close();
253 
254  return;
255 }
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:63
int sector() const
Returns sector number.
Definition: DTTracoId.h:57
int traco() const
Returns the traco.
Definition: DTTracoId.h:59
void setDTConfigTraco(DTTracoId, DTConfigTraco)
Set DTConfigTraco for desired chip.
int wheel() const
Returns wheel number.
Definition: DTBtiId.h:55
int superlayer() const
Returns the superlayer.
Definition: DTBtiId.h:61
int station() const
Returns station number.
Definition: DTTracoId.h:55
int sector() const
Returns sector number.
Definition: DTBtiId.h:59
DTChamberId ChamberId() const
Returns the chamber id.
Definition: DTTracoId.h:61
void setDTConfigBti(DTBtiId, DTConfigBti)
Set DTConfigBti for desired chip.
int station() const
Returns station number.
Definition: DTBtiId.h:57
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:53
d
Definition: ztail.py:151
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:31
int bti() const
Returns the bti.
Definition: DTBtiId.h:63
int wheel() const
Definition: DTSectCollId.h:30
int sector() const
Definition: DTChamberId.h:49
DTConfigManager()
Constructor.
float Xcn() const
Xcn: distance vertex to normal, unit cm.
Definition: DTConfigLUTs.h:60
const DTConfigTSPhi * getDTConfigTSPhi(DTChamberId) const
Get desired Trigger Server Phi configuration.
~DTConfigManager()
Destructor.
int station() const
Return the station number.
Definition: DTChamberId.h:42
const DTConfigTSTheta * getDTConfigTSTheta(DTChamberId) const
Get desired Trigger Server Theta configuration.
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
const DTConfigPedestals * getDTConfigPedestals() const
Get desired Pedestals configuration.
float D() const
d: distance vertex to normal, unit cm.
Definition: DTConfigLUTs.h:57
const DTConfigTrigUnit * getDTConfigTrigUnit(DTChamberId) const
Get desired Trigger Unit configuration.
DTSuperLayerId SLId() const
Returns the superlayer id.
Definition: DTBtiId.h:65