22 if (
first.genericSubdet() !=
second.genericSubdet())
23 return first.genericSubdet() <
second.genericSubdet();
24 if (
first.isHcalDetId()) {
39 return first.readoutVMECrateId() !=
second.readoutVMECrateId()
40 ?
first.readoutVMECrateId() <
second.readoutVMECrateId()
49 std::vector<std::string>
result;
52 for (
unsigned i = 0;
i <= fLine.size();
i++) {
53 if (fLine[
i] ==
' ' ||
i == fLine.size()) {
77 " %15s %15s %15s %15s",
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);
143 template <
class S,
class T>
146 while (fInput.getline(
buffer, 1024)) {
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();
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)) {
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();
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)) {
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",
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)) {
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");
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)) {
461 if (
items.size() < 14) {
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)
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.);
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",
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",
562 item->getSigma(0, 0),
563 item->getSigma(0, 1),
564 item->getSigma(0, 2),
565 item->getSigma(0, 3),
566 item->getSigma(1, 0),
567 item->getSigma(1, 1),
568 item->getSigma(1, 2),
569 item->getSigma(1, 3),
570 item->getSigma(2, 0),
571 item->getSigma(2, 1),
572 item->getSigma(2, 2),
573 item->getSigma(2, 3),
574 item->getSigma(3, 0),
575 item->getSigma(3, 1),
576 item->getSigma(3, 2),
577 item->getSigma(3, 3),
588 while (fInput.getline(
buffer, 1024)) {
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++) {
627 for (
unsigned capid = 0; capid < 4; capid++) {
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",
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++) {
678 for (
unsigned capid = 0; capid < 4; capid++) {
684 fOutput << std::endl;
692 while (fInput.getline(
buffer, 1024)) {
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++) {
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");
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++) {
739 fOutput << std::endl;
748 while (fInput.getline(
buffer, 1024)) {
752 if (
items.size() < 12) {
755 if (
items.size() < 9) {
760 while (
items.size() < 12)
762 }
else if (
items[8] ==
"HT") {
763 if (
items.size() == 11)
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());
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") {
809 edm::LogWarning(
"Format Error") <<
"CastorElectronicsMap-> Unknown subdetector: " <<
items[8] <<
'/' 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++) {
841 if (
eid.isTriggerChainId()) {
849 " %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
854 eid.readoutVMECrateId(),
856 eid.htrTopBottom() > 0 ?
't' :
'b',
860 eid.slbChannelIndex(),
865 fOutput <<
buf << std::endl;
869 if (channel.
rawId()) {
874 " %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
877 eid.readoutVMECrateId(),
879 eid.htrTopBottom() > 0 ?
't' :
'b',
888 fOutput <<
buf << std::endl;
897 while (fInput.getline(
buffer, 1024)) {
903 if (
items.size() < 6) {
906 <<
"\n line must contain 6 items: eta, phi, depth, subdet, firstSample, samplesToAdd" << std::endl;
920 "# %15s %15s %15s %15s %18s %15s %10s\n",
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
float lowEdge(unsigned fAdc) const
bool operator()(DetId fFirst, DetId fSecond) const
const Item * getValues(DetId fId, bool throwOnFail=true) const
const float * minCharges() const
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)
constexpr int ietaAbs() const
get the absolute value of the cell ieta
void setHTR(int crate, int slot, int tb)
bool addCoder(const CastorCalibrationQIECoder &fCoder)
bool getCastorSingleIntObject(std::istream &fInput, T &fObject, S *fCondObject)
bool getCastorSingleFloatObject(std::istream &fInput, T &fObject)
void setSlope(unsigned fCapId, unsigned fRange, float fValue)
void dumpId(std::ostream &fOutput, DetId id)
Log< level::Error, false > LogError
const DetId lookupTrigger(CastorElectronicsId fId) const
brief lookup the trigger logical detid associated with the given electronics id
bool dumpCastorSingleIntObject(std::ostream &fOutput, const T &fObject)
bool mapEId2tId(CastorElectronicsId fElectronicsId, HcalTrigTowerDetId fTriggerId)
std::vector< DetId > getAllChannels() const
const CastorCalibrationQIECoder * getCoder(DetId fId) const
get QIE parameters
unsigned int samplesToAdd() const
std::vector< CastorElectronicsId > allElectronicsId() const
U second(std::pair< T, U > const &p)
unsigned int firstSample() const
void setMinCharges(const float fValue[32])
float slope(unsigned fCapId, unsigned fRange) const
float offset(unsigned fCapId, unsigned fRange) const
bool dumpCastorSingleFloatObject(std::ostream &fOutput, const T &fObject)
void setOffset(unsigned fCapId, unsigned fRange, float fValue)
void setUnitADC(bool isADC)
DetId getId(const std::vector< std::string > &items)
bool dumpObject(std::ostream &fOutput, const CastorPedestals &fObject)
constexpr uint32_t rawId() const
get the raw id
bool getObject(std::istream &fInput, CastorPedestals &fObject)
uint32_t getValue() const
const DetId lookup(CastorElectronicsId fId) const
lookup the logical detid associated with the given electronics id
static const HcalTrigTowerDetId Undefined
bool addValues(const Item &myItem)
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 bool exists(DetId fId) const
const CastorQIEShape & getShape() const
get basic shape
Log< level::Warning, false > LogWarning
bool operator()(CastorElectronicsId first, CastorElectronicsId second) const
const float * getValues() const
get value for all capId = 0..3
const CastorQIECoder * getCoder(DetId fId) const
get QIE parameters
constexpr int iphi() const
get the cell iphi
bool addCoder(const CastorQIECoder &fCoder)
constexpr int depth() const
get the tower depth