Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:52

0001 /***********************************************/
0002 /* EcalCondDBInterface.h               */
0003 /*                         */
0004 /*                         */
0005 /* Interface to the Ecal Conditions DB.        */
0006 /***********************************************/
0007 
0008 #ifndef ECALCONDDBINTERFACE_HH
0009 #define ECALCONDDBINTERFACE_HH
0010 
0011 #include <iostream>
0012 #include <string>
0013 #include <vector>
0014 #include <map>
0015 #include <stdexcept>
0016 #include "OnlineDB/Oracle/interface/Oracle.h"
0017 
0018 #include "OnlineDB/EcalCondDB/interface/EcalDBConnection.h"
0019 #include "OnlineDB/EcalCondDB/interface/Tm.h"
0020 #include "OnlineDB/EcalCondDB/interface/EcalLogicID.h"
0021 #include "OnlineDB/EcalCondDB/interface/IIOV.h"
0022 #include "OnlineDB/EcalCondDB/interface/RunIOV.h"
0023 #include "OnlineDB/EcalCondDB/interface/MonRunIOV.h"
0024 #include "OnlineDB/EcalCondDB/interface/DCUIOV.h"
0025 #include "OnlineDB/EcalCondDB/interface/CaliIOV.h"
0026 #include "OnlineDB/EcalCondDB/interface/RunList.h"
0027 #include "OnlineDB/EcalCondDB/interface/MonRunList.h"
0028 #include "OnlineDB/EcalCondDB/interface/MonRunTag.h"
0029 #include "OnlineDB/EcalCondDB/interface/DCSPTMTempList.h"
0030 #include "OnlineDB/EcalCondDB/interface/all_fe_config_types.h"
0031 #include "OnlineDB/EcalCondDB/interface/all_lmf_types.h"
0032 #include "OnlineDB/EcalCondDB/interface/all_od_types.h"
0033 
0034 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0035 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0036 
0037 class EcalCondDBInterface : public EcalDBConnection {
0038 public:
0039   /******************\
0040   -  public methods  -
0041   \******************/
0042 
0043   /**
0044    *  Constructor, makes connection to DB without TNS_ADMIN
0045    *  === Parameters ===
0046    *  host:    DB host machine
0047    *  sid:     DB SID (name)
0048    *  user:    User to connect
0049    *  pass:    Password for user
0050    *  port:    port number to connect, default 1521
0051    */
0052   EcalCondDBInterface(std::string host, std::string sid, std::string user, std::string pass, int port = 1521)
0053       : EcalDBConnection(host, sid, user, pass, port) {
0054     // call the parent constructor
0055 
0056     // create a DateHandler
0057     dh = new DateHandler(env, conn);
0058   }
0059 
0060   /**
0061    *  Constructor, makes connection to DB with TNS_ADMIN
0062    *  === Parameters ===
0063    *  sid:     DB SID (name)
0064    *  user:    User to connect
0065    *  pass:    Password for user
0066    */
0067   EcalCondDBInterface(std::string sid, std::string user, std::string pass) : EcalDBConnection(sid, user, pass) {
0068     // call the parent constructor
0069 
0070     // create a DateHandler
0071     dh = new DateHandler(env, conn);
0072   }
0073 
0074   /**
0075    * Destructor
0076    */
0077   ~EcalCondDBInterface() noexcept(false) override {
0078     // call the parent destructor
0079 
0080     // destroy the DateHandler
0081     delete (dh);
0082   }
0083 
0084   /**
0085    *  Return a date handler associated with this connection
0086    */
0087   inline DateHandler* getDateHandler() { return dh; }
0088 
0089   /**
0090    *  Look up the "human readable" ids and return an EcalLogicID object which contains
0091    *  the "database readable" logic_id
0092    *  === Parameters ===
0093    *  name:           name of the channel type you are specifying
0094    *  id1, id2, id3:  ids of the channel type
0095    *  mapsTo:         name of the channel type you are mapping to
0096    */
0097   EcalLogicID getEcalLogicID(std::string name,
0098                              int id1 = EcalLogicID::NULLID,
0099                              int id2 = EcalLogicID::NULLID,
0100                              int id3 = EcalLogicID::NULLID,
0101                              std::string mapsTo = "") noexcept(false);
0102 
0103   /**
0104    *  Build various reverse maps
0105    *  Map an LMR, or a Ex_LM_PN into the set of components
0106    */
0107 
0108   std::vector<EcalLogicID> getEcalLogicIDMappedTo(int logic_id, std::string maps_to);
0109 
0110   std::vector<EcalLogicID> getEcalLogicIDForLMR(int lmr_logic_id);
0111   std::vector<EcalLogicID> getEcalLogicIDForLMR(const EcalLogicID& lmr_logic_id);
0112   std::vector<EcalLogicID> getEcalLogicIDForLMPN(int lmr_logic_id);
0113   std::vector<EcalLogicID> getEcalLogicIDForLMPN(const EcalLogicID& lmr_logic_id);
0114 
0115   /**
0116    *  Look up the database logic_id and return the EcalLogicID object which contains
0117    *  the "human readable" ids
0118    *  === Parameters ===
0119    *  logicID:  DB logic_id
0120    */
0121   EcalLogicID getEcalLogicID(int logicID) noexcept(false);
0122 
0123   /**
0124    *  Get a set of EcalLogicID in one transaction
0125    *  === Parameters ===
0126    *  name:             name of the channel type you are specifying
0127    *  fromId1, toId1:   Range of id1 in the DB to retrieve
0128    *  fromId2, toId2:   Range of id2 in the DB to retrieve
0129    *  fromId3, toId3:   Range of id3 in the DB to retrieve
0130    *  string mapsTo:    channel type name these ids map to
0131    */
0132   std::vector<EcalLogicID> getEcalLogicIDSet(std::string name,
0133                                              int fromId1 = EcalLogicID::NULLID,
0134                                              int toId1 = EcalLogicID::NULLID,
0135                                              int fromId2 = EcalLogicID::NULLID,
0136                                              int toId2 = EcalLogicID::NULLID,
0137                                              int fromId3 = EcalLogicID::NULLID,
0138                                              int toId3 = EcalLogicID::NULLID,
0139                                              std::string mapsTo = "") noexcept(false);
0140 
0141   std::map<int, int> getEcalLogicID2LmrMap();
0142   std::vector<EcalLogicID> getEcalLogicIDSetOrdered(std::string name,
0143                                                     int fromId1,
0144                                                     int toId1,
0145                                                     int fromId2 = EcalLogicID::NULLID,
0146                                                     int toId2 = EcalLogicID::NULLID,
0147                                                     int fromId3 = EcalLogicID::NULLID,
0148                                                     int toId3 = EcalLogicID::NULLID,
0149                                                     std::string mapsTo = "",
0150                                                     int orderedBy = EcalLogicID::NULLID) noexcept(false);
0151 
0152   /**
0153    *  Insert a run IOV object.  Nothing is committed in the event of an exception
0154    */
0155   void insertRunIOV(RunIOV* iov) noexcept(false);
0156   // updates the end time of an iov
0157   void updateRunIOV(RunIOV* iov) noexcept(false);
0158   void updateRunIOVStartTime(RunIOV* iov) noexcept(false);
0159   void updateRunIOVEndTime(RunIOV* iov) noexcept(false);
0160 
0161   void updateRunConfig(ODRunConfigInfo* od) noexcept(false);
0162 
0163   void insertLmfIOV(LMFIOV* iov) noexcept(false);
0164   void insertLmfLmrSubIOV(LMFLmrSubIOV* iov) noexcept(false);
0165   void insertLmfSeq(LMFSeqDat* iov) noexcept(false);
0166   void insertLmfRunIOV(LMFRunIOV* iov) noexcept(false);
0167   void insertLmfDat(LMFDat* dat) noexcept(false);
0168   void insertLmfDat(std::list<LMFDat*> dat) noexcept(false);
0169 
0170   /**
0171    *  Return run Fe Config Dat objects for a given run
0172    */
0173 
0174   std::list<ODDelaysDat> fetchFEDelaysForRun(RunIOV* iov) noexcept(false);
0175 
0176   /**
0177    *  Return a run IOV object for a given tag
0178    */
0179   RunIOV fetchRunIOV(RunTag* tag, run_t run) noexcept(false);
0180 
0181   /**
0182    *  Return a run IOV object for a given location.
0183    *  It is not guarunteed that a run is unique for a location only,
0184    *  so an exception is thrown if more than one result exists.
0185    */
0186   RunIOV fetchRunIOV(std::string location, run_t run) noexcept(false);
0187 
0188   RunIOV fetchRunIOV(std::string location, const Tm& t) noexcept(false);
0189 
0190   /**
0191    *  Insert a monitoring run object.  Nothing is committed in the event of an exception
0192    */
0193   void insertMonRunIOV(MonRunIOV* iov) noexcept(false);
0194 
0195   /**
0196    *  Insert a DCU IOV object.  Nothing is committed in the event of an exception
0197    */
0198   void insertDCUIOV(DCUIOV* iov) noexcept(false);
0199 
0200   /**
0201    *  Return a monitoring run object
0202    */
0203   MonRunIOV fetchMonRunIOV(RunTag* runtag, MonRunTag* montag, run_t run, subrun_t monrun) noexcept(false);
0204 
0205   /**
0206    *   Return a DCU IOV object
0207    */
0208   DCUIOV fetchDCUIOV(DCUTag* tag, const Tm& evenTm) noexcept(false);
0209 
0210   /**
0211    *  Return a laser monitoring farm run object
0212    */
0213   LMFRunIOV fetchLMFRunIOV(RunTag* runtag, LMFRunTag* lmftag, run_t run, subrun_t lmfrun) noexcept(false);
0214   bool fetchLMFRunIOV(const LMFSeqDat&, LMFRunIOV&, int lmr, int type, int color) const;
0215   RunIOV fetchLMFLastRun() const;
0216 
0217   /**
0218    *   Return a Calibration IOV object
0219    */
0220   CaliIOV fetchCaliIOV(CaliTag* tag, const Tm& evenTm) noexcept(false);
0221 
0222   /**
0223    *   Return a Run List
0224    */
0225   RunList fetchRunList(const RunTag& tag) noexcept(false);
0226   RunList fetchRunList(const RunTag& tag, int min_run, int max_run) noexcept(false);
0227   RunList fetchNonEmptyRunList(const RunTag& tag, int min_run, int max_run) noexcept(false);
0228   RunList fetchNonEmptyGlobalRunList(const RunTag& tag, int min_run, int max_run) noexcept(false);
0229   RunList fetchRunListByLocation(const RunTag& tag, int min_run, int max_run, const LocationDef& locDef) noexcept(false);
0230   RunList fetchGlobalRunListByLocation(const RunTag& tag,
0231                                        int min_run,
0232                                        int max_run,
0233                                        const LocationDef& locDef) noexcept(false);
0234   RunList fetchRunListLastNRuns(const RunTag& tag, int max_run, int n_runs) noexcept(false);
0235 
0236   /**
0237    *   Return a PTM Temp List
0238    */
0239 
0240   DCSPTMTempList fetchDCSPTMTempList(const EcalLogicID& ecid) noexcept(false);
0241   DCSPTMTempList fetchDCSPTMTempList(const EcalLogicID& ecid, const Tm& start, const Tm& end) noexcept(false);
0242 
0243   MonRunList fetchMonRunList(const RunTag& tag, const MonRunTag& monruntag) noexcept(false);
0244   MonRunList fetchMonRunList(const RunTag& tag, const MonRunTag& monruntag, int min_run, int max_run) noexcept(false);
0245   MonRunList fetchMonRunListLastNRuns(const RunTag& tag,
0246                                       const MonRunTag& monruntag,
0247                                       int max_run,
0248                                       int n_runs) noexcept(false);
0249 
0250   /*
0251    *   Insert a set of data at the given iov.  If the iov does not yet
0252    *   exist in the database they will be written.  Nothing is committed in the the event of
0253    *   an exception
0254    */
0255   // XXX TODO:  Split declaration and definition using a macro
0256   // XXX        Naive method causes linker errors...
0257   // XXX        See example FWCore/Framework/interface/eventSetupGetImplementation.h
0258 
0259   template <class DATT, class IOVT>
0260   void insertDataSet(const std::map<EcalLogicID, DATT>* data, IOVT* iov) noexcept(false) {
0261     try {
0262       iov->setConnection(env, conn);
0263       // if it has not yet been written then write
0264       if (iov->getID() == 0) {
0265         std::cout << "IOV was not set we retrieve it from DB" << std::endl;
0266         iov->fetchID();
0267       }
0268       if (iov->getID() == 0) {
0269         std::cout << "IOV was not written we write it" << std::endl;
0270         iov->writeDB();
0271       }
0272 
0273       DATT dataIface;
0274       dataIface.setConnection(env, conn);
0275       dataIface.prepareWrite();
0276 
0277       const EcalLogicID* channel;
0278       const DATT* dataitem;
0279       typedef typename std::map<EcalLogicID, DATT>::const_iterator CI;
0280       for (CI p = data->begin(); p != data->end(); ++p) {
0281         channel = &(p->first);
0282         dataitem = &(p->second);
0283         dataIface.writeDB(channel, dataitem, iov);
0284       }
0285       conn->commit();
0286       dataIface.terminateWriteStatement();
0287     } catch (std::runtime_error& e) {
0288       conn->rollback();
0289       throw(e);
0290     } catch (...) {
0291       conn->rollback();
0292       throw(std::runtime_error("EcalCondDBInterface::insertDataSet:  Unknown exception caught"));
0293     }
0294   }
0295 
0296   //test for DB Array insertion
0297   template <class DATT, class IOVT>
0298   void insertDataArraySet(const std::map<EcalLogicID, DATT>* data, IOVT* iov) noexcept(false) {
0299     try {
0300       iov->setConnection(env, conn);
0301       if (iov->getID() == 0) {
0302         std::cout << "IOV was not set we retrieve it from DB" << std::endl;
0303         iov->fetchID();
0304       }
0305       if (iov->getID() == 0) {
0306         std::cout << "IOV was not written we write it" << std::endl;
0307         iov->writeDB();
0308       }
0309 
0310       std::cout << "id=" << iov->getID() << std::endl;
0311 
0312       DATT dataIface;
0313       dataIface.setConnection(env, conn);
0314       dataIface.prepareWrite();
0315 
0316       dataIface.writeArrayDB(data, iov);
0317       conn->commit();
0318 
0319       dataIface.terminateWriteStatement();
0320 
0321     } catch (std::runtime_error& e) {
0322       conn->rollback();
0323       throw(e);
0324     } catch (...) {
0325       conn->rollback();
0326       throw(std::runtime_error("EcalCondDBInterface::insertDataSet:  Unknown exception caught"));
0327     }
0328   }
0329 
0330   template <class DATT, class IOVT>
0331   void insertDataSetVector(const std::vector<EcalLogicID>& ecid,
0332                            const std::vector<IOVT>& run_iov,
0333                            const std::vector<DATT>& data) noexcept(false) {
0334     int nruns = run_iov.size();
0335 
0336     if (run_iov.size() != ecid.size() && ecid.size() != data.size()) {
0337       throw(std::runtime_error("EcalCondDBInterface::insertDataSetVector:  vector sizes are different.."));
0338     }
0339 
0340     try {
0341       DATT dataIface;
0342       dataIface.setConnection(env, conn);
0343       dataIface.prepareWrite();
0344 
0345       for (int i = 0; i < nruns; i++) {
0346         run_iov[i].setConnection(env, conn);
0347         run_iov[i].writeDB();
0348 
0349         dataIface.writeDB(&ecid[i], &data[i], &run_iov[i]);
0350 
0351         conn->commit();
0352       }
0353     } catch (std::runtime_error& e) {
0354       conn->rollback();
0355       throw(e);
0356     } catch (...) {
0357       conn->rollback();
0358       throw(std::runtime_error("EcalCondDBInterface::insertDataSet:  Unknown exception caught"));
0359     }
0360   }
0361 
0362   // CONFIG DB methods
0363 
0364   template <class ICONF>
0365   void insertConfigSet(ICONF* iconf) noexcept(false) {
0366     try {
0367       iconf->setConnection(env, conn);
0368       iconf->prepareWrite();
0369       // if it has not yet been written then write
0370       iconf->writeDB();
0371       std::cout << "iconf inserted with ID=" << iconf->getId() << std::endl;
0372       conn->commit();
0373       iconf->terminateWriteStatement();
0374     } catch (std::runtime_error& e) {
0375       conn->rollback();
0376       throw(e);
0377     } catch (...) {
0378       conn->rollback();
0379       throw(std::runtime_error("EcalCondDBInterface::insertDataSet:  Unknown exception caught"));
0380     }
0381   }
0382 
0383   /*
0384    *  Fetch a config set
0385    */
0386   template <class ICONF>
0387   void fetchConfigSet(ICONF* iconf) noexcept(false) {
0388     iconf->clear();
0389     iconf->setConnection(env, conn);
0390     iconf->createReadStatement();
0391     iconf->fetchData(iconf);
0392     iconf->terminateReadStatement();
0393   }
0394 
0395   /*
0396    *  Fetch a config set
0397    */
0398   template <class ICONF>
0399   void fetchLastConfigSet(ICONF* iconf) noexcept(false) {
0400     iconf->clear();
0401     iconf->setConnection(env, conn);
0402     iconf->createReadStatement();
0403     iconf->fetchLastData(iconf);
0404     iconf->terminateReadStatement();
0405   }
0406 
0407   /*
0408    *  Insert a config data set 
0409    */
0410   template <class DATT, class ICONF>
0411   void insertConfigDataSet(const std::vector<DATT> data, ICONF* iconf) noexcept(false) {
0412     try {
0413       iconf->setConnection(env, conn);
0414       // if it has not yet been written then write
0415       if (iconf->getId() == 0) {
0416         std::cout << "EcalCondDBInterface>> config_id was not set we retrieve it from DB" << std::endl;
0417         iconf->fetchID();
0418       }
0419       if (iconf->getId() == 0) {
0420         std::cout << "EcalCondDBInterface>> configuration info was not written we write it" << std::endl;
0421         iconf->writeDB();
0422       }
0423 
0424       DATT dataIface;
0425       dataIface.setConnection(env, conn);
0426       dataIface.prepareWrite();
0427 
0428       const DATT* dataitem;
0429 
0430       for (int p = 0; p != data->size(); ++p) {
0431         dataitem = data[p];
0432         dataIface.writeDB(dataitem, iconf);
0433       }
0434       conn->commit();
0435       dataIface.terminateWriteStatement();
0436     } catch (std::runtime_error& e) {
0437       conn->rollback();
0438       throw(e);
0439     } catch (...) {
0440       conn->rollback();
0441       throw(std::runtime_error("EcalCondDBInterface::insertConfigDataSet:  Unknown exception caught"));
0442     }
0443   }
0444   /*
0445    *  insert a config data set array fast
0446    */
0447   template <class DATT, class ICONF>
0448   void insertConfigDataArraySet(const std::vector<DATT>& data, ICONF* iconf) noexcept(false) {
0449     try {
0450       iconf->setConnection(env, conn);
0451       // if it has not yet been written then write
0452       if (iconf->getId() == 0) {
0453         std::cout << "EcalCondDBInterface>> config_id was not set we retrieve it from DB" << std::endl;
0454         iconf->fetchID();
0455       }
0456       if (iconf->getId() == 0) {
0457         std::cout << "EcalCondDBInterface>> configuration info was not written we write it" << std::endl;
0458         iconf->writeDB();
0459       }
0460 
0461       DATT dataIface;
0462       dataIface.setConnection(env, conn);
0463       dataIface.prepareWrite();
0464 
0465       dataIface.writeArrayDB(data, iconf);
0466       conn->commit();
0467 
0468       dataIface.terminateWriteStatement();
0469 
0470     } catch (std::runtime_error& e) {
0471       conn->rollback();
0472       throw(e);
0473     } catch (...) {
0474       conn->rollback();
0475       throw(std::runtime_error("EcalCondDBInterface::insertConfigDataArraySet:  Unknown exception caught"));
0476     }
0477   }
0478   /*
0479    *  Fetch a set of data based on an EXACT match of an iov
0480    */
0481   template <class DATT, class ICONF>
0482   void fetchConfigDataSet(std::vector<DATT>* fillMap, ICONF* iconf) noexcept(false) {
0483     DATT datiface;
0484     datiface.setConnection(env, conn);
0485     datiface.createReadStatement();
0486     datiface.setPrefetchRowCount(1024);
0487     datiface.fetchData(fillMap, iconf);
0488     datiface.terminateReadStatement();
0489   }
0490 
0491   /*
0492    *  Fetch a set of data based on an EXACT match of an iov
0493    */
0494   template <class DATT, class IOVT>
0495   void fetchDataSet(std::map<EcalLogicID, DATT>* fillMap, IOVT* iov) noexcept(false) {
0496     fillMap->clear();
0497 
0498     DATT datiface;
0499     datiface.setConnection(env, conn);
0500     datiface.createReadStatement();
0501     datiface.setPrefetchRowCount(1024);
0502     datiface.fetchData(fillMap, iov);
0503     datiface.terminateReadStatement();
0504   }
0505 
0506   /*                               
0507    *  Fetch a set of DCS data based on time stamp
0508    */
0509   template <class DATT>
0510   void fetchDCSDataSet(std::list<std::pair<Tm, std::map<EcalLogicID, DATT> > >* fillMap, const Tm& t) noexcept(false) {
0511     fillMap->clear();
0512 
0513     DATT datiface;
0514     datiface.setConnection(env, conn);
0515     datiface.createReadStatement();
0516     datiface.setPrefetchRowCount(1024);
0517     datiface.fetchHistoricalData(fillMap, t);
0518     datiface.terminateReadStatement();
0519   }
0520 
0521   /*
0522    *  Fetch a set of data based on an EXACT match of an iov
0523    * with a specific mapping name 
0524    */
0525   template <class DATT, class IOVT>
0526   void fetchDataSetWithMap(std::map<EcalLogicID, DATT>* fillMap, IOVT* iov, std::string mapping_name) noexcept(false) {
0527     fillMap->clear();
0528 
0529     DATT datiface;
0530     datiface.setConnection(env, conn);
0531     datiface.createReadStatement();
0532     datiface.setPrefetchRowCount(1024);
0533     datiface.fetchData(fillMap, iov, mapping_name);
0534     datiface.terminateReadStatement();
0535   }
0536 
0537   /*
0538    *  Fetch dataset that is valid for the given RunTag and run.
0539    *  Also fills the given IOV object with the IOV associated with the data
0540    *  run is optional, by default is set to infinity
0541    *  Note:  ONLY works for Run*Dat objects
0542    *  TODO:  Make this function (or similar) work for all *Dat objects
0543    */
0544   template <class DATT, class IOVT>
0545   void fetchValidDataSet(std::map<EcalLogicID, DATT>* fillMap,
0546                          IOVT* fillIOV,
0547                          RunTag* tag,
0548                          run_t run = (unsigned int)-1) noexcept(false) {
0549     fillMap->clear();
0550     DATT datiface;
0551     fillIOV->setConnection(env, conn);
0552     fillIOV->setByRecentData(datiface.getTable(), tag, run);
0553     datiface.setConnection(env, conn);
0554     datiface.createReadStatement();
0555     datiface.setPrefetchRowCount(1024);
0556     datiface.fetchData(fillMap, fillIOV);
0557     datiface.terminateReadStatement();
0558   }
0559 
0560   /*
0561    *  Fetch dataset that is valid for the given location and run.
0562    *  Also fills the given IOV object with the IOV associated with the data
0563    *  run is optional, by default is set to infinity
0564    *  Note:  ONLY works for Run*Dat objects
0565    *  TODO:  Make this function (or similar) work for all *Dat objects
0566    */
0567   template <class DATT, class IOVT>
0568   void fetchValidDataSet(std::map<EcalLogicID, DATT>* fillMap,
0569                          IOVT* fillIOV,
0570                          std::string location,
0571                          run_t run = (unsigned int)-1) noexcept(false) {
0572     fillMap->clear();
0573     DATT datiface;
0574     fillIOV->setConnection(env, conn);
0575     fillIOV->setByRecentData(datiface.getTable(), location, run);
0576     datiface.setConnection(env, conn);
0577     datiface.createReadStatement();
0578     datiface.setPrefetchRowCount(1024);
0579     datiface.fetchData(fillMap, fillIOV);
0580     datiface.terminateReadStatement();
0581   }
0582 
0583   inline int getDetIdFromLogicId(int logic_id) {
0584     int detid = -1;
0585     if (_logicId2DetId.empty()) {
0586       fillLogicId2DetIdMaps();
0587     }
0588     if (_logicId2DetId.find(logic_id) != _logicId2DetId.end()) {
0589       detid = _logicId2DetId[logic_id];
0590     }
0591     return detid;
0592   }
0593 
0594   inline int getLogicIdFromDetId(int det_id) {
0595     int logic_id = -1;
0596     if (_logicId2DetId.empty()) {
0597       fillLogicId2DetIdMaps();
0598     }
0599     if (_detId2LogicId.find(det_id) != _detId2LogicId.end()) {
0600       logic_id = _detId2LogicId[det_id];
0601     }
0602     return logic_id;
0603   }
0604 
0605   inline std::map<int, int> getLogicId2DetIdMap() {
0606     if (_logicId2DetId.empty()) {
0607       fillLogicId2DetIdMaps();
0608     }
0609     return _logicId2DetId;
0610   }
0611 
0612   inline std::map<int, int> getDetId2LogicIdMap() {
0613     if (_logicId2DetId.empty()) {
0614       fillLogicId2DetIdMaps();
0615     }
0616     return _detId2LogicId;
0617   }
0618 
0619   void dummy();
0620 
0621 private:
0622   /**
0623    *  Private method: fill a private map used to associate logicIds to DetIds
0624    */
0625   void fillLogicId2DetIdMaps();
0626 
0627   /*********************\
0628   -  private variables  -
0629   \*********************/
0630 
0631   DateHandler* dh;
0632 
0633   std::map<int, int> _logicId2DetId;
0634   std::map<int, int> _detId2LogicId;
0635 
0636 public:
0637   EcalCondDBInterface() = delete;
0638   EcalCondDBInterface(const EcalCondDBInterface& copy) = delete;
0639 };
0640 
0641 #endif