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);
70 return converter.getId();
77 " %15s %15s %15s %15s",
78 converter.getField1().c_str(),
79 converter.getField2().c_str(),
80 converter.getField3().c_str(),
81 converter.getFlavor().c_str());
85 template <
class S,
class T>
88 while (fInput.getline(buffer, 1024)) {
94 if (items.size() < 8) {
96 <<
"\n line must contain 8 items: eta, phi, depth, subdet, 4x values"
106 S fCondObject(
id, atof(items[4].c_str()), atof(items[5].c_str()), atof(items[6].c_str()), atof(items[7].c_str()));
107 fObject.addValues(fCondObject);
118 "# %15s %15s %15s %15s %8s %8s %8s %8s %10s\n",
129 std::vector<DetId> channels = fObject.getAllChannels();
131 for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
132 const float*
values = fObject.getValues(*channel)->getValues();
134 dumpId(fOutput, *channel);
136 buffer,
" %8.5f %8.5f %8.5f %8.5f %10X\n", values[0], values[1], values[2], values[3], channel->rawId());
143 template <
class S,
class T>
146 while (fInput.getline(buffer, 1024)) {
147 if (buffer[0] ==
'#')
152 if (items.size() < 5) {
154 <<
"\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
163 S fCondObject(
id, atof(items[4].c_str()));
164 fObject.addValues(fCondObject);
173 sprintf(buffer,
"# %15s %15s %15s %15s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
175 std::vector<DetId> channels = fObject.getAllChannels();
176 std::sort(channels.begin(), channels.end(),
DetIdLess());
177 for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
178 const float value = fObject.getValues(*channel)->getValue();
179 dumpId(fOutput, *channel);
180 sprintf(buffer,
" %8.5f %10X\n", value, channel->rawId());
186 template <
class S,
class T>
189 while (fInput.getline(buffer, 1024)) {
190 if (buffer[0] ==
'#')
195 if (items.size() < 5) {
197 <<
"\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
206 fCondObject =
new S(
id, atoi(items[4].c_str()));
207 fObject.addValues(*fCondObject);
217 sprintf(buffer,
"# %15s %15s %15s %15s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
219 std::vector<DetId> channels = fObject.getAllChannels();
220 std::sort(channels.begin(), channels.end(),
DetIdLess());
221 for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
222 const int value = fObject.getValues(*channel)->getValue();
223 dumpId(fOutput, *channel);
224 sprintf(buffer,
" %15d %10X\n", value, channel->rawId());
230 bool getObject(std::istream& fInput,
CastorGains& fObject) {
return getCastorObject<CastorGain>(fInput, fObject); }
233 return getCastorObject<CastorGainWidth>(fInput, fObject);
238 return getCastorSingleFloatObject<CastorSaturationCorr>(fInput, fObject);
248 while (fInput.getline(buffer, 1024)) {
253 if (items[0] ==
"#U") {
259 edm::LogWarning(
"Pedestal Unit Error") <<
"Unrecognized unit for pedestals. Assuming fC." << std::endl;
265 <<
"The unit for the pedestals is missing in the txt file." << std::endl;
270 while (fInput.getline(buffer, 1024)) {
271 if (buffer[0] ==
'#')
276 if (items.size() < 8) {
278 <<
"Bad line: " << buffer <<
"\n line must contain 8 items: eta, phi, depth, subdet, 4x values"
279 <<
" or 12 items: eta, phi, depth, subdet, 4x values for mean, 4x values for width" << std::endl;
289 if (items.size() < 12)
292 atof(items[4].c_str()),
293 atof(items[5].c_str()),
294 atof(items[6].c_str()),
295 atof(items[7].c_str()),
304 atof(items[4].c_str()),
305 atof(items[5].c_str()),
306 atof(items[6].c_str()),
307 atof(items[7].c_str()),
308 atof(items[8].c_str()),
309 atof(items[9].c_str()),
310 atof(items[10].c_str()),
311 atof(items[11].c_str()));
323 sprintf(buffer,
"#U ADC << this is the unit \n");
325 sprintf(buffer,
"#U fC << this is the unit \n");
329 "# %15s %15s %15s %15s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
346 std::sort(channels.begin(), channels.end(), DetIdLess());
347 for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
350 dumpId(fOutput, *channel);
352 " %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %10X\n",
371 while (fInput.getline(buffer, 1024)) {
372 if (buffer[0] ==
'#')
377 if (items.size() < 5) {
379 <<
"\n line must contain 5 items: eta, phi, depth, subdet, GOOD/BAD/HOT/DEAD"
387 <<
"line: " << buffer <<
"\n attempts to redefine data. Ignored" << std::endl;
393 std::unique_ptr<CastorChannelStatus> fCondObject;
394 if (items[4].substr(0, 2) ==
"0x") {
395 sscanf(items[4].c_str(),
"%X", &mystatus);
396 fCondObject = std::make_unique<CastorChannelStatus>(
id, mystatus);
397 }
else if (isalpha(items[4].c_str()[0])) {
398 fCondObject = std::make_unique<CastorChannelStatus>(
id, items[4]);
400 sscanf(items[4].c_str(),
"%u", &mystatus);
401 fCondObject = std::make_unique<CastorChannelStatus>(
id, mystatus);
411 sprintf(buffer,
"# %15s %15s %15s %15s %15s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
414 std::sort(channels.begin(), channels.end(), DetIdLess());
415 for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
417 dumpId(fOutput, *channel);
418 sprintf(buffer,
" %15X %10X\n", value, channel->rawId());
429 while (fInput.getline(buffer, 1024)) {
442 <<
"Unrecognized unit for pedestal widths. Assuming fC." << std::endl;
448 <<
"The unit for the pedestal widths is missing in the txt file." << std::endl;
454 while (fInput.getline(buffer, 1024)) {
456 if (buffer[0] ==
'#')
461 if (items.size() < 14) {
462 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line number: " << linecounter
463 <<
"\n line must contain 14 items: eta, phi, depth, subdet, 10x correlations"
464 <<
" or 20 items: eta, phi, depth, subdet, 16x correlations" << std::endl;
474 if (items.size() < 20)
477 values.setSigma(0, 0, atof(items[4].c_str()));
478 values.setSigma(1, 0, atof(items[5].c_str()));
479 values.setSigma(1, 1, atof(items[6].c_str()));
480 values.setSigma(2, 0, atof(items[7].c_str()));
481 values.setSigma(2, 1, atof(items[8].c_str()));
482 values.setSigma(2, 2, atof(items[9].c_str()));
483 values.setSigma(3, 0, atof(items[10].c_str()));
484 values.setSigma(3, 1, atof(items[11].c_str()));
485 values.setSigma(3, 2, atof(items[12].c_str()));
486 values.setSigma(3, 3, atof(items[13].c_str()));
487 values.setSigma(0, 1, 0.);
488 values.setSigma(0, 2, 0.);
489 values.setSigma(0, 3, 0.);
490 values.setSigma(1, 2, 0.);
491 values.setSigma(1, 3, 0.);
492 values.setSigma(2, 3, 0.);
497 values.setSigma(0, 0, atof(items[4].c_str()));
498 values.setSigma(0, 1, atof(items[5].c_str()));
499 values.setSigma(0, 2, atof(items[6].c_str()));
500 values.setSigma(0, 3, atof(items[7].c_str()));
501 values.setSigma(1, 0, atof(items[8].c_str()));
502 values.setSigma(1, 1, atof(items[9].c_str()));
503 values.setSigma(1, 2, atof(items[10].c_str()));
504 values.setSigma(1, 3, atof(items[11].c_str()));
505 values.setSigma(2, 0, atof(items[12].c_str()));
506 values.setSigma(2, 1, atof(items[13].c_str()));
507 values.setSigma(2, 2, atof(items[14].c_str()));
508 values.setSigma(2, 3, atof(items[15].c_str()));
509 values.setSigma(3, 0, atof(items[16].c_str()));
510 values.setSigma(3, 1, atof(items[17].c_str()));
511 values.setSigma(3, 2, atof(items[18].c_str()));
512 values.setSigma(3, 3, atof(items[19].c_str()));
524 sprintf(buffer,
"#U ADC << this is the unit \n");
526 sprintf(buffer,
"#U fC << this is the unit \n");
530 "# %15s %15s %15s %15s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
554 std::sort(channels.begin(), channels.end(), DetIdLess());
555 for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
558 dumpId(fOutput, *channel);
561 " %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",
588 while (fInput.getline(buffer, 1024)) {
589 if (buffer[0] ==
'#')
594 if (items[0] ==
"SHAPE") {
595 if (items.size() < 33) {
597 <<
"Bad line: " << buffer <<
"\n line must contain 33 items: SHAPE 32 x low QIE edges for first 32 bins"
606 if (items.size() < 36) {
608 <<
"\n line must contain 36 items: eta, phi, depth, subdet, 4 capId x 4 "
609 "Ranges x offsets, 4 capId x 4 Ranges x slopes"
622 for (
unsigned capid = 0; capid < 4; capid++) {
624 coder.setOffset(capid,
range, atof(items[index++].c_str()));
627 for (
unsigned capid = 0; capid < 4; capid++) {
629 coder.setSlope(capid,
range, atof(items[index++].c_str()));
642 fOutput <<
"# QIE basic shape: SHAPE 32 x low edge values for first 32 channels" << std::endl;
643 sprintf(buffer,
"SHAPE ");
645 for (
unsigned bin = 0;
bin < 32;
bin++) {
649 fOutput << std::endl;
651 fOutput <<
"# QIE data" << std::endl;
653 "# %15s %15s %15s %15s %36s %36s %36s %36s %36s %36s %36s %36s\n",
668 std::sort(channels.begin(), channels.end(), DetIdLess());
669 for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
671 dumpId(fOutput, *channel);
672 for (
unsigned capid = 0; capid < 4; capid++) {
674 sprintf(buffer,
" %8.5f", coder->
offset(capid,
range));
678 for (
unsigned capid = 0; capid < 4; capid++) {
680 sprintf(buffer,
" %8.5f", coder->
slope(capid,
range));
684 fOutput << std::endl;
692 while (fInput.getline(buffer, 1024)) {
693 if (buffer[0] ==
'#')
696 if (items.size() < 36) {
698 <<
"\n line must contain 36 items: eta, phi, depth, subdet, 32 bin values"
712 for (
unsigned bin = 0;
bin < 32;
bin++) {
713 values[
bin] = atof(items[index++].c_str());
715 coder.setMinCharges(values);
725 fOutput <<
"# QIE data in calibration mode" << std::endl;
726 sprintf(buffer,
"# %15s %15s %15s %15s %288s\n",
"eta",
"phi",
"dep",
"det",
"32 x charges");
729 std::sort(channels.begin(), channels.end(), DetIdLess());
730 for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
733 dumpId(fOutput, *channel);
735 for (
unsigned bin = 0;
bin < 32;
bin++) {
736 sprintf(buffer,
" %8.5f", lowEdge[
bin]);
739 fOutput << std::endl;
748 while (fInput.getline(buffer, 1024)) {
749 if (buffer[0] ==
'#')
752 if (items.size() < 12) {
755 if (items.size() < 9) {
759 if (items[8] ==
"NA" || items[8] ==
"NT") {
760 while (items.size() < 12)
762 }
else if (items[8] ==
"HT") {
763 if (items.size() == 11)
766 edm::LogError(
"MapFormat") <<
"CastorElectronicsMap-> Bad line: " << buffer
767 <<
"\n HT line must contain at least 11 items: i cr sl tb dcc spigot fiber "
768 "fiberchan subdet=HT ieta iphi";
773 <<
"CastorElectronicsMap-> Bad line: " << buffer
774 <<
"\n line must contain 12 items: i cr sl tb dcc spigot fiber fiberchan subdet ieta iphi depth";
779 int crate = atoi(items[1].c_str());
780 int slot = atoi(items[2].c_str());
784 int dcc = atoi(items[4].c_str());
785 int spigot = atoi(items[5].c_str());
787 if (items[8] ==
"HT" || items[8] ==
"NT") {
788 int slb = atoi(items[6].c_str());
789 int slbCh = atoi(items[7].c_str());
792 int fiber = atoi(items[6].c_str());
793 int fiberCh = atoi(items[7].c_str());
796 elId.
setHTR(crate, slot, top);
800 if (items[8] ==
"NA") {
802 }
else if (items[8] ==
"NT") {
806 if (converter.isHcalCastorDetId()) {
809 edm::LogWarning(
"Format Error") <<
"CastorElectronicsMap-> Unknown subdetector: " << items[8] <<
'/'
810 << items[9] <<
'/' << items[10] <<
'/' << items[11] << std::endl;
824 "# %7s %3s %3s %3s %4s %7s %10s %14s %7s %5s %5s %6s",
837 fOutput << buf << std::endl;
839 for (
unsigned i = 0;
i < eids.size();
i++) {
843 if (trigger.
rawId()) {
849 " %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
851 converter.getId().rawId(),
861 converter.getFlavor().c_str(),
862 converter.getField1().c_str(),
863 converter.getField2().c_str(),
864 converter.getField3().c_str());
865 fOutput << buf << std::endl;
869 if (channel.
rawId()) {
874 " %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
876 converter.getId().rawId(),
884 converter.getFlavor().c_str(),
885 converter.getField1().c_str(),
886 converter.getField2().c_str(),
887 converter.getField3().c_str());
888 fOutput << buf << std::endl;
897 while (fInput.getline(buffer, 1024)) {
898 if (buffer[0] ==
'#')
903 if (items.size() < 6) {
905 <<
"Bad line: " << buffer
906 <<
"\n line must contain 6 items: eta, phi, depth, subdet, firstSample, samplesToAdd" << std::endl;
911 CastorRecoParam fCondObject(
id, atoi(items[4].c_str()), atoi(items[5].c_str()));
920 "# %15s %15s %15s %15s %18s %15s %10s\n",
930 std::sort(channels.begin(), channels.end(), DetIdLess());
931 for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
932 dumpId(fOutput, *channel);
bool getCastorObject(std::istream &fInput, T &fObject)
static const HcalDetId Undefined
constexpr int ietaAbs() const
get the absolute value of the cell ieta
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
uint16_t *__restrict__ id
static int slb(const HcalTriggerPrimitiveSample &theSample)
void setUnitADC(bool isADC)
constexpr int zside() const
get the z-side of the cell (1/-1)
std::vector< std::string > splitString(const std::string &fLine)
int readoutVMECrateId() const
const CastorQIEShape & getShape() const
get basic shape
void setHTR(int crate, int slot, int tb)
bool addCoder(const CastorCalibrationQIECoder &fCoder)
constexpr uint32_t rawId() const
get the raw id
std::vector< DetId > getAllChannels() const
const CastorCalibrationQIECoder * getCoder(DetId fId) const
get QIE parameters
bool getCastorSingleIntObject(std::istream &fInput, T &fObject, S *fCondObject)
bool getCastorSingleFloatObject(std::istream &fInput, T &fObject)
const float * minCharges() const
int slbSiteNumber() const
void dumpId(std::ostream &fOutput, DetId id)
Log< level::Error, false > LogError
const Item * getValues(DetId fId, bool throwOnFail=true) const
bool dumpCastorSingleIntObject(std::ostream &fOutput, const T &fObject)
bool mapEId2tId(CastorElectronicsId fElectronicsId, HcalTrigTowerDetId fTriggerId)
const uint16_t range(const Frame &aFrame)
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
uint32_t getValue() const
constexpr int iphi() const
get the cell iphi
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 dumpCastorSingleFloatObject(std::ostream &fOutput, const T &fObject)
bool isTriggerChainId() const
void setUnitADC(bool isADC)
DetId getId(const std::vector< std::string > &items)
unsigned int firstSample() const
const CastorQIECoder * getCoder(DetId fId) const
get QIE parameters
bool dumpObject(std::ostream &fOutput, const CastorPedestals &fObject)
bool getObject(std::istream &fInput, 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
constexpr int depth() const
get the tower depth
HcalGenericSubdetector genericSubdet() const
Log< level::Warning, false > LogWarning
float slope(unsigned fCapId, unsigned fRange) const
int slbChannelIndex() const
bool addCoder(const CastorQIECoder &fCoder)