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());
395 if (!fObject)
return false;
397 while (fInput.getline(buffer, 1024)) {
398 if (buffer [0] ==
'#')
continue;
400 if (items.size()==0)
continue;
401 if (items.size () < 6) {
402 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 6 items: eta, phi, depth, subdet, param1, param2" << std::endl;
407 int packingScheme =0;
408 if(items.size ()>22) {
409 packingScheme = atoi (items [22].c_str());
414 if(packingScheme==0) {
415 param1=atoi (items [4].c_str());
416 param2=atoi (items [5].c_str());
419 if(packingScheme==1) {
421 int aabits[6]= {1,1, 8, 4, 4, 9};
422 int aamax[ 6]= {1,1,255,15,15,511};
424 int bbbits[10]={1, 4,1, 4,1, 4, 4, 4, 4, 4};
425 int bbmax [10]={1,15,1,15,1,15,15,15,15,15};
431 for(
int i=0;
i<6;
i++) {
434 float phase=atof (items [j].c_str());
435 float xphase=(phase+32.0)*4.0;
438 aa=atoi (items [j].c_str());
440 if(aa>aamax[
i] || aa<0) {
441 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n value for a"<<
i<<
" should be less than"<<aamax[
i]<< std::endl;
443 param1=param1|aa<<aashift;
444 aashift=aashift+aabits[
i];
450 for(
int i=0;
i<10;
i++) {
452 bb=atoi (items [j].c_str());
454 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n value for b"<<i<<
" should be less than"<<bbmax[
i]<< std::endl;
456 param2=param2|bb<<bbshift;
457 bbshift=bbshift+bbbits[
i];
478 std::sort (channels.begin(), channels.end(), DetIdLess ());
480 for (std::vector<DetId>::iterator channel = channels.begin ();
481 channel != channels.end ();
490 if(packingScheme==0) {
493 sprintf (buffer,
"# %15s %15s %15s %15s %18s %15s %10s\n",
"eta",
"phi",
"dep",
"det",
"firstSample",
"samplesToAdd",
"DetId");
496 sprintf (buffer,
" %15d %15d %16X\n",
501 if(packingScheme==1) {
504 char lineT[100],lineA[200],lineB[200];
506 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
507 sprintf (lineA,
" %31s",
"a0: correctForPhaseContainment"); fOutput << lineA;
508 sprintf (lineB,
" %36s",
"b0: useLeakCorrection\n"); fOutput << lineB;
510 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
511 sprintf (lineA,
" %31s",
"a1: correctForLeadingEdge"); fOutput << lineA;
512 sprintf (lineB,
" %36s",
"b1: leakCorrectionID\n"); fOutput << lineB;
514 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
515 sprintf (lineA,
" %31s",
"a2: correctionPhaseNS"); fOutput << lineA;
516 sprintf (lineB,
" %36s",
"b2: correctForTimeslew\n"); fOutput << lineB;
518 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
519 sprintf (lineA,
" %31s",
"a3: firstSample"); fOutput << lineA;
520 sprintf (lineB,
" %36s",
"b3: timeslewCorrectionID\n"); fOutput << lineB;
522 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
523 sprintf (lineA,
" %31s",
"a4: samplesToAdd"); fOutput << lineA;
524 sprintf (lineB,
" %36s",
"b4: correctTiming\n"); fOutput << lineB;
526 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
527 sprintf (lineA,
" %31s",
"a5: pulseShapeID"); fOutput << lineA;
528 sprintf (lineB,
" %36s",
"b5: firstAuxTS\n"); fOutput << lineB;
530 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
531 sprintf (lineA,
" %31s",
" "); fOutput << lineA;
532 sprintf (lineB,
" %36s",
"b6: specialCaseID\n"); fOutput << lineB;
534 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
535 sprintf (lineA,
" %31s",
" "); fOutput << lineA;
536 sprintf (lineB,
" %36s",
"b7: noiseFlaggingID\n"); fOutput << lineB;
538 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
539 sprintf (lineA,
" %31s",
" "); fOutput << lineA;
540 sprintf (lineB,
" %36s",
"b8: pileupCleaningID\n"); fOutput << lineB;
542 sprintf (lineT,
"#%50s",
" "); fOutput << lineT;
543 sprintf (lineA,
" %31s",
" "); fOutput << lineA;
544 sprintf (lineB,
" %36s",
"b9: packingScheme\n"); fOutput << lineB;
547 sprintf (lineT,
"# %5s %4s %4s %10s %11s %10s %10s",
"eta",
"phi",
"dep",
"det",
"param1",
"param2",
"DetId");
550 sprintf (lineA,
" %6s %4s %6s %4s %4s %4s",
"a0",
"a1",
"a2",
"a3",
"a4",
"a5");
553 sprintf (lineB,
" %6s %3s %3s %3s %3s %3s %3s %3s %3s\n",
"b0",
"b1",
"b2",
"b3",
"b4",
"b5",
"b6",
"b7",
"b8");
558 sprintf (buffer,
" %11d %10d %10X", param1, param2, channel->rawId ());
567 sprintf (buffer,
" %6d %4d %6.1f %4d %4d %4d",aa0,aa1,aa2,aa3,aa4,aa5);
580 sprintf(buffer,
" %6d %3d %3d %3d %3d %3d %3d %3d %3d %3d\n",bb0,bb1,bb2,bb3,bb4,bb5,bb6,bb7,bb8,bb9);
590 if (!fObject)
return false;
592 while (fInput.getline(buffer, 1024)) {
593 if (buffer [0] ==
'#')
continue;
595 if (items.size()==0)
continue;
596 if (items.size() < 5) {
597 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 6 items: eta, phi, depth, subdet, signalTSs, noiseTSs" << std::endl;
600 if (items.size() > 7) {
601 edm::LogWarning(
"Format Problem ?") <<
"Check line: " << buffer <<
"\n line must contain 6 items: eta, phi, depth, subdet, signalTSs, noiseTSs. "
602 <<
"\n ! signalTS and noiseTS must be of format <ts1,ts2,ts3,...> withOUT spaces. Ignoring line for safety" << std::endl;
619 if (!fObject)
return false;
621 while (fInput.getline(buffer, 1024)) {
622 if (buffer [0] ==
'#')
continue;
624 if (items.size()==0)
continue;
625 if (items.size () < 7) {
626 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 7 items: eta, phi, depth, subdet, nhit, phase, rms,detid" << std::endl;
648 sprintf (buffer,
"# %15s %15s %15s %15s %15s %15s %15s %15s\n",
"eta",
"phi",
"dep",
"det",
"nhit",
"mean",
"rms" ,
"DetId");
651 std::sort (channels.begin(), channels.end(), DetIdLess ());
652 for (std::vector<DetId>::iterator channel = channels.begin ();
653 channel != channels.end ();
656 sprintf (buffer,
" %15d %8.5f %8.5f %16X\n",
666 sprintf (buffer,
"# %15s %15s %15s %15s %10s %10s %10s\n",
"eta",
"phi",
"dep",
"det",
"signalTSs",
"noiseTSs",
"DetId");
669 std::sort (channels.begin(), channels.end(), DetIdLess ());
670 for (std::vector<DetId>::iterator channel = channels.begin ();
671 channel != channels.end ();
674 if (fId.isHcalZDCDetId())
677 std::vector<unsigned int> vNoiseTS = fObject.
getValues (*channel)->
noiseTS();
679 sprintf (buffer,
" ");
681 for (
unsigned int i=0;
i<vSignalTS.size();
i++)
683 if (
i>0) {sprintf (buffer,
","); fOutput << buffer;}
684 sprintf (buffer,
"%u", vSignalTS.at(
i));
687 sprintf (buffer,
" ");
689 for (
unsigned int i=0;
i<vNoiseTS.size();
i++)
691 if (
i>0) { sprintf (buffer,
","); fOutput << buffer;}
692 sprintf (buffer,
"%u", vNoiseTS.at(
i));
695 sprintf (buffer,
" %10X\n", channel->rawId ());
704 if (!fObject)
return false;
706 while (fInput.getline(buffer, 1024)) {
707 if (buffer [0] ==
'#')
continue;
709 if (items.size()==0)
continue;
710 if (items.size () < 5) {
711 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 5 items: eta, phi, depth, subdet, signalShape" << std::endl;
717 if(items.size ()>11) {
718 packingScheme = atoi (items [11].c_str());
722 if(packingScheme==0) {
723 param1=atoi (items [4].c_str());
726 if(packingScheme==1) {
727 int aabits[6]={ 9,1, 4, 8,5, 4};
728 int aamax [6]={511,1,15,255,1,16};
732 for(
int i=0;
i<6;
i++) {
735 float phase=atof (items [j].c_str());
736 float xphase=(phase+32.0)*4.0;
739 aa=atoi (items [j].c_str());
741 if(aa>aamax[
i] || aa<0) {
742 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n value for a"<<
i<<
" should be less than"<<aamax[
i]<< std::endl;
745 param1=param1|aa<<aashift;
746 aashift=aashift+aabits[
i];
762 std::sort (channels.begin(), channels.end(), DetIdLess ());
764 for (std::vector<DetId>::iterator channel = channels.begin ();
765 channel != channels.end ();
769 if(packingScheme==0) {
771 sprintf (buffer,
"# %15s %15s %15s %15s %14s %10s\n",
"eta",
"phi",
"dep",
"det",
"signalShape",
"DetId");
776 sprintf (buffer,
" %10d %17X\n", value, channel->rawId ());
779 if(packingScheme==1) {
781 char lineT[100],lineA[200];
783 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
784 sprintf (lineA,
" %31s",
"a0: signalShape\n"); fOutput << lineA;
785 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
786 sprintf (lineA,
" %31s",
"a1: syncPhase\n"); fOutput << lineA;
787 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
788 sprintf (lineA,
" %31s",
"a2: binOfMaximum\n"); fOutput << lineA;
789 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
790 sprintf (lineA,
" %31s",
"a3: timePhase\n"); fOutput << lineA;
791 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
792 sprintf (lineA,
" %31s",
"a4: timeSmearing\n"); fOutput << lineA;
793 sprintf (lineT,
"#%40s",
" "); fOutput << lineT;
794 sprintf (lineA,
" %31s",
"a5: packingScheme\n"); fOutput << lineA;
795 sprintf (lineT,
"# %5s %4s %4s %10s %11s %10s",
"eta",
"phi",
"dep",
"det",
"param1",
"DetId");
797 sprintf (lineA,
" %6s %4s %4s %6s %4s %4s\n",
"a0",
"a1",
"a2",
"a3",
"a4",
"a5");
802 sprintf (buffer,
" %11d %10X", param1, channel->rawId ());
810 sprintf (buffer,
"%6d %4d %4d %6.1f %4d %4d\n",aa0,aa1,aa2,aa3,aa4,aa5);
820 while (fInput.getline(buffer, 1024)) {
822 if (items.size()==0)
continue;
824 if (items[0] ==
"#U")
830 edm::LogWarning(
"Pedestal Unit Error") <<
"Unrecognized unit for pedestals. Assuming fC." << std::endl;
837 edm::LogWarning(
"Pedestal Unit Missing") <<
"The unit for the pedestals is missing in the txt file." << std::endl;
842 while (fInput.getline(buffer, 1024)) {
843 if (buffer [0] ==
'#')
continue;
845 if (items.size()==0)
continue;
846 if (items.size () < 8) {
847 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 8 items: eta, phi, depth, subdet, 4x values"
848 <<
" or 12 items: eta, phi, depth, subdet, 4x values for mean, 4x values for width"
859 if (items.size() < 12)
862 atof (items [6].c_str()), atof (items [7].c_str()),
870 atof (items [6].c_str()), atof (items [7].c_str()),
871 atof (items [8].c_str()), atof (items [9].c_str()),
872 atof (items [10].c_str()), atof (items [11].c_str()) );
885 if (fObject.
isADC() ) sprintf (buffer,
"#U ADC << this is the unit \n");
886 else sprintf (buffer,
"#U fC << this is the unit \n");
889 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");
893 std::sort (channels.begin(), channels.end(), DetIdLess ());
894 for (std::vector<DetId>::iterator channel = channels.begin ();
895 channel != channels.end ();
899 dumpId (fOutput, *channel);
900 sprintf (buffer,
" %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %10X\n",
901 values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], channel->rawId ());
912 if (!fObject)
return false;
914 while (fInput.getline(buffer, 1024)) {
915 if (buffer [0] ==
'#')
continue;
917 if (items.size()==0)
continue;
918 if (items.size () < 6) {
919 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;
929 if (items[4] ==
"(hex)")
930 sscanf(items[5].c_str(),
"%X", &mystatus);
931 else if (items[4] ==
"(dec)")
932 sscanf(items[5].c_str(),
"%u", &mystatus);
935 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n value field must contain the base: one of (hex), (dec)" << std::endl;
950 sprintf (buffer,
"# %15s %15s %15s %15s %15s %10s\n",
"eta",
"phi",
"dep",
"det",
"(base) value",
"DetId");
953 std::sort (channels.begin(), channels.end(), DetIdLess ());
954 for (std::vector<DetId>::iterator channel = channels.begin ();
955 channel != channels.end ();
958 dumpId (fOutput, *channel);
959 sprintf (buffer,
"%6s %15X %10X\n",
"(hex)",
960 value, channel->rawId ());
972 while (fInput.getline(buffer, 1024)) {
973 if (buffer [0] ==
'#')
975 if (buffer [1] ==
'T')
981 if (buffer [1] ==
'A')
990 if (items.size()==0)
continue;
991 if (items.size () < 7) {
992 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 7 items: eta, phi, depth, subdet, pedestal, resp.corr.gain, flag" << std::endl;
1009 sprintf (buffer,
"#T %s << this is the tag name \n", fObject.
getTagString().c_str() );
1011 sprintf (buffer,
"#A %s << this is the algorithm name \n", fObject.
getAlgoString().c_str() );
1015 sprintf (buffer,
"# %15s %15s %15s %15s %8s %13s %8s %10s\n",
1016 "eta",
"phi",
"dep",
"det",
"ped",
"respcorrgain",
"flag",
1021 for (std::vector<DetId>::iterator channel = channels.begin ();
1022 channel != channels.end ();
1026 dumpId (fOutput, *channel);
1027 sprintf (buffer,
" %10.7f %10.7f %12d %10X\n",
1040 int linecounter = 0;
1042 while (fInput.getline(buffer, 1024)) {
1045 if (items.size()==0)
continue;
1053 edm::LogWarning(
"Pedestal Width Unit Error") <<
"Unrecognized unit for pedestal widths. Assuming fC." << std::endl;
1060 edm::LogWarning(
"Pedestal Width Unit Missing") <<
"The unit for the pedestal widths is missing in the txt file." << std::endl;
1066 while (fInput.getline(buffer, 1024)) {
1068 if (buffer [0] ==
'#')
continue;
1070 if (items.size()==0)
continue;
1071 if (items.size () < 14) {
1072 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line number: " << linecounter <<
"\n line must contain 14 items: eta, phi, depth, subdet, 10x correlations"
1073 <<
" or 20 items: eta, phi, depth, subdet, 16x correlations"
1084 if (items.size() < 20)
1087 values.setSigma (0, 0, atof (items [4].c_str()));
1088 values.setSigma (1, 0, atof (items [5].c_str()));
1089 values.setSigma (1, 1, atof (items [6].c_str()));
1090 values.setSigma (2, 0, atof (items [7].c_str()));
1091 values.setSigma (2, 1, atof (items [8].c_str()));
1092 values.setSigma (2, 2, atof (items [9].c_str()));
1093 values.setSigma (3, 0, atof (items [10].c_str()));
1094 values.setSigma (3, 1, atof (items [11].c_str()));
1095 values.setSigma (3, 2, atof (items [12].c_str()));
1096 values.setSigma (3, 3, atof (items [13].c_str()));
1097 values.setSigma (0, 1, 0.);
1098 values.setSigma (0, 2, 0.);
1099 values.setSigma (0, 3, 0.);
1100 values.setSigma (1, 2, 0.);
1101 values.setSigma (1, 3, 0.);
1102 values.setSigma (2, 3, 0.);
1108 values.setSigma (0, 0, atof (items [4].c_str()) );
1109 values.setSigma (0, 1, atof (items [5].c_str()) );
1110 values.setSigma (0, 2, atof (items [6].c_str()) );
1111 values.setSigma (0, 3, atof (items [7].c_str()) );
1112 values.setSigma (1, 0, atof (items [8].c_str()) );
1113 values.setSigma (1, 1, atof (items [9].c_str()) );
1114 values.setSigma (1, 2, atof (items [10].c_str()) );
1115 values.setSigma (1, 3, atof (items [11].c_str()) );
1116 values.setSigma (2, 0, atof (items [12].c_str()) );
1117 values.setSigma (2, 1, atof (items [13].c_str()) );
1118 values.setSigma (2, 2, atof (items [14].c_str()) );
1119 values.setSigma (2, 3, atof (items [15].c_str()) );
1120 values.setSigma (3, 0, atof (items [16].c_str()) );
1121 values.setSigma (3, 1, atof (items [17].c_str()) );
1122 values.setSigma (3, 2, atof (items [18].c_str()) );
1123 values.setSigma (3, 3, atof (items [19].c_str()) );
1134 if (fObject.
isADC() ) sprintf (buffer,
"#U ADC << this is the unit \n");
1135 else sprintf (buffer,
"#U fC << this is the unit \n");
1138 sprintf (buffer,
"# %15s %15s %15s %15s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
1139 "eta",
"phi",
"dep",
"det",
1140 "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",
1144 std::sort (channels.begin(), channels.end(), DetIdLess ());
1145 for (std::vector<DetId>::iterator channel = channels.begin ();
1146 channel != channels.end ();
1150 dumpId (fOutput, *channel);
1151 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",
1166 while (fInput.getline(buffer, 1024)) {
1167 if (buffer [0] ==
'#')
continue;
1169 if (items.size()<1)
continue;
1170 if (items [0] ==
"SHAPE") {
1174 if (items.size () < 36) {
1175 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;
1187 for (
unsigned capid = 0; capid < 4; capid++) {
1188 for (
unsigned range = 0; range < 4; range++) {
1189 coder.setOffset (capid, range, atof (items [index++].c_str ()));
1192 for (
unsigned capid = 0; capid < 4; capid++) {
1193 for (
unsigned range = 0; range < 4; range++) {
1194 coder.setSlope (capid, range, atof (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 fOutput << std::endl;
1243 while (fInput.getline(buffer, 1024)) {
1244 if (buffer [0] ==
'#')
continue;
1246 if (items.size () < 36) {
1247 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 36 items: eta, phi, depth, subdet, 32 bin values" << std::endl;
1260 for (
unsigned bin = 0;
bin < 32;
bin++) {
1261 values[
bin] = atof (items [index++].c_str ());
1263 coder.setMinCharges (values);
1273 fOutput <<
"# QIE data in calibration mode" << std::endl;
1274 sprintf (buffer,
"# %15s %15s %15s %15s %288s\n",
1275 "eta",
"phi",
"dep",
"det",
"32 x charges");
1278 std::sort (channels.begin(), channels.end(), DetIdLess ());
1279 for (std::vector<DetId>::iterator channel = channels.begin ();
1280 channel != channels.end ();
1284 dumpId (fOutput, *channel);
1286 for (
unsigned bin = 0;
bin < 32;
bin++) {
1287 sprintf (buffer,
" %8.5f", lowEdge [
bin]);
1290 fOutput << std::endl;
1300 while (fInput.getline(buffer, 1024)) {
1301 if (buffer [0] ==
'#')
continue;
1303 if (items.size () < 12) {
1304 if (items.size()==0)
continue;
1305 if (items.size()<9) {
1306 edm::LogError(
"MapFormat") <<
"HcalElectronicsMap-> line too short: " << buffer;
1309 if (items[8]==
"NA" || items[8]==
"NT") {
1310 while (items.size()<12) items.push_back(
"");
1311 }
else if (items[8]==
"HT") {
1312 if (items.size()==11) items.push_back(
"");
1314 edm::LogError(
"MapFormat") <<
"HcalElectronicsMap-> Bad line: " << buffer
1315 <<
"\n HT line must contain at least 11 items: i cr sl tb dcc spigot fiber fiberchan subdet=HT ieta iphi";
1319 edm::LogError(
"MapFormat") <<
"HcalElectronicsMap-> Bad line: " << buffer
1320 <<
"\n line must contain 12 items: i cr sl tb dcc spigot fiber fiberchan subdet ieta iphi depth";
1325 int crate = atoi (items [1].c_str());
1326 int slot = atoi (items [2].c_str());
1328 if (items [3] ==
"b") top = 0;
1329 int dcc = atoi (items [4].c_str());
1330 int spigot = atoi (items [5].c_str());
1332 if (items[3][0] ==
'u') {
1333 int fiber = atoi (items [6].c_str());
1334 int fiberCh = atoi (items [7].c_str());
1335 bool isTrig=(items[8] ==
"HT" || items[8] ==
"NT");
1337 }
else if (items[8] ==
"HT" || items[8] ==
"NT") {
1338 int slb = atoi (items [6].c_str());
1339 int slbCh = atoi (items [7].c_str());
1342 int fiber = atoi (items [6].c_str());
1343 int fiberCh = atoi (items [7].c_str());
1346 elId.
setHTR (crate, slot, top);
1350 if (items [8] ==
"NA") {
1352 }
else if (items [8] ==
"NT") {
1356 if (converter.isHcalDetId ()) {
1359 else if (converter.isHcalTrigTowerDetId ()) {
1360 fObject->
mapEId2tId (elId, converter.getId ());
1362 else if (converter.isHcalCalibDetId ()) {
1365 else if (converter.isHcalZDCDetId ()) {
1369 edm::LogWarning(
"Format Error") <<
"HcalElectronicsMap-> Unknown subdetector: "
1370 << items [8] <<
'/' << items [9] <<
'/' << items [10] <<
'/' << items [11] << std::endl;
1383 sprintf (buf,
"# %7s %3s %3s %3s %4s %7s %10s %14s %7s %5s %5s %6s",
1384 "i",
"cr",
"sl",
"tb",
"dcc",
"spigot",
"fiber/slb",
"fibcha/slbcha",
"subdet",
"ieta",
"iphi",
"depth");
1385 fOutput << buf << std::endl;
1387 for (
unsigned i = 0;
i < eids.size ();
i++) {
1391 if (trigger.
rawId ()) {
1396 sprintf (buf,
" %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
1398 converter.getId().rawId(),
1402 converter.getFlavor ().c_str (), converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str ()
1404 fOutput << buf << std::endl;
1406 sprintf (buf,
" %7X %3d %3d u %4d %7d %10d %14d %7s %5s %5s %6s",
1407 converter.getId().rawId(),
1410 converter.getFlavor ().c_str (), converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str ()
1412 fOutput << buf << std::endl;
1414 sprintf (buf,
"NOT SUPPORTED!");
1415 fOutput << buf << std::endl;
1420 if (channel.
rawId()) {
1425 sprintf (buf,
" %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
1427 converter.getId().rawId(),
1429 converter.getFlavor ().c_str (), converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str ()
1432 sprintf (buf,
" %7X %3d %3d u %4d %7d %10d %14d %7s %5s %5s %6s",
1434 converter.getId().rawId(),
1437 converter.getFlavor ().c_str (), converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str ()
1440 fOutput << buf << std::endl;
1449 if (!fObject)
return false;
1451 while (fInput.getline(buffer, 1024)) {
1452 if (buffer [0] ==
'#')
continue;
1454 if (items.size()==0)
continue;
1456 if (items.size() > 1 &&
1457 items[0].find(
"RctLsb")!=std::string::npos){
1458 fObject->
setRctLsb( atof( items[1].c_str() ) );
1461 if (items.size() > 1 &&
1462 items[0].find(
"Gain")!=std::string::npos){
1467 if (items.size () < 7) {
1468 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 7 items: eta, phi, depth, subdet, Rcalib, LutGranularity, OutputLutThreshold" << std::endl;
1474 atof (items [4].c_str()),
1475 atoi (items [5].c_str()),
1476 atoi (items [6].c_str()));
1486 const float _rctLsb = fObject.
getRctLsb();
1488 sprintf (buffer,
"# %20s\n",
"Non-channel data");
1490 sprintf (buffer,
"%8s %8.5f\n",
"RctLsb", _rctLsb);
1492 sprintf (buffer,
"%8s %8.5f\n",
"Gain", _gain);
1494 sprintf (buffer,
"# %15s %15s %15s %15s %8s %15s %19s %10s\n",
"eta",
"phi",
"dep",
"det",
"Rcalib",
"LutGranularity",
"OutputLutThreshold",
"DetId");
1497 std::sort (channels.begin(), channels.end(), DetIdLess ());
1498 for (std::vector<DetId>::iterator channel = channels.begin ();
1499 channel != channels.end ();
1504 dumpId (fOutput, *channel);
1505 sprintf (buffer,
" %8.5f %15d %19d %10X\n",
1508 _outputLutThreshold,
1517 if (!fObject)
return false;
1519 while (getline(fInput, buffer)) {
1520 if (buffer.at(0) ==
'#')
continue;
1521 std::vector <std::string> items =
splitString (buffer);
1522 if (items.size()==0)
continue;
1524 if (items.size() < 9) {
1525 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;
1531 unsigned int slice, subchan;
1532 switch (items[0].at(1)) {
1549 from_string<int>(sidering, items[1],
std::dec);
1550 from_string<unsigned int>(slice, items[2],
std::dec);
1552 from_string<unsigned int>(subchan, items[4],
std::dec);
1558 float val,
upper,lower;
1559 from_string<int>(LS, items[5],
std::dec);
1560 from_string<float>(val, items[6],
std::dec);
1562 from_string<float>(lower, items[8],
std::dec);
1570 if (!(fObject->
addValue(newVal))) {
1572 <<
"\nwas not added to the HcalDcsValues object." << std::endl;
1582 fOutput <<
"# subDet side_ring slice type subChan LS Value UpperLimit LowerLimit DcsId\n";
1588 for (HcalDcsValues::DcsSet::const_iterator val = vals.begin();
1589 val != vals.end(); ++val) {
1592 switch (valId.subdet()) {
1606 fOutput << valId.subdet() <<
' ';
1610 fOutput << valId.ring() <<
' ';
1612 fOutput << valId.zside() <<
' ';
1614 fOutput << valId.slice() <<
' '
1615 << valId.typeString(valId.type()) <<
' '
1616 << valId.subchannel() <<
' ';
1617 fOutput << val->LS() <<
' '
1618 << val->getValue() <<
' '
1619 << val->getUpperLimit() <<
' '
1620 << val->getLowerLimit() <<
' ';
1621 fOutput << std::hex << val->DcsId() <<
std::dec <<
'\n';
1640 while (fInput.getline(buffer, 1024)) {
1641 if (buffer [0] ==
'#')
continue;
1643 if (items.size () < 8) {
1644 if (items.size()==0)
continue;
1646 edm::LogError(
"MapFormat") <<
"HcalDcsMap-> Bad line: " << buffer
1647 <<
"\n line must contain 8 items: line side_ring slice subchannel subdet ieta iphi depth";
1653 int ring = atoi(items[1].c_str());
1654 unsigned int slice = atoi (items [2].c_str());
1655 unsigned int subchannel = atoi (items [3].c_str());
1701 if (items[4].
find(
"CALIB")!=std::string::npos){
1704 else if (items[4].
find(
"HB")!=std::string::npos){
1707 else if (items[4].
find(
"HE")!=std::string::npos){
1710 else if (items[4].
find(
"HO")!=std::string::npos){
1713 else if (items[4].
find(
"HF")!=std::string::npos){
1717 edm::LogError(
"MapFormat") <<
"HcalDcsMap-> Unknown subdetector, line is not accepted: " << items[5];
1720 HcalDcsDetId dcsId(subdet, ring, slice, type, subchannel);
1723 if (converter.isHcalDetId()){
1724 id = converter.getId();
1727 edm::LogWarning(
"Invalid HCAL channel") <<
"HcalDcsMap-> invalid channel: "
1731 << items [7] << std::endl;
1745 sprintf (buf,
"# %7s %10s %6s %8s %7s %5s %5s %6s",
1746 "i",
"side_ring",
"slice",
"subchan",
"subdet",
"ieta",
"iphi",
"depth");
1747 fOutput << buf << std::endl;
1749 unsigned int line_counter = 0;
1756 sprintf (buf,
" %8X %10d %6d %8d %7s %5s %5s %6s",
1761 _converter.getFlavor().c_str(),
1762 _converter.getField1().c_str(),
1763 _converter.getField2().c_str(),
1764 _converter.getField3().c_str()
1766 fOutput << buf << std::endl;
1776 if (!fObject)
return false;
1778 while (fInput.getline(buffer, 1024)) {
1779 if (buffer [0] ==
'#')
continue;
1781 if (items.size()==0)
continue;
1782 if (items.size () != 9) {
1783 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;
1791 atoi (items [4].c_str()),
1792 atoi (items [5].c_str()),
1793 atoi (items [6].c_str()),
1794 atof (items [7].c_str()),
1806 sprintf (buffer,
"# %15s %15s %15s %15s %15s %15s %15s %15s %30s\n",
"eta",
"phi",
"dep",
"det",
"FirstSample",
"SamplesToAdd",
"ExpectedPeak",
"MinEnergy",
"Coefficients");
1809 std::sort (channels.begin(), channels.end(), DetIdLess ());
1810 for (std::vector<DetId>::iterator channel = channels.begin ();
1811 channel != channels.end ();
1816 sprintf (buffer,
" %15u %15u %15u %15f",
1831 if (x<coef.size()-1)
1834 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.
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
T x() const
Cartesian x coordinate.
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