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

Constructor & Destructor Documentation

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

Definition at line 9 of file EcalIntercalibHandler.cc.

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

10  : m_name(ps.getUntrackedParameter<std::string>("name","EcalIntercalibHandler")) {
11 
12  std::cout << "EcalIntercalib 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  m_value_highfield= ps.getUntrackedParameter< double >("Value_Bon");
24  // m_value_highfield= 0.75585;
25 
26 
27 
28  std::cout << m_sid<<"/"<<m_user<<"/"<<m_location<<"/"<<m_gentag << std::endl;
29 
30 }
popcon::EcalIntercalibHandler::~EcalIntercalibHandler ( )

Definition at line 32 of file EcalIntercalibHandler.cc.

33 {
34 }

Member Function Documentation

void popcon::EcalIntercalibHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalIntercalibConstants >.

Definition at line 37 of file EcalIntercalibHandler.cc.

References gather_cfg::cout, createfilelist::dataset, econn, Exception, EcalCondDBInterface::fetchDataSet(), EcalCondDBInterface::fetchValidDataSet(), objects.autophobj::float, RunDCSMagnetDat::getMagnetCurrent(), RunIOV::getRunNumber(), RecoTauValidation_cfi::header, cond::TagInfo_t::lastInterval, popcon::PopConSourceHandler< EcalIntercalibConstants >::lastPayload(), m_file_highfield, m_file_lowfield, m_pass, m_sid, m_user, popcon::PopConSourceHandler< EcalIntercalibConstants >::m_userTextLog, m_value_highfield, jetCorrFactors_cfi::payload, DetId::rawId(), EcalFloatCondObjectContainerXMLTranslator::readXML(), lumiCalc2::runmax, cond::TagInfo_t::size, findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, popcon::PopConSourceHandler< EcalIntercalibConstants >::tagInfo(), and EEDetId::validDetId().

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

Member Data Documentation

EcalCondDBInterface* popcon::EcalIntercalibHandler::econn

Definition at line 66 of file EcalIntercalibHandler.h.

Referenced by getNewObjects().

std::string popcon::EcalIntercalibHandler::m_file_highfield
private

Definition at line 84 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler(), and getNewObjects().

std::string popcon::EcalIntercalibHandler::m_file_lowfield
private

Definition at line 83 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler(), and getNewObjects().

unsigned int popcon::EcalIntercalibHandler::m_firstRun
private

Definition at line 73 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler().

std::string popcon::EcalIntercalibHandler::m_gentag
private

Definition at line 77 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler().

unsigned int popcon::EcalIntercalibHandler::m_lastRun
private

Definition at line 74 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler().

std::string popcon::EcalIntercalibHandler::m_location
private

Definition at line 76 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler().

std::string popcon::EcalIntercalibHandler::m_locationsource
private

Definition at line 81 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler().

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

Definition at line 82 of file EcalIntercalibHandler.h.

std::string popcon::EcalIntercalibHandler::m_pass
private

Definition at line 80 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler(), and getNewObjects().

std::string popcon::EcalIntercalibHandler::m_sid
private

Definition at line 78 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler(), and getNewObjects().

std::string popcon::EcalIntercalibHandler::m_user
private

Definition at line 79 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler(), and getNewObjects().

double popcon::EcalIntercalibHandler::m_value_highfield
private

Definition at line 85 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler(), and getNewObjects().

const EcalIntercalibConstants* popcon::EcalIntercalibHandler::myintercalib
private

Definition at line 71 of file EcalIntercalibHandler.h.