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 ()
 
std::string id () const
 
 ~EcalADCToGeVHandler ()
 
- 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 56 of file EcalADCToGeVHandler.h.

Constructor & Destructor Documentation

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

Definition at line 9 of file EcalADCToGeVHandler.cc.

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.

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

Definition at line 30 of file EcalADCToGeVHandler.cc.

31 {
32 }

Member Function Documentation

void popcon::EcalADCToGeVHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalADCToGeVConstant >.

Definition at line 35 of file EcalADCToGeVHandler.cc.

References gather_cfg::cout, createfilelist::dataset, econn, Exception, EcalCondDBInterface::fetchDataSet(), EcalCondDBInterface::fetchValidDataSet(), EcalADCToGeVConstant::getEEValue(), RunDCSMagnetDat::getMagnetCurrent(), RunIOV::getRunNumber(), RecoTauValidation_cfi::header, cond::TagInfo_t::lastInterval, popcon::PopConSourceHandler< EcalADCToGeVConstant >::lastPayload(), m_file_highfield, m_file_lowfield, m_pass, m_sid, m_user, popcon::PopConSourceHandler< EcalADCToGeVConstant >::m_userTextLog, jetCorrFactors_cfi::payload, EcalADCToGeVXMLTranslator::readXML(), lumiCalc2::runmax, cond::TagInfo_t::size, findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, and popcon::PopConSourceHandler< EcalADCToGeVConstant >::tagInfo().

