CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Attributes
popcon::EcalPFRecHitThresholdsHandler Class Reference

#include <EcalPFRecHitThresholdsHandler.h>

Inheritance diagram for popcon::EcalPFRecHitThresholdsHandler:
popcon::PopConSourceHandler< EcalPFRecHitThresholds >

Public Member Functions

 EcalPFRecHitThresholdsHandler (edm::ParameterSet const &)
 
void getNewObjects () override
 
std::string id () const override
 
void readTXT (const std::string &filename, EcalFloatCondObjectContainer &record)
 
void readXML (const std::string &filename, EcalFloatCondObjectContainer &record)
 
 ~EcalPFRecHitThresholdsHandler () override
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalPFRecHitThresholds >
void convertFromOld ()
 
SummarydummySummary (typename OldContainer::value_type const &) const
 
void initialize (const cond::persistency::Session &dbSession, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry_t const & logDBEntry () const
 
std::pair< Container const *, std::string const > operator() (const cond::persistency::Session &session, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry) const
 
 PopConSourceHandler ()
 
Container const & returnData ()
 
void sort ()
 
cond::TagInfo_t const & tagInfo () const
 
std::string const & userTextLog () const
 
virtual ~PopConSourceHandler ()
 

Public Attributes

EcalCondDBInterfaceeconn
 

Private Attributes

std::string m_file_name
 
std::string m_file_type
 
unsigned int m_firstRun
 
std::string m_name
 
const EcalPFRecHitThresholdsmyPFRecHitThresholds
 

Additional Inherited Members

- Public Types inherited from popcon::PopConSourceHandler< EcalPFRecHitThresholds >
typedef std::vector< Triplet > Container
 
typedef std::vector< std::pair< EcalPFRecHitThresholds *, cond::Time_t > > OldContainer
 
typedef PopConSourceHandler< EcalPFRecHitThresholdsself
 
typedef cond::Summary Summary
 
typedef cond::Time_t Time_t
 
typedef EcalPFRecHitThresholds value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< EcalPFRecHitThresholds >
int add (value_type *payload, Summary *summary, Time_t time)
 
cond::persistency::SessiondbSession () const
 
- Protected Attributes inherited from popcon::PopConSourceHandler< EcalPFRecHitThresholds >
OldContainer m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 46 of file EcalPFRecHitThresholdsHandler.h.

Constructor & Destructor Documentation

◆ EcalPFRecHitThresholdsHandler()

popcon::EcalPFRecHitThresholdsHandler::EcalPFRecHitThresholdsHandler ( edm::ParameterSet const &  ps)

Definition at line 10 of file EcalPFRecHitThresholdsHandler.cc.

11  : m_name(ps.getUntrackedParameter<std::string>("name", "EcalPFRecHitThresholdsHandler")) {
12  edm::LogInfo("EcalPFRecHitThresholds Source handler constructor\n");
13  m_firstRun = static_cast<unsigned int>(atoi(ps.getParameter<std::string>("firstRun").c_str()));
14  m_file_type = ps.getParameter<std::string>("type"); // xml/txt
15  m_file_name = ps.getParameter<std::string>("fileName");
16 }

References edm::ParameterSet::getParameter(), m_file_name, m_file_type, m_firstRun, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~EcalPFRecHitThresholdsHandler()

popcon::EcalPFRecHitThresholdsHandler::~EcalPFRecHitThresholdsHandler ( )
override

Definition at line 18 of file EcalPFRecHitThresholdsHandler.cc.

18 {}

Member Function Documentation

◆ getNewObjects()

void popcon::EcalPFRecHitThresholdsHandler::getNewObjects ( )
overridevirtual

Implements popcon::PopConSourceHandler< EcalPFRecHitThresholds >.

Definition at line 20 of file EcalPFRecHitThresholdsHandler.cc.

20  {
21  // std::cout << "------- Ecal - > getNewObjects\n";
22  std::ostringstream ss;
23  ss << "ECAL ";
24 
25  unsigned long long irun;
26  std::string file_ = m_file_name;
27  edm::LogInfo("going to open file ") << file_;
28 
29  // EcalCondHeader header;
31  if (m_file_type == "xml")
32  readXML(file_, *payload);
33  else
34  readTXT(file_, *payload);
35  irun = m_firstRun;
36  Time_t snc = (Time_t)irun;
37 
39 }

References jets_cff::payload, contentValuesCheck::ss, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ id()

std::string popcon::EcalPFRecHitThresholdsHandler::id ( ) const
inlineoverridevirtual

Implements popcon::PopConSourceHandler< EcalPFRecHitThresholds >.

Definition at line 55 of file EcalPFRecHitThresholdsHandler.h.

55 { return m_name; }

References m_name.

◆ readTXT()

void popcon::EcalPFRecHitThresholdsHandler::readTXT ( const std::string &  filename,
EcalFloatCondObjectContainer record 
)

Definition at line 97 of file EcalPFRecHitThresholdsHandler.cc.

97  {
98  std::ifstream ftxt;
99  ftxt.open(file_);
100  if (!ftxt.is_open()) {
101  edm::LogInfo("ERROR : cannot open file ") << file_;
102  exit(1);
103  }
104  int number_of_lines = 0, eta, phi, x, y, z;
105  float val;
107  while (std::getline(ftxt, line)) {
108  if (number_of_lines < kEBChannels) { // barrel
109  sscanf(line.c_str(), "%i %i %i %f", &eta, &phi, &z, &val);
110  EBDetId ebdetid(eta, phi, EBDetId::ETAPHIMODE);
111  record[ebdetid] = val;
112  } else { // endcaps
113  sscanf(line.c_str(), "%i %i %i %f", &x, &y, &z, &val);
114  EEDetId eedetid(x, y, z, EEDetId::XYMODE);
115  record[eedetid] = val;
116  }
117  number_of_lines++;
118  }
119  edm::LogInfo("Number of lines in text file: ") << number_of_lines;
121  if (number_of_lines != kChannels)
122  edm::LogInfo("wrong number of channels! Please check ");
123 }

References PVValHelper::eta, EBDetId::ETAPHIMODE, beamvalidation::exit(), kChannels, kEBChannels, kEEChannels, mps_splice::line, phi, AlCaHarvesting_cff::record, AlCaHLTBitMon_QueryRunRegistry::string, heppy_batch::val, x, EEDetId::XYMODE, y, and z.

◆ readXML()

void popcon::EcalPFRecHitThresholdsHandler::readXML ( const std::string &  filename,
EcalFloatCondObjectContainer record 
)

Definition at line 41 of file EcalPFRecHitThresholdsHandler.cc.

41  {
42  std::string dummyLine, bid;
43  std::ifstream fxml;
44  fxml.open(file_);
45  if (!fxml.is_open()) {
46  edm::LogInfo("ERROR : cannot open file ") << file_;
47  exit(1);
48  }
49  // header
50  for (int i = 0; i < 6; i++) {
51  getline(fxml, dummyLine); // skip first lines
52  // std::cout << dummyLine << std::endl;
53  }
54  fxml >> bid;
55  std::string stt = bid.substr(7, 5);
56  std::istringstream iEB(stt);
57  int nEB;
58  iEB >> nEB;
59  if (nEB != kEBChannels) {
60  edm::LogInfo("strange number of EB channels ") << nEB;
61  exit(-1);
62  }
63  fxml >> bid; // <item_version>0</item_version>
64  for (int iChannel = 0; iChannel < kEBChannels; iChannel++) {
65  EBDetId myEBDetId = EBDetId::unhashIndex(iChannel);
66  fxml >> bid;
67  std::size_t found = bid.find("</");
68  stt = bid.substr(6, found - 6);
69  float val = std::stof(stt);
70  record[myEBDetId] = val;
71  }
72  for (int i = 0; i < 5; i++) {
73  getline(fxml, dummyLine); // skip first lines
74  // std::cout << dummyLine << std::endl;
75  }
76  fxml >> bid;
77  stt = bid.substr(7, 5);
78  std::istringstream iEE(stt);
79  int nEE;
80  iEE >> nEE;
81  if (nEE != kEEChannels) {
82  edm::LogInfo("strange number of EE channels ") << nEE;
83  exit(-1);
84  }
85  fxml >> bid; // <item_version>0</item_version>
86  // now endcaps
87  for (int iChannel = 0; iChannel < kEEChannels; iChannel++) {
88  EEDetId myEEDetId = EEDetId::unhashIndex(iChannel);
89  fxml >> bid;
90  std::size_t found = bid.find("</");
91  stt = bid.substr(6, found - 6);
92  float val = std::stof(stt);
93  record[myEEDetId] = val;
94  }
95 }

References beamvalidation::exit(), newFWLiteAna::found, mps_fire::i, kEBChannels, kEEChannels, AlCaHarvesting_cff::record, AlCaHLTBitMon_QueryRunRegistry::string, EBDetId::unhashIndex(), EEDetId::unhashIndex(), and heppy_batch::val.

Member Data Documentation

◆ econn

EcalCondDBInterface* popcon::EcalPFRecHitThresholdsHandler::econn

Definition at line 56 of file EcalPFRecHitThresholdsHandler.h.

◆ m_file_name

std::string popcon::EcalPFRecHitThresholdsHandler::m_file_name
private

Definition at line 62 of file EcalPFRecHitThresholdsHandler.h.

Referenced by EcalPFRecHitThresholdsHandler().

◆ m_file_type

std::string popcon::EcalPFRecHitThresholdsHandler::m_file_type
private

Definition at line 63 of file EcalPFRecHitThresholdsHandler.h.

Referenced by EcalPFRecHitThresholdsHandler().

◆ m_firstRun

unsigned int popcon::EcalPFRecHitThresholdsHandler::m_firstRun
private

Definition at line 61 of file EcalPFRecHitThresholdsHandler.h.

Referenced by EcalPFRecHitThresholdsHandler().

◆ m_name

std::string popcon::EcalPFRecHitThresholdsHandler::m_name
private

Definition at line 60 of file EcalPFRecHitThresholdsHandler.h.

Referenced by id().

◆ myPFRecHitThresholds

const EcalPFRecHitThresholds* popcon::EcalPFRecHitThresholdsHandler::myPFRecHitThresholds
private

Definition at line 59 of file EcalPFRecHitThresholdsHandler.h.

DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:428
popcon::EcalPFRecHitThresholdsHandler::readTXT
void readTXT(const std::string &filename, EcalFloatCondObjectContainer &record)
Definition: EcalPFRecHitThresholdsHandler.cc:97
EBDetId
Definition: EBDetId.h:17
EEDetId::unhashIndex
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
EBDetId::unhashIndex
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
popcon::PopConSourceHandler< EcalPFRecHitThresholds >::Time_t
cond::Time_t Time_t
Definition: PopConSourceHandler.h:34
popcon::EcalPFRecHitThresholdsHandler::readXML
void readXML(const std::string &filename, EcalFloatCondObjectContainer &record)
Definition: EcalPFRecHitThresholdsHandler.cc:41
EcalPFRecHitThresholds
EcalPFRecHitThresholdsMap EcalPFRecHitThresholds
Definition: EcalPFRecHitThresholds.h:12
DDAxes::x
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
popcon::EcalPFRecHitThresholdsHandler::m_file_name
std::string m_file_name
Definition: EcalPFRecHitThresholdsHandler.h:62
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
PVValHelper::eta
Definition: PVValidationHelpers.h:70
DDAxes::z
popcon::EcalPFRecHitThresholdsHandler::m_file_type
std::string m_file_type
Definition: EcalPFRecHitThresholdsHandler.h:63
jets_cff.payload
payload
Definition: jets_cff.py:32
EEDetId
Definition: EEDetId.h:14
EBDetId::ETAPHIMODE
static const int ETAPHIMODE
Definition: EBDetId.h:158
AlCaHarvesting_cff.record
record
Definition: AlCaHarvesting_cff.py:42
popcon::PopConSourceHandler
Definition: PopConSourceHandler.h:30
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDAxes::phi
kEEChannels
const Int_t kEEChannels
Definition: EcalPFRecHitThresholdsHandler.cc:8
heppy_batch.val
val
Definition: heppy_batch.py:351
EEDetId::XYMODE
static const int XYMODE
Definition: EEDetId.h:335
kChannels
const Int_t kChannels
Definition: EcalPedestalsHandler.cc:13
popcon::EcalPFRecHitThresholdsHandler::m_firstRun
unsigned int m_firstRun
Definition: EcalPFRecHitThresholdsHandler.h:61
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:52
mps_splice.line
line
Definition: mps_splice.py:76
popcon::EcalPFRecHitThresholdsHandler::m_name
std::string m_name
Definition: EcalPFRecHitThresholdsHandler.h:60
kEBChannels
const Int_t kEBChannels
Definition: EcalPFRecHitThresholdsHandler.cc:8