CMS 3D CMS Logo

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

#include <EcalIntercalibHandler.h>

Inheritance diagram for popcon::EcalIntercalibHandler:
popcon::PopConSourceHandler< EcalIntercalibConstants >

Public Member Functions

 EcalIntercalibHandler (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)
 
 ~EcalIntercalibHandler () override
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalIntercalibConstants >
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 EcalIntercalibConstantsmyintercalib
 

Additional Inherited Members

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

Detailed Description

Definition at line 53 of file EcalIntercalibHandler.h.

Constructor & Destructor Documentation

popcon::EcalIntercalibHandler::EcalIntercalibHandler ( edm::ParameterSet const &  )

Definition at line 10 of file EcalIntercalibHandler.cc.

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

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

Definition at line 19 of file EcalIntercalibHandler.cc.

19 {}

Member Function Documentation

void popcon::EcalIntercalibHandler::getNewObjects ( )
overridevirtual

Implements popcon::PopConSourceHandler< EcalIntercalibConstants >.

Definition at line 21 of file EcalIntercalibHandler.cc.

References m_file_name, m_file_type, m_firstRun, jets_cff::payload, readTXT(), readXML(), and AlCaHLTBitMon_QueryRunRegistry::string.

21  {
22  // std::cout << "------- Ecal - > getNewObjects\n";
23  std::ostringstream ss;
24  ss<<"ECAL ";
25 
26  unsigned long long irun;
27  std::string file_= m_file_name;
28  edm::LogInfo("going to open file ") << file_;
29 
30  // EcalCondHeader header;
32  if(m_file_type == "xml")
33  readXML(file_, *payload);
34  else
35  readTXT(file_, *payload);
36  irun = m_firstRun;
37  Time_t snc= (Time_t) irun ;
38 
39  popcon::PopConSourceHandler<EcalIntercalibConstants>::m_to_transfer.push_back(std::make_pair(payload, snc));
40 }
void readTXT(const std::string &filename, EcalFloatCondObjectContainer &record)
void readXML(const std::string &filename, EcalFloatCondObjectContainer &record)
EcalIntercalibConstantMap EcalIntercalibConstants
std::string popcon::EcalIntercalibHandler::id ( ) const
inlineoverridevirtual
void popcon::EcalIntercalibHandler::readTXT ( const std::string &  filename,
EcalFloatCondObjectContainer record 
)

Definition at line 99 of file EcalIntercalibHandler.cc.

References PVValHelper::eta, EBDetId::ETAPHIMODE, cmsRelvalreport::exit, kChannels, kEBChannels, kEEChannels, geometryCSVtoXML::line, AlCaHLTBitMon_QueryRunRegistry::string, heppy_batch::val, and EEDetId::XYMODE.

Referenced by getNewObjects().

100  {
101  std::ifstream ftxt;
102  ftxt.open(file_);
103  if(!ftxt.is_open()) {
104  edm::LogInfo("ERROR : cannot open file ") << file_;
105  exit (1);
106  }
107  int number_of_lines = 0, eta, phi, x, y, z;
108  float val;
110  while (std::getline(ftxt, line)) {
111  if(number_of_lines < kEBChannels) { // barrel
112  sscanf(line.c_str(), "%i %i %i %f", &eta, &phi, &z, &val);
113  EBDetId ebdetid(eta, phi, EBDetId::ETAPHIMODE);
114  record[ebdetid] = val;
115  }
116  else { // endcaps
117  sscanf(line.c_str(), "%i %i %i %f", &x, &y, &z, &val);
118  EEDetId eedetid(x, y, z, EEDetId::XYMODE);
119  record[eedetid] = val;
120  }
121  number_of_lines++;
122  }
123  edm::LogInfo("Number of lines in text file: ") << number_of_lines;
125  if(number_of_lines != kChannels)
126  edm::LogInfo("wrong number of channels! Please check ");
127 }
static const int XYMODE
Definition: EEDetId.h:339
float float float z
const Int_t kEEChannels
static const int ETAPHIMODE
Definition: EBDetId.h:166
const Int_t kEBChannels
const Int_t kChannels
void popcon::EcalIntercalibHandler::readXML ( const std::string &  filename,
EcalFloatCondObjectContainer record 
)

Definition at line 42 of file EcalIntercalibHandler.cc.

References cmsRelvalreport::exit, runEdmFileComparison::found, mps_fire::i, kEBChannels, kEEChannels, AlCaHLTBitMon_QueryRunRegistry::string, EBDetId::unhashIndex(), EEDetId::unhashIndex(), and heppy_batch::val.

Referenced by getNewObjects().

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

Member Data Documentation

EcalCondDBInterface* popcon::EcalIntercalibHandler::econn

Definition at line 63 of file EcalIntercalibHandler.h.

std::string popcon::EcalIntercalibHandler::m_file_name
private

Definition at line 69 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler(), and getNewObjects().

std::string popcon::EcalIntercalibHandler::m_file_type
private

Definition at line 70 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler(), and getNewObjects().

unsigned int popcon::EcalIntercalibHandler::m_firstRun
private

Definition at line 68 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler(), and getNewObjects().

std::string popcon::EcalIntercalibHandler::m_name
private

Definition at line 67 of file EcalIntercalibHandler.h.

const EcalIntercalibConstants* popcon::EcalIntercalibHandler::myintercalib
private

Definition at line 66 of file EcalIntercalibHandler.h.