CMS 3D CMS Logo

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

#include <EcalADCToGeVHandler.h>

Inheritance diagram for popcon::EcalADCToGeVHandler:
popcon::PopConSourceHandler< EcalADCToGeVConstant >

Public Member Functions

 EcalADCToGeVHandler (edm::ParameterSet const &)
 
void getNewObjects () override
 
std::string id () const override
 
 ~EcalADCToGeVHandler () override
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalADCToGeVConstant >
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_highfield
 
std::string m_file_lowfield
 
unsigned int m_firstRun
 
std::string m_gentag
 
unsigned int m_lastRun
 
std::string m_location
 
std::string m_locationsource
 
std::string m_name
 
std::string m_pass
 
std::string m_sid
 
std::string m_user
 
const EcalADCToGeVConstantmyintercalib
 

Additional Inherited Members

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

Detailed Description

Definition at line 48 of file EcalADCToGeVHandler.h.

Constructor & Destructor Documentation

◆ EcalADCToGeVHandler()

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

Definition at line 8 of file EcalADCToGeVHandler.cc.

9  : m_name(ps.getUntrackedParameter<std::string>("name", "EcalADCToGeVHandler")) {
10  std::cout << "EcalADCToGeV Source handler constructor\n" << std::endl;
11  m_firstRun = static_cast<unsigned int>(atoi(ps.getParameter<std::string>("firstRun").c_str()));
12  m_lastRun = static_cast<unsigned int>(atoi(ps.getParameter<std::string>("lastRun").c_str()));
13  m_sid = ps.getParameter<std::string>("OnlineDBSID");
14  m_user = ps.getParameter<std::string>("OnlineDBUser");
15  m_pass = ps.getParameter<std::string>("OnlineDBPassword");
16  m_locationsource = ps.getParameter<std::string>("LocationSource");
17  m_location = ps.getParameter<std::string>("Location");
18  m_gentag = ps.getParameter<std::string>("GenTag");
19  m_file_lowfield = ps.getParameter<std::string>("FileLowField");
20  m_file_highfield = ps.getParameter<std::string>("FileHighField");
21 
22  std::cout << m_sid << "/" << m_user << "/" << m_location << "/" << m_gentag << std::endl;
23 }

References gather_cfg::cout, edm::ParameterSet::getParameter(), m_file_highfield, m_file_lowfield, m_firstRun, m_gentag, m_lastRun, m_location, m_locationsource, m_pass, m_sid, m_user, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~EcalADCToGeVHandler()

popcon::EcalADCToGeVHandler::~EcalADCToGeVHandler ( )
override

Definition at line 25 of file EcalADCToGeVHandler.cc.

25 {}

Member Function Documentation

◆ getNewObjects()

void popcon::EcalADCToGeVHandler::getNewObjects ( )
overridevirtual

Implements popcon::PopConSourceHandler< EcalADCToGeVConstant >.

Definition at line 27 of file EcalADCToGeVHandler.cc.

