CMS 3D CMS Logo

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

#include <EcalTimeCalibHandler.h>

Inheritance diagram for popcon::EcalTimeCalibHandler:
popcon::PopConSourceHandler< EcalTimeCalibConstants >

Public Member Functions

 EcalTimeCalibHandler (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)
 
 ~EcalTimeCalibHandler () override=default
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalTimeCalibConstants >
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 ()
 
cond::TagInfo_t const & tagInfo () const
 
std::string const & userTextLog () const
 
virtual ~PopConSourceHandler ()
 

Public Attributes

EcalCondDBInterfaceeconn
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from popcon::PopConSourceHandler< EcalTimeCalibConstants >
typedef std::map< Time_t, std::shared_ptr< EcalTimeCalibConstants > > Container
 
typedef std::unique_ptr< EcalTimeCalibConstantsRef
 
typedef PopConSourceHandler< EcalTimeCalibConstantsself
 
typedef cond::Time_t Time_t
 
typedef EcalTimeCalibConstants value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< EcalTimeCalibConstants >
cond::persistency::SessiondbSession () const
 
- Protected Attributes inherited from popcon::PopConSourceHandler< EcalTimeCalibConstants >
Container m_iovs
 
std::vector< std::pair< EcalTimeCalibConstants *, Time_t > > m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 18 of file EcalTimeCalibHandler.h.

Constructor & Destructor Documentation

◆ EcalTimeCalibHandler()

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

Definition at line 13 of file EcalTimeCalibHandler.cc.

14  : m_name(ps.getUntrackedParameter<std::string>("name", "EcalTimeCalibHandler")),
15  m_firstRun(static_cast<unsigned int>(atoi(ps.getParameter<std::string>("firstRun").c_str()))),
16  m_file_name(ps.getParameter<std::string>("fileName")),
17  m_file_type(ps.getParameter<std::string>("type")) // xml/txt
18 {
19  edm::LogInfo("EcalTimeCalib Source handler constructor\n");
20 }
Log< level::Info, false > LogInfo

◆ ~EcalTimeCalibHandler()

popcon::EcalTimeCalibHandler::~EcalTimeCalibHandler ( )
overridedefault

Member Function Documentation

◆ getNewObjects()

void popcon::EcalTimeCalibHandler::getNewObjects ( )
overridevirtual

Implements popcon::PopConSourceHandler< EcalTimeCalibConstants >.

Definition at line 22 of file EcalTimeCalibHandler.cc.

References jetsAK4_Puppi_cff::payload.

22  {
23  edm::LogInfo("going to open file ") << m_file_name;
24 
25  // EcalCondHeader header;
27  if (m_file_type == "xml")
29  else
31  Time_t snc = (Time_t)m_firstRun;
32 
34 }
void readTXT(const std::string &filename, EcalFloatCondObjectContainer &record)
Log< level::Info, false > LogInfo
EcalTimeCalibConstantMap EcalTimeCalibConstants
void readXML(const std::string &filename, EcalFloatCondObjectContainer &record)

◆ id()

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

Implements popcon::PopConSourceHandler< EcalTimeCalibConstants >.

Definition at line 27 of file EcalTimeCalibHandler.h.

References m_name.

27 { return m_name; }

◆ readTXT()

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

Definition at line 87 of file EcalTimeCalibHandler.cc.

References PVValHelper::eta, EBDetId::ETAPHIMODE, Exception, kChannels, kEBChannels, kEEChannels, mps_splice::line, phi, Hcal_FrontierConditions_cff::record, AlCaHLTBitMon_QueryRunRegistry::string, heppy_batch::val, x, EEDetId::XYMODE, y, and z.

