22 bool operator () (
DetId fFirst,
DetId fSecond)
const {
25 if (
first.genericSubdet () !=
second.genericSubdet ())
return first.genericSubdet () <
second.genericSubdet ();
26 if (
first.isHcalDetId ()) {
29 return f1.zside () != s1.zside () ?
f1.zside () < s1.zside () :
30 f1.iphi () != s1.iphi () ?
f1.iphi () < s1.iphi () :
31 f1.ietaAbs () != s1.ietaAbs () ?
f1.ietaAbs () < s1.ietaAbs () :
32 f1.depth () < s1.depth ();
39 class HcalElectronicsIdLess {
55 std::vector <std::string>
result;
58 for (
unsigned i = 0;
i <= fLine.size ();
i++) {
59 if (fLine [
i] ==
' ' ||
i == fLine.size ()) {
62 result.push_back (item);
68 if (empty) empty =
false;
75 std::vector <unsigned int>
result;
78 for (
unsigned i = 0;
i <= fLine.size ();
i++) {
79 if (fLine [
i] ==
',' ||
i == fLine.size ()) {
82 result.push_back (atoi (itemString.c_str()) );
88 if (empty) empty =
false;
95 std::vector <float>
result;
98 for (
unsigned i = 0;
i <= fLine.size ();
i++) {
99 if (fLine [
i] ==
',' ||
i == fLine.size ()) {
102 result.push_back (atof (itemString.c_str()) );
108 if (empty) empty =
false;
115 std::vector <double>
result;
118 for (
unsigned i = 0;
i <= fLine.size ();
i++) {
119 if (fLine [
i] ==
',' ||
i == fLine.size ()) {
122 result.push_back (atof (itemString.c_str()) );
128 if (empty) empty =
false;
136 return converter.getId ();
142 sprintf (buffer,
" %15s %15s %15s %15s",
143 converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str (),converter.getFlavor ().c_str ());
150 sprintf (buffer,
" %5s %4s %4s %10s",
151 converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str (),converter.getFlavor ().c_str ());
160 std::istringstream iss(s);
161 return !(iss >>
f >>
t).
fail();
164 template <
class T,
class S>
166 if (!fObject)
return false;
168 while (fInput.getline(buffer, 1024)) {
169 if (buffer [0] ==
'#')
continue;
171 if (items.size()==0)
continue;
172 if (items.size () < 8) {
173 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 8 items: eta, phi, depth, subdet, 4x values" << std::endl;
182 fCondObject =
new S(
id, atof (items [4].c_str()), atof (items [5].c_str()),
183 atof (items [6].c_str()), atof (items [7].c_str()));
184 fObject->addValues(*fCondObject);
195 sprintf (buffer,
"# %15s %15s %15s %15s %8s %8s %8s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"cap0",
"cap1",
"cap2",
"cap3",
"DetId");
197 std::vector<DetId> channels = fObject.getAllChannels ();
198 std::sort (channels.begin(), channels.end(), DetIdLess ());
199 for (std::vector<DetId>::iterator channel = channels.begin ();
200 channel != channels.end ();
202 const float*
values = fObject.getValues (*channel)->getValues ();
205 sprintf (buffer,
" %8.5f %8.5f %8.5f %8.5f %10X\n",
206 values[0], values[1], values[2], values[3], channel->rawId ());
213 template <
class T,
class S>
215 if (!fObject)
return false;
217 while (fInput.getline(buffer, 1024)) {
218 if (buffer [0] ==
'#')
continue;
220 if (items.size()==0)
continue;
221 if (items.size () < 5) {
222 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
231 fCondObject =
new S(
id, atof (items [4].c_str()) );
232 fObject->addValues(*fCondObject);
242 sprintf (buffer,
"# %15s %15s %15s %15s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
244 std::vector<DetId> channels = fObject.getAllChannels ();
245 std::sort (channels.begin(), channels.end(), DetIdLess ());
246 for (std::vector<DetId>::iterator channel = channels.begin ();
247 channel != channels.end ();
249 const float value = fObject.getValues (*channel)->getValue ();
251 sprintf (buffer,
" %8.5f %10X\n",
252 value, channel->rawId ());
258 template <
class T,
class S>
260 if (!fObject)
return false;
262 while (fInput.getline(buffer, 1024)) {
263 if (buffer [0] ==
'#')
continue;
265 if (items.size()==0)
continue;
266 if (items.size () < 5) {
267 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
276 fCondObject =
new S(
id, atoi (items [4].c_str()) );
277 fObject->addValues(*fCondObject);
287 sprintf (buffer,
"# %15s %15s %15s %15s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
289 std::vector<DetId> channels = fObject.getAllChannels ();
290 std::sort (channels.begin(), channels.end(), DetIdLess ());
291 for (std::vector<DetId>::iterator channel = channels.begin ();
292 channel != channels.end ();
294 const int value = fObject.getValues (*channel)->getValue ();
296 sprintf (buffer,
" %15d %10X\n",
297 value, channel->rawId ());
303 template <
class T,
class S>
305 if (!fObject)
return false;
307 while (fInput.getline(buffer, 1024)) {
308 if (buffer [0] ==
'#')
continue;
310 if (items.size()==0)
continue;
312 fCondObject =
new S(firstid.
rawId());
313 for(
int j = 0;
j != 10;
j++) fCondObject->setValue(atoi(items[4].c_str()), 0,
j, atof(items[
j+5].c_str()));
314 for(
int i = 1;
i != 40;
i++){
315 fInput.getline(buffer, 1024);
318 if(
id.rawId() != firstid.
rawId())
break;
319 for(
int j = 0;
j != 10;
j++) fCondObject->setValue(atoi(items[4].c_str()),
i%10,
j, atof(items[
j+5].c_str()));
321 fObject->addValues(*fCondObject);
330 sprintf (buffer,
"# %5s %5s %5s %5s %5s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
331 "eta",
"phi",
"dep",
"det",
"capid",
"c0",
"c1",
"c2",
"c3",
"c4",
"c5",
"c6",
"c7",
"c8",
"c9",
"DetId");
333 std::vector<DetId> channels = fObject.getAllChannels ();
334 std::sort (channels.begin(), channels.end(), DetIdLess ());
335 for (std::vector<DetId>::iterator channel = channels.begin ();
336 channel != channels.end ();
339 for(
int m = 0;
m != 4;
m++){
340 for(
int i = 0;
i != 10;
i++){
341 for(
int j = 0;
j != 10;
j++){
343 thisline[
j] = fObject.getValues(*channel)->getValue(
m,
i,
j);
347 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",
348 m, thisline[0], thisline[1], thisline[2], thisline[3], thisline[4], thisline[5], thisline[6], thisline[7],
349 thisline[8], thisline[9], channel->rawId());
391 if (!fObject)
return false;
393 while (fInput.getline(buffer, 1024)) {
394 if (buffer [0] ==
'#')
continue;
396 if (items.size()==0)
continue;
397 if (items.size () < 6) {
398 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 6 items: eta, phi, depth, subdet, param1, param2" << std::endl;
403 int packingScheme =0;
404 if(items.size ()>22) {
405 packingScheme = atoi (items [22].c_str());
410 if(packingScheme==0) {
411 param1=atoi (items [4].c_str());
412 param2=atoi (items [5].c_str());
415 if(packingScheme==1) {
417 int aabits[6]= {1,1, 8, 4, 4, 9};
418 int aamax[ 6]= {1,1,255,15,15,511};
420 int bbbits[10]={1, 4,1, 4,1, 4, 4, 4, 4, 4};
421 int bbmax [10]={1,15,1,15,1,15,15,15,15,15};
427 for(
int i=0;
i<6;
i++) {
430 float phase=atof (items [j].c_str());
431 float xphase=(phase+32.0)*4.0;
434 aa=atoi (items [j].c_str());
436 if(aa>aamax[
i] || aa<0) {
437 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n value for a"<<
i<<
" should be less than"<<aamax[
i]<< std::endl;
439 param1=param1|aa<<aashift;
440 aashift=aashift+aabits[
i];
446 for(
int i=0;
i<10;
i++) {
448 bb=atoi (items [j].c_str());
450 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n value for b"<<i<<
" should be less than"<<bbmax[
i]<< std::endl;
452 param2=param2|bb<<bbshift;
453 bbshift=bbshift+bbbits[
i];
474 std::sort (channels.begin(), channels.end(), DetIdLess ());
476 for (std::vector<DetId>::iterator channel = channels.begin ();
477 channel != channels.end ();
486 if(packingScheme==0) {
489 sprintf (buffer,
"# %15s %15s %15s %15s %18s %15s %10s\n",
"eta",
"phi",
"dep",
"det",
"firstSample",
"samplesToAdd",
"DetId");
492 sprintf (buffer,
" %15d %15d %16X\n",
497 if(packingScheme==1) {
500 char lineT[100],lineA[200],lineB[200];
502 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
503 sprintf (lineA,
" %31s",
"a0: correctForPhaseContainment"); fOutput << lineA;
504 sprintf (lineB,
" %36s",
"b0: useLeakCorrection\n"); fOutput << lineB;
506 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
507 sprintf (lineA,
" %31s",
"a1: correctForLeadingEdge"); fOutput << lineA;
508 sprintf (lineB,
" %36s",
"b1: leakCorrectionID\n"); fOutput << lineB;
510 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
511 sprintf (lineA,
" %31s",
"a2: correctionPhaseNS"); fOutput << lineA;
512 sprintf (lineB,
" %36s",
"b2: correctForTimeslew\n"); fOutput << lineB;
514 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
515 sprintf (lineA,
" %31s",
"a3: firstSample"); fOutput << lineA;
516 sprintf (lineB,
" %36s",
"b3: timeslewCorrectionID\n"); fOutput << lineB;
518 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
519 sprintf (lineA,
" %31s",
"a4: samplesToAdd"); fOutput << lineA;
520 sprintf (lineB,
" %36s",
"b4: correctTiming\n"); fOutput << lineB;
522 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
523 sprintf (lineA,
" %31s",
"a5: pulseShapeID"); fOutput << lineA;
524 sprintf (lineB,
" %36s",
"b5: firstAuxTS\n"); fOutput << lineB;
526 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
527 sprintf (lineA,
" %31s",
" "); fOutput << lineA;
528 sprintf (lineB,
" %36s",
"b6: specialCaseID\n"); fOutput << lineB;
530 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
531 sprintf (lineA,
" %31s",
" "); fOutput << lineA;
532 sprintf (lineB,
" %36s",
"b7: noiseFlaggingID\n"); fOutput << lineB;
534 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
535 sprintf (lineA,
" %31s",
" "); fOutput << lineA;
536 sprintf (lineB,
" %36s",
"b8: pileupCleaningID\n"); fOutput << lineB;
538 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
539 sprintf (lineA,
" %31s",
" "); fOutput << lineA;
540 sprintf (lineB,
" %36s",
"b9: packingScheme\n"); fOutput << lineB;
543 sprintf (lineT,
"# %5s %4s %4s %10s %11s %10s %10s",
"eta",
"phi",
"dep",
"det",
"param1",
"param2",
"DetId");
546 sprintf (lineA,
" %6s %4s %6s %4s %4s %4s",
"a0",
"a1",
"a2",
"a3",
"a4",
"a5");
549 sprintf (lineB,
" %6s %3s %3s %3s %3s %3s %3s %3s %3s\n",
"b0",
"b1",
"b2",
"b3",
"b4",
"b5",
"b6",
"b7",
"b8");
554 sprintf (buffer,
" %11d %10d %10X", param1, param2, channel->rawId ());
563 sprintf (buffer,
" %6d %4d %6.1f %4d %4d %4d",aa0,aa1,aa2,aa3,aa4,aa5);
576 sprintf(buffer,
" %6d %3d %3d %3d %3d %3d %3d %3d %3d %3d\n",bb0,bb1,bb2,bb3,bb4,bb5,bb6,bb7,bb8,bb9);
586 if (!fObject)
return false;
588 while (fInput.getline(buffer, 1024)) {
589 if (buffer [0] ==
'#')
continue;
591 if (items.size()==0)
continue;
592 if (items.size() < 5) {
593 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 6 items: eta, phi, depth, subdet, signalTSs, noiseTSs" << std::endl;
596 if (items.size() > 7) {
597 edm::LogWarning(
"Format Problem ?") <<
"Check line: " << buffer <<
"\n line must contain 6 items: eta, phi, depth, subdet, signalTSs, noiseTSs. "
598 <<
"\n ! signalTS and noiseTS must be of format <ts1,ts2,ts3,...> withOUT spaces. Ignoring line for safety" << std::endl;
614 if (!fObject)
return false;
616 while (fInput.getline(buffer, 1024)) {
617 if (buffer [0] ==
'#')
continue;
619 if (items.size()==0)
continue;
620 if (items.size () < 7) {
621 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 7 items: eta, phi, depth, subdet, nhit, phase, rms,detid" << std::endl;
643 sprintf (buffer,
"# %15s %15s %15s %15s %15s %15s %15s %15s\n",
"eta",
"phi",
"dep",
"det",
"nhit",
"mean",
"rms" ,
"DetId");
646 std::sort (channels.begin(), channels.end(), DetIdLess ());
647 for (std::vector<DetId>::iterator channel = channels.begin ();
648 channel != channels.end ();
651 sprintf (buffer,
" %15d %8.5f %8.5f %16X\n",
661 sprintf (buffer,
"# %15s %15s %15s %15s %10s %10s %10s\n",
"eta",
"phi",
"dep",
"det",
"signalTSs",
"noiseTSs",
"DetId");
664 std::sort (channels.begin(), channels.end(), DetIdLess ());
665 for (std::vector<DetId>::iterator channel = channels.begin ();
666 channel != channels.end ();
669 if (fId.isHcalZDCDetId())
672 std::vector<unsigned int> vNoiseTS = fObject.
getValues (*channel)->
noiseTS();
674 sprintf (buffer,
" ");
676 for (
unsigned int i=0;
i<vSignalTS.size();
i++)
678 if (
i>0) {sprintf (buffer,
","); fOutput << buffer;}
679 sprintf (buffer,
"%u", vSignalTS.at(
i));
682 sprintf (buffer,
" ");
684 for (
unsigned int i=0;
i<vNoiseTS.size();
i++)
686 if (
i>0) { sprintf (buffer,
","); fOutput << buffer;}
687 sprintf (buffer,
"%u", vNoiseTS.at(
i));
690 sprintf (buffer,
" %10X\n", channel->rawId ());
699 if (!fObject)
return false;
701 while (fInput.getline(buffer, 1024)) {
702 if (buffer [0] ==
'#')
continue;
704 if (items.size()==0)
continue;
705 if (items.size () < 5) {
706 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 5 items: eta, phi, depth, subdet, signalShape" << std::endl;
712 if(items.size ()>11) {
713 packingScheme = atoi (items [11].c_str());
717 if(packingScheme==0) {
718 param1=atoi (items [4].c_str());
721 if(packingScheme==1) {
722 int aabits[6]={ 9,1, 4, 8,5, 4};
723 int aamax [6]={511,1,15,255,1,16};
727 for(
int i=0;
i<6;
i++) {
730 float phase=atof (items [j].c_str());
731 float xphase=(phase+32.0)*4.0;
734 aa=atoi (items [j].c_str());
736 if(aa>aamax[
i] || aa<0) {
737 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n value for a"<<
i<<
" should be less than"<<aamax[
i]<< std::endl;
740 param1=param1|aa<<aashift;
741 aashift=aashift+aabits[
i];
757 std::sort (channels.begin(), channels.end(), DetIdLess ());
759 for (std::vector<DetId>::iterator channel = channels.begin ();
760 channel != channels.end ();
764 if(packingScheme==0) {
766 sprintf (buffer,
"# %15s %15s %15s %15s %14s %10s\n",
"eta",
"phi",
"dep",
"det",
"signalShape",
"DetId");
771 sprintf (buffer,
" %10d %17X\n", value, channel->rawId ());
774 if(packingScheme==1) {
776 char lineT[100],lineA[200];
778 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
779 sprintf (lineA,
" %31s",
"a0: signalShape\n"); fOutput << lineA;
780 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
781 sprintf (lineA,
" %31s",
"a1: syncPhase\n"); fOutput << lineA;
782 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
783 sprintf (lineA,
" %31s",
"a2: binOfMaximum\n"); fOutput << lineA;
784 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
785 sprintf (lineA,
" %31s",
"a3: timePhase\n"); fOutput << lineA;
786 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
787 sprintf (lineA,
" %31s",
"a4: timeSmearing\n"); fOutput << lineA;
788 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
789 sprintf (lineA,
" %31s",
"a5: packingScheme\n"); fOutput << lineA;
790 sprintf (lineT,
"# %5s %4s %4s %10s %11s %10s",
"eta",
"phi",
"dep",
"det",
"param1",
"DetId");
792 sprintf (lineA,
" %6s %4s %4s %6s %4s %4s\n",
"a0",
"a1",
"a2",
"a3",
"a4",
"a5");
797 sprintf (buffer,
" %11d %10X", param1, channel->rawId ());
805 sprintf (buffer,
"%6d %4d %4d %6.1f %4d %4d\n",aa0,aa1,aa2,aa3,aa4,aa5);
815 while (fInput.getline(buffer, 1024)) {
817 if (items.size()==0)
continue;
819 if (items[0] ==
"#U")
825 edm::LogWarning(
"Pedestal Unit Error") <<
"Unrecognized unit for pedestals. Assuming fC." << std::endl;
832 edm::LogWarning(
"Pedestal Unit Missing") <<
"The unit for the pedestals is missing in the txt file." << std::endl;
837 while (fInput.getline(buffer, 1024)) {
838 if (buffer [0] ==
'#')
continue;
840 if (items.size()==0)
continue;
841 if (items.size () < 8) {
842 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 8 items: eta, phi, depth, subdet, 4x values"
843 <<
" or 12 items: eta, phi, depth, subdet, 4x values for mean, 4x values for width"
854 if (items.size() < 12)
857 atof (items [6].c_str()), atof (items [7].c_str()),
865 atof (items [6].c_str()), atof (items [7].c_str()),
866 atof (items [8].c_str()), atof (items [9].c_str()),
867 atof (items [10].c_str()), atof (items [11].c_str()) );
880 if (fObject.
isADC() ) sprintf (buffer,
"#U ADC << this is the unit \n");
881 else sprintf (buffer,
"#U fC << this is the unit \n");
884 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");
888 std::sort (channels.begin(), channels.end(), DetIdLess ());
889 for (std::vector<DetId>::iterator channel = channels.begin ();
890 channel != channels.end ();
894 dumpId (fOutput, *channel);
895 sprintf (buffer,
" %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %10X\n",
896 values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], channel->rawId ());
907 if (!fObject)
return false;
909 while (fInput.getline(buffer, 1024)) {
910 if (buffer [0] ==
'#')
continue;
912 if (items.size()==0)
continue;
913 if (items.size () < 6) {
914 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;
924 if (items[4] ==
"(hex)")
925 sscanf(items[5].c_str(),
"%X", &mystatus);
926 else if (items[4] ==
"(dec)")
927 sscanf(items[5].c_str(),
"%u", &mystatus);
930 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n value field must contain the base: one of (hex), (dec)" << std::endl;
945 sprintf (buffer,
"# %15s %15s %15s %15s %15s %10s\n",
"eta",
"phi",
"dep",
"det",
"(base) value",
"DetId");
948 std::sort (channels.begin(), channels.end(), DetIdLess ());
949 for (std::vector<DetId>::iterator channel = channels.begin ();
950 channel != channels.end ();
953 dumpId (fOutput, *channel);
954 sprintf (buffer,
"%6s %15X %10X\n",
"(hex)",
955 value, channel->rawId ());
967 while (fInput.getline(buffer, 1024)) {
968 if (buffer [0] ==
'#')
970 if (buffer [1] ==
'T')
976 if (buffer [1] ==
'A')
985 if (items.size()==0)
continue;
986 if (items.size () < 7) {
987 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 7 items: eta, phi, depth, subdet, pedestal, resp.corr.gain, flag" << std::endl;
1004 sprintf (buffer,
"#T %s << this is the tag name \n", fObject.
getTagString().c_str() );
1006 sprintf (buffer,
"#A %s << this is the algorithm name \n", fObject.
getAlgoString().c_str() );
1010 sprintf (buffer,
"# %15s %15s %15s %15s %8s %13s %8s %10s\n",
1011 "eta",
"phi",
"dep",
"det",
"ped",
"respcorrgain",
"flag",
1016 for (std::vector<DetId>::iterator channel = channels.begin ();
1017 channel != channels.end ();
1021 dumpId (fOutput, *channel);
1022 sprintf (buffer,
" %10.7f %10.7f %12d %10X\n",
1035 int linecounter = 0;
1037 while (fInput.getline(buffer, 1024)) {
1040 if (items.size()==0)
continue;
1048 edm::LogWarning(
"Pedestal Width Unit Error") <<
"Unrecognized unit for pedestal widths. Assuming fC." << std::endl;
1055 edm::LogWarning(
"Pedestal Width Unit Missing") <<
"The unit for the pedestal widths is missing in the txt file." << std::endl;
1061 while (fInput.getline(buffer, 1024)) {
1063 if (buffer [0] ==
'#')
continue;
1065 if (items.size()==0)
continue;
1066 if (items.size () < 14) {
1067 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line number: " << linecounter <<
"\n line must contain 14 items: eta, phi, depth, subdet, 10x correlations"
1068 <<
" or 20 items: eta, phi, depth, subdet, 16x correlations"
1079 if (items.size() < 20)
1082 values.setSigma (0, 0, atof (items [4].c_str()));
1083 values.setSigma (1, 0, atof (items [5].c_str()));
1084 values.setSigma (1, 1, atof (items [6].c_str()));
1085 values.setSigma (2, 0, atof (items [7].c_str()));
1086 values.setSigma (2, 1, atof (items [8].c_str()));
1087 values.setSigma (2, 2, atof (items [9].c_str()));
1088 values.setSigma (3, 0, atof (items [10].c_str()));
1089 values.setSigma (3, 1, atof (items [11].c_str()));
1090 values.setSigma (3, 2, atof (items [12].c_str()));
1091 values.setSigma (3, 3, atof (items [13].c_str()));
1092 values.setSigma (0, 1, 0.);
1093 values.setSigma (0, 2, 0.);
1094 values.setSigma (0, 3, 0.);
1095 values.setSigma (1, 2, 0.);
1096 values.setSigma (1, 3, 0.);
1097 values.setSigma (2, 3, 0.);
1103 values.setSigma (0, 0, atof (items [4].c_str()) );
1104 values.setSigma (0, 1, atof (items [5].c_str()) );
1105 values.setSigma (0, 2, atof (items [6].c_str()) );
1106 values.setSigma (0, 3, atof (items [7].c_str()) );
1107 values.setSigma (1, 0, atof (items [8].c_str()) );
1108 values.setSigma (1, 1, atof (items [9].c_str()) );
1109 values.setSigma (1, 2, atof (items [10].c_str()) );
1110 values.setSigma (1, 3, atof (items [11].c_str()) );
1111 values.setSigma (2, 0, atof (items [12].c_str()) );
1112 values.setSigma (2, 1, atof (items [13].c_str()) );
1113 values.setSigma (2, 2, atof (items [14].c_str()) );
1114 values.setSigma (2, 3, atof (items [15].c_str()) );
1115 values.setSigma (3, 0, atof (items [16].c_str()) );
1116 values.setSigma (3, 1, atof (items [17].c_str()) );
1117 values.setSigma (3, 2, atof (items [18].c_str()) );
1118 values.setSigma (3, 3, atof (items [19].c_str()) );
1129 if (fObject.
isADC() ) sprintf (buffer,
"#U ADC << this is the unit \n");
1130 else sprintf (buffer,
"#U fC << this is the unit \n");
1133 sprintf (buffer,
"# %15s %15s %15s %15s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
1134 "eta",
"phi",
"dep",
"det",
1135 "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",
1139 std::sort (channels.begin(), channels.end(), DetIdLess ());
1140 for (std::vector<DetId>::iterator channel = channels.begin ();
1141 channel != channels.end ();
1145 dumpId (fOutput, *channel);
1146 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",
1161 while (fInput.getline(buffer, 1024)) {
1162 if (buffer [0] ==
'#')
continue;
1164 if (items.size()<1)
continue;
1165 if (items [0] ==
"SHAPE") {
1169 if (items.size () < 36) {
1170 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;
1182 for (
unsigned capid = 0; capid < 4; capid++) {
1183 for (
unsigned range = 0; range < 4; range++) {
1184 coder.setOffset (capid, range, atof (items [index++].c_str ()));
1187 for (
unsigned capid = 0; capid < 4; capid++) {
1188 for (
unsigned range = 0; range < 4; range++) {
1189 coder.setSlope (capid, range, atof (items [index++].c_str ()));
1192 if (items.size()>36)
1193 coder.setQIEIndex(atoi(items[index++].c_str()));
1207 fOutput <<
"# QIE data" << std::endl;
1208 sprintf (buffer,
"# %15s %15s %15s %15s %36s %36s %36s %36s %36s %36s %36s %36s\n",
1209 "eta",
"phi",
"dep",
"det",
1210 "4 x offsets cap0",
"4 x offsets cap1",
"4 x offsets cap2",
"4 x offsets cap3",
1211 "4 x slopes cap0",
"4 x slopes cap1",
"4 x slopes cap2",
"4 x slopes cap3");
1214 std::sort (channels.begin(), channels.end(), DetIdLess ());
1215 for (std::vector<DetId>::iterator channel = channels.begin ();
1216 channel != channels.end ();
1219 dumpId (fOutput, *channel);
1220 for (
unsigned capid = 0; capid < 4; capid++) {
1221 for (
unsigned range = 0; range < 4; range++) {
1222 sprintf (buffer,
" %8.5f", coder->
offset (capid, range));
1226 for (
unsigned capid = 0; capid < 4; capid++) {
1227 for (
unsigned range = 0; range < 4; range++) {
1228 sprintf (buffer,
" %8.5f", coder->
slope (capid, range));
1232 sprintf (buffer,
" %2d", coder->
qieIndex());
1234 fOutput << std::endl;
1242 while (fInput.getline(buffer, 1024)) {
1243 if (buffer [0] ==
'#')
continue;
1245 if (items.size () < 36) {
1246 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 36 items: eta, phi, depth, subdet, 32 bin values" << std::endl;
1259 for (
unsigned bin = 0;
bin < 32;
bin++) {
1260 values[
bin] = atof (items [index++].c_str ());
1262 coder.setMinCharges (values);
1272 fOutput <<
"# QIE data in calibration mode" << std::endl;
1273 sprintf (buffer,
"# %15s %15s %15s %15s %288s\n",
1274 "eta",
"phi",
"dep",
"det",
"32 x charges");
1277 std::sort (channels.begin(), channels.end(), DetIdLess ());
1278 for (std::vector<DetId>::iterator channel = channels.begin ();
1279 channel != channels.end ();
1283 dumpId (fOutput, *channel);
1285 for (
unsigned bin = 0;
bin < 32;
bin++) {
1286 sprintf (buffer,
" %8.5f", lowEdge [
bin]);
1289 fOutput << std::endl;
1299 while (fInput.getline(buffer, 1024)) {
1300 if (buffer [0] ==
'#')
continue;
1302 if (items.size () < 12) {
1303 if (items.size()==0)
continue;
1304 if (items.size()<9) {
1305 edm::LogError(
"MapFormat") <<
"HcalElectronicsMap-> line too short: " << buffer;
1308 if (items[8]==
"NA" || items[8]==
"NT") {
1309 while (items.size()<12) items.push_back(
"");
1310 }
else if (items[8]==
"HT") {
1311 if (items.size()==11) items.push_back(
"");
1313 edm::LogError(
"MapFormat") <<
"HcalElectronicsMap-> Bad line: " << buffer
1314 <<
"\n HT line must contain at least 11 items: i cr sl tb dcc spigot fiber fiberchan subdet=HT ieta iphi";
1318 edm::LogError(
"MapFormat") <<
"HcalElectronicsMap-> Bad line: " << buffer
1319 <<
"\n line must contain 12 items: i cr sl tb dcc spigot fiber fiberchan subdet ieta iphi depth";
1324 int crate = atoi (items [1].c_str());
1325 int slot = atoi (items [2].c_str());
1327 if (items [3] ==
"b") top = 0;
1328 int dcc = atoi (items [4].c_str());
1329 int spigot = atoi (items [5].c_str());
1331 if (items[8] ==
"HT" || items[8] ==
"NT") {
1332 int slb = atoi (items [6].c_str());
1333 int slbCh = atoi (items [7].c_str());
1336 int fiber = atoi (items [6].c_str());
1337 int fiberCh = atoi (items [7].c_str());
1340 elId.
setHTR (crate, slot, top);
1344 if (items [8] ==
"NA") {
1346 }
else if (items [8] ==
"NT") {
1350 if (converter.isHcalDetId ()) {
1353 else if (converter.isHcalTrigTowerDetId ()) {
1354 fObject->
mapEId2tId (elId, converter.getId ());
1356 else if (converter.isHcalCalibDetId ()) {
1359 else if (converter.isHcalZDCDetId ()) {
1363 edm::LogWarning(
"Format Error") <<
"HcalElectronicsMap-> Unknown subdetector: "
1364 << items [8] <<
'/' << items [9] <<
'/' << items [10] <<
'/' << items [11] << std::endl;
1377 sprintf (buf,
"# %7s %3s %3s %3s %4s %7s %10s %14s %7s %5s %5s %6s",
1378 "i",
"cr",
"sl",
"tb",
"dcc",
"spigot",
"fiber/slb",
"fibcha/slbcha",
"subdet",
"ieta",
"iphi",
"depth");
1379 fOutput << buf << std::endl;
1381 for (
unsigned i = 0;
i < eids.size ();
i++) {
1385 if (trigger.
rawId ()) {
1389 sprintf (buf,
" %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
1391 converter.getId().rawId(),
1395 converter.getFlavor ().c_str (), converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str ()
1397 fOutput << buf << std::endl;
1401 if (channel.
rawId()) {
1405 sprintf (buf,
" %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
1407 converter.getId().rawId(),
1409 converter.getFlavor ().c_str (), converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str ()
1411 fOutput << buf << std::endl;
1420 if (!fObject)
return false;
1422 while (fInput.getline(buffer, 1024)) {
1423 if (buffer [0] ==
'#')
continue;
1425 if (items.size()==0)
continue;
1427 if (items.size() > 1 &&
1428 items[0].find(
"RctLsb")!=std::string::npos){
1429 fObject->
setRctLsb( atof( items[1].c_str() ) );
1432 if (items.size() > 1 &&
1433 items[0].find(
"Gain")!=std::string::npos){
1438 if (items.size () < 7) {
1439 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 7 items: eta, phi, depth, subdet, Rcalib, LutGranularity, OutputLutThreshold" << std::endl;
1445 atof (items [4].c_str()),
1446 atoi (items [5].c_str()),
1447 atoi (items [6].c_str()));
1457 const float _rctLsb = fObject.
getRctLsb();
1459 sprintf (buffer,
"# %20s\n",
"Non-channel data");
1461 sprintf (buffer,
"%8s %8.5f\n",
"RctLsb", _rctLsb);
1463 sprintf (buffer,
"%8s %8.5f\n",
"Gain", _gain);
1465 sprintf (buffer,
"# %15s %15s %15s %15s %8s %15s %19s %10s\n",
"eta",
"phi",
"dep",
"det",
"Rcalib",
"LutGranularity",
"OutputLutThreshold",
"DetId");
1468 std::sort (channels.begin(), channels.end(), DetIdLess ());
1469 for (std::vector<DetId>::iterator channel = channels.begin ();
1470 channel != channels.end ();
1475 dumpId (fOutput, *channel);
1476 sprintf (buffer,
" %8.5f %15d %19d %10X\n",
1479 _outputLutThreshold,
1488 if (!fObject)
return false;
1490 while (getline(fInput, buffer)) {
1491 if (buffer.at(0) ==
'#')
continue;
1492 std::vector <std::string> items =
splitString (buffer);
1493 if (items.size()==0)
continue;
1495 if (items.size() < 9) {
1496 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;
1502 unsigned int slice, subchan;
1503 switch (items[0].
at(1)) {
1520 from_string<int>(sidering, items[1], std::dec);
1521 from_string<unsigned int>(slice, items[2], std::dec);
1523 from_string<unsigned int>(subchan, items[4], std::dec);
1529 float val,
upper,lower;
1530 from_string<int>(LS, items[5], std::dec);
1531 from_string<float>(val, items[6], std::dec);
1532 from_string<float>(
upper, items[7], std::dec);
1533 from_string<float>(lower, items[8], std::dec);
1541 if (!(fObject->
addValue(newVal))) {
1543 <<
"\nwas not added to the HcalDcsValues object." << std::endl;
1553 fOutput <<
"# subDet side_ring slice type subChan LS Value UpperLimit LowerLimit DcsId\n";
1559 for (HcalDcsValues::DcsSet::const_iterator val = vals.begin();
1560 val != vals.end(); ++val) {
1563 switch (valId.subdet()) {
1577 fOutput << valId.subdet() <<
' ';
1581 fOutput << valId.ring() <<
' ';
1583 fOutput << valId.zside() <<
' ';
1585 fOutput << valId.slice() <<
' '
1586 << valId.typeString(valId.type()) <<
' '
1587 << valId.subchannel() <<
' ';
1588 fOutput << val->LS() <<
' '
1589 << val->getValue() <<
' '
1590 << val->getUpperLimit() <<
' '
1591 << val->getLowerLimit() <<
' ';
1592 fOutput << std::hex << val->DcsId() << std::dec <<
'\n';
1611 while (fInput.getline(buffer, 1024)) {
1612 if (buffer [0] ==
'#')
continue;
1614 if (items.size () < 8) {
1615 if (items.size()==0)
continue;
1617 edm::LogError(
"MapFormat") <<
"HcalDcsMap-> Bad line: " << buffer
1618 <<
"\n line must contain 8 items: line side_ring slice subchannel subdet ieta iphi depth";
1624 int ring = atoi(items[1].c_str());
1625 unsigned int slice = atoi (items [2].c_str());
1626 unsigned int subchannel = atoi (items [3].c_str());
1672 if (items[4].
find(
"CALIB")!=std::string::npos){
1675 else if (items[4].
find(
"HB")!=std::string::npos){
1678 else if (items[4].
find(
"HE")!=std::string::npos){
1681 else if (items[4].
find(
"HO")!=std::string::npos){
1684 else if (items[4].
find(
"HF")!=std::string::npos){
1688 edm::LogError(
"MapFormat") <<
"HcalDcsMap-> Unknown subdetector, line is not accepted: " << items[5];
1691 HcalDcsDetId dcsId(subdet, ring, slice, type, subchannel);
1694 if (converter.isHcalDetId()){
1695 id = converter.getId();
1698 edm::LogWarning(
"Invalid HCAL channel") <<
"HcalDcsMap-> invalid channel: "
1702 << items [7] << std::endl;
1716 sprintf (buf,
"# %7s %10s %6s %8s %7s %5s %5s %6s",
1717 "i",
"side_ring",
"slice",
"subchan",
"subdet",
"ieta",
"iphi",
"depth");
1718 fOutput << buf << std::endl;
1720 unsigned int line_counter = 0;
1727 sprintf (buf,
" %8X %10d %6d %8d %7s %5s %5s %6s",
1732 _converter.getFlavor().c_str(),
1733 _converter.getField1().c_str(),
1734 _converter.getField2().c_str(),
1735 _converter.getField3().c_str()
1737 fOutput << buf << std::endl;
1747 if (!fObject)
return false;
1749 while (fInput.getline(buffer, 1024)) {
1750 if (buffer [0] ==
'#')
continue;
1752 if (items.size()==0)
continue;
1753 if (items.size () != 9) {
1754 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;
1762 atoi (items [4].c_str()),
1763 atoi (items [5].c_str()),
1764 atoi (items [6].c_str()),
1765 atof (items [7].c_str()),
1777 sprintf (buffer,
"# %15s %15s %15s %15s %15s %15s %15s %15s %30s\n",
"eta",
"phi",
"dep",
"det",
"FirstSample",
"SamplesToAdd",
"ExpectedPeak",
"MinEnergy",
"Coefficients");
1780 std::sort (channels.begin(), channels.end(), DetIdLess ());
1781 for (std::vector<DetId>::iterator channel = channels.begin ();
1782 channel != channels.end ();
1787 sprintf (buffer,
" %15u %15u %15u %15f",
1802 if (
x<coef.size()-1)
1805 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
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