27  {
28  std::cout << "------- Ecal - > getNewObjects\n";
29 
30  std::ostringstream ss;
31  ss << "ECAL ";
32 
33  unsigned int max_since = 0;
34  max_since = static_cast<unsigned int>(tagInfo().lastInterval.since);
35  std::cout << "max_since : " << max_since << std::endl;
36  bool magnet_high = false;
37  bool something_to_transfer = false;
38  if (tagInfo().size) {
39  Ref ped_db = lastPayload();
40 
41  // we parse the last record in the DB and check if it is low or high field
42 
43  std::cout << "retrieved last payload " << std::endl;
44 
45  EcalADCToGeVConstant the_cal;
46 
47  //unused float adc_eb=ped_db->getEBValue();
48  float adc_ee = ped_db->getEEValue();
49 
50  // float the_value_high_eb=0.03894;
51  // float the_value_high_ee=0.06285;
52  // float the_value_high_eb=0.03894;
53  // float the_value_high_ee=0.06378;
54 
55  // bool magnet_high=true;
56  // if(adc_eb!= the_value_high_eb || adc_ee!= the_value_high_ee ) magnet_high=false;
57 
58  //unused float the_value_low_eb=0.03894;
59  // Run 1 : float the_value_low_ee=0.05678;
60  float the_value_low_ee = 0.0590975;
61  if (adc_ee > the_value_low_ee)
62  magnet_high = true;
63  } // check if there is already a payload
64  else
65  something_to_transfer = true;
66 
67  // here we connect to the online DB to check the value of the magnetic field
68  std::cout << "Connecting to ONLINE DB ... " << std::endl;
70  std::cout << "Connection done" << std::endl;
71 
72  std::cout << "Retrieving last run from ONLINE DB ... " << std::endl;
73  std::map<EcalLogicID, RunDat> rundat;
74  RunIOV rp;
75  run_t runmax = 10000000;
76  std::string location_p5 = "P5_Co";
77  econn->fetchValidDataSet(&rundat, &rp, location_p5, runmax);
78 
79  unsigned long long irun = (unsigned long long)rp.getRunNumber();
80 
81  std::cout << "retrieved run number " << irun << std::endl;
82 
83  if (irun > max_since) {
84  // retrieve from last value data record
85  // always call this method at first run
86 
87  std::map<EcalLogicID, RunDCSMagnetDat> dataset;
88 
89  econn->fetchDataSet(&dataset, &rp);
90 
91  if (dataset.empty()) {
92  throw(std::runtime_error("Zero rows read back"));
93  } else {
94  std::cout << "retrieved magnet current" << std::endl;
95  }
96 
97  float mag_cur = 0;
98 
99  std::map<EcalLogicID, RunDCSMagnetDat>::iterator it;
100  for (it = dataset.begin(); it != dataset.end(); ++it) {
101  RunDCSMagnetDat a_mag = (*it).second;
102  mag_cur = a_mag.getMagnetCurrent();
103  }
104 
106  if (tagInfo().size) {
107  if (mag_cur > 7000. && magnet_high) {
108  std::cout << " the magnet is ON and the constants are for magnet ON " << std::endl;
109 
110  } else if (mag_cur > 7000. && !magnet_high) {
111  something_to_transfer = true;
112  std::cout << " the magnet is ON and the constants are for magnet OFF " << std::endl;
113  std::cout << " I transfer the ON constants " << std::endl;
114  file_ = m_file_highfield;
115 
116  } else if (mag_cur < 6000. && magnet_high) {
117  something_to_transfer = true;
118  std::cout << " the magnet is OFF and the constants are for magnet ON " << std::endl;
119  std::cout << " I transfer the OFF constants " << std::endl;
120  file_ = m_file_lowfield;
121 
122  } else if (mag_cur < 6000. && !magnet_high) {
123  std::cout << " the magnet is OFF and the constants are for magnet OFF " << std::endl;
124  file_ = m_file_lowfield;
125 
126  } else {
127  std::cout << " the magnet is in a strange situation I do nothing ... just be patient " << std::endl;
128  }
129  } else {
130  if (mag_cur > 7000.)
131  std::cout << " first payload, the magnet is ON " << std::endl;
132  else if (mag_cur < 6000.) {
133  std::cout << " first payload, the magnet is OFF " << std::endl;
134  file_ = m_file_lowfield;
135  } else
136  std::cout << " the magnet is in a strange situation I do nothing ... just be patient " << std::endl;
137  }
138 
139  if (something_to_transfer) {
140  std::cout << "Generating popcon record for run " << irun << " going to open file " << file_ << "\n"
141  << std::flush;
143  // EcalCondHeader header; // DBv1
144  // EcalADCToGeVXMLTranslator::readXML(file_,header,*payload); // DBv1
145  // DBv2 poor xml file :-(
146  std::ifstream fxml;
147  fxml.open(file_.c_str());
148  std::string line, bid, bid2;
149  float val;
150  for (int il = 0; il < 4; il++) {
151  std::getline(fxml, line);
152  // std::cout << line << "\n";
153  }
154  for (int iPart = 0; iPart < 2; iPart++) { // EB, EE
155  fxml >> bid;
156  std::size_t begin = bid.find_first_of('>');
157  std::size_t end = bid.find_last_of('<');
158  begin++;
159  std::string str2 = bid.substr(begin, end - begin);
160  std::size_t endmantissa = str2.find('e');
161  std::string mantissa = str2.substr(0, endmantissa);
162  std::size_t string_size = str2.size();
163  std::string exponent = str2.substr(endmantissa + 1, string_size);
164  std::istringstream is(mantissa);
165  is >> val;
166  float mult;
167  std::istringstream ise(exponent);
168  ise >> mult;
169  val = val * pow(10, mult);
170  std::cout << " Partition " << iPart << " ADCToGeV " << val << "\n";
171  if (iPart < 1)
172  payload->setEBValue(val);
173  else
174  payload->setEEValue(val);
175  }
176  // end change for DBv2
177 
178  Time_t snc = (Time_t)irun;
180  ss << "Run=" << irun << "_Magnet_changed_" << std::endl;
181  m_userTextLog = ss.str() + ";";
182  } else {
183  std::cout << "Run " << irun << " nothing sent to the DB" << std::endl;
184  ss << "Run=" << irun << "_Magnet_NOT_changed_" << std::endl;
185  m_userTextLog = ss.str() + ";";
186  }
187 
188  delete econn;
189  } // irun > max_since
190  else {
191  std::cout << "Run " << irun << " nothing sent to the DB" << std::endl;
192  ss << "Run=" << irun << "_no_new_runs_" << std::endl;
193  m_userTextLog = ss.str() + ";";
194  }
195  std::cout << "Ecal - > end of getNewObjects -----------\n";
196 }

