21 bool operator () (
DetId fFirst,
DetId fSecond)
const {
24 if (
first.genericSubdet () !=
second.genericSubdet ())
return first.genericSubdet () <
second.genericSubdet ();
25 if (
first.isHcalDetId ()) {
28 return f1.zside () != s1.zside () ?
f1.zside () < s1.zside () :
29 f1.iphi () != s1.iphi () ?
f1.iphi () < s1.iphi () :
30 f1.ietaAbs () != s1.ietaAbs () ?
f1.ietaAbs () < s1.ietaAbs () :
31 f1.depth () < s1.depth ();
38 class HcalElectronicsIdLess {
54 std::vector <std::string>
result;
57 for (
unsigned i = 0;
i <= fLine.size ();
i++) {
58 if (fLine [
i] ==
' ' ||
i == fLine.size ()) {
61 result.push_back (item);
67 if (empty) empty =
false;
74 std::vector <unsigned int>
result;
77 for (
unsigned i = 0;
i <= fLine.size ();
i++) {
78 if (fLine [
i] ==
',' ||
i == fLine.size ()) {
81 result.push_back (atoi (itemString.c_str()) );
87 if (empty) empty =
false;
94 std::vector <float>
result;
97 for (
unsigned i = 0;
i <= fLine.size ();
i++) {
98 if (fLine [
i] ==
',' ||
i == fLine.size ()) {
101 result.push_back (atof (itemString.c_str()) );
107 if (empty) empty =
false;
114 std::vector <double>
result;
117 for (
unsigned i = 0;
i <= fLine.size ();
i++) {
118 if (fLine [
i] ==
',' ||
i == fLine.size ()) {
121 result.push_back (atof (itemString.c_str()) );
127 if (empty) empty =
false;
135 return converter.getId ();
141 sprintf (buffer,
" %15s %15s %15s %15s",
142 converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str (),converter.getFlavor ().c_str ());
149 sprintf (buffer,
" %5s %4s %4s %10s",
150 converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str (),converter.getFlavor ().c_str ());
159 std::istringstream iss(s);
160 return !(iss >>
f >>
t).
fail();
163 template <
class T,
class S>
165 if (!fObject)
return false;
167 while (fInput.getline(buffer, 1024)) {
168 if (buffer [0] ==
'#')
continue;
170 if (items.size()==0)
continue;
171 if (items.size () < 8) {
172 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 8 items: eta, phi, depth, subdet, 4x values" << std::endl;
181 fCondObject =
new S(
id, atof (items [4].c_str()), atof (items [5].c_str()),
182 atof (items [6].c_str()), atof (items [7].c_str()));
183 fObject->addValues(*fCondObject);
194 sprintf (buffer,
"# %15s %15s %15s %15s %8s %8s %8s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"cap0",
"cap1",
"cap2",
"cap3",
"DetId");
196 std::vector<DetId> channels = fObject.getAllChannels ();
197 std::sort (channels.begin(), channels.end(), DetIdLess ());
198 for (std::vector<DetId>::iterator channel = channels.begin ();
199 channel != channels.end ();
201 const float*
values = fObject.getValues (*channel)->getValues ();
204 sprintf (buffer,
" %8.5f %8.5f %8.5f %8.5f %10X\n",
205 values[0], values[1], values[2], values[3], channel->rawId ());
212 template <
class T,
class S>
214 if (!fObject)
return false;
216 while (fInput.getline(buffer, 1024)) {
217 if (buffer [0] ==
'#')
continue;
219 if (items.size()==0)
continue;
220 if (items.size () < 5) {
221 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
230 fCondObject =
new S(
id, atof (items [4].c_str()) );
231 fObject->addValues(*fCondObject);
241 sprintf (buffer,
"# %15s %15s %15s %15s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
243 std::vector<DetId> channels = fObject.getAllChannels ();
244 std::sort (channels.begin(), channels.end(), DetIdLess ());
245 for (std::vector<DetId>::iterator channel = channels.begin ();
246 channel != channels.end ();
248 const float value = fObject.getValues (*channel)->getValue ();
250 sprintf (buffer,
" %8.5f %10X\n",
251 value, channel->rawId ());
257 template <
class T,
class S>
259 if (!fObject)
return false;
261 while (fInput.getline(buffer, 1024)) {
262 if (buffer [0] ==
'#')
continue;
264 if (items.size()==0)
continue;
265 if (items.size () < 5) {
266 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
275 fCondObject =
new S(
id, atoi (items [4].c_str()) );
276 fObject->addValues(*fCondObject);
286 sprintf (buffer,
"# %15s %15s %15s %15s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
288 std::vector<DetId> channels = fObject.getAllChannels ();
289 std::sort (channels.begin(), channels.end(), DetIdLess ());
290 for (std::vector<DetId>::iterator channel = channels.begin ();
291 channel != channels.end ();
293 const int value = fObject.getValues (*channel)->getValue ();
295 sprintf (buffer,
" %15d %10X\n",
296 value, channel->rawId ());
302 template <
class T,
class S>
304 if (!fObject)
return false;
306 while (fInput.getline(buffer, 1024)) {
307 if (buffer [0] ==
'#')
continue;
309 if (items.size()==0)
continue;
311 fCondObject =
new S(firstid.
rawId());
312 for(
int j = 0;
j != 10;
j++) fCondObject->setValue(atoi(items[4].c_str()), 0,
j, atof(items[
j+5].c_str()));
313 for(
int i = 1;
i != 40;
i++){
314 fInput.getline(buffer, 1024);
317 if(
id.rawId() != firstid.
rawId())
break;
318 for(
int j = 0;
j != 10;
j++) fCondObject->setValue(atoi(items[4].c_str()),
i%10,
j, atof(items[
j+5].c_str()));
320 fObject->addValues(*fCondObject);
329 sprintf (buffer,
"# %5s %5s %5s %5s %5s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
330 "eta",
"phi",
"dep",
"det",
"capid",
"c0",
"c1",
"c2",
"c3",
"c4",
"c5",
"c6",
"c7",
"c8",
"c9",
"DetId");
332 std::vector<DetId> channels = fObject.getAllChannels ();
333 std::sort (channels.begin(), channels.end(), DetIdLess ());
334 for (std::vector<DetId>::iterator channel = channels.begin ();
335 channel != channels.end ();
338 for(
int m = 0;
m != 4;
m++){
339 for(
int i = 0;
i != 10;
i++){
340 for(
int j = 0;
j != 10;
j++){
342 thisline[
j] = fObject.getValues(*channel)->getValue(
m,
i,
j);
346 sprintf(buffer,
" %5i %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %10X\n",
347 m, thisline[0], thisline[1], thisline[2], thisline[3], thisline[4], thisline[5], thisline[6], thisline[7],
348 thisline[8], thisline[9], channel->rawId());
390 if (!fObject)
return false;
392 while (fInput.getline(buffer, 1024)) {
393 if (buffer [0] ==
'#')
continue;
395 if (items.size()==0)
continue;
396 if (items.size () < 6) {
397 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 6 items: eta, phi, depth, subdet, param1, param2" << std::endl;
402 int packingScheme =0;
403 if(items.size ()>22) {
404 packingScheme = atoi (items [22].c_str());
409 if(packingScheme==0) {
410 param1=atoi (items [4].c_str());
411 param2=atoi (items [5].c_str());
414 if(packingScheme==1) {
416 int aabits[6]= {1,1, 8, 4, 4, 9};
417 int aamax[ 6]= {1,1,255,15,15,511};
419 int bbbits[10]={1, 4,1, 4,1, 4, 4, 4, 4, 4};
420 int bbmax [10]={1,15,1,15,1,15,15,15,15,15};
426 for(
int i=0;
i<6;
i++) {
429 float phase=atof (items [j].c_str());
430 float xphase=(phase+32.0)*4.0;
433 aa=atoi (items [j].c_str());
435 if(aa>aamax[
i] || aa<0) {
436 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n value for a"<<
i<<
" should be less than"<<aamax[
i]<< std::endl;
438 param1=param1|aa<<aashift;
439 aashift=aashift+aabits[
i];
445 for(
int i=0;
i<10;
i++) {
447 bb=atoi (items [j].c_str());
449 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n value for b"<<i<<
" should be less than"<<bbmax[
i]<< std::endl;
451 param2=param2|bb<<bbshift;
452 bbshift=bbshift+bbbits[
i];
473 std::sort (channels.begin(), channels.end(), DetIdLess ());
475 for (std::vector<DetId>::iterator channel = channels.begin ();
476 channel != channels.end ();
485 if(packingScheme==0) {
488 sprintf (buffer,
"# %15s %15s %15s %15s %18s %15s %10s\n",
"eta",
"phi",
"dep",
"det",
"firstSample",
"samplesToAdd",
"DetId");
491 sprintf (buffer,
" %15d %15d %16X\n",
496 if(packingScheme==1) {
499 char lineT[100],lineA[200],lineB[200];
501 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
502 sprintf (lineA,
" %31s",
"a0: correctForPhaseContainment"); fOutput << lineA;
503 sprintf (lineB,
" %36s",
"b0: useLeakCorrection\n"); fOutput << lineB;
505 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
506 sprintf (lineA,
" %31s",
"a1: correctForLeadingEdge"); fOutput << lineA;
507 sprintf (lineB,
" %36s",
"b1: leakCorrectionID\n"); fOutput << lineB;
509 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
510 sprintf (lineA,
" %31s",
"a2: correctionPhaseNS"); fOutput << lineA;
511 sprintf (lineB,
" %36s",
"b2: correctForTimeslew\n"); fOutput << lineB;
513 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
514 sprintf (lineA,
" %31s",
"a3: firstSample"); fOutput << lineA;
515 sprintf (lineB,
" %36s",
"b3: timeslewCorrectionID\n"); fOutput << lineB;
517 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
518 sprintf (lineA,
" %31s",
"a4: samplesToAdd"); fOutput << lineA;
519 sprintf (lineB,
" %36s",
"b4: correctTiming\n"); fOutput << lineB;
521 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
522 sprintf (lineA,
" %31s",
"a5: pulseShapeID"); fOutput << lineA;
523 sprintf (lineB,
" %36s",
"b5: firstAuxTS\n"); fOutput << lineB;
525 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
526 sprintf (lineA,
" %31s",
" "); fOutput << lineA;
527 sprintf (lineB,
" %36s",
"b6: specialCaseID\n"); fOutput << lineB;
529 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
530 sprintf (lineA,
" %31s",
" "); fOutput << lineA;
531 sprintf (lineB,
" %36s",
"b7: noiseFlaggingID\n"); fOutput << lineB;
533 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
534 sprintf (lineA,
" %31s",
" "); fOutput << lineA;
535 sprintf (lineB,
" %36s",
"b8: pileupCleaningID\n"); fOutput << lineB;
537 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
538 sprintf (lineA,
" %31s",
" "); fOutput << lineA;
539 sprintf (lineB,
" %36s",
"b9: packingScheme\n"); fOutput << lineB;
542 sprintf (lineT,
"# %5s %4s %4s %10s %11s %10s %10s",
"eta",
"phi",
"dep",
"det",
"param1",
"param2",
"DetId");
545 sprintf (lineA,
" %6s %4s %6s %4s %4s %4s",
"a0",
"a1",
"a2",
"a3",
"a4",
"a5");
548 sprintf (lineB,
" %6s %3s %3s %3s %3s %3s %3s %3s %3s\n",
"b0",
"b1",
"b2",
"b3",
"b4",
"b5",
"b6",
"b7",
"b8");
553 sprintf (buffer,
" %11d %10d %10X", param1, param2, channel->rawId ());
562 sprintf (buffer,
" %6d %4d %6.1f %4d %4d %4d",aa0,aa1,aa2,aa3,aa4,aa5);
575 sprintf(buffer,
" %6d %3d %3d %3d %3d %3d %3d %3d %3d %3d\n",bb0,bb1,bb2,bb3,bb4,bb5,bb6,bb7,bb8,bb9);
585 if (!fObject)
return false;
587 while (fInput.getline(buffer, 1024)) {
588 if (buffer [0] ==
'#')
continue;
590 if (items.size()==0)
continue;
591 if (items.size() < 5) {
592 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 6 items: eta, phi, depth, subdet, signalTSs, noiseTSs" << std::endl;
595 if (items.size() > 7) {
596 edm::LogWarning(
"Format Problem ?") <<
"Check line: " << buffer <<
"\n line must contain 6 items: eta, phi, depth, subdet, signalTSs, noiseTSs. "
597 <<
"\n ! signalTS and noiseTS must be of format <ts1,ts2,ts3,...> withOUT spaces. Ignoring line for safety" << std::endl;
613 if (!fObject)
return false;
615 while (fInput.getline(buffer, 1024)) {
616 if (buffer [0] ==
'#')
continue;
618 if (items.size()==0)
continue;
619 if (items.size () < 7) {
620 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 7 items: eta, phi, depth, subdet, nhit, phase, rms,detid" << std::endl;
642 sprintf (buffer,
"# %15s %15s %15s %15s %15s %15s %15s %15s\n",
"eta",
"phi",
"dep",
"det",
"nhit",
"mean",
"rms" ,
"DetId");
645 std::sort (channels.begin(), channels.end(), DetIdLess ());
646 for (std::vector<DetId>::iterator channel = channels.begin ();
647 channel != channels.end ();
650 sprintf (buffer,
" %15d %8.5f %8.5f %16X\n",
660 sprintf (buffer,
"# %15s %15s %15s %15s %10s %10s %10s\n",
"eta",
"phi",
"dep",
"det",
"signalTSs",
"noiseTSs",
"DetId");
663 std::sort (channels.begin(), channels.end(), DetIdLess ());
664 for (std::vector<DetId>::iterator channel = channels.begin ();
665 channel != channels.end ();
668 if (fId.isHcalZDCDetId())
671 std::vector<unsigned int> vNoiseTS = fObject.
getValues (*channel)->
noiseTS();
673 sprintf (buffer,
" ");
675 for (
unsigned int i=0;
i<vSignalTS.size();
i++)
677 if (
i>0) {sprintf (buffer,
","); fOutput << buffer;}
678 sprintf (buffer,
"%u", vSignalTS.at(
i));
681 sprintf (buffer,
" ");
683 for (
unsigned int i=0;
i<vNoiseTS.size();
i++)
685 if (
i>0) { sprintf (buffer,
","); fOutput << buffer;}
686 sprintf (buffer,
"%u", vNoiseTS.at(
i));
689 sprintf (buffer,
" %10X\n", channel->rawId ());
698 if (!fObject)
return false;
700 while (fInput.getline(buffer, 1024)) {
701 if (buffer [0] ==
'#')
continue;
703 if (items.size()==0)
continue;
704 if (items.size () < 5) {
705 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 5 items: eta, phi, depth, subdet, signalShape" << std::endl;
711 if(items.size ()>11) {
712 packingScheme = atoi (items [11].c_str());
716 if(packingScheme==0) {
717 param1=atoi (items [4].c_str());
720 if(packingScheme==1) {
721 int aabits[6]={ 9,1, 4, 8,5, 4};
722 int aamax [6]={511,1,15,255,1,16};
726 for(
int i=0;
i<6;
i++) {
729 float phase=atof (items [j].c_str());
730 float xphase=(phase+32.0)*4.0;
733 aa=atoi (items [j].c_str());
735 if(aa>aamax[
i] || aa<0) {
736 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n value for a"<<
i<<
" should be less than"<<aamax[
i]<< std::endl;
739 param1=param1|aa<<aashift;
740 aashift=aashift+aabits[
i];
756 std::sort (channels.begin(), channels.end(), DetIdLess ());
758 for (std::vector<DetId>::iterator channel = channels.begin ();
759 channel != channels.end ();
763 if(packingScheme==0) {
765 sprintf (buffer,
"# %15s %15s %15s %15s %14s %10s\n",
"eta",
"phi",
"dep",
"det",
"signalShape",
"DetId");
770 sprintf (buffer,
" %10d %17X\n", value, channel->rawId ());
773 if(packingScheme==1) {
775 char lineT[100],lineA[200];
777 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
778 sprintf (lineA,
" %31s",
"a0: signalShape\n"); fOutput << lineA;
779 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
780 sprintf (lineA,
" %31s",
"a1: syncPhase\n"); fOutput << lineA;
781 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
782 sprintf (lineA,
" %31s",
"a2: binOfMaximum\n"); fOutput << lineA;
783 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
784 sprintf (lineA,
" %31s",
"a3: timePhase\n"); fOutput << lineA;
785 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
786 sprintf (lineA,
" %31s",
"a4: timeSmearing\n"); fOutput << lineA;
787 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
788 sprintf (lineA,
" %31s",
"a5: packingScheme\n"); fOutput << lineA;
789 sprintf (lineT,
"# %5s %4s %4s %10s %11s %10s",
"eta",
"phi",
"dep",
"det",
"param1",
"DetId");
791 sprintf (lineA,
" %6s %4s %4s %6s %4s %4s\n",
"a0",
"a1",
"a2",
"a3",
"a4",
"a5");
796 sprintf (buffer,
" %11d %10X", param1, channel->rawId ());
804 sprintf (buffer,
"%6d %4d %4d %6.1f %4d %4d\n",aa0,aa1,aa2,aa3,aa4,aa5);
814 while (fInput.getline(buffer, 1024)) {
816 if (items.size()==0)
continue;
818 if (items[0] ==
"#U")
824 edm::LogWarning(
"Pedestal Unit Error") <<
"Unrecognized unit for pedestals. Assuming fC." << std::endl;
831 edm::LogWarning(
"Pedestal Unit Missing") <<
"The unit for the pedestals is missing in the txt file." << std::endl;
836 while (fInput.getline(buffer, 1024)) {
837 if (buffer [0] ==
'#')
continue;
839 if (items.size()==0)
continue;
840 if (items.size () < 8) {
841 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 8 items: eta, phi, depth, subdet, 4x values"
842 <<
" or 12 items: eta, phi, depth, subdet, 4x values for mean, 4x values for width"
853 if (items.size() < 12)
856 atof (items [6].c_str()), atof (items [7].c_str()),
864 atof (items [6].c_str()), atof (items [7].c_str()),
865 atof (items [8].c_str()), atof (items [9].c_str()),
866 atof (items [10].c_str()), atof (items [11].c_str()) );
879 if (fObject.
isADC() ) sprintf (buffer,
"#U ADC << this is the unit \n");
880 else sprintf (buffer,
"#U fC << this is the unit \n");
883 sprintf (buffer,
"# %15s %15s %15s %15s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"cap0",
"cap1",
"cap2",
"cap3",
"widthcap0",
"widthcap1",
"widthcap2",
"widthcap3",
"DetId");
887 std::sort (channels.begin(), channels.end(), DetIdLess ());
888 for (std::vector<DetId>::iterator channel = channels.begin ();
889 channel != channels.end ();
893 dumpId (fOutput, *channel);
894 sprintf (buffer,
" %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %10X\n",
895 values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], channel->rawId ());
906 if (!fObject)
return false;
908 while (fInput.getline(buffer, 1024)) {
909 if (buffer [0] ==
'#')
continue;
911 if (items.size()==0)
continue;
912 if (items.size () < 6) {
913 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 6 items: eta, phi, depth, subdet, base - either (hex) or (dec), value" << std::endl;
923 if (items[4] ==
"(hex)")
924 sscanf(items[5].c_str(),
"%X", &mystatus);
925 else if (items[4] ==
"(dec)")
926 sscanf(items[5].c_str(),
"%u", &mystatus);
929 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n value field must contain the base: one of (hex), (dec)" << std::endl;
944 sprintf (buffer,
"# %15s %15s %15s %15s %15s %10s\n",
"eta",
"phi",
"dep",
"det",
"(base) value",
"DetId");
947 std::sort (channels.begin(), channels.end(), DetIdLess ());
948 for (std::vector<DetId>::iterator channel = channels.begin ();
949 channel != channels.end ();
952 dumpId (fOutput, *channel);
953 sprintf (buffer,
"%6s %15X %10X\n",
"(hex)",
954 value, channel->rawId ());
966 while (fInput.getline(buffer, 1024)) {
967 if (buffer [0] ==
'#')
969 if (buffer [1] ==
'T')
975 if (buffer [1] ==
'A')
984 if (items.size()==0)
continue;
985 if (items.size () < 7) {
986 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 7 items: eta, phi, depth, subdet, pedestal, resp.corr.gain, flag" << std::endl;
1003 sprintf (buffer,
"#T %s << this is the tag name \n", fObject.
getTagString().c_str() );
1005 sprintf (buffer,
"#A %s << this is the algorithm name \n", fObject.
getAlgoString().c_str() );
1009 sprintf (buffer,
"# %15s %15s %15s %15s %8s %13s %8s %10s\n",
1010 "eta",
"phi",
"dep",
"det",
"ped",
"respcorrgain",
"flag",
1015 for (std::vector<DetId>::iterator channel = channels.begin ();
1016 channel != channels.end ();
1020 dumpId (fOutput, *channel);
1021 sprintf (buffer,
" %10.7f %10.7f %12d %10X\n",
1034 int linecounter = 0;
1036 while (fInput.getline(buffer, 1024)) {
1039 if (items.size()==0)
continue;
1047 edm::LogWarning(
"Pedestal Width Unit Error") <<
"Unrecognized unit for pedestal widths. Assuming fC." << std::endl;
1054 edm::LogWarning(
"Pedestal Width Unit Missing") <<
"The unit for the pedestal widths is missing in the txt file." << std::endl;
1060 while (fInput.getline(buffer, 1024)) {
1062 if (buffer [0] ==
'#')
continue;
1064 if (items.size()==0)
continue;
1065 if (items.size () < 14) {
1066 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line number: " << linecounter <<
"\n line must contain 14 items: eta, phi, depth, subdet, 10x correlations"
1067 <<
" or 20 items: eta, phi, depth, subdet, 16x correlations"
1078 if (items.size() < 20)
1081 values.setSigma (0, 0, atof (items [4].c_str()));
1082 values.setSigma (1, 0, atof (items [5].c_str()));
1083 values.setSigma (1, 1, atof (items [6].c_str()));
1084 values.setSigma (2, 0, atof (items [7].c_str()));
1085 values.setSigma (2, 1, atof (items [8].c_str()));
1086 values.setSigma (2, 2, atof (items [9].c_str()));
1087 values.setSigma (3, 0, atof (items [10].c_str()));
1088 values.setSigma (3, 1, atof (items [11].c_str()));
1089 values.setSigma (3, 2, atof (items [12].c_str()));
1090 values.setSigma (3, 3, atof (items [13].c_str()));
1091 values.setSigma (0, 1, 0.);
1092 values.setSigma (0, 2, 0.);
1093 values.setSigma (0, 3, 0.);
1094 values.setSigma (1, 2, 0.);
1095 values.setSigma (1, 3, 0.);
1096 values.setSigma (2, 3, 0.);
1102 values.setSigma (0, 0, atof (items [4].c_str()) );
1103 values.setSigma (0, 1, atof (items [5].c_str()) );
1104 values.setSigma (0, 2, atof (items [6].c_str()) );
1105 values.setSigma (0, 3, atof (items [7].c_str()) );
1106 values.setSigma (1, 0, atof (items [8].c_str()) );
1107 values.setSigma (1, 1, atof (items [9].c_str()) );
1108 values.setSigma (1, 2, atof (items [10].c_str()) );
1109 values.setSigma (1, 3, atof (items [11].c_str()) );
1110 values.setSigma (2, 0, atof (items [12].c_str()) );
1111 values.setSigma (2, 1, atof (items [13].c_str()) );
1112 values.setSigma (2, 2, atof (items [14].c_str()) );
1113 values.setSigma (2, 3, atof (items [15].c_str()) );
1114 values.setSigma (3, 0, atof (items [16].c_str()) );
1115 values.setSigma (3, 1, atof (items [17].c_str()) );
1116 values.setSigma (3, 2, atof (items [18].c_str()) );
1117 values.setSigma (3, 3, atof (items [19].c_str()) );
1128 if (fObject.
isADC() ) sprintf (buffer,
"#U ADC << this is the unit \n");
1129 else sprintf (buffer,
"#U fC << this is the unit \n");
1132 sprintf (buffer,
"# %15s %15s %15s %15s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
1133 "eta",
"phi",
"dep",
"det",
1134 "cov_0_0",
"cov_0_1",
"cov_0_2",
"cov_0_3",
"cov_1_0",
"cov_1_1",
"cov_1_2",
"cov_1_3",
"cov_2_0",
"cov_2_1",
"cov_2_2",
"cov_2_3",
"cov_3_0",
"cov_3_1",
"cov_3_2",
"cov_3_3",
1138 std::sort (channels.begin(), channels.end(), DetIdLess ());
1139 for (std::vector<DetId>::iterator channel = channels.begin ();
1140 channel != channels.end ();
1144 dumpId (fOutput, *channel);
1145 sprintf (buffer,
" %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %10X\n",
1160 while (fInput.getline(buffer, 1024)) {
1161 if (buffer [0] ==
'#')
continue;
1163 if (items.size()<1)
continue;
1164 if (items [0] ==
"SHAPE") {
1168 if (items.size () < 36) {
1169 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 36 items: eta, phi, depth, subdet, 4 capId x 4 Ranges x offsets, 4 capId x 4 Ranges x slopes" << std::endl;
1181 for (
unsigned capid = 0; capid < 4; capid++) {
1182 for (
unsigned range = 0; range < 4; range++) {
1183 coder.setOffset (capid, range, atof (items [index++].c_str ()));
1186 for (
unsigned capid = 0; capid < 4; capid++) {
1187 for (
unsigned range = 0; range < 4; range++) {
1188 coder.setSlope (capid, range, atof (items [index++].c_str ()));
1191 if (items.size()>36)
1192 coder.setQIEIndex(atoi(items[index++].c_str()));
1206 fOutput <<
"# QIE data" << std::endl;
1207 sprintf (buffer,
"# %15s %15s %15s %15s %36s %36s %36s %36s %36s %36s %36s %36s\n",
1208 "eta",
"phi",
"dep",
"det",
1209 "4 x offsets cap0",
"4 x offsets cap1",
"4 x offsets cap2",
"4 x offsets cap3",
1210 "4 x slopes cap0",
"4 x slopes cap1",
"4 x slopes cap2",
"4 x slopes cap3");
1213 std::sort (channels.begin(), channels.end(), DetIdLess ());
1214 for (std::vector<DetId>::iterator channel = channels.begin ();
1215 channel != channels.end ();
1218 dumpId (fOutput, *channel);
1219 for (
unsigned capid = 0; capid < 4; capid++) {
1220 for (
unsigned range = 0; range < 4; range++) {
1221 sprintf (buffer,
" %8.5f", coder->
offset (capid, range));
1225 for (
unsigned capid = 0; capid < 4; capid++) {
1226 for (
unsigned range = 0; range < 4; range++) {
1227 sprintf (buffer,
" %8.5f", coder->
slope (capid, range));
1231 sprintf (buffer,
" %2d", coder->
qieIndex());
1233 fOutput << std::endl;
1241 while (fInput.getline(buffer, 1024)) {
1242 if (buffer [0] ==
'#')
continue;
1244 if (items.size () < 36) {
1245 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 36 items: eta, phi, depth, subdet, 32 bin values" << std::endl;
1258 for (
unsigned bin = 0;
bin < 32;
bin++) {
1259 values[
bin] = atof (items [index++].c_str ());
1261 coder.setMinCharges (values);
1271 fOutput <<
"# QIE data in calibration mode" << std::endl;
1272 sprintf (buffer,
"# %15s %15s %15s %15s %288s\n",
1273 "eta",
"phi",
"dep",
"det",
"32 x charges");
1276 std::sort (channels.begin(), channels.end(), DetIdLess ());
1277 for (std::vector<DetId>::iterator channel = channels.begin ();
1278 channel != channels.end ();
1282 dumpId (fOutput, *channel);
1284 for (
unsigned bin = 0;
bin < 32;
bin++) {
1285 sprintf (buffer,
" %8.5f", lowEdge [
bin]);
1288 fOutput << std::endl;
1298 while (fInput.getline(buffer, 1024)) {
1299 if (buffer [0] ==
'#')
continue;
1301 if (items.size () < 12) {
1302 if (items.size()==0)
continue;
1303 if (items.size()<9) {
1304 edm::LogError(
"MapFormat") <<
"HcalElectronicsMap-> line too short: " << buffer;
1307 if (items[8]==
"NA" || items[8]==
"NT") {
1308 while (items.size()<12) items.push_back(
"");
1309 }
else if (items[8]==
"HT") {
1310 if (items.size()==11) items.push_back(
"");
1312 edm::LogError(
"MapFormat") <<
"HcalElectronicsMap-> Bad line: " << buffer
1313 <<
"\n HT line must contain at least 11 items: i cr sl tb dcc spigot fiber fiberchan subdet=HT ieta iphi";
1317 edm::LogError(
"MapFormat") <<
"HcalElectronicsMap-> Bad line: " << buffer
1318 <<
"\n line must contain 12 items: i cr sl tb dcc spigot fiber fiberchan subdet ieta iphi depth";
1323 int crate = atoi (items [1].c_str());
1324 int slot = atoi (items [2].c_str());
1326 if (items [3] ==
"b") top = 0;
1327 int dcc = atoi (items [4].c_str());
1328 int spigot = atoi (items [5].c_str());
1330 if (items[8] ==
"HT" || items[8] ==
"NT") {
1331 int slb = atoi (items [6].c_str());
1332 int slbCh = atoi (items [7].c_str());
1335 int fiber = atoi (items [6].c_str());
1336 int fiberCh = atoi (items [7].c_str());
1339 elId.
setHTR (crate, slot, top);
1343 if (items [8] ==
"NA") {
1345 }
else if (items [8] ==
"NT") {
1349 if (converter.isHcalDetId ()) {
1352 else if (converter.isHcalTrigTowerDetId ()) {
1353 fObject->
mapEId2tId (elId, converter.getId ());
1355 else if (converter.isHcalCalibDetId ()) {
1358 else if (converter.isHcalZDCDetId ()) {
1362 edm::LogWarning(
"Format Error") <<
"HcalElectronicsMap-> Unknown subdetector: "
1363 << items [8] <<
'/' << items [9] <<
'/' << items [10] <<
'/' << items [11] << std::endl;
1376 sprintf (buf,
"# %7s %3s %3s %3s %4s %7s %10s %14s %7s %5s %5s %6s",
1377 "i",
"cr",
"sl",
"tb",
"dcc",
"spigot",
"fiber/slb",
"fibcha/slbcha",
"subdet",
"ieta",
"iphi",
"depth");
1378 fOutput << buf << std::endl;
1380 for (
unsigned i = 0;
i < eids.size ();
i++) {
1384 if (trigger.
rawId ()) {
1388 sprintf (buf,
" %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
1390 converter.getId().rawId(),
1394 converter.getFlavor ().c_str (), converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str ()
1396 fOutput << buf << std::endl;
1400 if (channel.
rawId()) {
1404 sprintf (buf,
" %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
1406 converter.getId().rawId(),
1408 converter.getFlavor ().c_str (), converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str ()
1410 fOutput << buf << std::endl;
1419 if (!fObject)
return false;
1421 while (fInput.getline(buffer, 1024)) {
1422 if (buffer [0] ==
'#')
continue;
1424 if (items.size()==0)
continue;
1426 if (items.size() > 1 &&
1427 items[0].find(
"RctLsb")!=std::string::npos){
1428 fObject->
setRctLsb( atof( items[1].c_str() ) );
1431 if (items.size() > 1 &&
1432 items[0].find(
"Gain")!=std::string::npos){
1437 if (items.size () < 7) {
1438 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 7 items: eta, phi, depth, subdet, Rcalib, LutGranularity, OutputLutThreshold" << std::endl;
1444 atof (items [4].c_str()),
1445 atoi (items [5].c_str()),
1446 atoi (items [6].c_str()));
1456 const float _rctLsb = fObject.
getRctLsb();
1458 sprintf (buffer,
"# %20s\n",
"Non-channel data");
1460 sprintf (buffer,
"%8s %8.5f\n",
"RctLsb", _rctLsb);
1462 sprintf (buffer,
"%8s %8.5f\n",
"Gain", _gain);
1464 sprintf (buffer,
"# %15s %15s %15s %15s %8s %15s %19s %10s\n",
"eta",
"phi",
"dep",
"det",
"Rcalib",
"LutGranularity",
"OutputLutThreshold",
"DetId");
1467 std::sort (channels.begin(), channels.end(), DetIdLess ());
1468 for (std::vector<DetId>::iterator channel = channels.begin ();
1469 channel != channels.end ();
1474 dumpId (fOutput, *channel);
1475 sprintf (buffer,
" %8.5f %15d %19d %10X\n",
1478 _outputLutThreshold,
1487 if (!fObject)
return false;
1489 while (getline(fInput, buffer)) {
1490 if (buffer.at(0) ==
'#')
continue;
1491 std::vector <std::string> items =
splitString (buffer);
1492 if (items.size()==0)
continue;
1494 if (items.size() < 9) {
1495 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 9 items: subDet, side_ring, slice, type, subChannel, LS, Value, UpperLimit, LowerLimit" << std::endl;
1501 unsigned int slice, subchan;
1502 switch (items[0].
at(1)) {
1519 from_string<int>(sidering, items[1], std::dec);
1520 from_string<unsigned int>(slice, items[2], std::dec);
1522 from_string<unsigned int>(subchan, items[4], std::dec);
1528 float val,
upper,lower;
1529 from_string<int>(LS, items[5], std::dec);
1530 from_string<float>(val, items[6], std::dec);
1531 from_string<float>(
upper, items[7], std::dec);
1532 from_string<float>(lower, items[8], std::dec);
1540 if (!(fObject->
addValue(newVal))) {
1542 <<
"\nwas not added to the HcalDcsValues object." << std::endl;
1552 fOutput <<
"# subDet side_ring slice type subChan LS Value UpperLimit LowerLimit DcsId\n";
1558 for (HcalDcsValues::DcsSet::const_iterator val = vals.begin();
1559 val != vals.end(); ++val) {
1562 switch (valId.subdet()) {
1576 fOutput << valId.subdet() <<
' ';
1580 fOutput << valId.ring() <<
' ';
1582 fOutput << valId.zside() <<
' ';
1584 fOutput << valId.slice() <<
' '
1585 << valId.typeString(valId.type()) <<
' '
1586 << valId.subchannel() <<
' ';
1587 fOutput << val->LS() <<
' '
1588 << val->getValue() <<
' '
1589 << val->getUpperLimit() <<
' '
1590 << val->getLowerLimit() <<
' ';
1591 fOutput << std::hex << val->DcsId() << std::dec <<
'\n';
1610 while (fInput.getline(buffer, 1024)) {
1611 if (buffer [0] ==
'#')
continue;
1613 if (items.size () < 8) {
1614 if (items.size()==0)
continue;
1616 edm::LogError(
"MapFormat") <<
"HcalDcsMap-> Bad line: " << buffer
1617 <<
"\n line must contain 8 items: line side_ring slice subchannel subdet ieta iphi depth";
1623 int ring = atoi(items[1].c_str());
1624 unsigned int slice = atoi (items [2].c_str());
1625 unsigned int subchannel = atoi (items [3].c_str());
1671 if (items[4].
find(
"CALIB")!=std::string::npos){
1674 else if (items[4].
find(
"HB")!=std::string::npos){
1677 else if (items[4].
find(
"HE")!=std::string::npos){
1680 else if (items[4].
find(
"HO")!=std::string::npos){
1683 else if (items[4].
find(
"HF")!=std::string::npos){
1687 edm::LogError(
"MapFormat") <<
"HcalDcsMap-> Unknown subdetector, line is not accepted: " << items[5];
1690 HcalDcsDetId dcsId(subdet, ring, slice, type, subchannel);
1693 if (converter.isHcalDetId()){
1694 id = converter.getId();
1697 edm::LogWarning(
"Invalid HCAL channel") <<
"HcalDcsMap-> invalid channel: "
1701 << items [7] << std::endl;
1715 sprintf (buf,
"# %7s %10s %6s %8s %7s %5s %5s %6s",
1716 "i",
"side_ring",
"slice",
"subchan",
"subdet",
"ieta",
"iphi",
"depth");
1717 fOutput << buf << std::endl;
1719 unsigned int line_counter = 0;
1726 sprintf (buf,
" %8X %10d %6d %8d %7s %5s %5s %6s",
1731 _converter.getFlavor().c_str(),
1732 _converter.getField1().c_str(),
1733 _converter.getField2().c_str(),
1734 _converter.getField3().c_str()
1736 fOutput << buf << std::endl;
1746 if (!fObject)
return false;
1748 while (fInput.getline(buffer, 1024)) {
1749 if (buffer [0] ==
'#')
continue;
1751 if (items.size()==0)
continue;
1752 if (items.size () != 9) {
1753 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain at 9 least items: eta, phi, depth, subdet, firstSample, samplesToAdd, ExpectedPeak, MinEnergy, and a set of comma-separated coefficients" << std::endl;
1761 atoi (items [4].c_str()),
1762 atoi (items [5].c_str()),
1763 atoi (items [6].c_str()),
1764 atof (items [7].c_str()),
1776 sprintf (buffer,
"# %15s %15s %15s %15s %15s %15s %15s %15s %30s\n",
"eta",
"phi",
"dep",
"det",
"FirstSample",
"SamplesToAdd",
"ExpectedPeak",
"MinEnergy",
"Coefficients");
1779 std::sort (channels.begin(), channels.end(), DetIdLess ());
1780 for (std::vector<DetId>::iterator channel = channels.begin ();
1781 channel != channels.end ();
1786 sprintf (buffer,
" %15u %15u %15u %15f",
1801 if (
x<coef.size()-1)
1804 sprintf(buffer,
"\n");
void dumpIdShort(std::ostream &fOutput, DetId id)
float getPedestal() const
unsigned int firstSample() const
static const HcalDetId Undefined
void setAlgoString(std::string fAlgo)
int fiberIndex() const
get the fiber index [1-8] (which of eight fibers carried by a spigot) (valid only for non-trigger-cha...
void setUnitADC(bool isADC)
float slope(unsigned fCapId, unsigned fRange) const
tuple start
Check for commandline option errors.
uint32_t qieIndex() const
unsigned int param2() const
bool getHcalSingleIntObject(std::istream &fInput, T *fObject, S *fCondObject)
std::vector< unsigned int > signalTS() const
bool getHcalSingleFloatObject(std::istream &fInput, T *fObject, S *fCondObject)
unsigned int pileupCleaningID() const
const HcalQIECoder * getCoder(DetId fId) const
get QIE parameters
bool timeSmearing() const
unsigned int packingScheme() const
float getSigma(int fCapId1, int fCapId2) const
get correlation element for capId1/2 = 0..3
bool mapGeomId2DcsId(HcalDetId fId, HcalDcsDetId fDcsId)
uint32_t HFdigiflagSamplesToAdd() const
bool getHcalMatrixObject(std::istream &fInput, T *fObject, S *fCondObject)
std::vector< float > splitStringToFloatByComma(const std::string &fLine)
DcsSet const & getAllSubdetValues(DcsSubDet subd) const
bool correctForPhaseContainment() const
int htrSlot() const
get the htr slot
std::vector< unsigned int > splitStringToIntByComma(const std::string &fLine)
const Item * getValues(DetId fId, bool throwOnFail=true) const
bool dumpHcalSingleFloatObject(std::ostream &fOutput, const T &fObject)
unsigned int noiseFlaggingID() const
bool mapEId2tId(HcalElectronicsId fElectronicsId, HcalTrigTowerDetId fTriggerId)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const HcalCalibrationQIECoder * getCoder(DetId fId) const
get QIE parameters
std::vector< std::string > splitString(const std::string &fLine)
unsigned int leakCorrectionID() const
bool addCoder(const HcalQIECoder &fCoder)
int readoutVMECrateId() const
get the readout VME crate number
void dumpId(std::ostream &fOutput, DetId id)
unsigned int param1() const
unsigned int specialCaseID() const
uint32_t rawId() const
get the raw id
U second(std::pair< T, U > const &p)
const_iterator endById(void) const
std::vector< HcalDcsValue > DcsSet
void setUnitADC(bool isADC)
float getRespGain() const
int htrTopBottom() const
get the htr top/bottom (1=top/0=bottom)
float offset(unsigned fCapId, unsigned fRange) const
const_iterator beginById(void) const
std::vector< DetId > getAllChannels() const
unsigned int param1() const
unsigned int nhits() const
HcalDetId getHcalDetId(void)
bool correctForTimeslew() const
bool correctTiming() const
int dccid() const
get the (Hcal local) DCC id
HcalDcsDetId getHcalDcsDetId(void)
bool dumpHcalMatrixObject(std::ostream &fOutput, const T &fObject)
uint32_t HFdigiflagExpectedPeak() const
int fiberChanId() const
get the fiber channel id (which of three channels on a readout fiber) (valid only for non-trigger-cha...
std::string getTagString() const
unsigned int samplesToAdd() const
bool mapEId2chId(HcalElectronicsId fElectronicsId, DetId fId)
float correctionPhaseNS() const
int spigot() const
get the spigot (input number on DCC)
unsigned int pulseShapeID() const
static DcsType DcsTypeFromString(const std::string &str)
int slbChannelIndex() const
get the SLB channel index (valid only for trigger-chain ids)
std::vector< double > HFdigiflagCoefficients() const
void setHTR(int crate, int slot, int tb)
std::string getAlgoString() const
std::vector< HcalElectronicsId > allElectronicsId() const
uint32_t HFdigiflagFirstSample() const
double S(const TLorentzVector &, const TLorentzVector &)
bool isTriggerChainId() const
unsigned int signalShape() const
static const HcalTrigTowerDetId Undefined
bool addValue(HcalDcsValue const &newVal)
bool getHcalObject(std::istream &fInput, T *fObject, S *fCondObject)
bool getObject(std::istream &fInput, HcalPedestals *fObject)
DetId getId(const std::vector< std::string > &items)
unsigned int binOfMaximum() const
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
int slbSiteNumber() const
get the SLB site number (valid only for trigger-chain ids)
unsigned int packingScheme() const
const float * getValues() const
get value for all capId = 0..3
bool dumpHcalObject(std::ostream &fOutput, const T &fObject)
std::vector< unsigned int > noiseTS() const
const DetId lookupTrigger(HcalElectronicsId fId) const
brief lookup the trigger logical detid associated with the given electronics id
unsigned int firstAuxTS() const
const float * minCharges() const
void setTagString(std::string fTag)
uint32_t getValue() const
bool correctForLeadingEdge() const
bool addCoder(const HcalCalibrationQIECoder &fCoder)
bool addValues(const Item &myItem)
Readout chain identification for Hcal [31:26] Unused (so far) [25] Trigger-chain id flag [24:20] Read...
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
bool dumpHcalSingleIntObject(std::ostream &fOutput, const T &fObject)
unsigned int timeslewCorrectionID() const
std::vector< double > splitStringToDoubleByComma(const std::string &fLine)
bool from_string(T &t, const std::string &s, std::ios_base &(*f)(std::ios_base &))
double HFdigiflagMinEThreshold() const
bool useLeakCorrection() const