#include <CondTools/Ecal/interface/EcalLaserHandler.h>
Public Member Functions | |
EcalLaserHandler (edm::ParameterSet const &) | |
void | getNewObjects () |
std::string | id () const |
~EcalLaserHandler () | |
Public Attributes | |
EcalCondDBInterface * | econn |
Private Attributes | |
unsigned long | m_firstRun |
std::string | m_gentag |
unsigned long | 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 EcalLaserAPDPNRatios * | myapdpns |
Definition at line 59 of file EcalLaserHandler.h.
popcon::EcalLaserHandler::~EcalLaserHandler | ( | ) |
popcon::EcalLaserHandler::EcalLaserHandler | ( | edm::ParameterSet const & | ps | ) |
Definition at line 8 of file EcalLaserHandler.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), edm::ParameterSet::getParameter(), m_firstRun, m_gentag, m_lastRun, m_location, m_locationsource, m_pass, m_sid, and m_user.
00009 : m_name(ps.getUntrackedParameter<std::string>("name","EcalLaserHandler")) { 00010 00011 std::cout << "EcalLaser Source handler constructor\n" << std::endl; 00012 00013 m_firstRun=(unsigned long)atoi( ps.getParameter<std::string>("firstRun").c_str()); 00014 m_lastRun=(unsigned long)atoi( ps.getParameter<std::string>("lastRun").c_str()); 00015 m_sid= ps.getParameter<std::string>("OnlineDBSID"); 00016 m_user= ps.getParameter<std::string>("OnlineDBUser"); 00017 m_pass= ps.getParameter<std::string>("OnlineDBPassword"); 00018 m_locationsource= ps.getParameter<std::string>("LocationSource"); 00019 m_location=ps.getParameter<std::string>("Location"); 00020 m_gentag=ps.getParameter<std::string>("GenTag"); 00021 00022 std::cout << m_sid<<"/"<<m_user<<"/"<<m_pass<<"/"<<m_location<<"/"<<m_gentag << std::endl; 00023 }
void popcon::EcalLaserHandler::getNewObjects | ( | ) | [virtual] |
Implements popcon::PopConSourceHandler< EcalLaserAPDPNRatios >.
Definition at line 29 of file EcalLaserHandler.cc.
References TestMuL1L2Filter_cff::cerr, GenMuonPlsPt100GeV_cfg::cout, e, econn, EcalCondObjectContainer< T >::end(), lat::endl(), Exception, EcalCondDBInterface::fetchDataSet(), EcalCondDBInterface::fetchLMFRunList(), EcalCondObjectContainer< T >::find(), flush(), LMFLaserBlueNormDat::getAPDOverPNMean(), EcalLogicID::getID1(), EcalLogicID::getID2(), EcalLaserAPDPNRatios::getLaserMap(), LMFRunList::getRuns(), EcalLaserAPDPNRatios::getTimeMap(), EBDetId::hashedIndex(), i, int, cond::TagInfo::lastInterval, popcon::PopConSourceHandler< EcalLaserAPDPNRatios >::lastPayload(), m_firstRun, m_gentag, m_lastRun, m_location, m_name, m_pass, m_sid, popcon::PopConSourceHandler< EcalLaserAPDPNRatios >::m_to_transfer, m_user, EBDetId::MAX_IETA, EBDetId::MAX_IPHI, EBDetId::MIN_IPHI, p, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p1, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p2, RunTag::setGeneralTag(), LMFRunTag::setGeneralTag(), LMFRunList::setLMFRunTag(), LocationDef::setLocation(), RunTag::setLocationDef(), LMFRunList::setRunTag(), RunTypeDef::setRunType(), RunTag::setRunTypeDef(), EcalLaserAPDPNRatios::setTime(), EcalLaserAPDPNRatios::setValue(), EBDetId::SMCRYSTALMODE, EcalLaserAPDPNRatios::EcalLaserTimeStamp::t1, EcalLaserAPDPNRatios::EcalLaserTimeStamp::t2, popcon::PopConSourceHandler< EcalLaserAPDPNRatios >::tagInfo(), cond::timestamp, and EBDetId::validDetId().
00030 { 00031 std::cerr << "------- " << m_name 00032 << " - > getNewObjects" << std::endl; 00033 00034 std::cout << "------- Ecal - > getNewObjects\n"; 00035 00036 00037 int max_since=0; 00038 max_since=(int)tagInfo().lastInterval.first; 00039 std::cout << "max_since : " << max_since << endl; 00040 Ref payload= lastPayload(); 00041 00042 std::cout << "retrieved last payload " << endl; 00043 00044 00045 // we will copy the last valid record to a temporary object apdpns_temp 00046 EcalLaserAPDPNRatios* apdpns_temp = new EcalLaserAPDPNRatios(); 00047 00048 // let's get from offline DB the last valid apdpn object to set apdpn_db 00049 00050 EcalLaserAPDPNRatios::EcalLaserTimeStamp timestamp; 00051 EcalLaserAPDPNRatios::EcalLaserAPDPNpair apdpnpair; 00052 00053 EcalLaserAPDPNRatios::EcalLaserTimeStamp timestamp_temp; // to be used to temporary stor values befor copy 00054 EcalLaserAPDPNRatios::EcalLaserAPDPNpair apdpnpair_temp; // to be used to temporary stor values befor copy 00055 00056 const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap& laserRatiosMap = payload->getLaserMap(); 00057 const EcalLaserAPDPNRatios::EcalLaserTimeStampMap& laserTimeMap = payload->getTimeMap(); 00058 std::cout << "going to access objects in the last payload " << endl; 00059 00060 00061 // const EcalLaserAPDPNPairs& apdpns_db= *apdpns.product(); // got the apdpns 00062 00063 00064 // loop through barrel 00065 for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) { 00066 if(iEta==0) continue; 00067 for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) { 00068 try 00069 { 00070 if (EBDetId::validDetId(iEta,iPhi)) 00071 { 00072 EBDetId ebdetid(iEta,iPhi); 00073 unsigned int hiee = ebdetid.hashedIndex(); // no need with the new structure of containers designed by Federico 00074 if (laserRatiosMap.find(ebdetid)!=laserRatiosMap.end()){ 00075 apdpnpair = laserRatiosMap[ebdetid]; 00076 apdpnpair_temp.p1 = apdpnpair.p1; 00077 apdpnpair_temp.p2 = apdpnpair.p2; 00078 apdpns_temp->setValue(ebdetid, apdpnpair_temp); 00079 if (hiee%1000 == 0 )std::cout <<"hiee = "<< hiee << " p1 = " << apdpnpair.p1 <<" p2 = " << apdpnpair.p2 <<endl; 00080 } else { 00081 edm::LogError("EcalLaserHandler") << "error with laserRatiosMap!" << endl; 00082 } 00083 } 00084 } 00085 catch (cms::Exception &e) { } 00086 } 00087 } 00088 00089 std::cout << "going to access Endcap objects in the last payload " << endl; 00090 00091 /* 00092 // loop through ecal endcap 00093 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) { 00094 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) { 00095 try 00096 { 00097 EEDetId eedetidpos(iX,iY,1); 00098 int hi = eedetidpos.hashedIndex(); 00099 00100 if (laserRatiosMap.find(eedetidpos)!=laserRatiosMap.end()){ 00101 apdpnpair = laserRatiosMap[eedetidpos]; 00102 apdpnpair_temp.p1 = apdpnpair.p1; 00103 apdpnpair_temp.p2 = apdpnpair.p2; 00104 apdpns_temp->setValue(eedetidpos, apdpnpair_temp); 00105 00106 } else { 00107 edm::LogError("EcalLaserHandler") << "error with laserRatiosMap!" << endl; 00108 } 00109 00110 EEDetId eedetidneg(iX,iY,-1); 00111 hi = eedetidneg.hashedIndex(); 00112 00113 if (laserRatiosMap.find(eedetidneg)!=laserRatiosMap.end()){ 00114 apdpnpair = laserRatiosMap[eedetidneg]; 00115 apdpnpair_temp.p1 = apdpnpair.p1; 00116 apdpnpair_temp.p2 = apdpnpair.p2; 00117 apdpns_temp->setValue(eedetidneg, apdpnpair_temp); 00118 00119 } else { 00120 edm::LogError("EcalLaserHandler") << "error with laserRatiosMap!" << endl; 00121 } 00122 00123 } 00124 catch (cms::Exception &e) { } 00125 } 00126 } 00127 */ 00128 //loop through light modules 00129 for (int i=0; i<92; i++){ 00130 timestamp = laserTimeMap[i]; 00131 00132 timestamp_temp.t1 = timestamp.t1; 00133 timestamp_temp.t2 = timestamp.t2; 00134 00135 apdpns_temp->setTime(i,timestamp_temp); 00136 } 00137 00138 cout <<"WOW: we just retrieved the last valid record from DB "<< endl; 00139 00140 00141 // here we retrieve all the runs after the last from online DB 00142 00143 cout << "Retrieving run list from ONLINE DB ... " << endl; 00144 try { 00145 cout << "Making connection..." << flush; 00146 econn = new EcalCondDBInterface( m_sid, m_user, m_pass ); 00147 cout << "Done." << endl; 00148 } catch (runtime_error &e) { 00149 cout << " connection parameters " <<m_sid <<"/"<<m_user<<"/"<<m_pass<<endl; 00150 cerr << e.what() << endl; 00151 throw cms::Exception("OMDS not available"); 00152 } 00153 00154 // these are the online conditions DB classes 00155 RunList my_runlist ; 00156 RunTag my_runtag; 00157 LocationDef my_locdef; 00158 RunTypeDef my_rundef; 00159 00160 my_locdef.setLocation(m_location); 00161 my_rundef.setRunType("LASER"); 00162 my_runtag.setLocationDef(my_locdef); 00163 my_runtag.setRunTypeDef(my_rundef); 00164 my_runtag.setGeneralTag(m_gentag); 00165 00166 00167 // here we retrieve the laser Monitoring Farm run records 00168 00169 LMFRunTag lmf_tag; 00170 lmf_tag.setGeneralTag("default"); 00171 LMFRunList lmf_list; 00172 lmf_list.setLMFRunTag(lmf_tag); 00173 lmf_list.setRunTag(my_runtag); 00174 // mon_list=econn->fetchMonRunList(my_runtag, mon_tag); 00175 00176 int min_run=m_firstRun; 00177 if(m_firstRun==0 || m_firstRun < (max_since+1) ){ 00178 min_run=(int)max_since+1; // we have to add 1 to the last transferred one 00179 } 00180 cout << " minimum accepted run is "<<min_run<< endl; 00181 00182 00183 int max_run=(int)m_lastRun; 00184 lmf_list=econn->fetchLMFRunList(my_runtag, lmf_tag,min_run,max_run ); 00185 00186 std::vector<LMFRunIOV> lmf_run_vec= lmf_list.getRuns(); 00187 int lmf_runs=lmf_run_vec.size(); 00188 cout <<"number of LMF runs is : "<< lmf_runs<< endl; 00189 00190 if(lmf_runs>0){ 00191 00192 for(int kr=0; kr<lmf_runs; kr++){ 00193 00194 unsigned long irun=(unsigned long) lmf_run_vec[kr].getRunIOV().getRunNumber(); 00195 cout << "here is the run number: "<< lmf_run_vec[kr].getRunIOV().getRunNumber() << endl; 00196 00197 cout <<" retrieve the data for a given run"<< endl; 00198 00199 if (lmf_run_vec[kr].getSubRunNumber() <=1){ 00200 00201 // retrieve the data for a given run 00202 RunIOV runiov_prime = lmf_run_vec[kr].getRunIOV(); 00203 00204 // retrieve the APDPNs from OMDS for this run 00205 map<EcalLogicID, LMFLaserBlueNormDat> dataset_lmf; 00206 econn->fetchDataSet(&dataset_lmf, &lmf_run_vec[kr]); 00207 cout <<"OMDS record for run "<<irun <<" is made of "<< dataset_lmf.size() << endl; 00208 typedef map<EcalLogicID, LMFLaserBlueNormDat>::const_iterator CIlmf; 00209 EcalLogicID ecid_xt; 00210 LMFLaserBlueNormDat rd_apdnorm; 00211 00212 //fill the laserRatiosMap with the values from the previose object in case of the 00213 //first retrieved run it will be the same map as in the last valid object from Offline DB 00214 //EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap& laserRatiosMap = apdpns_temp->getLaserMap(); 00215 //EcalLaserAPDPNRatios::EcalLaserTimeStampMap& laserTimeMap = apdpns_temp->getTimeMap(); 00216 00217 00218 for (CIlmf p = dataset_lmf.begin(); p != dataset_lmf.end(); p++) { 00219 ecid_xt = p->first; 00220 rd_apdnorm = p->second; 00221 int sm_num=ecid_xt.getID1(); 00222 const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap& laserRatiosMap = apdpns_temp->getLaserMap(); 00223 int xt_num=ecid_xt.getID2(); 00224 EBDetId ebdetid(sm_num,xt_num,EBDetId::SMCRYSTALMODE); 00225 unsigned int hiee = ebdetid.hashedIndex(); 00226 apdpnpair = laserRatiosMap[ebdetid]; 00227 00228 // p1 in a new object should be equal to the p2 in the previos object 00229 apdpnpair_temp.p1 = apdpnpair.p2; 00230 // if(hiee%1000==0) cout << apdpnpair.p2 << endl; 00231 apdpnpair_temp.p2 = rd_apdnorm.getAPDOverPNMean(); 00232 00233 00234 // here we change in the apdpns_temp object only the values that are available in the online DB 00235 // otherwise we keep the old value 00236 apdpns_temp->setValue(ebdetid, apdpnpair_temp); 00237 } 00238 00239 for (int i=0; i<92; i++){ 00240 const EcalLaserAPDPNRatios::EcalLaserTimeStampMap& laserTimeMap = apdpns_temp->getTimeMap(); 00241 timestamp = laserTimeMap[i]; 00242 00243 timestamp_temp.t1 = timestamp.t2; 00244 // if(i%10==0) cout << int(timestamp.t2.value()) << endl; 00245 timestamp_temp.t2 = irun; 00246 00247 apdpns_temp->setTime(i,timestamp_temp); 00248 } 00249 00250 cout << "Generating popcon record for run " << irun << "..." << flush; 00251 00252 00253 // now I copy apdpns_temp in apdpns_popcon and I ship apdpns_popcon to popcon 00254 // if I use always the same apdpns_temp I always overwrite 00255 // so I really have to create new objects for each new run 00256 // popcon deletes everything for me 00257 00258 EcalLaserAPDPNRatios* apdpns_popcon = new EcalLaserAPDPNRatios(); 00259 00260 for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) { 00261 if(iEta==0) continue; 00262 for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) { 00263 // make an EBDetId since we need EBDetId::rawId() to be used as the key for the pedestals 00264 if (EBDetId::validDetId(iEta,iPhi)) 00265 { 00266 EBDetId ebdetid(iEta,iPhi); 00267 unsigned int hiee = ebdetid.hashedIndex(); 00268 00269 00270 // here I copy the last valid value in the laser object 00271 if (laserRatiosMap.find(ebdetid)!=laserRatiosMap.end()){ 00272 // const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap& laserRatiosMap = handle.product()->getLaserMap(); 00273 const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap& laserRatiosMap = apdpns_temp->getLaserMap(); 00274 apdpnpair = laserRatiosMap[ebdetid]; 00275 apdpnpair_temp.p1 = apdpnpair.p1; 00276 apdpnpair_temp.p2 = apdpnpair.p2; 00277 //if(hiee%1000==0) cout << apdpnpair.p1 << " " <<apdpnpair.p2<< endl; 00278 apdpns_popcon->setValue(ebdetid, apdpnpair_temp); 00279 } else { 00280 edm::LogError("EcalLaserHandler") << "error with laserRatiosMap!" << endl; 00281 } 00282 00283 } 00284 } 00285 } 00286 00287 for (int i=0; i<92; i++){ 00288 // const EcalLaserAPDPNRatios::EcalLaserTimeStampMap& laserTimeMap = handle.product()->getTimeMap(); 00289 const EcalLaserAPDPNRatios::EcalLaserTimeStampMap& laserTimeMap = apdpns_temp->getTimeMap(); 00290 timestamp = laserTimeMap[i]; 00291 00292 timestamp_temp.t1 = timestamp.t1; 00293 timestamp_temp.t2 = timestamp.t2; 00294 00295 apdpns_popcon->setTime(i,timestamp_temp); 00296 } 00297 00298 Time_t snc = irun ; 00299 //int tll= edm::IOVSyncValue::endOfTime().eventID().time(); 00300 // unsigned long long tll = edm::Timestamp::endOfTime().value(); 00301 // cout << "valid will 'tll': "<< tll << endl; 00302 //popcon::IOVPair iop = {snc,tll}; 00303 00304 00305 m_to_transfer.push_back(std::make_pair(apdpns_popcon,snc)); 00306 00307 std::cout << "Ecal - > end of getNewObjects -----------\n"; 00308 00309 00310 } 00311 } 00312 00313 } 00314 00315 00316 delete econn; 00317 delete apdpns_temp; // this is the only one that popcon does not delete 00318 00319 00320 }
std::string popcon::EcalLaserHandler::id | ( | void | ) | const [inline, virtual] |
Implements popcon::PopConSourceHandler< EcalLaserAPDPNRatios >.
Definition at line 68 of file EcalLaserHandler.h.
References m_name.
00068 { return m_name;}
unsigned long popcon::EcalLaserHandler::m_firstRun [private] |
Definition at line 72 of file EcalLaserHandler.h.
Referenced by EcalLaserHandler(), and getNewObjects().
std::string popcon::EcalLaserHandler::m_gentag [private] |
Definition at line 75 of file EcalLaserHandler.h.
Referenced by EcalLaserHandler(), and getNewObjects().
unsigned long popcon::EcalLaserHandler::m_lastRun [private] |
Definition at line 73 of file EcalLaserHandler.h.
Referenced by EcalLaserHandler(), and getNewObjects().
std::string popcon::EcalLaserHandler::m_location [private] |
Definition at line 74 of file EcalLaserHandler.h.
Referenced by EcalLaserHandler(), and getNewObjects().
std::string popcon::EcalLaserHandler::m_locationsource [private] |
std::string popcon::EcalLaserHandler::m_name [private] |
std::string popcon::EcalLaserHandler::m_pass [private] |
Definition at line 78 of file EcalLaserHandler.h.
Referenced by EcalLaserHandler(), and getNewObjects().
std::string popcon::EcalLaserHandler::m_sid [private] |
Definition at line 76 of file EcalLaserHandler.h.
Referenced by EcalLaserHandler(), and getNewObjects().
std::string popcon::EcalLaserHandler::m_user [private] |
Definition at line 77 of file EcalLaserHandler.h.
Referenced by EcalLaserHandler(), and getNewObjects().
const EcalLaserAPDPNRatios* popcon::EcalLaserHandler::myapdpns [private] |
Definition at line 71 of file EcalLaserHandler.h.