References gather_cfg::cout, writedatasetfile::dataset, test_db_connect::econn, mps_fire::end, HLT_FULL_cff::exponent, EcalADCToGeVConstant::getEEValue(), RunDCSMagnetDat::getMagnetCurrent(), RunIOV::getRunNumber(), mps_splice::line, VarParsing::mult, jets_cff::payload, funct::pow(), findQualityFiles::size, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, dumpRecoGeometry_cfg::tagInfo, and heppy_batch::val.

◆ id()

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

Implements popcon::PopConSourceHandler< EcalADCToGeVConstant >.

Definition at line 55 of file EcalADCToGeVHandler.h.

55 { return m_name; }

References m_name.

Member Data Documentation

◆ econn

EcalCondDBInterface* popcon::EcalADCToGeVHandler::econn

Definition at line 56 of file EcalADCToGeVHandler.h.

◆ m_file_highfield

std::string popcon::EcalADCToGeVHandler::m_file_highfield
private

Definition at line 72 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler().

◆ m_file_lowfield

std::string popcon::EcalADCToGeVHandler::m_file_lowfield
private

Definition at line 71 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler().

◆ m_firstRun

unsigned int popcon::EcalADCToGeVHandler::m_firstRun
private

Definition at line 61 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler().

◆ m_gentag

std::string popcon::EcalADCToGeVHandler::m_gentag
private

Definition at line 65 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler().

◆ m_lastRun

unsigned int popcon::EcalADCToGeVHandler::m_lastRun
private

Definition at line 62 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler().

◆ m_location

std::string popcon::EcalADCToGeVHandler::m_location
private

Definition at line 64 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler().

◆ m_locationsource

std::string popcon::EcalADCToGeVHandler::m_locationsource
private

Definition at line 69 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler().

◆ m_name

std::string popcon::EcalADCToGeVHandler::m_name
private

Definition at line 70 of file EcalADCToGeVHandler.h.

Referenced by id().

◆ m_pass

std::string popcon::EcalADCToGeVHandler::m_pass
private

Definition at line 68 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler().

◆ m_sid

std::string popcon::EcalADCToGeVHandler::m_sid
private

Definition at line 66 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler().

◆ m_user

std::string popcon::EcalADCToGeVHandler::m_user
private

Definition at line 67 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler().

◆ myintercalib

const EcalADCToGeVConstant* popcon::EcalADCToGeVHandler::myintercalib
private

Definition at line 59 of file EcalADCToGeVHandler.h.

