52 std::vector<std::string>
result;
55 for (
unsigned i = 0;
i <= fLine.size();
i++) {
56 if (fLine[
i] ==
' ' ||
i == fLine.size()) {
59 result.push_back(item);
73 return converter.
getId();
80 " %15s %15s %15s %15s",
88 template <
class S,
class T>
91 while (fInput.getline(buffer, 1024)) {
97 if (items.size() < 8) {
99 <<
"\n line must contain 8 items: eta, phi, depth, subdet, 4x values" 109 S fCondObject(
id, atof(items[4].c_str()), atof(items[5].c_str()), atof(items[6].c_str()), atof(items[7].c_str()));
110 fObject.addValues(fCondObject);
121 "# %15s %15s %15s %15s %8s %8s %8s %8s %10s\n",
132 std::vector<DetId> channels = fObject.getAllChannels();
134 for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
135 const float*
values = fObject.getValues(*channel)->getValues();
137 dumpId(fOutput, *channel);
139 buffer,
" %8.5f %8.5f %8.5f %8.5f %10X\n", values[0], values[1], values[2], values[3], channel->rawId());
146 template <
class S,
class T>
149 while (fInput.getline(buffer, 1024)) {
150 if (buffer[0] ==
'#')
155 if (items.size() < 5) {
157 <<
"\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
166 S fCondObject(
id, atof(items[4].c_str()));
167 fObject.addValues(fCondObject);
176 sprintf(buffer,
"# %15s %15s %15s %15s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
178 std::vector<DetId> channels = fObject.getAllChannels();
180 for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
181 const float value = fObject.getValues(*channel)->getValue();
182 dumpId(fOutput, *channel);
183 sprintf(buffer,
" %8.5f %10X\n", value, channel->rawId());
189 template <
class S,
class T>
192 while (fInput.getline(buffer, 1024)) {
193 if (buffer[0] ==
'#')
198 if (items.size() < 5) {
200 <<
"\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
209 fCondObject =
new S(
id, atoi(items[4].c_str()));
210 fObject.addValues(*fCondObject);
220 sprintf(buffer,
"# %15s %15s %15s %15s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
222 std::vector<DetId> channels = fObject.getAllChannels();
224 for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
225 const int value = fObject.getValues(*channel)->getValue();
226 dumpId(fOutput, *channel);
227 sprintf(buffer,
" %15d %10X\n", value, channel->rawId());
233 bool getObject(std::istream& fInput,
CastorGains& fObject) {
return getCastorObject<CastorGain>(fInput, fObject); }
236 return getCastorObject<CastorGainWidth>(fInput, fObject);
241 return getCastorSingleFloatObject<CastorSaturationCorr>(fInput, fObject);
251 while (fInput.getline(buffer, 1024)) {
256 if (items[0] ==
"#U") {
262 edm::LogWarning(
"Pedestal Unit Error") <<
"Unrecognized unit for pedestals. Assuming fC." << std::endl;
268 <<
"The unit for the pedestals is missing in the txt file." << std::endl;
273 while (fInput.getline(buffer, 1024)) {
274 if (buffer[0] ==
'#')
279 if (items.size() < 8) {
281 <<
"Bad line: " << buffer <<
"\n line must contain 8 items: eta, phi, depth, subdet, 4x values" 282 <<
" or 12 items: eta, phi, depth, subdet, 4x values for mean, 4x values for width" << std::endl;
292 if (items.size() < 12)
295 atof(items[4].c_str()),
296 atof(items[5].c_str()),
297 atof(items[6].c_str()),
298 atof(items[7].c_str()),
307 atof(items[4].c_str()),
308 atof(items[5].c_str()),
309 atof(items[6].c_str()),
310 atof(items[7].c_str()),
311 atof(items[8].c_str()),
312 atof(items[9].c_str()),
313 atof(items[10].c_str()),
314 atof(items[11].c_str()));
326 sprintf(buffer,
"#U ADC << this is the unit \n");
328 sprintf(buffer,
"#U fC << this is the unit \n");
332 "# %15s %15s %15s %15s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
350 for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
353 dumpId(fOutput, *channel);
355 " %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %10X\n",
374 while (fInput.getline(buffer, 1024)) {
375 if (buffer[0] ==
'#')
380 if (items.size() < 5) {
382 <<
"\n line must contain 5 items: eta, phi, depth, subdet, GOOD/BAD/HOT/DEAD" 390 <<
"line: " << buffer <<
"\n attempts to redefine data. Ignored" << std::endl;
396 std::unique_ptr<CastorChannelStatus> fCondObject;
397 if (items[4].substr(0, 2) ==
"0x") {
398 sscanf(items[4].c_str(),
"%X", &mystatus);
399 fCondObject = std::make_unique<CastorChannelStatus>(
id, mystatus);
400 }
else if (isalpha(items[4].c_str()[0])) {
401 fCondObject = std::make_unique<CastorChannelStatus>(
id, items[4]);
403 sscanf(items[4].c_str(),
"%u", &mystatus);
404 fCondObject = std::make_unique<CastorChannelStatus>(
id, mystatus);
414 sprintf(buffer,
"# %15s %15s %15s %15s %15s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
418 for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
420 dumpId(fOutput, *channel);
421 sprintf(buffer,
" %15X %10X\n", value, channel->rawId());
432 while (fInput.getline(buffer, 1024)) {
445 <<
"Unrecognized unit for pedestal widths. Assuming fC." << std::endl;
451 <<
"The unit for the pedestal widths is missing in the txt file." << std::endl;
457 while (fInput.getline(buffer, 1024)) {
459 if (buffer[0] ==
'#')
464 if (items.size() < 14) {
465 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line number: " << linecounter
466 <<
"\n line must contain 14 items: eta, phi, depth, subdet, 10x correlations" 467 <<
" or 20 items: eta, phi, depth, subdet, 16x correlations" << std::endl;
477 if (items.size() < 20)
480 values.
setSigma(0, 0, atof(items[4].c_str()));
481 values.
setSigma(1, 0, atof(items[5].c_str()));
482 values.
setSigma(1, 1, atof(items[6].c_str()));
483 values.
setSigma(2, 0, atof(items[7].c_str()));
484 values.
setSigma(2, 1, atof(items[8].c_str()));
485 values.
setSigma(2, 2, atof(items[9].c_str()));
486 values.
setSigma(3, 0, atof(items[10].c_str()));
487 values.
setSigma(3, 1, atof(items[11].c_str()));
488 values.
setSigma(3, 2, atof(items[12].c_str()));
489 values.
setSigma(3, 3, atof(items[13].c_str()));
500 values.
setSigma(0, 0, atof(items[4].c_str()));
501 values.
setSigma(0, 1, atof(items[5].c_str()));
502 values.
setSigma(0, 2, atof(items[6].c_str()));
503 values.
setSigma(0, 3, atof(items[7].c_str()));
504 values.
setSigma(1, 0, atof(items[8].c_str()));
505 values.
setSigma(1, 1, atof(items[9].c_str()));
506 values.
setSigma(1, 2, atof(items[10].c_str()));
507 values.
setSigma(1, 3, atof(items[11].c_str()));
508 values.
setSigma(2, 0, atof(items[12].c_str()));
509 values.
setSigma(2, 1, atof(items[13].c_str()));
510 values.
setSigma(2, 2, atof(items[14].c_str()));
511 values.
setSigma(2, 3, atof(items[15].c_str()));
512 values.
setSigma(3, 0, atof(items[16].c_str()));
513 values.
setSigma(3, 1, atof(items[17].c_str()));
514 values.
setSigma(3, 2, atof(items[18].c_str()));
515 values.
setSigma(3, 3, atof(items[19].c_str()));
527 sprintf(buffer,
"#U ADC << this is the unit \n");
529 sprintf(buffer,
"#U fC << this is the unit \n");
533 "# %15s %15s %15s %15s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
558 for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
561 dumpId(fOutput, *channel);
564 " %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",
591 while (fInput.getline(buffer, 1024)) {
592 if (buffer[0] ==
'#')
597 if (items[0] ==
"SHAPE") {
598 if (items.size() < 33) {
600 <<
"Bad line: " << buffer <<
"\n line must contain 33 items: SHAPE 32 x low QIE edges for first 32 bins" 609 if (items.size() < 36) {
611 <<
"\n line must contain 36 items: eta, phi, depth, subdet, 4 capId x 4 " 612 "Ranges x offsets, 4 capId x 4 Ranges x slopes" 625 for (
unsigned capid = 0; capid < 4; capid++) {
626 for (
unsigned range = 0; range < 4; range++) {
627 coder.
setOffset(capid, range, atof(items[index++].c_str()));
630 for (
unsigned capid = 0; capid < 4; capid++) {
631 for (
unsigned range = 0; range < 4; range++) {
632 coder.
setSlope(capid, range, atof(items[index++].c_str()));
645 fOutput <<
"# QIE basic shape: SHAPE 32 x low edge values for first 32 channels" << std::endl;
646 sprintf(buffer,
"SHAPE ");
648 for (
unsigned bin = 0;
bin < 32;
bin++) {
652 fOutput << std::endl;
654 fOutput <<
"# QIE data" << std::endl;
656 "# %15s %15s %15s %15s %36s %36s %36s %36s %36s %36s %36s %36s\n",
672 for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
674 dumpId(fOutput, *channel);
675 for (
unsigned capid = 0; capid < 4; capid++) {
676 for (
unsigned range = 0; range < 4; range++) {
677 sprintf(buffer,
" %8.5f", coder->
offset(capid, range));
681 for (
unsigned capid = 0; capid < 4; capid++) {
682 for (
unsigned range = 0; range < 4; range++) {
683 sprintf(buffer,
" %8.5f", coder->
slope(capid, range));
687 fOutput << std::endl;
695 while (fInput.getline(buffer, 1024)) {
696 if (buffer[0] ==
'#')
699 if (items.size() < 36) {
701 <<
"\n line must contain 36 items: eta, phi, depth, subdet, 32 bin values" 715 for (
unsigned bin = 0;
bin < 32;
bin++) {
716 values[
bin] = atof(items[index++].c_str());
728 fOutput <<
"# QIE data in calibration mode" << std::endl;
729 sprintf(buffer,
"# %15s %15s %15s %15s %288s\n",
"eta",
"phi",
"dep",
"det",
"32 x charges");
733 for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
736 dumpId(fOutput, *channel);
738 for (
unsigned bin = 0;
bin < 32;
bin++) {
739 sprintf(buffer,
" %8.5f", lowEdge[
bin]);
742 fOutput << std::endl;
751 while (fInput.getline(buffer, 1024)) {
752 if (buffer[0] ==
'#')
755 if (items.size() < 12) {
758 if (items.size() < 9) {
762 if (items[8] ==
"NA" || items[8] ==
"NT") {
763 while (items.size() < 12)
765 }
else if (items[8] ==
"HT") {
766 if (items.size() == 11)
769 edm::LogError(
"MapFormat") <<
"CastorElectronicsMap-> Bad line: " << buffer
770 <<
"\n HT line must contain at least 11 items: i cr sl tb dcc spigot fiber " 771 "fiberchan subdet=HT ieta iphi";
776 <<
"CastorElectronicsMap-> Bad line: " << buffer
777 <<
"\n line must contain 12 items: i cr sl tb dcc spigot fiber fiberchan subdet ieta iphi depth";
782 int crate = atoi(items[1].c_str());
783 int slot = atoi(items[2].c_str());
787 int dcc = atoi(items[4].c_str());
788 int spigot = atoi(items[5].c_str());
790 if (items[8] ==
"HT" || items[8] ==
"NT") {
791 int slb = atoi(items[6].c_str());
792 int slbCh = atoi(items[7].c_str());
795 int fiber = atoi(items[6].c_str());
796 int fiberCh = atoi(items[7].c_str());
799 elId.
setHTR(crate, slot, top);
803 if (items[8] ==
"NA") {
805 }
else if (items[8] ==
"NT") {
812 edm::LogWarning(
"Format Error") <<
"CastorElectronicsMap-> Unknown subdetector: " << items[8] <<
'/' 813 << items[9] <<
'/' << items[10] <<
'/' << items[11] << std::endl;
827 "# %7s %3s %3s %3s %4s %7s %10s %14s %7s %5s %5s %6s",
840 fOutput << buf << std::endl;
842 for (
unsigned i = 0;
i < eids.size();
i++) {
846 if (trigger.
rawId()) {
852 " %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
868 fOutput << buf << std::endl;
872 if (channel.
rawId()) {
877 " %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
891 fOutput << buf << std::endl;
900 while (fInput.getline(buffer, 1024)) {
901 if (buffer[0] ==
'#')
906 if (items.size() < 6) {
908 <<
"Bad line: " << buffer
909 <<
"\n line must contain 6 items: eta, phi, depth, subdet, firstSample, samplesToAdd" << std::endl;
914 CastorRecoParam fCondObject(
id, atoi(items[4].c_str()), atoi(items[5].c_str()));
923 "# %15s %15s %15s %15s %18s %15s %10s\n",
934 for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
935 dumpId(fOutput, *channel);
const std::string & getField2() const
bool getCastorObject(std::istream &fInput, T &fObject)
static const HcalDetId Undefined
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
void setSigma(int fCapId1, int fCapId2, float fSigma)
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 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 setSlope(unsigned fCapId, unsigned fRange, float fValue)
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)
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
void setMinCharges(const float fValue[32])
uint32_t getValue() const
float getSigma(int fCapId1, int fCapId2) const
get correlation element for capId1/2 = 0..3
unsigned int samplesToAdd() const
bool dumpCastorSingleFloatObject(std::ostream &fOutput, const T &fObject)
const std::string & getField1() const
void setOffset(unsigned fCapId, unsigned fRange, float fValue)
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
bin
set the eta bin as selection string.
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 getObject(std::istream &fInput, CastorPedestals &fObject)
bool operator()(DetId fFirst, DetId fSecond) const
double S(const TLorentzVector &, const TLorentzVector &)
bool isHcalCastorDetId() const
static const HcalTrigTowerDetId Undefined
std::vector< CastorElectronicsId > allElectronicsId() const
float offset(unsigned fCapId, unsigned fRange) const
bool addValues(const Item &myItem)
const std::string & getField3() const
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
const std::string & getFlavor() const
float slope(unsigned fCapId, unsigned fRange) const
int slbChannelIndex() const
bool addCoder(const CastorQIECoder &fCoder)