12 PixelFEDTestDAC::PixelFEDTestDAC(std::vector<std::vector<std::string> > & tableMat )
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;
23 unsigned long int npos=std::string::npos;
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");
51 for(
unsigned int c = 0 ;
c < tableMat[0].size() ;
c++)
53 for(
unsigned int n=0;
n<colNames.size();
n++)
55 if(tableMat[0][
c] == colNames[
n])
57 colM[colNames[
n]] =
c;
62 for(
unsigned int n=0;
n<colNames.size();
n++)
64 if(colM.find(colNames[
n]) == colM.end())
66 std::cerr << __LINE__ <<
"]\t" << mthn <<
"Couldn't find in the database the column with name " << colNames[
n] << std::endl;
72 std::istringstream
fin ;
73 fin.str(tableMat[1][colM[
"CALIB_OBJ_DATA_CLOB"]]) ;
76 for (
unsigned int i=0;i<pulseTrain.size();++
i)
78 pulseTrain[
i]=offset+
B;
85 assert(mode_==
"EmulatedPhysics"||
86 mode_==
"FEDBaselineWithTestDACs"||
87 mode_==
"FEDAddressLevelWithTestDACs");
93 if (line.find(
"TBMHeader")!=npos)
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());
100 pulseTrain[
i]=UB;++
i;
101 pulseTrain[
i]=UB;++
i;
104 pixelTBMHeader=decimalToBaseX(TBMHeader, 4, 4);
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;
111 else if (line.find(
"ROCHeader")!=std::string::npos)
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());
119 pulseTrain[
i]=UB;++
i;
121 pulseTrain[
i]=levelEncoder(LastDAC); ++
i;
123 else if (line.find(
"PixelHit")!=std::string::npos) {
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());
134 LorR=int(column-DCol*2);
135 pixelDCol=decimalToBaseX(DCol, 6, 2);
136 pixelPxl=decimalToBaseX((80-row)*2+LorR, 6, 3);
138 std::cout<<
"Pxl = "<<pixelPxl[2]<<pixelPxl[1]<<pixelPxl[0]<<
", DCol= "<<pixelDCol[1]<<pixelDCol[0]<<std::endl;
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;
148 else if (line.find(
"TBMTrailer")!=std::string::npos)
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());
154 pulseTrain[
i]=UB;++
i;
155 pulseTrain[
i]=UB;++
i;
156 pulseTrain[
i]=
B; ++
i;
157 pulseTrain[
i]=
B; ++
i;
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;
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;
182 unsigned long int npos=std::string::npos;
186 for (
unsigned int i=0;i<pulseTrain.size();++
i)
188 pulseTrain[
i]=offset+
B;
191 ifstream
fin(filename.c_str());
197 assert(mode_==
"EmulatedPhysics"||
198 mode_==
"FEDBaselineWithTestDACs"||
199 mode_==
"FEDAddressLevelWithTestDACs");
205 if (line.find(
"TBMHeader")!=npos)
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());
211 pulseTrain[
i]=UB;++
i;
212 pulseTrain[
i]=UB;++
i;
213 pulseTrain[
i]=UB;++
i;
216 pixelTBMHeader=decimalToBaseX(TBMHeader, 4, 4);
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;
223 else if (line.find(
"ROCHeader")!=std::string::npos)
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());
231 pulseTrain[
i]=UB;++
i;
233 pulseTrain[
i]=levelEncoder(LastDAC); ++
i;
235 else if (line.find(
"PixelHit")!=std::string::npos) {
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());
246 LorR=int(column-DCol*2);
247 pixelDCol=decimalToBaseX(DCol, 6, 2);
248 pixelPxl=decimalToBaseX((80-row)*2+LorR, 6, 3);
250 std::cout<<
"Pxl = "<<pixelPxl[2]<<pixelPxl[1]<<pixelPxl[0]<<
", DCol= "<<pixelDCol[1]<<pixelDCol[0]<<std::endl;
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;
260 else if (line.find(
"TBMTrailer")!=std::string::npos)
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());
266 pulseTrain[
i]=UB;++
i;
267 pulseTrain[
i]=UB;++
i;
268 pulseTrain[
i]=
B; ++
i;
269 pulseTrain[
i]=
B; ++
i;
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;
283 unsigned int PixelFEDTestDAC::levelEncoder(
int level){
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;
303 vector<unsigned int> PixelFEDTestDAC::decimalToBaseX (
unsigned int a,
unsigned int x,
unsigned int length){
305 vector<unsigned int> ans(100,0);
316 if (length>0) ans.resize(length);
else ans.resize(i);
325 std::ofstream *outstream,
326 std::ofstream *out1stream,
327 std::ofstream *out2stream)
const
329 std::string mthn =
"[PixelFEDTestDAC::writeXMLHeader()]\t\t\t " ;
330 std::stringstream maskFullPath ;
334 maskFullPath << path <<
"/PixelCalib_Test_" << PixelTimeFormatter::getmSecTime() <<
".xml";
335 std::cout << __LINE__ <<
"]\t" << mthn <<
"Writing to: " << maskFullPath.str() << std::endl ;
337 outstream->open(maskFullPath.str().c_str()) ;
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 ;
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 ;
369 void PixelFEDTestDAC::writeXML( std::ofstream *outstream,
370 std::ofstream *out1stream,
371 std::ofstream *out2stream)
const
373 std::string mthn =
"[PixelFEDTestDAC::writeXML()]\t\t\t " ;
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 ;
386 void PixelFEDTestDAC::writeXMLTrailer(std::ofstream *outstream,
387 std::ofstream *out1stream,
388 std::ofstream *out2stream )
const
390 std::string mthn =
"[PixelFEDTestDAC::writeXMLTrailer()]\t\t\t " ;
392 *outstream <<
" </DATA_SET>" << std::endl ;
393 *outstream <<
"</ROOT>" << std::endl ;
396 std::cout << __LINE__ <<
"]\t" << mthn <<
"Data written " << std::endl ;
tuple start
Check for commandline option errors.
tuple path
else: Piece not in the list, fine.