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;
70 return converter.
getId ();
76 sprintf (buffer,
" %15s %15s %15s %15s",
81 template <
class S,
class T>
83 if (!fObject) fObject =
new T;
85 while (fInput.getline(buffer, 1024)) {
86 if (buffer [0] ==
'#')
continue;
88 if (items.empty())
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 S fCondObject(
id, atof (items [4].c_str()), atof (items [5].c_str()), atof (items [6].c_str()), atof (items [7].c_str()));
100 fObject->addValues(fCondObject);
110 sprintf (buffer,
"# %15s %15s %15s %15s %8s %8s %8s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"cap0",
"cap1",
"cap2",
"cap3",
"DetId");
112 std::vector<DetId> channels = fObject.getAllChannels ();
114 for (std::vector<DetId>::iterator channel = channels.begin ();
115 channel != channels.end ();
117 const float*
values = fObject.getValues (*channel)->getValues ();
119 dumpId (fOutput, *channel);
120 sprintf (buffer,
" %8.5f %8.5f %8.5f %8.5f %10X\n",
121 values[0], values[1], values[2], values[3], channel->rawId ());
128 template <
class S,
class T>
130 if (!fObject) fObject =
new T;
132 while (fInput.getline(buffer, 1024)) {
133 if (buffer [0] ==
'#')
continue;
135 if (items.empty())
continue;
136 if (items.size () < 5) {
137 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
146 S fCondObject(
id, atof (items [4].c_str()) );
147 fObject->addValues(fCondObject);
156 sprintf (buffer,
"# %15s %15s %15s %15s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
158 std::vector<DetId> channels = fObject.getAllChannels ();
159 std::sort (channels.begin(), channels.end(),
DetIdLess ());
160 for (std::vector<DetId>::iterator channel = channels.begin ();
161 channel != channels.end ();
163 const float value = fObject.getValues (*channel)->getValue ();
164 dumpId (fOutput, *channel);
165 sprintf (buffer,
" %8.5f %10X\n",
166 value, channel->rawId ());
172 template <
class S,
class T>
174 if (!fObject) fObject =
new T;
176 while (fInput.getline(buffer, 1024)) {
177 if (buffer [0] ==
'#')
continue;
179 if (items.empty())
continue;
180 if (items.size () < 5) {
181 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
190 fCondObject =
new S(
id, atoi (items [4].c_str()) );
191 fObject->addValues(*fCondObject);
201 sprintf (buffer,
"# %15s %15s %15s %15s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
203 std::vector<DetId> channels = fObject.getAllChannels ();
204 std::sort (channels.begin(), channels.end(),
DetIdLess ());
205 for (std::vector<DetId>::iterator channel = channels.begin ();
206 channel != channels.end ();
208 const int value = fObject.getValues (*channel)->getValue ();
209 dumpId (fOutput, *channel);
210 sprintf (buffer,
" %15d %10X\n",
211 value, channel->rawId ());
218 bool getObject (std::istream& fInput,
CastorGains* fObject) {
return getCastorObject<CastorGain> (fInput, fObject);}
233 while (fInput.getline(buffer, 1024)) {
235 if (items.empty())
continue;
237 if (items[0] ==
"#U")
243 edm::LogWarning(
"Pedestal Unit Error") <<
"Unrecognized unit for pedestals. Assuming fC." << std::endl;
250 edm::LogWarning(
"Pedestal Unit Missing") <<
"The unit for the pedestals is missing in the txt file." << std::endl;
255 while (fInput.getline(buffer, 1024)) {
256 if (buffer [0] ==
'#')
continue;
258 if (items.empty())
continue;
259 if (items.size () < 8) {
260 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 8 items: eta, phi, depth, subdet, 4x values" 261 <<
" or 12 items: eta, phi, depth, subdet, 4x values for mean, 4x values for width" 272 if (items.size() < 12)
275 atof (items [6].c_str()), atof (items [7].c_str()),
283 atof (items [6].c_str()), atof (items [7].c_str()),
284 atof (items [8].c_str()), atof (items [9].c_str()),
285 atof (items [10].c_str()), atof (items [11].c_str()) );
298 if (fObject.
isADC() ) sprintf (buffer,
"#U ADC << this is the unit \n");
299 else sprintf (buffer,
"#U fC << this is the unit \n");
302 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");
306 std::sort (channels.begin(), channels.end(),
DetIdLess ());
307 for (std::vector<DetId>::iterator channel = channels.begin ();
308 channel != channels.end ();
312 dumpId (fOutput, *channel);
313 sprintf (buffer,
" %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %10X\n",
314 values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], channel->rawId ());
327 while (fInput.getline(buffer, 1024)) {
328 if (buffer [0] ==
'#')
continue;
330 if (items.empty())
continue;
331 if (items.size () < 5) {
332 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 5 items: eta, phi, depth, subdet, GOOD/BAD/HOT/DEAD" << std::endl;
337 if (fObject->
exists(
id) ) {
338 edm::LogWarning(
"Redefining Channel") <<
"line: " << buffer <<
"\n attempts to redefine data. Ignored" << std::endl;
345 if (items[4].substr(0,2)==
"0x") {
346 sscanf(items[4].c_str(),
"%X", &mystatus);
349 else if (isalpha(items[4].c_str()[0])) {
353 sscanf(items[4].c_str(),
"%u", &mystatus);
366 sprintf (buffer,
"# %15s %15s %15s %15s %15s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
369 std::sort (channels.begin(), channels.end(),
DetIdLess ());
370 for (std::vector<DetId>::iterator channel = channels.begin ();
371 channel != channels.end ();
374 dumpId (fOutput, *channel);
375 sprintf (buffer,
" %15X %10X\n",
376 value, channel->rawId ());
389 while (fInput.getline(buffer, 1024)) {
392 if (items.empty())
continue;
400 edm::LogWarning(
"Pedestal Width Unit Error") <<
"Unrecognized unit for pedestal widths. Assuming fC." << std::endl;
407 edm::LogWarning(
"Pedestal Width Unit Missing") <<
"The unit for the pedestal widths is missing in the txt file." << std::endl;
413 while (fInput.getline(buffer, 1024)) {
415 if (buffer [0] ==
'#')
continue;
417 if (items.empty())
continue;
418 if (items.size () < 14) {
419 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line number: " << linecounter <<
"\n line must contain 14 items: eta, phi, depth, subdet, 10x correlations" 420 <<
" or 20 items: eta, phi, depth, subdet, 16x correlations" 431 if (items.size() < 20)
434 values.
setSigma (0, 0, atof (items [4].c_str()));
435 values.
setSigma (1, 0, atof (items [5].c_str()));
436 values.
setSigma (1, 1, atof (items [6].c_str()));
437 values.
setSigma (2, 0, atof (items [7].c_str()));
438 values.
setSigma (2, 1, atof (items [8].c_str()));
439 values.
setSigma (2, 2, atof (items [9].c_str()));
440 values.
setSigma (3, 0, atof (items [10].c_str()));
441 values.
setSigma (3, 1, atof (items [11].c_str()));
442 values.
setSigma (3, 2, atof (items [12].c_str()));
443 values.
setSigma (3, 3, atof (items [13].c_str()));
455 values.
setSigma (0, 0, atof (items [4].c_str()) );
456 values.
setSigma (0, 1, atof (items [5].c_str()) );
457 values.
setSigma (0, 2, atof (items [6].c_str()) );
458 values.
setSigma (0, 3, atof (items [7].c_str()) );
459 values.
setSigma (1, 0, atof (items [8].c_str()) );
460 values.
setSigma (1, 1, atof (items [9].c_str()) );
461 values.
setSigma (1, 2, atof (items [10].c_str()) );
462 values.
setSigma (1, 3, atof (items [11].c_str()) );
463 values.
setSigma (2, 0, atof (items [12].c_str()) );
464 values.
setSigma (2, 1, atof (items [13].c_str()) );
465 values.
setSigma (2, 2, atof (items [14].c_str()) );
466 values.
setSigma (2, 3, atof (items [15].c_str()) );
467 values.
setSigma (3, 0, atof (items [16].c_str()) );
468 values.
setSigma (3, 1, atof (items [17].c_str()) );
469 values.
setSigma (3, 2, atof (items [18].c_str()) );
470 values.
setSigma (3, 3, atof (items [19].c_str()) );
481 if (fObject.
isADC() ) sprintf (buffer,
"#U ADC << this is the unit \n");
482 else sprintf (buffer,
"#U fC << this is the unit \n");
485 sprintf (buffer,
"# %15s %15s %15s %15s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
486 "eta",
"phi",
"dep",
"det",
487 "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",
491 std::sort (channels.begin(), channels.end(),
DetIdLess ());
492 for (std::vector<DetId>::iterator channel = channels.begin ();
493 channel != channels.end ();
497 dumpId (fOutput, *channel);
498 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",
513 while (fInput.getline(buffer, 1024)) {
514 if (buffer [0] ==
'#')
continue;
516 if (items.empty())
continue;
517 if (items [0] ==
"SHAPE") {
518 if (items.size () < 33) {
519 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;
528 if (items.size () < 36) {
529 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;
541 for (
unsigned capid = 0; capid < 4; capid++) {
542 for (
unsigned range = 0; range < 4; range++) {
543 coder.
setOffset (capid, range, atof (items [index++].c_str ()));
546 for (
unsigned capid = 0; capid < 4; capid++) {
547 for (
unsigned range = 0; range < 4; range++) {
548 coder.
setSlope (capid, range, atof (items [index++].c_str ()));
561 fOutput <<
"# QIE basic shape: SHAPE 32 x low edge values for first 32 channels" << std::endl;
562 sprintf (buffer,
"SHAPE ");
564 for (
unsigned bin = 0;
bin < 32;
bin++) {
568 fOutput << std::endl;
570 fOutput <<
"# QIE data" << std::endl;
571 sprintf (buffer,
"# %15s %15s %15s %15s %36s %36s %36s %36s %36s %36s %36s %36s\n",
572 "eta",
"phi",
"dep",
"det",
573 "4 x offsets cap0",
"4 x offsets cap1",
"4 x offsets cap2",
"4 x offsets cap3",
574 "4 x slopes cap0",
"4 x slopes cap1",
"4 x slopes cap2",
"4 x slopes cap3");
577 std::sort (channels.begin(), channels.end(),
DetIdLess ());
578 for (std::vector<DetId>::iterator channel = channels.begin ();
579 channel != channels.end ();
582 dumpId (fOutput, *channel);
583 for (
unsigned capid = 0; capid < 4; capid++) {
584 for (
unsigned range = 0; range < 4; range++) {
585 sprintf (buffer,
" %8.5f", coder->
offset (capid, range));
589 for (
unsigned capid = 0; capid < 4; capid++) {
590 for (
unsigned range = 0; range < 4; range++) {
591 sprintf (buffer,
" %8.5f", coder->
slope (capid, range));
595 fOutput << std::endl;
603 while (fInput.getline(buffer, 1024)) {
604 if (buffer [0] ==
'#')
continue;
606 if (items.size () < 36) {
607 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 36 items: eta, phi, depth, subdet, 32 bin values" << std::endl;
620 for (
unsigned bin = 0;
bin < 32;
bin++) {
621 values[
bin] = atof (items [index++].c_str ());
633 fOutput <<
"# QIE data in calibration mode" << std::endl;
634 sprintf (buffer,
"# %15s %15s %15s %15s %288s\n",
635 "eta",
"phi",
"dep",
"det",
"32 x charges");
638 std::sort (channels.begin(), channels.end(),
DetIdLess ());
639 for (std::vector<DetId>::iterator channel = channels.begin ();
640 channel != channels.end ();
644 dumpId (fOutput, *channel);
646 for (
unsigned bin = 0;
bin < 32;
bin++) {
647 sprintf (buffer,
" %8.5f", lowEdge [
bin]);
650 fOutput << std::endl;
660 while (fInput.getline(buffer, 1024)) {
661 if (buffer [0] ==
'#')
continue;
663 if (items.size () < 12) {
664 if (items.empty())
continue;
665 if (items.size()<9) {
669 if (items[8]==
"NA" || items[8]==
"NT") {
670 while (items.size()<12) items.push_back(
"");
671 }
else if (items[8]==
"HT") {
672 if (items.size()==11) items.push_back(
"");
674 edm::LogError(
"MapFormat") <<
"CastorElectronicsMap-> Bad line: " << buffer
675 <<
"\n HT line must contain at least 11 items: i cr sl tb dcc spigot fiber fiberchan subdet=HT ieta iphi";
679 edm::LogError(
"MapFormat") <<
"CastorElectronicsMap-> Bad line: " << buffer
680 <<
"\n line must contain 12 items: i cr sl tb dcc spigot fiber fiberchan subdet ieta iphi depth";
685 int crate = atoi (items [1].c_str());
686 int slot = atoi (items [2].c_str());
688 if (items [3] ==
"b") top = 0;
689 int dcc = atoi (items [4].c_str());
690 int spigot = atoi (items [5].c_str());
692 if (items[8] ==
"HT" || items[8] ==
"NT") {
693 int slb = atoi (items [6].c_str());
694 int slbCh = atoi (items [7].c_str());
697 int fiber = atoi (items [6].c_str());
698 int fiberCh = atoi (items [7].c_str());
701 elId.
setHTR (crate, slot, top);
705 if (items [8] ==
"NA") {
707 }
else if (items [8] ==
"NT") {
715 edm::LogWarning(
"Format Error") <<
"CastorElectronicsMap-> Unknown subdetector: " 716 << items [8] <<
'/' << items [9] <<
'/' << items [10] <<
'/' << items [11] << std::endl;
729 sprintf (buf,
"# %7s %3s %3s %3s %4s %7s %10s %14s %7s %5s %5s %6s",
730 "i",
"cr",
"sl",
"tb",
"dcc",
"spigot",
"fiber/slb",
"fibcha/slbcha",
"subdet",
"ieta",
"iphi",
"depth");
731 fOutput << buf << std::endl;
733 for (
unsigned i = 0;
i < eids.size ();
i++) {
737 if (trigger.
rawId ()) {
741 sprintf (buf,
" %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
749 fOutput << buf << std::endl;
753 if (channel.
rawId()) {
757 sprintf (buf,
" %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
763 fOutput << buf << std::endl;
773 while (fInput.getline(buffer, 1024)) {
774 if (buffer [0] ==
'#')
continue;
776 if (items.empty())
continue;
777 if (items.size () < 6) {
778 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 6 items: eta, phi, depth, subdet, firstSample, samplesToAdd" << std::endl;
792 sprintf (buffer,
"# %15s %15s %15s %15s %18s %15s %10s\n",
"eta",
"phi",
"dep",
"det",
"firstSample",
"samplesToAdd",
"DetId");
795 std::sort (channels.begin(), channels.end(),
DetIdLess ());
796 for (std::vector<DetId>::iterator channel = channels.begin();channel != channels.end();++channel) {
797 dumpId (fOutput, *channel);
798 sprintf (buffer,
" %15d %15d %16X\n",
const std::string & getField2() const
static const HcalDetId Undefined
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
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
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
bool getCastorSingleFloatObject(std::istream &fInput, T *fObject)
unsigned int samplesToAdd() const
bool getObject(std::istream &fInput, CastorPedestals *fObject)
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 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 getCastorObject(std::istream &fInput, T *fObject)
bool addCoder(const CastorQIECoder &fCoder)