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());
393 if (!fObject)
return false;
395 while (fInput.getline(buffer, 1024)) {
396 if (buffer [0] ==
'#')
continue;
398 if (items.size()==0)
continue;
399 if (items.size () < 6) {
400 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 6 items: eta, phi, depth, subdet, param1, param2" << std::endl;
405 int packingScheme =0;
406 if(items.size ()>22) {
407 packingScheme = atoi (items [22].c_str());
412 if(packingScheme==0) {
413 param1=atoi (items [4].c_str());
414 param2=atoi (items [5].c_str());
417 if(packingScheme==1) {
419 int aabits[6]= {1,1, 8, 4, 4, 9};
420 int aamax[ 6]= {1,1,255,15,15,511};
422 int bbbits[10]={1, 4,1, 4,1, 4, 4, 4, 4, 4};
423 int bbmax [10]={1,15,1,15,1,15,15,15,15,15};
429 for(
int i=0;
i<6;
i++) {
432 float phase=atof (items [j].c_str());
433 float xphase=(phase+32.0)*4.0;
436 aa=atoi (items [j].c_str());
438 if(aa>aamax[
i] || aa<0) {
439 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n value for a"<<
i<<
" should be less than"<<aamax[
i]<< std::endl;
441 param1=param1|aa<<aashift;
442 aashift=aashift+aabits[
i];
448 for(
int i=0;
i<10;
i++) {
450 bb=atoi (items [j].c_str());
452 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n value for b"<<i<<
" should be less than"<<bbmax[
i]<< std::endl;
454 param2=param2|bb<<bbshift;
455 bbshift=bbshift+bbbits[
i];
476 std::sort (channels.begin(), channels.end(), DetIdLess ());
478 for (std::vector<DetId>::iterator channel = channels.begin ();
479 channel != channels.end ();
488 if(packingScheme==0) {
491 sprintf (buffer,
"# %15s %15s %15s %15s %18s %15s %10s\n",
"eta",
"phi",
"dep",
"det",
"firstSample",
"samplesToAdd",
"DetId");
494 sprintf (buffer,
" %15d %15d %16X\n",
499 if(packingScheme==1) {
502 char lineT[100],lineA[200],lineB[200];
504 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
505 sprintf (lineA,
" %31s",
"a0: correctForPhaseContainment"); fOutput << lineA;
506 sprintf (lineB,
" %36s",
"b0: useLeakCorrection\n"); fOutput << lineB;
508 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
509 sprintf (lineA,
" %31s",
"a1: correctForLeadingEdge"); fOutput << lineA;
510 sprintf (lineB,
" %36s",
"b1: leakCorrectionID\n"); fOutput << lineB;
512 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
513 sprintf (lineA,
" %31s",
"a2: correctionPhaseNS"); fOutput << lineA;
514 sprintf (lineB,
" %36s",
"b2: correctForTimeslew\n"); fOutput << lineB;
516 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
517 sprintf (lineA,
" %31s",
"a3: firstSample"); fOutput << lineA;
518 sprintf (lineB,
" %36s",
"b3: timeslewCorrectionID\n"); fOutput << lineB;
520 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
521 sprintf (lineA,
" %31s",
"a4: samplesToAdd"); fOutput << lineA;
522 sprintf (lineB,
" %36s",
"b4: correctTiming\n"); fOutput << lineB;
524 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
525 sprintf (lineA,
" %31s",
"a5: pulseShapeID"); fOutput << lineA;
526 sprintf (lineB,
" %36s",
"b5: firstAuxTS\n"); fOutput << lineB;
528 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
529 sprintf (lineA,
" %31s",
" "); fOutput << lineA;
530 sprintf (lineB,
" %36s",
"b6: specialCaseID\n"); fOutput << lineB;
532 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
533 sprintf (lineA,
" %31s",
" "); fOutput << lineA;
534 sprintf (lineB,
" %36s",
"b7: noiseFlaggingID\n"); fOutput << lineB;
536 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
537 sprintf (lineA,
" %31s",
" "); fOutput << lineA;
538 sprintf (lineB,
" %36s",
"b8: pileupCleaningID\n"); fOutput << lineB;
540 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
541 sprintf (lineA,
" %31s",
" "); fOutput << lineA;
542 sprintf (lineB,
" %36s",
"b9: packingScheme\n"); fOutput << lineB;
545 sprintf (lineT,
"# %5s %4s %4s %10s %11s %10s %10s",
"eta",
"phi",
"dep",
"det",
"param1",
"param2",
"DetId");
548 sprintf (lineA,
" %6s %4s %6s %4s %4s %4s",
"a0",
"a1",
"a2",
"a3",
"a4",
"a5");
551 sprintf (lineB,
" %6s %3s %3s %3s %3s %3s %3s %3s %3s\n",
"b0",
"b1",
"b2",
"b3",
"b4",
"b5",
"b6",
"b7",
"b8");
556 sprintf (buffer,
" %11d %10d %10X", param1, param2, channel->rawId ());
565 sprintf (buffer,
" %6d %4d %6.1f %4d %4d %4d",aa0,aa1,aa2,aa3,aa4,aa5);
578 sprintf(buffer,
" %6d %3d %3d %3d %3d %3d %3d %3d %3d %3d\n",bb0,bb1,bb2,bb3,bb4,bb5,bb6,bb7,bb8,bb9);
588 if (!fObject)
return false;
590 while (fInput.getline(buffer, 1024)) {
591 if (buffer [0] ==
'#')
continue;
593 if (items.size()==0)
continue;
594 if (items.size() < 5) {
595 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 6 items: eta, phi, depth, subdet, signalTSs, noiseTSs" << std::endl;
598 if (items.size() > 7) {
599 edm::LogWarning(
"Format Problem ?") <<
"Check line: " << buffer <<
"\n line must contain 6 items: eta, phi, depth, subdet, signalTSs, noiseTSs. "
600 <<
"\n ! signalTS and noiseTS must be of format <ts1,ts2,ts3,...> withOUT spaces. Ignoring line for safety" << std::endl;
617 if (!fObject)
return false;
619 while (fInput.getline(buffer, 1024)) {
620 if (buffer [0] ==
'#')
continue;
622 if (items.size()==0)
continue;
623 if (items.size () < 7) {
624 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 7 items: eta, phi, depth, subdet, nhit, phase, rms,detid" << std::endl;
646 sprintf (buffer,
"# %15s %15s %15s %15s %15s %15s %15s %15s\n",
"eta",
"phi",
"dep",
"det",
"nhit",
"mean",
"rms" ,
"DetId");
649 std::sort (channels.begin(), channels.end(), DetIdLess ());
650 for (std::vector<DetId>::iterator channel = channels.begin ();
651 channel != channels.end ();
654 sprintf (buffer,
" %15d %8.5f %8.5f %16X\n",
664 sprintf (buffer,
"# %15s %15s %15s %15s %10s %10s %10s\n",
"eta",
"phi",
"dep",
"det",
"signalTSs",
"noiseTSs",
"DetId");
667 std::sort (channels.begin(), channels.end(), DetIdLess ());
668 for (std::vector<DetId>::iterator channel = channels.begin ();
669 channel != channels.end ();
672 if (fId.isHcalZDCDetId())
675 std::vector<unsigned int> vNoiseTS = fObject.
getValues (*channel)->
noiseTS();
677 sprintf (buffer,
" ");
679 for (
unsigned int i=0;
i<vSignalTS.size();
i++)
681 if (
i>0) {sprintf (buffer,
","); fOutput << buffer;}
682 sprintf (buffer,
"%u", vSignalTS.at(
i));
685 sprintf (buffer,
" ");
687 for (
unsigned int i=0;
i<vNoiseTS.size();
i++)
689 if (
i>0) { sprintf (buffer,
","); fOutput << buffer;}
690 sprintf (buffer,
"%u", vNoiseTS.at(
i));
693 sprintf (buffer,
" %10X\n", channel->rawId ());
702 if (!fObject)
return false;
704 while (fInput.getline(buffer, 1024)) {
705 if (buffer [0] ==
'#')
continue;
707 if (items.size()==0)
continue;
708 if (items.size () < 5) {
709 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 5 items: eta, phi, depth, subdet, signalShape" << std::endl;
715 if(items.size ()>11) {
716 packingScheme = atoi (items [11].c_str());
720 if(packingScheme==0) {
721 param1=atoi (items [4].c_str());
724 if(packingScheme==1) {
725 int aabits[6]={ 9,1, 4, 8,5, 4};
726 int aamax [6]={511,1,15,255,1,16};
730 for(
int i=0;
i<6;
i++) {
733 float phase=atof (items [j].c_str());
734 float xphase=(phase+32.0)*4.0;
737 aa=atoi (items [j].c_str());
739 if(aa>aamax[
i] || aa<0) {
740 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n value for a"<<
i<<
" should be less than"<<aamax[
i]<< std::endl;
743 param1=param1|aa<<aashift;
744 aashift=aashift+aabits[
i];
760 std::sort (channels.begin(), channels.end(), DetIdLess ());
762 for (std::vector<DetId>::iterator channel = channels.begin ();
763 channel != channels.end ();
767 if(packingScheme==0) {
769 sprintf (buffer,
"# %15s %15s %15s %15s %14s %10s\n",
"eta",
"phi",
"dep",
"det",
"signalShape",
"DetId");
774 sprintf (buffer,
" %10d %17X\n", value, channel->rawId ());
777 if(packingScheme==1) {
779 char lineT[100],lineA[200];
781 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
782 sprintf (lineA,
" %31s",
"a0: signalShape\n"); fOutput << lineA;
783 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
784 sprintf (lineA,
" %31s",
"a1: syncPhase\n"); fOutput << lineA;
785 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
786 sprintf (lineA,
" %31s",
"a2: binOfMaximum\n"); fOutput << lineA;
787 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
788 sprintf (lineA,
" %31s",
"a3: timePhase\n"); fOutput << lineA;
789 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
790 sprintf (lineA,
" %31s",
"a4: timeSmearing\n"); fOutput << lineA;
791 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
792 sprintf (lineA,
" %31s",
"a5: packingScheme\n"); fOutput << lineA;
793 sprintf (lineT,
"# %5s %4s %4s %10s %11s %10s",
"eta",
"phi",
"dep",
"det",
"param1",
"DetId");
795 sprintf (lineA,
" %6s %4s %4s %6s %4s %4s\n",
"a0",
"a1",
"a2",
"a3",
"a4",
"a5");
800 sprintf (buffer,
" %11d %10X", param1, channel->rawId ());
808 sprintf (buffer,
"%6d %4d %4d %6.1f %4d %4d\n",aa0,aa1,aa2,aa3,aa4,aa5);
818 while (fInput.getline(buffer, 1024)) {
820 if (items.size()==0)
continue;
822 if (items[0] ==
"#U")
828 edm::LogWarning(
"Pedestal Unit Error") <<
"Unrecognized unit for pedestals. Assuming fC." << std::endl;
835 edm::LogWarning(
"Pedestal Unit Missing") <<
"The unit for the pedestals is missing in the txt file." << std::endl;
840 while (fInput.getline(buffer, 1024)) {
841 if (buffer [0] ==
'#')
continue;
843 if (items.size()==0)
continue;
844 if (items.size () < 8) {
845 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 8 items: eta, phi, depth, subdet, 4x values"
846 <<
" or 12 items: eta, phi, depth, subdet, 4x values for mean, 4x values for width"
857 if (items.size() < 12)
860 atof (items [6].c_str()), atof (items [7].c_str()),
868 atof (items [6].c_str()), atof (items [7].c_str()),
869 atof (items [8].c_str()), atof (items [9].c_str()),
870 atof (items [10].c_str()), atof (items [11].c_str()) );
883 if (fObject.
isADC() ) sprintf (buffer,
"#U ADC << this is the unit \n");
884 else sprintf (buffer,
"#U fC << this is the unit \n");
887 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");
891 std::sort (channels.begin(), channels.end(), DetIdLess ());
892 for (std::vector<DetId>::iterator channel = channels.begin ();
893 channel != channels.end ();
897 dumpId (fOutput, *channel);
898 sprintf (buffer,
" %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %10X\n",
899 values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], channel->rawId ());
910 if (!fObject)
return false;
912 while (fInput.getline(buffer, 1024)) {
913 if (buffer [0] ==
'#')
continue;
915 if (items.size()==0)
continue;
916 if (items.size () < 6) {
917 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;
927 if (items[4] ==
"(hex)")
928 sscanf(items[5].c_str(),
"%X", &mystatus);
929 else if (items[4] ==
"(dec)")
930 sscanf(items[5].c_str(),
"%u", &mystatus);
933 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n value field must contain the base: one of (hex), (dec)" << std::endl;
948 sprintf (buffer,
"# %15s %15s %15s %15s %15s %10s\n",
"eta",
"phi",
"dep",
"det",
"(base) value",
"DetId");
951 std::sort (channels.begin(), channels.end(), DetIdLess ());
952 for (std::vector<DetId>::iterator channel = channels.begin ();
953 channel != channels.end ();
956 dumpId (fOutput, *channel);
957 sprintf (buffer,
"%6s %15X %10X\n",
"(hex)",
958 value, channel->rawId ());
970 while (fInput.getline(buffer, 1024)) {
971 if (buffer [0] ==
'#')
973 if (buffer [1] ==
'T')
979 if (buffer [1] ==
'A')
988 if (items.size()==0)
continue;
989 if (items.size () < 7) {
990 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 7 items: eta, phi, depth, subdet, pedestal, resp.corr.gain, flag" << std::endl;
1007 sprintf (buffer,
"#T %s << this is the tag name \n", fObject.
getTagString().c_str() );
1009 sprintf (buffer,
"#A %s << this is the algorithm name \n", fObject.
getAlgoString().c_str() );
1013 sprintf (buffer,
"# %15s %15s %15s %15s %8s %13s %8s %10s\n",
1014 "eta",
"phi",
"dep",
"det",
"ped",
"respcorrgain",
"flag",
1019 for (std::vector<DetId>::iterator channel = channels.begin ();
1020 channel != channels.end ();
1024 dumpId (fOutput, *channel);
1025 sprintf (buffer,
" %10.7f %10.7f %12d %10X\n",
1038 int linecounter = 0;
1040 while (fInput.getline(buffer, 1024)) {
1043 if (items.size()==0)
continue;
1051 edm::LogWarning(
"Pedestal Width Unit Error") <<
"Unrecognized unit for pedestal widths. Assuming fC." << std::endl;
1058 edm::LogWarning(
"Pedestal Width Unit Missing") <<
"The unit for the pedestal widths is missing in the txt file." << std::endl;
1064 while (fInput.getline(buffer, 1024)) {
1066 if (buffer [0] ==
'#')
continue;
1068 if (items.size()==0)
continue;
1069 if (items.size () < 14) {
1070 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line number: " << linecounter <<
"\n line must contain 14 items: eta, phi, depth, subdet, 10x correlations"
1071 <<
" or 20 items: eta, phi, depth, subdet, 16x correlations"
1082 if (items.size() < 20)
1085 values.setSigma (0, 0, atof (items [4].c_str()));
1086 values.setSigma (1, 0, atof (items [5].c_str()));
1087 values.setSigma (1, 1, atof (items [6].c_str()));
1088 values.setSigma (2, 0, atof (items [7].c_str()));
1089 values.setSigma (2, 1, atof (items [8].c_str()));
1090 values.setSigma (2, 2, atof (items [9].c_str()));
1091 values.setSigma (3, 0, atof (items [10].c_str()));
1092 values.setSigma (3, 1, atof (items [11].c_str()));
1093 values.setSigma (3, 2, atof (items [12].c_str()));
1094 values.setSigma (3, 3, atof (items [13].c_str()));
1095 values.setSigma (0, 1, 0.);
1096 values.setSigma (0, 2, 0.);
1097 values.setSigma (0, 3, 0.);
1098 values.setSigma (1, 2, 0.);
1099 values.setSigma (1, 3, 0.);
1100 values.setSigma (2, 3, 0.);
1106 values.setSigma (0, 0, atof (items [4].c_str()) );
1107 values.setSigma (0, 1, atof (items [5].c_str()) );
1108 values.setSigma (0, 2, atof (items [6].c_str()) );
1109 values.setSigma (0, 3, atof (items [7].c_str()) );
1110 values.setSigma (1, 0, atof (items [8].c_str()) );
1111 values.setSigma (1, 1, atof (items [9].c_str()) );
1112 values.setSigma (1, 2, atof (items [10].c_str()) );
1113 values.setSigma (1, 3, atof (items [11].c_str()) );
1114 values.setSigma (2, 0, atof (items [12].c_str()) );
1115 values.setSigma (2, 1, atof (items [13].c_str()) );
1116 values.setSigma (2, 2, atof (items [14].c_str()) );
1117 values.setSigma (2, 3, atof (items [15].c_str()) );
1118 values.setSigma (3, 0, atof (items [16].c_str()) );
1119 values.setSigma (3, 1, atof (items [17].c_str()) );
1120 values.setSigma (3, 2, atof (items [18].c_str()) );
1121 values.setSigma (3, 3, atof (items [19].c_str()) );
1132 if (fObject.
isADC() ) sprintf (buffer,
"#U ADC << this is the unit \n");
1133 else sprintf (buffer,
"#U fC << this is the unit \n");
1136 sprintf (buffer,
"# %15s %15s %15s %15s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
1137 "eta",
"phi",
"dep",
"det",
1138 "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",
1142 std::sort (channels.begin(), channels.end(), DetIdLess ());
1143 for (std::vector<DetId>::iterator channel = channels.begin ();
1144 channel != channels.end ();
1148 dumpId (fOutput, *channel);
1149 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",
1164 while (fInput.getline(buffer, 1024)) {
1165 if (buffer [0] ==
'#')
continue;
1167 if (items.size()<1)
continue;
1168 if (items [0] ==
"SHAPE") {
1172 if (items.size () < 36) {
1173 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;
1185 for (
unsigned capid = 0; capid < 4; capid++) {
1186 for (
unsigned range = 0; range < 4; range++) {
1187 coder.setOffset (capid, range, atof (items [index++].c_str ()));
1190 for (
unsigned capid = 0; capid < 4; capid++) {
1191 for (
unsigned range = 0; range < 4; range++) {
1192 coder.setSlope (capid, range, atof (items [index++].c_str ()));
1195 if (items.size()>36)
1196 coder.setQIEIndex(atoi(items[index++].c_str()));
1210 fOutput <<
"# QIE data" << std::endl;
1211 sprintf (buffer,
"# %15s %15s %15s %15s %36s %36s %36s %36s %36s %36s %36s %36s\n",
1212 "eta",
"phi",
"dep",
"det",
1213 "4 x offsets cap0",
"4 x offsets cap1",
"4 x offsets cap2",
"4 x offsets cap3",
1214 "4 x slopes cap0",
"4 x slopes cap1",
"4 x slopes cap2",
"4 x slopes cap3");
1217 std::sort (channels.begin(), channels.end(), DetIdLess ());
1218 for (std::vector<DetId>::iterator channel = channels.begin ();
1219 channel != channels.end ();
1222 dumpId (fOutput, *channel);
1223 for (
unsigned capid = 0; capid < 4; capid++) {
1224 for (
unsigned range = 0; range < 4; range++) {
1225 sprintf (buffer,
" %8.5f", coder->
offset (capid, range));
1229 for (
unsigned capid = 0; capid < 4; capid++) {
1230 for (
unsigned range = 0; range < 4; range++) {
1231 sprintf (buffer,
" %8.5f", coder->
slope (capid, range));
1235 sprintf (buffer,
" %2d", coder->
qieIndex());
1237 fOutput << std::endl;
1245 while (fInput.getline(buffer, 1024)) {
1246 if (buffer [0] ==
'#')
continue;
1248 if (items.size () < 36) {
1249 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 36 items: eta, phi, depth, subdet, 32 bin values" << std::endl;
1262 for (
unsigned bin = 0;
bin < 32;
bin++) {
1263 values[
bin] = atof (items [index++].c_str ());
1265 coder.setMinCharges (values);
1275 fOutput <<
"# QIE data in calibration mode" << std::endl;
1276 sprintf (buffer,
"# %15s %15s %15s %15s %288s\n",
1277 "eta",
"phi",
"dep",
"det",
"32 x charges");
1280 std::sort (channels.begin(), channels.end(), DetIdLess ());
1281 for (std::vector<DetId>::iterator channel = channels.begin ();
1282 channel != channels.end ();
1286 dumpId (fOutput, *channel);
1288 for (
unsigned bin = 0;
bin < 32;
bin++) {
1289 sprintf (buffer,
" %8.5f", lowEdge [
bin]);
1292 fOutput << std::endl;
1302 while (fInput.getline(buffer, 1024)) {
1303 if (buffer [0] ==
'#')
continue;
1305 if (items.size () < 12) {
1306 if (items.size()==0)
continue;
1307 if (items.size()<9) {
1308 edm::LogError(
"MapFormat") <<
"HcalElectronicsMap-> line too short: " << buffer;
1311 if (items[8]==
"NA" || items[8]==
"NT") {
1312 while (items.size()<12) items.push_back(
"");
1313 }
else if (items[8]==
"HT") {
1314 if (items.size()==11) items.push_back(
"");
1316 edm::LogError(
"MapFormat") <<
"HcalElectronicsMap-> Bad line: " << buffer
1317 <<
"\n HT line must contain at least 11 items: i cr sl tb dcc spigot fiber fiberchan subdet=HT ieta iphi";
1321 edm::LogError(
"MapFormat") <<
"HcalElectronicsMap-> Bad line: " << buffer
1322 <<
"\n line must contain 12 items: i cr sl tb dcc spigot fiber fiberchan subdet ieta iphi depth";
1327 int crate = atoi (items [1].c_str());
1328 int slot = atoi (items [2].c_str());
1330 if (items [3] ==
"b") top = 0;
1331 int dcc = atoi (items [4].c_str());
1332 int spigot = atoi (items [5].c_str());
1334 if (items[3][0] ==
'u') {
1335 int fiber = atoi (items [6].c_str());
1336 int fiberCh = atoi (items [7].c_str());
1337 bool isTrig=(items[8] ==
"HT" || items[8] ==
"NT");
1339 }
else if (items[8] ==
"HT" || items[8] ==
"NT") {
1340 int slb = atoi (items [6].c_str());
1341 int slbCh = atoi (items [7].c_str());
1344 int fiber = atoi (items [6].c_str());
1345 int fiberCh = atoi (items [7].c_str());
1348 elId.
setHTR (crate, slot, top);
1352 if (items [8] ==
"NA") {
1354 }
else if (items [8] ==
"NT") {
1358 if (converter.isHcalDetId ()) {
1361 else if (converter.isHcalTrigTowerDetId ()) {
1362 fObject->
mapEId2tId (elId, converter.getId ());
1364 else if (converter.isHcalCalibDetId ()) {
1367 else if (converter.isHcalZDCDetId ()) {
1371 edm::LogWarning(
"Format Error") <<
"HcalElectronicsMap-> Unknown subdetector: "
1372 << items [8] <<
'/' << items [9] <<
'/' << items [10] <<
'/' << items [11] << std::endl;
1385 sprintf (buf,
"# %7s %3s %3s %3s %4s %7s %10s %14s %7s %5s %5s %6s",
1386 "i",
"cr",
"sl",
"tb",
"dcc",
"spigot",
"fiber/slb",
"fibcha/slbcha",
"subdet",
"ieta",
"iphi",
"depth");
1387 fOutput << buf << std::endl;
1389 for (
unsigned i = 0;
i < eids.size ();
i++) {
1393 if (trigger.
rawId ()) {
1397 sprintf (buf,
" %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
1399 converter.getId().rawId(),
1403 converter.getFlavor ().c_str (), converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str ()
1405 fOutput << buf << std::endl;
1409 if (channel.
rawId()) {
1414 sprintf (buf,
" %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
1416 converter.getId().rawId(),
1418 converter.getFlavor ().c_str (), converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str ()
1421 sprintf (buf,
" %7X %3d %3d u %4d %7d %10d %14d %7s %5s %5s %6s",
1423 converter.getId().rawId(),
1425 converter.getFlavor ().c_str (), converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str ()
1428 fOutput << buf << std::endl;
1437 if (!fObject)
return false;
1439 while (fInput.getline(buffer, 1024)) {
1440 if (buffer [0] ==
'#')
continue;
1442 if (items.size()==0)
continue;
1444 if (items.size() > 1 &&
1445 items[0].find(
"RctLsb")!=std::string::npos){
1446 fObject->
setRctLsb( atof( items[1].c_str() ) );
1449 if (items.size() > 1 &&
1450 items[0].find(
"Gain")!=std::string::npos){
1455 if (items.size () < 7) {
1456 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 7 items: eta, phi, depth, subdet, Rcalib, LutGranularity, OutputLutThreshold" << std::endl;
1462 atof (items [4].c_str()),
1463 atoi (items [5].c_str()),
1464 atoi (items [6].c_str()));
1474 const float _rctLsb = fObject.
getRctLsb();
1476 sprintf (buffer,
"# %20s\n",
"Non-channel data");
1478 sprintf (buffer,
"%8s %8.5f\n",
"RctLsb", _rctLsb);
1480 sprintf (buffer,
"%8s %8.5f\n",
"Gain", _gain);
1482 sprintf (buffer,
"# %15s %15s %15s %15s %8s %15s %19s %10s\n",
"eta",
"phi",
"dep",
"det",
"Rcalib",
"LutGranularity",
"OutputLutThreshold",
"DetId");
1485 std::sort (channels.begin(), channels.end(), DetIdLess ());
1486 for (std::vector<DetId>::iterator channel = channels.begin ();
1487 channel != channels.end ();
1492 dumpId (fOutput, *channel);
1493 sprintf (buffer,
" %8.5f %15d %19d %10X\n",
1496 _outputLutThreshold,
1505 if (!fObject)
return false;
1507 while (getline(fInput, buffer)) {
1508 if (buffer.at(0) ==
'#')
continue;
1509 std::vector <std::string> items =
splitString (buffer);
1510 if (items.size()==0)
continue;
1512 if (items.size() < 9) {
1513 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;
1519 unsigned int slice, subchan;
1520 switch (items[0].
at(1)) {
1537 from_string<int>(sidering, items[1],
std::dec);
1538 from_string<unsigned int>(slice, items[2],
std::dec);
1540 from_string<unsigned int>(subchan, items[4],
std::dec);
1546 float val,
upper,lower;
1547 from_string<int>(LS, items[5],
std::dec);
1548 from_string<float>(val, items[6],
std::dec);
1550 from_string<float>(lower, items[8],
std::dec);
1558 if (!(fObject->
addValue(newVal))) {
1560 <<
"\nwas not added to the HcalDcsValues object." << std::endl;
1570 fOutput <<
"# subDet side_ring slice type subChan LS Value UpperLimit LowerLimit DcsId\n";
1576 for (HcalDcsValues::DcsSet::const_iterator val = vals.begin();
1577 val != vals.end(); ++val) {
1580 switch (valId.subdet()) {
1594 fOutput << valId.subdet() <<
' ';
1598 fOutput << valId.ring() <<
' ';
1600 fOutput << valId.zside() <<
' ';
1602 fOutput << valId.slice() <<
' '
1603 << valId.typeString(valId.type()) <<
' '
1604 << valId.subchannel() <<
' ';
1605 fOutput << val->LS() <<
' '
1606 << val->getValue() <<
' '
1607 << val->getUpperLimit() <<
' '
1608 << val->getLowerLimit() <<
' ';
1609 fOutput << std::hex << val->DcsId() <<
std::dec <<
'\n';
1628 while (fInput.getline(buffer, 1024)) {
1629 if (buffer [0] ==
'#')
continue;
1631 if (items.size () < 8) {
1632 if (items.size()==0)
continue;
1634 edm::LogError(
"MapFormat") <<
"HcalDcsMap-> Bad line: " << buffer
1635 <<
"\n line must contain 8 items: line side_ring slice subchannel subdet ieta iphi depth";
1641 int ring = atoi(items[1].c_str());
1642 unsigned int slice = atoi (items [2].c_str());
1643 unsigned int subchannel = atoi (items [3].c_str());
1689 if (items[4].
find(
"CALIB")!=std::string::npos){
1692 else if (items[4].
find(
"HB")!=std::string::npos){
1695 else if (items[4].
find(
"HE")!=std::string::npos){
1698 else if (items[4].
find(
"HO")!=std::string::npos){
1701 else if (items[4].
find(
"HF")!=std::string::npos){
1705 edm::LogError(
"MapFormat") <<
"HcalDcsMap-> Unknown subdetector, line is not accepted: " << items[5];
1708 HcalDcsDetId dcsId(subdet, ring, slice, type, subchannel);
1711 if (converter.isHcalDetId()){
1712 id = converter.getId();
1715 edm::LogWarning(
"Invalid HCAL channel") <<
"HcalDcsMap-> invalid channel: "
1719 << items [7] << std::endl;
1733 sprintf (buf,
"# %7s %10s %6s %8s %7s %5s %5s %6s",
1734 "i",
"side_ring",
"slice",
"subchan",
"subdet",
"ieta",
"iphi",
"depth");
1735 fOutput << buf << std::endl;
1737 unsigned int line_counter = 0;
1744 sprintf (buf,
" %8X %10d %6d %8d %7s %5s %5s %6s",
1749 _converter.getFlavor().c_str(),
1750 _converter.getField1().c_str(),
1751 _converter.getField2().c_str(),
1752 _converter.getField3().c_str()
1754 fOutput << buf << std::endl;
1764 if (!fObject)
return false;
1766 while (fInput.getline(buffer, 1024)) {
1767 if (buffer [0] ==
'#')
continue;
1769 if (items.size()==0)
continue;
1770 if (items.size () != 9) {
1771 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;
1779 atoi (items [4].c_str()),
1780 atoi (items [5].c_str()),
1781 atoi (items [6].c_str()),
1782 atof (items [7].c_str()),
1794 sprintf (buffer,
"# %15s %15s %15s %15s %15s %15s %15s %15s %30s\n",
"eta",
"phi",
"dep",
"det",
"FirstSample",
"SamplesToAdd",
"ExpectedPeak",
"MinEnergy",
"Coefficients");
1797 std::sort (channels.begin(), channels.end(), DetIdLess ());
1798 for (std::vector<DetId>::iterator channel = channels.begin ();
1799 channel != channels.end ();
1804 sprintf (buffer,
" %15u %15u %15u %15f",
1819 if (
x<coef.size()-1)
1822 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. For VME 1-8 (which of eight fibers carried by a spigot), for uTCA fibers are zer...
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)
static int slb(const HcalTriggerPrimitiveSample &theSample)
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 crateId() const
get the readout VME crate number
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), valid for VME
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 for VME, crate number for uTCA
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 channels on a fiber)
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, AMC card number for uTCA)
unsigned int pulseShapeID() const
static DcsType DcsTypeFromString(const std::string &str)
int slbChannelIndex() const
get the SLB channel index (valid only for VME 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
int slot() const
get the htr or uHTR slot
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 VME 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.
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