CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/CaloOnlineTools/HcalOnlineDb/interface/HcalLutManager.h

Go to the documentation of this file.
00001 #ifndef HcalLutManager_h
00002 #define HcalLutManager_h
00003 
00012 #include <iostream>
00013 #include <string>
00014 #include <vector>
00015 #include <map>
00016 #include <boost/shared_ptr.hpp>
00017 #include "CalibCalorimetry/HcalTPGAlgos/interface/LutXml.h"
00018 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
00019 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
00020 #include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
00021 //#include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseImpl.hh"
00022 #include "CaloOnlineTools/HcalOnlineDb/interface/HCALConfigDB.h"
00023 #include "CaloOnlineTools/HcalOnlineDb/interface/LMap.h"
00024 #include "CalibFormats/HcalObjects/interface/HcalTPGCoder.h"
00025 #include "CalibCalorimetry/CaloTPG/src/CaloTPGTranscoderULUT.h"
00026 #include "CaloOnlineTools/HcalOnlineDb/interface/HcalAssistant.h"
00027 #include "CaloOnlineTools/HcalOnlineDb/interface/HcalChannelIterator.h"
00028 
00029 
00030 
00031 class XMLDOMBlock;
00032 
00033 class HcalLutSet{
00034  public:
00035   std::string label;
00036   std::vector<std::string> subdet;
00037   std::vector<int> eta_min, eta_max, phi_min, phi_max, depth_min, depth_max;
00038   std::vector<std::vector<unsigned int> > lut;
00039 };
00040 
00041 
00042 
00043 class HcalLutManager{
00044  public:
00045   
00046   HcalLutManager( );
00047   HcalLutManager(std::vector<HcalGenericDetId> & map);
00048   HcalLutManager(const HcalElectronicsMap * _emap,
00049                  const HcalChannelQuality * _cq = 0,
00050                  uint32_t _status_word_to_mask = 0x0000);
00051   ~HcalLutManager( );
00052 
00053   void init( void );
00054   std::string & getLutXml( std::vector<unsigned int> & _lut );
00055 
00056   // crate=-1 stands for all crates
00057   // legacy - use old LMAP. Use the xxxEmap method instead
00058   std::map<int, boost::shared_ptr<LutXml> > getLutXmlFromAsciiMaster( std::string _filename,
00059                                                                std::string _tag,
00060                                                                int _crate = -1,
00061                                                                bool split_by_crate = true );
00062 
00063   std::map<int, boost::shared_ptr<LutXml> > getLinearizationLutXmlFromAsciiMasterEmap( std::string _filename,
00064                                                                                 std::string _tag,
00065                                                                                 int _crate,
00066                                                                                 bool split_by_crate = true );
00067 
00068   std::map<int, boost::shared_ptr<LutXml> > getLinearizationLutXmlFromAsciiMasterEmap_new( std::string _filename,
00069                                                                                     std::string _tag,
00070                                                                                     int _crate,
00071                                                                                     bool split_by_crate = true );
00072 
00073   std::map<int, boost::shared_ptr<LutXml> > getCompressionLutXmlFromAsciiMaster( std::string _filename,
00074                                                                           std::string _tag,
00075                                                                           int _crate = -1,
00076                                                                           bool split_by_crate = true );
00077 
00078   std::map<int, boost::shared_ptr<LutXml> > getLinearizationLutXmlFromCoder( const HcalTPGCoder & _coder,
00079                                                                       std::string _tag,
00080                                                                       bool split_by_crate = true );
00081 
00082   std::map<int, boost::shared_ptr<LutXml> > getLinearizationLutXmlFromCoderEmap( const HcalTPGCoder & _coder,
00083                                                                           std::string _tag,
00084                                                                           bool split_by_crate = true );
00085 
00086   std::map<int, boost::shared_ptr<LutXml> > getCompressionLutXmlFromCoder( std::string _tag, bool split_by_crate = true );
00087 
00088   std::map<int, boost::shared_ptr<LutXml> > getCompressionLutXmlFromCoder( const CaloTPGTranscoderULUT & _coder,
00089                                                                     std::string _tag,
00090                                                                     bool split_by_crate = true );
00091 
00092   std::map<int, boost::shared_ptr<LutXml> > getZdcLutXml( std::string _tag,
00093                                                    bool split_by_crate = true );
00094 
00095   // add two std::map<s with LUTs. Designed mainly for joining compression LUTs to linearization ones.
00096   void addLutMap(std::map<int,
00097                  boost::shared_ptr<LutXml> > & result,
00098                  const std::map<int,
00099                  boost::shared_ptr<LutXml> > & other);
00100   
00101   // read LUTs from ASCII master file. 
00102   HcalLutSet getLutSetFromFile( std::string _filename, int _type = 1 ); // _type = 1 - linearization, 2 - compression
00103 
00104   int writeLutXmlFiles( std::map<int, boost::shared_ptr<LutXml> > & _xml, std::string _tag = "default_tag", bool split_by_crate = true );
00105 
00106   int createLinLutXmlFiles( std::string _tag, std::string _lin_file, bool split_by_crate = true );
00107   int createCompLutXmlFilesFromCoder( std::string _tag, bool split_by_crate = true );
00108   int createAllLutXmlFiles( std::string _tag, std::string _lin_file, std::string _comp_file, bool split_by_crate = true );
00109   int createAllLutXmlFilesFromCoder( const HcalTPGCoder & _coder, std::string _tag, bool split_by_crate = true );
00110   int createLutXmlFiles_HBEFFromCoder_HOFromAscii( std::string _tag, const HcalTPGCoder & _coder, std::string _lin_file, bool split_by_crate = true );
00111   int createLutXmlFiles_HBEFFromCoder_HOFromAscii( std::string _tag, const HcalTPGCoder & _coder, const CaloTPGTranscoderULUT & _transcoder, std::string _lin_file, bool split_by_crate = true );
00112 
00113   int createLutXmlFiles_HBEFFromCoder_HOFromAscii_ZDC( std::string _tag, const HcalTPGCoder & _coder, const CaloTPGTranscoderULUT & _transcoder, std::string _lin_file, bool split_by_crate = true );
00114 
00115   int createAllLutXmlFilesLinAsciiCompCoder( std::string _tag, std::string _lin_file, bool split_by_crate = true );
00116 
00117   // tests
00118   //    reading LUTs from a local XML
00119   int test_xml_access( std::string _tag, std::string _filename );
00120   int test_direct_xml_parsing( std::string _filename );
00121   void test_emap(void);
00122   
00123   // connect to local XML file with LUTs and local ASCII file with LMAP
00124   // connection interface through protected members db and lmap
00125   int read_lmap( std::string lmap_hbef_file, std::string lmap_ho_file );
00126   int read_luts( std::string lut_xml_file );
00127   int local_connect( std::string lut_xml_file, std::string lmap_hbef_file, std::string lmap_ho_file );
00128 
00129   // hcal::ConfigurationDatabase::LinearizerLUT
00130   // hcal::ConfigurationDatabase::CompressionLUT
00131   std::vector<unsigned int> getLutFromXml_old( std::string tag, uint32_t _rawid, hcal::ConfigurationDatabase::LUTType _lt );
00132   std::vector<unsigned int> getLutFromXml( std::string tag, uint32_t _rawid, hcal::ConfigurationDatabase::LUTType _lt );
00133 
00134   std::map<int, boost::shared_ptr<LutXml> > get_brickSet_from_oracle( std::string tag, const std::string _accessor = "occi://CMS_HCL_PRTTYPE_HCAL_READER@anyhost/int2r?PASSWORD=HCAL_Reader_88,LHWM_VERSION=22" );
00135 
00136   int get_xml_files_from_db( std::string tag, const std::string db_accessor = "occi://CMS_HCL_PRTTYPE_HCAL_READER@anyhost/int2r?PASSWORD=HCAL_Reader_88,LHWM_VERSION=22", bool split_by_crate = true );
00137 
00138   int create_lut_loader( std::string file_list, std::string _prefix, std::string tag_name, std::string comment="default comment", std::string version="V00-01-01", int subversion=1 );
00139 
00140   // get md5 checksums for LUTs
00141   std::string get_checksum( std::vector<unsigned int> & lut );
00142 
00143   static int getInt( std::string number );
00144   static HcalSubdetector get_subdetector( std::string _subdet );
00145   static std::string get_time_stamp( time_t _time );
00146 
00147   // gives the iterator a list of channels
00148   int initChannelIterator(std::vector<HcalGenericDetId> & map);
00149 
00150  protected:
00151   
00152   LutXml * lut_xml;
00153   XMLDOMBlock * lut_checksums_xml;
00154   HCALConfigDB * db;
00155   LMap * lmap;
00156   HcalChannelIterator _iter;
00157   HcalAssistant _ass;
00158   const HcalElectronicsMap * emap;
00159   const HcalChannelQuality * cq;
00160   uint32_t status_word_to_mask;
00161 };
00162 
00163 
00164 class HcalLutManager_test{
00165  public:
00166   
00167   static int getLutXml_test( std::vector<unsigned int> & _lut ){return 0;}
00168 
00169   static int getLutSetFromFile_test( std::string _filename );
00170 
00171   static int getInt_test( std::string number );
00172 
00173  protected:
00174   LutXml * lut_xml;
00175 };
00176 
00177 #endif