36 {
37 
38  std::cout << "------- Ecal - > getNewObjects\n";
39 
40  std::ostringstream ss;
41  ss<<"ECAL ";
42 
43  unsigned int max_since=0;
44  max_since=static_cast<unsigned int>(tagInfo().lastInterval.first);
45  std::cout << "max_since : " << max_since << std::endl;
46  bool magnet_high = false;
47  bool something_to_transfer = false;
48  if(tagInfo().size) {
49  Ref ped_db = lastPayload();
50 
51  // we parse the last record in the DB and check if it is low or high field
52 
53  std::cout << "retrieved last payload " << std::endl;
54 
55 
56  EcalADCToGeVConstant the_cal ;
57 
58  //unused float adc_eb=ped_db->getEBValue();
59  float adc_ee=ped_db->getEEValue();
60 
61  // float the_value_high_eb=0.03894;
62  // float the_value_high_ee=0.06285;
63  // float the_value_high_eb=0.03894;
64  // float the_value_high_ee=0.06378;
65 
66 
67  // bool magnet_high=true;
68  // if(adc_eb!= the_value_high_eb || adc_ee!= the_value_high_ee ) magnet_high=false;
69 
70 
71  //unused float the_value_low_eb=0.03894;
72  // Run 1 : float the_value_low_ee=0.05678;
73  float the_value_low_ee=0.0590975;
74  if( adc_ee > the_value_low_ee ) magnet_high=true;
75  } // check if there is already a payload
76  else something_to_transfer = true;
77 
78  // here we connect to the online DB to check the value of the magnetic field
79  std::cout << "Connecting to ONLINE DB ... " << std::endl;
81  std::cout << "Connection done" << std::endl;
82 
83  if (!econn)
84  {
85  std::cout << " Problem with OMDS: connection parameters " <<m_sid <<"/"<<m_user<<"/"<<m_pass<<std::endl;
86  throw cms::Exception("OMDS not available");
87  }
88 
89 
90  std::cout << "Retrieving last run from ONLINE DB ... " << std::endl;
91  std::map<EcalLogicID, RunDat> rundat;
92  RunIOV rp ;
93  run_t runmax=10000000;
94  std::string location_p5="P5_Co";
95  econn->fetchValidDataSet(&rundat , &rp, location_p5 ,runmax);
96 
97  unsigned long long irun=(unsigned long long) rp.getRunNumber();
98 
99  std::cout<< "retrieved run number "<< irun <<std::endl;
100 
101  if(irun>max_since) {
102  // retrieve from last value data record
103  // always call this method at first run
104 
105  std::map<EcalLogicID, RunDCSMagnetDat> dataset;
106 
107  econn->fetchDataSet(&dataset, &rp);
108 
109  if (!dataset.size()) {
110  throw(std::runtime_error("Zero rows read back"));
111  } else {
112  std::cout<< "retrieved magnet current"<<std::endl;
113  }
114 
115 
116  float mag_cur=0;
117 
118  std::map< EcalLogicID, RunDCSMagnetDat >::iterator it;
119  for (it=dataset.begin(); it!=dataset.end(); ++it){
120 
121  RunDCSMagnetDat a_mag = (*it).second;
122  mag_cur= a_mag.getMagnetCurrent();
123 
124  }
125 
126 
128  if(tagInfo().size) {
129  if(mag_cur>7000. && magnet_high ) {
130 
131  std::cout << " the magnet is ON and the constants are for magnet ON " << std::endl;
132 
133  } else if(mag_cur>7000. && !magnet_high ) {
134  something_to_transfer=true;
135  std::cout << " the magnet is ON and the constants are for magnet OFF " << std::endl;
136  std::cout << " I transfer the ON constants "<< std::endl;
137  file_=m_file_highfield;
138 
139  } else if(mag_cur<6000. && magnet_high ) {
140  something_to_transfer=true;
141  std::cout << " the magnet is OFF and the constants are for magnet ON "<< std::endl;
142  std::cout << " I transfer the OFF constants "<< std::endl;
143  file_=m_file_lowfield;
144 
145  } else if( mag_cur<6000. && !magnet_high ){
146 
147  std::cout << " the magnet is OFF and the constants are for magnet OFF "<< std::endl;
148  file_=m_file_lowfield;
149 
150  } else {
151 
152  std::cout << " the magnet is in a strange situation I do nothing ... just be patient "<< std::endl;
153 
154  }
155  }
156  else {
157  if(mag_cur>7000.)
158  std::cout <<" first payload, the magnet is ON " << std::endl;
159  else if( mag_cur<6000.) {
160  std::cout <<" first payload, the magnet is OFF " << std::endl;
161  file_=m_file_lowfield;
162  }
163  else
164  std::cout << " the magnet is in a strange situation I do nothing ... just be patient "<< std::endl;
165  }
166 
167  if(something_to_transfer) {
168 
169  std::cout << "Generating popcon record for run " << irun << "..." << std::flush;
170  std::cout << "going to open file "<<file_ << std::flush;
171 
172 
175  EcalADCToGeVXMLTranslator::readXML(file_,header,*payload);
176 
177 
178  Time_t snc= (Time_t) irun ;
179 
181  std::make_pair(payload,snc));
182 
183  ss << "Run=" << irun << "_Magnet_changed_"<<std::endl;
184  m_userTextLog = ss.str()+";";
185 
186  } else {
187  std::cout << "Run " << irun << " nothing sent to the DB"<< std::endl;
188 
189  ss<< "Run=" << irun << "_Magnet_NOT_changed_"<<std::endl;
190  m_userTextLog = ss.str()+";";
191  }
192 
193  delete econn;
194  } // irun > max_since
195  else {
196  std::cout << "Run " << irun << " nothing sent to the DB"<< std::endl;
197  ss<< "Run=" << irun << "_no_new_runs_"<<std::endl;
198  m_userTextLog = ss.str()+";";
199 
200 
201  }
202 
203  std::cout << "Ecal - > end of getNewObjects -----------\n";
204 }
size
Write out results.
int run_t
Definition: CaliIOV.h:11
size_t size
Definition: Types.h:76
static int readXML(const std::string &filename, EcalCondHeader &header, EcalADCToGeVConstant &record)
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov) noexcept(false)
float getMagnetCurrent() const
cond::ValidityInterval lastInterval
Definition: Types.h:74
payload
payload postfix for testing
run_t getRunNumber() const
Definition: RunIOV.cc:45
Definition: RunIOV.h:13
EcalCondDBInterface * econn
void fetchValidDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *fillIOV, RunTag *tag, run_t run=(unsigned int)-1) noexcept(false)
std::string popcon::EcalADCToGeVHandler::id ( ) const
inlinevirtual

Member Data Documentation

EcalCondDBInterface* popcon::EcalADCToGeVHandler::econn

Definition at line 66 of file EcalADCToGeVHandler.h.

Referenced by getNewObjects().

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

Definition at line 84 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler(), and getNewObjects().

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

Definition at line 83 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler(), and getNewObjects().

unsigned int popcon::EcalADCToGeVHandler::m_firstRun
private

Definition at line 73 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler().

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

Definition at line 77 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler().

unsigned int popcon::EcalADCToGeVHandler::m_lastRun
private

Definition at line 74 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler().

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

Definition at line 76 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler().

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

Definition at line 81 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler().

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

Definition at line 82 of file EcalADCToGeVHandler.h.

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

Definition at line 80 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler(), and getNewObjects().

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

Definition at line 78 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler(), and getNewObjects().

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

Definition at line 79 of file EcalADCToGeVHandler.h.

Referenced by EcalADCToGeVHandler(), and getNewObjects().

const EcalADCToGeVConstant* popcon::EcalADCToGeVHandler::myintercalib
private

Definition at line 71 of file EcalADCToGeVHandler.h.