CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/Geometry/HcalEventSetup/src/HcalTopologyIdealEP.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    HcalTopologyIdealEP
00004 // Class:      HcalTopologyIdealEP
00005 // 
00013 //
00014 // Original Author:  Jeremiah Mans
00015 //         Created:  Mon Oct  3 11:35:27 CDT 2005
00016 //
00017 //
00018 
00019 #include "Geometry/HcalEventSetup/interface/HcalTopologyIdealEP.h"
00020 #include "Geometry/CaloTopology/interface/HcalTopologyRestrictionParser.h"
00021 #include "FWCore/Utilities/interface/Exception.h"
00022 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00023 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00024 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00025 
00026 //
00027 // constants, enums and typedefs
00028 //
00029 
00030 //
00031 // static data member definitions
00032 //
00033 
00034 //
00035 // constructors and destructor
00036 //
00037 HcalTopologyIdealEP::HcalTopologyIdealEP(const edm::ParameterSet& conf)
00038   : m_restrictions(conf.getUntrackedParameter<std::string>("Exclude")),
00039     m_pSet( conf )
00040 {
00041   //std::cout << "HcalTopologyIdealEP::HcalTopologyIdealEP" << std::endl;
00042   edm::LogInfo("HCAL") << "HcalTopologyIdealEP::HcalTopologyIdealEP";
00043 
00044   // copied from HcalHitRelabeller, input like {1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,4}
00045   m_segmentation.resize(29);
00046   std::vector<int> segmentation;
00047   for (int iring=1; iring<=29; ++iring) {
00048     char name[10];
00049     snprintf(name,10,"Eta%d",iring);
00050     if(conf.existsAs<std::vector<int> >(name, false)) {
00051       RingSegmentation entry;
00052       entry.ring = iring;
00053       entry.segmentation = conf.getUntrackedParameter<std::vector<int> >(name);
00054       m_segmentation.push_back(entry);
00055     }
00056   }
00057   setWhatProduced(this);
00058 }
00059 
00060 
00061 HcalTopologyIdealEP::~HcalTopologyIdealEP()
00062 { 
00063 }
00064 
00065 void
00066 HcalTopologyIdealEP::fillDescriptions( edm::ConfigurationDescriptions & descriptions ) 
00067 {
00068   edm::ParameterSetDescription hcalTopologyConstants;
00069   hcalTopologyConstants.add<std::string>( "mode", "HcalTopologyMode::LHC" );
00070   hcalTopologyConstants.add<int>( "maxDepthHB", 2 );
00071   hcalTopologyConstants.add<int>( "maxDepthHE", 3 );  
00072 
00073   edm::ParameterSetDescription hcalSLHCTopologyConstants;
00074   hcalSLHCTopologyConstants.add<std::string>( "mode", "HcalTopologyMode::SLHC" );
00075   hcalSLHCTopologyConstants.add<int>( "maxDepthHB", 7 );
00076   hcalSLHCTopologyConstants.add<int>( "maxDepthHE", 7 );
00077 
00078   edm::ParameterSetDescription desc;
00079   desc.addUntracked<std::string>( "Exclude", "" );
00080   desc.addOptional<edm::ParameterSetDescription>( "hcalTopologyConstants", hcalTopologyConstants );
00081   descriptions.add( "hcalTopologyIdeal", desc );
00082 
00083   edm::ParameterSetDescription descSLHC;
00084   descSLHC.addUntracked<std::string>( "Exclude", "" );
00085   descSLHC.addOptional<edm::ParameterSetDescription>( "hcalTopologyConstants", hcalSLHCTopologyConstants );
00086   descriptions.add( "hcalTopologyIdealSLHC", descSLHC );  
00087 }
00088 
00089 //
00090 // member functions
00091 //
00092 
00093 // ------------ method called to produce the data  ------------
00094 HcalTopologyIdealEP::ReturnType
00095 HcalTopologyIdealEP::produce(const IdealGeometryRecord& iRecord)
00096 {
00097   //   std::cout << "HcalTopologyIdealEP::produce(const IdealGeometryRecord& iRecord)" << std::endl;
00098   edm::LogInfo("HCAL") <<  "HcalTopologyIdealEP::produce(const IdealGeometryRecord& iRecord)";
00099     
00100   using namespace edm::es;
00101 
00102   HcalTopologyMode::Mode mode = HcalTopologyMode::LHC;
00103   int maxDepthHB = 2;
00104   int maxDepthHE = 3;
00105   if( m_pSet.exists( "hcalTopologyConstants" ))
00106   {
00107     const edm::ParameterSet hcalTopoConsts( m_pSet.getParameter<edm::ParameterSet>( "hcalTopologyConstants" ));
00108     StringToEnumParser<HcalTopologyMode::Mode> eparser;
00109     mode = (HcalTopologyMode::Mode) eparser.parseString(hcalTopoConsts.getParameter<std::string>("mode"));
00110     maxDepthHB = hcalTopoConsts.getParameter<int>("maxDepthHB");
00111     maxDepthHE = hcalTopoConsts.getParameter<int>("maxDepthHE");
00112   }
00113   //  std::cout << "mode = " << mode << ", maxDepthHB = " << maxDepthHB << ", maxDepthHE = " << maxDepthHE << std::endl;
00114   edm::LogInfo("HCAL") << "mode = " << mode << ", maxDepthHB = " << maxDepthHB << ", maxDepthHE = " << maxDepthHE;
00115 
00116   ReturnType myTopo(new HcalTopology( mode, maxDepthHB, maxDepthHE ));
00117 
00118   HcalTopologyRestrictionParser parser(*myTopo);
00119   if (!m_restrictions.empty()) {
00120     std::string error=parser.parse(m_restrictions);
00121     if (!error.empty()) {
00122       throw cms::Exception("Parse Error","Parse error on Exclude "+error);
00123     }
00124   }
00125 
00126   // see if any depth segmentation needs to be added
00127   for(std::vector<RingSegmentation>::const_iterator ringSegItr = m_segmentation.begin();
00128       ringSegItr != m_segmentation.end(); ++ringSegItr) {
00129     myTopo->setDepthSegmentation(ringSegItr->ring, ringSegItr->segmentation);
00130   } 
00131   return myTopo ;
00132 }
00133 
00134