CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/OnlineDB/SiStripESSources/interface/SiStripCondObjBuilderFromDb.h

Go to the documentation of this file.
00001 // Last commit: $Id: SiStripCondObjBuilderFromDb.h,v 1.8 2009/12/10 10:18:55 alinn Exp $
00002 // Latest tag:  $Name: V05-00-02-05 $
00003 // Location:    $Source: /local/reps/CMSSW/CMSSW/OnlineDB/SiStripESSources/interface/SiStripCondObjBuilderFromDb.h,v $
00004 
00005 #ifndef OnlineDB_SiStripESSources_SiStripCondObjBuilderFromDb_H
00006 #define OnlineDB_SiStripESSources_SiStripCondObjBuilderFromDb_H
00007 
00008 #include "FWCore/ServiceRegistry/interface/Service.h"
00009 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
00010 #include "OnlineDB/SiStripConfigDb/interface/SiStripConfigDb.h"
00011 #include "OnlineDB/SiStripConfigDb/interface/SiStripDbParams.h"
00012 #include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h"
00013 
00014 
00015 #include "OnlineDB/SiStripESSources/interface/SiStripCondObjBuilderFromDb.h"
00016 #include "OnlineDB/SiStripESSources/interface/SiStripFedCablingBuilderFromDb.h"
00017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00018 #include "DataFormats/SiStripCommon/interface/SiStripFecKey.h"
00019 #include "DataFormats/SiStripCommon/interface/SiStripFedKey.h"
00020 #include "CondFormats/SiStripObjects/interface/SiStripPedestals.h"
00021 #include "CondFormats/SiStripObjects/interface/SiStripNoises.h"
00022 #include "CondFormats/SiStripObjects/interface/SiStripThreshold.h"
00023 #include "CondFormats/SiStripObjects/interface/SiStripApvGain.h"
00024 #include "CondFormats/SiStripObjects/interface/SiStripLatency.h"
00025 #include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h"
00026 #include "CondFormats/SiStripObjects/interface/FedChannelConnection.h"
00027 #include "CalibFormats/SiStripObjects/interface/SiStripFecCabling.h"
00028 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
00029 #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
00030 #include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"
00031 
00032 #include "boost/cstdint.hpp"
00033 #include <vector>
00034 #include <string>
00035 
00036 class SiStripFecCabling;
00037 class SiStripDetCabling;
00038 class SiStripPedestals;
00039 class SiStripNoises;
00040 class SiStripQuality;
00041 class SiStripThreshold;
00042 class DcuDetIdMap;
00043 class SiStripApvGain;
00044 class SiStripLatency;
00045 
00046 class SiStripCondObjBuilderFromDb {
00047   
00048  public:
00049 
00050    // Typedefs
00051   typedef std::pair<uint32_t,FedChannelConnection> pair_apvpairconn;
00052   typedef std::vector<pair_apvpairconn> v_apvpairconn;
00053   typedef std::pair<uint32_t, v_apvpairconn> pair_detcon;
00054   typedef std::vector<pair_detcon> trackercon;
00055 
00056   typedef std::vector<pair_detcon>::iterator i_trackercon;
00057   typedef std::vector<pair_apvpairconn>::iterator i_apvpairconn;
00058 
00059  
00060   SiStripCondObjBuilderFromDb();
00061   SiStripCondObjBuilderFromDb(const edm::ParameterSet&,
00062                               const edm::ActivityRegistry&);
00063   virtual ~SiStripCondObjBuilderFromDb();
00064   
00066   inline const SiStripDbParams& dbParams() const {return db_->dbParams();} 
00067 
00070   void buildCondObj();
00071   void buildStripRelatedObjects( SiStripConfigDb* const db,
00072                                  const SiStripDetCabling& det_cabling);
00073   void buildAnalysisRelatedObjects( SiStripConfigDb* const db, trackercon tc);
00074   void buildFECRelatedObjects( SiStripConfigDb* const db, trackercon tc);
00075   void buildFEDRelatedObjects( SiStripConfigDb* const db, trackercon tc);
00076                                 
00077 
00078   bool checkForCompatibility(std::stringstream& input,std::stringstream& output,std::string& label);
00079 
00080   SiStripFedCabling*  getFedCabling() {checkUpdate(); return fed_cabling_;}
00081   SiStripPedestals *  getPedestals()  {checkUpdate(); return pedestals_;}  
00082   SiStripNoises    *  getNoises()     {checkUpdate(); return noises_;}  
00083   SiStripThreshold *  getThreshold()  {checkUpdate(); return threshold_;}  
00084   SiStripQuality   *  getQuality()    {checkUpdate(); return quality_;}  
00085   SiStripApvGain* getApvGain() { checkUpdate(); return gain_; }  
00086   SiStripLatency* getApvLatency() { checkUpdate(); return latency_; }
00087 
00088   void getValue(SiStripFedCabling* & val){ val = getFedCabling();}
00089   void getValue(SiStripPedestals * & val){ val = getPedestals(); }  
00090   void getValue(SiStripNoises    * & val){ val = getNoises();    }  
00091   void getValue(SiStripThreshold * & val){ val = getThreshold(); }  
00092   void getValue(SiStripQuality   * & val){ val = getQuality();   }  
00093   void getValue(SiStripBadStrip  * & val){ val = new SiStripBadStrip(* (const SiStripBadStrip*) getQuality());   }  
00094   void getValue( SiStripApvGain*& val ){ val = getApvGain(); }  
00095   void getValue( SiStripLatency*& val ){ val = getApvLatency(); }  
00096 
00097 
00098  protected:
00099   
00100   void checkUpdate();
00101   
00103   // Build and retrieve SiStripConfigDb object using service
00104   edm::Service<SiStripConfigDb> db_;
00105   
00107   SiStripDbParams dbParams_;
00108   SiStripFedCabling  *fed_cabling_;
00109   SiStripPedestals   *pedestals_;  
00110   SiStripNoises      *noises_;  
00111   SiStripThreshold   *threshold_;  
00112   SiStripQuality     *quality_;  
00113   SiStripApvGain     *gain_;
00114   SiStripLatency* latency_;
00115 
00116  
00117   //methods used by BuildStripRelatedObjects
00118   bool setValuesApvLatency(SiStripLatency & latency_, SiStripConfigDb* const db, FedChannelConnection &ipair, uint32_t detid, uint16_t apvnr);
00119   bool setValuesApvTiming(SiStripConfigDb* const db, FedChannelConnection &ipair);
00120   bool setValuesCabling(SiStripConfigDb* const db, FedChannelConnection &ipair, uint32_t detid);
00121   bool retrieveFedDescriptions(SiStripConfigDb* const db);
00122   bool retrieveTimingAnalysisDescriptions( SiStripConfigDb* const db);
00123   vector<uint32_t> retrieveActiveDetIds(const SiStripDetCabling& det_cabling);
00124   vector<FedChannelConnection> buildConnections(const SiStripDetCabling& det_cabling, uint32_t det_id );
00125   uint16_t retrieveNumberAPVPairs(uint32_t det_id);
00126  
00127   //set and store data
00128   void setDefaultValuesCabling(uint16_t apvPair);
00129   void setDefaultValuesApvTiming();
00130   void setDefaultValuesApvLatency(SiStripLatency & latency_, FedChannelConnection ipair, uint16_t apvnr);
00131   void storePedestals(uint32_t det_id);
00132   void storeNoise(uint32_t det_id);
00133   void storeThreshold(uint32_t det_id);
00134   void storeQuality(uint32_t det_id);
00135   void storeTiming(uint32_t det_id);
00136   
00137   
00138   // cfi input parameters
00139   float m_gaincalibrationfactor;
00140   float m_defaultpedestalvalue;
00141   float m_defaultnoisevalue;
00142   float m_defaultthresholdhighvalue;
00143   float m_defaultthresholdlowvalue;
00144   uint16_t  m_defaultapvmodevalue;
00145   uint16_t  m_defaultapvlatencyvalue;
00146   float m_defaulttickheightvalue;
00147   bool m_useanalysis;
00148   bool m_usefed;
00149   bool m_usefec;
00150   bool m_debug;
00151 
00152   //Data containers
00153   SiStripPedestals::InputVector inputPedestals;
00154   SiStripNoises::InputVector inputNoises;
00155   SiStripThreshold::InputVector inputThreshold;
00156   SiStripQuality::InputVector inputQuality;
00157   SiStripApvGain::InputVector inputApvGain;
00158   
00159 
00160   // Tracker Cabling objects
00161   pair_apvpairconn p_apvpcon;
00162   v_apvpairconn v_apvpcon;
00163   pair_detcon p_detcon;
00164   trackercon v_trackercon;
00165 
00166  };
00167 
00168 #endif // OnlineDB_SiStripESSources_SiStripCondObjBuilderFromDb_H
00169