EcalCondDBInterface
Definition: EcalCondDBInterface.h:37
popcon::EcalADCToGeVHandler::econn
EcalCondDBInterface * econn
Definition: EcalADCToGeVHandler.h:56
RunIOV
Definition: RunIOV.h:13
popcon::EcalADCToGeVHandler::m_sid
std::string m_sid
Definition: EcalADCToGeVHandler.h:66
run_t
int run_t
Definition: CaliIOV.h:11
popcon::EcalADCToGeVHandler::m_pass
std::string m_pass
Definition: EcalADCToGeVHandler.h:68
popcon::EcalADCToGeVHandler::m_location
std::string m_location
Definition: EcalADCToGeVHandler.h:64
gather_cfg.cout
cout
Definition: gather_cfg.py:144
popcon::PopConSourceHandler< EcalADCToGeVConstant >::Time_t
cond::Time_t Time_t
Definition: PopConSourceHandler.h:34
popcon::EcalADCToGeVHandler::m_gentag
std::string m_gentag
Definition: EcalADCToGeVHandler.h:65
EcalADCToGeVConstant
Definition: EcalADCToGeVConstant.h:13
popcon::EcalADCToGeVHandler::m_locationsource
std::string m_locationsource
Definition: EcalADCToGeVHandler.h:69
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
mps_fire.end
end
Definition: mps_fire.py:242
HLT_FULL_cff.exponent
exponent
Definition: HLT_FULL_cff.py:52788
jets_cff.payload
payload
Definition: jets_cff.py:32
RunIOV::getRunNumber
run_t getRunNumber() const
Definition: RunIOV.cc:31
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
popcon::EcalADCToGeVHandler::m_name
std::string m_name
Definition: EcalADCToGeVHandler.h:70
popcon::EcalADCToGeVHandler::m_lastRun
unsigned int m_lastRun
Definition: EcalADCToGeVHandler.h:62
EcalADCToGeVConstant::getEEValue
float getEEValue() const
Definition: EcalADCToGeVConstant.h:21
popcon::PopConSourceHandler< EcalADCToGeVConstant >::tagInfo
cond::TagInfo_t const & tagInfo() const
Definition: PopConSourceHandler.h:78
RunDCSMagnetDat
Definition: RunDCSMagnetDat.h:15
EcalCondDBInterface::fetchDataSet
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov) noexcept(false)
Definition: EcalCondDBInterface.h:495
popcon::PopConSourceHandler
Definition: PopConSourceHandler.h:30
popcon::EcalADCToGeVHandler::m_file_highfield
std::string m_file_highfield
Definition: EcalADCToGeVHandler.h:72
heppy_batch.val
val
Definition: heppy_batch.py:351
writedatasetfile.dataset
dataset
Definition: writedatasetfile.py:19
popcon::EcalADCToGeVHandler::m_firstRun
unsigned int m_firstRun
Definition: EcalADCToGeVHandler.h:61
popcon::EcalADCToGeVHandler::m_user
std::string m_user
Definition: EcalADCToGeVHandler.h:67
reco::JetExtendedAssociation::Ref
edm::Ref< Container > Ref
Definition: JetExtendedAssociation.h:32
popcon::EcalADCToGeVHandler::m_file_lowfield
std::string m_file_lowfield
Definition: EcalADCToGeVHandler.h:71
popcon::PopConSourceHandler< EcalADCToGeVConstant >::lastPayload
Ref lastPayload() const
Definition: PopConSourceHandler.h:81
EcalCondDBInterface::fetchValidDataSet
void fetchValidDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *fillIOV, RunTag *tag, run_t run=(unsigned int) -1) noexcept(false)
Definition: EcalCondDBInterface.h:545
VarParsing.mult
mult
Definition: VarParsing.py:659
dataset
Definition: dataset.py:1
RunDCSMagnetDat::getMagnetCurrent
float getMagnetCurrent() const
Definition: RunDCSMagnetDat.h:27
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
mps_splice.line
line
Definition: mps_splice.py:76
popcon::PopConSourceHandler< EcalADCToGeVConstant >::m_userTextLog
std::string m_userTextLog
Definition: PopConSourceHandler.h:168
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443