CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 // Last commit: $Id: SiStripCondObjBuilderFromDb.h,v 1.11 2011/09/19 08:32:24 demattia Exp $
00002 // Latest tag:  $Name: V05-01-03 $
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, SiStripConfigDb::DeviceDescriptionsRange apvs);
00119   bool setValuesApvTiming(SiStripConfigDb* const db, FedChannelConnection &ipair);
00120   //  bool setValuesCabling(SiStripConfigDb* const db, FedChannelConnection &ipair, uint32_t detid);
00121   bool setValuesCabling(SiStripConfigDb::FedDescriptionsRange &descriptions, FedChannelConnection &ipair, uint32_t detid);
00122   bool retrieveFedDescriptions(SiStripConfigDb* const db);
00123   bool retrieveTimingAnalysisDescriptions( SiStripConfigDb* const db);
00124   vector<uint32_t> retrieveActiveDetIds(const SiStripDetCabling& det_cabling);
00125   vector<const FedChannelConnection *> buildConnections(const SiStripDetCabling& det_cabling, uint32_t det_id );
00126   uint16_t retrieveNumberAPVPairs(uint32_t det_id);
00127  
00128   //set and store data
00129   void setDefaultValuesCabling(uint16_t apvPair);
00130   void setDefaultValuesApvTiming();
00131   void setDefaultValuesApvLatency(SiStripLatency & latency_, FedChannelConnection ipair, uint32_t detid, uint16_t apvnr);
00132   void storePedestals(uint32_t det_id);
00133   void storeNoise(uint32_t det_id);
00134   void storeThreshold(uint32_t det_id);
00135   void storeQuality(uint32_t det_id);
00136   void storeTiming(uint32_t det_id);
00137   
00138   
00139   // cfi input parameters
00140   float m_gaincalibrationfactor;
00141   float m_defaultpedestalvalue;
00142   float m_defaultnoisevalue;
00143   float m_defaultthresholdhighvalue;
00144   float m_defaultthresholdlowvalue;
00145   uint16_t  m_defaultapvmodevalue;
00146   uint16_t  m_defaultapvlatencyvalue;
00147   float m_defaulttickheightvalue;
00148   bool m_useanalysis;
00149   bool m_usefed;
00150   bool m_usefec;
00151   bool m_debug;
00152 
00153   //Data containers
00154   SiStripPedestals::InputVector inputPedestals;
00155   SiStripNoises::InputVector inputNoises;
00156   SiStripThreshold::InputVector inputThreshold;
00157   SiStripQuality::InputVector inputQuality;
00158   SiStripApvGain::InputVector inputApvGain;
00159   
00160 
00161   // Tracker Cabling objects
00162   pair_apvpairconn p_apvpcon;
00163   v_apvpairconn v_apvpcon;
00164   pair_detcon p_detcon;
00165   trackercon v_trackercon;
00166 
00167  };
00168 
00169 #endif // OnlineDB_SiStripESSources_SiStripCondObjBuilderFromDb_H
00170