Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:48:27

0001 #include "Geometry/HGCalCommonData/interface/FastTimeParametersFromDD.h"
0002 #include "DetectorDescription/Core/interface/DDCompactView.h"
0003 #include "DetectorDescription/Core/interface/DDFilteredView.h"
0004 #include "DetectorDescription/Core/interface/DDutils.h"
0005 #include "Geometry/HGCalCommonData/interface/FastTimeParameters.h"
0006 
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 
0009 //#define EDM_ML_DEBUG
0010 
0011 bool FastTimeParametersFromDD::build(const DDCompactView* cpv,
0012                                      FastTimeParameters& php,
0013                                      const std::string& name,
0014                                      const int type) {
0015 #ifdef EDM_ML_DEBUG
0016   edm::LogVerbatim("HGCalGeom") << "FastTimeParametersFromDD::build called with names " << name << " and type " << type;
0017 #endif
0018 
0019   // Special parameters at simulation level
0020   std::string attribute = "Volume";
0021   const std::string& value = name;
0022   DDValue val(attribute, value, 0.0);
0023   DDSpecificsMatchesValueFilter filter{val};
0024   DDFilteredView fv(*cpv, filter);
0025   bool ok = fv.firstChild();
0026 
0027   if (ok) {
0028     DDsvalues_type sv(fv.mergedSpecifics());
0029     std::vector<double> temp;
0030     if (type == 1) {
0031       php.geomParBarrel_ = getDDDArray("geomParsB", sv);
0032       temp = getDDDArray("numberZB", sv);
0033       php.nZBarrel_ = (int)(temp[0]);
0034       temp = getDDDArray("numberPhiB", sv);
0035       php.nPhiBarrel_ = (int)(temp[0]);
0036 #ifdef EDM_ML_DEBUG
0037       edm::LogVerbatim("HGCalGeom") << "Barrel Parameters: " << php.nZBarrel_ << ":" << php.nPhiBarrel_ << ":"
0038                                     << php.geomParBarrel_[0] << ":" << php.geomParBarrel_[1];
0039 #endif
0040     } else if (type == 2) {
0041       php.geomParEndcap_ = getDDDArray("geomParsE", sv);
0042       temp = getDDDArray("numberEtaE", sv);
0043       php.nEtaEndcap_ = (int)(temp[0]);
0044       temp = getDDDArray("numberPhiE", sv);
0045       php.nPhiEndcap_ = (int)(temp[0]);
0046 #ifdef EDM_ML_DEBUG
0047       edm::LogVerbatim("HGCalGeom") << "Endcap Parameters: " << php.nEtaEndcap_ << ":" << php.nPhiEndcap_ << ":"
0048                                     << php.geomParEndcap_[0] << ":" << php.geomParEndcap_[1] << ":"
0049                                     << php.geomParEndcap_[2];
0050 #endif
0051     } else {
0052       edm::LogWarning("HGCalGeom") << "Unknown Geometry type " << type << " for FastTiming " << name;
0053     }
0054   } else {
0055     edm::LogError("HGCalGeom") << " Attribute " << val << " not found but needed.";
0056     throw cms::Exception("DDException") << "Attribute " << val << " not found but needed.";
0057   }
0058 #ifdef EDM_ML_DEBUG
0059   edm::LogVerbatim("HGCalGeom") << "FastTimeParametersFromDD::Returns with flag " << ok << " for " << name
0060                                 << " and type " << type;
0061 #endif
0062   return ok;
0063 }
0064 
0065 std::vector<double> FastTimeParametersFromDD::getDDDArray(const std::string& str, const DDsvalues_type& sv) {
0066   DDValue value(str);
0067   if (DDfetch(&sv, value)) {
0068     const std::vector<double>& fvec = value.doubles();
0069     int nval = fvec.size();
0070     if (nval < 1) {
0071       edm::LogError("HGCalGeom") << "HGCalGeomParameters : # of " << str << " bins " << nval << " < 1 ==> illegal";
0072       throw cms::Exception("DDException") << "HGCalGeomParameters: cannot get array " << str;
0073     }
0074     return fvec;
0075   } else {
0076     edm::LogError("HGCalGeom") << "HGCalGeomParameters: cannot get array " << str;
0077     throw cms::Exception("DDException") << "HGCalGeomParameters: cannot get array " << str;
0078   }
0079 }