87  {
88  std::ifstream ftxt;
89  ftxt.open(file_);
90  if (!ftxt.is_open()) {
91  throw cms::Exception("ERROR : cannot open file ") << file_;
92  }
93  int number_of_lines = 0, eta, phi, x, y, z;
94  float val;
96  while (std::getline(ftxt, line)) {
97  if (number_of_lines < kEBChannels) { // barrel
98  std::sscanf(line.c_str(), "%i %i %i %f", &eta, &phi, &z, &val);
99  EBDetId ebdetid(eta, phi, EBDetId::ETAPHIMODE);
100  record[ebdetid] = val;
101  } else { // endcaps
102  std::sscanf(line.c_str(), "%i %i %i %f", &x, &y, &z, &val);
103  EEDetId eedetid(x, y, z, EEDetId::XYMODE);
104  record[eedetid] = val;
105  }
106  number_of_lines++;
107  }
108  edm::LogInfo("Number of lines in text file: ") << number_of_lines;
110  if (number_of_lines != kChannels)
111  throw cms::Exception("Wrong number of channels! Please check ");
112 }
static const int XYMODE
Definition: EEDetId.h:333
static const int ETAPHIMODE
Definition: EBDetId.h:158
Log< level::Info, false > LogInfo
const Int_t kEEChannels
float x
const Int_t kEBChannels
const Int_t kChannels

◆ readXML()

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

Definition at line 36 of file EcalTimeCalibHandler.cc.

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

36  {
37  std::string dummyLine, bid;
38  std::ifstream fxml;
39  fxml.open(file_);
40  if (!fxml.is_open()) {
41  throw cms::Exception("ERROR : cannot open file ") << file_;
42  }
43  // header
44  for (int i = 0; i < 6; i++) {
45  getline(fxml, dummyLine); // skip first lines
46  }
47  fxml >> bid;
48  std::string stt = bid.substr(7, 5);
49  std::istringstream iEB(stt);
50  int nEB;
51  iEB >> nEB;
52  if (nEB != kEBChannels) {
53  throw cms::Exception("Strange number of EB channels ") << nEB;
54  }
55  fxml >> bid; // <item_version>0</item_version>
56  for (int iChannel = 0; iChannel < kEBChannels; iChannel++) {
57  EBDetId myEBDetId = EBDetId::unhashIndex(iChannel);
58  fxml >> bid;
59  std::size_t found = bid.find("</");
60  stt = bid.substr(6, found - 6);
61  float val = std::stof(stt);
62  record[myEBDetId] = val;
63  }
64  for (int i = 0; i < 5; i++) {
65  getline(fxml, dummyLine); // skip first lines
66  }
67  fxml >> bid;
68  stt = bid.substr(7, 5);
69  std::istringstream iEE(stt);
70  int nEE;
71  iEE >> nEE;
72  if (nEE != kEEChannels) {
73  throw cms::Exception("Strange number of EE channels ") << nEE;
74  }
75  fxml >> bid; // <item_version>0</item_version>
76  // now endcaps
77  for (int iChannel = 0; iChannel < kEEChannels; iChannel++) {
78  EEDetId myEEDetId = EEDetId::unhashIndex(iChannel);
79  fxml >> bid;
80  std::size_t found = bid.find("</");
81  stt = bid.substr(6, found - 6);
82  float val = std::stof(stt);
83  record[myEEDetId] = val;
84  }
85 }
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
const Int_t kEEChannels
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
const Int_t kEBChannels

Member Data Documentation

◆ econn

EcalCondDBInterface* popcon::EcalTimeCalibHandler::econn

Definition at line 28 of file EcalTimeCalibHandler.h.

◆ m_file_name

const std::string popcon::EcalTimeCalibHandler::m_file_name
private

Definition at line 33 of file EcalTimeCalibHandler.h.

◆ m_file_type

const std::string popcon::EcalTimeCalibHandler::m_file_type
private

Definition at line 34 of file EcalTimeCalibHandler.h.

◆ m_firstRun

const unsigned int popcon::EcalTimeCalibHandler::m_firstRun
private

Definition at line 32 of file EcalTimeCalibHandler.h.

◆ m_name

const std::string popcon::EcalTimeCalibHandler::m_name
private

Definition at line 31 of file EcalTimeCalibHandler.h.

Referenced by id().