49 std::vector <std::string>
result;
52 for (
unsigned i = 0;
i <= fLine.size ();
i++) {
53 if (fLine [
i] ==
' ' ||
i == fLine.size ()) {
56 result.push_back (item);
62 if (empty) empty =
false;
68 DetId getId (
const std::vector <std::string> & items) {
70 return converter.getId ();
76 sprintf (buffer,
" %15s %15s %15s %15s",
77 converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str (),converter.getFlavor ().c_str ());
81 template <
class T,
class S>
83 if (!fObject) fObject =
new T;
85 while (fInput.getline(buffer, 1024)) {
86 if (buffer [0] ==
'#')
continue;
88 if (items.size()==0)
continue;
89 if (items.size () < 8) {
90 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 8 items: eta, phi, depth, subdet, 4x values" << std::endl;
99 fCondObject =
new S(
id, atof (items [4].c_str()), atof (items [5].c_str()),
100 atof (items [6].c_str()), atof (items [7].c_str()));
101 fObject->addValues(*fCondObject);
112 sprintf (buffer,
"# %15s %15s %15s %15s %8s %8s %8s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"cap0",
"cap1",
"cap2",
"cap3",
"DetId");
114 std::vector<DetId> channels = fObject.getAllChannels ();
116 for (std::vector<DetId>::iterator channel = channels.begin ();
117 channel != channels.end ();
119 const float*
values = fObject.getValues (*channel)->getValues ();
121 dumpId (fOutput, *channel);
122 sprintf (buffer,
" %8.5f %8.5f %8.5f %8.5f %10X\n",
123 values[0], values[1], values[2], values[3], channel->rawId ());
130 template <
class T,
class S>
132 if (!fObject) fObject =
new T;
134 while (fInput.getline(buffer, 1024)) {
135 if (buffer [0] ==
'#')
continue;
137 if (items.size()==0)
continue;
138 if (items.size () < 5) {
139 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
148 fCondObject =
new S(
id, atof (items [4].c_str()) );
149 fObject->addValues(*fCondObject);
159 sprintf (buffer,
"# %15s %15s %15s %15s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
161 std::vector<DetId> channels = fObject.getAllChannels ();
162 std::sort (channels.begin(), channels.end(),
DetIdLess ());
163 for (std::vector<DetId>::iterator channel = channels.begin ();
164 channel != channels.end ();
166 const float value = fObject.getValues (*channel)->getValue ();
167 dumpId (fOutput, *channel);
168 sprintf (buffer,
" %8.5f %10X\n",
169 value, channel->rawId ());
175 template <
class T,
class S>
177 if (!fObject) fObject =
new T;
179 while (fInput.getline(buffer, 1024)) {
180 if (buffer [0] ==
'#')
continue;
182 if (items.size()==0)
continue;
183 if (items.size () < 5) {
184 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
193 fCondObject =
new S(
id, atoi (items [4].c_str()) );
194 fObject->addValues(*fCondObject);
204 sprintf (buffer,
"# %15s %15s %15s %15s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
206 std::vector<DetId> channels = fObject.getAllChannels ();
207 std::sort (channels.begin(), channels.end(),
DetIdLess ());
208 for (std::vector<DetId>::iterator channel = channels.begin ();
209 channel != channels.end ();
211 const int value = fObject.getValues (*channel)->getValue ();
212 dumpId (fOutput, *channel);
213 sprintf (buffer,
" %15d %10X\n",
214 value, channel->rawId ());
236 while (fInput.getline(buffer, 1024)) {
238 if (items.size()==0)
continue;
240 if (items[0] ==
"#U")
246 edm::LogWarning(
"Pedestal Unit Error") <<
"Unrecognized unit for pedestals. Assuming fC." << std::endl;
253 edm::LogWarning(
"Pedestal Unit Missing") <<
"The unit for the pedestals is missing in the txt file." << std::endl;
258 while (fInput.getline(buffer, 1024)) {
259 if (buffer [0] ==
'#')
continue;
261 if (items.size()==0)
continue;
262 if (items.size () < 8) {
263 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 8 items: eta, phi, depth, subdet, 4x values"
264 <<
" or 12 items: eta, phi, depth, subdet, 4x values for mean, 4x values for width"
275 if (items.size() < 12)
278 atof (items [6].c_str()), atof (items [7].c_str()),
286 atof (items [6].c_str()), atof (items [7].c_str()),
287 atof (items [8].c_str()), atof (items [9].c_str()),
288 atof (items [10].c_str()), atof (items [11].c_str()) );
301 if (fObject.
isADC() ) sprintf (buffer,
"#U ADC << this is the unit \n");
302 else sprintf (buffer,
"#U fC << this is the unit \n");
305 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");
309 std::sort (channels.begin(), channels.end(), DetIdLess ());
310 for (std::vector<DetId>::iterator channel = channels.begin ();
311 channel != channels.end ();
315 dumpId (fOutput, *channel);
316 sprintf (buffer,
" %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %10X\n",
317 values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], channel->rawId ());
330 while (fInput.getline(buffer, 1024)) {
331 if (buffer [0] ==
'#')
continue;
333 if (items.size()==0)
continue;
334 if (items.size () < 5) {
335 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 5 items: eta, phi, depth, subdet, GOOD/BAD/HOT/DEAD" << std::endl;
340 if (fObject->
exists(
id) ) {
341 edm::LogWarning(
"Redefining Channel") <<
"line: " << buffer <<
"\n attempts to redefine data. Ignored" << std::endl;
348 if (items[4].substr(0,2)==
"0x") {
349 sscanf(items[4].c_str(),
"%X", &mystatus);
352 else if (isalpha(items[4].c_str()[0])) {
356 sscanf(items[4].c_str(),
"%u", &mystatus);
369 sprintf (buffer,
"# %15s %15s %15s %15s %15s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
372 std::sort (channels.begin(), channels.end(), DetIdLess ());
373 for (std::vector<DetId>::iterator channel = channels.begin ();
374 channel != channels.end ();
377 dumpId (fOutput, *channel);
378 sprintf (buffer,
" %15X %10X\n",
379 value, channel->rawId ());
392 while (fInput.getline(buffer, 1024)) {
395 if (items.size()==0)
continue;
403 edm::LogWarning(
"Pedestal Width Unit Error") <<
"Unrecognized unit for pedestal widths. Assuming fC." << std::endl;
410 edm::LogWarning(
"Pedestal Width Unit Missing") <<
"The unit for the pedestal widths is missing in the txt file." << std::endl;
416 while (fInput.getline(buffer, 1024)) {
418 if (buffer [0] ==
'#')
continue;
420 if (items.size()==0)
continue;
421 if (items.size () < 14) {
422 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line number: " << linecounter <<
"\n line must contain 14 items: eta, phi, depth, subdet, 10x correlations"
423 <<
" or 20 items: eta, phi, depth, subdet, 16x correlations"
434 if (items.size() < 20)
437 values.setSigma (0, 0, atof (items [4].c_str()));
438 values.setSigma (1, 0, atof (items [5].c_str()));
439 values.setSigma (1, 1, atof (items [6].c_str()));
440 values.setSigma (2, 0, atof (items [7].c_str()));
441 values.setSigma (2, 1, atof (items [8].c_str()));
442 values.setSigma (2, 2, atof (items [9].c_str()));
443 values.setSigma (3, 0, atof (items [10].c_str()));
444 values.setSigma (3, 1, atof (items [11].c_str()));
445 values.setSigma (3, 2, atof (items [12].c_str()));
446 values.setSigma (3, 3, atof (items [13].c_str()));
447 values.setSigma (0, 1, 0.);
448 values.setSigma (0, 2, 0.);
449 values.setSigma (0, 3, 0.);
450 values.setSigma (1, 2, 0.);
451 values.setSigma (1, 3, 0.);
452 values.setSigma (2, 3, 0.);
458 values.setSigma (0, 0, atof (items [4].c_str()) );
459 values.setSigma (0, 1, atof (items [5].c_str()) );
460 values.setSigma (0, 2, atof (items [6].c_str()) );
461 values.setSigma (0, 3, atof (items [7].c_str()) );
462 values.setSigma (1, 0, atof (items [8].c_str()) );
463 values.setSigma (1, 1, atof (items [9].c_str()) );
464 values.setSigma (1, 2, atof (items [10].c_str()) );
465 values.setSigma (1, 3, atof (items [11].c_str()) );
466 values.setSigma (2, 0, atof (items [12].c_str()) );
467 values.setSigma (2, 1, atof (items [13].c_str()) );
468 values.setSigma (2, 2, atof (items [14].c_str()) );
469 values.setSigma (2, 3, atof (items [15].c_str()) );
470 values.setSigma (3, 0, atof (items [16].c_str()) );
471 values.setSigma (3, 1, atof (items [17].c_str()) );
472 values.setSigma (3, 2, atof (items [18].c_str()) );
473 values.setSigma (3, 3, atof (items [19].c_str()) );
484 if (fObject.
isADC() ) sprintf (buffer,
"#U ADC << this is the unit \n");
485 else sprintf (buffer,
"#U fC << this is the unit \n");
488 sprintf (buffer,
"# %15s %15s %15s %15s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
489 "eta",
"phi",
"dep",
"det",
490 "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",
494 std::sort (channels.begin(), channels.end(), DetIdLess ());
495 for (std::vector<DetId>::iterator channel = channels.begin ();
496 channel != channels.end ();
500 dumpId (fOutput, *channel);
501 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",
516 while (fInput.getline(buffer, 1024)) {
517 if (buffer [0] ==
'#')
continue;
519 if (items.size()<1)
continue;
520 if (items [0] ==
"SHAPE") {
521 if (items.size () < 33) {
522 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 33 items: SHAPE 32 x low QIE edges for first 32 bins" << std::endl;
531 if (items.size () < 36) {
532 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;
544 for (
unsigned capid = 0; capid < 4; capid++) {
545 for (
unsigned range = 0; range < 4; range++) {
546 coder.setOffset (capid, range, atof (items [index++].c_str ()));
549 for (
unsigned capid = 0; capid < 4; capid++) {
550 for (
unsigned range = 0; range < 4; range++) {
551 coder.setSlope (capid, range, atof (items [index++].c_str ()));
564 fOutput <<
"# QIE basic shape: SHAPE 32 x low edge values for first 32 channels" << std::endl;
565 sprintf (buffer,
"SHAPE ");
567 for (
unsigned bin = 0;
bin < 32;
bin++) {
571 fOutput << std::endl;
573 fOutput <<
"# QIE data" << std::endl;
574 sprintf (buffer,
"# %15s %15s %15s %15s %36s %36s %36s %36s %36s %36s %36s %36s\n",
575 "eta",
"phi",
"dep",
"det",
576 "4 x offsets cap0",
"4 x offsets cap1",
"4 x offsets cap2",
"4 x offsets cap3",
577 "4 x slopes cap0",
"4 x slopes cap1",
"4 x slopes cap2",
"4 x slopes cap3");
580 std::sort (channels.begin(), channels.end(), DetIdLess ());
581 for (std::vector<DetId>::iterator channel = channels.begin ();
582 channel != channels.end ();
585 dumpId (fOutput, *channel);
586 for (
unsigned capid = 0; capid < 4; capid++) {
587 for (
unsigned range = 0; range < 4; range++) {
588 sprintf (buffer,
" %8.5f", coder->
offset (capid, range));
592 for (
unsigned capid = 0; capid < 4; capid++) {
593 for (
unsigned range = 0; range < 4; range++) {
594 sprintf (buffer,
" %8.5f", coder->
slope (capid, range));
598 fOutput << std::endl;
606 while (fInput.getline(buffer, 1024)) {
607 if (buffer [0] ==
'#')
continue;
609 if (items.size () < 36) {
610 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 36 items: eta, phi, depth, subdet, 32 bin values" << std::endl;
623 for (
unsigned bin = 0;
bin < 32;
bin++) {
624 values[
bin] = atof (items [index++].c_str ());
626 coder.setMinCharges (values);
636 fOutput <<
"# QIE data in calibration mode" << std::endl;
637 sprintf (buffer,
"# %15s %15s %15s %15s %288s\n",
638 "eta",
"phi",
"dep",
"det",
"32 x charges");
641 std::sort (channels.begin(), channels.end(), DetIdLess ());
642 for (std::vector<DetId>::iterator channel = channels.begin ();
643 channel != channels.end ();
647 dumpId (fOutput, *channel);
649 for (
unsigned bin = 0;
bin < 32;
bin++) {
650 sprintf (buffer,
" %8.5f", lowEdge [
bin]);
653 fOutput << std::endl;
663 while (fInput.getline(buffer, 1024)) {
664 if (buffer [0] ==
'#')
continue;
666 if (items.size () < 12) {
667 if (items.size()==0)
continue;
668 if (items.size()<9) {
669 edm::LogError(
"MapFormat") <<
"CastorElectronicsMap-> line too short: " << buffer;
672 if (items[8]==
"NA" || items[8]==
"NT") {
673 while (items.size()<12) items.push_back(
"");
674 }
else if (items[8]==
"HT") {
675 if (items.size()==11) items.push_back(
"");
677 edm::LogError(
"MapFormat") <<
"CastorElectronicsMap-> Bad line: " << buffer
678 <<
"\n HT line must contain at least 11 items: i cr sl tb dcc spigot fiber fiberchan subdet=HT ieta iphi";
682 edm::LogError(
"MapFormat") <<
"CastorElectronicsMap-> Bad line: " << buffer
683 <<
"\n line must contain 12 items: i cr sl tb dcc spigot fiber fiberchan subdet ieta iphi depth";
688 int crate = atoi (items [1].c_str());
689 int slot = atoi (items [2].c_str());
691 if (items [3] ==
"b") top = 0;
692 int dcc = atoi (items [4].c_str());
693 int spigot = atoi (items [5].c_str());
695 if (items[8] ==
"HT" || items[8] ==
"NT") {
696 int slb = atoi (items [6].c_str());
697 int slbCh = atoi (items [7].c_str());
700 int fiber = atoi (items [6].c_str());
701 int fiberCh = atoi (items [7].c_str());
704 elId.
setHTR (crate, slot, top);
708 if (items [8] ==
"NA") {
710 }
else if (items [8] ==
"NT") {
714 if (converter.isHcalCastorDetId ()) {
718 edm::LogWarning(
"Format Error") <<
"CastorElectronicsMap-> Unknown subdetector: "
719 << items [8] <<
'/' << items [9] <<
'/' << items [10] <<
'/' << items [11] << std::endl;
732 sprintf (buf,
"# %7s %3s %3s %3s %4s %7s %10s %14s %7s %5s %5s %6s",
733 "i",
"cr",
"sl",
"tb",
"dcc",
"spigot",
"fiber/slb",
"fibcha/slbcha",
"subdet",
"ieta",
"iphi",
"depth");
734 fOutput << buf << std::endl;
736 for (
unsigned i = 0;
i < eids.size ();
i++) {
740 if (trigger.
rawId ()) {
744 sprintf (buf,
" %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
746 converter.getId().rawId(),
750 converter.getFlavor ().c_str (), converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str ()
752 fOutput << buf << std::endl;
756 if (channel.
rawId()) {
760 sprintf (buf,
" %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
762 converter.getId().rawId(),
764 converter.getFlavor ().c_str (), converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str ()
766 fOutput << buf << std::endl;
776 while (fInput.getline(buffer, 1024)) {
777 if (buffer [0] ==
'#')
continue;
779 if (items.size()==0)
continue;
780 if (items.size () < 6) {
781 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 6 items: eta, phi, depth, subdet, firstSample, samplesToAdd" << std::endl;
795 sprintf (buffer,
"# %15s %15s %15s %15s %18s %15s %10s\n",
"eta",
"phi",
"dep",
"det",
"firstSample",
"samplesToAdd",
"DetId");
798 std::sort (channels.begin(), channels.end(), DetIdLess ());
799 for (std::vector<DetId>::iterator channel = channels.begin();channel != channels.end();++channel) {
800 dumpId (fOutput, *channel);
801 sprintf (buffer,
" %15d %15d %16X\n",
static const HcalDetId Undefined
tuple start
Check for commandline option errors.
bool getCastorSingleIntObject(std::istream &fInput, T *fObject, S *fCondObject)
const DetId lookupTrigger(CastorElectronicsId fId) const
brief lookup the trigger logical detid associated with the given electronics id
bool operator()(CastorElectronicsId first, CastorElectronicsId second) const
static int slb(const HcalTriggerPrimitiveSample &theSample)
void setUnitADC(bool isADC)
std::vector< std::string > splitString(const std::string &fLine)
int readoutVMECrateId() const
int zside() const
get the z-side of the cell (1/-1)
const CastorQIEShape & getShape() const
get basic shape
void setHTR(int crate, int slot, int tb)
bool getCastorSingleFloatObject(std::istream &fInput, T *fObject, S *fCondObject)
bool addCoder(const CastorCalibrationQIECoder &fCoder)
std::vector< DetId > getAllChannels() const
const CastorCalibrationQIECoder * getCoder(DetId fId) const
get QIE parameters
const float * minCharges() const
int slbSiteNumber() const
void dumpId(std::ostream &fOutput, DetId id)
const Item * getValues(DetId fId, bool throwOnFail=true) const
bool dumpCastorSingleIntObject(std::ostream &fOutput, const T &fObject)
bool mapEId2tId(CastorElectronicsId fElectronicsId, HcalTrigTowerDetId fTriggerId)
uint32_t rawId() const
get the raw id
U second(std::pair< T, U > const &p)
const bool exists(DetId fId) const
const DetId lookup(CastorElectronicsId fId) const
lookup the logical detid associated with the given electronics id
int depth() const
get the tower depth
uint32_t getValue() const
bool getCastorObject(std::istream &fInput, T *fObject, S *fCondObject)
float getSigma(int fCapId1, int fCapId2) const
get correlation element for capId1/2 = 0..3
unsigned int samplesToAdd() const
IO for ASCII instances of Castor/HCAL Calibrations.
bool getObject(std::istream &fInput, CastorPedestals *fObject)
bool dumpCastorSingleFloatObject(std::ostream &fOutput, const T &fObject)
bool isTriggerChainId() const
void setUnitADC(bool isADC)
DetId getId(const std::vector< std::string > &items)
int ietaAbs() const
get the absolute value of the cell ieta
int iphi() const
get the cell iphi
unsigned int firstSample() const
const CastorQIECoder * getCoder(DetId fId) const
get QIE parameters
bool dumpObject(std::ostream &fOutput, const CastorPedestals &fObject)
bool operator()(DetId fFirst, DetId fSecond) const
double S(const TLorentzVector &, const TLorentzVector &)
static const HcalTrigTowerDetId Undefined
std::vector< CastorElectronicsId > allElectronicsId() const
float offset(unsigned fCapId, unsigned fRange) const
bool addValues(const Item &myItem)
float lowEdge(unsigned fAdc) const
bool mapEId2chId(CastorElectronicsId fElectronicsId, DetId fId)
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...
bool dumpCastorObject(std::ostream &fOutput, const T &fObject)
const float * getValues() const
get value for all capId = 0..3
HcalGenericSubdetector genericSubdet() const
float slope(unsigned fCapId, unsigned fRange) const
int slbChannelIndex() const
bool addCoder(const CastorQIECoder &fCoder)