CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
pos::PixelFEDTestDAC Class Reference

This class implements.. More...

#include "interface/PixelFEDTestDAC.h"

Inheritance diagram for pos::PixelFEDTestDAC:
pos::PixelCalibBase

Public Member Functions

std::vector< unsigned int > dacs ()
 
std::string mode () const override
 
 PixelFEDTestDAC (std::string filename)
 
 PixelFEDTestDAC (std::vector< std::vector< std::string > > &)
 
void writeXML (std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
 
void writeXMLHeader (pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
 
void writeXMLTrailer (std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
 
- Public Member Functions inherited from pos::PixelCalibBase
 PixelCalibBase ()
 
virtual ~PixelCalibBase ()
 

Private Member Functions

std::vector< unsigned int > decimalToBaseX (unsigned int a, unsigned int x, unsigned int length)
 
unsigned int levelEncoder (int level)
 

Private Attributes

std::vector< unsigned int > dacs_
 

Additional Inherited Members

- Protected Attributes inherited from pos::PixelCalibBase
std::string mode_
 

Detailed Description

This class implements..

A longer explanation will be placed here later

Definition at line 29 of file PixelFEDTestDAC.h.

Constructor & Destructor Documentation

PixelFEDTestDAC::PixelFEDTestDAC ( std::string  filename)

Definition at line 171 of file PixelFEDTestDAC.cc.

References TtFullHadDaughter::B, ALCARECOTkAlJpsiMuMu_cff::charge, gather_cfg::cout, groupFilesInBlocks::fin, mps_fire::i, createfilelist::int, geometryCSVtoXML::line, PFRecoTauDiscriminationByIsolation_cfi::offset, command_line::start, and AlCaHLTBitMon_QueryRunRegistry::string.

172 {
173 
174  std::string mthn = "[PixelFEDTestDAC::PixelFEDTestDAC()]\t\t\t\t " ;
175  const unsigned long int UB=200;
176  const unsigned long int B=500;
177  const unsigned long int offset=0;
178  vector <unsigned int> pulseTrain(256), pixelDCol(1), pixelPxl(2), pixelTBMHeader(3), pixelTBMTrailer(3);
179  unsigned int DCol, LorR, start=15;
181  std::string::size_type loc1, loc2, loc3, loc4;
182  unsigned long int npos=std::string::npos;
183  int i;
184 
185  // Initialise the pulseTrain to offset+black
186  for (unsigned int i=0;i<pulseTrain.size();++i)
187  {
188  pulseTrain[i]=offset+B;
189  }
190 
191  ifstream fin(filename.c_str());
192 
193  i=start;
194 
195  getline(fin, line);
196  mode_=line;
197  assert(mode_=="EmulatedPhysics"||
198  mode_=="FEDBaselineWithTestDACs"||
199  mode_=="FEDAddressLevelWithTestDACs");
200 
201  while (!fin.eof())
202  {
203  getline(fin, line);
204 
205  if (line.find("TBMHeader")!=npos)
206  {
207  loc1=line.find("("); if (loc1==npos) {cout<< __LINE__ << "]\t" << mthn << "'(' not found after TBMHeader.\n"; break;}
208  loc2=line.find(")", loc1+1); if (loc2==npos) {cout<< __LINE__ << "]\t" << mthn << "')' not found after TBMHeader.\n"; break;}
209  int TBMHeader=atoi(line.substr(loc1+1,loc2-loc1-1).c_str());
210 
211  pulseTrain[i]=UB;++i;
212  pulseTrain[i]=UB;++i;
213  pulseTrain[i]=UB;++i;
214  pulseTrain[i]=B;++i;
215 
216  pixelTBMHeader=decimalToBaseX(TBMHeader, 4, 4);
217 
218  pulseTrain[i]=levelEncoder(pixelTBMHeader[3]);++i;
219  pulseTrain[i]=levelEncoder(pixelTBMHeader[2]);++i;
220  pulseTrain[i]=levelEncoder(pixelTBMHeader[1]);++i;
221  pulseTrain[i]=levelEncoder(pixelTBMHeader[0]);++i;
222  }
223  else if (line.find("ROCHeader")!=std::string::npos)
224  {
225  loc1=line.find("("); if (loc1==npos) {cout<< __LINE__ << "]\t" << mthn << "'(' not found after ROCHeader.\n"; break;}
226  loc2=line.find(")", loc1+1); if (loc2==npos) {cout<< __LINE__ << "]\t" << mthn << "')' not found after ROCHeader.\n"; break;}
227  int LastDAC=atoi(line.substr(loc1+1,loc2-loc1-1).c_str());
228 
229  std::cout<<"--------------"<<std::endl;
230 
231  pulseTrain[i]=UB;++i;
232  pulseTrain[i]=B;++i;
233  pulseTrain[i]=levelEncoder(LastDAC); ++i;
234  }
235  else if (line.find("PixelHit")!=std::string::npos) {
236 
237  loc1=line.find("("); if (loc1==npos) {cout<< __LINE__ << "]\t" << mthn <<"'(' not found after PixelHit.\n"; break;}
238  loc2=line.find(",", loc1+1); if (loc2==npos) {cout<< __LINE__ << "]\t" << mthn <<"',' not found after the first argument of PixelHit.\n"; break;}
239  loc3=line.find(",", loc2+1); if (loc3==npos) {cout<< __LINE__ << "]\t" << mthn <<"'.' not found after the second argument of PixelHit.\n"; break;}
240  loc4=line.find(")", loc3+1); if (loc4==npos) {cout<< __LINE__ << "]\t" << mthn <<"')' not found after the third argument of PixelHit.\n"; break;}
241  int column=atoi(line.substr(loc1+1, loc2-loc1-1).c_str());
242  int row=atoi(line.substr(loc2+1, loc3-loc2-1).c_str());
243  int charge=atoi(line.substr(loc3+1, loc4-loc3-1).c_str());
244 
245  DCol=int(column/2);
246  LorR=int(column-DCol*2);
247  pixelDCol=decimalToBaseX(DCol, 6, 2);
248  pixelPxl=decimalToBaseX((80-row)*2+LorR, 6, 3);
249 
250  std::cout<<"Pxl = "<<pixelPxl[2]<<pixelPxl[1]<<pixelPxl[0]<<", DCol= "<<pixelDCol[1]<<pixelDCol[0]<<std::endl;
251 
252  pulseTrain[i]=levelEncoder(pixelDCol[1]);++i;
253  pulseTrain[i]=levelEncoder(pixelDCol[0]);++i;
254  pulseTrain[i]=levelEncoder(pixelPxl[2]);++i;
255  pulseTrain[i]=levelEncoder(pixelPxl[1]);++i;
256  pulseTrain[i]=levelEncoder(pixelPxl[0]);++i;
257  pulseTrain[i]=charge;++i;
258 
259  }
260  else if (line.find("TBMTrailer")!=std::string::npos)
261  {
262  loc1=line.find("("); if (loc1==npos) {cout<< __LINE__ << "]\t" << mthn <<"'(' not found after TBMTrailer.\n"; break;}
263  loc2=line.find(")", loc1+1); if (loc2==npos) {cout<< __LINE__ << "]\t" << mthn <<"')' not found after TBMTrailer.\n"; break;}
264  int TBMTrailer=atoi(line.substr(loc1+1,loc2-loc1-1).c_str());
265 
266  pulseTrain[i]=UB;++i;
267  pulseTrain[i]=UB;++i;
268  pulseTrain[i]=B; ++i;
269  pulseTrain[i]=B; ++i;
270 
271  pixelTBMTrailer=decimalToBaseX(TBMTrailer, 4, 4);
272  pulseTrain[i]=levelEncoder(pixelTBMTrailer[3]);++i;
273  pulseTrain[i]=levelEncoder(pixelTBMTrailer[2]);++i;
274  pulseTrain[i]=levelEncoder(pixelTBMTrailer[1]);++i;
275  pulseTrain[i]=levelEncoder(pixelTBMTrailer[0]);++i;
276  }
277  }
278  fin.close();
279  dacs_=pulseTrain;
280 }
Definition: start.py:1
std::vector< unsigned int > dacs_
uint16_t size_type
static const std::string B
unsigned int levelEncoder(int level)
std::vector< unsigned int > decimalToBaseX(unsigned int a, unsigned int x, unsigned int length)
PixelFEDTestDAC::PixelFEDTestDAC ( std::vector< std::vector< std::string > > &  tableMat)

EXTENSION_TABLE_NAME: PIXEL_CALIB_CLOB (VIEW: CONF_KEY_PIXEL_CALIB_V)

CONFIG_KEY NOT NULL VARCHAR2(80) KEY_TYPE NOT NULL VARCHAR2(80) KEY_ALIAS NOT NULL VARCHAR2(80) VERSION VARCHAR2(40) KIND_OF_COND NOT NULL VARCHAR2(40) CALIB_TYPE VARCHAR2(200) CALIB_OBJ_DATA_FILE NOT NULL VARCHAR2(200) CALIB_OBJ_DATA_CLOB NOT NULL CLOB

Definition at line 12 of file PixelFEDTestDAC.cc.

References TtFullHadDaughter::B, EnergyCorrector::c, MessageLogger_cfi::cerr, ALCARECOTkAlJpsiMuMu_cff::charge, gather_cfg::cout, groupFilesInBlocks::fin, mps_fire::i, createfilelist::int, geometryCSVtoXML::line, gen::n, PFRecoTauDiscriminationByIsolation_cfi::offset, command_line::start, and AlCaHLTBitMon_QueryRunRegistry::string.

13 {
14 
15  std::string mthn = "[PixelFEDTestDAC::PixelFEDTestDAC()]\t\t\t " ;
16  const unsigned long int UB=200;
17  const unsigned long int B=500;
18  const unsigned long int offset=0;
19  vector <unsigned int> pulseTrain(256), pixelDCol(1), pixelPxl(2), pixelTBMHeader(3), pixelTBMTrailer(3);
20  unsigned int DCol, LorR, start=15;
22  std::string::size_type loc1, loc2, loc3, loc4;
23  unsigned long int npos=std::string::npos;
24  int i;
25 
26  std::map<std::string , int > colM;
27  std::vector<std::string > colNames;
42  colNames.push_back("CONFIG_KEY" );
43  colNames.push_back("KEY_TYPE" );
44  colNames.push_back("KEY_ALIAS" );
45  colNames.push_back("VERSION" );
46  colNames.push_back("KIND_OF_COND" );
47  colNames.push_back("CALIB_TYPE" );
48  colNames.push_back("CALIB_OBJ_DATA_FILE");
49  colNames.push_back("CALIB_OBJ_DATA_CLOB");
50 
51  for(unsigned int c = 0 ; c < tableMat[0].size() ; c++)
52  {
53  for(unsigned int n=0; n<colNames.size(); n++)
54  {
55  if(tableMat[0][c] == colNames[n])
56  {
57  colM[colNames[n]] = c;
58  break;
59  }
60  }
61  }//end for
62  for(unsigned int n=0; n<colNames.size(); n++)
63  {
64  if(colM.find(colNames[n]) == colM.end())
65  {
66  std::cerr << __LINE__ << "]\t" << mthn << "Couldn't find in the database the column with name " << colNames[n] << std::endl;
67  assert(0);
68  }
69  }
70 
71 
72  std::istringstream fin ;
73  fin.str(tableMat[1][colM["CALIB_OBJ_DATA_CLOB"]]) ;
74 
75  // Initialise the pulseTrain to offset+black
76  for (unsigned int i=0;i<pulseTrain.size();++i)
77  {
78  pulseTrain[i]=offset+B;
79  }
80 
81  i=start;
82 
83  getline(fin, line);
84  mode_=line;
85  assert(mode_=="EmulatedPhysics"||
86  mode_=="FEDBaselineWithTestDACs"||
87  mode_=="FEDAddressLevelWithTestDACs");
88 
89  while (!fin.eof())
90  {
91  getline(fin, line);
92 
93  if (line.find("TBMHeader")!=npos)
94  {
95  loc1=line.find("("); if (loc1==npos) {cout<< __LINE__ << "]\t" << mthn << "'(' not found after TBMHeader.\n"; break;}
96  loc2=line.find(")", loc1+1); if (loc2==npos) {cout<< __LINE__ << "]\t" << mthn << "')' not found after TBMHeader.\n"; break;}
97  int TBMHeader=atoi(line.substr(loc1+1,loc2-loc1-1).c_str());
98 
99  pulseTrain[i]=UB;++i;
100  pulseTrain[i]=UB;++i;
101  pulseTrain[i]=UB;++i;
102  pulseTrain[i]=B;++i;
103 
104  pixelTBMHeader=decimalToBaseX(TBMHeader, 4, 4);
105 
106  pulseTrain[i]=levelEncoder(pixelTBMHeader[3]);++i;
107  pulseTrain[i]=levelEncoder(pixelTBMHeader[2]);++i;
108  pulseTrain[i]=levelEncoder(pixelTBMHeader[1]);++i;
109  pulseTrain[i]=levelEncoder(pixelTBMHeader[0]);++i;
110  }
111  else if (line.find("ROCHeader")!=std::string::npos)
112  {
113  loc1=line.find("("); if (loc1==npos) {cout<< __LINE__ << "]\t" << mthn << "'(' not found after ROCHeader.\n"; break;}
114  loc2=line.find(")", loc1+1); if (loc2==npos) {cout<< __LINE__ << "]\t" << mthn << "')' not found after ROCHeader.\n"; break;}
115  int LastDAC=atoi(line.substr(loc1+1,loc2-loc1-1).c_str());
116 
117  std::cout<<"--------------"<<std::endl;
118 
119  pulseTrain[i]=UB;++i;
120  pulseTrain[i]=B;++i;
121  pulseTrain[i]=levelEncoder(LastDAC); ++i;
122  }
123  else if (line.find("PixelHit")!=std::string::npos) {
124 
125  loc1=line.find("("); if (loc1==npos) {cout<< __LINE__ << "]\t" << mthn << "'(' not found after PixelHit.\n"; break;}
126  loc2=line.find(",", loc1+1); if (loc2==npos) {cout<< __LINE__ << "]\t" << mthn << "',' not found after the first argument of PixelHit.\n"; break;}
127  loc3=line.find(",", loc2+1); if (loc3==npos) {cout<< __LINE__ << "]\t" << mthn << "'.' not found after the second argument of PixelHit.\n"; break;}
128  loc4=line.find(")", loc3+1); if (loc4==npos) {cout<< __LINE__ << "]\t" << mthn << "')' not found after the third argument of PixelHit.\n"; break;}
129  int column=atoi(line.substr(loc1+1, loc2-loc1-1).c_str());
130  int row=atoi(line.substr(loc2+1, loc3-loc2-1).c_str());
131  int charge=atoi(line.substr(loc3+1, loc4-loc3-1).c_str());
132 
133  DCol=int(column/2);
134  LorR=int(column-DCol*2);
135  pixelDCol=decimalToBaseX(DCol, 6, 2);
136  pixelPxl=decimalToBaseX((80-row)*2+LorR, 6, 3);
137 
138  std::cout<<"Pxl = "<<pixelPxl[2]<<pixelPxl[1]<<pixelPxl[0]<<", DCol= "<<pixelDCol[1]<<pixelDCol[0]<<std::endl;
139 
140  pulseTrain[i]=levelEncoder(pixelDCol[1]);++i;
141  pulseTrain[i]=levelEncoder(pixelDCol[0]);++i;
142  pulseTrain[i]=levelEncoder(pixelPxl[2]);++i;
143  pulseTrain[i]=levelEncoder(pixelPxl[1]);++i;
144  pulseTrain[i]=levelEncoder(pixelPxl[0]);++i;
145  pulseTrain[i]=charge;++i;
146 
147  }
148  else if (line.find("TBMTrailer")!=std::string::npos)
149  {
150  loc1=line.find("("); if (loc1==npos) {cout<< __LINE__ << "]\t" << mthn <<"'(' not found after TBMTrailer.\n"; break;}
151  loc2=line.find(")", loc1+1); if (loc2==npos) {cout<< __LINE__ << "]\t" << mthn <<"')' not found after TBMTrailer.\n"; break;}
152  int TBMTrailer=atoi(line.substr(loc1+1,loc2-loc1-1).c_str());
153 
154  pulseTrain[i]=UB;++i;
155  pulseTrain[i]=UB;++i;
156  pulseTrain[i]=B; ++i;
157  pulseTrain[i]=B; ++i;
158 
159  pixelTBMTrailer=decimalToBaseX(TBMTrailer, 4, 4);
160  pulseTrain[i]=levelEncoder(pixelTBMTrailer[3]);++i;
161  pulseTrain[i]=levelEncoder(pixelTBMTrailer[2]);++i;
162  pulseTrain[i]=levelEncoder(pixelTBMTrailer[1]);++i;
163  pulseTrain[i]=levelEncoder(pixelTBMTrailer[0]);++i;
164  }
165  }
166 // fin.close();
167  dacs_=pulseTrain;
168 }
Definition: start.py:1
std::vector< unsigned int > dacs_
uint16_t size_type
static const std::string B
unsigned int levelEncoder(int level)
std::vector< unsigned int > decimalToBaseX(unsigned int a, unsigned int x, unsigned int length)

Member Function Documentation

std::vector<unsigned int> pos::PixelFEDTestDAC::dacs ( )
inline
vector< unsigned int > PixelFEDTestDAC::decimalToBaseX ( unsigned int  a,
unsigned int  x,
unsigned int  length 
)
private

Definition at line 303 of file PixelFEDTestDAC.cc.

References mps_fire::i.

Referenced by dacs().

303  {
304 
305  vector<unsigned int> ans(100,0);
306  int i=0;
307 
308  while (a>0)
309  {
310  ans[i]=a%x;
311  //ans.push_back(a%x);
312  a=a/x;
313  i+=1;
314  }
315 
316  if (length>0) ans.resize(length); else ans.resize(i);
317 
318  return ans;
319 }
double a
Definition: hdecay.h:121
unsigned int PixelFEDTestDAC::levelEncoder ( int  level)
private

Definition at line 283 of file PixelFEDTestDAC.cc.

References pulse().

Referenced by dacs().

283  {
284 
285  unsigned int pulse;
286 
287  switch (level)
288  {
289  case 0: pulse=450; break;
290  case 1: pulse=500; break;
291  case 2: pulse=550; break;
292  case 3: pulse=600; break;
293  case 4: pulse=650; break;
294  case 5: pulse=700; break;
295  default: assert(0); break;
296  }
297 
298  return pulse;
299 
300 }
double pulse(double x, double y, double z, double t)
std::string pos::PixelFEDTestDAC::mode ( ) const
inlineoverridevirtual

Reimplemented from pos::PixelCalibBase.

Definition at line 34 of file PixelFEDTestDAC.h.

References pos::PixelCalibBase::mode_.

34 {return mode_;}
void PixelFEDTestDAC::writeXML ( std::ofstream *  out,
std::ofstream *  out1 = nullptr,
std::ofstream *  out2 = nullptr 
) const
overridevirtual

Reimplemented from pos::PixelCalibBase.

Definition at line 369 of file PixelFEDTestDAC.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by dacs().

372 {
373  std::string mthn = "[PixelFEDTestDAC::writeXML()]\t\t\t " ;
374 
375 
376  *outstream << " " << std::endl ;
377  *outstream << " <DATA>" << std::endl ;
378  *outstream << " <CALIB_OBJ_DATA_FILE>./fedtestdac.dat</CALIB_OBJ_DATA_FILE>" << std::endl ;
379  *outstream << " <CALIB_TYPE>fedtestdac</CALIB_TYPE>" << std::endl ;
380  *outstream << " </DATA>" << std::endl ;
381  *outstream << " " << std::endl ;
382 }
void PixelFEDTestDAC::writeXMLHeader ( pos::PixelConfigKey  key,
int  version,
std::string  path,
std::ofstream *  out,
std::ofstream *  out1 = nullptr,
std::ofstream *  out2 = nullptr 
) const
overridevirtual

Reimplemented from pos::PixelCalibBase.

Definition at line 322 of file PixelFEDTestDAC.cc.

References gather_cfg::cout, edmStreamStallGrapher::getTime(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by dacs().

328 {
329  std::string mthn = "[PixelFEDTestDAC::writeXMLHeader()]\t\t\t " ;
330  std::stringstream maskFullPath ;
331 
332 // writeASCII(path) ;
333 
334  maskFullPath << path << "/PixelCalib_Test_" << PixelTimeFormatter::getmSecTime() << ".xml";
335  std::cout << __LINE__ << "]\t" << mthn << "Writing to: " << maskFullPath.str() << std::endl ;
336 
337  outstream->open(maskFullPath.str().c_str()) ;
338 
339  *outstream << "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl ;
340  *outstream << "<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl ;
341  *outstream << "" << std::endl ;
342  *outstream << " <HEADER>" << std::endl ;
343  *outstream << " <TYPE>" << std::endl ;
344  *outstream << " <EXTENSION_TABLE_NAME>PIXEL_CALIB_CLOB</EXTENSION_TABLE_NAME>" << std::endl ;
345  *outstream << " <NAME>Calibration Object Clob</NAME>" << std::endl ;
346  *outstream << " </TYPE>" << std::endl ;
347  *outstream << " <RUN>" << std::endl ;
348  *outstream << " <RUN_TYPE>PixelFEDTestDAC</RUN_TYPE>" << std::endl ;
349  *outstream << " <RUN_NUMBER>1</RUN_NUMBER>" << std::endl ;
350  *outstream << " <RUN_BEGIN_TIMESTAMP>" << PixelTimeFormatter::getTime() << "</RUN_BEGIN_TIMESTAMP>" << std::endl ;
351  *outstream << " <LOCATION>CERN P5</LOCATION>" << std::endl ;
352  *outstream << " </RUN>" << std::endl ;
353  *outstream << " </HEADER>" << std::endl ;
354  *outstream << "" << std::endl ;
355  *outstream << " <DATA_SET>" << std::endl ;
356  *outstream << "" << std::endl ;
357  *outstream << " <VERSION>" << version << "</VERSION>" << std::endl ;
358  *outstream << " <COMMENT_DESCRIPTION>No comment defined: this class does NOT inherit from PixelCalibBase</COMMENT_DESCRIPTION>" << std::endl ;
359  *outstream << " <CREATED_BY_USER>Unknown user</CREATED_BY_USER>" << std::endl ;
360  *outstream << "" << std::endl ;
361  *outstream << " <PART>" << std::endl ;
362  *outstream << " <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << std::endl ;
363  *outstream << " <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << std::endl ;
364  *outstream << " </PART>" << std::endl ;
365 
366 }
static std::string getmSecTime(void)
static std::string getTime(void)
void PixelFEDTestDAC::writeXMLTrailer ( std::ofstream *  out,
std::ofstream *  out1 = nullptr,
std::ofstream *  out2 = nullptr 
) const
overridevirtual

Reimplemented from pos::PixelCalibBase.

Definition at line 386 of file PixelFEDTestDAC.cc.

References gather_cfg::cout, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by dacs().

389 {
390  std::string mthn = "[PixelFEDTestDAC::writeXMLTrailer()]\t\t\t " ;
391 
392  *outstream << " </DATA_SET>" << std::endl ;
393  *outstream << "</ROOT>" << std::endl ;
394 
395  outstream->close() ;
396  std::cout << __LINE__ << "]\t" << mthn << "Data written " << std::endl ;
397 
398 }

Member Data Documentation

std::vector<unsigned int> pos::PixelFEDTestDAC::dacs_
private

Definition at line 55 of file PixelFEDTestDAC.h.

Referenced by dacs().