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>
84 while (fInput.getline(buffer, 1024)) {
85 if (buffer [0] ==
'#')
continue;
87 if (items.empty())
continue;
88 if (items.size () < 8) {
89 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 8 items: eta, phi, depth, subdet, 4x values" << std::endl;
98 S fCondObject(
id, atof (items [4].c_str()), atof (items [5].c_str()), atof (items [6].c_str()), atof (items [7].c_str()));
99 fObject.addValues(fCondObject);
109 sprintf (buffer,
"# %15s %15s %15s %15s %8s %8s %8s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"cap0",
"cap1",
"cap2",
"cap3",
"DetId");
111 std::vector<DetId> channels = fObject.getAllChannels ();
113 for (std::vector<DetId>::iterator channel = channels.begin ();
114 channel != channels.end ();
116 const float*
values = fObject.getValues (*channel)->getValues ();
118 dumpId (fOutput, *channel);
119 sprintf (buffer,
" %8.5f %8.5f %8.5f %8.5f %10X\n",
120 values[0], values[1], values[2], values[3], channel->rawId ());
127 template <
class S,
class T>
130 while (fInput.getline(buffer, 1024)) {
131 if (buffer [0] ==
'#')
continue;
133 if (items.empty())
continue;
134 if (items.size () < 5) {
135 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
144 S fCondObject(
id, atof (items [4].c_str()) );
145 fObject.addValues(fCondObject);
154 sprintf (buffer,
"# %15s %15s %15s %15s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
156 std::vector<DetId> channels = fObject.getAllChannels ();
157 std::sort (channels.begin(), channels.end(),
DetIdLess ());
158 for (std::vector<DetId>::iterator channel = channels.begin ();
159 channel != channels.end ();
161 const float value = fObject.getValues (*channel)->getValue ();
162 dumpId (fOutput, *channel);
163 sprintf (buffer,
" %8.5f %10X\n",
164 value, channel->rawId ());
170 template <
class S,
class T>
173 while (fInput.getline(buffer, 1024)) {
174 if (buffer [0] ==
'#')
continue;
176 if (items.empty())
continue;
177 if (items.size () < 5) {
178 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
187 fCondObject =
new S(
id, atoi (items [4].c_str()) );
188 fObject.addValues(*fCondObject);
198 sprintf (buffer,
"# %15s %15s %15s %15s %8s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
200 std::vector<DetId> channels = fObject.getAllChannels ();
201 std::sort (channels.begin(), channels.end(),
DetIdLess ());
202 for (std::vector<DetId>::iterator channel = channels.begin ();
203 channel != channels.end ();
205 const int value = fObject.getValues (*channel)->getValue ();
206 dumpId (fOutput, *channel);
207 sprintf (buffer,
" %15d %10X\n",
208 value, channel->rawId ());
215 bool getObject (std::istream& fInput,
CastorGains& fObject) {
return getCastorObject<CastorGain> (fInput, fObject);}
229 while (fInput.getline(buffer, 1024)) {
231 if (items.empty())
continue;
233 if (items[0] ==
"#U")
239 edm::LogWarning(
"Pedestal Unit Error") <<
"Unrecognized unit for pedestals. Assuming fC." << std::endl;
246 edm::LogWarning(
"Pedestal Unit Missing") <<
"The unit for the pedestals is missing in the txt file." << std::endl;
251 while (fInput.getline(buffer, 1024)) {
252 if (buffer [0] ==
'#')
continue;
254 if (items.empty())
continue;
255 if (items.size () < 8) {
256 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 8 items: eta, phi, depth, subdet, 4x values" 257 <<
" or 12 items: eta, phi, depth, subdet, 4x values for mean, 4x values for width" 268 if (items.size() < 12)
270 CastorPedestal fCondObject(
id, atof (items [4].c_str()), atof (items [5].c_str()),
271 atof (items [6].c_str()), atof (items [7].c_str()),
277 CastorPedestal fCondObject(
id, atof (items [4].c_str()), atof (items [5].c_str()),
278 atof (items [6].c_str()), atof (items [7].c_str()),
279 atof (items [8].c_str()), atof (items [9].c_str()),
280 atof (items [10].c_str()), atof (items [11].c_str()) );
292 if (fObject.
isADC() ) sprintf (buffer,
"#U ADC << this is the unit \n");
293 else sprintf (buffer,
"#U fC << this is the unit \n");
296 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");
300 std::sort (channels.begin(), channels.end(),
DetIdLess ());
301 for (std::vector<DetId>::iterator channel = channels.begin ();
302 channel != channels.end ();
306 dumpId (fOutput, *channel);
307 sprintf (buffer,
" %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %10X\n",
308 values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], channel->rawId ());
320 while (fInput.getline(buffer, 1024)) {
321 if (buffer [0] ==
'#')
continue;
323 if (items.empty())
continue;
324 if (items.size () < 5) {
325 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 5 items: eta, phi, depth, subdet, GOOD/BAD/HOT/DEAD" << std::endl;
330 if (fObject.
exists(
id) ) {
331 edm::LogWarning(
"Redefining Channel") <<
"line: " << buffer <<
"\n attempts to redefine data. Ignored" << std::endl;
337 std::unique_ptr<CastorChannelStatus> fCondObject;
338 if (items[4].substr(0,2)==
"0x") {
339 sscanf(items[4].c_str(),
"%X", &mystatus);
340 fCondObject = std::make_unique<CastorChannelStatus>(
id,mystatus);
342 else if (isalpha(items[4].c_str()[0])) {
343 fCondObject = std::make_unique<CastorChannelStatus>(
id, items[4]);
346 sscanf(items[4].c_str(),
"%u", &mystatus);
347 fCondObject = std::make_unique<CastorChannelStatus>(
id,mystatus);
358 sprintf (buffer,
"# %15s %15s %15s %15s %15s %10s\n",
"eta",
"phi",
"dep",
"det",
"value",
"DetId");
361 std::sort (channels.begin(), channels.end(),
DetIdLess ());
362 for (std::vector<DetId>::iterator channel = channels.begin ();
363 channel != channels.end ();
366 dumpId (fOutput, *channel);
367 sprintf (buffer,
" %15X %10X\n",
368 value, channel->rawId ());
380 while (fInput.getline(buffer, 1024)) {
383 if (items.empty())
continue;
391 edm::LogWarning(
"Pedestal Width Unit Error") <<
"Unrecognized unit for pedestal widths. Assuming fC." << std::endl;
398 edm::LogWarning(
"Pedestal Width Unit Missing") <<
"The unit for the pedestal widths is missing in the txt file." << std::endl;
404 while (fInput.getline(buffer, 1024)) {
406 if (buffer [0] ==
'#')
continue;
408 if (items.empty())
continue;
409 if (items.size () < 14) {
410 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line number: " << linecounter <<
"\n line must contain 14 items: eta, phi, depth, subdet, 10x correlations" 411 <<
" or 20 items: eta, phi, depth, subdet, 16x correlations" 422 if (items.size() < 20)
425 values.
setSigma (0, 0, atof (items [4].c_str()));
426 values.
setSigma (1, 0, atof (items [5].c_str()));
427 values.
setSigma (1, 1, atof (items [6].c_str()));
428 values.
setSigma (2, 0, atof (items [7].c_str()));
429 values.
setSigma (2, 1, atof (items [8].c_str()));
430 values.
setSigma (2, 2, atof (items [9].c_str()));
431 values.
setSigma (3, 0, atof (items [10].c_str()));
432 values.
setSigma (3, 1, atof (items [11].c_str()));
433 values.
setSigma (3, 2, atof (items [12].c_str()));
434 values.
setSigma (3, 3, atof (items [13].c_str()));
446 values.
setSigma (0, 0, atof (items [4].c_str()) );
447 values.
setSigma (0, 1, atof (items [5].c_str()) );
448 values.
setSigma (0, 2, atof (items [6].c_str()) );
449 values.
setSigma (0, 3, atof (items [7].c_str()) );
450 values.
setSigma (1, 0, atof (items [8].c_str()) );
451 values.
setSigma (1, 1, atof (items [9].c_str()) );
452 values.
setSigma (1, 2, atof (items [10].c_str()) );
453 values.
setSigma (1, 3, atof (items [11].c_str()) );
454 values.
setSigma (2, 0, atof (items [12].c_str()) );
455 values.
setSigma (2, 1, atof (items [13].c_str()) );
456 values.
setSigma (2, 2, atof (items [14].c_str()) );
457 values.
setSigma (2, 3, atof (items [15].c_str()) );
458 values.
setSigma (3, 0, atof (items [16].c_str()) );
459 values.
setSigma (3, 1, atof (items [17].c_str()) );
460 values.
setSigma (3, 2, atof (items [18].c_str()) );
461 values.
setSigma (3, 3, atof (items [19].c_str()) );
472 if (fObject.
isADC() ) sprintf (buffer,
"#U ADC << this is the unit \n");
473 else sprintf (buffer,
"#U fC << this is the unit \n");
476 sprintf (buffer,
"# %15s %15s %15s %15s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
477 "eta",
"phi",
"dep",
"det",
478 "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",
482 std::sort (channels.begin(), channels.end(),
DetIdLess ());
483 for (std::vector<DetId>::iterator channel = channels.begin ();
484 channel != channels.end ();
488 dumpId (fOutput, *channel);
489 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",
504 while (fInput.getline(buffer, 1024)) {
505 if (buffer [0] ==
'#')
continue;
507 if (items.empty())
continue;
508 if (items [0] ==
"SHAPE") {
509 if (items.size () < 33) {
510 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;
519 if (items.size () < 36) {
520 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;
532 for (
unsigned capid = 0; capid < 4; capid++) {
533 for (
unsigned range = 0; range < 4; range++) {
534 coder.
setOffset (capid, range, atof (items [index++].c_str ()));
537 for (
unsigned capid = 0; capid < 4; capid++) {
538 for (
unsigned range = 0; range < 4; range++) {
539 coder.
setSlope (capid, range, atof (items [index++].c_str ()));
552 fOutput <<
"# QIE basic shape: SHAPE 32 x low edge values for first 32 channels" << std::endl;
553 sprintf (buffer,
"SHAPE ");
555 for (
unsigned bin = 0;
bin < 32;
bin++) {
559 fOutput << std::endl;
561 fOutput <<
"# QIE data" << std::endl;
562 sprintf (buffer,
"# %15s %15s %15s %15s %36s %36s %36s %36s %36s %36s %36s %36s\n",
563 "eta",
"phi",
"dep",
"det",
564 "4 x offsets cap0",
"4 x offsets cap1",
"4 x offsets cap2",
"4 x offsets cap3",
565 "4 x slopes cap0",
"4 x slopes cap1",
"4 x slopes cap2",
"4 x slopes cap3");
568 std::sort (channels.begin(), channels.end(),
DetIdLess ());
569 for (std::vector<DetId>::iterator channel = channels.begin ();
570 channel != channels.end ();
573 dumpId (fOutput, *channel);
574 for (
unsigned capid = 0; capid < 4; capid++) {
575 for (
unsigned range = 0; range < 4; range++) {
576 sprintf (buffer,
" %8.5f", coder->
offset (capid, range));
580 for (
unsigned capid = 0; capid < 4; capid++) {
581 for (
unsigned range = 0; range < 4; range++) {
582 sprintf (buffer,
" %8.5f", coder->
slope (capid, range));
586 fOutput << std::endl;
594 while (fInput.getline(buffer, 1024)) {
595 if (buffer [0] ==
'#')
continue;
597 if (items.size () < 36) {
598 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 36 items: eta, phi, depth, subdet, 32 bin values" << std::endl;
611 for (
unsigned bin = 0;
bin < 32;
bin++) {
612 values[
bin] = atof (items [index++].c_str ());
624 fOutput <<
"# QIE data in calibration mode" << std::endl;
625 sprintf (buffer,
"# %15s %15s %15s %15s %288s\n",
626 "eta",
"phi",
"dep",
"det",
"32 x charges");
629 std::sort (channels.begin(), channels.end(),
DetIdLess ());
630 for (std::vector<DetId>::iterator channel = channels.begin ();
631 channel != channels.end ();
635 dumpId (fOutput, *channel);
637 for (
unsigned bin = 0;
bin < 32;
bin++) {
638 sprintf (buffer,
" %8.5f", lowEdge [
bin]);
641 fOutput << std::endl;
651 while (fInput.getline(buffer, 1024)) {
652 if (buffer [0] ==
'#')
continue;
654 if (items.size () < 12) {
655 if (items.empty())
continue;
656 if (items.size()<9) {
660 if (items[8]==
"NA" || items[8]==
"NT") {
661 while (items.size()<12) items.push_back(
"");
662 }
else if (items[8]==
"HT") {
663 if (items.size()==11) items.push_back(
"");
665 edm::LogError(
"MapFormat") <<
"CastorElectronicsMap-> Bad line: " << buffer
666 <<
"\n HT line must contain at least 11 items: i cr sl tb dcc spigot fiber fiberchan subdet=HT ieta iphi";
670 edm::LogError(
"MapFormat") <<
"CastorElectronicsMap-> Bad line: " << buffer
671 <<
"\n line must contain 12 items: i cr sl tb dcc spigot fiber fiberchan subdet ieta iphi depth";
676 int crate = atoi (items [1].c_str());
677 int slot = atoi (items [2].c_str());
679 if (items [3] ==
"b") top = 0;
680 int dcc = atoi (items [4].c_str());
681 int spigot = atoi (items [5].c_str());
683 if (items[8] ==
"HT" || items[8] ==
"NT") {
684 int slb = atoi (items [6].c_str());
685 int slbCh = atoi (items [7].c_str());
688 int fiber = atoi (items [6].c_str());
689 int fiberCh = atoi (items [7].c_str());
692 elId.
setHTR (crate, slot, top);
696 if (items [8] ==
"NA") {
698 }
else if (items [8] ==
"NT") {
706 edm::LogWarning(
"Format Error") <<
"CastorElectronicsMap-> Unknown subdetector: " 707 << items [8] <<
'/' << items [9] <<
'/' << items [10] <<
'/' << items [11] << std::endl;
720 sprintf (buf,
"# %7s %3s %3s %3s %4s %7s %10s %14s %7s %5s %5s %6s",
721 "i",
"cr",
"sl",
"tb",
"dcc",
"spigot",
"fiber/slb",
"fibcha/slbcha",
"subdet",
"ieta",
"iphi",
"depth");
722 fOutput << buf << std::endl;
724 for (
unsigned i = 0;
i < eids.size ();
i++) {
728 if (trigger.
rawId ()) {
732 sprintf (buf,
" %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
740 fOutput << buf << std::endl;
744 if (channel.
rawId()) {
748 sprintf (buf,
" %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
754 fOutput << buf << std::endl;
763 while (fInput.getline(buffer, 1024)) {
764 if (buffer [0] ==
'#')
continue;
766 if (items.empty())
continue;
767 if (items.size () < 6) {
768 edm::LogWarning(
"Format Error") <<
"Bad line: " << buffer <<
"\n line must contain 6 items: eta, phi, depth, subdet, firstSample, samplesToAdd" << std::endl;
773 CastorRecoParam fCondObject(
id, atoi (items [4].c_str()), atoi (items [5].c_str()) );
781 sprintf (buffer,
"# %15s %15s %15s %15s %18s %15s %10s\n",
"eta",
"phi",
"dep",
"det",
"firstSample",
"samplesToAdd",
"DetId");
784 std::sort (channels.begin(), channels.end(),
DetIdLess ());
785 for (std::vector<DetId>::iterator channel = channels.begin();channel != channels.end();++channel) {
786 dumpId (fOutput, *channel);
787 sprintf (buffer,
" %15d %15d %16X\n",
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
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)